增加根据租电套餐id获取租电套餐的接口

This commit is contained in:
2025-07-28 22:04:59 +08:00
parent dfbf490905
commit 2ec971c620
4 changed files with 71 additions and 2 deletions

View File

@ -0,0 +1,37 @@
package com.sczx.car.controller;
import com.sczx.car.common.Result;
import com.sczx.car.dto.RentBatteyRuleDTO;
import com.sczx.car.service.RentBatteyRuleService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
/**
* <p>
* 车型表 前端控制器
* </p>
*
* @author zhangli
* @since 2025-07-12 19:55:31
*/
@Api(value = "租电套餐接口", tags = "套餐接口")
@RestController
@RequestMapping("/batteyRule")
public class RentBatteyRuleController {
@Autowired
private RentBatteyRuleService rentBatteyRuleService;
@ApiOperation(value = "根据租电套餐id查询租电套餐")
@GetMapping("/getRentBatteyRuleByBatteyRuleId")
public Result<RentBatteyRuleDTO> getRentBatteyRuleByBatteyRuleId(@RequestParam(name = "batteyRuleId") Long batteyRuleId){
return Result.ok(rentBatteyRuleService.getRentBatteyRuleByBatteyRuleId(batteyRuleId));
}
}

View File

@ -20,7 +20,7 @@ import org.springframework.web.bind.annotation.RestController;
* @author zhangli
* @since 2025-07-12 19:55:31
*/
@Api(value = "车型接口", tags = "车型相关")
@Api(value = "租车套餐接口", tags = "套餐接口")
@RestController
@RequestMapping("/carRule")
public class RentCarRuleController {
@ -29,7 +29,7 @@ public class RentCarRuleController {
private RentCarRuleService rentCarRuleService;
@ApiOperation(value = "根据租车规则id查询车型")
@ApiOperation(value = "根据租车套餐id查询租电套餐")
@GetMapping("/getRentCarRuleByCarRuleId")
public Result<RentCarRuleDTO> getRentCarRuleByCarRuleId(@RequestParam(name = "carRuleId") Long carRuleId){
return Result.ok(rentCarRuleService.getRentCarRuleByCarRuleId(carRuleId));

View File

@ -0,0 +1,8 @@
package com.sczx.car.service;
import com.sczx.car.dto.RentBatteyRuleDTO;
public interface RentBatteyRuleService {
RentBatteyRuleDTO getRentBatteyRuleByBatteyRuleId(Long carRuleId);
}

View File

@ -0,0 +1,24 @@
package com.sczx.car.service.impl;
import com.sczx.car.convert.RentBatteyRuleConvert;
import com.sczx.car.dto.RentBatteyRuleDTO;
import com.sczx.car.po.RentBatteyRulePO;
import com.sczx.car.repository.RentBatteyRuleRepo;
import com.sczx.car.service.RentBatteyRuleService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Slf4j
@Service
public class RentBatteyRuleServiceImpl implements RentBatteyRuleService {
@Autowired
private RentBatteyRuleRepo rentBatteyRuleRepo;
@Override
public RentBatteyRuleDTO getRentBatteyRuleByBatteyRuleId(Long carRuleId) {
RentBatteyRulePO rentBatteyRulePO = rentBatteyRuleRepo.getById(carRuleId);
return RentBatteyRuleConvert.INSTANCE.poToDto(rentBatteyRulePO);
}
}