rk
2025-09-28 2304d7b140c5c5b4bf3a83f9ced8bff37d20c42e
server/services/src/main/java/com/doumee/service/business/impl/CategoryServiceImpl.java
@@ -25,6 +25,7 @@
import org.checkerframework.checker.units.qual.C;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import java.util.Date;
@@ -46,6 +47,7 @@
    private SystemDictDataBiz systemDictDataBiz;
    @Override
    @Transactional(rollbackFor = {Exception.class,BusinessException.class})
    public Integer create(Category category) {
        if(Objects.isNull(category)
        || Objects.isNull(category.getType())
@@ -61,7 +63,8 @@
        category.setCreateUser(loginUserInfo.getId());
        category.setUpdateTime(new Date());
        category.setUpdateUser(loginUserInfo.getId());
        if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(category.getDetailList())){
        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)){
@@ -93,6 +96,7 @@
    }
    @Override
    @Transactional(rollbackFor = {Exception.class,BusinessException.class})
    public void updateById(Category category) {
        if(Objects.isNull(category)
                || Objects.isNull(category.getId())
@@ -107,7 +111,8 @@
        category.setUpdateTime(new Date());
        category.setIsFixed(null);
        category.setUpdateUser(loginUserInfo.getId());
        if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(category.getDetailList())){
        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);
@@ -243,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;
    }
}