diff --git a/src/main/java/com/cultural/heritage/controller/good/CategoryController.java b/src/main/java/com/cultural/heritage/controller/good/CategoryController.java index 9bbeeb3..6256556 100644 --- a/src/main/java/com/cultural/heritage/controller/good/CategoryController.java +++ b/src/main/java/com/cultural/heritage/controller/good/CategoryController.java @@ -17,11 +17,13 @@ import jakarta.annotation.Resource; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.BeanUtils; +import org.springframework.util.CollectionUtils; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -106,6 +108,21 @@ public class CategoryController { } + /** + * 查询所有商品类别 + * @return 商品类别列表 + */ + @PostMapping("/list") + public BaseResponse> listCategory() { + List list = categoryService.list(); + if (CollectionUtils.isEmpty(list)) { + list = new ArrayList<>(); + } + return ResultUtils.success(list); + } + + + /** * 根据类别查询商品列表 * @param categoryQueryRequest 类别查询请求体