From bc7ec98b131a78a0fd86d0d64eeba9ee57b60f51 Mon Sep 17 00:00:00 2001 From: zhangli <123879394@qq.com> Date: Mon, 28 Jul 2025 20:36:27 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=A0=B9=E6=8D=AE=E7=A7=9F?= =?UTF-8?q?=E8=BD=A6=E5=A5=97=E9=A4=90id=E8=8E=B7=E5=8F=96=E7=A7=9F?= =?UTF-8?q?=E7=94=B5=E5=A5=97=E9=A4=90=E7=9A=84=E6=8E=A5=E5=8F=A3=EF=BC=8C?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=94=B5=E6=B1=A0=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../car/controller/CarRentalController.java | 6 ++---- .../com/sczx/car/dto/RentBatteyRuleDTO.java | 3 +++ .../com/sczx/car/dto/RentBatteyRuleRsp.java | 20 +++++++++++++++++++ .../sczx/car/service/CarRentalService.java | 6 ++---- .../service/impl/CarRentalServiceImpl.java | 18 +++++++++++++++-- .../resources/mapper/RentBatteyRuleMapper.xml | 4 +++- 6 files changed, 46 insertions(+), 11 deletions(-) create mode 100644 src/main/java/com/sczx/car/dto/RentBatteyRuleRsp.java diff --git a/src/main/java/com/sczx/car/controller/CarRentalController.java b/src/main/java/com/sczx/car/controller/CarRentalController.java index 2c2b9c6..83311e8 100644 --- a/src/main/java/com/sczx/car/controller/CarRentalController.java +++ b/src/main/java/com/sczx/car/controller/CarRentalController.java @@ -3,7 +3,7 @@ package com.sczx.car.controller; import com.sczx.car.common.Result; import com.sczx.car.dto.CarRentalDetailDTO; -import com.sczx.car.dto.RentBatteyRuleDTO; +import com.sczx.car.dto.RentBatteyRuleRsp; import com.sczx.car.service.CarRentalService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @@ -13,8 +13,6 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; -import java.util.List; - /** *

* 车型表 前端控制器 @@ -40,7 +38,7 @@ public class CarRentalController { @ApiOperation(value = "根据租车套餐id查询租店套餐列表") @GetMapping("/listRentBatteyRuleByCarRuleId") - public Result> listRentBatteyRuleByCarRuleId(@RequestParam(name = "carRuleId") Integer carRuleId){ + public Result listRentBatteyRuleByCarRuleId(@RequestParam(name = "carRuleId") Integer carRuleId){ return Result.ok(carRentalService.queryRentBatteyRuleByCarRuleId(carRuleId)); } } diff --git a/src/main/java/com/sczx/car/dto/RentBatteyRuleDTO.java b/src/main/java/com/sczx/car/dto/RentBatteyRuleDTO.java index 0b75239..bb2293c 100644 --- a/src/main/java/com/sczx/car/dto/RentBatteyRuleDTO.java +++ b/src/main/java/com/sczx/car/dto/RentBatteyRuleDTO.java @@ -72,6 +72,9 @@ public class RentBatteyRuleDTO { @ApiModelProperty("电池类型") private Integer categoryId; + @ApiModelProperty("电池类型名称") + private String categoryName; + @ApiModelProperty("套餐类型 换电/租电") private Integer mealType; diff --git a/src/main/java/com/sczx/car/dto/RentBatteyRuleRsp.java b/src/main/java/com/sczx/car/dto/RentBatteyRuleRsp.java new file mode 100644 index 0000000..f90baad --- /dev/null +++ b/src/main/java/com/sczx/car/dto/RentBatteyRuleRsp.java @@ -0,0 +1,20 @@ +package com.sczx.car.dto; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.List; + +@ApiModel(value = "租电套餐计费规则返回对象") +@Data +public class RentBatteyRuleRsp { + + @ApiModelProperty("电池名称列表") + private List categoryNameList; + + @ApiModelProperty("租电套餐计费规则列表") + private List rentBatteyRuleList; + + +} diff --git a/src/main/java/com/sczx/car/service/CarRentalService.java b/src/main/java/com/sczx/car/service/CarRentalService.java index 1d8531a..79961f6 100644 --- a/src/main/java/com/sczx/car/service/CarRentalService.java +++ b/src/main/java/com/sczx/car/service/CarRentalService.java @@ -1,9 +1,7 @@ package com.sczx.car.service; import com.sczx.car.dto.CarRentalDetailDTO; -import com.sczx.car.dto.RentBatteyRuleDTO; - -import java.util.List; +import com.sczx.car.dto.RentBatteyRuleRsp; public interface CarRentalService { @@ -22,5 +20,5 @@ public interface CarRentalService { * @param carRuleId * @return */ - List queryRentBatteyRuleByCarRuleId(Integer carRuleId); + RentBatteyRuleRsp queryRentBatteyRuleByCarRuleId(Integer carRuleId); } diff --git a/src/main/java/com/sczx/car/service/impl/CarRentalServiceImpl.java b/src/main/java/com/sczx/car/service/impl/CarRentalServiceImpl.java index 297a045..2d417f0 100644 --- a/src/main/java/com/sczx/car/service/impl/CarRentalServiceImpl.java +++ b/src/main/java/com/sczx/car/service/impl/CarRentalServiceImpl.java @@ -3,6 +3,8 @@ package com.sczx.car.service.impl; import com.sczx.car.convert.CarModelConvert; import com.sczx.car.dto.CarRentalDetailDTO; import com.sczx.car.dto.RentBatteyRuleDTO; +import com.sczx.car.dto.RentBatteyRuleRsp; +import com.sczx.car.exception.BizException; import com.sczx.car.po.CarModelPO; import com.sczx.car.repository.CarModelRepo; import com.sczx.car.repository.RentBatteyRuleRepo; @@ -12,8 +14,10 @@ import com.sczx.car.thirdpart.integration.StoreInteg; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.springframework.util.CollectionUtils; import java.util.List; +import java.util.stream.Collectors; @Slf4j @Service @@ -47,7 +51,17 @@ public class CarRentalServiceImpl implements CarRentalService { } @Override - public List queryRentBatteyRuleByCarRuleId(Integer carRuleId) { - return rentBatteyRuleRepo.queryRentBatteyRuleByCarRuleId(carRuleId); + public RentBatteyRuleRsp queryRentBatteyRuleByCarRuleId(Integer carRuleId) { + + List rentBatteyRuleList = rentBatteyRuleRepo.queryRentBatteyRuleByCarRuleId(carRuleId); + if(CollectionUtils.isEmpty(rentBatteyRuleList)){ + throw new BizException("无对应租电套餐,请重新选择租车套餐"); + }else { + RentBatteyRuleRsp rentBatteyRuleRsp = new RentBatteyRuleRsp(); + rentBatteyRuleRsp.setRentBatteyRuleList(rentBatteyRuleList); + List categoryNameList = rentBatteyRuleList.stream().map(RentBatteyRuleDTO::getCategoryName).distinct().collect(Collectors.toList()); + rentBatteyRuleRsp.setCategoryNameList(categoryNameList); + return rentBatteyRuleRsp; + } } } diff --git a/src/main/resources/mapper/RentBatteyRuleMapper.xml b/src/main/resources/mapper/RentBatteyRuleMapper.xml index fad1b9b..b1b5bc3 100644 --- a/src/main/resources/mapper/RentBatteyRuleMapper.xml +++ b/src/main/resources/mapper/RentBatteyRuleMapper.xml @@ -4,11 +4,13 @@