From 7021b2864edc47fdf8a3cc81865bab0ce2f6cc85 Mon Sep 17 00:00:00 2001 From: jevononlie <728254585@qq.com> Date: Mon, 22 Apr 2024 17:59:42 +0800 Subject: [PATCH] =?UTF-8?q?review-list:=20=E4=BA=8C=E7=BA=A7=E7=B1=BB?= =?UTF-8?q?=E7=9B=AE=EF=BC=8C=E6=95=A3=E6=88=B7=E7=AB=AF=EF=BC=9B=E5=9B=9E?= =?UTF-8?q?=E6=94=B6=E7=AB=AF=E7=A1=AE=E8=AE=A4=E5=9B=9E=E6=94=B6todo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cc/yunxi/common/utils/CommonUtil.java | 24 +++++++++++++- .../controller/RecycleStationController.java | 24 +++++++++++--- .../cc/yunxi/controller/TestController.java | 10 +++--- .../RecycleOrderDetailCreateVO.java | 6 ++-- .../mapper/RecycleStationPriceMapper.java | 21 ++++++++++++ .../yunxi/service/IRecycleStationService.java | 18 ++++++++++ .../impl/RecycleStationServiceImpl.java | 15 ++++++++- .../mapper/RecycleStationPriceMapper.xml | 33 +++++++++++++++++++ 8 files changed, 137 insertions(+), 14 deletions(-) diff --git a/nxhs-common/src/main/java/cc/yunxi/common/utils/CommonUtil.java b/nxhs-common/src/main/java/cc/yunxi/common/utils/CommonUtil.java index e3f3445..9239333 100644 --- a/nxhs-common/src/main/java/cc/yunxi/common/utils/CommonUtil.java +++ b/nxhs-common/src/main/java/cc/yunxi/common/utils/CommonUtil.java @@ -111,12 +111,34 @@ public class CommonUtil { * @return */ public static List getChildrenList(String parentId, List dataList) { + List voList = new ArrayList<>(); + dataList.forEach(v -> { + if(v != null) { + String pid = (String) obtainField(v, "parentId"); + if (Objects.equals(pid, parentId)) { + String id = (String) obtainField(v, "id"); + List children = getChildrenList(id, dataList); + assignField(v, "children", children); + voList.add(v); + } + } + }); + return voList; + } + + /** + * 获取子节点 + * @param parentId + * @param dataList + * @return + */ + public static List getChildrenList2(String parentId, List dataList) { List voList = new ArrayList<>(); dataList.forEach(v -> { String pid = (String) obtainField(v, "parentId"); if (Objects.equals(pid, parentId)) { String id = (String) obtainField(v, "id"); - List children = getChildrenList(id, dataList); + List children = getChildrenList2(id, dataList); assignField(v, "children", children); voList.add(v); } diff --git a/nxhs-service/src/main/java/cc/yunxi/controller/RecycleStationController.java b/nxhs-service/src/main/java/cc/yunxi/controller/RecycleStationController.java index 819f6b9..639a7b9 100644 --- a/nxhs-service/src/main/java/cc/yunxi/controller/RecycleStationController.java +++ b/nxhs-service/src/main/java/cc/yunxi/controller/RecycleStationController.java @@ -66,6 +66,22 @@ public class RecycleStationController { } + @ApiOperation("回收站详情") + @GetMapping("/info2") + public CommonResult stationInfo2(@RequestParam("stationId") String stationId, @Valid LocationDTO location) { + RecycleStation station = recycleStationService.getStationById(stationId); + RecycleStationRespVO recycleStationRespVO = BeanUtils.copyBean(station, RecycleStationRespVO.class); + + if (ObjectUtil.isNotEmpty(station)) { + recycleStationRespVO = BeanUtils.copyBean(station, RecycleStationRespVO.class); + List productList = recycleStationService.getStationProduct(station.getId()); + List productTreeList = CommonUtil.getChildrenList(null, productList); + recycleStationRespVO.setStationProducts(productTreeList); + this.computeStationDistance(recycleStationRespVO, location); + } + return CommonResult.success(recycleStationRespVO); + } + @ApiOperation("回收站详情") @GetMapping("/info") public CommonResult stationInfo(@RequestParam("stationId") String stationId, @Valid LocationDTO location) { @@ -73,7 +89,7 @@ public class RecycleStationController { RecycleStationRespVO recycleStationRespVO = BeanUtils.copyBean(station, RecycleStationRespVO.class); if (ObjectUtil.isNotEmpty(station)) { recycleStationRespVO = BeanUtils.copyBean(station, RecycleStationRespVO.class); - List productList = recycleStationService.getStationProduct(station.getId()); + List productList = recycleStationService.getStationProductAllByStationId(station.getId()); List productTreeList = CommonUtil.getChildrenList(null, productList); recycleStationRespVO.setStationProducts(productTreeList); this.computeStationDistance(recycleStationRespVO, location); @@ -85,12 +101,11 @@ public class RecycleStationController { @ApiOperation("回收站废品价格类目") @GetMapping("/price-product") public CommonResult> stationProduct(@RequestParam("stationId") String stationId) { - List productList = recycleStationService.getStationProduct(stationId); + List productList = recycleStationService.getStationProductAllByStationId(stationId); List productTreeList = CommonUtil.getChildrenList(null, productList); return CommonResult.success(productTreeList); } - @ApiOperation("附近的回收站") @GetMapping("/nearby") public CommonResult stationNearby(@Valid LocationDTO location) { @@ -98,7 +113,8 @@ public class RecycleStationController { RecycleStationRespVO stationRespVO = null; if (ObjectUtil.isNotEmpty(nearbyStation)) { stationRespVO = BeanUtils.copyBean(nearbyStation, RecycleStationRespVO.class); - List produceList = recycleStationService.getStationProduct(nearbyStation.getId()); + List produceList = recycleStationService.getStationProductFirstByStationId(nearbyStation.getId()); + stationRespVO.setStationProducts(produceList); this.computeStationDistance(stationRespVO, location); } diff --git a/nxhs-service/src/main/java/cc/yunxi/controller/TestController.java b/nxhs-service/src/main/java/cc/yunxi/controller/TestController.java index 5111b66..35824f9 100644 --- a/nxhs-service/src/main/java/cc/yunxi/controller/TestController.java +++ b/nxhs-service/src/main/java/cc/yunxi/controller/TestController.java @@ -9,8 +9,8 @@ import cc.yunxi.domain.dto.UserDTO; import cc.yunxi.domain.query.TestQuery; import cc.yunxi.enums.UserTypeEnum; import cc.yunxi.service.ITestService; -import cc.yunxi.test.AppConfig; -import cc.yunxi.test.dal.Animal; +//import cc.yunxi.test.AppConfig; +//import cc.yunxi.test.dal.Animal; import cc.yunxi.utils.JwtTool; import cn.hutool.core.date.DatePattern; import cn.hutool.core.date.DateUtil; @@ -71,9 +71,9 @@ public class TestController { @ApiOperation("测试接口成功") @GetMapping("/test01") public CommonResult success() { - Animal animal = SpringUtil.getBean("animalObj", Animal.class); - AppConfig appConfig = SpringUtil.getBean("appConfig", AppConfig.class); - log.info("animal bean: {}, appConfig bean: {}", animal, appConfig); +// Animal animal = SpringUtil.getBean("animalObj", Animal.class); +// AppConfig appConfig = SpringUtil.getBean("appConfig", AppConfig.class); +// log.info("animal bean: {}, appConfig bean: {}", animal, appConfig); return CommonResult.success("ok"); } diff --git a/nxhs-service/src/main/java/cc/yunxi/domain/vo/recycleorderdetail/RecycleOrderDetailCreateVO.java b/nxhs-service/src/main/java/cc/yunxi/domain/vo/recycleorderdetail/RecycleOrderDetailCreateVO.java index c944d93..b30d57a 100644 --- a/nxhs-service/src/main/java/cc/yunxi/domain/vo/recycleorderdetail/RecycleOrderDetailCreateVO.java +++ b/nxhs-service/src/main/java/cc/yunxi/domain/vo/recycleorderdetail/RecycleOrderDetailCreateVO.java @@ -27,9 +27,9 @@ public class RecycleOrderDetailCreateVO { // @NotBlank(message = "商品名称不能为空") // private String productName; - @ApiModelProperty(value = "下单时回收单价", required = true) - @NotNull(message = "下单时回收单价不能为空") - @DecimalMin(value = "0.01", message = "下单时回收单价数值错误") + @ApiModelProperty(value = "下单时回收单价", required = false) +// @NotNull(message = "下单时回收单价不能为空") +// @DecimalMin(value = "0.01", message = "下单时回收单价数值错误") private BigDecimal recoveryPrice; @ApiModelProperty(value = "创建时间", hidden = true) diff --git a/nxhs-service/src/main/java/cc/yunxi/mapper/RecycleStationPriceMapper.java b/nxhs-service/src/main/java/cc/yunxi/mapper/RecycleStationPriceMapper.java index 8fb7881..30aa3a9 100644 --- a/nxhs-service/src/main/java/cc/yunxi/mapper/RecycleStationPriceMapper.java +++ b/nxhs-service/src/main/java/cc/yunxi/mapper/RecycleStationPriceMapper.java @@ -4,6 +4,7 @@ import cc.yunxi.domain.po.Price; import cc.yunxi.domain.po.PriceProduct; import cc.yunxi.domain.po.RecycleStation; import cc.yunxi.domain.po.RecycleStationPrice; +import cc.yunxi.domain.vo.priceproduct.ProductRespVO; import com.baomidou.mybatisplus.core.conditions.Wrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; @@ -12,6 +13,8 @@ import com.baomidou.mybatisplus.core.toolkit.Constants; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; +import java.util.List; + /** *

* 回收站价目关联 Mapper 接口 @@ -32,4 +35,22 @@ public interface RecycleStationPriceMapper extends BaseMapper wrapper); + /** + * 根据回收站id 查询一二级类目 + * @param stationId + * @return stationInfo + */ + List getStationInfoByStationId( + @Param("stationId") String stationId, + @Param(Constants.WRAPPER) Wrapper wrapper); + + /** + * 根据回收站id 查询一级类目 + * @param stationId + * @return stationInfo + */ + List getStationInfoFirstByStationId( + @Param("stationId") String stationId, + @Param(Constants.WRAPPER) Wrapper wrapper); + } diff --git a/nxhs-service/src/main/java/cc/yunxi/service/IRecycleStationService.java b/nxhs-service/src/main/java/cc/yunxi/service/IRecycleStationService.java index cadebd0..f7bf2c1 100644 --- a/nxhs-service/src/main/java/cc/yunxi/service/IRecycleStationService.java +++ b/nxhs-service/src/main/java/cc/yunxi/service/IRecycleStationService.java @@ -59,4 +59,22 @@ public interface IRecycleStationService extends IService { */ List getStationProduct(String stationId); + + /** + * 站点废品价目信息, 一二级全部信息 + * @param stationId + * @return RecycleOrder + */ + List getStationProductAllByStationId(String stationId); + + + /** + * 站点废品价目信息, 一级全部信息 + * @param stationId + * @return RecycleOrder + */ + List getStationProductFirstByStationId(String stationId); + + + } diff --git a/nxhs-service/src/main/java/cc/yunxi/service/impl/RecycleStationServiceImpl.java b/nxhs-service/src/main/java/cc/yunxi/service/impl/RecycleStationServiceImpl.java index a9933e7..cc301eb 100644 --- a/nxhs-service/src/main/java/cc/yunxi/service/impl/RecycleStationServiceImpl.java +++ b/nxhs-service/src/main/java/cc/yunxi/service/impl/RecycleStationServiceImpl.java @@ -106,7 +106,6 @@ public class RecycleStationServiceImpl extends ServiceImpl getStationProduct(String stationId) { QueryWrapper wrapper = new QueryWrapper().eq("a.status", GlobalStatusEnum.VALID); @@ -142,4 +141,18 @@ public class RecycleStationServiceImpl extends ServiceImpl getStationProductAllByStationId(String stationId) { + QueryWrapper wrapper = new QueryWrapper().eq("a.status", GlobalStatusEnum.VALID); + List res = recycleStationPriceMapper.getStationInfoByStationId(stationId, wrapper); + return res; + } + + @Override + public List getStationProductFirstByStationId(String stationId) { + QueryWrapper wrapper = new QueryWrapper().eq("a.status", GlobalStatusEnum.VALID); + List info = recycleStationPriceMapper.getStationInfoFirstByStationId(stationId, wrapper); + return info; + } + } diff --git a/nxhs-service/src/main/resources/mapper/RecycleStationPriceMapper.xml b/nxhs-service/src/main/resources/mapper/RecycleStationPriceMapper.xml index 47d1e4a..060277b 100644 --- a/nxhs-service/src/main/resources/mapper/RecycleStationPriceMapper.xml +++ b/nxhs-service/src/main/resources/mapper/RecycleStationPriceMapper.xml @@ -22,4 +22,37 @@ LIMIT 1; + + + + +