Administrator
4 days ago cb78ad5f3aa9436cf32ae74f07dd1a5d18b8f046
src/main/java/cc/mrbird/febs/ai/service/impl/AiProductCategoryServiceImpl.java
@@ -2,6 +2,7 @@
import cc.mrbird.febs.ai.entity.AiMemberRole;
import cc.mrbird.febs.ai.entity.AiProductCategory;
import cc.mrbird.febs.ai.enumerates.AiCommonEnum;
import cc.mrbird.febs.ai.enumerates.ProductCategoryLevelEnum;
import cc.mrbird.febs.ai.mapper.AiProductCategoryMapper;
import cc.mrbird.febs.ai.req.productCategory.ApiProductCategoryAllDto;
@@ -79,11 +80,10 @@
        List<ApiProductCategoryVo> list = new ArrayList<>();
        LambdaQueryWrapper<AiProductCategory> query = Wrappers.lambdaQuery(AiProductCategory.class);
        if (StrUtil.isNotEmpty(dto.getCompanyId())){
            query.eq(AiProductCategory::getCompanyId, dto.getCompanyId());
        }else{
            query.isNull(AiProductCategory::getCompanyId);
        if (StrUtil.isEmpty(dto.getCompanyId())){
            dto.setCompanyId(AiCommonEnum.COMPANY_ID.getPrompt());
        }
        query.eq(AiProductCategory::getCompanyId, dto.getCompanyId());
        query.eq(AiProductCategory::getLevel, ProductCategoryLevelEnum.LEVEL_TWO.getLevel());
        query.eq(AiProductCategory::getState, 1);
        query.eq(AiProductCategory::getHotState, 1);
@@ -103,11 +103,52 @@
    }
    @Override
    public FebsResponse categoryList(ApiProductCategoryPageDto dto) {
        // 创建分页对象,传入当前页和每页大小
        Page<ApiProductCategoryVo> page = new Page<>(dto.getPageNow(), dto.getPageSize());
        Page<ApiProductCategoryVo> pageListByQuery = this.getPageListByQuery(page, dto);
        return new FebsResponse().success().data(pageListByQuery);
    public FebsResponse hotV2(ApiProductCategoryHotDto dto) {
        List<ApiProductCategoryVo> list = new ArrayList<>();
        LambdaQueryWrapper<AiProductCategory> query = Wrappers.lambdaQuery(AiProductCategory.class);
        if (StrUtil.isEmpty(dto.getCompanyId())){
            dto.setCompanyId(AiCommonEnum.COMPANY_ID.getPrompt());
        }
        query.eq(AiProductCategory::getCompanyId, dto.getCompanyId());
        query.eq(AiProductCategory::getLevel, ProductCategoryLevelEnum.LEVEL_ONE.getLevel());
        query.eq(AiProductCategory::getState, 1);
        query.eq(AiProductCategory::getHotState, 1);
        query.orderByAsc(AiProductCategory::getSort);
        List<AiProductCategory> listByQuery = this.getListByQuery(query);
        if (CollUtil.isNotEmpty(listByQuery)){
            for (AiProductCategory aiProductCategory : listByQuery){
                ApiProductCategoryVo apiProductCategoryVo = new ApiProductCategoryVo();
                apiProductCategoryVo.setId(aiProductCategory.getId());
                apiProductCategoryVo.setName(aiProductCategory.getName());
                apiProductCategoryVo.setBackImg(aiProductCategory.getBackImg());
                apiProductCategoryVo.setIconImg(aiProductCategory.getIconImg());
                list.add(apiProductCategoryVo);
            }
        }
        return new FebsResponse().success().data(list);
    }
    @Override
    public FebsResponse categoryChildList(ApiProductCategoryPageDto dto) {
        List<ApiProductCategoryVo> vos = new ArrayList<>();
        List<AiProductCategory> aiProductCategories = aiProductCategoryMapper.selectList(
                Wrappers.lambdaQuery(AiProductCategory.class)
                        .eq(AiProductCategory::getParentId, dto.getParentId())
                        .eq(AiProductCategory::getState, 1)
                .orderByAsc(AiProductCategory::getSort)
        );
        if (CollUtil.isNotEmpty(aiProductCategories)){
            for (AiProductCategory aiProductCategory : aiProductCategories) {
                ApiProductCategoryVo vo = new ApiProductCategoryVo();
                vo.setId(aiProductCategory.getId());
                vo.setName(aiProductCategory.getName());
                vos.add(vo);
            }
        }
        return new FebsResponse().success().data(vos);
    }
    @Override
@@ -129,11 +170,10 @@
    public FebsResponse allList(ApiProductCategoryAllDto dto) {
        List<ApiProductCategoryVo> list = new ArrayList<>();
        LambdaQueryWrapper<AiProductCategory> query = Wrappers.lambdaQuery(AiProductCategory.class);
        if (StrUtil.isNotEmpty(dto.getCompanyId())){
            query.eq(AiProductCategory::getCompanyId, dto.getCompanyId());
        }else{
            query.isNull(AiProductCategory::getCompanyId);
        if (StrUtil.isEmpty(dto.getCompanyId())){
            dto.setCompanyId(AiCommonEnum.COMPANY_ID.getPrompt());
        }
        query.eq(AiProductCategory::getCompanyId, dto.getCompanyId());
        query.eq(AiProductCategory::getState, 1);
        query.eq(AiProductCategory::getLevel, ProductCategoryLevelEnum.LEVEL_ONE.getLevel());
        query.orderByAsc(AiProductCategory::getSort);