From 347909bae241fff128b628ea6d12992d7e5b4b10 Mon Sep 17 00:00:00 2001 From: xin <1099200748@qq.com> Date: Fri, 30 May 2025 18:35:43 +0800 Subject: [PATCH] 响应信息主体 --- oying-system/src/main/java/com/oying/modules/pc/store/rest/StoreMerchantController.java | 263 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 263 insertions(+), 0 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 new file mode 100644 index 0000000..6e5d928 --- /dev/null +++ b/oying-system/src/main/java/com/oying/modules/pc/store/rest/StoreMerchantController.java @@ -0,0 +1,263 @@ +package com.oying.modules.pc.store.rest; + +import cn.hutool.core.collection.ListUtil; +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; +import com.oying.modules.pc.store.domain.dto.StoreQueryCriteria; +import com.oying.modules.pc.store.service.StoreCreateService; +import com.oying.modules.pc.store.service.StoreService; +import com.oying.modules.pc.store.view.StoreMerchantView; +import com.oying.modules.pc.store.view.StoreSimpleView; +import com.oying.utils.SecurityUtils; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.RequiredArgsConstructor; +import org.springframework.beans.BeanUtils; +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 java.util.List; +import java.util.Optional; +import java.util.stream.Collectors; + +/** + * 店铺 + * + * @author lzp + * @date 2025-04-22 + */ +@Api(tags = "店铺(商户端)") +@RestController +@RequiredArgsConstructor +@RequestMapping("/api/pc/merchant/store") +public class StoreMerchantController { + + private final StoreService storeService; + private final StoreCreateService storeCreateService; + + @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 -> { + StoreSimpleView view = new StoreSimpleView(); + view.setId(s.getStoreId()); + view.setName(s.getStoreName()); + view.setLogoUrl(""); + view.setStatus(s.getStatus()); + return view; + }).collect(Collectors.toList()); + return ResponseEntity.ok(R.success(storeViewList)); + } + + @GetMapping(value = "/{storeId}") + @ApiOperation("查询店铺") + //@PreAuthorize("@el.check('merchant:store:getById')" + + // " and @storeMerchantOwnershipService.check(#storeId)") + public ResponseEntity<?> getById(@PathVariable Long storeId) { + Store store = storeService.getById(storeId); + StoreMerchantView view = new StoreMerchantView(); + BeanUtils.copyProperties(store, view); + view.setLogoUrl(""); + return ResponseEntity.ok(R.success(view)); + } + + @PostMapping + @ApiOperation("创建店铺") + //@PreAuthorize("@el.check('merchant:store:create')") + public ResponseEntity<?> create(@RequestBody StoreCreateRequest request) { + storeCreateService.create(request); + return ResponseEntity.status(HttpStatus.CREATED).build(); + } + + /** + * 修改店铺信息 + */ + @PostMapping(value = "/{storeId}") + @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); + return ResponseEntity.noContent().build(); + } + + /** + * 修改店铺LOGO + */ + @PatchMapping(value = "/{storeId}/logo") + @ApiOperation("修改店铺LOGO") + //@PreAuthorize("@el.check('merchant:store:list')" + + // " and @storeMerchantOwnershipService.check(#storeId)") + public ResponseEntity<?> updateLogo(@PathVariable("storeId") Long storeId, + @Validated(value = StoreFieldUpdateRequest.UpdateStoreLogoImageGroup.class) + @RequestBody StoreFieldUpdateRequest request) { + storeService.updateLogo(storeId, request.getLogoImageUploadId()); + return ResponseEntity.noContent().build(); + } + + /** + * 修改店铺名称 + */ + @PatchMapping(value = "/{storeId}/name") + @ApiOperation("修改店铺名称") + //@PreAuthorize("@el.check('merchant:store:name')" + + // " and @storeMerchantOwnershipService.check(#storeId)") + public ResponseEntity<?> updateName(@PathVariable("storeId") Long storeId, + @Validated(value = StoreFieldUpdateRequest.UpdateStoreNameGroup.class) + @RequestBody StoreFieldUpdateRequest request) { + storeService.updateName(storeId, request.getStoreName()); + return ResponseEntity.noContent().build(); + } + + /** + * 修改店铺简介 + */ + @PatchMapping(value = "/{storeId}/description") + @ApiOperation("修改店铺简介") + //@PreAuthorize("@el.check('merchant:store:description')" + + // " and @storeMerchantOwnershipService.check(#storeId)") + public ResponseEntity<?> updateDescription(@PathVariable("storeId") Long storeId, + @Validated(value = StoreFieldUpdateRequest.UpdateStoreDescriptionGroup.class) + @RequestBody StoreFieldUpdateRequest request) { + storeService.updateDescription(storeId, request.getDescription()); + return ResponseEntity.noContent().build(); + } + + /** + * 修改店铺联系电话 + */ + @PatchMapping(value = "/{storeId}/contactPhone") + @ApiOperation("修改店铺联系电话") + @PreAuthorize("@el.check('merchant:store:list')" + + " and @storeMerchantOwnershipService.check(#storeId)") + public ResponseEntity<?> updateContactPhone(@PathVariable("storeId") Long storeId, + @Validated(value = StoreFieldUpdateRequest.UpdateStoreContactPhoneGroup.class) + @RequestBody StoreFieldUpdateRequest request) { + storeService.updateContactPhone(storeId, request.getContactPhone()); + return ResponseEntity.noContent().build(); + } + + /** + * 修改店铺地址 + */ + @PatchMapping(value = "/{storeId}/address") + @ApiOperation("修改店铺地址") + @PreAuthorize("@el.check('merchant:store:address')" + + " and @storeMerchantOwnershipService.check(#storeId)") + public ResponseEntity<?> updateAddress(@PathVariable("storeId") Long storeId, + @Validated(value = StoreFieldUpdateRequest.UpdateStoreAddressGroup.class) + @RequestBody StoreFieldUpdateRequest request) { + storeService.updateAddress(storeId, request.getAddress()); + return ResponseEntity.noContent().build(); + } + + /** + * 修改店铺坐标 + */ + @PatchMapping(value = "/{storeId}/location") + @ApiOperation("修改店铺坐标") + @PreAuthorize("@el.check('merchant:store:location')" + + " and @storeMerchantOwnershipService.check(#storeId)") + public ResponseEntity<?> updateLocation(@PathVariable("storeId") Long storeId, + @Validated(value = StoreFieldUpdateRequest.UpdateStoreLocationGroup.class) + @RequestBody StoreFieldUpdateRequest request) { + storeService.updateLocation(storeId, request.getLongitude(), request.getLatitude()); + return ResponseEntity.noContent().build(); + } + + /** + * 修改店铺配送范围 + */ + @PatchMapping(value = "/{storeId}/radius") + @ApiOperation("修改店铺配送范围") + @PreAuthorize("@el.check('merchant:store:radius')" + + " and @storeMerchantOwnershipService.check(#storeId)") + public ResponseEntity<?> updateRadius(@PathVariable("storeId") Long storeId, + @Validated(value = StoreFieldUpdateRequest.UpdateStoreRadiusGroup.class) + @RequestBody StoreFieldUpdateRequest request) { + storeService.updateRadius(storeId, request.getRadius()); + return ResponseEntity.noContent().build(); + } + + /** + * 修改店铺绑定的经营类目 + */ + @PatchMapping(value = "/{storeId}/platformCategory") + @ApiOperation("修改店铺绑定的经营类目") + @PreAuthorize("@el.check('merchant:store:platformCategory')" + + " and @storeMerchantOwnershipService.check(#storeId)") + public ResponseEntity<?> updatePlatformCategory(@PathVariable("storeId") Long storeId, + @Validated(value = StoreFieldUpdateRequest.UpdateStorePlatformCategoryGroup.class) + @RequestBody StoreFieldUpdateRequest request) { + storeService.updatePlatformCategory(storeId, request.getPlatformCategoryId()); + return ResponseEntity.noContent().build(); + } + + /** + * 修改店铺营业时间 + */ + @PatchMapping(value = "/{storeId}/businessHours") + @ApiOperation("修改店铺营业时间") + @PreAuthorize("@el.check('merchant:store:businessHours')" + + " and @storeMerchantOwnershipService.check(#storeId)") + public ResponseEntity<?> updateBusinessHours(@PathVariable("storeId") Long storeId, + @Validated(value = StoreFieldUpdateRequest.UpdateStoreBusinessHoursGroup.class) + @RequestBody StoreFieldUpdateRequest request) { + storeService.updateBusinessHours(storeId, request.getOpenTime(), request.getCloseTime()); + return ResponseEntity.noContent().build(); + } + + /** + * 修改起送金额 + */ + @PatchMapping(value = "/{storeId}/deliveryMinimum") + @ApiOperation("修改起送金额") + @PreAuthorize("@el.check('merchant:store:deliveryMinimum')" + + " and @storeMerchantOwnershipService.check(#storeId)") + public ResponseEntity<?> updateDeliveryMinimum(@PathVariable("storeId") Long storeId, + @Validated(value = StoreFieldUpdateRequest.UpdateStoreDeliveryMinimumGroup.class) + @RequestBody StoreFieldUpdateRequest request) { + storeService.updateDeliveryMinimum(storeId, request.getDeliveryMinimum()); + return ResponseEntity.noContent().build(); + } + + /** + * 修改配送费用 + */ + @PatchMapping(value = "/{storeId}/deliveryFee") + @ApiOperation("修改配送费用") + @PreAuthorize("@el.check('merchant:store:deliveryFee')" + + " and @storeMerchantOwnershipService.check(#storeId)") + public ResponseEntity<?> updateDeliveryFee(@PathVariable("storeId") Long storeId, + @Validated(value = StoreFieldUpdateRequest.UpdateStoreDeliveryFeeGroup.class) + @RequestBody StoreFieldUpdateRequest request) { + storeService.updateDeliveryFee(storeId, request.getDeliveryFee()); + return ResponseEntity.noContent().build(); + } + + /** + * 修改状态 + */ + @PatchMapping(value = "/{storeId}/businessStatus") + @ApiOperation("修改状态") + @PreAuthorize("@el.check('merchant:store:businessStatus')" + + " and @storeMerchantOwnershipService.check(#storeId)") + public ResponseEntity<?> businessStatus(@PathVariable("storeId") Long storeId, + @Validated(value = StoreFieldUpdateRequest.UpdateStoreBusinessStatusGroup.class) + @RequestBody StoreFieldUpdateRequest request) { + storeService.updateStatus(storeId, request.getBusinessStatus()); + return ResponseEntity.noContent().build(); + } +} -- Gitblit v1.9.3