aop日志
parent
7e85cf16c2
commit
09a4b16316
|
@ -0,0 +1,22 @@
|
||||||
|
package com.dragon.car.config;
|
||||||
|
|
||||||
|
import com.dragon.car.utils.LogRecordAspect;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.context.annotation.EnableAspectJAutoProxy;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author : Administrator
|
||||||
|
* @Description : 配置类: [{日志AOP},{}]
|
||||||
|
*/
|
||||||
|
@Configuration
|
||||||
|
@EnableAspectJAutoProxy
|
||||||
|
public class ConfigAspect {
|
||||||
|
|
||||||
|
/** 启用切面处理和开启自动代理 */
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public LogRecordAspect logRecordAspect () {
|
||||||
|
return new LogRecordAspect ();
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,5 +1,8 @@
|
||||||
package com.dragon.car.domain;
|
package com.dragon.car.domain;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
import lombok.Builder;
|
import lombok.Builder;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
|
@ -9,11 +12,13 @@ import lombok.Data;
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
@Builder
|
@Builder
|
||||||
|
@TableName ("fault_code")
|
||||||
public class FaultCode {
|
public class FaultCode {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 故障码编号
|
* 故障码编号
|
||||||
*/
|
*/
|
||||||
|
@TableId (type = IdType.AUTO)
|
||||||
private Integer id;
|
private Integer id;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package com.dragon.car.domain.resp;
|
package com.dragon.car.domain.resp;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
import lombok.Builder;
|
import lombok.Builder;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
|
@ -11,6 +12,7 @@ import java.time.LocalDateTime;
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
@Builder
|
@Builder
|
||||||
|
@TableName ("vehicleFaultInfoResp")
|
||||||
public class VehicleFaultInfoResp {
|
public class VehicleFaultInfoResp {
|
||||||
private Integer id;
|
private Integer id;
|
||||||
private Integer vehicleId;
|
private Integer vehicleId;
|
||||||
|
|
|
@ -0,0 +1,141 @@
|
||||||
|
package com.dragon.car.utils;
|
||||||
|
|
||||||
|
import com.dragon.common.core.constant.SecurityConstants;
|
||||||
|
import com.dragon.common.core.domain.Result;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.aspectj.lang.JoinPoint;
|
||||||
|
import org.aspectj.lang.annotation.*;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
import org.springframework.web.context.request.RequestContextHolder;
|
||||||
|
import org.springframework.web.context.request.ServletRequestAttributes;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Enumeration;
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author : Administrator
|
||||||
|
* @description : 更新AOP日志
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
@Aspect
|
||||||
|
@Slf4j
|
||||||
|
public class LogAOP {
|
||||||
|
/**
|
||||||
|
* com.dragon.car.service.controller:表示匹配这个包下的类。
|
||||||
|
* ..:表示匹配任意子包。
|
||||||
|
* :表示匹配任意类。
|
||||||
|
* .*:表示匹配任意方法。
|
||||||
|
* (..):表示匹配任意参数列表的方法。
|
||||||
|
*/
|
||||||
|
private static final String POINT = "execution(* com.dragon.car.service.controller..*.*(..))";
|
||||||
|
private static final ThreadLocal<Long> START_TIME = ThreadLocal.withInitial (System::currentTimeMillis);
|
||||||
|
private static final ThreadLocal<String> SEQUENCE = ThreadLocal.withInitial (
|
||||||
|
() -> UUID
|
||||||
|
.randomUUID ()
|
||||||
|
.toString ()
|
||||||
|
.replaceAll ("-", ""));
|
||||||
|
|
||||||
|
@Pointcut (POINT)
|
||||||
|
public void executeService () {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 前置通知 */
|
||||||
|
@Before ("executeService()")
|
||||||
|
public void before (JoinPoint joinPoint) {
|
||||||
|
ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes ();
|
||||||
|
HttpServletRequest request = Optional.ofNullable (attributes).map (ServletRequestAttributes::getRequest).orElse (null);
|
||||||
|
String ipAddress = Optional.ofNullable (request).map (r -> r.getHeader ("X-Forwarded-For")).orElse (null);
|
||||||
|
|
||||||
|
if (ipAddress == null || ipAddress.isEmpty () || "unknown".equalsIgnoreCase (ipAddress)) {
|
||||||
|
Optional.ofNullable (request).map (HttpServletRequest::getRemoteAddr).orElse (null);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
ipAddress = ipAddress.split (",")[0];
|
||||||
|
}
|
||||||
|
String headers = Optional.ofNullable (request).map (HttpServletRequest::getHeaderNames)
|
||||||
|
.map (Enumeration::asIterator)
|
||||||
|
.stream ()
|
||||||
|
.map (name -> name + ":" + request.getHeader (name.toString ()))
|
||||||
|
.reduce ("", (a, b) -> a + "|" + b);
|
||||||
|
|
||||||
|
|
||||||
|
String parameters = Optional.ofNullable (request).map (HttpServletRequest::getParameterMap)
|
||||||
|
.map (map -> map.entrySet ()
|
||||||
|
.stream ()
|
||||||
|
.map (entry -> entry.getKey () + ":" + Arrays.toString (entry.getValue ()))
|
||||||
|
.reduce ("", (a, b) -> a + "|" + b))
|
||||||
|
.orElse ("");
|
||||||
|
log.info (
|
||||||
|
"""
|
||||||
|
trace log begin --> sequence::{},
|
||||||
|
userName::{},
|
||||||
|
RealIp::{},
|
||||||
|
User- Agent::{},
|
||||||
|
requestUri::{},
|
||||||
|
header::{},
|
||||||
|
requestMethod::{},
|
||||||
|
request::{},
|
||||||
|
args::{}
|
||||||
|
""",
|
||||||
|
|
||||||
|
SEQUENCE.get (), SecurityConstants.DETAILS_USERNAME, ipAddress,
|
||||||
|
Optional.ofNullable (request)
|
||||||
|
.map (r -> r.getHeader ("User-Agent"))
|
||||||
|
.orElse (""),
|
||||||
|
Optional.ofNullable (request)
|
||||||
|
.map (HttpServletRequest::getRequestURI)
|
||||||
|
.orElse (""),
|
||||||
|
headers,
|
||||||
|
Optional.ofNullable (request)
|
||||||
|
.map (HttpServletRequest::getMethod)
|
||||||
|
.orElse (""),
|
||||||
|
Optional.ofNullable (request)
|
||||||
|
.map (HttpServletRequest::toString)
|
||||||
|
.orElse (""),
|
||||||
|
Arrays.deepToString (joinPoint.getArgs ())
|
||||||
|
);
|
||||||
|
|
||||||
|
START_TIME.set (System.currentTimeMillis ());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 后置 */
|
||||||
|
@AfterReturning (pointcut = "executeService()", returning = "result")
|
||||||
|
public void after (Object result) {
|
||||||
|
String responseBody = result instanceof Result ? result.toString () : "not standard response";
|
||||||
|
log.info ("""
|
||||||
|
trace log end -->sequence::{}, used::{}ms, responseBody::{}
|
||||||
|
""", SEQUENCE.get (), (System.currentTimeMillis () - START_TIME.get ()), responseBody);
|
||||||
|
SEQUENCE.remove ();
|
||||||
|
START_TIME.remove ();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 异常 */
|
||||||
|
@AfterThrowing (pointcut = "executeService()", throwing = "e")
|
||||||
|
public void afterThrowing (JoinPoint joinPoint, Exception e) {
|
||||||
|
log.error (
|
||||||
|
"""
|
||||||
|
trace log exception --> sequence::{},
|
||||||
|
message::{},
|
||||||
|
requestMethod::{},
|
||||||
|
requestUri::{},
|
||||||
|
args::{}
|
||||||
|
""",
|
||||||
|
SEQUENCE.get (),
|
||||||
|
e.getMessage (),
|
||||||
|
Optional.ofNullable (RequestContextHolder.getRequestAttributes ())
|
||||||
|
.map (attributes -> ((ServletRequestAttributes) attributes).getRequest ().getMethod ())
|
||||||
|
.orElse (""),
|
||||||
|
Optional.ofNullable (RequestContextHolder.getRequestAttributes ())
|
||||||
|
.map (attributes -> ((ServletRequestAttributes) attributes).getRequest ().getRequestURI ())
|
||||||
|
.orElse (""),
|
||||||
|
Arrays.deepToString (joinPoint.getArgs ()),
|
||||||
|
e
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,158 @@
|
||||||
|
package com.dragon.car.utils;
|
||||||
|
|
||||||
|
import com.dragon.common.core.constant.SecurityConstants;
|
||||||
|
import com.dragon.common.core.domain.Result;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.commons.lang3.RandomStringUtils;
|
||||||
|
import org.aspectj.lang.JoinPoint;
|
||||||
|
import org.aspectj.lang.annotation.AfterReturning;
|
||||||
|
import org.aspectj.lang.annotation.Aspect;
|
||||||
|
import org.aspectj.lang.annotation.Before;
|
||||||
|
import org.aspectj.lang.annotation.Pointcut;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
import org.springframework.web.context.request.RequestAttributes;
|
||||||
|
import org.springframework.web.context.request.RequestContextHolder;
|
||||||
|
import org.springframework.web.context.request.ServletRequestAttributes;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Enumeration;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author : Administrator
|
||||||
|
* @Description : aop日志
|
||||||
|
*/
|
||||||
|
@Aspect
|
||||||
|
@Component
|
||||||
|
@Slf4j
|
||||||
|
public class LogRecordAspect {
|
||||||
|
/** 定义切面表达式 */
|
||||||
|
private static final String POINT = "execution(* com.dragon.car.server.controller..*.*(..))";
|
||||||
|
/** 记录每次请求的开始时间 */
|
||||||
|
private static final ThreadLocal<Long> START_TIME = new ThreadLocal<> ();
|
||||||
|
/** 记录每次请求的序列号 */
|
||||||
|
private static final ThreadLocal<String> SEQUENCE = new ThreadLocal<> ();
|
||||||
|
@Resource
|
||||||
|
HttpServletRequest request;
|
||||||
|
|
||||||
|
@Pointcut (POINT)
|
||||||
|
public void executeService () {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Before ("executeService()")
|
||||||
|
public void beFore (JoinPoint pjp) {
|
||||||
|
|
||||||
|
//请求信息
|
||||||
|
RequestAttributes req = RequestContextHolder.getRequestAttributes ();
|
||||||
|
ServletRequestAttributes reqSra = (ServletRequestAttributes) req;
|
||||||
|
HttpServletRequest request = null;
|
||||||
|
if (reqSra != null) {
|
||||||
|
request = reqSra.getRequest ();
|
||||||
|
}
|
||||||
|
String header = null;
|
||||||
|
if (request != null) {
|
||||||
|
header = request.getHeader ("X-Forwarded-For");
|
||||||
|
}
|
||||||
|
if (header == null || header.isEmpty () || "unknown".equalsIgnoreCase (header)) {
|
||||||
|
|
||||||
|
if (request != null) {
|
||||||
|
header = request.getRemoteAddr ();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
|
||||||
|
int i = header.indexOf (",");
|
||||||
|
if (i != -1) {
|
||||||
|
header = header.substring (0, i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/*ip地址是*/
|
||||||
|
String ipAddr = null;
|
||||||
|
if (header != null) {
|
||||||
|
ipAddr = header.trim ();
|
||||||
|
}
|
||||||
|
Enumeration<String> headerNames = null;
|
||||||
|
if (request != null) {
|
||||||
|
headerNames = request.getHeaderNames ();
|
||||||
|
}
|
||||||
|
StringBuilder stringBuilder = new StringBuilder ();
|
||||||
|
if (headerNames != null) {
|
||||||
|
while (headerNames.hasMoreElements ()) {
|
||||||
|
String s = headerNames.nextElement ();
|
||||||
|
stringBuilder.append (s)
|
||||||
|
.append (":")
|
||||||
|
.append (request.getHeader (s))
|
||||||
|
.append ("|");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/*解析参数*/
|
||||||
|
Object[] pjpArgs = pjp.getArgs ();
|
||||||
|
Map<String, String[]> parameterMap = null;
|
||||||
|
if (request != null) {
|
||||||
|
parameterMap = request.getParameterMap ();
|
||||||
|
}
|
||||||
|
StringBuilder builder = new StringBuilder ();
|
||||||
|
if (parameterMap != null) {
|
||||||
|
parameterMap.forEach ((k, v) -> builder
|
||||||
|
.append (k)
|
||||||
|
.append (":")
|
||||||
|
.append (Arrays.deepToString (v))
|
||||||
|
.append ("|")
|
||||||
|
);
|
||||||
|
}
|
||||||
|
/*每次请求的序列号,避免方便匹配同一个请求以及对应的响应*/
|
||||||
|
|
||||||
|
SEQUENCE.set (getRandom ());
|
||||||
|
if (request != null) {
|
||||||
|
log.info (
|
||||||
|
"trace log begin --> sequence::{},userName::{},RealIp::{},User-Agent::{},requestUri::{}" + ",header::{},requestMethod::{},request::{}, args::{}",
|
||||||
|
SEQUENCE.get (),
|
||||||
|
SecurityConstants.DETAILS_USERNAME,
|
||||||
|
ipAddr,
|
||||||
|
request.getHeader ("User-Agent"),
|
||||||
|
request.getRequestURI (),
|
||||||
|
builder.toString (),
|
||||||
|
request.getMethod (),
|
||||||
|
stringBuilder.toString (),
|
||||||
|
Arrays.deepToString (pjpArgs)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
START_TIME.set (System.currentTimeMillis ());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getRandom () {
|
||||||
|
|
||||||
|
return RandomStringUtils.random (8, true, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@AfterReturning (pointcut = "executeService()", returning = "result")
|
||||||
|
public void after (Object result) {
|
||||||
|
try {
|
||||||
|
String res = "not standard response";
|
||||||
|
//自定义返回标准类
|
||||||
|
if (result instanceof Result) {
|
||||||
|
res = result.toString ();
|
||||||
|
}
|
||||||
|
log.info (
|
||||||
|
"""
|
||||||
|
trace log end -->sequence::{}, used::{}ms, responseBody::{}
|
||||||
|
""",
|
||||||
|
SEQUENCE.get (), (System.currentTimeMillis () - START_TIME.get ()),
|
||||||
|
res
|
||||||
|
);
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (Exception e) {
|
||||||
|
throw new RuntimeException (e);
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
START_TIME.remove ();
|
||||||
|
SEQUENCE.remove ();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,29 +0,0 @@
|
||||||
package com.dragon.car.server.service.impl;
|
|
||||||
|
|
||||||
import com.dragon.car.domain.resp.ResquestFaultCode;
|
|
||||||
import com.dragon.car.server.service.FaultService;
|
|
||||||
import com.dragon.common.core.domain.Result;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author : Administrator
|
|
||||||
* @description : 车辆故障码维护
|
|
||||||
*/
|
|
||||||
@Service
|
|
||||||
public class FaultServiceImpl implements FaultService {
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 对故障码的管理查看
|
|
||||||
*
|
|
||||||
* @return 故障码的返回结果集
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public Result<List<ResquestFaultCode>> faultCodeList () {
|
|
||||||
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,4 +1,4 @@
|
||||||
package com.dragon.car.server;
|
package com.dragon.car.service;
|
||||||
|
|
||||||
|
|
||||||
import com.dragon.common.security.annotation.EnableCustomConfig;
|
import com.dragon.common.security.annotation.EnableCustomConfig;
|
|
@ -1,9 +1,9 @@
|
||||||
package com.dragon.car.server.controller;
|
package com.dragon.car.service.controller;
|
||||||
|
|
||||||
import com.dragon.car.domain.req.RequestCar;
|
import com.dragon.car.domain.req.RequestCar;
|
||||||
import com.dragon.car.domain.resp.ResquestFaultCode;
|
import com.dragon.car.domain.resp.ResquestFaultCode;
|
||||||
import com.dragon.car.server.service.CarService;
|
import com.dragon.car.service.service.CarManageService;
|
||||||
import com.dragon.car.server.service.FaultService;
|
import com.dragon.car.service.service.FaultService;
|
||||||
import com.dragon.common.core.domain.Result;
|
import com.dragon.common.core.domain.Result;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
@ -21,7 +21,7 @@ import java.util.List;
|
||||||
@RequestMapping ("/car")
|
@RequestMapping ("/car")
|
||||||
public class CarController {
|
public class CarController {
|
||||||
@Autowired
|
@Autowired
|
||||||
CarService carService;
|
CarManageService carManageService;
|
||||||
@Autowired
|
@Autowired
|
||||||
FaultService faultService;
|
FaultService faultService;
|
||||||
|
|
||||||
|
@ -33,32 +33,54 @@ public class CarController {
|
||||||
@PostMapping ("/carInit")
|
@PostMapping ("/carInit")
|
||||||
public Result<List<RequestCar>> carInit () {
|
public Result<List<RequestCar>> carInit () {
|
||||||
|
|
||||||
return carService.carInit ();
|
return carManageService.carInit ();
|
||||||
}
|
}
|
||||||
|
|
||||||
//车辆添加
|
/**
|
||||||
|
* 车辆添加
|
||||||
|
*
|
||||||
|
* @param request
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
@PostMapping ("/carInsert")
|
@PostMapping ("/carInsert")
|
||||||
public Result carInsert (@RequestBody RequestCar request) {
|
public Result carInsert (@RequestBody RequestCar request) {
|
||||||
|
|
||||||
return carService.carInsert (request);
|
return carManageService.carInsert (request);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 辆修改参数
|
/**
|
||||||
|
* 辆修改参数
|
||||||
|
*
|
||||||
|
* @param request
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
@PostMapping ("/carUpdate")
|
@PostMapping ("/carUpdate")
|
||||||
public Result carUpdate (@RequestBody RequestCar request) {
|
public Result carUpdate (@RequestBody RequestCar request) {
|
||||||
return carService.carUpdate (request);
|
return carManageService.carUpdate (request);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 车辆删除
|
/**
|
||||||
|
* 车辆删除
|
||||||
|
*
|
||||||
|
* @param request
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
@PostMapping ("/carDelect")
|
@PostMapping ("/carDelect")
|
||||||
public Result carDelect (@RequestBody RequestCar request) {
|
public Result carDelect (@RequestBody RequestCar request) {
|
||||||
return carService.carDelect (request);
|
return carManageService.carDelect (request);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: 2023/11/20 车辆故障码
|
/**
|
||||||
|
* 车辆故障码
|
||||||
|
*/
|
||||||
@PostMapping ("/faultCode")
|
@PostMapping ("/faultCode")
|
||||||
public Result<List<ResquestFaultCode>> faultCodeList () {
|
public Result<List<ResquestFaultCode>> faultCodeList () {
|
||||||
|
|
||||||
return faultService.faultCodeList ();
|
return faultService.faultCodeList ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -0,0 +1,30 @@
|
||||||
|
package com.dragon.car.service.controller;
|
||||||
|
|
||||||
|
import com.dragon.car.domain.resp.VehicleFaultInfoResp;
|
||||||
|
import com.dragon.car.service.service.FaultService;
|
||||||
|
import com.dragon.common.core.domain.Result;
|
||||||
|
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;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author : Administrator
|
||||||
|
* @description : 故障码管理控制
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping ("/fault")
|
||||||
|
public class FaultController {
|
||||||
|
@Autowired
|
||||||
|
FaultService faultService;
|
||||||
|
|
||||||
|
// 按 ID 选择带有故障代码的车辆故障信息
|
||||||
|
|
||||||
|
@GetMapping ("/{id}")
|
||||||
|
public Result<VehicleFaultInfoResp> getVehicleFaultInfoWithFaultCode (@PathVariable ("id") Integer id) {
|
||||||
|
return faultService.getVehicleFaultInfoWithFaultCodeById (id);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
package com.dragon.car.server.mapper;
|
package com.dragon.car.service.mapper;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
import com.dragon.car.domain.req.RequestCar;
|
import com.dragon.car.domain.req.RequestCar;
|
||||||
|
@ -9,5 +9,5 @@ import org.apache.ibatis.annotations.Mapper;
|
||||||
* @description :
|
* @description :
|
||||||
*/
|
*/
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface ReqCarMapper extends BaseMapper<RequestCar> {
|
public interface CarManageMapper extends BaseMapper<RequestCar> {
|
||||||
}
|
}
|
|
@ -0,0 +1,26 @@
|
||||||
|
package com.dragon.car.service.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.dragon.car.domain.VehicleFaultInfo;
|
||||||
|
import com.dragon.car.domain.resp.VehicleFaultInfoResp;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
import org.apache.ibatis.annotations.Select;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author : Administrator
|
||||||
|
* @description : 故障码映射
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface FaultCodeMapper extends BaseMapper<VehicleFaultInfo> {
|
||||||
|
|
||||||
|
@Select ("""
|
||||||
|
SELECT vfi.*, fc.code, fc.description
|
||||||
|
FROM vehicle_fault_info vfi
|
||||||
|
INNER JOIN fault_code fc ON vfi.fault_code_id = fc.id
|
||||||
|
WHERE vfi.id = #{id}
|
||||||
|
""")
|
||||||
|
VehicleFaultInfoResp selectVehicleFaultInfoWithFaultCodeById (@Param ("id") Integer id);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
package com.dragon.car.server.service;
|
package com.dragon.car.service.service;
|
||||||
|
|
||||||
import com.dragon.car.domain.req.RequestCar;
|
import com.dragon.car.domain.req.RequestCar;
|
||||||
import com.dragon.common.core.domain.Result;
|
import com.dragon.common.core.domain.Result;
|
||||||
|
@ -9,7 +9,7 @@ import java.util.List;
|
||||||
* @author : Administrator
|
* @author : Administrator
|
||||||
* @description :
|
* @description :
|
||||||
*/
|
*/
|
||||||
public interface CarService {
|
public interface CarManageService {
|
||||||
/**
|
/**
|
||||||
* 初始化车辆
|
* 初始化车辆
|
||||||
*
|
*
|
|
@ -1,6 +1,7 @@
|
||||||
package com.dragon.car.server.service;
|
package com.dragon.car.service.service;
|
||||||
|
|
||||||
import com.dragon.car.domain.resp.ResquestFaultCode;
|
import com.dragon.car.domain.resp.ResquestFaultCode;
|
||||||
|
import com.dragon.car.domain.resp.VehicleFaultInfoResp;
|
||||||
import com.dragon.common.core.domain.Result;
|
import com.dragon.common.core.domain.Result;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -18,4 +19,13 @@ public interface FaultService {
|
||||||
* @return 故障码的返回结果集
|
* @return 故障码的返回结果集
|
||||||
*/
|
*/
|
||||||
Result<List<ResquestFaultCode>> faultCodeList ();
|
Result<List<ResquestFaultCode>> faultCodeList ();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 按照id码查车
|
||||||
|
*
|
||||||
|
* @param id
|
||||||
|
*
|
||||||
|
* @return List<VehicleFaultInfoResp>
|
||||||
|
*/
|
||||||
|
Result<VehicleFaultInfoResp> getVehicleFaultInfoWithFaultCodeById (Integer id);
|
||||||
}
|
}
|
|
@ -1,10 +1,10 @@
|
||||||
package com.dragon.car.server.service.impl;
|
package com.dragon.car.service.service.impl;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||||
import com.dragon.car.domain.req.RequestCar;
|
import com.dragon.car.domain.req.RequestCar;
|
||||||
import com.dragon.car.server.mapper.ReqCarMapper;
|
import com.dragon.car.service.mapper.CarManageMapper;
|
||||||
import com.dragon.car.server.service.CarService;
|
import com.dragon.car.service.service.CarManageService;
|
||||||
import com.dragon.common.core.domain.Result;
|
import com.dragon.common.core.domain.Result;
|
||||||
import lombok.extern.log4j.Log4j2;
|
import lombok.extern.log4j.Log4j2;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
@ -18,10 +18,10 @@ import java.util.List;
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
@Log4j2
|
@Log4j2
|
||||||
public class CarServiceImpl implements CarService {
|
public class CarManageServiceImpl implements CarManageService {
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
ReqCarMapper carMapper;
|
CarManageMapper carMapper;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
|
@ -0,0 +1,47 @@
|
||||||
|
package com.dragon.car.service.service.impl;
|
||||||
|
|
||||||
|
import com.dragon.car.domain.resp.ResquestFaultCode;
|
||||||
|
import com.dragon.car.domain.resp.VehicleFaultInfoResp;
|
||||||
|
import com.dragon.car.service.mapper.FaultCodeMapper;
|
||||||
|
import com.dragon.car.service.service.FaultService;
|
||||||
|
import com.dragon.common.core.domain.Result;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author : Administrator
|
||||||
|
* @description : 车辆故障码维护
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class FaultServiceImpl implements FaultService {
|
||||||
|
@Autowired
|
||||||
|
FaultCodeMapper faultCodeMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 对故障码的管理查看
|
||||||
|
*
|
||||||
|
* @return 故障码的返回结果集
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Result<List<ResquestFaultCode>> faultCodeList () {
|
||||||
|
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 按照id码查车
|
||||||
|
*
|
||||||
|
* @param id
|
||||||
|
*
|
||||||
|
* @return List<VehicleFaultInfoResp>
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Result<VehicleFaultInfoResp> getVehicleFaultInfoWithFaultCodeById (Integer id) {
|
||||||
|
VehicleFaultInfoResp vehicleFaultInfoResp = faultCodeMapper.selectVehicleFaultInfoWithFaultCodeById (id);
|
||||||
|
|
||||||
|
return Result.success (vehicleFaultInfoResp);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue