增加获取车型和套餐接口
This commit is contained in:
@ -1,15 +1,16 @@
|
||||
package com.sczx.car.controller;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.sczx.car.common.Result;
|
||||
import com.sczx.car.dto.CarModelSimpleDTO;
|
||||
import com.sczx.car.dto.req.StoreCarModelReq;
|
||||
import com.sczx.car.service.CarModelService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
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>
|
||||
@ -19,7 +20,7 @@ import org.springframework.web.bind.annotation.*;
|
||||
* @author zhangli
|
||||
* @since 2025-07-12 19:55:31
|
||||
*/
|
||||
@Api(value = "车型接口", tags = "车型相关")
|
||||
@Api(value = "租车套餐规则接口", tags = "租车套餐规则接口")
|
||||
@RestController
|
||||
@RequestMapping("/carModel")
|
||||
public class CarModelController {
|
||||
@ -27,11 +28,11 @@ public class CarModelController {
|
||||
@Autowired
|
||||
private CarModelService carModelService;
|
||||
|
||||
@ApiOperation(value = "分页查询门店车型列表")
|
||||
@PostMapping("/pageStoreCarModel")
|
||||
public Result<IPage<CarModelSimpleDTO>> pageStoreCarModel(@RequestParam(name = "pageNo", required = false, defaultValue = "1") Integer pageNo,
|
||||
@RequestParam(name = "pageSize", required = false, defaultValue = "10") Integer pageSize,
|
||||
@RequestBody StoreCarModelReq storeCarModelReq){
|
||||
return Result.ok(carModelService.pageCarModelSimpleDTO(storeCarModelReq, pageNo, pageSize));
|
||||
|
||||
@ApiOperation(value = "根据车型id查询车型")
|
||||
@GetMapping("/getCarModelByModelId")
|
||||
public Result<CarModelSimpleDTO> getCarModelByModelId(@RequestParam(name = "modelId") Long modelId){
|
||||
return Result.ok(carModelService.getCarModelByModelId(modelId));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,37 @@
|
||||
package com.sczx.car.controller;
|
||||
|
||||
|
||||
import com.sczx.car.common.Result;
|
||||
import com.sczx.car.dto.RentCarRuleDTO;
|
||||
import com.sczx.car.service.RentCarRuleService;
|
||||
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("/carRule")
|
||||
public class RentCarRuleController {
|
||||
|
||||
@Autowired
|
||||
private RentCarRuleService rentCarRuleService;
|
||||
|
||||
|
||||
@ApiOperation(value = "根据租车规则id查询车型")
|
||||
@GetMapping("/getRentCarRuleByCarRuleId")
|
||||
public Result<RentCarRuleDTO> getRentCarRuleByCarRuleId(@RequestParam(name = "carRuleId") Long carRuleId){
|
||||
return Result.ok(rentCarRuleService.getRentCarRuleByCarRuleId(carRuleId));
|
||||
}
|
||||
}
|
||||
12
src/main/java/com/sczx/car/convert/RentCarRuleConvert.java
Normal file
12
src/main/java/com/sczx/car/convert/RentCarRuleConvert.java
Normal file
@ -0,0 +1,12 @@
|
||||
package com.sczx.car.convert;
|
||||
|
||||
import com.sczx.car.dto.RentCarRuleDTO;
|
||||
import com.sczx.car.po.RentCarRulePO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
@Mapper
|
||||
public interface RentCarRuleConvert {
|
||||
RentCarRuleConvert INSTANCE = Mappers.getMapper(RentCarRuleConvert.class);
|
||||
RentCarRuleDTO poToDTO(RentCarRulePO po);
|
||||
}
|
||||
@ -34,4 +34,7 @@ public class CarModelSimpleDTO {
|
||||
|
||||
@ApiModelProperty("电池类型")
|
||||
private String batteryType;
|
||||
|
||||
@ApiModelProperty("车型照片")
|
||||
private String image;
|
||||
}
|
||||
|
||||
@ -12,4 +12,11 @@ public interface CarModelService {
|
||||
* @return
|
||||
*/
|
||||
IPage<CarModelSimpleDTO> pageCarModelSimpleDTO(StoreCarModelReq storeCarModelReq, Integer pageNo, Integer pageSize);
|
||||
|
||||
/**
|
||||
* 根据车型ID查询车型信息
|
||||
* @param modelId
|
||||
* @return
|
||||
*/
|
||||
CarModelSimpleDTO getCarModelByModelId(Long modelId);
|
||||
}
|
||||
|
||||
@ -0,0 +1,7 @@
|
||||
package com.sczx.car.service;
|
||||
|
||||
import com.sczx.car.dto.RentCarRuleDTO;
|
||||
|
||||
public interface RentCarRuleService {
|
||||
RentCarRuleDTO getRentCarRuleByCarRuleId(Long carRuleId);
|
||||
}
|
||||
@ -1,8 +1,10 @@
|
||||
package com.sczx.car.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.sczx.car.convert.CarModelConvert;
|
||||
import com.sczx.car.dto.CarModelSimpleDTO;
|
||||
import com.sczx.car.dto.req.StoreCarModelReq;
|
||||
import com.sczx.car.po.CarModelPO;
|
||||
import com.sczx.car.repository.CarModelRepo;
|
||||
import com.sczx.car.service.CarModelService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@ -19,4 +21,10 @@ public class CarModelServiceImpl implements CarModelService {
|
||||
public IPage<CarModelSimpleDTO> pageCarModelSimpleDTO(StoreCarModelReq storeCarModelReq, Integer pageNo, Integer pageSize) {
|
||||
return carModelRepo.pageCarModelSimpleDTO(storeCarModelReq, pageNo, pageSize);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CarModelSimpleDTO getCarModelByModelId(Long modelId) {
|
||||
CarModelPO carModelPO = carModelRepo.getById(modelId);
|
||||
return CarModelConvert.INSTANCE.poToSimpleDTO(carModelPO);
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,23 @@
|
||||
package com.sczx.car.service.impl;
|
||||
|
||||
import com.sczx.car.convert.RentCarRuleConvert;
|
||||
import com.sczx.car.dto.RentCarRuleDTO;
|
||||
import com.sczx.car.po.RentCarRulePO;
|
||||
import com.sczx.car.repository.RentCarRuleRepo;
|
||||
import com.sczx.car.service.RentCarRuleService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
public class RentCarRuleServiceImpl implements RentCarRuleService {
|
||||
|
||||
@Autowired
|
||||
private RentCarRuleRepo rentCarRuleRepo;
|
||||
@Override
|
||||
public RentCarRuleDTO getRentCarRuleByCarRuleId(Long carRuleId) {
|
||||
RentCarRulePO rentCarRulePO = rentCarRuleRepo.getById(carRuleId);
|
||||
return RentCarRuleConvert.INSTANCE.poToDTO(rentCarRulePO);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user