| | |
| | | package com.consum.base.controller; |
| | | |
| | | import java.util.List; |
| | | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.util.CollectionUtils; |
| | | 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.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import com.consum.base.BaseController; |
| | | import com.consum.base.core.utils.CommonUtil; |
| | | import com.consum.base.pojo.BaseCategoryParam; |
| | |
| | | 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 io.swagger.annotations.Api; |
| | | 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.DeleteMapping; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | /** |
| | | * @Description 物品分类 |
| | |
| | | |
| | | @Autowired |
| | | private BaseGoodsTemplateService 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 获取分类树 |
| | |
| | | if (param.getOrderNumber() == null) { |
| | | return ResponseValue.error("顺序号为空"); |
| | | } |
| | | //判断同一父类id下分类名称是否重复 |
| | | BaseCategory category = this.baseCategoryService.getByCategoryNameAndFatherCategoryId(param.getCategoryName(), param.getFatherCategoryId()); |
| | | // 判断同一父类id下分类名称是否重复 |
| | | BaseCategory category = this.baseCategoryService.getByCategoryNameAndFatherCategoryId(param.getCategoryName(), |
| | | param.getFatherCategoryId()); |
| | | if (category != null) { |
| | | return ResponseValue.error("分类名称已存在"); |
| | | } |
| | |
| | | GenericPager<BaseCategory> pager = this.baseCategoryService.queryBaseCategoryList(param); |
| | | return ResponseValue.success(pager); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * @Description 编辑 |
| | |
| | | * @author 卢庆阳 |
| | | * @date 2023/10/23 |
| | | */ |
| | | //分类下有正常状态的物品时,不允许禁用 |
| | | // 分类下有正常状态的物品时,不允许禁用 |
| | | @PostMapping("/updStatus") |
| | | public ResponseValue updateStatus() { |
| | | BaseCategory baseCategory = CommonUtil.getObjFromReqBody(BaseCategory.class); |
| | |
| | | if (baseCategory == null || baseCategory.getId() == null || baseCategory.getStates() == null) { |
| | | return ResponseValue.error("参数错误"); |
| | | } |
| | | //根据分类id和状态查询物品模版 |
| | | // 根据分类id和状态查询物品模版 |
| | | List<BaseCategory> list = this.baseGoodsTemplateService.getByCategoryId(baseCategory.getId()); |
| | | if (baseCategory.getStates() == 2 && !CollectionUtils.isEmpty(list)) { |
| | | return ResponseValue.error("分类下有正常状态的物品,不允许禁用"); |
| | |
| | | } |
| | | |
| | | } |
| | | |