| | |
| | | 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 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; |
| | |
| | | |
| | | 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)); |
| | |
| | | |
| | | @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: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(); |
| | | } |
| | | |
| | |
| | | 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(); |
| | | } |
| | | |
| | |
| | | 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(); |
| | | } |
| | | |
| | |
| | | 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(); |
| | | } |
| | | |
| | |
| | | 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(); |
| | | } |
| | | |
| | |
| | | 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(); |
| | | } |
| | | |
| | |
| | | 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(); |
| | | } |
| | | |
| | |
| | | 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(); |
| | | } |
| | | |
| | |
| | | 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(); |
| | | } |
| | | |
| | |
| | | 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(); |
| | | } |
| | | |
| | |
| | | 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(); |
| | | } |
| | | |
| | |
| | | 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(); |
| | | } |
| | | |
| | |
| | | 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(); |
| | | } |
| | | } |