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
@@ -61,6 +69,25 @@
    @RequestMapping(value = "/item/add/auth")
    @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());
@@ -74,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);
@@ -85,14 +129,18 @@
    @RequestMapping(value = "/item/delete/auth")
    @ManagerAuth
    public R delete(@RequestParam String param){
        List<Item> list = JSONArray.parseArray(param, Item.class);
        if (Cools.isEmpty(list)){
            return R.error();
    public R delete(@RequestParam("ids[]") String param){
        if (param != null){
            itemService.delete(new EntityWrapper<Item>()
                    .eq("id",param));
        }
        for (Item entity : list){
            itemService.delete(new EntityWrapper<>(entity));
        }
//        List<Item> list = JSONArray.parseArray(param, Item.class);
//        if (Cools.isEmpty(list)){
//            return R.error();
//        }
//        for (Item entity : list){
//            itemService.delete(new EntityWrapper<>(entity));
//        }
        return R.ok();
    }