mrzhssss
2022-01-10 bbb54c1ab65d141219dfbf7efb2af086522667a0
src/main/java/zy/cloud/wms/manager/controller/ItemController.java
@@ -13,8 +13,12 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import zy.cloud.wms.common.web.BaseController;
import zy.cloud.wms.manager.entity.Cstmr;
import zy.cloud.wms.manager.entity.Item;
import zy.cloud.wms.manager.entity.ProjectType;
import zy.cloud.wms.manager.service.CstmrService;
import zy.cloud.wms.manager.service.ItemService;
import zy.cloud.wms.manager.service.ProjectTypeService;
import java.util.*;
@@ -23,6 +27,10 @@
    @Autowired
    private ItemService itemService;
    @Autowired
    private CstmrService cstmrService;
    @Autowired
    private ProjectTypeService projectTypeService;
    @RequestMapping(value = "/item/{id}/auth")
    @ManagerAuth
@@ -62,6 +70,24 @@
    @ManagerAuth
    public R add(Item item) {
        if (Cools.isEmpty(item)) {
            return R.error("参数为空,请联系管理员");
        }
        Cstmr user_code = cstmrService.selectOne(new EntityWrapper<Cstmr>()
                .eq("user_code", item.getCstmrUuid()));
        if (!Cools.isEmpty(user_code)) {
            item.setCstmr(user_code.getName());
        }else {
            return R.error("参数错误,请输入正确的客户编号");
        }
        ProjectType id = projectTypeService.selectOne(new EntityWrapper<ProjectType>()
                .eq("id", item.getType()));
        if (!Cools.isEmpty(id)) {
            item.setType(id.getTypeName());
        }else {
            return R.error("参数错误,找不到该项目类型");
        }
        item.setHostId(getHostId());
        item.setCreateBy(getUserId());
        item.setCreateTime(new Date());
@@ -75,9 +101,26 @@
   @RequestMapping(value = "/item/update/auth")
   @ManagerAuth
    public R update(Item item){
        if (Cools.isEmpty(item) || null==item.getUuid()){
            return R.error();
        if (Cools.isEmpty(item)) {
            return R.error("参数为空,请联系管理员");
        }
        Cstmr user_code = cstmrService.selectOne(new EntityWrapper<Cstmr>()
                .eq("user_code", item.getCstmrUuid()));
        if (!Cools.isEmpty(user_code)) {
            item.setCstmr(user_code.getName());
        }else {
            return R.error("参数错误,请输入正确的客户编号");
        }
        ProjectType id = projectTypeService.selectOne(new EntityWrapper<ProjectType>()
                .eq("id", item.getType()));
        if (!Cools.isEmpty(id)) {
            item.setType(id.getTypeName());
        }else {
            return R.error("参数错误,找不到该项目类型");
        }
//        if (Cools.isEmpty(item) || null==item.getUuid()){
//            return R.error();
//        }
        item.setUpdateBy(getUserId());
        item.setUpdateTime(new Date());
        itemService.updateById(item);