From 0b37408e5f92f2c7f1dee8f4eb121db92a4edaa4 Mon Sep 17 00:00:00 2001
From: zepengdev <lzpsmith@outlook.com>
Date: Wed, 17 Sep 2025 19:39:30 +0800
Subject: [PATCH] fix: 调整店铺用户角色
---
oying-system/src/main/java/com/oying/modules/pc/store/rest/StoreController.java | 70 +++++++++++++++++++---------------
1 files changed, 39 insertions(+), 31 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 a53cf9c..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,45 +30,47 @@
private final StoreService storeService;
- @GetMapping(value = "/page")
- public R<?> getStoresByPage(@RequestBody 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(@RequestBody 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());
- store.setCreateBy(SecurityUtils.getCurrentUserId());
- store.setCreateTime(ZonedDateTime.now());
- 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