Ver código fonte

正常日志记录和异常日志记录

gaodm 3 anos atrás
pai
commit
6340611051

+ 81 - 0
src/main/java/com/diagbot/aop/CdssLogAspect.java

@@ -0,0 +1,81 @@
+package com.diagbot.aop;
+
+import com.diagbot.annotation.CdssLog;
+import com.diagbot.entity.TranLog;
+import com.diagbot.rabbit.MySender;
+import com.diagbot.util.CdssLogUtil;
+import com.diagbot.util.DateUtil;
+import lombok.extern.slf4j.Slf4j;
+import org.aspectj.lang.JoinPoint;
+import org.aspectj.lang.ProceedingJoinPoint;
+import org.aspectj.lang.annotation.AfterThrowing;
+import org.aspectj.lang.annotation.Around;
+import org.aspectj.lang.annotation.Aspect;
+import org.aspectj.lang.annotation.Pointcut;
+import org.aspectj.lang.reflect.MethodSignature;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
+import org.springframework.stereotype.Component;
+
+import java.lang.reflect.Method;
+import java.util.Date;
+
+/**
+ * @Description: 日志记录切面
+ * @author: gaodm
+ * @time: 2021/10/20 9:58
+ */
+@Aspect
+@Component
+@ConditionalOnProperty(prefix = "cdssLog", value = { "enable" }, havingValue = "true")
+@Slf4j
+public class CdssLogAspect {
+
+    @Autowired
+    MySender mySender;
+
+    //切所有Controller
+    @Pointcut("execution(* com.diagbot.web..*.*(..)) && @annotation(com.diagbot.annotation.CdssLog)")
+    public void pointcutController() {
+    }
+
+    @Around("pointcutController()")
+    public Object cdssLogIntercept(ProceedingJoinPoint joinPoint) throws Throwable {
+        MethodSignature signature = (MethodSignature) joinPoint.getSignature();
+        Method method = signature.getMethod();
+        //获取方法参数
+        Object[] args = joinPoint.getArgs();
+        //请求的参数
+        TranLog tanLog = CdssLogUtil.tranLogReqAspect(joinPoint);
+        Date now = DateUtil.now();
+        tanLog.setGmtCreate(now);
+        tanLog.setGmtModified(now);
+        tanLog.setSceneName(method.getAnnotation(CdssLog.class).value());
+        long start = System.currentTimeMillis();
+        tanLog.setGmtReq(DateUtil.now());
+        Object proceed = joinPoint.proceed(args);
+        //执行方法后获取出参
+        tanLog = CdssLogUtil.tranLogRespAspect(proceed, tanLog, start, joinPoint);
+
+        //异步记录日志
+        mySender.outputCdssLogSend(tanLog);
+        return proceed;
+    }
+
+    @AfterThrowing(pointcut = "pointcutController()", throwing = "ex")
+    public void cdssLogInterceptThrow(JoinPoint joinPoint, Throwable ex) {
+        MethodSignature signature = (MethodSignature) joinPoint.getSignature();
+        Method method = signature.getMethod();
+        TranLog tanLog = new TranLog();
+        Date now = DateUtil.now();
+        tanLog.setGmtCreate(now);
+        tanLog.setGmtModified(now);
+        tanLog.setSceneName(method.getAnnotation(CdssLog.class).value());
+        long start = System.currentTimeMillis();
+        tanLog.setGmtReq(DateUtil.now());
+        tanLog = CdssLogUtil.tranLogRespAspectThrow(joinPoint, tanLog, start, ex);
+
+        //保存日志
+        mySender.outputCdssLogSend(tanLog);
+    }
+}

+ 209 - 0
src/main/java/com/diagbot/entity/TranLog.java

@@ -0,0 +1,209 @@
+package com.diagbot.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * <p>
+ * 系统日志表
+ * </p>
+ *
+ * @author zhoutg
+ * @since 2021-10-20
+ */
+public class TranLog implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 日志ID
+     */
+    @TableId(value = "id", type = IdType.AUTO)
+    private Long id;
+
+    /**
+     * 是否删除,N:未删除,Y:删除
+     */
+    private String isDeleted;
+
+    /**
+     * 记录创建时间
+     */
+    private Date gmtCreate;
+
+    /**
+     * 记录修改时间,如果时间是1970年则表示纪录未修改
+     */
+    private Date gmtModified;
+
+    /**
+     * 创建人,0表示无创建人值
+     */
+    private String creator;
+
+    /**
+     * 修改人,如果为0则表示纪录未修改
+     */
+    private String modifier;
+
+    /**
+     * 场景名称
+     */
+    private String sceneName;
+
+    /**
+     * 输入参数
+     */
+    private String params;
+
+    /**
+     * 返回参数
+     */
+    private String result;
+
+    /**
+     * 请求时间
+     */
+    private Date gmtReq;
+
+    /**
+     * 响应时间
+     */
+    private Date gmtResp;
+
+    /**
+     * 耗时
+     */
+    private String execTime;
+
+    /**
+     * 调用是否成功(0:失败;1:成功)
+     */
+    private Integer successFlag;
+
+    public Long getId() {
+        return id;
+    }
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    public String getIsDeleted() {
+        return isDeleted;
+    }
+
+    public void setIsDeleted(String isDeleted) {
+        this.isDeleted = isDeleted;
+    }
+
+    public Date getGmtCreate() {
+        return gmtCreate;
+    }
+
+    public void setGmtCreate(Date gmtCreate) {
+        this.gmtCreate = gmtCreate;
+    }
+
+    public Date getGmtModified() {
+        return gmtModified;
+    }
+
+    public void setGmtModified(Date gmtModified) {
+        this.gmtModified = gmtModified;
+    }
+
+    public String getCreator() {
+        return creator;
+    }
+
+    public void setCreator(String creator) {
+        this.creator = creator;
+    }
+
+    public String getModifier() {
+        return modifier;
+    }
+
+    public void setModifier(String modifier) {
+        this.modifier = modifier;
+    }
+
+    public String getSceneName() {
+        return sceneName;
+    }
+
+    public void setSceneName(String sceneName) {
+        this.sceneName = sceneName;
+    }
+
+    public String getParams() {
+        return params;
+    }
+
+    public void setParams(String params) {
+        this.params = params;
+    }
+
+    public String getResult() {
+        return result;
+    }
+
+    public void setResult(String result) {
+        this.result = result;
+    }
+
+    public Date getGmtReq() {
+        return gmtReq;
+    }
+
+    public void setGmtReq(Date gmtReq) {
+        this.gmtReq = gmtReq;
+    }
+
+    public Date getGmtResp() {
+        return gmtResp;
+    }
+
+    public void setGmtResp(Date gmtResp) {
+        this.gmtResp = gmtResp;
+    }
+
+    public String getExecTime() {
+        return execTime;
+    }
+
+    public void setExecTime(String execTime) {
+        this.execTime = execTime;
+    }
+
+    public Integer getSuccessFlag() {
+        return successFlag;
+    }
+
+    public void setSuccessFlag(Integer successFlag) {
+        this.successFlag = successFlag;
+    }
+
+    @Override
+    public String toString() {
+        return "TranLog{" +
+                "id=" + id +
+                ", isDeleted=" + isDeleted +
+                ", gmtCreate=" + gmtCreate +
+                ", gmtModified=" + gmtModified +
+                ", creator=" + creator +
+                ", modifier=" + modifier +
+                ", sceneName=" + sceneName +
+                ", params=" + params +
+                ", result=" + result +
+                ", gmtReq=" + gmtReq +
+                ", gmtResp=" + gmtResp +
+                ", execTime=" + execTime +
+                ", successFlag=" + successFlag +
+                "}";
+    }
+}

+ 26 - 0
src/main/java/com/diagbot/facade/LogTestFacade.java

@@ -0,0 +1,26 @@
+package com.diagbot.facade;
+
+import com.diagbot.exception.CommonErrorCode;
+import com.diagbot.exception.CommonException;
+import com.diagbot.vo.LogTestVO;
+import org.springframework.stereotype.Component;
+
+/**
+ * @Description:
+ * @author: gaodm
+ * @time: 2021/10/20 10:57
+ */
+@Component
+public class LogTestFacade {
+    public Boolean logTest(LogTestVO logTestVO) {
+        if (logTestVO.getType().equals(1)) {
+            //抛错
+            throw new CommonException(CommonErrorCode.SERVER_IS_ERROR);
+        } else if (logTestVO.getType().equals(2)) {
+
+        } else {
+            /** DO NOTHING*/
+        }
+        return true;
+    }
+}

+ 13 - 0
src/main/java/com/diagbot/facade/TranLogFacade.java

@@ -0,0 +1,13 @@
+package com.diagbot.facade;
+
+import com.diagbot.service.impl.TranLogServiceImpl;
+import org.springframework.stereotype.Component;
+
+/**
+ * @Description:
+ * @author: gaodm
+ * @time: 2021/10/20 10:24
+ */
+@Component
+public class TranLogFacade extends TranLogServiceImpl {
+}

+ 16 - 0
src/main/java/com/diagbot/mapper/TranLogMapper.java

@@ -0,0 +1,16 @@
+package com.diagbot.mapper;
+
+import com.diagbot.entity.TranLog;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * <p>
+ * 系统日志表 Mapper 接口
+ * </p>
+ *
+ * @author zhoutg
+ * @since 2021-10-20
+ */
+public interface TranLogMapper extends BaseMapper<TranLog> {
+
+}

+ 11 - 1
src/main/java/com/diagbot/rabbit/MyReceiver.java

@@ -1,5 +1,10 @@
 package com.diagbot.rabbit;
 package com.diagbot.rabbit;
 
 
+import com.diagbot.entity.TranLog;
+import com.diagbot.facade.TranLogFacade;
+import com.diagbot.util.FastJsonUtils;
+import com.diagbot.util.StringUtil;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.cloud.stream.annotation.EnableBinding;
 import org.springframework.cloud.stream.annotation.EnableBinding;
 import org.springframework.cloud.stream.annotation.StreamListener;
 import org.springframework.cloud.stream.annotation.StreamListener;
 
 
@@ -10,9 +15,14 @@ import org.springframework.cloud.stream.annotation.StreamListener;
  */
  */
 @EnableBinding({ MyProcessor.class })
 @EnableBinding({ MyProcessor.class })
 public class MyReceiver {
 public class MyReceiver {
+    @Autowired
+    private TranLogFacade tranLogFacade;
 
 
     @StreamListener(MyProcessor.INPUT_CdssLog)
     @StreamListener(MyProcessor.INPUT_CdssLog)
     public void inputCdssLog(String message) {
     public void inputCdssLog(String message) {
-        System.out.println("Received <" + "接受到的信息" + ">" + message);
+        //System.out.println("Received <" + "接受到的信息" + ">" + message);
+        if (StringUtil.isNotBlank(message)) {
+            tranLogFacade.save(FastJsonUtils.getJsonToBean(message, TranLog.class));
+        }
     }
     }
 }
 }

+ 2 - 1
src/main/java/com/diagbot/rabbit/MySender.java

@@ -1,5 +1,6 @@
 package com.diagbot.rabbit;
 package com.diagbot.rabbit;
 
 
+import com.diagbot.entity.TranLog;
 import com.diagbot.util.FastJsonUtils;
 import com.diagbot.util.FastJsonUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.beans.factory.annotation.Qualifier;
@@ -21,7 +22,7 @@ public class MySender {
     @Qualifier("outputCdssLog")
     @Qualifier("outputCdssLog")
     MessageChannel outputCdssLog;
     MessageChannel outputCdssLog;
 
 
-    public void outputCdssLogSend(String msg) {
+    public void outputCdssLogSend(TranLog msg) {
         outputCdssLog.send(MessageBuilder.withPayload(FastJsonUtils.getBeanToJson(msg)).build());
         outputCdssLog.send(MessageBuilder.withPayload(FastJsonUtils.getBeanToJson(msg)).build());
     }
     }
 }
 }

+ 16 - 0
src/main/java/com/diagbot/service/TranLogService.java

@@ -0,0 +1,16 @@
+package com.diagbot.service;
+
+import com.diagbot.entity.TranLog;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ * <p>
+ * 系统日志表 服务类
+ * </p>
+ *
+ * @author zhoutg
+ * @since 2021-10-20
+ */
+public interface TranLogService extends IService<TranLog> {
+
+}

+ 20 - 0
src/main/java/com/diagbot/service/impl/TranLogServiceImpl.java

@@ -0,0 +1,20 @@
+package com.diagbot.service.impl;
+
+import com.diagbot.entity.TranLog;
+import com.diagbot.mapper.TranLogMapper;
+import com.diagbot.service.TranLogService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.stereotype.Service;
+
+/**
+ * <p>
+ * 系统日志表 服务实现类
+ * </p>
+ *
+ * @author zhoutg
+ * @since 2021-10-20
+ */
+@Service
+public class TranLogServiceImpl extends ServiceImpl<TranLogMapper, TranLog> implements TranLogService {
+
+}

+ 151 - 0
src/main/java/com/diagbot/util/CdssLogUtil.java

@@ -0,0 +1,151 @@
+package com.diagbot.util;
+
+import com.diagbot.dto.RespDTO;
+import com.diagbot.entity.TranLog;
+import com.diagbot.exception.CommonErrorCode;
+import com.diagbot.exception.CommonException;
+import org.aspectj.lang.JoinPoint;
+import org.aspectj.lang.ProceedingJoinPoint;
+import org.springframework.validation.BindException;
+import org.springframework.validation.FieldError;
+import org.springframework.web.bind.MethodArgumentNotValidException;
+import org.springframework.web.bind.MissingServletRequestParameterException;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @Description: Cdss日志工具类
+ * @author: gaodm
+ * @time: 2021/10/20 10:30
+ */
+public class CdssLogUtil {
+
+    /**
+     * 入参设置
+     *
+     * @param joinPoint
+     */
+    public static TranLog tranLogReqAspect(ProceedingJoinPoint joinPoint) {
+        TranLog TranLog = new TranLog();
+        //请求的参数
+        Object[] args = joinPoint.getArgs();
+        //请求的参数
+        String params = "";
+        for (Object o : args) {
+            params += FastJsonUtils.getBeanToJson(o);
+            break;
+        }
+        if (!StringUtil.isEmpty(params)) {
+            TranLog.setParams(params);
+        }
+        return TranLog;
+    }
+
+    /**
+     * 正常结束出参
+     *
+     * @param tranLog
+     * @param joinPoint
+     * @return
+     * @throws Throwable
+     */
+    public static TranLog tranLogRespAspect(Object proceed, TranLog tranLog, long start, ProceedingJoinPoint joinPoint) throws Throwable {
+        String result = "";
+        result = FastJsonUtils.getBeanToJson(proceed);
+        tranLog.setSuccessFlag(1);
+        if (!StringUtil.isEmpty(result)) {
+            tranLog.setResult(result);
+            if (proceed instanceof RespDTO) {
+                RespDTO respDTO = (RespDTO) proceed;
+                if (!respDTO.code.equals("0")) {
+                    tranLog.setSuccessFlag(0);
+                }
+            }
+        }
+        long execTime = System.currentTimeMillis() - start;
+        tranLog.setGmtResp(DateUtil.now());
+        tranLog.setExecTime(String.valueOf(execTime));
+        return tranLog;
+    }
+
+    /**
+     * 异常结束
+     *
+     * @param joinPoint
+     * @param ex
+     * @return
+     */
+    public static TranLog tranLogRespAspectThrow(JoinPoint joinPoint, TranLog tranLog, long start, Throwable ex) {
+        //请求的参数
+        Object[] args = joinPoint.getArgs();
+        //请求的参数
+        String params = "";
+        for (Object o : args) {
+            params += FastJsonUtils.getBeanToJson(o);
+            break;
+        }
+        if (!StringUtil.isEmpty(params)) {
+            tranLog.setParams(params);
+        }
+        //出参设置
+        String result = "";
+        result = FastJsonUtils.getBeanToJson(handleException((Exception) ex));
+        tranLog.setResult(result);
+        tranLog.setSuccessFlag(0);
+        long execTime = System.currentTimeMillis() - start;
+        tranLog.setGmtResp(DateUtil.now());
+        tranLog.setExecTime(String.valueOf(execTime));
+        return tranLog;
+    }
+
+    /**
+     * 抛错信息处理
+     *
+     * @param e
+     * @return 结果参数
+     */
+    private static RespDTO handleException(Exception e) {
+        RespDTO resp = new RespDTO();
+        if (e instanceof BindException) {
+            BindException ex = (BindException) e;
+            Map<String, String> stringMap = new HashMap<>();
+            for (FieldError fieldError : ex.getBindingResult().getFieldErrors()) {
+                stringMap.put(fieldError.getField(), fieldError.getDefaultMessage());
+            }
+            String msg = FastJsonUtils.getBeanToJson(stringMap);
+            resp.code = CommonErrorCode.PARAM_ERROR.getCode();
+            resp.msg = msg;
+            return resp;
+        }
+        if (e instanceof MethodArgumentNotValidException) {
+            MethodArgumentNotValidException ex = (MethodArgumentNotValidException) e;
+            Map<String, String> stringMap = new HashMap<>();
+            for (FieldError fieldError : ex.getBindingResult().getFieldErrors()) {
+                stringMap.put(fieldError.getField(), fieldError.getDefaultMessage());
+            }
+            String msg = FastJsonUtils.getBeanToJson(stringMap);
+            resp.code = CommonErrorCode.PARAM_ERROR.getCode();
+            resp.msg = msg;
+            return resp;
+        }
+        if (e instanceof MissingServletRequestParameterException) {
+            MissingServletRequestParameterException ex = (MissingServletRequestParameterException) e;
+            Map<String, String> stringMap = new HashMap<>();
+            stringMap.put(ex.getParameterName(), "不能为null");
+            String msg = FastJsonUtils.getBeanToJson(stringMap);
+            resp.code = CommonErrorCode.PARAM_ERROR.getCode();
+            resp.msg = msg;
+            return resp;
+        }
+        if (e instanceof CommonException) {
+            CommonException taiChiException = (CommonException) e;
+            resp.code = taiChiException.getCode();
+            resp.msg = e.getMessage();
+            return resp;
+        }
+        resp.code = CommonErrorCode.FAIL.getCode();
+        resp.msg = e.getMessage();
+        return resp;
+    }
+}

+ 20 - 0
src/main/java/com/diagbot/vo/LogTestVO.java

@@ -0,0 +1,20 @@
+package com.diagbot.vo;
+
+import lombok.Getter;
+import lombok.Setter;
+
+import javax.validation.constraints.NotNull;
+
+/**
+ * @Description:
+ * @author: gaodm
+ * @time: 2021/10/20 10:53
+ */
+@Getter
+@Setter
+public class LogTestVO {
+    private String msg;
+    //0:正常,1:抛错,3:子方法放入参数
+    @NotNull
+    private Integer type = 0;
+}

+ 12 - 7
src/main/java/com/diagbot/web/LogTestController.java

@@ -1,8 +1,10 @@
 package com.diagbot.web;
 package com.diagbot.web;
 
 
+import com.diagbot.annotation.CdssLog;
 import com.diagbot.annotation.SysLogger;
 import com.diagbot.annotation.SysLogger;
 import com.diagbot.dto.RespDTO;
 import com.diagbot.dto.RespDTO;
-import com.diagbot.rabbit.MySender;
+import com.diagbot.facade.LogTestFacade;
+import com.diagbot.vo.LogTestVO;
 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;
@@ -11,6 +13,8 @@ import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 import org.springframework.web.bind.annotation.RestController;
 
 
+import javax.validation.Valid;
+
 /**
 /**
  * @Description: 站内信控制层
  * @Description: 站内信控制层
  * @author: gaodm
  * @author: gaodm
@@ -21,17 +25,18 @@ import org.springframework.web.bind.annotation.RestController;
 @RequestMapping("/test")
 @RequestMapping("/test")
 @SuppressWarnings("unchecked")
 @SuppressWarnings("unchecked")
 public class LogTestController {
 public class LogTestController {
-
     @Autowired
     @Autowired
-    private MySender mySender;
+    private LogTestFacade logTestFacade;
 
 
 
 
-    @ApiOperation(value = "异步日志测试[by:gaodm]", notes = "异步日志测试")
+    @ApiOperation(value = "异步日志测试[by:gaodm]",
+            notes = "msg:信息内容<br>" +
+                    "type:0:正常,1:抛错,3:子方法放入参数")
     @PostMapping("/logTest")
     @PostMapping("/logTest")
     @SysLogger("logTest")
     @SysLogger("logTest")
-    public RespDTO<Boolean> logTest(@RequestBody String msg) {
-        mySender.outputCdssLogSend(msg);
-        return RespDTO.onSuc(true);
+    @CdssLog("异步日志测试")
+    public RespDTO<Boolean> logTest(@RequestBody @Valid LogTestVO logTestVO) {
+        return RespDTO.onSuc(logTestFacade.logTest(logTestVO));
     }
     }
 }
 }
 
 

+ 4 - 0
src/main/resources/application-dev.yml

@@ -184,6 +184,10 @@ oath.self.address: http://${myhost}:${server.port}
 swagger:
 swagger:
   enable: true
   enable: true
 
 
+#日志记录
+cdssLog:
+  enable: true
+
 #Token鉴权
 #Token鉴权
 tokenAuth:
 tokenAuth:
   enable: false
   enable: false

+ 4 - 0
src/main/resources/application-local.yml

@@ -184,6 +184,10 @@ oath.self.address: http://${myhost}:${server.port}
 swagger:
 swagger:
   enable: true
   enable: true
 
 
+#日志记录
+cdssLog:
+  enable: true
+
 #Token鉴权
 #Token鉴权
 tokenAuth:
 tokenAuth:
   enable: false
   enable: false

+ 4 - 0
src/main/resources/application-pre.yml

@@ -185,6 +185,10 @@ oath.self.address: http://${myhost}:${server.port}
 swagger:
 swagger:
   enable: true
   enable: true
 
 
+#日志记录
+cdssLog:
+  enable: true
+
 #Token鉴权
 #Token鉴权
 tokenAuth:
 tokenAuth:
   enable: false
   enable: false

+ 4 - 0
src/main/resources/application-pro.yml

@@ -184,6 +184,10 @@ oath.self.address: http://${myhost}:${server.port}
 swagger:
 swagger:
   enable: true
   enable: true
 
 
+#日志记录
+cdssLog:
+  enable: true
+
 #Token鉴权
 #Token鉴权
 tokenAuth:
 tokenAuth:
   enable: false
   enable: false

+ 4 - 0
src/main/resources/application-test.yml

@@ -184,6 +184,10 @@ oath.self.address: http://${myhost}:${server.port}
 swagger:
 swagger:
   enable: true
   enable: true
 
 
+#日志记录
+cdssLog:
+  enable: true
+
 #Token鉴权
 #Token鉴权
 tokenAuth:
 tokenAuth:
   enable: false
   enable: false

+ 22 - 0
src/main/resources/mapper/TranLogMapper.xml

@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.diagbot.mapper.TranLogMapper">
+
+    <!-- 通用查询映射结果 -->
+    <resultMap id="BaseResultMap" type="com.diagbot.entity.TranLog">
+        <id column="id" property="id" />
+        <result column="is_deleted" property="isDeleted" />
+        <result column="gmt_create" property="gmtCreate" />
+        <result column="gmt_modified" property="gmtModified" />
+        <result column="creator" property="creator" />
+        <result column="modifier" property="modifier" />
+        <result column="scene_name" property="sceneName" />
+        <result column="params" property="params" />
+        <result column="result" property="result" />
+        <result column="gmt_req" property="gmtReq" />
+        <result column="gmt_resp" property="gmtResp" />
+        <result column="exec_time" property="execTime" />
+        <result column="success_flag" property="successFlag" />
+    </resultMap>
+
+</mapper>

+ 1 - 1
src/test/java/com/diagbot/CodeGeneration.java

@@ -57,7 +57,7 @@ public class CodeGeneration {
         StrategyConfig strategy = new StrategyConfig();
         StrategyConfig strategy = new StrategyConfig();
         // strategy.setTablePrefix(new String[] { "demo_" });// 此处可以修改为您的表前缀
         // strategy.setTablePrefix(new String[] { "demo_" });// 此处可以修改为您的表前缀
         strategy.setNaming(NamingStrategy.underline_to_camel);// 表名生成策略
         strategy.setNaming(NamingStrategy.underline_to_camel);// 表名生成策略
-        strategy.setInclude(new String[] { "tran_hospital_relation"}); // 需要生成的表
+        strategy.setInclude(new String[] { "tran_log"}); // 需要生成的表
 
 
         strategy.setSuperServiceClass(null);
         strategy.setSuperServiceClass(null);
         strategy.setSuperServiceImplClass(null);
         strategy.setSuperServiceImplClass(null);