feat(ai): 新增产品分类相关功能
- 在 AiProductCategoryMapper.xml 中添加了根据 parentId 查询的条件
- 在 AiProductCategoryServiceImpl 中实现了获取不同级别分类列表的方法
- 在 ApiProductCategoryController 中添加了子分类列表的接口- 新增了 ProductCategoryLevelEnum 枚举类,用于定义分类级别
- 修改了 ApiProductCategoryPageDto,将 query 字段改为 parentId,并添加了必填验证
4 files modified
1 files added
| | |
| | | } |
| | | |
| | | |
| | | @ApiOperation(value = "分类列表", notes = "分类列表") |
| | | @ApiResponses({ |
| | | @ApiResponse(code = 200, message = "success", response = ApiProductCategoryVo.class) |
| | | }) |
| | | @PostMapping(value = "/list") |
| | | public FebsResponse list(@RequestBody @Validated ApiProductCategoryPageDto dto) { |
| | | |
| | | return aiProductCategoryService.categoryList(dto); |
| | | } |
| | | |
| | | |
| | | @ApiOperation(value = "全部分类", notes = "全部分类") |
| | | @ApiOperation(value = "全部父级分类", notes = "全部父级分类") |
| | | @ApiResponses({ |
| | | @ApiResponse(code = 200, message = "success", response = ApiProductCategoryVo.class) |
| | | }) |
| | |
| | | |
| | | return aiProductCategoryService.allList(); |
| | | } |
| | | |
| | | |
| | | @ApiOperation(value = "子分类列表", notes = "子分类列表") |
| | | @ApiResponses({ |
| | | @ApiResponse(code = 200, message = "success", response = ApiProductCategoryVo.class) |
| | | }) |
| | | @PostMapping(value = "/list") |
| | | public FebsResponse list(@RequestBody @Validated ApiProductCategoryPageDto dto) { |
| | | |
| | | return aiProductCategoryService.categoryList(dto); |
| | | } |
| | | } |
New file |
| | |
| | | package cc.mrbird.febs.ai.enumerates; |
| | | |
| | | import lombok.Getter; |
| | | |
| | | @Getter |
| | | public enum ProductCategoryLevelEnum { |
| | | |
| | | LEVEL_TWO("二级菜单",2), |
| | | LEVEL_ONE("一级菜单",1); |
| | | |
| | | |
| | | private String name; |
| | | private Integer level; |
| | | |
| | | ProductCategoryLevelEnum(String name,Integer level) { |
| | | |
| | | this.level = level; |
| | | this.name = name; |
| | | } |
| | | } |
| | |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | import javax.validation.constraints.NotBlank; |
| | | import javax.validation.constraints.NotNull; |
| | | |
| | | /** |
| | |
| | | @ApiModelProperty(value = "每页数量", example = "10") |
| | | private Integer pageSize; |
| | | |
| | | @ApiModelProperty(value = "查询名称", example = "123") |
| | | private String query; |
| | | |
| | | @NotBlank(message = "父分类不能为空") |
| | | @ApiModelProperty(value = "父分类ID", example = "123") |
| | | private String parentId; |
| | | |
| | | } |
| | |
| | | package cc.mrbird.febs.ai.service.impl; |
| | | |
| | | import cc.mrbird.febs.ai.entity.AiProductCategory; |
| | | import cc.mrbird.febs.ai.enumerates.ProductCategoryLevelEnum; |
| | | import cc.mrbird.febs.ai.mapper.AiProductCategoryMapper; |
| | | import cc.mrbird.febs.ai.req.productCategory.ApiProductCategoryPageDto; |
| | | import cc.mrbird.febs.ai.res.productCategory.ApiProductCategoryVo; |
| | |
| | | List<ApiProductCategoryVo> list = new ArrayList<>(); |
| | | |
| | | LambdaQueryWrapper<AiProductCategory> query = Wrappers.lambdaQuery(AiProductCategory.class); |
| | | query.eq(AiProductCategory::getLevel, ProductCategoryLevelEnum.LEVEL_TWO.getLevel()); |
| | | query.eq(AiProductCategory::getState, 1); |
| | | query.eq(AiProductCategory::getHotState, 1); |
| | | query.orderByAsc(AiProductCategory::getSort); |
| | |
| | | List<ApiProductCategoryVo> list = new ArrayList<>(); |
| | | LambdaQueryWrapper<AiProductCategory> query = Wrappers.lambdaQuery(AiProductCategory.class); |
| | | query.eq(AiProductCategory::getState, 1); |
| | | query.eq(AiProductCategory::getLevel, ProductCategoryLevelEnum.LEVEL_ONE.getLevel()); |
| | | query.orderByAsc(AiProductCategory::getSort); |
| | | List<AiProductCategory> listByQuery = this.getListByQuery(query); |
| | | if (CollUtil.isNotEmpty(listByQuery)){ |
| | |
| | | from ai_product_category a |
| | | where |
| | | a.state = 1 |
| | | <if test="record.parentId != null and record.parentId != ''"> |
| | | and a.parent_id = #{record.parentId} |
| | | </if> |
| | | order by a.sort asc |
| | | </select> |
| | | </mapper> |