| | |
| | | |
| | | import com.consum.base.Constants; |
| | | import com.consum.base.pojo.BaseCategoryParam; |
| | | import com.consum.base.pojo.ProjectTreeResult; |
| | | import com.consum.base.util.IdUtil; |
| | | import com.consum.model.po.BaseCategory; |
| | | import com.iplatform.model.po.S_user_core; |
| | |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.Comparator; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * @Description 物品分类 |
| | |
| | | */ |
| | | @Service |
| | | public class BaseCategoryServiceImpl extends BaseServiceImpl { |
| | | |
| | | private static final String QUERY_TREE_ALL = "select * from base_category where states = 1 order by FATHER_CATEGORY_ID, LEVELS ASC"; |
| | | |
| | | /** |
| | | * @Description 新增分类 |
| | |
| | | public BaseCategory getById(Long id) { |
| | | return this.get(new BaseCategory(id)); |
| | | } |
| | | |
| | | /** |
| | | * @Description |
| | | * @Author 卢庆阳 |
| | | * @Date 2023/10/30 |
| | | */ |
| | | public List<BaseCategory> queryForTree() { |
| | | // 展示全部节点 |
| | | return this.select(QUERY_TREE_ALL, new Object[]{}, new BaseCategory()); |
| | | } |
| | | |
| | | public List<ProjectTreeResult> tree(String categoryName) { |
| | | BaseCategory categoryParam = new BaseCategory(); |
| | | categoryParam.setStates(1); |
| | | List<BaseCategory> categories = select(categoryParam); |
| | | return categories.stream() |
| | | .filter(category -> Integer.valueOf(1).equals(category.getLevels())) |
| | | .sorted(Comparator.comparing(BaseCategory::getOrderNumber)) |
| | | .map(ProjectTreeResult::new) |
| | | .peek(lv1TreeResult -> lv1TreeResult.setChildren(categories.stream().filter(categorie -> lv1TreeResult.getId().equals(categorie.getFatherCategoryId())).sorted(Comparator.comparing(BaseCategory::getOrderNumber)).map(ProjectTreeResult::new).collect(Collectors.toList()))) |
| | | .collect(Collectors.toList()); |
| | | } |
| | | |
| | | /** |
| | | * @Description 三级分类列表查询 |
| | | * @Author 卢庆阳 |
| | | * @Date 2023/10/30 |
| | | * @return |
| | | */ |
| | | public List<BaseCategory> queryForLv3Tree() { |
| | | StringBuilder sql = new StringBuilder("SELECT * FROM base_category WHERE states = 1 and levels = 3 order by ORDER_NUMBER,CREATE_TIME desc"); |
| | | return this.select(sql.toString(), new Object[]{}, new BaseCategory()); |
| | | } |
| | | } |