111
rk
2025-09-28 42c0d9901e9adbfbeea4a5abb1d901196ea0ffcb
server/services/src/main/java/com/doumee/service/business/impl/CategoryServiceImpl.java
@@ -21,6 +21,7 @@
import com.github.yulichang.base.MPJBaseMapper;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.SecurityUtils;
import org.checkerframework.checker.units.qual.C;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -56,11 +57,14 @@
        ){
            throw new BusinessException(ResponseStatus.BAD_REQUEST);
        }
        LoginUserInfo loginUserInfo = category.getLoginUserInfo();
        category.setCreateTime(new Date());
        LoginUserInfo loginUserInfo = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal();
        category.setDeleted(Constants.ZERO);
        category.setCreateTime(new Date());
        category.setCreateUser(loginUserInfo.getId());
        if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(category.getDetailList())){
        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)){
@@ -103,7 +107,23 @@
        ){
            throw new BusinessException(ResponseStatus.BAD_REQUEST);
        }
        LoginUserInfo loginUserInfo = category.getLoginUserInfo();
        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
    public void updateStatus(Category category) {
        if(Objects.isNull(category)
                || Objects.isNull(category.getId())){
            throw new BusinessException(ResponseStatus.BAD_REQUEST);
        }
        LoginUserInfo loginUserInfo = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal();
        category.setUpdateTime(new Date());
        category.setIsFixed(null);
        category.setUpdateUser(loginUserInfo.getId());
@@ -228,4 +248,27 @@
        QueryWrapper<Category> wrapper = new QueryWrapper<>(category);
        return categoryMapper.selectCount(wrapper);
    }
    @Override
    public List<Category> getCategoryList(Integer type){
        List<Category> categoryList = categoryMapper.selectList(new QueryWrapper<Category>().lambda().eq(Category::getDeleted,Constants.ZERO).eq(Category::getStatus,Constants.ZERO)
                .eq(Objects.nonNull(type),Category::getType,type)
                .orderByAsc(Category::getSortnum)
        );
        if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(categoryList)){
            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;
    }
}