| | |
| | | if(Objects.isNull(category) |
| | | || Objects.isNull(category.getType()) |
| | | || Objects.isNull(category.getName()) |
| | | || (!Constants.equalsInteger(category.getType(),Constants.ZERO)&& CollectionUtils.isEmpty(category.getDetailList())) |
| | | || (Constants.equalsInteger(category.getType(),Constants.ONE) && (Objects.isNull(category.getIcon())||Objects.isNull(category.getIsFixed())) ) |
| | | || StringUtils.isBlank(category.getDetail()) |
| | | ){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST); |
| | | } |
| | | validateByType(category); |
| | | LoginUserInfo loginUserInfo = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal(); |
| | | category.setDeleted(Constants.ZERO); |
| | | category.setCreateTime(new Date()); |
| | | category.setCreateUser(loginUserInfo.getId()); |
| | | category.setUpdateTime(new Date()); |
| | | category.setUpdateUser(loginUserInfo.getId()); |
| | | if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(category.getDetailList()) |
| | | && !Constants.equalsInteger(category.getType(),Constants.THREE)){ |
| | | category.setDetail(category.getDetailList().toJSONString()); |
| | | } |
| | | if(!Constants.equalsInteger(category.getType(),Constants.ONE)){ |
| | | category.setIsFixed(Constants.ZERO); |
| | | } |
| | | categoryMapper.insert(category); |
| | | return category.getId(); |
| | | } |
| | |
| | | || Objects.isNull(category.getId()) |
| | | || Objects.isNull(category.getType()) |
| | | || Objects.isNull(category.getName()) |
| | | || (!Constants.equalsInteger(category.getType(),Constants.ZERO)&& CollectionUtils.isEmpty(category.getDetailList())) |
| | | || (Constants.equalsInteger(category.getType(),Constants.ONE) && (Objects.isNull(category.getIcon())||Objects.isNull(category.getIsFixed())) ) |
| | | || StringUtils.isBlank(category.getDetail()) |
| | | ){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST); |
| | | } |
| | | validateByType(category); |
| | | LoginUserInfo loginUserInfo = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal(); |
| | | category.setUpdateTime(new Date()); |
| | | category.setIsFixed(null); |
| | | category.setUpdateUser(loginUserInfo.getId()); |
| | | if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(category.getDetailList()) |
| | | && !Constants.equalsInteger(category.getType(),Constants.THREE)){ |
| | | category.setDetail(category.getDetailList().toJSONString()); |
| | | } |
| | | categoryMapper.updateById(category); |
| | | } |
| | | @Override |
| | |
| | | } |
| | | LoginUserInfo loginUserInfo = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal(); |
| | | category.setUpdateTime(new Date()); |
| | | category.setIsFixed(null); |
| | | category.setUpdateUser(loginUserInfo.getId()); |
| | | if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(category.getDetailList())){ |
| | | category.setDetail(category.getDetailList().toJSONString()); |
| | | } |
| | | categoryMapper.updateById(category); |
| | | } |
| | | |
| | |
| | | Category category = categoryMapper.selectById(id); |
| | | if(Objects.isNull(category)){ |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY); |
| | | } |
| | | if(StringUtils.isNotBlank(category.getDetail())){ |
| | | category.setDetailList(JSONArray.parseArray(category.getDetail())); |
| | | } |
| | | if(StringUtils.isNotBlank(category.getIcon())){ |
| | | String path = systemDictDataBiz.queryByCode(Constants.SYSTEM,Constants.RESOURCE_PATH).getCode() |
| | |
| | | if (pageWrap.getModel().getIcon() != null) { |
| | | queryWrapper.eq(Category::getIcon, pageWrap.getModel().getIcon()); |
| | | } |
| | | if (pageWrap.getModel().getIsFixed() != null) { |
| | | queryWrapper.eq(Category::getIsFixed, pageWrap.getModel().getIsFixed()); |
| | | } |
| | | queryWrapper.orderByAsc(Category::getSortnum); |
| | | PageData<Category> result =PageData.from(categoryMapper.selectJoinPage(page, Category.class,queryWrapper)); |
| | | if(result!=null && result.getRecords()!=null){ |
| | |
| | | +systemDictDataBiz.queryByCode(Constants.SYSTEM,Constants.CATEGORY_FILES).getCode(); |
| | | for(Category cate : result.getRecords()){ |
| | | try { |
| | | if(StringUtils.isNotBlank(cate.getDetail())){ |
| | | cate.setDetailList(JSONArray.parseArray(cate.getDetail())); |
| | | } |
| | | if(StringUtils.isNotBlank(cate.getIcon())){ |
| | | cate.setIconFull(path + cate.getIcon()); |
| | | } |
| | |
| | | String path = systemDictDataBiz.queryByCode(Constants.SYSTEM,Constants.RESOURCE_PATH).getCode() |
| | | +systemDictDataBiz.queryByCode(Constants.SYSTEM,Constants.CATEGORY_FILES).getCode(); |
| | | for (Category category:categoryList) { |
| | | if(StringUtils.isNotBlank(category.getDetail())){ |
| | | category.setDetailList(JSONArray.parseArray(category.getDetail())); |
| | | } |
| | | if(StringUtils.isNotBlank(category.getIcon())){ |
| | | category.setIconFull(path + category.getIcon()); |
| | | } |
| | |
| | | return categoryList; |
| | | } |
| | | |
| | | private void validateByType(Category category) { |
| | | if (Constants.equalsInteger(category.getType(), Constants.ONE)) { |
| | | if (StringUtils.isBlank(category.getOtherField())) { |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "车辆类型必须填写附属字段"); |
| | | } |
| | | } else if (Constants.equalsInteger(category.getType(), Constants.TWO)) { |
| | | if (Objects.isNull(category.getRelationId())) { |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "物品分类必须选择关联物品等级"); |
| | | } |
| | | } else if (Constants.equalsInteger(category.getType(), Constants.FOUR)) { |
| | | if (StringUtils.isBlank(category.getIcon())) { |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "物品尺寸必须上传图标"); |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |