From 5da53ab90d6152de28b8475cd9ccaa00abba45e8 Mon Sep 17 00:00:00 2001 From: zepengdev <lzpsmith@outlook.com> Date: Thu, 26 Jun 2025 22:45:18 +0800 Subject: [PATCH] fix: 优化店铺添加,预检查店铺名称,返回添加的店铺信息 --- oying-system/src/main/java/com/oying/modules/pc/store/rest/StoreMerchantController.java | 80 ++++++++++++++++++++++++---------------- 1 files changed, 48 insertions(+), 32 deletions(-) diff --git a/oying-system/src/main/java/com/oying/modules/pc/store/rest/StoreMerchantController.java b/oying-system/src/main/java/com/oying/modules/pc/store/rest/StoreMerchantController.java index aa332cc..1c19479 100644 --- a/oying-system/src/main/java/com/oying/modules/pc/store/rest/StoreMerchantController.java +++ b/oying-system/src/main/java/com/oying/modules/pc/store/rest/StoreMerchantController.java @@ -1,7 +1,13 @@ package com.oying.modules.pc.store.rest; +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.bean.copier.CopyOptions; import cn.hutool.core.collection.ListUtil; -import com.oying.modules.pc.common.core.domain.R; +import cn.hutool.core.util.ObjUtil; +import cn.hutool.core.util.ObjectUtil; +import com.oying.modules.pc.store.domain.dto.StoreUpdateRequest; +import com.oying.modules.pc.store.service.StoreQualificationService; +import com.oying.utils.R; import com.oying.modules.pc.store.domain.Store; import com.oying.modules.pc.store.domain.dto.StoreCreateRequest; import com.oying.modules.pc.store.domain.dto.StoreFieldUpdateRequest; @@ -39,21 +45,24 @@ private final StoreService storeService; private final StoreCreateService storeCreateService; + private final StoreQualificationService storeQualificationService; @GetMapping(value = "/list") @ApiOperation("查询所有店铺") //@PreAuthorize("@el.check('merchant:store:list')") public ResponseEntity<?> getList() { - StoreQueryCriteria criteria = new StoreQueryCriteria(); - criteria.setMerchantId(SecurityUtils.getCurrentUserId()); - //criteria.setStatus(); - List<Store> storeList = Optional.ofNullable(storeService.queryAll(criteria)).orElse(ListUtil.empty()); - List<StoreSimpleView> storeViewList = storeList.stream().map(s -> { + List<Store> stores = Optional.ofNullable(storeService.queryUserStores(SecurityUtils.getCurrentUserId())).orElse(ListUtil.empty()); + return ResponseEntity.ok(R.success(stores)); + } + + @GetMapping(value = "/simple-list") + @ApiOperation("查询所有店铺") + //@PreAuthorize("@el.check('merchant:store:list')") + public ResponseEntity<?> getSimpleStores() { + List<Store> stores = Optional.ofNullable(storeService.queryUserStores(SecurityUtils.getCurrentUserId())).orElse(ListUtil.empty()); + List<StoreSimpleView> storeViewList = stores.stream().map(i -> { StoreSimpleView view = new StoreSimpleView(); - view.setId(s.getStoreId()); - view.setName(s.getStoreName()); - view.setLogoUrl(""); - view.setStatus(s.getStatus()); + BeanUtil.copyProperties(i, view, CopyOptions.create().setIgnoreNullValue(true)); return view; }).collect(Collectors.toList()); return ResponseEntity.ok(R.success(storeViewList)); @@ -61,22 +70,30 @@ @GetMapping(value = "/{storeId}") @ApiOperation("查询店铺") - //@PreAuthorize("@el.check('merchant:store:getById')" + - // " and @storeMerchantOwnershipService.check(#storeId)") - public ResponseEntity<?> getById(@PathVariable Long storeId) { + //@PreAuthorize("@el.check('merchant:store:getById')") + public ResponseEntity<?> getStoreById(@PathVariable Long storeId) { Store store = storeService.getById(storeId); StoreMerchantView view = new StoreMerchantView(); BeanUtils.copyProperties(store, view); - view.setLogoUrl(""); return ResponseEntity.ok(R.success(view)); + } + + @GetMapping(value = "/{storeId}/details") + @ApiOperation("查询店铺") + //@PreAuthorize("@el.check('merchant:store:getById')") + public ResponseEntity<?> getStoreDetailsById(@PathVariable Long storeId) { + Store store = storeService.getById(storeId); + if (ObjUtil.isNotEmpty(store)) { + store.setQualifications(storeQualificationService.queryByStoreId(storeId)); + } + return ResponseEntity.ok(R.success(store)); } @PostMapping @ApiOperation("创建店铺") //@PreAuthorize("@el.check('merchant:store:create')") public ResponseEntity<?> create(@RequestBody StoreCreateRequest request) { - storeCreateService.create(request); - return ResponseEntity.status(HttpStatus.CREATED).build(); + return ResponseEntity.status(HttpStatus.CREATED).body(storeCreateService.create(request)); } /** @@ -86,10 +103,9 @@ @ApiOperation("修改店铺") //@PreAuthorize("@el.check('merchant:store:update')" + // " and @storeMerchantOwnershipService.check(#storeId)") - public ResponseEntity<?> update(@PathVariable("storeId") Long storeId, - @RequestBody Store store) { - store.setStoreId(storeId); - storeService.updateById(store); + public ResponseEntity<?> update(@PathVariable("storeId") Long storeId, @RequestBody StoreUpdateRequest request) { + request.setStoreId(ObjectUtil.defaultIfNull(request.getStoreId(), storeId)); + storeService.update(request); return ResponseEntity.noContent().build(); } @@ -103,7 +119,7 @@ public ResponseEntity<?> updateLogo(@PathVariable("storeId") Long storeId, @Validated(value = StoreFieldUpdateRequest.UpdateStoreLogoImageGroup.class) @RequestBody StoreFieldUpdateRequest request) { - storeService.updateLogo(storeId, request.getLogoImageUploadId()); + storeService.updateLogo(storeId, request.getLogoImageUploadId(), request.getVersion()); return ResponseEntity.noContent().build(); } @@ -117,7 +133,7 @@ public ResponseEntity<?> updateName(@PathVariable("storeId") Long storeId, @Validated(value = StoreFieldUpdateRequest.UpdateStoreNameGroup.class) @RequestBody StoreFieldUpdateRequest request) { - storeService.updateName(storeId, request.getStoreName()); + storeService.updateName(storeId, request.getStoreName(), request.getVersion()); return ResponseEntity.noContent().build(); } @@ -131,7 +147,7 @@ public ResponseEntity<?> updateDescription(@PathVariable("storeId") Long storeId, @Validated(value = StoreFieldUpdateRequest.UpdateStoreDescriptionGroup.class) @RequestBody StoreFieldUpdateRequest request) { - storeService.updateDescription(storeId, request.getDescription()); + storeService.updateDescription(storeId, request.getDescription(), request.getVersion()); return ResponseEntity.noContent().build(); } @@ -145,7 +161,7 @@ public ResponseEntity<?> updateContactPhone(@PathVariable("storeId") Long storeId, @Validated(value = StoreFieldUpdateRequest.UpdateStoreContactPhoneGroup.class) @RequestBody StoreFieldUpdateRequest request) { - storeService.updateContactPhone(storeId, request.getContactPhone()); + storeService.updateContactPhone(storeId, request.getContactPhone(), request.getVersion()); return ResponseEntity.noContent().build(); } @@ -159,7 +175,7 @@ public ResponseEntity<?> updateAddress(@PathVariable("storeId") Long storeId, @Validated(value = StoreFieldUpdateRequest.UpdateStoreAddressGroup.class) @RequestBody StoreFieldUpdateRequest request) { - storeService.updateAddress(storeId, request.getAddress()); + storeService.updateAddress(storeId, request.getAddress(), request.getVersion()); return ResponseEntity.noContent().build(); } @@ -173,7 +189,7 @@ public ResponseEntity<?> updateLocation(@PathVariable("storeId") Long storeId, @Validated(value = StoreFieldUpdateRequest.UpdateStoreLocationGroup.class) @RequestBody StoreFieldUpdateRequest request) { - storeService.updateLocation(storeId, request.getLongitude(), request.getLatitude()); + storeService.updateLocation(storeId, request.getLongitude(), request.getLatitude(), request.getVersion()); return ResponseEntity.noContent().build(); } @@ -187,7 +203,7 @@ public ResponseEntity<?> updateRadius(@PathVariable("storeId") Long storeId, @Validated(value = StoreFieldUpdateRequest.UpdateStoreRadiusGroup.class) @RequestBody StoreFieldUpdateRequest request) { - storeService.updateRadius(storeId, request.getRadius()); + storeService.updateRadius(storeId, request.getRadius(), request.getVersion()); return ResponseEntity.noContent().build(); } @@ -201,7 +217,7 @@ public ResponseEntity<?> updatePlatformCategory(@PathVariable("storeId") Long storeId, @Validated(value = StoreFieldUpdateRequest.UpdateStorePlatformCategoryGroup.class) @RequestBody StoreFieldUpdateRequest request) { - storeService.updatePlatformCategory(storeId, request.getPlatformCategoryId()); + storeService.updatePlatformCategory(storeId, request.getPlatformCategoryId(), request.getVersion()); return ResponseEntity.noContent().build(); } @@ -215,7 +231,7 @@ public ResponseEntity<?> updateBusinessHours(@PathVariable("storeId") Long storeId, @Validated(value = StoreFieldUpdateRequest.UpdateStoreBusinessHoursGroup.class) @RequestBody StoreFieldUpdateRequest request) { - storeService.updateBusinessHours(storeId, request.getOpenTime(), request.getCloseTime()); + storeService.updateBusinessHours(storeId, request.getOpenTime(), request.getCloseTime(), request.getVersion()); return ResponseEntity.noContent().build(); } @@ -229,7 +245,7 @@ public ResponseEntity<?> updateDeliveryMinimum(@PathVariable("storeId") Long storeId, @Validated(value = StoreFieldUpdateRequest.UpdateStoreDeliveryMinimumGroup.class) @RequestBody StoreFieldUpdateRequest request) { - storeService.updateDeliveryMinimum(storeId, request.getDeliveryMinimum()); + storeService.updateDeliveryMinimum(storeId, request.getDeliveryMinimum(), request.getVersion()); return ResponseEntity.noContent().build(); } @@ -243,7 +259,7 @@ public ResponseEntity<?> updateDeliveryFee(@PathVariable("storeId") Long storeId, @Validated(value = StoreFieldUpdateRequest.UpdateStoreDeliveryFeeGroup.class) @RequestBody StoreFieldUpdateRequest request) { - storeService.updateDeliveryFee(storeId, request.getDeliveryFee()); + storeService.updateDeliveryFee(storeId, request.getDeliveryFee(), request.getVersion()); return ResponseEntity.noContent().build(); } @@ -257,7 +273,7 @@ public ResponseEntity<?> businessStatus(@PathVariable("storeId") Long storeId, @Validated(value = StoreFieldUpdateRequest.UpdateStoreBusinessStatusGroup.class) @RequestBody StoreFieldUpdateRequest request) { - storeService.updateStatus(storeId, request.getBusinessStatus()); + storeService.updateStatus(storeId, request.getBusinessStatus(), request.getVersion()); return ResponseEntity.noContent().build(); } } -- Gitblit v1.9.3