jiangping
2024-11-07 4c2bae1c7e6f84699091a7e094120808137138dc
server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/CategoryServiceImpl.java
@@ -14,11 +14,13 @@
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Objects;
@@ -155,6 +157,36 @@
        QueryWrapper<Category> wrapper = new QueryWrapper<>(category);
        return categoryMapper.selectCount(wrapper);
    }
    @Override
    public  List<Category> findChileList(Category model) {
        List<Category> list =findList(model);
        List<Category> data = new ArrayList<>();
        if(list!=null){
            for(Category category : list){
                if(category.getParentId()!=null){
                    Category pcate = getParentById(category.getParentId(),list);
                    if(pcate!=null){
                        category.setParentName(StringUtils.defaultString(pcate.getName(),""));
                        category.setName(StringUtils.defaultString(category.getName(),""));
                        category.setGroupName( category.getParentName()+"/"+category.getName());
                        data.add(category);
                    }
                }
            }
        }
        return  data;
    }
    private Category getParentById(Integer parentId, List<Category> list) {
        if(list!=null){
            for(Category category : list){
                if(Constants.equalsInteger(parentId,category.getId())){
                   return  category;
                }
            }
        }
        return  null;
    }
    private void checkUnique(Category category){
        QueryWrapper<Category> wrapper = new QueryWrapper<>();