futian.liu
2023-11-23 5112320c542900d9e79bbc0938b195a43e3fc255
consum-base/src/main/java/com/consum/base/controller/BaseCategoryController.java
@@ -2,18 +2,26 @@
import com.consum.base.BaseController;
import com.consum.base.pojo.BaseCategoryParam;
import com.consum.base.pojo.ProjectTreeResult;
import com.consum.base.service.BaseCategoryServiceImpl;
import com.consum.base.service.BaseGoodsTemplateServiceImpl;
import com.consum.model.po.BaseCategory;
import com.iplatform.model.po.S_user_core;
import com.walker.db.page.GenericPager;
import com.walker.infrastructure.tree.TreeNode;
import com.walker.infrastructure.utils.StringUtils;
import com.walker.web.ResponseValue;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
 * @Description 物品分类
@@ -29,6 +37,23 @@
    @Autowired
    private BaseGoodsTemplateServiceImpl baseGoodsTemplateService;
    private boolean multiRoot = true;
    private TreeNode dummyRoot = null;
    private Map<Long, TreeNode> rootMap = new TreeMap();
    private Map<Long, TreeNode> childMap = new TreeMap();
    private long defaultParentId = 0L;
    /**
     * @Description 获取分类树
     * @Author 卢庆阳
     * @Date 2023/10/30
     */
    @GetMapping("/select/tree")
    public ResponseValue tree(String categoryName) {
        List<ProjectTreeResult> tree = this.baseCategoryService.tree();
        return ResponseValue.success(tree);
    }
    /**
     * @Description 新增分类
@@ -50,7 +75,9 @@
        }
        int result = this.baseCategoryService.add(param, this.getCurrentUser());
        if (result > 0) return ResponseValue.success(1);
        if (result > 0) {
            return ResponseValue.success(1);
        }
        return ResponseValue.error("新增失败!");
    }
@@ -68,6 +95,7 @@
        GenericPager<BaseCategory> pager = this.baseCategoryService.queryBaseCategoryList(param);
        return ResponseValue.success(pager);
    }
    /**
     * @Description 编辑
@@ -97,6 +125,7 @@
    /**
     * 修改状态
     *
     * @author 卢庆阳
     * @date 2023/10/23
     */
@@ -126,13 +155,14 @@
        if (baseCategory.getId() == null) {
            return ResponseValue.error("分类id为空");
        }
        int num = this.baseCategoryService.updateById(baseCategory,this.getCurrentUser());
        int num = this.baseCategoryService.updateById(baseCategory, this.getCurrentUser());
        return num > 0 ? ResponseValue.success(1) : ResponseValue.error("删除失败!");
    }
    /**
     * 根据物品id查询节点详情
     *
     * @author 卢庆阳
     * @Date 2023/10/23
     */
@@ -142,8 +172,27 @@
            return ResponseValue.error("分类id为空");
        }
        BaseCategory baseCategory = this.baseCategoryService.getById(id);
        if (baseCategory == null) return ResponseValue.error("查询失败!");
        if (baseCategory == null) {
            return ResponseValue.error("查询失败!");
        }
        return ResponseValue.success("查询成功!", baseCategory);
    }
    /**
     * @Description 三级分类列表查询
     * @Author 卢庆阳
     * @Date 2023/10/24
     */
    @GetMapping("/select/lv3_tree")
    public ResponseValue tree() {
        S_user_core currentUser = this.getCurrentUser();
        if (currentUser == null) {
            return ResponseValue.error("登录用户信息不存在");
        }
        List<BaseCategory> baseCategories = this.baseCategoryService.queryForLv3Tree();
        return ResponseValue.success(baseCategories);
    }
}