| | |
| | | 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; |
| | |
| | | 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<>(); |