From a6f4dda63df5a7f468a6ec429d67e9c4095ce9f0 Mon Sep 17 00:00:00 2001 From: zepengdev <lzpsmith@outlook.com> Date: Fri, 13 Jun 2025 16:45:33 +0800 Subject: [PATCH] feat(product): 优化商品图片功能 refactor(store): 重构店铺-商户关联 fix(api): 标准化接口字段 --- oying-system/src/main/java/com/oying/modules/pc/store/rest/StoreCustomerController.java | 61 +++++++++++++++++++++++++++--- 1 files changed, 54 insertions(+), 7 deletions(-) diff --git a/oying-system/src/main/java/com/oying/modules/pc/store/rest/StoreCustomerController.java b/oying-system/src/main/java/com/oying/modules/pc/store/rest/StoreCustomerController.java index 0dfd954..04dd21d 100644 --- a/oying-system/src/main/java/com/oying/modules/pc/store/rest/StoreCustomerController.java +++ b/oying-system/src/main/java/com/oying/modules/pc/store/rest/StoreCustomerController.java @@ -1,14 +1,31 @@ package com.oying.modules.pc.store.rest; -import com.oying.utils.R; +import com.oying.modules.pc.product.domain.Product; +import com.oying.modules.pc.product.domain.dto.ProductQueryCriteria; +import com.oying.modules.pc.product.domain.enums.ProductStatusEnum; +import com.oying.modules.pc.product.service.ProductService; +import com.oying.modules.pc.store.domain.Store; +import com.oying.modules.pc.store.domain.StoreQualification; import com.oying.modules.pc.store.domain.dto.StoreCustomerDetailDto; -import com.oying.modules.pc.store.domain.dto.StoreCustomerQueryCriteria; +import com.oying.modules.pc.store.domain.dto.StoreQualificationQueryCriteria; +import com.oying.modules.pc.store.domain.dto.StoreQueryCriteria; +import com.oying.modules.pc.store.service.StoreQualificationService; import com.oying.modules.pc.store.service.StoreQueryService; +import com.oying.modules.pc.store.service.StoreService; +import com.oying.modules.pc.utils.BusinessHoursUtils; +import com.oying.utils.PageResult; +import com.oying.utils.R; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.RequiredArgsConstructor; +import org.springframework.beans.BeanUtils; import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.*; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.List; /** * 店铺 @@ -22,15 +39,45 @@ @RequiredArgsConstructor public class StoreCustomerController { + private final StoreService storeService; private final StoreQueryService storeQueryService; + private final StoreQualificationService storeQualificationService; + private final ProductService productService; + + @GetMapping(value = "/page") + @ApiOperation("查询店铺") + public ResponseEntity<?> getStoresByPage(StoreQueryCriteria criteria) { + PageResult<Store> pagedStores = storeQueryService.findPagedStores(criteria); + List<Store> stores = pagedStores.getContent(); + for (Store store : stores) { + store.setProducts(this.getProductsByStoreId(store.getStoreId())); + } + return ResponseEntity.ok(R.success(stores)); + } @GetMapping(value = "/{storeId}") @ApiOperation("查询店铺") - public ResponseEntity<?> getCustomerStoreById(@PathVariable("storeId") Long storeId) { - StoreCustomerQueryCriteria criteria = new StoreCustomerQueryCriteria(); + public ResponseEntity<?> getStoreDetailsById(@PathVariable("storeId") Long storeId) { + Store store = storeService.getById(storeId); + //store.setQualifications(this.getQualificationsByStoreId(store.getStoreId())); + StoreCustomerDetailDto storeDto = new StoreCustomerDetailDto(); + BeanUtils.copyProperties(store, storeDto); + storeDto.setBusinessHours(BusinessHoursUtils.formatBusinessHours(store.getOpenTime(), store.getCloseTime())); + return ResponseEntity.ok(R.success(storeDto)); + } + + private List<StoreQualification> getQualificationsByStoreId(Long storeId) { + StoreQualificationQueryCriteria criteria = new StoreQualificationQueryCriteria(); criteria.setStoreId(storeId); - StoreCustomerDetailDto detailDto = storeQueryService.getCustomerStoreDetail(criteria); - return ResponseEntity.ok(R.success(detailDto)); + return storeQualificationService.queryAll(criteria); + } + + private List<Product> getProductsByStoreId(Long storeId) { + ProductQueryCriteria criteria = new ProductQueryCriteria(); + criteria.setStoreId(storeId); + criteria.setStatus(ProductStatusEnum.AVAILABLE.getValue()); + criteria.setLimit(3); + return productService.queryAll(criteria); } } -- Gitblit v1.9.3