|
@@ -1,18 +1,25 @@
|
|
|
package cn.iocoder.yudao.module.product.controller.app.category;
|
|
|
|
|
|
+import cn.hutool.core.collection.CollUtil;
|
|
|
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
|
|
+import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
|
|
import cn.iocoder.yudao.module.product.controller.app.category.vo.AppCategoryRespVO;
|
|
|
import cn.iocoder.yudao.module.product.convert.category.ProductCategoryConvert;
|
|
|
import cn.iocoder.yudao.module.product.dal.dataobject.category.ProductCategoryDO;
|
|
|
import cn.iocoder.yudao.module.product.service.category.ProductCategoryService;
|
|
|
import io.swagger.v3.oas.annotations.Operation;
|
|
|
+import io.swagger.v3.oas.annotations.Parameter;
|
|
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestParam;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
import jakarta.annotation.Resource;
|
|
|
+
|
|
|
+import java.util.Collection;
|
|
|
+import java.util.Collections;
|
|
|
import java.util.Comparator;
|
|
|
import java.util.List;
|
|
|
|
|
@@ -32,7 +39,19 @@ public class AppCategoryController {
|
|
|
public CommonResult<List<AppCategoryRespVO>> getProductCategoryList() {
|
|
|
List<ProductCategoryDO> list = categoryService.getEnableCategoryList();
|
|
|
list.sort(Comparator.comparing(ProductCategoryDO::getSort));
|
|
|
- return success(ProductCategoryConvert.INSTANCE.convertList03(list));
|
|
|
+ return success(BeanUtils.toBean(list, AppCategoryRespVO.class));
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/list-by-ids")
|
|
|
+ @Operation(summary = "获得商品分类列表,指定编号")
|
|
|
+ @Parameter(name = "ids", description = "商品分类编号数组", required = true)
|
|
|
+ public CommonResult<List<AppCategoryRespVO>> getProductCategoryList(@RequestParam("ids") List<Long> ids) {
|
|
|
+ if (CollUtil.isEmpty(ids)) {
|
|
|
+ return success(Collections.emptyList());
|
|
|
+ }
|
|
|
+ List<ProductCategoryDO> list = categoryService.getEnableCategoryList(ids);
|
|
|
+ list.sort(Comparator.comparing(ProductCategoryDO::getSort));
|
|
|
+ return success(BeanUtils.toBean(list, AppCategoryRespVO.class));
|
|
|
}
|
|
|
|
|
|
}
|