From c466ff02844412184c6e032c82eeca18836b4e2d Mon Sep 17 00:00:00 2001
From: zepengdev <lzpsmith@outlook.com>
Date: Mon, 23 Jun 2025 12:06:37 +0800
Subject: [PATCH] refactor(StoreQueryService): 查询优化

---
 oying-system/src/main/java/com/oying/modules/pc/store/rest/StoreCategoryController.java |   71 ++++++++++++++++++++++-------------
 1 files changed, 44 insertions(+), 27 deletions(-)

diff --git a/oying-system/src/main/java/com/oying/modules/pc/store/rest/StoreCategoryController.java b/oying-system/src/main/java/com/oying/modules/pc/store/rest/StoreCategoryController.java
index 65462c7..6fcd434 100644
--- a/oying-system/src/main/java/com/oying/modules/pc/store/rest/StoreCategoryController.java
+++ b/oying-system/src/main/java/com/oying/modules/pc/store/rest/StoreCategoryController.java
@@ -1,25 +1,29 @@
 package com.oying.modules.pc.store.rest;
 
-import com.oying.annotation.Log;
-import com.oying.utils.R;
+import cn.hutool.core.bean.BeanUtil;
+import cn.hutool.core.bean.copier.CopyOptions;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.oying.modules.pc.store.domain.StoreCategory;
-import com.oying.modules.pc.store.service.StoreCategoryService;
+import com.oying.modules.pc.store.domain.dto.StoreCategoryCreateRequest;
 import com.oying.modules.pc.store.domain.dto.StoreCategoryQueryCriteria;
+import com.oying.modules.pc.store.domain.dto.StoreCategoryUpdateRequest;
+import com.oying.modules.pc.store.service.StoreCategoryService;
+import com.oying.utils.R;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
 import lombok.RequiredArgsConstructor;
-import java.util.List;
-
 import org.springframework.http.HttpStatus;
 import org.springframework.http.ResponseEntity;
-import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
-import io.swagger.annotations.*;
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+
+import java.util.List;
 
 /**
-* @author lzp
-* @date 2025-04-24
-**/
+ * @author lzp
+ * @date 2025-04-24
+ **/
 @Api(tags = "商品中心:店铺类目")
 @RestController
 @RequiredArgsConstructor
@@ -28,35 +32,48 @@
 
     private final StoreCategoryService storeCategoryService;
 
-    @GetMapping
-    @ApiOperation("查询api/store/category")
-    public ResponseEntity<?> queryStoreCategory(StoreCategoryQueryCriteria criteria){
+    @GetMapping(value = "/list")
+    @ApiOperation("查询")
+    public ResponseEntity<?> getStoreCategories(StoreCategoryQueryCriteria criteria) {
+        return ResponseEntity.ok(R.success(storeCategoryService.queryAll(criteria)));
+    }
+
+    @GetMapping(value = "/page")
+    @ApiOperation("查询")
+    public ResponseEntity<?> getStoreCategoriesByPage(StoreCategoryQueryCriteria criteria) {
         Page<Object> page = new Page<>(criteria.getPage(), criteria.getSize());
         return ResponseEntity.ok(R.success(storeCategoryService.queryAll(criteria, page)));
     }
 
+    @GetMapping(value = "/{categoryId}")
+    @ApiOperation("查询")
+    public ResponseEntity<?> getStoreCategory(@PathVariable Long categoryId) {
+        return ResponseEntity.ok(R.success(storeCategoryService.getById(categoryId)));
+    }
+
     @PostMapping
-    @Log("新增api/store")
-    @ApiOperation("新增api/store")
-    @PreAuthorize("@el.check('storeCategory:add')")
-    public ResponseEntity<?> createStoreCategory(@Validated @RequestBody StoreCategory resources){
-        storeCategoryService.create(resources);
+    @ApiOperation("新增")
+    // @PreAuthorize("@el.check('storeCategory:add')")
+    public ResponseEntity<?> createStoreCategory(@Validated @RequestBody StoreCategoryCreateRequest request) {
+        StoreCategory storeCategory = new StoreCategory();
+        BeanUtil.copyProperties(request, storeCategory, CopyOptions.create().setIgnoreNullValue(true));
+        storeCategoryService.create(storeCategory);
         return ResponseEntity.status(HttpStatus.CREATED).build();
     }
 
     @PutMapping
-    @Log("修改api/store")
-    @ApiOperation("修改api/store")
-    @PreAuthorize("@el.check('storeCategory:edit')")
-    public ResponseEntity<?> updateStoreCategory(@Validated @RequestBody StoreCategory resources){
-        storeCategoryService.update(resources);
+    @ApiOperation("修改")
+    // @PreAuthorize("@el.check('storeCategory:edit')")
+    public ResponseEntity<?> updateStoreCategory(@Validated @RequestBody StoreCategoryUpdateRequest request) {
+        StoreCategory storeCategory = new StoreCategory();
+        BeanUtil.copyProperties(request, storeCategory, CopyOptions.create().setIgnoreNullValue(true));
+        storeCategoryService.update(storeCategory);
         return ResponseEntity.noContent().build();
     }
 
     @DeleteMapping
-    @Log("删除api/store")
-    @ApiOperation("删除api/store")
-    @PreAuthorize("@el.check('storeCategory:del')")
+    @ApiOperation("删除")
+    // @PreAuthorize("@el.check('storeCategory:del')")
     public ResponseEntity<?> deleteStoreCategory(@ApiParam(value = "传ID数组[]") @RequestBody List<Long> ids) {
         storeCategoryService.deleteAll(ids);
         return ResponseEntity.noContent().build();

--
Gitblit v1.9.3