From 43315000b2840313a5aff96bf314b3c061e4616d Mon Sep 17 00:00:00 2001
From: zepengdev <lzpsmith@outlook.com>
Date: Mon, 14 Jul 2025 21:00:53 +0800
Subject: [PATCH] feat: 增加店铺和商品审核功能

---
 oying-system/src/main/java/com/oying/modules/pc/store/rest/StoreController.java |   68 +++++++++++++++++++--------------
 1 files changed, 39 insertions(+), 29 deletions(-)

diff --git a/oying-system/src/main/java/com/oying/modules/pc/store/rest/StoreController.java b/oying-system/src/main/java/com/oying/modules/pc/store/rest/StoreController.java
index 81082e4..3d421f3 100644
--- a/oying-system/src/main/java/com/oying/modules/pc/store/rest/StoreController.java
+++ b/oying-system/src/main/java/com/oying/modules/pc/store/rest/StoreController.java
@@ -1,15 +1,21 @@
 package com.oying.modules.pc.store.rest;
 
-import com.oying.utils.R;
-import com.oying.modules.pc.common.id.StoreIdGenerator;
+import cn.hutool.core.collection.ListUtil;
+import cn.hutool.core.util.ObjectUtil;
 import com.oying.modules.pc.store.domain.Store;
-import com.oying.modules.pc.store.domain.dto.*;
+import com.oying.modules.pc.store.domain.dto.StoreCreateRequest;
+import com.oying.modules.pc.store.domain.dto.StoreQueryCriteria;
+import com.oying.modules.pc.store.domain.dto.StoreUpdateRequest;
 import com.oying.modules.pc.store.service.StoreService;
-import com.oying.utils.SecurityUtils;
+import com.oying.utils.R;
+import io.swagger.annotations.ApiOperation;
 import lombok.RequiredArgsConstructor;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
 import org.springframework.web.bind.annotation.*;
 
-import java.time.ZonedDateTime;
+import java.util.List;
+import java.util.Optional;
 
 /**
  * 店铺
@@ -24,43 +30,47 @@
 
     private final StoreService storeService;
 
-    @GetMapping(value = "/page")
-    public R<?> getStoresByPage(StoreQueryCriteria criteria) {
-        return R.success(storeService.queryByPage(criteria));
+    @GetMapping(value = "/list")
+    @ApiOperation("查询所有店铺")
+    public ResponseEntity<?> getStores(StoreQueryCriteria criteria) {
+        List<Store> storeList = Optional.ofNullable(storeService.queryAll(criteria)).orElse(ListUtil.empty());
+        return ResponseEntity.ok(R.success(storeList));
     }
 
-    @GetMapping(value = "/list")
-    public R<?> getStores(StoreQueryCriteria criteria) {
-        return R.success(storeService.queryAll(criteria));
+    @GetMapping(value = "/page")
+    @ApiOperation("查询所有店铺")
+    public ResponseEntity<?> getStoresByPage(StoreQueryCriteria criteria) {
+        return ResponseEntity.ok(R.success(storeService.queryByPage(criteria)));
     }
 
     @GetMapping(value = "/{storeId}")
-    public R<?> getStoreById(@PathVariable("storeId") Long storeId) {
-        return R.success(storeService.getById(storeId));
+    @ApiOperation("查询店铺")
+    public ResponseEntity<?> getStoreById(@PathVariable Long storeId) {
+        return ResponseEntity.ok(R.success(storeService.getById(storeId)));
     }
 
     @GetMapping(value = "/{storeId}/details")
-    public R<?> getStoreDetailsById(@PathVariable("storeId") Long storeId) {
-        return R.success(storeService.getById(storeId));
+    public ResponseEntity<?> getStoreDetailsById(@PathVariable("storeId") Long storeId) {
+        return ResponseEntity.ok(R.success(storeService.getById(storeId)));
     }
 
-    @PostMapping(value = "/createEmpty")
-    public R<?> createEmpty(@RequestBody StoreCreateRequest request) {
-        Store store = new Store();
-        store.setStoreId(StoreIdGenerator.getId());
-        store.setMerchantId(SecurityUtils.getCurrentUserId());
-        storeService.save(store);
-        return R.success();
+    @GetMapping(value = "/{storeId}/name-check")
+    public ResponseEntity<?> checkStoreName(@RequestParam String storeName) {
+        return ResponseEntity.ok(R.success(storeService.existsStoreName(storeName)));
     }
 
-    /**
-     * 修改店铺信息
-     */
+    @PostMapping
+    @ApiOperation("创建店铺")
+    public ResponseEntity<?> create(@RequestBody StoreCreateRequest request) {
+        return ResponseEntity.status(HttpStatus.CREATED).body(R.success(storeService.create(request)));
+    }
+
     @PostMapping(value = "/{storeId}")
-    public R<?> update(@PathVariable("storeId") Long storeId, @RequestBody Store store) {
-        store.setStoreId(storeId);
-        storeService.updateById(store);
-        return R.success();
+    @ApiOperation("修改店铺")
+    public ResponseEntity<?> update(@PathVariable("storeId") Long storeId, @RequestBody StoreUpdateRequest request) {
+        request.setStoreId(ObjectUtil.defaultIfNull(request.getStoreId(), storeId));
+        storeService.update(request);
+        return ResponseEntity.noContent().build();
     }
 
 }

--
Gitblit v1.9.3