修改根据租车套餐id获取租电套餐的接口,增加电池列表
This commit is contained in:
@ -3,7 +3,7 @@ package com.sczx.car.controller;
|
|||||||
|
|
||||||
import com.sczx.car.common.Result;
|
import com.sczx.car.common.Result;
|
||||||
import com.sczx.car.dto.CarRentalDetailDTO;
|
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 com.sczx.car.service.CarRentalService;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiOperation;
|
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.RequestParam;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
* 车型表 前端控制器
|
* 车型表 前端控制器
|
||||||
@ -40,7 +38,7 @@ public class CarRentalController {
|
|||||||
|
|
||||||
@ApiOperation(value = "根据租车套餐id查询租店套餐列表")
|
@ApiOperation(value = "根据租车套餐id查询租店套餐列表")
|
||||||
@GetMapping("/listRentBatteyRuleByCarRuleId")
|
@GetMapping("/listRentBatteyRuleByCarRuleId")
|
||||||
public Result<List<RentBatteyRuleDTO>> listRentBatteyRuleByCarRuleId(@RequestParam(name = "carRuleId") Integer carRuleId){
|
public Result<RentBatteyRuleRsp> listRentBatteyRuleByCarRuleId(@RequestParam(name = "carRuleId") Integer carRuleId){
|
||||||
return Result.ok(carRentalService.queryRentBatteyRuleByCarRuleId(carRuleId));
|
return Result.ok(carRentalService.queryRentBatteyRuleByCarRuleId(carRuleId));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -72,6 +72,9 @@ public class RentBatteyRuleDTO {
|
|||||||
@ApiModelProperty("电池类型")
|
@ApiModelProperty("电池类型")
|
||||||
private Integer categoryId;
|
private Integer categoryId;
|
||||||
|
|
||||||
|
@ApiModelProperty("电池类型名称")
|
||||||
|
private String categoryName;
|
||||||
|
|
||||||
@ApiModelProperty("套餐类型 换电/租电")
|
@ApiModelProperty("套餐类型 换电/租电")
|
||||||
private Integer mealType;
|
private Integer mealType;
|
||||||
|
|
||||||
|
|||||||
20
src/main/java/com/sczx/car/dto/RentBatteyRuleRsp.java
Normal file
20
src/main/java/com/sczx/car/dto/RentBatteyRuleRsp.java
Normal file
@ -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<String> categoryNameList;
|
||||||
|
|
||||||
|
@ApiModelProperty("租电套餐计费规则列表")
|
||||||
|
private List<RentBatteyRuleDTO> rentBatteyRuleList;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -1,9 +1,7 @@
|
|||||||
package com.sczx.car.service;
|
package com.sczx.car.service;
|
||||||
|
|
||||||
import com.sczx.car.dto.CarRentalDetailDTO;
|
import com.sczx.car.dto.CarRentalDetailDTO;
|
||||||
import com.sczx.car.dto.RentBatteyRuleDTO;
|
import com.sczx.car.dto.RentBatteyRuleRsp;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public interface CarRentalService {
|
public interface CarRentalService {
|
||||||
|
|
||||||
@ -22,5 +20,5 @@ public interface CarRentalService {
|
|||||||
* @param carRuleId
|
* @param carRuleId
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
List<RentBatteyRuleDTO> queryRentBatteyRuleByCarRuleId(Integer carRuleId);
|
RentBatteyRuleRsp queryRentBatteyRuleByCarRuleId(Integer carRuleId);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,6 +3,8 @@ package com.sczx.car.service.impl;
|
|||||||
import com.sczx.car.convert.CarModelConvert;
|
import com.sczx.car.convert.CarModelConvert;
|
||||||
import com.sczx.car.dto.CarRentalDetailDTO;
|
import com.sczx.car.dto.CarRentalDetailDTO;
|
||||||
import com.sczx.car.dto.RentBatteyRuleDTO;
|
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.po.CarModelPO;
|
||||||
import com.sczx.car.repository.CarModelRepo;
|
import com.sczx.car.repository.CarModelRepo;
|
||||||
import com.sczx.car.repository.RentBatteyRuleRepo;
|
import com.sczx.car.repository.RentBatteyRuleRepo;
|
||||||
@ -12,8 +14,10 @@ import com.sczx.car.thirdpart.integration.StoreInteg;
|
|||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.util.CollectionUtils;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Service
|
@Service
|
||||||
@ -47,7 +51,17 @@ public class CarRentalServiceImpl implements CarRentalService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<RentBatteyRuleDTO> queryRentBatteyRuleByCarRuleId(Integer carRuleId) {
|
public RentBatteyRuleRsp queryRentBatteyRuleByCarRuleId(Integer carRuleId) {
|
||||||
return rentBatteyRuleRepo.queryRentBatteyRuleByCarRuleId(carRuleId);
|
|
||||||
|
List<RentBatteyRuleDTO> rentBatteyRuleList = rentBatteyRuleRepo.queryRentBatteyRuleByCarRuleId(carRuleId);
|
||||||
|
if(CollectionUtils.isEmpty(rentBatteyRuleList)){
|
||||||
|
throw new BizException("无对应租电套餐,请重新选择租车套餐");
|
||||||
|
}else {
|
||||||
|
RentBatteyRuleRsp rentBatteyRuleRsp = new RentBatteyRuleRsp();
|
||||||
|
rentBatteyRuleRsp.setRentBatteyRuleList(rentBatteyRuleList);
|
||||||
|
List<String> categoryNameList = rentBatteyRuleList.stream().map(RentBatteyRuleDTO::getCategoryName).distinct().collect(Collectors.toList());
|
||||||
|
rentBatteyRuleRsp.setCategoryNameList(categoryNameList);
|
||||||
|
return rentBatteyRuleRsp;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,11 +4,13 @@
|
|||||||
|
|
||||||
<select id="queryRentBatteyRuleByCarRuleId" resultType="com.sczx.car.dto.RentBatteyRuleDTO">
|
<select id="queryRentBatteyRuleByCarRuleId" resultType="com.sczx.car.dto.RentBatteyRuleDTO">
|
||||||
SELECT
|
SELECT
|
||||||
b.*
|
b.*,c.category_name
|
||||||
FROM
|
FROM
|
||||||
zc_rent_car_rule_battery rcb
|
zc_rent_car_rule_battery rcb
|
||||||
JOIN
|
JOIN
|
||||||
zc_rent_battey_rule b ON rcb.battery_rule_id = b.id
|
zc_rent_battey_rule b ON rcb.battery_rule_id = b.id
|
||||||
|
JOIN
|
||||||
|
zc_battery_category c ON b.category_id = c.id
|
||||||
WHERE
|
WHERE
|
||||||
rcb.car_rule_id = #{carRuleId}
|
rcb.car_rule_id = #{carRuleId}
|
||||||
AND b.is_delete = 0
|
AND b.is_delete = 0
|
||||||
|
|||||||
Reference in New Issue
Block a user