package com.mortals.xhx.module.product.web;

import com.mortals.framework.model.Context;
import com.mortals.framework.web.BaseCRUDJsonBodyMappingController;
import com.mortals.xhx.base.system.param.service.ParamService;
import com.mortals.xhx.module.platform.model.PlatformQuery;
import com.mortals.xhx.module.platform.service.PlatformService;
import com.mortals.xhx.module.product.model.ProductEntity;
import com.mortals.xhx.module.product.service.ProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;
import java.util.stream.Collectors;

/**
*
* 产品
*
* @author zxfei
* @date 2022-06-27
*/
@RestController
@RequestMapping("product")
public class ProductController extends BaseCRUDJsonBodyMappingController<ProductService,ProductEntity,Long> {

    @Autowired
    private ParamService paramService;
    @Autowired
    private PlatformService platformService;

    public ProductController(){
        super.setModuleDesc( "产品");
    }

    @Override
    protected void init(Map<String, Object> model, Context context) {
        this.addDict(model,"platformId",platformService.find(new PlatformQuery()).stream().collect(Collectors.toMap(x->x.getId().toString(),y->y.getPlatformName())));
        super.init(model, context);
    }


}