| | |
| | | package com.oying.modules.pc.store.rest; |
| | | |
| | | import cn.hutool.core.bean.BeanUtil; |
| | | import cn.hutool.core.bean.copier.CopyOptions; |
| | | import cn.hutool.core.util.ObjUtil; |
| | | import com.oying.modules.pc.product.domain.Product; |
| | | import com.oying.modules.pc.product.domain.dto.ProductQueryCriteria; |
| | |
| | | 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.GetMapping; |
| | | import org.springframework.web.bind.annotation.PathVariable; |
| | |
| | | public ResponseEntity<?> getStoreById(@PathVariable("storeId") Long storeId) { |
| | | Store store = storeService.getById(storeId); |
| | | CustomerStoreView view = new CustomerStoreView(); |
| | | BeanUtils.copyProperties(store, view); |
| | | BeanUtil.copyProperties(store, view, CopyOptions.create().setIgnoreNullValue(true)); |
| | | view.setBusinessHours(BusinessHoursUtils.formatBusinessHours(store.getOpenTime(), store.getCloseTime())); |
| | | return ResponseEntity.ok(R.success(view)); |
| | | } |
| | |
| | | @ApiOperation("查询店铺") |
| | | public ResponseEntity<?> getStoreDetailsById(@PathVariable("storeId") Long storeId) { |
| | | Store store = storeService.getById(storeId); |
| | | CustomerStoreView view = new CustomerStoreView(); |
| | | BeanUtil.copyProperties(store, view, CopyOptions.create().setIgnoreNullValue(true)); |
| | | view.setBusinessHours(BusinessHoursUtils.formatBusinessHours(store.getOpenTime(), store.getCloseTime())); |
| | | if (ObjUtil.isNotEmpty(store)) { |
| | | store.setQualifications(storeQualificationService.getByStoreId(storeId)); |
| | | view.setQualifications(storeQualificationService.getByStoreId(storeId)); |
| | | } |
| | | return ResponseEntity.ok(R.success(store)); |
| | | return ResponseEntity.ok(R.success(view)); |
| | | } |
| | | |
| | | private List<Product> getProductsByStoreId(Long storeId) { |
| | | ProductQueryCriteria criteria = new ProductQueryCriteria(); |
| | | criteria.setStoreId(storeId); |
| | | criteria.setStatus(ProductStatusEnum.AVAILABLE.getValue()); |
| | | criteria.setShelfStatus(ProductStatusEnum.AVAILABLE.getValue()); |
| | | criteria.setLimit(3); |
| | | return productService.queryAll(criteria); |
| | | } |