代码规范:车辆模块

dev.event
Number7 2024-09-29 09:52:27 +08:00
parent 55169e9267
commit b8858754f5
17 changed files with 120 additions and 30 deletions

View File

@ -7,7 +7,7 @@ nacos:
addr: 47.101.53.251:8848
user-name: nacos
password: nacos
namespace: lgy
namespace: four
# Spring
spring:
application:

View File

@ -7,7 +7,7 @@ nacos:
addr: 47.101.53.251:8848
user-name: nacos
password: nacos
namespace: lgy
namespace: four
# Spring
spring:

View File

@ -7,7 +7,7 @@ nacos:
addr: 47.101.53.251:8848
user-name: nacos
password: nacos
namespace: yzl
namespace: four
# Spring
spring:

View File

@ -7,7 +7,7 @@ nacos:
addr: 47.101.53.251:8848
user-name: nacos
password: nacos
namespace: yzl
namespace: four
# SPRING_AMQP_DESERIALIZATION_TRUST_ALL=true spring.amqp.deserialization.trust.all
# Spring
spring:

View File

@ -7,7 +7,7 @@ nacos:
addr: 47.101.53.251:8848
user-name: nacos
password: nacos
namespace: lgy
namespace: four
# SPRING_AMQP_DESERIALIZATION_TRUST_ALL=true spring.amqp.deserialization.trust.all
# Spring
spring:

View File

@ -7,7 +7,7 @@ nacos:
addr: 47.101.53.251:8848
user-name: nacos
password: nacos
namespace: lgy
namespace: four
# Spring
spring:

View File

@ -1,33 +1,57 @@
package com.muyu.server.controller;
import com.muyu.common.core.domain.Result;
import com.muyu.common.domain.CarType;
import com.muyu.server.service.CarTypeService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.AllArgsConstructor;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@RestController
@RequestMapping("/carType")
@AllArgsConstructor
@Tag(name = "车辆类型管理",description = "车辆类型管理")
@Log4j2
public class CarTypeController {
@Autowired
private CarTypeService carTypeService;
/**
*
* @return
*/
@GetMapping("/selectCarTypeList")
@Operation(summary = "车辆类型列表",description = "车辆类型列表")
public Result selectCarTypeList(){
return Result.success(carTypeService.selectCarTypeList());
}
/**
*
* @param id
* @return
*/
@GetMapping("/selectCarTypeRespList/{id}")
@Operation(summary = "根据车辆ID查询车辆列表",description ="根据车辆ID查询车辆列表" )
public Result selectCarTypeRespList(@PathVariable("id") Long id) {
return Result.success(carTypeService.selectCarTypeRespList(id));
}
/**1
* ID
* @param carTypeId
* @return
*/
@PostMapping("/findCarTypeById")
@Operation(summary = "根据类型ID获取车辆类型",description = "根据类型ID获取车辆类型")
public Result<CarType> findCarTypeById(@RequestParam Long carTypeId) {
return Result.success(carTypeService.findCarTypeById(carTypeId));
}
}

View File

@ -5,6 +5,10 @@ import com.muyu.common.domain.SysCar;
import com.muyu.common.domain.req.SysCarReq;
import com.muyu.common.domain.resp.SysCarFaultLogVo;
import com.muyu.server.service.SysCarService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.AllArgsConstructor;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@ -12,34 +16,52 @@ import java.util.List;
@RestController
@RequestMapping("/sysCar")
@AllArgsConstructor
@Tag(name = "车辆管理",description = "车辆类型管理")
@Log4j2
public class SysCarController {
@Autowired
private SysCarService sysCarService;
/**
*
* @param sysCarReq
* @return
*/
@PostMapping("/selectSysCarVoList")
@Operation(summary = "车辆列表",description = "车辆列表")
public Result selectSysCarVoList(@RequestBody SysCarReq sysCarReq){
return Result.success(sysCarService.selectSysCarVoList(sysCarReq));
}
/**
*
* @param id
* @return
*/
@GetMapping("/selectSysCarVoById/{id}")
@Operation(summary = "根据ID查询车辆列表",description = "根据ID查询车辆列表")
public Result selectSysCarVoById(@PathVariable("id") Long id){
return Result.success(sysCarService.selectSysCarVoById(id));
}
@PostMapping("/addSysCar")
@Operation(summary = "车辆添加",description = "车辆添加")
public Result addSysCar(@RequestBody SysCar sysCar){
return Result.success(sysCarService.addSysCar(sysCar));
}
@PostMapping("/updateSysCar")
@Operation(summary = "车辆修改",description = "车辆修改")
public Result updateSysCar(@RequestBody SysCar sysCar){
return Result.success(sysCarService.updateSysCar(sysCar));
}
@DeleteMapping("/deleteSysCarById/{id}")
@Operation(summary = "车辆删除",description = "车辆删除")
public Result deleteSysCarById(@PathVariable("id") Long id){
int i = sysCarService.deleteSysCarById(id);
return i>0?Result.success():Result.error();
@ -51,8 +73,20 @@ public class SysCarController {
* @return
*/
@PostMapping("/findFenceByCarVin/{carVin}")
@Operation(summary = "根据车辆的VIN码查询该车的故障记录",description = "根据车辆的VIN码查询该车的故障记录")
public Result<List<SysCarFaultLogVo>> findFenceByCarVin(@PathVariable("carVin") String carVin){
return Result.success(sysCarService.findFenceByCarVin(carVin));
}
/**
* VIN
* @param carVin
* @return
*/
@PostMapping("/findCarByVin")
@Operation(summary = "根据VIN码查询车信息",description = "根据VIN码查询车信息")
public Result<SysCar> findCarByVin(@RequestParam("carVin") String carVin){
return Result.success(sysCarService.findCarByVin(carVin));
}
}

View File

@ -2,6 +2,10 @@ package com.muyu.server.controller;
import com.muyu.common.core.domain.Result;
import com.muyu.server.service.SysCarLogService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.AllArgsConstructor;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
@ -12,17 +16,22 @@ import java.util.List;
@RestController
@RequestMapping("/sysCarLog")
@AllArgsConstructor
@Tag(name = "车辆日志",description = "车辆日志管理")
@Log4j2
public class SysCarLogController {
@Autowired
private SysCarLogService sysCarLogService;
@GetMapping("/selectList")
@Operation(summary = "车辆日志列表",description = "车辆日志列表")
public Result selectList(){
return Result.success(sysCarLogService.selectList());
}
@GetMapping("/selectList/{id}")
@Operation(summary = "根据ID查询车辆日志列表",description = "根据ID查询车辆日志列表")
public Result selectById(@PathVariable("id") Long id){
return Result.success(sysCarLogService.selectById(id));
}

View File

@ -5,8 +5,17 @@ import com.muyu.common.domain.CarType;
import com.muyu.common.domain.resp.CarTypeResp;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import java.util.List;
@Mapper
public interface CarTypeMapper extends BaseMapper<CarType> {
@Select(" SELECT *,t_template.template_name FROM car_type LEFT JOIN t_template ON car_type.template_id = t_template.template_id where car_type.id=#{id}")
CarTypeResp selectCarTypeRespList(@Param("id")Long id);
@Select(" SELECT car_type.*,t_template.template_name FROM car_type LEFT JOIN t_template ON car_type.template_id = t_template.template_id")
List<CarTypeResp> findAllCars();
}

View File

@ -18,10 +18,5 @@ public interface SysCarMapper extends BaseMapper<SysCar> {
List<SysCarFaultLogVo> findFenceByCarVin(@Param("carVin") String carVin);
//修改车辆
Integer updSysCarById(SysCar sysCar);
//添加车辆信息
Integer addSysCar(SysCar sysCar);
}

View File

@ -11,4 +11,7 @@ public interface CarTypeService extends IService<CarType> {
CarTypeResp selectCarTypeRespList(Long id);
CarType findCarTypeById(Long carTypeId);
List<CarTypeResp> findAllCars();
}

View File

@ -20,4 +20,6 @@ public interface SysCarService {
List<SysCarFaultLogVo> findFenceByCarVin(String carVin);
SysCar findCarByVin(String carVin);
}

View File

@ -12,7 +12,7 @@ import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class CarTypeServiceImpl extends ServiceImpl<CarTypeMapper, CarType> implements CarTypeService {
public class CarTypeServiceImpl extends ServiceImpl<CarTypeMapper, CarType> implements CarTypeService{
@Autowired
private CarTypeMapper carTypeMapper;
@Override
@ -25,4 +25,17 @@ private CarTypeMapper carTypeMapper;
public CarTypeResp selectCarTypeRespList(Long id) {
return carTypeMapper.selectCarTypeRespList(id);
}
@Override
public CarType findCarTypeById(Long carTypeId) {
QueryWrapper<CarType> carTypeQueryWrapper = new QueryWrapper<>();
carTypeQueryWrapper.eq("car_type_id", carTypeId);
CarType carType = carTypeMapper.selectOne(carTypeQueryWrapper);
return carType;
}
@Override
public List<CarTypeResp> findAllCars() {
return carTypeMapper.findAllCars();
}
}

View File

@ -1,5 +1,6 @@
package com.muyu.server.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.muyu.common.domain.SysCar;
import com.muyu.common.domain.req.SysCarReq;
@ -28,7 +29,7 @@ public class SysCarServiceImpl extends ServiceImpl<SysCarMapper, SysCar> impleme
@Override
public int addSysCar(SysCar sysCar) {
return sysCarMapper.addSysCar(sysCar);
return sysCarMapper.insert(sysCar);
}
@Override
@ -38,11 +39,19 @@ public class SysCarServiceImpl extends ServiceImpl<SysCarMapper, SysCar> impleme
@Override
public int updateSysCar(SysCar sysCar) {
return sysCarMapper.updSysCarById(sysCar);
return sysCarMapper.updateById(sysCar);
}
@Override
public List<SysCarFaultLogVo> findFenceByCarVin(String carVin) {
return sysCarMapper.findFenceByCarVin(carVin);
}
@Override
public SysCar findCarByVin(String carVin) {
QueryWrapper<SysCar> sysCarQueryWrapper = new QueryWrapper<>();
sysCarQueryWrapper.eq("car_vin", carVin);
SysCar sysCar = sysCarMapper.selectOne(sysCarQueryWrapper);
return sysCar;
}
}

View File

@ -7,7 +7,7 @@ nacos:
addr: 47.101.53.251:8848
user-name: nacos
password: nacos
namespace: lgy
namespace: four
# SPRING_AMQP_DESERIALIZATION_TRUST_ALL=true spring.amqp.deserialization.trust.all
# Spring
spring:

View File

@ -4,14 +4,6 @@
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.muyu.server.mapper.CarTypeMapper">
<select id="selectCarTypeRespList" resultType="com.muyu.common.domain.resp.CarTypeResp">
SELECT
*,
t_template.template_name
FROM
car_type
LEFT JOIN t_template ON car_type.template_id = t_template.template_id
where car_type.id=#{id}
</select>
</mapper>