增加获取车型和套餐接口

This commit is contained in:
2025-07-26 23:27:24 +08:00
parent f4b46b4fcd
commit 96716607d6
8 changed files with 108 additions and 10 deletions

View File

@ -1,15 +1,16 @@
package com.sczx.car.controller; package com.sczx.car.controller;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.sczx.car.common.Result; import com.sczx.car.common.Result;
import com.sczx.car.dto.CarModelSimpleDTO; import com.sczx.car.dto.CarModelSimpleDTO;
import com.sczx.car.dto.req.StoreCarModelReq;
import com.sczx.car.service.CarModelService; import com.sczx.car.service.CarModelService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired; 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> * <p>
@ -19,7 +20,7 @@ import org.springframework.web.bind.annotation.*;
* @author zhangli * @author zhangli
* @since 2025-07-12 19:55:31 * @since 2025-07-12 19:55:31
*/ */
@Api(value = "车型接口", tags = "车型相关") @Api(value = "租车套餐规则接口", tags = "租车套餐规则接口")
@RestController @RestController
@RequestMapping("/carModel") @RequestMapping("/carModel")
public class CarModelController { public class CarModelController {
@ -27,11 +28,11 @@ public class CarModelController {
@Autowired @Autowired
private CarModelService carModelService; private CarModelService carModelService;
@ApiOperation(value = "分页查询门店车型列表")
@PostMapping("/pageStoreCarModel") @ApiOperation(value = "根据车型id查询车型")
public Result<IPage<CarModelSimpleDTO>> pageStoreCarModel(@RequestParam(name = "pageNo", required = false, defaultValue = "1") Integer pageNo, @GetMapping("/getCarModelByModelId")
@RequestParam(name = "pageSize", required = false, defaultValue = "10") Integer pageSize, public Result<CarModelSimpleDTO> getCarModelByModelId(@RequestParam(name = "modelId") Long modelId){
@RequestBody StoreCarModelReq storeCarModelReq){ return Result.ok(carModelService.getCarModelByModelId(modelId));
return Result.ok(carModelService.pageCarModelSimpleDTO(storeCarModelReq, pageNo, pageSize));
} }
} }

View File

@ -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));
}
}

View 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);
}

View File

@ -34,4 +34,7 @@ public class CarModelSimpleDTO {
@ApiModelProperty("电池类型") @ApiModelProperty("电池类型")
private String batteryType; private String batteryType;
@ApiModelProperty("车型照片")
private String image;
} }

View File

@ -12,4 +12,11 @@ public interface CarModelService {
* @return * @return
*/ */
IPage<CarModelSimpleDTO> pageCarModelSimpleDTO(StoreCarModelReq storeCarModelReq, Integer pageNo, Integer pageSize); IPage<CarModelSimpleDTO> pageCarModelSimpleDTO(StoreCarModelReq storeCarModelReq, Integer pageNo, Integer pageSize);
/**
* 根据车型ID查询车型信息
* @param modelId
* @return
*/
CarModelSimpleDTO getCarModelByModelId(Long modelId);
} }

View File

@ -0,0 +1,7 @@
package com.sczx.car.service;
import com.sczx.car.dto.RentCarRuleDTO;
public interface RentCarRuleService {
RentCarRuleDTO getRentCarRuleByCarRuleId(Long carRuleId);
}

View File

@ -1,8 +1,10 @@
package com.sczx.car.service.impl; package com.sczx.car.service.impl;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.sczx.car.convert.CarModelConvert;
import com.sczx.car.dto.CarModelSimpleDTO; import com.sczx.car.dto.CarModelSimpleDTO;
import com.sczx.car.dto.req.StoreCarModelReq; import com.sczx.car.dto.req.StoreCarModelReq;
import com.sczx.car.po.CarModelPO;
import com.sczx.car.repository.CarModelRepo; import com.sczx.car.repository.CarModelRepo;
import com.sczx.car.service.CarModelService; import com.sczx.car.service.CarModelService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@ -19,4 +21,10 @@ public class CarModelServiceImpl implements CarModelService {
public IPage<CarModelSimpleDTO> pageCarModelSimpleDTO(StoreCarModelReq storeCarModelReq, Integer pageNo, Integer pageSize) { public IPage<CarModelSimpleDTO> pageCarModelSimpleDTO(StoreCarModelReq storeCarModelReq, Integer pageNo, Integer pageSize) {
return carModelRepo.pageCarModelSimpleDTO(storeCarModelReq, pageNo, pageSize); return carModelRepo.pageCarModelSimpleDTO(storeCarModelReq, pageNo, pageSize);
} }
@Override
public CarModelSimpleDTO getCarModelByModelId(Long modelId) {
CarModelPO carModelPO = carModelRepo.getById(modelId);
return CarModelConvert.INSTANCE.poToSimpleDTO(carModelPO);
}
} }

View File

@ -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);
}
}