Przeglądaj źródła

feat(store): 添加预订服务分类详情查询功能

- 在StoreBookingTableController中新增分类详情查询接口
- 添加对StoreBookingCategoryService的依赖注入
- 实现getCategoryDetailByCategoryId方法支持按分类ID查询
- 添加API文档注解支持Swagger文档生成
- 增加参数验证和异常处理逻辑
- 移除代码末尾多余空行优化格式
fcw 1 miesiąc temu
rodzic
commit
6699cda632

+ 28 - 0
alien-store/src/main/java/shop/alien/store/controller/StoreBookingTableController.java

@@ -6,9 +6,11 @@ import lombok.extern.slf4j.Slf4j;
 import org.springframework.util.StringUtils;
 import org.springframework.web.bind.annotation.*;
 import shop.alien.entity.result.R;
+import shop.alien.entity.store.StoreBookingCategory;
 import shop.alien.entity.store.StoreBookingTable;
 import shop.alien.entity.store.dto.StoreBookingTableBatchDTO;
 import shop.alien.entity.store.dto.StoreBookingTableDTO;
+import shop.alien.store.service.StoreBookingCategoryService;
 import shop.alien.store.service.StoreBookingTableService;
 
 import java.util.List;
@@ -29,6 +31,7 @@ import java.util.List;
 public class StoreBookingTableController {
 
     private final StoreBookingTableService storeBookingTableService;
+    private final StoreBookingCategoryService storeBookingCategoryService;
 
     @ApiOperationSupport(order = 1)
     @ApiOperation("查询预订服务桌号列表")
@@ -189,4 +192,29 @@ public class StoreBookingTableController {
             return R.fail("删除失败:" + e.getMessage());
         }
     }
+
+    @ApiOperationSupport(order = 6)
+    @ApiOperation("根据分类ID查询分类详细信息")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "categoryId", value = "分类ID", dataType = "Integer", paramType = "query", required = true)
+    })
+    @GetMapping("/category/detail")
+    public R<StoreBookingCategory> getCategoryDetailByCategoryId(@RequestParam Integer categoryId) {
+        log.info("StoreBookingTableController.getCategoryDetailByCategoryId?categoryId={}", categoryId);
+
+        if (categoryId == null) {
+            return R.fail("分类ID不能为空");
+        }
+
+        try {
+            StoreBookingCategory category = storeBookingCategoryService.getById(categoryId);
+            if (category == null) {
+                return R.fail("分类不存在");
+            }
+            return R.data(category);
+        } catch (Exception e) {
+            log.error("根据分类ID查询分类详情失败", e);
+            return R.fail("查询失败:" + e.getMessage());
+        }
+    }
 }