删除elog
This commit is contained in:
parent
395d3f567f
commit
405fe226d9
|
|
@ -1,15 +0,0 @@
|
|||
package com.api.salary.web;
|
||||
|
||||
import javax.ws.rs.Path;
|
||||
|
||||
/**
|
||||
* 日志列表公共接口暴漏
|
||||
* <p>Copyright: Copyright (c) 2023</p>
|
||||
* <p>Company: 泛微软件</p>
|
||||
*
|
||||
* @author qiantao
|
||||
* @version 1.0
|
||||
**/
|
||||
@Path("/bs/hrmsalary/elog")
|
||||
public class LoggerTableController extends com.engine.salary.elog.web.LoggerTableController{
|
||||
}
|
||||
|
|
@ -1,23 +0,0 @@
|
|||
package com.engine.salary.elog.annotation;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
@Documented
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target({ElementType.METHOD})
|
||||
public @interface Elog {
|
||||
|
||||
String module();
|
||||
|
||||
String function();
|
||||
|
||||
String operateType();
|
||||
|
||||
String operateTypeName();
|
||||
|
||||
String sql() default "";
|
||||
|
||||
boolean isLocal() default true;
|
||||
|
||||
String infoMethod() default "";
|
||||
}
|
||||
|
|
@ -1,14 +0,0 @@
|
|||
package com.engine.salary.elog.annotation;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
@Documented
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target({ElementType.FIELD})
|
||||
public @interface ElogDetailField {
|
||||
|
||||
String fieldType() default "varchar";
|
||||
String length() default "50";
|
||||
String fieldName();
|
||||
String desc() default "自定义字段";
|
||||
}
|
||||
|
|
@ -1,13 +0,0 @@
|
|||
package com.engine.salary.elog.annotation;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
@Documented
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target({ElementType.TYPE})
|
||||
public @interface ElogDetailTable {
|
||||
|
||||
String module();
|
||||
|
||||
String function() default "common";
|
||||
}
|
||||
|
|
@ -1,23 +0,0 @@
|
|||
package com.engine.salary.elog.annotation;
|
||||
|
||||
import com.engine.salary.elog.entity.dto.DataTypeEnum;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
@Documented
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target({ElementType.FIELD})
|
||||
public @interface ElogField {
|
||||
|
||||
DataTypeEnum dataType() default DataTypeEnum.VARCHAR;
|
||||
|
||||
int length() default 50;
|
||||
|
||||
String comment() default "自定义字段";
|
||||
|
||||
String defaultValue() default "";
|
||||
|
||||
boolean isNull() default true;
|
||||
|
||||
boolean isKey() default false;
|
||||
}
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
package com.engine.salary.elog.annotation;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
@Documented
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target({ElementType.PARAMETER})
|
||||
public @interface ElogPrimaryKey {
|
||||
}
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
package com.engine.salary.elog.annotation;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
@Documented
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target({ElementType.TYPE})
|
||||
|
||||
public @interface ElogTable {
|
||||
|
||||
String module();
|
||||
|
||||
String function() default "common";
|
||||
}
|
||||
|
|
@ -1,29 +0,0 @@
|
|||
package com.engine.salary.elog.annotation;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
@Documented
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target({ElementType.FIELD, ElementType.TYPE})
|
||||
@Inherited
|
||||
public @interface ElogTransform {
|
||||
|
||||
String tablename() default "";
|
||||
|
||||
String name();
|
||||
|
||||
int labelId() default -1;
|
||||
|
||||
String type() default "";
|
||||
|
||||
String valuesKVPairs() default "";
|
||||
|
||||
boolean ignore() default false;
|
||||
|
||||
boolean analyticSubclass() default false;
|
||||
|
||||
boolean analyticList() default false;
|
||||
|
||||
Class<?> analyticListClass() default void.class;
|
||||
|
||||
}
|
||||
|
|
@ -1,17 +0,0 @@
|
|||
package com.engine.salary.elog.annotation;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
@Target(ElementType.TYPE)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface HandleElog {
|
||||
|
||||
String modulename() default "";
|
||||
|
||||
String functionname() default "";
|
||||
|
||||
String service() default "";
|
||||
}
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
package com.engine.salary.elog.annotation;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* @ClassName: LoggerTarget
|
||||
* @Description 日志构造器-自定义注解
|
||||
* @Author tanghj
|
||||
* @Date 2021/2/10 14:18
|
||||
*/
|
||||
@Documented
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target({ElementType.TYPE})
|
||||
public @interface LoggerTarget {
|
||||
// @AliasFor("module")
|
||||
String value() default "";
|
||||
|
||||
// @AliasFor("value")
|
||||
String module() default "";
|
||||
|
||||
String function() default "common";
|
||||
}
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
package com.engine.salary.elog.annotation;
|
||||
|
||||
public class OperateType {
|
||||
public static final String view = "view";
|
||||
public static final String viewSpan = "查看";
|
||||
|
||||
public static final String add = "add";
|
||||
public static final String addSpan = "新增";
|
||||
|
||||
public static final String update = "update";
|
||||
public static final String updateSpan = "更新";
|
||||
|
||||
public static final String delete = "delete";
|
||||
public static final String deleteSpan = "删除";
|
||||
}
|
||||
|
|
@ -1,177 +0,0 @@
|
|||
//package com.engine.salary.elog.annotation.handle;
|
||||
//
|
||||
//import com.weaver.common.async.producer.client.AsyncClient;
|
||||
//import com.weaver.common.distribution.genid.IdGenerator;
|
||||
//import com.weaver.common.elog.annotation.Elog;
|
||||
//import com.weaver.common.elog.annotation.ElogPrimaryKey;
|
||||
//import com.weaver.common.elog.dao.QueryCurretValusMapper;
|
||||
//import com.weaver.common.elog.dto.LoggerContext;
|
||||
//import com.weaver.common.elog.util.LoggerTemplate;
|
||||
//import org.apache.commons.lang3.StringUtils;
|
||||
//import org.aspectj.lang.ProceedingJoinPoint;
|
||||
//import org.aspectj.lang.Signature;
|
||||
//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.context.ApplicationContext;
|
||||
//import org.springframework.stereotype.Component;
|
||||
//import org.springframework.util.ReflectionUtils;
|
||||
//
|
||||
//import java.lang.annotation.Annotation;
|
||||
//import java.lang.reflect.Method;
|
||||
//import java.util.Date;
|
||||
//import java.util.List;
|
||||
//import java.util.Map;
|
||||
//
|
||||
//
|
||||
///**
|
||||
// * @ClassName: LoggerTargetHandler
|
||||
// * @Description 从Spring扫描到的类中获取到Elog自定义注解类设置function属性
|
||||
// * @Author tanghj
|
||||
// * @Date 2021/2/10 14:18
|
||||
// */
|
||||
//@Aspect
|
||||
//
|
||||
//public class ElogHandler {
|
||||
//
|
||||
// @Autowired
|
||||
// ApplicationContext applicationContext;
|
||||
//
|
||||
// @Autowired
|
||||
// protected AsyncClient asyncClient;
|
||||
//
|
||||
// @Autowired
|
||||
// QueryCurretValusMapper queryCurretValusMapper;
|
||||
//
|
||||
// /**
|
||||
// * 切面写入日志
|
||||
// */
|
||||
// @Pointcut("@annotation(com.weaver.common.elog.annotation.Elog)" )
|
||||
// public void writeLog(){}
|
||||
// @Around("writeLog()")
|
||||
// public Object writeLog(ProceedingJoinPoint pjp){
|
||||
// Object[] args = pjp.getArgs();
|
||||
// Signature signature = pjp.getSignature();
|
||||
// MethodSignature methodSignature = (MethodSignature) signature;
|
||||
// Method method = methodSignature.getMethod();
|
||||
//
|
||||
// Elog elog = method.getAnnotation(Elog.class);
|
||||
// String moduleName = elog.module();
|
||||
// String funtionName = elog.function();
|
||||
// String operateType = elog.operateType();
|
||||
// String operateTypeName = elog.operateTypeName();
|
||||
// boolean isLocal = elog.isLocal();
|
||||
// Annotation[][] annos = method.getParameterAnnotations();
|
||||
//
|
||||
// Object id = null;
|
||||
// int keyPosition = -1;
|
||||
// int index = 0;
|
||||
//
|
||||
// Class idClass = null;
|
||||
// // 获取主键id注解
|
||||
// for(Annotation[] anno : annos) {
|
||||
// if(anno.length > 0) {
|
||||
// for(Annotation annotation : anno) {
|
||||
// if(annotation instanceof ElogPrimaryKey) {
|
||||
// idClass = method.getParameters()[index].getType();
|
||||
// id = args[index];
|
||||
// if(StringUtils.isEmpty(id+"")) {
|
||||
// id = idClass.cast(IdGenerator.generate() + "");
|
||||
// }
|
||||
// keyPosition = index;
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// index ++;
|
||||
// }
|
||||
//
|
||||
// LoggerContext loggerContext = null;
|
||||
// // 获取日志实体类
|
||||
// for(Object arg: args) {
|
||||
// if(arg instanceof LoggerContext) {
|
||||
// loggerContext = (LoggerContext) arg;
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// if(loggerContext == null) {
|
||||
// loggerContext = new LoggerContext();
|
||||
// }
|
||||
//
|
||||
// // 日志实体类的初始化
|
||||
// // loggerContext.setOperateType("UPDATE");
|
||||
// loggerContext.setFunctionName(funtionName);
|
||||
// loggerContext.setModuleName(moduleName);
|
||||
// loggerContext.setOperateType(operateType);
|
||||
// loggerContext.setOperateTypeName(operateTypeName);
|
||||
// loggerContext.setDate(new Date());
|
||||
// loggerContext.setDevice("IOS");
|
||||
//
|
||||
// String sql = elog.sql();
|
||||
// String infoMethod = elog.infoMethod();
|
||||
//
|
||||
// boolean isSql = false;
|
||||
// boolean isMethod = false;
|
||||
// Object currentClass = null;
|
||||
// Method infoMtd = null;
|
||||
// if(StringUtils.isNotEmpty(id+"")) {
|
||||
// if(StringUtils.isNotEmpty(sql)) {
|
||||
// isSql = true;
|
||||
// Map oldValue = queryCurretValusMapper.queryValues(String.format(sql, id));
|
||||
// loggerContext.setOldValues(oldValue);
|
||||
// } else if(StringUtils.isNotEmpty(infoMethod)){
|
||||
// isMethod = true;
|
||||
// currentClass = applicationContext.getBean(pjp.getTarget().getClass());
|
||||
// // 获取方法
|
||||
// infoMtd = ReflectionUtils.findMethod(pjp.getTarget().getClass(),infoMethod, idClass);
|
||||
//
|
||||
// // todo 为空的情况加异常提醒
|
||||
// // 反射执行方法
|
||||
// Object res= ReflectionUtils.invokeMethod(infoMtd,currentClass, id);
|
||||
// if(res != null) {
|
||||
// if(res instanceof List) {
|
||||
// loggerContext.setOldValueList((List) res);
|
||||
// } else {
|
||||
// loggerContext.setOldValues(res);
|
||||
// }
|
||||
//
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// LoggerTemplate loggerTemplate = new LoggerTemplate();
|
||||
// loggerTemplate.setFunction(funtionName);
|
||||
// loggerTemplate.setModule(moduleName);
|
||||
// loggerTemplate.setAsyncClient(asyncClient);
|
||||
//
|
||||
// Object result = null;
|
||||
// try {
|
||||
// args[keyPosition] = id;
|
||||
// result = pjp.proceed(args);
|
||||
// } catch (Throwable throwable) {
|
||||
// throwable.printStackTrace();
|
||||
// }
|
||||
// if(isSql) {
|
||||
// Map oldValue = queryCurretValusMapper.queryValues(String.format(sql, id));
|
||||
// loggerContext.setNewValues(oldValue);
|
||||
// } else if(isMethod) {
|
||||
// Object res= ReflectionUtils.invokeMethod(infoMtd,currentClass, id);
|
||||
// if(res != null) {
|
||||
// if(res instanceof List) {
|
||||
// loggerContext.setNewValueList((List) res);
|
||||
// } else {
|
||||
// loggerContext.setNewValues(res);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// if(isLocal)
|
||||
// loggerTemplate.write(loggerContext);
|
||||
// else
|
||||
// loggerTemplate.write(loggerContext,false);
|
||||
// return result;
|
||||
//
|
||||
// }
|
||||
//}
|
||||
|
|
@ -1,156 +0,0 @@
|
|||
//package com.engine.salary.elog.annotation.handle;
|
||||
//
|
||||
//import com.engine.salary.elog.annotation.ElogField;
|
||||
//import com.engine.salary.elog.annotation.ElogTable;
|
||||
//import com.engine.salary.elog.entity.dto.DataTypeEnum;
|
||||
//import com.engine.salary.elog.entity.dto.TableColumnBean;
|
||||
//import com.engine.salary.elog.util.ElogUtils;
|
||||
//import lombok.extern.slf4j.Slf4j;
|
||||
//import org.reflections.Reflections;
|
||||
//import org.slf4j.Logger;
|
||||
//import org.slf4j.LoggerFactory;
|
||||
//
|
||||
//import java.lang.reflect.Field;
|
||||
//import java.util.*;
|
||||
//import java.util.stream.Collectors;
|
||||
//
|
||||
///**
|
||||
// * @ClassName: ElogTableScanner
|
||||
// * @Description 日志操作表扫描
|
||||
// * @Author tanghj
|
||||
// * @Date 2021/3/12 13:31
|
||||
// */
|
||||
//@Slf4j
|
||||
//public class ElogTableScanner {
|
||||
// private Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
//
|
||||
//// private TableCheckerMapper tableCheckerMapper;
|
||||
//
|
||||
//// @Override
|
||||
// public void run() throws Exception {
|
||||
//
|
||||
// // todo 需要考虑集群下,控制一台机器来跑
|
||||
// scanElogTable();
|
||||
//
|
||||
// }
|
||||
//
|
||||
// private void scanElogTable() {
|
||||
// // todo 是否还需要扫描Elog(因为可能不需要本地存储) ELogDetailTable,
|
||||
//// Map<String, Object> tableBeans = this.applicationContext.getBeansWithAnnotation(ElogTable.class);
|
||||
// Reflections reflections = new Reflections("com.engine.salary.elog");
|
||||
// Set<Class<?>> tableBeans = reflections.getTypesAnnotatedWith(ElogTable.class);
|
||||
//
|
||||
//
|
||||
// List<TableColumnBean> baseColumns = new ArrayList<>();
|
||||
//
|
||||
// Map<String, List<TableColumnBean>> tableColumns = elogTableHandle(tableBeans,baseColumns);
|
||||
//
|
||||
// for(String tableName : tableColumns.keySet()) {
|
||||
//
|
||||
// // todo 需要处理明细表,如果没有直接初始化原始明细表,如果有加上自定义的
|
||||
// List<TableColumnBean> columns = tableColumns.get(tableName);
|
||||
// if(columns == null) {
|
||||
// columns = baseColumns;
|
||||
// } else {
|
||||
// columns.addAll(baseColumns);
|
||||
// }
|
||||
// tableCheck(tableName, columns);
|
||||
// }
|
||||
//
|
||||
// }
|
||||
//
|
||||
// private Map<String, List<TableColumnBean>> elogTableHandle(Set<Class<?>> tableBeans, List<TableColumnBean> baseColumns) {
|
||||
// Map<String, List<TableColumnBean>> tableMap = new HashMap<>();
|
||||
// for (Class<?> aClass :tableBeans) {//遍历每个controller层
|
||||
//
|
||||
// List<TableColumnBean> list = new ArrayList<>();
|
||||
//
|
||||
// ElogTable elogTable = aClass.getAnnotation(ElogTable.class);
|
||||
//
|
||||
// List<Field> fields = Arrays.asList(aClass.getDeclaredFields());//获取方法
|
||||
// for (Field f : fields) {
|
||||
//
|
||||
// ElogField field = f.getAnnotation(ElogField.class);
|
||||
// if(field == null) {
|
||||
// continue;
|
||||
// }
|
||||
//
|
||||
// TableColumnBean tableColumnBean = new TableColumnBean();
|
||||
//
|
||||
// tableColumnBean.setColumnName(f.getName());
|
||||
// tableColumnBean.setColumnComment(field.comment());
|
||||
// tableColumnBean.setColumnDefault(field.defaultValue());
|
||||
// tableColumnBean.setFieldLength(field.length());
|
||||
// tableColumnBean.setDataType(field.dataType());
|
||||
// tableColumnBean.setNullable(field.isNull());
|
||||
// list.add(tableColumnBean);
|
||||
// }
|
||||
// if(!ElogUtils.BASE_TABLE.equals(elogTable.module())) {
|
||||
// tableMap.put(ElogUtils.getTableName(elogTable.module(), elogTable.function()), list);
|
||||
// } else {
|
||||
// baseColumns.addAll(list);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// return tableMap;
|
||||
// }
|
||||
//
|
||||
// private void tableCheck(String tableName, List<TableColumnBean> columns) {
|
||||
// List<TableColumnBean> oldColumns = new ArrayList<>();
|
||||
//// List<TableColumnBean> oldColumns = tableCheckerMapper.getTableStructure(tableName);
|
||||
//
|
||||
// // 表不存在
|
||||
// if(oldColumns == null || oldColumns.size() == 0) {
|
||||
// createTable(tableName,columns );
|
||||
// } else {
|
||||
// Map<String, TableColumnBean> newcolMap = new HashMap<>();
|
||||
// Map<String, TableColumnBean> oldcolMap = new HashMap<>();
|
||||
//
|
||||
// columns.stream().forEach(tableColumnBean -> newcolMap.put(tableColumnBean.getColumnName().toLowerCase(), tableColumnBean));
|
||||
// oldColumns.stream().forEach(tableColumnBean -> {
|
||||
// tableColumnBean.setDataType(ElogUtils.getEnumFromString(DataTypeEnum.class, tableColumnBean.getDataTypeStr()));
|
||||
// tableColumnBean.setNullable("YES".equalsIgnoreCase(tableColumnBean.getIsNullableStr()));
|
||||
// oldcolMap.put(tableColumnBean.getColumnName().toLowerCase(), tableColumnBean);
|
||||
// });
|
||||
// // 只增加或者修改,不删除字段
|
||||
// for(String key : newcolMap.keySet()) {
|
||||
// if(oldcolMap.containsKey(key)) {
|
||||
// // 字段变动则修改
|
||||
// if(!(newcolMap.get(key).toSql()).equals(oldcolMap.get(key).toSql()))
|
||||
// this.modifyColumn(tableName, newcolMap.get(key));
|
||||
// } else {
|
||||
// this.addColumn(tableName, newcolMap.get(key));
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// }
|
||||
//
|
||||
// private void createTable(String tableName, List<TableColumnBean> columns) {
|
||||
// StringBuilder sb = new StringBuilder("create table ").append(tableName).append(" ( ");
|
||||
// sb.append(columns.stream().map( bean -> bean.toSql()).collect(Collectors.joining(",")));
|
||||
// sb.append(")");
|
||||
// logger.info("创建sql:{}",sb.toString());
|
||||
//// tableCheckerMapper.createElogTable(sb.toString());
|
||||
// }
|
||||
//
|
||||
// private void addColumn(String tableName, TableColumnBean tableColumnBean) {
|
||||
// StringBuilder sb = new StringBuilder("alter table ")
|
||||
// .append(tableName).append(" ")
|
||||
// .append(" add ")
|
||||
// .append(" column ")
|
||||
// .append(tableColumnBean.toSql());
|
||||
// logger.info("新增字段sql:{}",sb.toString());
|
||||
//// tableCheckerMapper.createElogTable(sb.toString());
|
||||
// }
|
||||
//
|
||||
// private void modifyColumn(String tableName, TableColumnBean tableColumnBean) {
|
||||
// StringBuilder sb = new StringBuilder("alter table ")
|
||||
// .append(tableName).append(" ")
|
||||
// .append(" modify ")
|
||||
// .append(" column ")
|
||||
// .append(tableColumnBean.toSql());
|
||||
// logger.info("修改字段sql:{}",sb.toString());
|
||||
//// tableCheckerMapper.createElogTable(sb.toString());
|
||||
// }
|
||||
//}
|
||||
|
|
@ -1,38 +0,0 @@
|
|||
//package com.engine.salary.elog.annotation.handle;
|
||||
//
|
||||
//import com.weaver.common.elog.annotation.LoggerTarget;
|
||||
//import com.weaver.common.elog.util.LoggerTemplate;
|
||||
//import org.apache.commons.lang3.StringUtils;
|
||||
//import org.springframework.beans.factory.annotation.Autowired;
|
||||
//import org.springframework.boot.CommandLineRunner;
|
||||
//import org.springframework.context.ApplicationContext;
|
||||
//import org.springframework.stereotype.Component;
|
||||
//
|
||||
//import java.util.Map;
|
||||
//
|
||||
//
|
||||
///**
|
||||
// * @ClassName: LoggerTargetHandler
|
||||
// * @Description 从Spring扫描到的类中获取到LoggerTarget自定义注解类设置function属性
|
||||
// * @Author tanghj
|
||||
// * @Date 2021/2/10 14:18
|
||||
// */
|
||||
//
|
||||
//public class LoggerTargetHandler {
|
||||
//
|
||||
// ApplicationContext applicationContext;
|
||||
//
|
||||
// @Override
|
||||
// public void run(String... args) throws Exception {
|
||||
// Map<String, Object> loggtemplateMap = applicationContext.getBeansWithAnnotation(LoggerTarget.class);
|
||||
//
|
||||
// for(Object obj : loggtemplateMap.values()) {
|
||||
// if(obj instanceof LoggerTemplate) {
|
||||
// LoggerTarget loggerTarget = obj.getClass().getAnnotation(LoggerTarget.class);
|
||||
// ((LoggerTemplate) obj).setFunction(loggerTarget.function());
|
||||
// ((LoggerTemplate) obj).setModule(StringUtils.isNotEmpty(loggerTarget.value()) ? loggerTarget.value() : loggerTarget.module());
|
||||
// }
|
||||
//
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
|
@ -1,30 +0,0 @@
|
|||
package com.engine.salary.elog.async;
|
||||
|
||||
import com.engine.salary.elog.config.ELogTableChecker;
|
||||
import com.engine.salary.elog.entity.dto.LoggerContext;
|
||||
import com.engine.salary.elog.service.impl.LocalElogService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* @ClassName: LoggerMessageListener
|
||||
* @Description 本地日志存储消息队列监听类
|
||||
* @Author tanghj
|
||||
* @Date 2021/2/10 14:18
|
||||
*/
|
||||
public class LoggerMessageListener {
|
||||
|
||||
private final Logger logger = LoggerFactory.getLogger(getClass());
|
||||
|
||||
LocalElogService localElogService = new LocalElogService();
|
||||
|
||||
public <T> String receiveold(LoggerContext messageBean) {
|
||||
|
||||
new ELogTableChecker().check(messageBean);
|
||||
localElogService.insertLocalElog(messageBean);
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -1,25 +0,0 @@
|
|||
package com.engine.salary.elog.config;
|
||||
|
||||
import com.engine.salary.mapper.elog.ElogTableCheckerMapper;
|
||||
import com.engine.salary.util.db.MapperProxyFactory;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class ELogCache {
|
||||
|
||||
private Map<String, Long> tableCache = new HashMap<>();
|
||||
|
||||
private ElogTableCheckerMapper getTableCheckerMapper() {
|
||||
return MapperProxyFactory.getProxy(ElogTableCheckerMapper.class);
|
||||
}
|
||||
|
||||
public Long getVersion(String mainTable) {
|
||||
Long version = tableCache.get(mainTable);
|
||||
if (version == null) {
|
||||
version = getTableCheckerMapper().getVersion(mainTable);
|
||||
tableCache.put(mainTable, version);
|
||||
}
|
||||
return version;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,44 +0,0 @@
|
|||
package com.engine.salary.elog.config;
|
||||
|
||||
import com.engine.salary.elog.entity.dto.LoggerContext;
|
||||
import com.engine.salary.mapper.elog.ElogTableCheckerMapper;
|
||||
import com.engine.salary.util.db.IdGenerator;
|
||||
import com.engine.salary.util.db.MapperProxyFactory;
|
||||
|
||||
|
||||
public class ELogTableChecker {
|
||||
private static final long version = 0;
|
||||
private ELogCache eLogCache = new ELogCache();
|
||||
|
||||
private ElogTableCheckerMapper getTableCheckerMapper() {
|
||||
return MapperProxyFactory.getProxy(ElogTableCheckerMapper.class);
|
||||
}
|
||||
|
||||
public <T> void check(LoggerContext<T> loggerContext) {
|
||||
String module = loggerContext.getModuleName();
|
||||
String function = loggerContext.getFunctionName();
|
||||
String mainTable = String.format("%s_%slogs", module, function);
|
||||
Long v = eLogCache.getVersion(mainTable);
|
||||
boolean noTable = v == null;
|
||||
if (noTable) {
|
||||
this.initTable(mainTable);
|
||||
v = version;
|
||||
} else {
|
||||
this.checkVersion(mainTable, v);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void checkVersion(String mainTable, Long v) {
|
||||
if (v == version) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void initTable(String mainTable) {
|
||||
getTableCheckerMapper().recordVersion(IdGenerator.generate(), mainTable, version);
|
||||
getTableCheckerMapper().createMainTable(mainTable);
|
||||
getTableCheckerMapper().createDetailTable(mainTable + "_detail");
|
||||
}
|
||||
}
|
||||
|
|
@ -1,25 +0,0 @@
|
|||
package com.engine.salary.elog.entity.dto;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
/**
|
||||
* @ClassName: CancelContext
|
||||
* @Description 撤销实体类
|
||||
* @Author tanghj
|
||||
* @Date 2021/2/10 14:18
|
||||
*/
|
||||
@ApiModel("撤销实体类")
|
||||
public class CancelContext<T> {
|
||||
|
||||
@ApiModelProperty("撤销参数")
|
||||
private T cancleParams;
|
||||
|
||||
public T getCancleParams() {
|
||||
return cancleParams;
|
||||
}
|
||||
|
||||
public void setCancleParams(T cancleParams) {
|
||||
this.cancleParams = cancleParams;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
package com.engine.salary.elog.entity.dto;
|
||||
|
||||
public enum DataTypeEnum {
|
||||
VARCHAR,
|
||||
BIGINT,
|
||||
INT,
|
||||
DATETIME,
|
||||
TEXT,
|
||||
LONGTEXT,
|
||||
DOUBLE,
|
||||
DECIMAL,
|
||||
TINYINT,
|
||||
FLOAT;
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -1,116 +0,0 @@
|
|||
package com.engine.salary.elog.entity.dto;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @Date: 2022/5/2 21:51
|
||||
* @Author: deli.xu
|
||||
* @Description: 日志中心bean
|
||||
**/
|
||||
public class ElogBean implements Serializable {
|
||||
|
||||
|
||||
private static final long serialVersionUID = 5357552376749564256L;
|
||||
private String module;
|
||||
private String function;
|
||||
private String current;
|
||||
private String pageSize;
|
||||
private String dataset;
|
||||
private String searchMap;
|
||||
private List<ShowColumsDto> showColumns = new ArrayList<>();
|
||||
private List<FilterConditionDto> filterConditionDtos = new ArrayList<>();
|
||||
private String downloadSize;
|
||||
private String transMethod;
|
||||
private Map authParamsJson;
|
||||
|
||||
public String getModule() {
|
||||
return module;
|
||||
}
|
||||
|
||||
public void setModule(String module) {
|
||||
this.module = module;
|
||||
}
|
||||
|
||||
public String getFunction() {
|
||||
return function;
|
||||
}
|
||||
|
||||
public void setFunction(String function) {
|
||||
this.function = function;
|
||||
}
|
||||
|
||||
public String getCurrent() {
|
||||
return current;
|
||||
}
|
||||
|
||||
public void setCurrent(String current) {
|
||||
this.current = current;
|
||||
}
|
||||
|
||||
public String getPageSize() {
|
||||
return pageSize;
|
||||
}
|
||||
|
||||
public void setPageSize(String pageSize) {
|
||||
this.pageSize = pageSize;
|
||||
}
|
||||
|
||||
public String getDataset() {
|
||||
return dataset;
|
||||
}
|
||||
|
||||
public void setDataset(String dataset) {
|
||||
this.dataset = dataset;
|
||||
}
|
||||
|
||||
public String getSearchMap() {
|
||||
return searchMap;
|
||||
}
|
||||
|
||||
public void setSearchMap(String searchMap) {
|
||||
this.searchMap = searchMap;
|
||||
}
|
||||
|
||||
public List<ShowColumsDto> getShowColumns() {
|
||||
return showColumns;
|
||||
}
|
||||
|
||||
public void setShowColumns(List<ShowColumsDto> showColumns) {
|
||||
this.showColumns = showColumns;
|
||||
}
|
||||
|
||||
public List<FilterConditionDto> getFilterConditionDtos() {
|
||||
return filterConditionDtos;
|
||||
}
|
||||
|
||||
public void setFilterConditionDtos(List<FilterConditionDto> filterConditionDtos) {
|
||||
this.filterConditionDtos = filterConditionDtos;
|
||||
}
|
||||
|
||||
public String getDownloadSize() {
|
||||
return downloadSize;
|
||||
}
|
||||
|
||||
public void setDownloadSize(String downloadSize) {
|
||||
this.downloadSize = downloadSize;
|
||||
}
|
||||
|
||||
public String getTransMethod() {
|
||||
return transMethod;
|
||||
}
|
||||
|
||||
public void setTransMethod(String transMethod) {
|
||||
this.transMethod = transMethod;
|
||||
}
|
||||
|
||||
public Map getAuthParamsJson() {
|
||||
return authParamsJson;
|
||||
}
|
||||
|
||||
public void setAuthParamsJson(Map authParamsJson) {
|
||||
this.authParamsJson = authParamsJson;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,91 +0,0 @@
|
|||
package com.engine.salary.elog.entity.dto;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @date: 2021/5/25 17:23
|
||||
* @author: deli.xu
|
||||
* @description:
|
||||
*/
|
||||
public class FilterConditionDto implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -3399942468474767859L;
|
||||
|
||||
/**
|
||||
* 列名
|
||||
*/
|
||||
private String columIndex;
|
||||
/**
|
||||
* 值
|
||||
*/
|
||||
private String value;
|
||||
|
||||
/**
|
||||
* 过滤类型
|
||||
*/
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* 模糊搜索
|
||||
*/
|
||||
private Like like;
|
||||
|
||||
/**
|
||||
* 关联条件
|
||||
*/
|
||||
private String connectCondition;
|
||||
|
||||
/**
|
||||
* sql条件
|
||||
*/
|
||||
private String sql;
|
||||
|
||||
|
||||
public String getColumIndex() {
|
||||
return columIndex;
|
||||
}
|
||||
|
||||
public void setColumIndex(String columIndex) {
|
||||
this.columIndex = columIndex;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public Like getLike() {
|
||||
return like;
|
||||
}
|
||||
|
||||
public void setLike(Like like) {
|
||||
this.like = like;
|
||||
}
|
||||
|
||||
public String getConnectCondition() {
|
||||
return connectCondition;
|
||||
}
|
||||
|
||||
public void setConnectCondition(String connectCondition) {
|
||||
this.connectCondition = connectCondition;
|
||||
}
|
||||
|
||||
public String getSql() {
|
||||
return sql;
|
||||
}
|
||||
|
||||
public void setSql(String sql) {
|
||||
this.sql = sql;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,31 +0,0 @@
|
|||
package com.engine.salary.elog.entity.dto;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @date: 2021/6/1 17:50
|
||||
* @author: deli.xu
|
||||
* @description:
|
||||
*/
|
||||
public class Like implements Serializable {
|
||||
private static final long serialVersionUID = -3399942468474767851L;
|
||||
private String prefix;
|
||||
private String suffix;
|
||||
|
||||
|
||||
public String getPrefix() {
|
||||
return prefix;
|
||||
}
|
||||
|
||||
public void setPrefix(String prefix) {
|
||||
this.prefix = prefix;
|
||||
}
|
||||
|
||||
public String getSuffix() {
|
||||
return suffix;
|
||||
}
|
||||
|
||||
public void setSuffix(String suffix) {
|
||||
this.suffix = suffix;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,890 +0,0 @@
|
|||
package com.engine.salary.elog.entity.dto;
|
||||
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import com.engine.salary.elog.annotation.ElogField;
|
||||
import com.engine.salary.elog.annotation.ElogTable;
|
||||
import com.engine.salary.elog.enums.ElogConsts;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import weaver.hrm.User;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @ClassName: LoggerContext
|
||||
* @Description 日志实体类。支持通过泛型扩展日志字段
|
||||
* @Author tanghj
|
||||
* @Date 2021/2/10 14:18
|
||||
*/
|
||||
@ElogTable(module = ElogConsts.BASE_TABLE)
|
||||
@ApiModel("日志实体类")
|
||||
public class LoggerContext<T> implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 15869325700230992L;
|
||||
|
||||
private User user;
|
||||
|
||||
@ElogField(comment = "ID", dataType = DataTypeEnum.BIGINT, isKey = true)
|
||||
@ApiModelProperty("日志ID")
|
||||
private long id;
|
||||
|
||||
@ElogField(dataType = DataTypeEnum.VARCHAR, length = 36, comment = "日志UUID")
|
||||
@ApiModelProperty("日志UUID")
|
||||
private String uuid = "";
|
||||
|
||||
@ApiModelProperty("自定义日志字段信息")
|
||||
private T customInfo;
|
||||
@ElogField(dataType = DataTypeEnum.DATETIME, comment = "操作时间")
|
||||
@ApiModelProperty("操作时间")
|
||||
@JSONField(format = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date date = new Date();
|
||||
|
||||
@ElogField(dataType = DataTypeEnum.VARCHAR, length = 500, comment = "终端信息")
|
||||
@ApiModelProperty("终端信息")
|
||||
private String device = "";
|
||||
|
||||
@ElogField(dataType = DataTypeEnum.BIGINT, defaultValue = "-1", comment = "操作人")
|
||||
@ApiModelProperty("操作人")
|
||||
private String operator = "";
|
||||
|
||||
@ElogField(dataType = DataTypeEnum.VARCHAR, length = 100, comment = "操作人姓名")
|
||||
@ApiModelProperty("操作人姓名")
|
||||
private String operatorName = "";
|
||||
|
||||
@ElogField(dataType = DataTypeEnum.VARCHAR, length = 10, comment = "租户id")
|
||||
@ApiModelProperty("租户id")
|
||||
private String tenant_key = "";
|
||||
|
||||
/**
|
||||
* 要操作的对象在表中的主键值
|
||||
*/
|
||||
@ElogField(dataType = DataTypeEnum.BIGINT, defaultValue = "-1", comment = "操作目标id")
|
||||
@ApiModelProperty("操作目标id")
|
||||
private String targetId = "";
|
||||
|
||||
@ElogField(dataType = DataTypeEnum.TEXT, comment = "操作目标名称")
|
||||
@ApiModelProperty("操作目标名称(用于显示)")
|
||||
private String targetName = "";
|
||||
|
||||
@ElogField(dataType = DataTypeEnum.VARCHAR, length = 100, comment = "模块")
|
||||
@ApiModelProperty("目标对象类型(大分类,模块,服务)")
|
||||
private String moduleName;// 模块
|
||||
|
||||
/**
|
||||
* 目标对象类型(小分类,模块/服务下的子功能。子项目)
|
||||
* 数据存储是以模块名_子项目名作为最基本的存储单元
|
||||
* 如果是子项目下的子项目 命名为:子项目名_子项目名_子项目名(全部小写)
|
||||
*/
|
||||
@ElogField(dataType = DataTypeEnum.VARCHAR, length = 100, comment = "服务(方法)")
|
||||
@ApiModelProperty("目标对象类型(小分类,模块/服务下的子功能。子项目)")
|
||||
private String functionName;
|
||||
|
||||
@ElogField(dataType = DataTypeEnum.VARCHAR, length = 100, comment = "访问接口名")
|
||||
@ApiModelProperty("访问接口名")
|
||||
private String interfaceName = "";
|
||||
|
||||
@ElogField(dataType = DataTypeEnum.VARCHAR, length = 200, comment = "请求全路径")
|
||||
@ApiModelProperty("请求全路径")
|
||||
private String requestUrl = "";
|
||||
|
||||
@ElogField(dataType = DataTypeEnum.VARCHAR, length = 200, comment = "请求地址")
|
||||
@ApiModelProperty("请求地址")
|
||||
private String requestUri = "";
|
||||
|
||||
@ElogField(dataType = DataTypeEnum.VARCHAR, length = 50, comment = "操作类型")
|
||||
@ApiModelProperty("操作类型(增删改查等)")
|
||||
private String operateType = "";
|
||||
|
||||
@ElogField(dataType = DataTypeEnum.VARCHAR, length = 100, comment = "操作类型名称")
|
||||
@ApiModelProperty("操作类型名称")
|
||||
private String operateTypeName = "";
|
||||
|
||||
/**
|
||||
* 每个TableChangeBean 为一张表,支持记录多张表的前后值
|
||||
*/
|
||||
@ApiModelProperty("修改前、后的值")
|
||||
private List<TableChangeBean> changeValues;// 操作表名,[字段名,值]
|
||||
|
||||
@ElogField(dataType = DataTypeEnum.VARCHAR, length = 3000, comment = "操作详细说明")
|
||||
@ApiModelProperty("操作详细说明")
|
||||
private String operatedesc = "";
|
||||
|
||||
@ElogField(dataType = DataTypeEnum.LONGTEXT, comment = "涉及的相关参数")
|
||||
@ApiModelProperty("涉及的相关参数")
|
||||
private Map<String, Object> params;
|
||||
|
||||
@ApiModelProperty("涉及的相关参数-转string存储")
|
||||
private String paramsStr;
|
||||
|
||||
/**
|
||||
* 当作为主表,belongMainId不赋值
|
||||
*/
|
||||
@ElogField(dataType = DataTypeEnum.VARCHAR, length = 36, comment = "所属主表uuid")
|
||||
@ApiModelProperty("所属主表uuid")
|
||||
private String belongMainId = "";
|
||||
|
||||
@ElogField(dataType = DataTypeEnum.VARCHAR, length = 50, comment = "操作IP")
|
||||
@ApiModelProperty("操作IP")
|
||||
private String clientIp = "";
|
||||
|
||||
@ElogField(dataType = DataTypeEnum.VARCHAR, length = 50, comment = "分组")
|
||||
@ApiModelProperty("分组")
|
||||
private String groupId = "";
|
||||
|
||||
/*@ApiModelProperty("是否明显表")
|
||||
private boolean isDetail;*/
|
||||
|
||||
@ElogField(dataType = DataTypeEnum.VARCHAR, length = 1000, comment = "分组标题")
|
||||
@ApiModelProperty("分组标题")
|
||||
private String groupNameLabel = "";
|
||||
|
||||
@ElogField(dataType = DataTypeEnum.VARCHAR, length = 200, comment = "重做业务接口")
|
||||
@ApiModelProperty("重做业务接口")
|
||||
private String redoService = "";
|
||||
|
||||
@ElogField(dataType = DataTypeEnum.LONGTEXT, comment = "重做参数")
|
||||
@ApiModelProperty("重做参数")
|
||||
private RedoContext redoContext;
|
||||
|
||||
@ApiModelProperty("重做参数-转String存储")
|
||||
private String redoContextStr;
|
||||
|
||||
@ElogField(dataType = DataTypeEnum.VARCHAR, length = 200, comment = "撤销业务接口")
|
||||
@ApiModelProperty("撤销业务接口")
|
||||
private String cancelService = "";
|
||||
|
||||
@ElogField(dataType = DataTypeEnum.LONGTEXT, comment = "撤销参数")
|
||||
@ApiModelProperty("撤销参数")
|
||||
private CancelContext cancelContext;
|
||||
|
||||
@ApiModelProperty("撤销参数-转String存储")
|
||||
private String cancelContextStr;
|
||||
|
||||
@ApiModelProperty("日志明细列表(值变化列表-自动赋值、或者自定义字段)")
|
||||
private List<LoggerDetailContext> detailContexts;
|
||||
|
||||
@ElogField(dataType = DataTypeEnum.DATETIME, defaultValue = "CURRENT_TIMESTAMP", comment = "创建时间")
|
||||
@ApiModelProperty("创建时间")
|
||||
@JSONField(format = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date create_time;
|
||||
|
||||
@ElogField(dataType = DataTypeEnum.DATETIME, defaultValue = "CURRENT_TIMESTAMP", comment = "修改时间")
|
||||
@ApiModelProperty("修改时间")
|
||||
@JSONField(format = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date update_time;
|
||||
|
||||
@ElogField(dataType = DataTypeEnum.BIGINT, defaultValue = "-1", comment = "创建人id")
|
||||
@ApiModelProperty("创建人id")
|
||||
private long creator;
|
||||
|
||||
@ElogField(dataType = DataTypeEnum.INT, defaultValue = "0", comment = "是否删除")
|
||||
@ApiModelProperty("是否删除")
|
||||
private int delete_type;
|
||||
|
||||
@ElogField(dataType = DataTypeEnum.BIGINT, defaultValue = "0", comment = "总运行时长")
|
||||
@ApiModelProperty("总运行时长")
|
||||
private long totalRunTime;
|
||||
|
||||
@ElogField(dataType = DataTypeEnum.BIGINT, defaultValue = "0", comment = "主方法运行时长")
|
||||
@ApiModelProperty("主方法运行时长")
|
||||
private long mainRunTime;
|
||||
|
||||
@ElogField(dataType = DataTypeEnum.VARCHAR, length = 100, defaultValue = "", comment = "运行结果标识")
|
||||
@ApiModelProperty("运行结果标识")
|
||||
private String result = "";
|
||||
|
||||
@ElogField(dataType = DataTypeEnum.VARCHAR, length = 100, defaultValue = "", comment = "来自pc web")
|
||||
@ApiModelProperty("来自终端")
|
||||
private String fromTerminal = "";
|
||||
|
||||
@ElogField(dataType = DataTypeEnum.TEXT, comment = "运行结果描述")
|
||||
@ApiModelProperty("运行结果描述")
|
||||
private String resultDesc = "";
|
||||
|
||||
@ElogField(dataType = DataTypeEnum.VARCHAR, length = 3000, comment = "原先内容")
|
||||
@ApiModelProperty("原先内容(et用)")
|
||||
private String old_content = "";
|
||||
|
||||
@ElogField(dataType = DataTypeEnum.VARCHAR, length = 20, comment = "链接类型")
|
||||
@ApiModelProperty("链接类型(et用)")
|
||||
private String link_type = "";
|
||||
|
||||
@ElogField(dataType = DataTypeEnum.BIGINT, defaultValue = "0", comment = "链接id")
|
||||
@ApiModelProperty("链接id(et用)")
|
||||
private long link_id;
|
||||
|
||||
@ElogField(dataType = DataTypeEnum.BIGINT, defaultValue = "0", comment = "原先链接id")
|
||||
@ApiModelProperty("原先链接id(et用)")
|
||||
private long old_link_id;
|
||||
|
||||
/**
|
||||
* 开发可以自由传中间临时参数,不会入库
|
||||
*/
|
||||
@ApiModelProperty("临时参数")
|
||||
private Object tempParams;
|
||||
|
||||
/**
|
||||
* 是否忽略该日志,不进行数据记录
|
||||
*/
|
||||
@ApiModelProperty("是否忽略该日志,不进行数据记录")
|
||||
private boolean logIgnore;
|
||||
|
||||
/**
|
||||
* 审计操作类型
|
||||
*/
|
||||
@ApiModelProperty("审计操作类型")
|
||||
protected String operateAuditType;
|
||||
|
||||
/**
|
||||
* 操作人账号
|
||||
*/
|
||||
@ApiModelProperty("操作人账号")
|
||||
protected String operateAccount;
|
||||
|
||||
@ApiModelProperty("操作人id(兼容数据库用)")
|
||||
protected long logOperator;
|
||||
|
||||
@ApiModelProperty("操作人id(兼容数据库用)")
|
||||
protected long logTargetid;
|
||||
|
||||
@ApiModelProperty("ES存储大字段功能标识")
|
||||
protected Boolean esFunction;
|
||||
|
||||
@ApiModelProperty("params参数是否忽略记录")
|
||||
private Boolean paramsIgnore = Boolean.FALSE;
|
||||
|
||||
@ApiModelProperty("params请求体keys")
|
||||
private List<String> paramsBodyKeys;
|
||||
|
||||
@ApiModelProperty("日志弱控记录")
|
||||
private Boolean weakElogReocrd = Boolean.FALSE;
|
||||
|
||||
private List<String> clobFieldList;
|
||||
|
||||
public User getUser() {
|
||||
return user;
|
||||
}
|
||||
|
||||
public void setUser(User user) {
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
public List<String> getClobFieldList() {
|
||||
return clobFieldList;
|
||||
}
|
||||
|
||||
public void setClobFieldList(List<String> clobFieldList) {
|
||||
this.clobFieldList = clobFieldList;
|
||||
}
|
||||
|
||||
public Boolean getWeakElogReocrd() {
|
||||
return weakElogReocrd;
|
||||
}
|
||||
|
||||
public void setWeakElogReocrd(Boolean weakElogReocrd) {
|
||||
this.weakElogReocrd = weakElogReocrd;
|
||||
}
|
||||
|
||||
public Boolean getParamsIgnore() {
|
||||
return paramsIgnore;
|
||||
}
|
||||
|
||||
public void setParamsIgnore(Boolean paramsIgnore) {
|
||||
this.paramsIgnore = paramsIgnore;
|
||||
}
|
||||
|
||||
public List<String> getParamsBodyKeys() {
|
||||
return paramsBodyKeys;
|
||||
}
|
||||
|
||||
public void setParamsBodyKeys(List<String> paramsBodyKeys) {
|
||||
this.paramsBodyKeys = paramsBodyKeys;
|
||||
}
|
||||
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getUuid() {
|
||||
return uuid;
|
||||
}
|
||||
|
||||
public void setUuid(String uuid) {
|
||||
this.uuid = uuid;
|
||||
}
|
||||
|
||||
public T getCustomInfo() {
|
||||
return customInfo;
|
||||
}
|
||||
|
||||
public void setCustomInfo(T customInfo) {
|
||||
this.customInfo = customInfo;
|
||||
}
|
||||
|
||||
public Date getDate() {
|
||||
return date;
|
||||
}
|
||||
|
||||
public void setDate(Date date) {
|
||||
this.date = date;
|
||||
}
|
||||
|
||||
public String getDevice() {
|
||||
return device;
|
||||
}
|
||||
|
||||
public void setDevice(String device) {
|
||||
this.device = device;
|
||||
}
|
||||
|
||||
public String getOperator() {
|
||||
return operator;
|
||||
}
|
||||
|
||||
public void setOperator(String operator) {
|
||||
this.operator = operator;
|
||||
}
|
||||
|
||||
public String getTenant_key() {
|
||||
return tenant_key;
|
||||
}
|
||||
|
||||
public void setTenant_key(String tenant_key) {
|
||||
this.tenant_key = tenant_key;
|
||||
}
|
||||
|
||||
public String getTargetId() {
|
||||
return targetId;
|
||||
}
|
||||
|
||||
public void setTargetId(String targetId) {
|
||||
this.targetId = targetId;
|
||||
}
|
||||
|
||||
public String getTargetName() {
|
||||
return targetName;
|
||||
}
|
||||
|
||||
public void setTargetName(String targetName) {
|
||||
this.targetName = targetName;
|
||||
}
|
||||
|
||||
public String getModuleName() {
|
||||
return moduleName;
|
||||
}
|
||||
|
||||
public void setModuleName(String moduleName) {
|
||||
this.moduleName = moduleName;
|
||||
}
|
||||
|
||||
public String getFunctionName() {
|
||||
return functionName;
|
||||
}
|
||||
|
||||
public void setFunctionName(String functionName) {
|
||||
this.functionName = functionName;
|
||||
}
|
||||
|
||||
public String getInterfaceName() {
|
||||
return interfaceName;
|
||||
}
|
||||
|
||||
public void setInterfaceName(String interfaceName) {
|
||||
this.interfaceName = interfaceName;
|
||||
}
|
||||
|
||||
public String getOperateType() {
|
||||
return operateType;
|
||||
}
|
||||
|
||||
public void setOperateType(String operateType) {
|
||||
this.operateType = operateType;
|
||||
}
|
||||
|
||||
public List<TableChangeBean> getChangeValues() {
|
||||
return changeValues;
|
||||
}
|
||||
|
||||
public void setChangeValues(List<TableChangeBean> changeValues) {
|
||||
this.changeValues = changeValues;
|
||||
}
|
||||
|
||||
public String getOperatedesc() {
|
||||
return operatedesc;
|
||||
}
|
||||
|
||||
public void setOperatedesc(String operatedesc) {
|
||||
this.operatedesc = operatedesc;
|
||||
}
|
||||
|
||||
public Map<String, Object> getParams() {
|
||||
return params;
|
||||
}
|
||||
|
||||
public void setParams(Map<String, Object> params) {
|
||||
this.params = params;
|
||||
}
|
||||
|
||||
/*public String getMainId() {
|
||||
return mainId;
|
||||
}
|
||||
|
||||
public void setMainId(String mainId) {
|
||||
this.mainId = mainId;
|
||||
}
|
||||
|
||||
public String getBelongMainId() {
|
||||
return belongMainId;
|
||||
}
|
||||
|
||||
public void setBelongMainId(String belongMainId) {
|
||||
this.belongMainId = belongMainId;
|
||||
}*/
|
||||
|
||||
public String getClientIp() {
|
||||
return clientIp;
|
||||
}
|
||||
|
||||
public void setClientIp(String clientIp) {
|
||||
this.clientIp = clientIp;
|
||||
}
|
||||
|
||||
public String getGroupId() {
|
||||
return groupId;
|
||||
}
|
||||
|
||||
public void setGroupId(String groupId) {
|
||||
this.groupId = groupId;
|
||||
}
|
||||
|
||||
/* public boolean isDetail() {
|
||||
return isDetail;
|
||||
}
|
||||
|
||||
public void setDetail(boolean detail) {
|
||||
isDetail = detail;
|
||||
}*/
|
||||
|
||||
public String getGroupNameLabel() {
|
||||
return groupNameLabel;
|
||||
}
|
||||
|
||||
public void setGroupNameLabel(String groupNameLabel) {
|
||||
this.groupNameLabel = groupNameLabel;
|
||||
}
|
||||
|
||||
public String getRedoService() {
|
||||
return redoService;
|
||||
}
|
||||
|
||||
public void setRedoService(String redoService) {
|
||||
this.redoService = redoService;
|
||||
}
|
||||
|
||||
public RedoContext getRedoContext() {
|
||||
return redoContext;
|
||||
}
|
||||
|
||||
public void setRedoContext(RedoContext redoContext) {
|
||||
this.redoContext = redoContext;
|
||||
}
|
||||
|
||||
public CancelContext getCancelContext() {
|
||||
return cancelContext;
|
||||
}
|
||||
|
||||
public void setCancelContext(CancelContext cancelContext) {
|
||||
this.cancelContext = cancelContext;
|
||||
}
|
||||
|
||||
public String getCancelService() {
|
||||
return cancelService;
|
||||
}
|
||||
|
||||
public void setCancelService(String cancelService) {
|
||||
this.cancelService = cancelService;
|
||||
}
|
||||
|
||||
public List<LoggerDetailContext> getDetailContexts() {
|
||||
return detailContexts;
|
||||
}
|
||||
|
||||
public void setDetailContexts(List<LoggerDetailContext> detailContexts) {
|
||||
this.detailContexts = detailContexts;
|
||||
}
|
||||
|
||||
public void addDetailContext(LoggerDetailContext loggerDetailContext) {
|
||||
if (this.detailContexts != null) {
|
||||
this.detailContexts.add(loggerDetailContext);
|
||||
} else {
|
||||
this.detailContexts = new ArrayList<>();
|
||||
this.detailContexts.add(loggerDetailContext);
|
||||
}
|
||||
}
|
||||
|
||||
public void addDetailContext(List<LoggerDetailContext> list) {
|
||||
if (this.detailContexts != null) {
|
||||
this.detailContexts.addAll(list);
|
||||
} else {
|
||||
this.detailContexts = new ArrayList<>();
|
||||
this.detailContexts.addAll(list);
|
||||
}
|
||||
}
|
||||
|
||||
public String getOperatorName() {
|
||||
return operatorName;
|
||||
}
|
||||
|
||||
public void setOperatorName(String operatorName) {
|
||||
this.operatorName = operatorName;
|
||||
}
|
||||
|
||||
public void setOldValues(Object object) {
|
||||
TableChangeBean bean = new TableChangeBean();
|
||||
bean.setOldValue(object);
|
||||
getChangeList().add(bean);
|
||||
}
|
||||
|
||||
public void setOldValueList(List<Object> list) {
|
||||
if (list != null)
|
||||
list.stream().forEach(obj -> setOldValues(obj));
|
||||
}
|
||||
|
||||
public void setNewValueList(List<Object> list) {
|
||||
if (list != null)
|
||||
list.stream().forEach(obj -> setNewValues(obj));
|
||||
}
|
||||
|
||||
public void setNewValues(Object object) {
|
||||
List<TableChangeBean> list = getChangeList();
|
||||
|
||||
boolean handled = false;
|
||||
for (TableChangeBean bean : list) {
|
||||
if (bean.getNewValue() == null) {
|
||||
bean.setNewValue(object);
|
||||
handled = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!handled) {
|
||||
TableChangeBean bean = new TableChangeBean();
|
||||
bean.setNewValue(object);
|
||||
list.add(bean);
|
||||
}
|
||||
}
|
||||
|
||||
public void setOldValues(Object object, String tableName, String dataId, String belongDataid) {
|
||||
setOldValues(object, tableName, dataId, belongDataid, false);
|
||||
}
|
||||
|
||||
public void setOldValues(Object object, String tableName, String dataId, String belongDataid, boolean isDetail) {
|
||||
TableChangeBean bean = new TableChangeBean();
|
||||
if (StringUtils.isNotEmpty(tableName))
|
||||
bean.setTableName(tableName);
|
||||
if (StringUtils.isNotEmpty(dataId))
|
||||
bean.setDataid(dataId);
|
||||
if (StringUtils.isNotEmpty(belongDataid))
|
||||
bean.setBelongDataid(belongDataid);
|
||||
if (isDetail)
|
||||
bean.setIsDetail(1);
|
||||
bean.setOldValue(object);
|
||||
getChangeList().add(bean);
|
||||
}
|
||||
|
||||
public void setOldValueList(List<Object> list, String tableName, String dataId, String belongDataid) {
|
||||
setOldValueList(list, tableName, dataId, belongDataid, false);
|
||||
}
|
||||
|
||||
public void setNewValueList(List<Object> list, String tableName, String dataId, String belongDataid) {
|
||||
setNewValueList(list, tableName, dataId, belongDataid, false);
|
||||
}
|
||||
|
||||
public void setOldValueList(List<Object> list, String tableName, String dataId, String belongDataid, boolean isDetail) {
|
||||
if (list != null)
|
||||
list.stream().forEach(obj -> setOldValues(obj, tableName, dataId, belongDataid, isDetail));
|
||||
}
|
||||
|
||||
public void setNewValueList(List<Object> list, String tableName, String dataId, String belongDataid, boolean isDetail) {
|
||||
if (list != null)
|
||||
list.stream().forEach(obj -> setNewValues(obj, tableName, dataId, belongDataid, isDetail));
|
||||
}
|
||||
|
||||
public void setNewValues(Object object, String tableName, String dataId, String belongDataid) {
|
||||
setNewValues(object, tableName, dataId, belongDataid, false);
|
||||
}
|
||||
|
||||
public void setNewValues(Object object, String tableName, String dataId, String belongDataid, boolean isDetail) {
|
||||
List<TableChangeBean> list = getChangeList();
|
||||
|
||||
boolean handled = false;
|
||||
for (TableChangeBean bean : list) {
|
||||
if (bean.getNewValue() == null) {
|
||||
bean.setNewValue(object);
|
||||
if (StringUtils.isNotEmpty(tableName))
|
||||
bean.setTableName(tableName);
|
||||
if (StringUtils.isNotEmpty(dataId))
|
||||
bean.setDataid(dataId);
|
||||
if (StringUtils.isNotEmpty(belongDataid))
|
||||
bean.setBelongDataid(belongDataid);
|
||||
if (isDetail)
|
||||
bean.setIsDetail(1);
|
||||
handled = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!handled) {
|
||||
TableChangeBean bean = new TableChangeBean();
|
||||
if (StringUtils.isNotEmpty(tableName))
|
||||
bean.setTableName(tableName);
|
||||
if (StringUtils.isNotEmpty(dataId))
|
||||
bean.setDataid(dataId);
|
||||
if (StringUtils.isNotEmpty(belongDataid))
|
||||
bean.setBelongDataid(belongDataid);
|
||||
if (isDetail)
|
||||
bean.setIsDetail(1);
|
||||
bean.setNewValue(object);
|
||||
list.add(bean);
|
||||
}
|
||||
}
|
||||
|
||||
public List<TableChangeBean> getChangeList() {
|
||||
|
||||
if (this.changeValues == null) {
|
||||
this.changeValues = new ArrayList<>();
|
||||
}
|
||||
|
||||
return this.changeValues;
|
||||
|
||||
}
|
||||
|
||||
public Object getParam(String id) {
|
||||
return this.params.get(id);
|
||||
}
|
||||
|
||||
public String getOperateTypeName() {
|
||||
return operateTypeName;
|
||||
}
|
||||
|
||||
public void setOperateTypeName(String operateTypeName) {
|
||||
this.operateTypeName = operateTypeName;
|
||||
}
|
||||
|
||||
public String getParamsStr() {
|
||||
return paramsStr;
|
||||
}
|
||||
|
||||
public void setParamsStr(String paramsStr) {
|
||||
this.paramsStr = paramsStr;
|
||||
}
|
||||
|
||||
public String getRedoContextStr() {
|
||||
return redoContextStr;
|
||||
}
|
||||
|
||||
public void setRedoContextStr(String redoContextStr) {
|
||||
this.redoContextStr = redoContextStr;
|
||||
}
|
||||
|
||||
public String getCancelContextStr() {
|
||||
return cancelContextStr;
|
||||
}
|
||||
|
||||
public void setCancelContextStr(String cancelContextStr) {
|
||||
this.cancelContextStr = cancelContextStr;
|
||||
}
|
||||
|
||||
public String getBelongMainId() {
|
||||
return belongMainId;
|
||||
}
|
||||
|
||||
public void setBelongMainId(String belongMainId) {
|
||||
this.belongMainId = belongMainId;
|
||||
}
|
||||
|
||||
public String getRequestUrl() {
|
||||
return requestUrl;
|
||||
}
|
||||
|
||||
public void setRequestUrl(String requestUrl) {
|
||||
this.requestUrl = requestUrl;
|
||||
}
|
||||
|
||||
public String getRequestUri() {
|
||||
return requestUri;
|
||||
}
|
||||
|
||||
public void setRequestUri(String requestUri) {
|
||||
this.requestUri = requestUri;
|
||||
}
|
||||
|
||||
public Date getCreate_time() {
|
||||
return create_time;
|
||||
}
|
||||
|
||||
public void setCreate_time(Date create_time) {
|
||||
this.create_time = create_time;
|
||||
}
|
||||
|
||||
public Date getUpdate_time() {
|
||||
return update_time;
|
||||
}
|
||||
|
||||
public void setUpdate_time(Date update_time) {
|
||||
this.update_time = update_time;
|
||||
}
|
||||
|
||||
public long getCreator() {
|
||||
return creator;
|
||||
}
|
||||
|
||||
public void setCreator(long creator) {
|
||||
this.creator = creator;
|
||||
}
|
||||
|
||||
public int getDelete_type() {
|
||||
return delete_type;
|
||||
}
|
||||
|
||||
public void setDelete_type(int delete_type) {
|
||||
this.delete_type = delete_type;
|
||||
}
|
||||
|
||||
public long getTotalRunTime() {
|
||||
return totalRunTime;
|
||||
}
|
||||
|
||||
public void setTotalRunTime(long totalRunTime) {
|
||||
this.totalRunTime = totalRunTime;
|
||||
}
|
||||
|
||||
public long getMainRunTime() {
|
||||
return mainRunTime;
|
||||
}
|
||||
|
||||
public void setMainRunTime(long mainRunTime) {
|
||||
this.mainRunTime = mainRunTime;
|
||||
}
|
||||
|
||||
public Object getTempParams() {
|
||||
return tempParams;
|
||||
}
|
||||
|
||||
public void setTempParams(Object tempParams) {
|
||||
this.tempParams = tempParams;
|
||||
}
|
||||
|
||||
public String getResult() {
|
||||
return result;
|
||||
}
|
||||
|
||||
public void setResult(String result) {
|
||||
this.result = result;
|
||||
}
|
||||
|
||||
public String getFromTerminal() {
|
||||
return fromTerminal;
|
||||
}
|
||||
|
||||
public void setFromTerminal(String fromTerminal) {
|
||||
this.fromTerminal = fromTerminal;
|
||||
}
|
||||
|
||||
public String getResultDesc() {
|
||||
return resultDesc;
|
||||
}
|
||||
|
||||
public void setResultDesc(String resultDesc) {
|
||||
this.resultDesc = resultDesc;
|
||||
}
|
||||
|
||||
public String getOld_content() {
|
||||
return old_content;
|
||||
}
|
||||
|
||||
public void setOld_content(String old_content) {
|
||||
this.old_content = old_content;
|
||||
}
|
||||
|
||||
public String getLink_type() {
|
||||
return link_type;
|
||||
}
|
||||
|
||||
public void setLink_type(String link_type) {
|
||||
this.link_type = link_type;
|
||||
}
|
||||
|
||||
public long getLink_id() {
|
||||
return link_id;
|
||||
}
|
||||
|
||||
public void setLink_id(long link_id) {
|
||||
this.link_id = link_id;
|
||||
}
|
||||
|
||||
public long getOld_link_id() {
|
||||
return old_link_id;
|
||||
}
|
||||
|
||||
public void setOld_link_id(long old_link_id) {
|
||||
this.old_link_id = old_link_id;
|
||||
}
|
||||
|
||||
public String getOperateAuditType() {
|
||||
return operateAuditType;
|
||||
}
|
||||
|
||||
public void setOperateAuditType(String operateAuditType) {
|
||||
this.operateAuditType = operateAuditType;
|
||||
}
|
||||
|
||||
public String getOperateAccount() {
|
||||
return operateAccount;
|
||||
}
|
||||
|
||||
public void setOperateAccount(String operateAccount) {
|
||||
this.operateAccount = operateAccount;
|
||||
}
|
||||
|
||||
public long getLogOperator() {
|
||||
return logOperator;
|
||||
}
|
||||
|
||||
public void setLogOperator(long logOperator) {
|
||||
this.logOperator = logOperator;
|
||||
}
|
||||
|
||||
public long getLogTargetid() {
|
||||
return logTargetid;
|
||||
}
|
||||
|
||||
public void setLogTargetid(long logTargetid) {
|
||||
this.logTargetid = logTargetid;
|
||||
}
|
||||
|
||||
public boolean getLogIgnore() {
|
||||
return logIgnore;
|
||||
}
|
||||
|
||||
public void setLogIgnore(boolean logIgnore) {
|
||||
this.logIgnore = logIgnore;
|
||||
}
|
||||
|
||||
public Boolean getEsFunction() {
|
||||
return esFunction;
|
||||
}
|
||||
|
||||
public void setEsFunction(Boolean esFunction) {
|
||||
this.esFunction = esFunction;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -1,316 +0,0 @@
|
|||
package com.engine.salary.elog.entity.dto;
|
||||
|
||||
import com.engine.salary.elog.annotation.ElogDetailTable;
|
||||
import com.engine.salary.elog.annotation.ElogField;
|
||||
import com.engine.salary.elog.enums.ElogConsts;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @ClassName: ValueChangeBean
|
||||
* @Description 值变化实体类(自动将表字段值变更类转换为该类)
|
||||
* @Author tanghj
|
||||
* @Date 2021/3/9 11:06
|
||||
*/
|
||||
@ElogDetailTable(module = ElogConsts.BASE_TABLE)
|
||||
@ApiModel("值变化实体类")
|
||||
public class LoggerDetailContext<T> implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 15869325700230992L;
|
||||
|
||||
@ElogField(comment = "ID", dataType = DataTypeEnum.BIGINT, isKey = true)
|
||||
@ApiModelProperty("ID")
|
||||
private long id;
|
||||
|
||||
@ElogField(dataType = DataTypeEnum.VARCHAR, length = 36,comment = "日志UUID")
|
||||
@ApiModelProperty("同一个bean转换的数据,uuid相同,作为区分标识")
|
||||
private String uuid = "";
|
||||
|
||||
@ElogField(dataType = DataTypeEnum.VARCHAR, length = 36,comment = "主表id")
|
||||
@ApiModelProperty("主表id")
|
||||
private String mainid = "";
|
||||
|
||||
@ElogField(dataType = DataTypeEnum.VARCHAR, length = 50,comment = "数据id")
|
||||
@ApiModelProperty("数据id")
|
||||
private String dataid = "";
|
||||
|
||||
/**
|
||||
* 当作为主表,belongDataId不赋值
|
||||
*/
|
||||
@ElogField(dataType = DataTypeEnum.VARCHAR, length = 50,comment = "主表数据id")
|
||||
@ApiModelProperty("主表数据id")
|
||||
private String belongDataid = "";
|
||||
|
||||
@ElogField(dataType = DataTypeEnum.VARCHAR, length = 200,comment = "表名")
|
||||
@ApiModelProperty("表名")
|
||||
private String tableName ="";
|
||||
|
||||
@ElogField(dataType = DataTypeEnum.VARCHAR, defaultValue = "-1", length = 50,comment = "表名labelid")
|
||||
@ApiModelProperty("表名labelid")
|
||||
private String tableNameLabelId = "-1";
|
||||
@ElogField(dataType = DataTypeEnum.VARCHAR, defaultValue="",isNull = false,length = 50,comment = "对应数据库的表")
|
||||
@ApiModelProperty("对应数据库的表")
|
||||
private String tableNameDesc = "";
|
||||
|
||||
@ElogField(dataType = DataTypeEnum.VARCHAR, length = 200,comment = "字段名")
|
||||
@ApiModelProperty("字段名")
|
||||
private String fieldName ="";
|
||||
|
||||
@ElogField(dataType = DataTypeEnum.VARCHAR, defaultValue = "-1", length = 50,comment = "字段名labelid")
|
||||
@ApiModelProperty("字段名labelid")
|
||||
private String fieldNameLabelId = "-1";
|
||||
|
||||
@ElogField(dataType = DataTypeEnum.LONGTEXT,comment = "更新后的值")
|
||||
@ApiModelProperty("更新后的值")
|
||||
private String newValue = "";
|
||||
|
||||
@ElogField(dataType = DataTypeEnum.LONGTEXT,comment = "更新前的值")
|
||||
@ApiModelProperty("更新前的值")
|
||||
private String oldValue = "";
|
||||
|
||||
@ElogField(dataType = DataTypeEnum.LONGTEXT,comment = "更新后的显示值")
|
||||
@ApiModelProperty("更新后的显示值")
|
||||
private String newRealValue = "";
|
||||
|
||||
@ElogField(dataType = DataTypeEnum.LONGTEXT,comment = "更新前的显示值")
|
||||
@ApiModelProperty("更新前的显示值")
|
||||
private String oldRealValue = "";
|
||||
|
||||
@ElogField(dataType = DataTypeEnum.VARCHAR, length = 200, comment = "字段名")
|
||||
@ApiModelProperty("字段描述")
|
||||
private String fieldDesc = "";
|
||||
|
||||
@ElogField(dataType = DataTypeEnum.INT, comment = "字段名")
|
||||
@ApiModelProperty("字段展示顺序")
|
||||
private int showorder = 0;
|
||||
|
||||
@ApiModelProperty("自定义字段")
|
||||
private T customDetailInfo;
|
||||
|
||||
@ElogField(dataType = DataTypeEnum.DATETIME, defaultValue = "CURRENT_TIMESTAMP", comment = "创建时间")
|
||||
@ApiModelProperty("创建时间")
|
||||
private Date create_time;
|
||||
|
||||
@ElogField(dataType = DataTypeEnum.DATETIME, defaultValue = "CURRENT_TIMESTAMP", comment = "修改时间")
|
||||
@ApiModelProperty("修改时间")
|
||||
private Date update_time;
|
||||
|
||||
@ElogField(dataType = DataTypeEnum.BIGINT, defaultValue = "-1", comment = "创建人id")
|
||||
@ApiModelProperty("创建人id")
|
||||
private long creator;
|
||||
|
||||
@ElogField(dataType = DataTypeEnum.INT, defaultValue = "0" , comment = "是否删除")
|
||||
@ApiModelProperty("是否删除")
|
||||
private int delete_type;
|
||||
|
||||
@ElogField(dataType = DataTypeEnum.VARCHAR,length = 10,comment = "租户id")
|
||||
@ApiModelProperty("租户id")
|
||||
private String tenant_key = "";
|
||||
|
||||
@ElogField(dataType = DataTypeEnum.INT, defaultValue = "0" , comment = "是否明细字段")
|
||||
@ApiModelProperty("是否明细字段")
|
||||
private int isDetail = 0;
|
||||
|
||||
|
||||
private String cusValus;
|
||||
|
||||
public String getCusValus() {
|
||||
return cusValus;
|
||||
}
|
||||
|
||||
public void setCusValus(String cusValus) {
|
||||
this.cusValus = cusValus;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getMainid() {
|
||||
return mainid;
|
||||
}
|
||||
|
||||
public void setMainid(String mainid) {
|
||||
this.mainid = mainid;
|
||||
}
|
||||
|
||||
public String getUuid() {
|
||||
return uuid;
|
||||
}
|
||||
|
||||
public void setUuid(String uuid) {
|
||||
this.uuid = uuid;
|
||||
}
|
||||
|
||||
public String getTableName() {
|
||||
return tableName;
|
||||
}
|
||||
|
||||
public void setTableName(String tableName) {
|
||||
this.tableName = tableName;
|
||||
}
|
||||
|
||||
public String getFieldName() {
|
||||
return fieldName;
|
||||
}
|
||||
|
||||
public void setFieldName(String fieldName) {
|
||||
this.fieldName = fieldName;
|
||||
}
|
||||
|
||||
public String getNewValue() {
|
||||
return newValue;
|
||||
}
|
||||
|
||||
public void setNewValue(String newValue) {
|
||||
this.newValue = newValue;
|
||||
}
|
||||
|
||||
public String getOldValue() {
|
||||
return oldValue;
|
||||
}
|
||||
|
||||
public void setOldValue(String oldValue) {
|
||||
this.oldValue = oldValue;
|
||||
}
|
||||
|
||||
public String getFieldDesc() {
|
||||
return fieldDesc;
|
||||
}
|
||||
|
||||
public void setFieldDesc(String fieldDesc) {
|
||||
this.fieldDesc = fieldDesc;
|
||||
}
|
||||
|
||||
public int getShoworder() {
|
||||
return showorder;
|
||||
}
|
||||
|
||||
public void setShoworder(int showorder) {
|
||||
this.showorder = showorder;
|
||||
}
|
||||
|
||||
public T getCustomDetailInfo() {
|
||||
return customDetailInfo;
|
||||
}
|
||||
|
||||
public void setCustomDetailInfo(T customDetailInfo) {
|
||||
this.customDetailInfo = customDetailInfo;
|
||||
}
|
||||
|
||||
public String getDataid() {
|
||||
return dataid;
|
||||
}
|
||||
|
||||
public void setDataid(String dataid) {
|
||||
this.dataid = dataid;
|
||||
}
|
||||
|
||||
public String getBelongDataid() {
|
||||
return belongDataid;
|
||||
}
|
||||
|
||||
public void setBelongDataid(String belongDataid) {
|
||||
this.belongDataid = belongDataid;
|
||||
}
|
||||
|
||||
public Date getCreate_time() {
|
||||
return create_time;
|
||||
}
|
||||
|
||||
public void setCreate_time(Date create_time) {
|
||||
this.create_time = create_time;
|
||||
}
|
||||
|
||||
public Date getUpdate_time() {
|
||||
return update_time;
|
||||
}
|
||||
|
||||
public void setUpdate_time(Date update_time) {
|
||||
this.update_time = update_time;
|
||||
}
|
||||
|
||||
public long getCreator() {
|
||||
return creator;
|
||||
}
|
||||
|
||||
public void setCreator(long creator) {
|
||||
this.creator = creator;
|
||||
}
|
||||
|
||||
public int getDelete_type() {
|
||||
return delete_type;
|
||||
}
|
||||
|
||||
public void setDelete_type(int delete_type) {
|
||||
this.delete_type = delete_type;
|
||||
}
|
||||
|
||||
public String getTenant_key() {
|
||||
return tenant_key;
|
||||
}
|
||||
|
||||
public void setTenant_key(String tenant_key) {
|
||||
this.tenant_key = tenant_key;
|
||||
}
|
||||
|
||||
public int getIsDetail() {
|
||||
return isDetail;
|
||||
}
|
||||
|
||||
public void setIsDetail(int isDetail) {
|
||||
this.isDetail = isDetail;
|
||||
}
|
||||
|
||||
public String getNewRealValue() {
|
||||
return newRealValue;
|
||||
}
|
||||
|
||||
public void setNewRealValue(String newRealValue) {
|
||||
this.newRealValue = newRealValue;
|
||||
}
|
||||
|
||||
public String getOldRealValue() {
|
||||
return oldRealValue;
|
||||
}
|
||||
|
||||
public void setOldRealValue(String oldRealValue) {
|
||||
this.oldRealValue = oldRealValue;
|
||||
}
|
||||
|
||||
public String getTableNameLabelId() {
|
||||
return tableNameLabelId;
|
||||
}
|
||||
|
||||
public void setTableNameLabelId(String tableNameLabelId) {
|
||||
this.tableNameLabelId = tableNameLabelId;
|
||||
}
|
||||
|
||||
public String getFieldNameLabelId() {
|
||||
return fieldNameLabelId;
|
||||
}
|
||||
|
||||
public void setFieldNameLabelId(String fieldNameLabelId) {
|
||||
this.fieldNameLabelId = fieldNameLabelId;
|
||||
}
|
||||
|
||||
public String getTableNameDesc() {
|
||||
return tableNameDesc;
|
||||
}
|
||||
|
||||
public void setTableNameDesc(String tableNameDesc) {
|
||||
this.tableNameDesc = tableNameDesc;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -1,40 +0,0 @@
|
|||
package com.engine.salary.elog.entity.dto;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @date: 2022/5/14 13:52
|
||||
* @author: deli.xu
|
||||
* @description:
|
||||
*/
|
||||
|
||||
public class ReadInfoEntity implements Serializable {
|
||||
private static final long serialVersionUID = -8890667941835568289L;
|
||||
private Long employeeId;
|
||||
private Date date;
|
||||
|
||||
public Long getEmployeeId() {
|
||||
return this.employeeId;
|
||||
}
|
||||
|
||||
public void setEmployeeId(Long employeeId) {
|
||||
this.employeeId = employeeId;
|
||||
}
|
||||
|
||||
public Date getDate() {
|
||||
return this.date;
|
||||
}
|
||||
|
||||
public void setDate(Date date) {
|
||||
this.date = date;
|
||||
}
|
||||
|
||||
public ReadInfoEntity() {
|
||||
}
|
||||
|
||||
public ReadInfoEntity(Long employeeId, Date date) {
|
||||
this.employeeId = employeeId;
|
||||
this.date = date;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,24 +0,0 @@
|
|||
package com.engine.salary.elog.entity.dto;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
/**
|
||||
* @ClassName: RedoContext
|
||||
* @Description 重做实体类
|
||||
* @Author tanghj
|
||||
* @Date 2021/2/10 14:18
|
||||
*/
|
||||
@ApiModel("重做实体类")
|
||||
public class RedoContext<T> {
|
||||
@ApiModelProperty("重做参数")
|
||||
private T redoParams;
|
||||
|
||||
public T getRedoParams() {
|
||||
return redoParams;
|
||||
}
|
||||
|
||||
public void setRedoParams(T redoParams) {
|
||||
this.redoParams = redoParams;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,105 +0,0 @@
|
|||
package com.engine.salary.elog.entity.dto;
|
||||
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @date: 2021/5/11 18:46
|
||||
* @author: deli.xu
|
||||
* @description: 显示列对象
|
||||
*/
|
||||
public class ShowColumsDto implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 4650449925605408753L;
|
||||
|
||||
/**
|
||||
* 列名
|
||||
*/
|
||||
private String columName;
|
||||
/**
|
||||
* 列别名
|
||||
*/
|
||||
private String aliasColumName;
|
||||
|
||||
/**
|
||||
* 列名index
|
||||
*/
|
||||
private String columIndex;
|
||||
|
||||
/**
|
||||
* 是否隐藏 默认显示
|
||||
*/
|
||||
private boolean isHide = false;
|
||||
|
||||
/**
|
||||
* 宽度
|
||||
*/
|
||||
private String width;
|
||||
|
||||
/**
|
||||
* 是否转多语言
|
||||
*/
|
||||
private boolean isTransfLanguage = false;
|
||||
|
||||
/**
|
||||
* 是否换行
|
||||
* @param width
|
||||
*/
|
||||
private boolean newLine = false;
|
||||
|
||||
public void setWidth(String width){
|
||||
this.width =width;
|
||||
}
|
||||
|
||||
public String getWidth(){
|
||||
return width;
|
||||
}
|
||||
public String getColumName() {
|
||||
return columName;
|
||||
}
|
||||
|
||||
public void setColumName(String columName) {
|
||||
this.columName = columName;
|
||||
}
|
||||
|
||||
public String getAliasColumName() {
|
||||
return aliasColumName;
|
||||
}
|
||||
|
||||
public void setAliasColumName(String aliasColumName) {
|
||||
this.aliasColumName = aliasColumName;
|
||||
}
|
||||
|
||||
public boolean isHide() {
|
||||
return isHide;
|
||||
}
|
||||
|
||||
public void setHide(boolean hide) {
|
||||
isHide = hide;
|
||||
}
|
||||
|
||||
public String getColumIndex() {
|
||||
return columIndex;
|
||||
}
|
||||
|
||||
public void setColumIndex(String columIndex) {
|
||||
this.columIndex = columIndex;
|
||||
}
|
||||
|
||||
public boolean isTransfLanguage() {
|
||||
return isTransfLanguage;
|
||||
}
|
||||
|
||||
public boolean isNewLine() {
|
||||
return newLine;
|
||||
}
|
||||
|
||||
public void setNewLine(boolean newLine) {
|
||||
this.newLine = newLine;
|
||||
}
|
||||
|
||||
public void setTransfLanguage(boolean transfLanguage) {
|
||||
|
||||
isTransfLanguage = transfLanguage;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,153 +0,0 @@
|
|||
package com.engine.salary.elog.entity.dto;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @ClassName: TableChangeBean
|
||||
* @Description 表更新前后值类
|
||||
* @Author tanghj
|
||||
* @Date 2021/3/8 15:58
|
||||
*/
|
||||
@ApiModel("表更新前后值类")
|
||||
public class TableChangeBean<T> implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 15869325700230992L;
|
||||
|
||||
@ApiModelProperty("表名")
|
||||
private String tableName;
|
||||
|
||||
@ApiModelProperty("数据id")
|
||||
private String dataid;
|
||||
|
||||
@ApiModelProperty("所属主表数据id")
|
||||
private String belongDataid;
|
||||
|
||||
@ApiModelProperty("是否为明细表(0,否;1,是)")
|
||||
private int isDetail = 0;
|
||||
|
||||
/**
|
||||
* 泛型必须是具体的实体类
|
||||
*/
|
||||
@ApiModelProperty("更新前的值")
|
||||
private T oldValue;
|
||||
|
||||
/**
|
||||
* 泛型必须是具体的实体类
|
||||
*/
|
||||
@ApiModelProperty("更新后的值")
|
||||
private T newValue;
|
||||
|
||||
/**
|
||||
* 泛型必须是具体的实体类
|
||||
*/
|
||||
@ApiModelProperty("更新前显示的值")
|
||||
private T oldRealValue;
|
||||
|
||||
/**
|
||||
* 泛型必须是具体的实体类
|
||||
*/
|
||||
@ApiModelProperty("更新后显示的值")
|
||||
private T newRealValue;
|
||||
|
||||
|
||||
@ApiModelProperty("字段对应的labelid")
|
||||
private String fieldNameLabelId;
|
||||
|
||||
@ApiModelProperty("表对应的labelid")
|
||||
private String tableNameLabelId;
|
||||
|
||||
@ApiModelProperty("对应数据库的表")
|
||||
private String tableNameDesc;
|
||||
|
||||
|
||||
public String getTableName() {
|
||||
return tableName;
|
||||
}
|
||||
|
||||
public void setTableName(String tableName) {
|
||||
this.tableName = tableName;
|
||||
}
|
||||
|
||||
public T getOldValue() {
|
||||
return oldValue;
|
||||
}
|
||||
|
||||
public void setOldValue(T oldValue) {
|
||||
this.oldValue = oldValue;
|
||||
}
|
||||
|
||||
public T getNewValue() {
|
||||
return newValue;
|
||||
}
|
||||
|
||||
public void setNewValue(T newValue) {
|
||||
this.newValue = newValue;
|
||||
}
|
||||
|
||||
public String getDataid() {
|
||||
return dataid;
|
||||
}
|
||||
|
||||
public void setDataid(String dataid) {
|
||||
this.dataid = dataid;
|
||||
}
|
||||
|
||||
public String getBelongDataid() {
|
||||
return belongDataid;
|
||||
}
|
||||
|
||||
public void setBelongDataid(String belongDataid) {
|
||||
this.belongDataid = belongDataid;
|
||||
}
|
||||
|
||||
public int getIsDetail() {
|
||||
return isDetail;
|
||||
}
|
||||
|
||||
public void setIsDetail(int isDetail) {
|
||||
this.isDetail = isDetail;
|
||||
}
|
||||
|
||||
public T getOldRealValue() {
|
||||
return oldRealValue;
|
||||
}
|
||||
|
||||
public void setOldRealValue(T oldRealValue) {
|
||||
this.oldRealValue = oldRealValue;
|
||||
}
|
||||
|
||||
public T getNewRealValue() {
|
||||
return newRealValue;
|
||||
}
|
||||
|
||||
public String getFieldNameLabelId() {
|
||||
return fieldNameLabelId;
|
||||
}
|
||||
|
||||
public void setFieldNameLabelId(String fieldNameLabelId) {
|
||||
this.fieldNameLabelId = fieldNameLabelId;
|
||||
}
|
||||
|
||||
public String getTableNameLabelId() {
|
||||
return tableNameLabelId;
|
||||
}
|
||||
|
||||
public void setTableNameLabelId(String tableNameLabelId) {
|
||||
this.tableNameLabelId = tableNameLabelId;
|
||||
}
|
||||
|
||||
public String getTableNameDesc() {
|
||||
return tableNameDesc;
|
||||
}
|
||||
|
||||
public void setTableNameDesc(String tableNameDesc) {
|
||||
this.tableNameDesc = tableNameDesc;
|
||||
}
|
||||
|
||||
public void setNewRealValue(T newRealValue) {
|
||||
this.newRealValue = newRealValue;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,155 +0,0 @@
|
|||
package com.engine.salary.elog.entity.dto;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
/**
|
||||
* @ClassName: TableColumnBean
|
||||
* @Description 表字段类
|
||||
* @Author tanghj
|
||||
* @Date 2021/3/12 11:44
|
||||
*/
|
||||
@ApiModel("表字段类")
|
||||
public class TableColumnBean {
|
||||
|
||||
@ApiModelProperty("列名")
|
||||
private String columnName;
|
||||
|
||||
/**
|
||||
* varchar(20)
|
||||
*/
|
||||
@ApiModelProperty("数据类型")
|
||||
private String columnType;
|
||||
|
||||
@ApiModelProperty("字段类型-字符串")
|
||||
private String dataTypeStr;
|
||||
|
||||
@ApiModelProperty("字段类型")
|
||||
private DataTypeEnum dataType;
|
||||
|
||||
@ApiModelProperty("长度")
|
||||
private long fieldLength;
|
||||
|
||||
@ApiModelProperty("是否为空")
|
||||
private boolean isNullable;
|
||||
|
||||
@ApiModelProperty("是否为空-字符串")
|
||||
private String isNullableStr;
|
||||
|
||||
@ApiModelProperty("默认值")
|
||||
private Object columnDefault;
|
||||
|
||||
@ApiModelProperty("备注")
|
||||
private String columnComment;
|
||||
|
||||
public String getColumnName() {
|
||||
return columnName;
|
||||
}
|
||||
|
||||
public void setColumnName(String columnName) {
|
||||
this.columnName = columnName;
|
||||
}
|
||||
|
||||
public String getColumnType() {
|
||||
return columnType;
|
||||
}
|
||||
|
||||
public void setColumnType(String columnType) {
|
||||
this.columnType = columnType;
|
||||
}
|
||||
|
||||
public DataTypeEnum getDataType() {
|
||||
return dataType;
|
||||
}
|
||||
|
||||
public void setDataType(DataTypeEnum dataType) {
|
||||
this.dataType = dataType;
|
||||
}
|
||||
|
||||
public long getFieldLength() {
|
||||
return fieldLength;
|
||||
}
|
||||
|
||||
public void setFieldLength(long fieldLength) {
|
||||
this.fieldLength = fieldLength;
|
||||
}
|
||||
|
||||
public boolean isNullable() {
|
||||
return isNullable;
|
||||
}
|
||||
|
||||
public void setNullable(boolean nullable) {
|
||||
isNullable = nullable;
|
||||
}
|
||||
|
||||
public Object getColumnDefault() {
|
||||
return columnDefault;
|
||||
}
|
||||
|
||||
public void setColumnDefault(Object columnDefault) {
|
||||
this.columnDefault = columnDefault;
|
||||
}
|
||||
|
||||
public String getColumnComment() {
|
||||
return columnComment;
|
||||
}
|
||||
|
||||
public void setColumnComment(String columnComment) {
|
||||
this.columnComment = columnComment;
|
||||
}
|
||||
|
||||
public String getDataTypeStr() {
|
||||
return dataTypeStr;
|
||||
}
|
||||
|
||||
public void setDataTypeStr(String dataTypeStr) {
|
||||
this.dataTypeStr = dataTypeStr;
|
||||
}
|
||||
|
||||
public String getIsNullableStr() {
|
||||
return isNullableStr;
|
||||
}
|
||||
|
||||
public void setIsNullableStr(String isNullableStr) {
|
||||
this.isNullableStr = isNullableStr;
|
||||
}
|
||||
|
||||
public boolean equals(TableColumnBean tableColumnBean) {
|
||||
|
||||
return this.toSql().equals(tableColumnBean.toSql());
|
||||
}
|
||||
|
||||
public String toSql() {
|
||||
|
||||
StringBuilder sb = new StringBuilder(this.columnName.toLowerCase()).append(" ");
|
||||
|
||||
if (this.dataType == null) {
|
||||
return "类型为空";
|
||||
}
|
||||
switch (this.dataType) {
|
||||
case BIGINT:
|
||||
case INT:
|
||||
case TEXT:
|
||||
case LONGTEXT:
|
||||
case DATETIME:
|
||||
case FLOAT:
|
||||
case TINYINT:
|
||||
case DOUBLE:
|
||||
sb.append(this.dataType.name().toLowerCase()).append(" ");
|
||||
break;
|
||||
case VARCHAR:
|
||||
sb.append(this.dataType.name().toLowerCase()).append("(").append(this.fieldLength).append(") ");
|
||||
break;
|
||||
case DECIMAL:
|
||||
long length = (this.fieldLength < 0 || this.fieldLength > 38) ? 0 : this.fieldLength;
|
||||
sb.append(this.dataType.name().toLowerCase()).append("(").append(38 - length).append(",").append(length).append(") ");
|
||||
break;
|
||||
default:
|
||||
sb.append("varchar").append("(").append(10).append(") ");
|
||||
}
|
||||
|
||||
sb.append("comment ").append("'").append(this.columnComment).append("' ");
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,35 +0,0 @@
|
|||
package com.engine.salary.elog.entity.param;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class ELogGetLogParam {
|
||||
/**
|
||||
* 服务(模块)名
|
||||
*/
|
||||
String module;
|
||||
/**
|
||||
* 方法名
|
||||
*/
|
||||
String function;
|
||||
/**
|
||||
* 查询条件
|
||||
*/
|
||||
String condition;
|
||||
/**
|
||||
* 每页多少数据
|
||||
*/
|
||||
String pageSize;
|
||||
/**
|
||||
* '
|
||||
* 当前页
|
||||
*/
|
||||
String current;
|
||||
|
||||
}
|
||||
|
|
@ -1,29 +0,0 @@
|
|||
package com.engine.salary.elog.entity.param;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class GetDetailChangesParam {
|
||||
/**
|
||||
* 服务(模块)名
|
||||
*/
|
||||
String module;
|
||||
/**
|
||||
* 方法名
|
||||
*/
|
||||
String function;
|
||||
/**
|
||||
* 主键id
|
||||
*/
|
||||
String mainid;
|
||||
/**
|
||||
* 转换方法
|
||||
*/
|
||||
String detailTransMethod;
|
||||
}
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
package com.engine.salary.elog.enums;
|
||||
|
||||
/**
|
||||
* @date: 2022/3/30 20:32
|
||||
* @author: deli.xu
|
||||
* @description: 日志常量
|
||||
*/
|
||||
public class ElogConsts {
|
||||
|
||||
public static final String ORACLE = "oracle";
|
||||
public static final String SQLSERVER = "sqlserver";
|
||||
public static final String MYSQL = "mysql";
|
||||
public static final String POSTGRESQL = "postgresql";
|
||||
|
||||
public static final String BASE_TABLE = "BASE_ELOG_TABLE";
|
||||
|
||||
public static final String TABLE_SPACER = "_";
|
||||
public static final String TABLE_SUFFIX = "logs";
|
||||
public static final String DETAIL_TABLE_SUFFIX = "_detail";
|
||||
|
||||
public static final String ES = "ES";
|
||||
}
|
||||
|
|
@ -1,48 +0,0 @@
|
|||
package com.engine.salary.elog.enums;
|
||||
|
||||
/**
|
||||
* @ClassName: FromTerminalType
|
||||
* @Description TODO
|
||||
* @Author tanghj
|
||||
* @Date 2021/6/8 11:35
|
||||
*/
|
||||
public enum FromTerminalType {
|
||||
PC("pc","来自 pc web"),
|
||||
ANDROID("android","来自 安卓"),
|
||||
IOS("ios","来自 iphone"),
|
||||
IPHONE("iphone","来自 iphone"),
|
||||
PC_CLIENT("pc_client","来自 windows客户端"),
|
||||
MAC_CLIENT("mac_client","来自 mac客户端"),
|
||||
H5("H5","来自 手机H5"),
|
||||
MOBILEWEB("mobileWeb","来自 手机H5"),
|
||||
MICO_MSG("mico_msg","来自 微信"),
|
||||
WECHAT("wechat","来自 企业微信"),
|
||||
APP_H5("app_h5","来自 app_h5"),
|
||||
BROWSER("browser", "来自 网页"),
|
||||
MOBILE("mobile","来自 移动端");
|
||||
|
||||
private String code;
|
||||
private String face;
|
||||
|
||||
FromTerminalType(String code, String face) {
|
||||
this.code = code;
|
||||
this.face = face;
|
||||
}
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public String getFace() {
|
||||
return face;
|
||||
}
|
||||
|
||||
public static FromTerminalType fromString(String name) {
|
||||
try {
|
||||
FromTerminalType type = FromTerminalType.valueOf(name);
|
||||
return type;
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,173 +0,0 @@
|
|||
package com.engine.salary.elog.enums;
|
||||
|
||||
/**
|
||||
* @date: 2022/5/13 21:13
|
||||
* @author: deli.xu
|
||||
* @description: 链接类型 用之前老eteams-base-bean
|
||||
*/
|
||||
|
||||
/**
|
||||
* 链接类型
|
||||
*
|
||||
* @author gk
|
||||
*/
|
||||
public enum LinkType {
|
||||
|
||||
// 主线
|
||||
mainline("项目"),
|
||||
|
||||
blog("工作日报"),
|
||||
|
||||
workreport("计划报告"),
|
||||
|
||||
clue("线索"),
|
||||
|
||||
crmcontact("联系人-用于全局搜索"),
|
||||
|
||||
marketactivity("活动"),
|
||||
|
||||
crmSummary("报表"),
|
||||
|
||||
statisticalReport("统计报表"),
|
||||
|
||||
attend("出勤"),
|
||||
|
||||
singalForm("表单应用"),
|
||||
|
||||
biaoge("表格"),
|
||||
|
||||
// 标签
|
||||
tag("标签"),
|
||||
|
||||
// 表单标签
|
||||
formtag("表单标签"),
|
||||
|
||||
// 附件
|
||||
attachment("附件"),
|
||||
|
||||
// 用户
|
||||
user("用户"),
|
||||
|
||||
// 任务
|
||||
task("任务"),
|
||||
|
||||
// 子任务
|
||||
subtask("子任务"),
|
||||
|
||||
// 文档
|
||||
document("文档"),
|
||||
|
||||
// 文件夹
|
||||
folder("文件夹"),
|
||||
|
||||
// 客户
|
||||
customer("客户"),
|
||||
|
||||
// 联系人
|
||||
contact("联系人"),
|
||||
|
||||
// 销售商机
|
||||
saleChance("销售商机"),
|
||||
|
||||
// 产品
|
||||
production("产品"),
|
||||
|
||||
// 合同
|
||||
contract("合同"),
|
||||
|
||||
// 竞争对手
|
||||
competitor("竞争对手"),
|
||||
|
||||
// 公告
|
||||
placard("公告"),
|
||||
|
||||
// 审批
|
||||
workflow("审批"),
|
||||
|
||||
// 部门
|
||||
department("部门"),
|
||||
|
||||
// 岗位
|
||||
position("岗位"),
|
||||
|
||||
// 日程
|
||||
calendar("日程"),
|
||||
|
||||
// 群组
|
||||
group("群组"),
|
||||
|
||||
// 合同
|
||||
hrcontract("人事合同"),
|
||||
|
||||
//人事管理
|
||||
hr("人事"),
|
||||
|
||||
//KPI
|
||||
kpi("绩效考核"),kpiFlow("绩效考核流程"),
|
||||
|
||||
// 全部
|
||||
all("所有人"),
|
||||
|
||||
formdatareport("数据上报"),
|
||||
|
||||
form("表单"),
|
||||
|
||||
userSetting("不可见成员"),
|
||||
|
||||
sms("短信"),
|
||||
|
||||
wechatEnterprise("企业微信"),
|
||||
|
||||
wechatService("微信服务号"),
|
||||
|
||||
salarybill("工资单"),
|
||||
|
||||
staffPosition("员工位置")/*定制化模块*/,
|
||||
|
||||
app("应用")/*自定义应用*/,
|
||||
|
||||
email("邮件"),
|
||||
|
||||
workTrends("工作动态"),
|
||||
|
||||
tenantLogo("个性化定制"),
|
||||
|
||||
module("模块"),
|
||||
|
||||
orderform("订单"),
|
||||
|
||||
price("价格"),
|
||||
|
||||
capital("资金"),
|
||||
|
||||
quote("报价"),
|
||||
|
||||
room("会议室管理"),
|
||||
|
||||
//模板任务
|
||||
mtTask("模板任务"),
|
||||
|
||||
watchMe("关注我的"),
|
||||
// crm
|
||||
crm("CRM"),
|
||||
|
||||
// 空
|
||||
blank(""),
|
||||
|
||||
role("角色"),
|
||||
|
||||
externalUser("外部联系人"),
|
||||
|
||||
subcompany("分部");
|
||||
|
||||
private String displayName;
|
||||
|
||||
LinkType(String displayName) {
|
||||
this.displayName = displayName;
|
||||
}
|
||||
|
||||
public String getDisplayName() {
|
||||
return displayName;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,14 +0,0 @@
|
|||
package com.engine.salary.elog.enums;
|
||||
|
||||
public class OperateAuditType {
|
||||
//自动
|
||||
public static final String AUTO = "AUTO";
|
||||
//信息
|
||||
public static final String INFO = "INFO";
|
||||
//错误
|
||||
public static final String ERROR = "ERROR";
|
||||
//警告
|
||||
public static final String WARNING = "WARNING";
|
||||
//重大事件
|
||||
public static final String EVENT = "EVENT";
|
||||
}
|
||||
|
|
@ -1,13 +0,0 @@
|
|||
package com.engine.salary.elog.service;
|
||||
|
||||
import com.engine.salary.elog.entity.dto.LoggerContext;
|
||||
import com.engine.salary.elog.entity.dto.LoggerDetailContext;
|
||||
|
||||
public interface ILocalElogService {
|
||||
|
||||
<T> int insertLocalElog(LoggerContext<T> context);
|
||||
|
||||
<T> int insertElogDetail(LoggerDetailContext<T> loggerDetailContext, String mainId, String detailTableName);
|
||||
|
||||
// <T> void rollBackElog(LoggerContext<T> context);
|
||||
}
|
||||
|
|
@ -1,41 +0,0 @@
|
|||
package com.engine.salary.elog.service;
|
||||
|
||||
import com.cloudstore.eccom.pc.table.WeaTable;
|
||||
import com.engine.salary.elog.entity.param.ELogGetLogParam;
|
||||
import com.engine.salary.elog.entity.param.GetDetailChangesParam;
|
||||
import com.engine.salary.util.page.PageInfo;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface ILoggerTableService {
|
||||
PageInfo queryLogs(String data);
|
||||
|
||||
WeaTable queryLogsPapi(String data, HttpServletRequest request);
|
||||
|
||||
List getDetailChanges(GetDetailChangesParam param);
|
||||
|
||||
List getDetailChangesPapi(String module, String function, String mainid, String transMethod, HttpServletRequest request);
|
||||
|
||||
List queryLogList(ELogGetLogParam param);
|
||||
|
||||
List queryCardLogList(String data);
|
||||
|
||||
Map countLog(String module, String function);
|
||||
|
||||
List queryDetailLogList(String module, String function, String current, String pageSize, String condition, String mainId);
|
||||
|
||||
Map countDestailLog(String module, String function, String mainId);
|
||||
|
||||
WeaTable queryElogTraceInfo(String traceId, String module, String function, Integer currentPage, Integer pageSize,String traceTransMethod);
|
||||
|
||||
List queryLogInfoByCustom(String module, String function, String field, String value, boolean isDetail);
|
||||
|
||||
List queryLogInfoByCustom(String module, String function, String field, String value);
|
||||
|
||||
// BatchDocumentMessage downloadLog(String data);
|
||||
|
||||
WeaTable getDetailChangePages(String module, String function, String mainid, String detailTransMethod, String current, String pageSize);
|
||||
|
||||
}
|
||||
|
|
@ -1,435 +0,0 @@
|
|||
package com.engine.salary.elog.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.engine.salary.elog.entity.dto.LoggerContext;
|
||||
import com.engine.salary.elog.entity.dto.LoggerDetailContext;
|
||||
import com.engine.salary.elog.enums.ElogConsts;
|
||||
import com.engine.salary.elog.service.ILocalElogService;
|
||||
import com.engine.salary.elog.util.ElogUtils;
|
||||
import com.engine.salary.mapper.elog.LocalElogAopDaoMapper;
|
||||
import com.engine.salary.util.db.IdGenerator;
|
||||
import com.engine.salary.util.db.MapperProxyFactory;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import weaver.conn.RecordSet;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @ClassName: LocalElogService
|
||||
* @Description 日志本地持久化
|
||||
* @Author tanghj
|
||||
* @Date 2021/2/24 11:03
|
||||
*/
|
||||
public class LocalElogService implements ILocalElogService {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(LocalElogService.class);
|
||||
|
||||
private LocalElogAopDaoMapper getLocalElogAopDaoMapper() {
|
||||
return MapperProxyFactory.getProxy(LocalElogAopDaoMapper.class);
|
||||
}
|
||||
|
||||
// private RestHighLevelClient client;
|
||||
//
|
||||
// private LazyRollBack lazyRollBack;
|
||||
|
||||
//数据库类型
|
||||
private static final String databaseId = new RecordSet().getDBType();
|
||||
|
||||
/**
|
||||
* @param context
|
||||
* @param <T>
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public <T> int insertLocalElog(LoggerContext<T> context) {
|
||||
// logger.error("接收到的数据,context:{}",JSONObject.toJSONString(context));
|
||||
// logger.info("接收到数据的时间:log_date:{}",context.getDate());
|
||||
if (StringUtils.isEmpty(context.getUuid())) {
|
||||
context.setUuid(UUID.randomUUID().toString().replace("-", ""));
|
||||
}
|
||||
|
||||
String cusColumns = "";
|
||||
String cusValus = "";
|
||||
if (context.getCustomInfo() != null) {
|
||||
JSONObject custom = JSONObject.parseObject(JSON.toJSONString(context.getCustomInfo()));
|
||||
List<String> clobFieldList = context.getClobFieldList();
|
||||
for (String key : (Set<String>) custom.keySet()) {
|
||||
cusColumns = cusColumns + ", " + key;
|
||||
String keystr = custom.getString(key);
|
||||
//如果keystr包含单引号,将单引号去掉
|
||||
if (StringUtils.isNotEmpty(keystr) && keystr.contains("'")) {
|
||||
keystr = keystr.replace("'", "''");
|
||||
}
|
||||
//如果是Oracle数据库
|
||||
if (ElogConsts.ORACLE.equals(databaseId)) {
|
||||
//clob字段集合不为空且包含此字段
|
||||
if (!CollectionUtils.isEmpty(clobFieldList) && clobFieldList.contains(key)) {
|
||||
String clobColumnStr = ElogUtils.handleClobColumn(keystr);
|
||||
cusValus = cusValus + ",TO_CLOB( " + clobColumnStr + " )";
|
||||
} else if (checkStrIsDate(keystr)) {
|
||||
//并且字符串为时间类型格式 则进行特殊处理
|
||||
cusValus = cusValus + ",TO_DATE('" + keystr + "', 'SYYYY-MM-DD HH24:MI:SS')";
|
||||
} else {
|
||||
cusValus = cusValus + ",'" + keystr + "'";
|
||||
}
|
||||
} else {
|
||||
cusValus = cusValus + ",'" + keystr + "'";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
normalizationContext(context);
|
||||
|
||||
String tableName = context.getModuleName() + "_" + context.getFunctionName() + "logs";
|
||||
//context.setId(IdGenerator.generate());
|
||||
Integer id = getLocalElogAopDaoMapper().queryElogContextById(context.getId(), tableName);
|
||||
if (id != null) {
|
||||
return 1;
|
||||
}
|
||||
// logger.info("插入前的数据:context:{}",JSONObject.toJSONString(context));
|
||||
int count = getLocalElogAopDaoMapper().insertElogContext(context, cusColumns, cusValus, tableName);
|
||||
if (context.getDetailContexts() != null) {
|
||||
String detailTableName = context.getModuleName() + "_" + context.getFunctionName() + "logs_detail";
|
||||
insertBatchDetailPrepared(detailTableName, context);
|
||||
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
/**
|
||||
* 预编译
|
||||
*
|
||||
* @param detailTableName
|
||||
* @param context
|
||||
*/
|
||||
private void insertBatchDetailPrepared(String detailTableName, LoggerContext context) {
|
||||
// 用mapper
|
||||
//分两种 有无自定义字段
|
||||
List<LoggerDetailContext> detailContexts = context.getDetailContexts();
|
||||
Boolean hasCustonInfo = false;
|
||||
String cusColumns = "";
|
||||
if (Objects.nonNull(detailContexts.get(0).getCustomDetailInfo())) {
|
||||
hasCustonInfo = true;
|
||||
//有自定义明细字段
|
||||
JSONObject custom = JSONObject.parseObject(JSON.toJSONString(detailContexts.get(0).getCustomDetailInfo()));
|
||||
for (String key : (Set<String>) custom.keySet()) {
|
||||
cusColumns = cusColumns + ", " + key;
|
||||
}
|
||||
|
||||
}
|
||||
for (LoggerDetailContext detailContext : detailContexts) {
|
||||
if (StringUtils.isNotEmpty(detailContext.getNewValue())) {
|
||||
String str = detailContext.getNewValue().replaceAll("[\\x{1F600}-\\x{1F64F}\\x{1F300}-\\x{1F5FF}]", "");
|
||||
detailContext.setNewValue(str);
|
||||
}
|
||||
if (StringUtils.isNotEmpty(detailContext.getOldValue())) {
|
||||
String str = detailContext.getOldValue().replaceAll("[\\x{1F600}-\\x{1F64F}\\x{1F300}-\\x{1F5FF}]", "");
|
||||
detailContext.setOldValue(str);
|
||||
}
|
||||
if (StringUtils.isNotEmpty(detailContext.getNewRealValue())) {
|
||||
String str = detailContext.getNewRealValue().replaceAll("[\\x{1F600}-\\x{1F64F}\\x{1F300}-\\x{1F5FF}]", "");
|
||||
detailContext.setNewRealValue(str);
|
||||
}
|
||||
if (StringUtils.isNotEmpty(detailContext.getOldRealValue())) {
|
||||
String str = detailContext.getOldRealValue().replaceAll("[\\x{1F600}-\\x{1F64F}\\x{1F300}-\\x{1F5FF}]", "");
|
||||
detailContext.setOldRealValue(str);
|
||||
}
|
||||
|
||||
|
||||
detailContext.setTenant_key(context.getTenant_key());
|
||||
detailContext.setCreate_time(new Date());
|
||||
detailContext.setUpdate_time(new Date());
|
||||
detailContext.setCreator(context.getLogOperator());
|
||||
detailContext.setId(IdGenerator.generate());
|
||||
if (hasCustonInfo) {
|
||||
String cusValus = "";
|
||||
//如果有明细
|
||||
JSONObject custom = JSONObject.parseObject(JSON.toJSONString(detailContext.getCustomDetailInfo()));
|
||||
for (String key : (Set<String>) custom.keySet()) {
|
||||
String keystr = custom.getString(key);
|
||||
//如果keystr包含单引号,将单引号去掉
|
||||
if (StringUtils.isNotEmpty(keystr) && keystr.contains("'")) {
|
||||
keystr = keystr.replace("'", "''");
|
||||
}
|
||||
cusValus = cusValus + ",'" + keystr + "'";
|
||||
}
|
||||
detailContext.setCusValus(cusValus);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (hasCustonInfo) {
|
||||
getLocalElogAopDaoMapper().insertElogDetailPreparedHasCustonInfo(detailTableName, detailContexts, context.getUuid(), cusColumns);
|
||||
} else {
|
||||
getLocalElogAopDaoMapper().insertElogDetailPrepared(detailTableName, detailContexts, context.getUuid());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private <T> void normalizationContext(LoggerContext<T> context) {
|
||||
String params = "";
|
||||
if (StringUtils.isNotEmpty(context.getParamsStr())) {
|
||||
params = context.getParamsStr();
|
||||
} else if (context.getParams() != null) {
|
||||
params = ElogUtils.compress(JSONObject.toJSONString(context.getParams()));
|
||||
}
|
||||
|
||||
context.setParamsStr(params);
|
||||
if (StringUtils.isBlank(context.getCancelContextStr())) {
|
||||
context.setCancelContextStr(context.getCancelContext() == null ? "" : JSONObject.toJSONString(context.getCancelContext()));
|
||||
}
|
||||
if (StringUtils.isBlank(context.getRedoContextStr())) {
|
||||
context.setRedoContextStr(context.getRedoContext() == null ? "" : JSONObject.toJSONString(context.getRedoContext()));
|
||||
}
|
||||
|
||||
if (StringUtils.isEmpty(context.getOperatedesc())) {
|
||||
context.setOperatedesc("");
|
||||
} else {
|
||||
//todo 兼容emojo特殊字符 没有时间 先暴力替换
|
||||
String str = context.getOperatedesc().replaceAll("[\\x{1F600}-\\x{1F64F}\\x{1F300}-\\x{1F5FF}]", "");
|
||||
context.setOperatedesc(str);
|
||||
}
|
||||
|
||||
if (Objects.isNull(context.getDate())) {
|
||||
context.setDate(new Date());
|
||||
}
|
||||
|
||||
if (StringUtils.isEmpty(context.getOperator())) {
|
||||
context.setLogOperator(-1l);
|
||||
} else {
|
||||
context.setLogOperator(Long.parseLong(context.getOperator()));
|
||||
}
|
||||
if (StringUtils.isEmpty(context.getTargetId())) {
|
||||
context.setLogTargetid(-1l);
|
||||
} else {
|
||||
context.setLogTargetid(Long.parseLong(context.getTargetId()));
|
||||
}
|
||||
if (StringUtils.isEmpty(context.getClientIp())) {
|
||||
context.setClientIp("127.0.0.1");
|
||||
}
|
||||
if (Objects.isNull(context.getCreate_time())) {
|
||||
context.setCreate_time(new Date());
|
||||
}
|
||||
if (Objects.isNull(context.getUpdate_time())) {
|
||||
context.setUpdate_time(new Date());
|
||||
}
|
||||
if (Objects.isNull(context.getDelete_type())) {
|
||||
context.setDelete_type(0);
|
||||
}
|
||||
}
|
||||
|
||||
private void insertBatchDetailSql(String detailTableName, LoggerContext context) {
|
||||
String standardField = "id, mainid, uuid, tablename, fieldname, newvalue, oldvalue, fielddesc, showorder, dataid, belongDataid, isDetail, tenant_key,creator, newRealValue, oldRealValue,tableNameDesc, tableNameLabelId,fieldNameLabelId, create_time, update_time";
|
||||
|
||||
Boolean hasCustonInfo = false;
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("INSERT INTO ").append(detailTableName).append("(").append(standardField);
|
||||
//List<LoggerDetailContext> collect = detailContexts.stream().filter(s -> Objects.nonNull(s.getCustomDetailInfo())).collect(Collectors.toList());
|
||||
List<LoggerDetailContext> detailContexts = context.getDetailContexts();
|
||||
if (Objects.nonNull(detailContexts.get(0).getCustomDetailInfo())) {
|
||||
hasCustonInfo = true;
|
||||
//有自定义明细字段
|
||||
String cusColumns = "";
|
||||
JSONObject custom = JSONObject.parseObject(JSON.toJSONString(detailContexts.get(0).getCustomDetailInfo()));
|
||||
for (String key : (Set<String>) custom.keySet()) {
|
||||
cusColumns = cusColumns + ", " + key;
|
||||
}
|
||||
sb.append(cusColumns);
|
||||
}
|
||||
sb.append(")");
|
||||
if ("oracle".equalsIgnoreCase(databaseId)) {
|
||||
sb.append(" ").append(String.join(" UNION ALL ", getBatchInsertValue(context, hasCustonInfo, true)));
|
||||
} else {
|
||||
sb.append(" VALUES ").append(String.join(",", getBatchInsertValue(context, hasCustonInfo, false)));
|
||||
}
|
||||
|
||||
try {
|
||||
getLocalElogAopDaoMapper().batchInsertDetail(sb.toString());
|
||||
} catch (Exception e) {
|
||||
logger.error("明细批量添加sql是:{},批量插入明细失败,{}", sb.toString(), e.getMessage(), e);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
private List<String> getBatchInsertValue(LoggerContext context, boolean hasCustomInfo, boolean isOracle) {
|
||||
|
||||
LocalDateTime localDateTime = LocalDateTime.now();
|
||||
String nowDate = localDateTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
||||
|
||||
List<LoggerDetailContext> detailContexts = context.getDetailContexts();
|
||||
List<String> batchValue = new ArrayList<>();
|
||||
for (LoggerDetailContext detailContext : detailContexts) {
|
||||
detailContext.setTenant_key(context.getTenant_key());
|
||||
detailContext.setCreator(context.getLogOperator());
|
||||
detailContext.setId(IdGenerator.generate());
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(isOracle ? " SELECT " : " ( ");
|
||||
sb.append(detailContext.getId())
|
||||
.append(",'").append(context.getUuid()).append("'")
|
||||
.append(",'").append(detailContext.getUuid()).append("'")
|
||||
.append(",'").append(detailContext.getTableName()).append("'")
|
||||
.append(",'").append(detailContext.getFieldName()).append("'")
|
||||
.append(",'").append(transferString(detailContext.getNewValue())).append("'")
|
||||
.append(",'").append(transferString(detailContext.getOldValue())).append("'")
|
||||
.append(",'").append(detailContext.getFieldDesc()).append("'")
|
||||
.append(",'").append(detailContext.getShoworder()).append("'")
|
||||
.append(",'").append(detailContext.getDataid()).append("'")
|
||||
.append(",'").append(detailContext.getBelongDataid()).append("'")
|
||||
.append(",'").append(detailContext.getIsDetail()).append("'")
|
||||
.append(",'").append(detailContext.getTenant_key()).append("'")
|
||||
.append(",'").append(detailContext.getCreator()).append("'")
|
||||
.append(",'").append(transferString(detailContext.getNewRealValue())).append("'")
|
||||
.append(",'").append(transferString(detailContext.getOldRealValue())).append("'")
|
||||
.append(",'").append(detailContext.getTableNameDesc()).append("'")
|
||||
.append(",'").append(detailContext.getTableNameLabelId()).append("'")
|
||||
.append(",'").append(detailContext.getFieldNameLabelId()).append("'")
|
||||
.append(",").append(handleValue(nowDate, databaseId))
|
||||
.append(",").append(handleValue(nowDate, databaseId));
|
||||
|
||||
if (hasCustomInfo) {
|
||||
String cusValus = "";
|
||||
//如果有明细
|
||||
JSONObject custom = JSONObject.parseObject(JSON.toJSONString(detailContext.getCustomDetailInfo()));
|
||||
for (String key : (Set<String>) custom.keySet()) {
|
||||
String keystr = custom.getString(key);
|
||||
//如果keystr包含单引号,将单引号去掉
|
||||
if (StringUtils.isNotEmpty(keystr) && keystr.contains("'")) {
|
||||
keystr = keystr.replace("'", "''");
|
||||
}
|
||||
cusValus = cusValus + ",'" + keystr + "'";
|
||||
}
|
||||
sb.append(cusValus);
|
||||
}
|
||||
String sql = isOracle ? sb.append(" from dual ").toString() : sb.append(")").toString();
|
||||
|
||||
batchValue.add(sql);
|
||||
}
|
||||
|
||||
return batchValue;
|
||||
}
|
||||
|
||||
private String transferString(String str) {
|
||||
if (StringUtils.isNotEmpty(str)) {
|
||||
str = str.replaceAll("#\\{", "\\\\\\\\#{");
|
||||
if (str.contains("'")) {
|
||||
str = str.replace("'", "''");
|
||||
}
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
|
||||
private String handleValue(String nowDate, String databaseId) {
|
||||
switch (databaseId) {
|
||||
case "mysql":
|
||||
return "'" + nowDate + "'";
|
||||
case "oracle":
|
||||
return "TO_DATE('" + nowDate + "','YYYY-MM-DD HH24:MI:SS')";
|
||||
case "sqlserver":
|
||||
return "'" + nowDate + "'";
|
||||
case "postgresql":
|
||||
return "'" + nowDate + "'";
|
||||
|
||||
}
|
||||
return nowDate;
|
||||
}
|
||||
|
||||
// private <T> void insertESElogCenter(LoggerContext<T> context, String customInfo, String tableName) {
|
||||
// //将数据转换为ES的数据格式
|
||||
// LogESDoc logESDoc = LogESDoc.context2Doc(context, customInfo, tableName);
|
||||
// String json = JSON.toJSONString(logESDoc);
|
||||
// String elogESTableName = ElogEsUtils.getElogESTableName(true, ElogEsUtils.getDateStr(context.getDate()));
|
||||
// IndexRequest indexRequest = new IndexRequest(elogESTableName).id(logESDoc.getId().toString());
|
||||
// indexRequest.source(json, XContentType.JSON);
|
||||
//
|
||||
// try {
|
||||
// client.index(indexRequest, RequestOptions.DEFAULT);
|
||||
// } catch (IOException e) {
|
||||
//// logger.info("主表数据添加失败:{}",e.getMessage());
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
@Override
|
||||
public <T> int insertElogDetail(LoggerDetailContext<T> loggerDetailContext, String mainId, String detailTableName) {
|
||||
String cusColumns = "";
|
||||
String cusValus = "";
|
||||
if (loggerDetailContext.getCustomDetailInfo() != null) {
|
||||
JSONObject custom = JSONObject.parseObject(JSON.toJSONString(loggerDetailContext.getCustomDetailInfo()));
|
||||
|
||||
for (String key : (Set<String>) custom.keySet()) {
|
||||
cusColumns = cusColumns + ", " + key;
|
||||
String keystr = custom.getString(key);
|
||||
//如果keystr包含单引号,将单引号去掉
|
||||
if (StringUtils.isNotEmpty(keystr) && keystr.contains("'")) {
|
||||
keystr = keystr.replace("'", "''");
|
||||
}
|
||||
cusValus = cusValus + ",'" + keystr + "'";
|
||||
}
|
||||
}
|
||||
loggerDetailContext.setId(IdGenerator.generate());
|
||||
return getLocalElogAopDaoMapper().insertElogDetail(loggerDetailContext, mainId, cusColumns, cusValus, detailTableName);
|
||||
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public <T> void rollBackElog(LoggerContext<T> context) {
|
||||
// //根据ID 判断数据是否存在
|
||||
//
|
||||
// String tableName = getElogTableName(context.getModuleName(), context.getFunctionName());
|
||||
// Integer id = getLocalElogAopDaoMapper().queryElogContextById(context.getId(), tableName);
|
||||
// //没查到就直接返回
|
||||
// if (id == null) {
|
||||
// lazyRollBack.delayedRollBack(context);
|
||||
// return;
|
||||
// }
|
||||
// getLocalElogAopDaoMapper().rollBackElogById(context.getId(), tableName);
|
||||
//
|
||||
//// if (context.getDetailContexts() != null) {
|
||||
// String detailTableName = context.getModuleName() + "_" + context.getFunctionName() + "logs_detail";
|
||||
// //根据uuid回滚
|
||||
// getLocalElogAopDaoMapper().rollBackDetailElogByUUID(context.getUuid(), detailTableName);
|
||||
//// }
|
||||
//
|
||||
//
|
||||
// }
|
||||
|
||||
/**
|
||||
* 判断字符串是否为日期格式
|
||||
*/
|
||||
public static Boolean checkStrIsDate(String str) {
|
||||
if (StringUtils.isBlank(str)) {
|
||||
return false;
|
||||
} else {
|
||||
try {
|
||||
LocalDateTime.parse(str, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private String getElogTableName(String moduleName, String functionName) {
|
||||
|
||||
// List<String> list = Arrays.asList("meetingTopic", "meetingService", "meetingDecision", "meetingSign", "meetingSignSet", "meetingMember", "meetingShare");
|
||||
|
||||
// if (list.contains(moduleName)) {
|
||||
// return "meeting"+ "_" + functionName + "logs";
|
||||
// }
|
||||
|
||||
return moduleName + "_" + functionName + "logs";
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
|
|
@ -1,75 +0,0 @@
|
|||
package com.engine.salary.elog.threadlocal;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.engine.salary.elog.entity.dto.LoggerContext;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Date: 2022/5/18 20:26
|
||||
* @Author: deli.xu
|
||||
* @Description:
|
||||
**/
|
||||
public class ElogThreadLocal {
|
||||
|
||||
private static final ThreadLocal<List<LoggerContext>> loggerContextList = new ThreadLocal<>();
|
||||
private static final ThreadLocal<JSONObject> requestBody = new ThreadLocal<>();
|
||||
|
||||
public static LoggerContext currentLoggerContext() {
|
||||
List<LoggerContext> list = loggerContextList.get();
|
||||
|
||||
if(list == null || list.size() == 0) {
|
||||
return null;
|
||||
} else {
|
||||
return list.get(list.size() -1);
|
||||
}
|
||||
}
|
||||
|
||||
public static void addLoggerContext(LoggerContext loggerContext) {
|
||||
if(loggerContext == null)
|
||||
return;
|
||||
List<LoggerContext> list = loggerContextList.get();
|
||||
if(list == null) {
|
||||
list = new ArrayList<>();
|
||||
loggerContextList.set(list);
|
||||
}
|
||||
|
||||
list.add(loggerContext);
|
||||
|
||||
}
|
||||
|
||||
public static List<LoggerContext> getLoggerContextList() {
|
||||
return loggerContextList.get();
|
||||
}
|
||||
|
||||
public static void clear() {
|
||||
loggerContextList.set(null);
|
||||
}
|
||||
|
||||
public static void removeLast() {
|
||||
List<LoggerContext> list = loggerContextList.get();
|
||||
|
||||
if(list != null) {
|
||||
int size = list.size();
|
||||
if(size > 0)
|
||||
list.remove(size - 1);
|
||||
}
|
||||
}
|
||||
|
||||
public static void remove() {
|
||||
loggerContextList.remove();
|
||||
}
|
||||
|
||||
public static JSONObject getRequestBody() {
|
||||
return requestBody.get();
|
||||
}
|
||||
|
||||
public static void setRequestBody(JSONObject json) {
|
||||
requestBody.set(json);
|
||||
}
|
||||
|
||||
public static void removeRequestBody() {
|
||||
requestBody.remove();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,92 +0,0 @@
|
|||
package com.engine.salary.elog.util;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.engine.salary.elog.entity.dto.ElogBean;
|
||||
import com.engine.salary.elog.entity.dto.FilterConditionDto;
|
||||
import com.engine.salary.elog.entity.dto.ShowColumsDto;
|
||||
import com.engine.salary.elog.enums.ElogConsts;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @Date: 2022/5/18 19:19
|
||||
* @Author: deli.xu
|
||||
* @Description: elog服务工具类
|
||||
**/
|
||||
public class ElogServiceUtils {
|
||||
|
||||
public static String getTableName(String module, String function) {
|
||||
return getTableName(module, function, false);
|
||||
}
|
||||
|
||||
public static String getTableName(String module, String function, boolean isDetail) {
|
||||
String tablename = module + ElogConsts.TABLE_SPACER + function + ElogConsts.TABLE_SUFFIX + (isDetail ? ElogConsts.DETAIL_TABLE_SUFFIX : "");
|
||||
sqlCheck(tablename);
|
||||
return tablename;
|
||||
}
|
||||
|
||||
public static void sqlCheck(String value) {
|
||||
if (value != null) {
|
||||
if (!value.matches("^[A-Za-z][a-zA-Z0-9_\\.,]{0,31}$")) {
|
||||
throw new RuntimeException("sqlCheck failed ! value :" + value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static ElogBean getElogBean(String data) {
|
||||
JSONObject datas = JSONObject.parseObject(data);
|
||||
ElogBean elogBean = new ElogBean();
|
||||
String module = datas.getString("module");
|
||||
String function = datas.getString("function");
|
||||
String pageNum = datas.getString("current");
|
||||
String pageSize = datas.getString("pageSize");
|
||||
String searchMap = datas.getString("searchMap");
|
||||
String transMethod = datas.getString("transMethod");
|
||||
String authParams = datas.getString("authParams");
|
||||
String showColums = datas.getString("showColums");
|
||||
String filterConditions = datas.getString("filterConditions");
|
||||
String downloadSize = datas.getString("downloadSize");
|
||||
List<ShowColumsDto> showColumsDtos = JSONArray.parseArray(showColums, ShowColumsDto.class);
|
||||
List<FilterConditionDto> filterConditionDtos = JSONArray.parseArray(filterConditions, FilterConditionDto.class);
|
||||
Map authParamsJson = JSONObject.parseObject(authParams);
|
||||
elogBean.setModule(module);
|
||||
elogBean.setFunction(function);
|
||||
elogBean.setCurrent(pageNum);
|
||||
elogBean.setPageSize(pageSize);
|
||||
elogBean.setSearchMap(searchMap);
|
||||
elogBean.setTransMethod(transMethod);
|
||||
elogBean.setDownloadSize(downloadSize);
|
||||
elogBean.setShowColumns(showColumsDtos);
|
||||
elogBean.setFilterConditionDtos(filterConditionDtos);
|
||||
elogBean.setAuthParamsJson(authParamsJson);
|
||||
return elogBean;
|
||||
}
|
||||
|
||||
public static int getIntValue(String v) {
|
||||
return getIntValue(v, -1);
|
||||
}
|
||||
|
||||
public static int getIntValue(String v, int def) {
|
||||
try {
|
||||
return Integer.parseInt(v);
|
||||
} catch (Exception var3) {
|
||||
return def;
|
||||
}
|
||||
}
|
||||
|
||||
public static long getLongValue(String v) {
|
||||
return getLongValue(v, -1l);
|
||||
}
|
||||
|
||||
public static long getLongValue(String v, long def) {
|
||||
try {
|
||||
return Long.parseLong(v);
|
||||
} catch (Exception var3) {
|
||||
return def;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
|
|
@ -1,528 +0,0 @@
|
|||
package com.engine.salary.elog.util;
|
||||
|
||||
import com.engine.salary.constant.SalaryDefaultTenantConstant;
|
||||
import com.engine.salary.elog.entity.dto.LoggerContext;
|
||||
import com.engine.salary.elog.enums.FromTerminalType;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
import java.util.*;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
import java.util.zip.GZIPOutputStream;
|
||||
|
||||
/**
|
||||
* @Date: 2022/5/18 23:34
|
||||
* @Author: deli.xu
|
||||
* @Description: elog服务工具类
|
||||
**/
|
||||
public class ElogSeviceUtils {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(ElogSeviceUtils.class);
|
||||
|
||||
/*@Autowired
|
||||
private ComInfoCache comInfoCache;
|
||||
private static ComInfoCache baseComInfoCache;
|
||||
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
baseComInfoCache = comInfoCache;
|
||||
}*/
|
||||
|
||||
private static final String TABLE_SPACER = "_";
|
||||
private static final String TABLE_SUFFIX = "logs";
|
||||
private static final String DETAIL_TABLE_SUFFIX = "_detail";
|
||||
public static final String BASE_TABLE = "BASE_ELOG_TABLE";
|
||||
|
||||
|
||||
public static String getTableName(String module, String function) {
|
||||
return getTableName(module, function, false);
|
||||
}
|
||||
|
||||
public static String getTableName(String module, String function, boolean isDetail) {
|
||||
String tablename = module + TABLE_SPACER + function + TABLE_SUFFIX + (isDetail ? DETAIL_TABLE_SUFFIX : "");
|
||||
// SecurityUtil.sqlCheck(tablename);
|
||||
return tablename;
|
||||
}
|
||||
|
||||
/**
|
||||
* String 转枚举
|
||||
*
|
||||
* @param c
|
||||
* @param string
|
||||
* @param <T>
|
||||
* @return
|
||||
*/
|
||||
public static <T extends Enum<T>> T getEnumFromString(Class<T> c, String string) {
|
||||
if (c != null && string != null) {
|
||||
try {
|
||||
return Enum.valueOf(c, string.trim().toUpperCase());
|
||||
} catch (IllegalArgumentException ex) {
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取ip地址
|
||||
*
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
public static String getIp(HttpServletRequest request) {
|
||||
String ipAddress = request.getHeader("x-forwarded-for");
|
||||
String unknown = "unknown";
|
||||
if (ipAddress == null || ipAddress.length() == 0 || unknown.equalsIgnoreCase(ipAddress)) {
|
||||
ipAddress = request.getHeader("Proxy-Client-IP");
|
||||
}
|
||||
if (ipAddress == null || ipAddress.length() == 0 || unknown.equalsIgnoreCase(ipAddress)) {
|
||||
ipAddress = request.getHeader("WL-Proxy-Client-IP");
|
||||
}
|
||||
if (ipAddress == null || ipAddress.length() == 0 || unknown.equalsIgnoreCase(ipAddress)) {
|
||||
ipAddress = request.getRemoteAddr();
|
||||
String benji = "127.0.0.1";
|
||||
String bj = "0:0:0:0:0:0:0:1";
|
||||
if (benji.equals(ipAddress) || bj.equals(ipAddress)) {
|
||||
///根据网卡取本机配置的IP
|
||||
InetAddress inet = null;
|
||||
try {
|
||||
inet = InetAddress.getLocalHost();
|
||||
} catch (UnknownHostException e) {
|
||||
logger.error("UnknownHostException", e);
|
||||
}
|
||||
if (inet != null) {
|
||||
ipAddress = inet.getHostAddress();
|
||||
}
|
||||
}
|
||||
}
|
||||
///对于通过多个代理的情况,第一个IP为客户端真实IP,多个IP按照','分割
|
||||
int i = 15;
|
||||
String s = ",";
|
||||
if (ipAddress != null && ipAddress.length() > i) {
|
||||
if (ipAddress.indexOf(s) > 0) {
|
||||
ipAddress = ipAddress.substring(0, ipAddress.indexOf(","));
|
||||
}
|
||||
}
|
||||
return ipAddress;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取设备信息
|
||||
*
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
public static String getDevice(HttpServletRequest request) {
|
||||
return request.getHeader("User-Agent");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取来自终端的信息
|
||||
*
|
||||
* @param context
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
public static void getFromTerminal(LoggerContext context, HttpServletRequest request) {
|
||||
String fromTerminal = context.getFromTerminal();
|
||||
if (StringUtils.isEmpty(fromTerminal)) {
|
||||
String device = getDevice(request);
|
||||
String setFT = "";
|
||||
if (StringUtils.isNotEmpty(device)) {
|
||||
context.setFromTerminal(getFromTerminal(device));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static String getTraceId(HttpServletRequest request) {
|
||||
String traceId = request.getHeader("traceId");
|
||||
if (StringUtils.isNotBlank(traceId)) {
|
||||
//System.out.println("traceId:====="+traceId);
|
||||
return traceId;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* @param request
|
||||
* @return localhost:9080/api/fs/demo/updateReport
|
||||
*/
|
||||
public static String getRequestUrl(HttpServletRequest request) {
|
||||
if (Objects.isNull(request) || Objects.isNull(request.getRequestURL())) {
|
||||
return null;
|
||||
}
|
||||
return request.getRequestURL().toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param request
|
||||
* @return /api/fs/demo/updateReport
|
||||
*/
|
||||
public static String getRequestUri(HttpServletRequest request) {
|
||||
return request.getRequestURI();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param request
|
||||
* @return GET/POST
|
||||
*/
|
||||
public static String getRequestMethod(HttpServletRequest request) {
|
||||
return request.getMethod();
|
||||
}
|
||||
|
||||
|
||||
// /**
|
||||
// * 获取当前方法中的日志实体类
|
||||
// * @return
|
||||
// */
|
||||
// public static LoggerContext currentElogContext() {
|
||||
// return ElogThreadLocal.currentLoggerContext();
|
||||
// }
|
||||
|
||||
|
||||
public static int getIntValue(String v) {
|
||||
return getIntValue(v, -1);
|
||||
}
|
||||
|
||||
public static int getIntValue(String v, int def) {
|
||||
try {
|
||||
return Integer.parseInt(v);
|
||||
} catch (Exception var3) {
|
||||
return def;
|
||||
}
|
||||
}
|
||||
|
||||
public static long getLongValue(String v) {
|
||||
return getLongValue(v, -1l);
|
||||
}
|
||||
|
||||
public static long getLongValue(String v, long def) {
|
||||
try {
|
||||
return Long.parseLong(v);
|
||||
} catch (Exception var3) {
|
||||
return def;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isLongValue(String v) {
|
||||
try {
|
||||
Long.parseLong(v);
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// /**
|
||||
// * 获取request请求
|
||||
// *
|
||||
// * @return
|
||||
// */
|
||||
// public static HttpServletRequest getRequest() {
|
||||
// return ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
|
||||
// }
|
||||
|
||||
/**
|
||||
* 将对象转换程字符串
|
||||
*
|
||||
* @param obj 目标对象
|
||||
* @param def 如果为null时的默认值
|
||||
* @return
|
||||
*/
|
||||
public static String null2String(Object obj, String def) {
|
||||
return obj == null ? def : obj.toString();
|
||||
}
|
||||
|
||||
public static String null2String(Object obj) {
|
||||
return null2String(obj, "");
|
||||
}
|
||||
|
||||
public static int getIntValue(Object obj, int def) {
|
||||
try {
|
||||
return Integer.parseInt(null2String(obj));
|
||||
} catch (Exception ex) {
|
||||
return def;
|
||||
}
|
||||
}
|
||||
|
||||
// public static Page getPage() {
|
||||
// HttpServletRequest request = getRequest();
|
||||
// String num = request.getParameter("pageNum");
|
||||
// String size = request.getParameter("pageSize");
|
||||
//
|
||||
// Page page = new Page(ElogSeviceUtils.getIntValue(num, 1), ElogSeviceUtils.getIntValue(size, 10));
|
||||
// return page;
|
||||
// }
|
||||
|
||||
// public static void main(String[] args) {
|
||||
// //System.out.println(getTableName("select", "from"));
|
||||
// //DataTypeEnum columnTypeEnum = getEnumFromString(DataTypeEnum.class, "varchar");
|
||||
// }
|
||||
|
||||
public static List switchString(List<Map> list) {
|
||||
if (list != null) {
|
||||
return list.stream().map(m -> {
|
||||
Set<Map.Entry> en = m.entrySet();
|
||||
for (Map.Entry entry : en) {
|
||||
if (entry.getValue() != null) {
|
||||
entry.setValue(String.valueOf(entry.getValue()));
|
||||
}
|
||||
}
|
||||
return m;
|
||||
}).collect(Collectors.toList());
|
||||
} else {
|
||||
return list;
|
||||
}
|
||||
}
|
||||
|
||||
public static List switchComplexString(List<Map> list) {
|
||||
if (list != null) {
|
||||
return list.stream().map(m -> {
|
||||
Iterator<Map.Entry> iterator = m.entrySet().iterator();
|
||||
while (iterator.hasNext()) {
|
||||
Map.Entry next = iterator.next();
|
||||
if (next.getValue() != null) {
|
||||
if (next.getValue() instanceof Map && "parmas".equals(next.getKey())) {
|
||||
next.setValue(String.valueOf(next.getValue()));
|
||||
}
|
||||
if (next.getValue() instanceof List) {
|
||||
} else {
|
||||
next.setValue(String.valueOf(next.getValue()));
|
||||
}
|
||||
}
|
||||
}
|
||||
return m;
|
||||
}).collect(Collectors.toList());
|
||||
} else {
|
||||
return list;
|
||||
}
|
||||
}
|
||||
|
||||
public static String getTenantKey() {
|
||||
return SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY;
|
||||
}
|
||||
|
||||
public static String getEmployeeId() {
|
||||
return "";
|
||||
}
|
||||
|
||||
// public static String getUserName() {
|
||||
//
|
||||
// String employeeId = getEmployeeId();
|
||||
// if (StringUtils.isNotEmpty(employeeId)) {
|
||||
// SimpleEmployee simpleEmployee = null;
|
||||
// try {
|
||||
// HrmCommonUtil hrmCommonUtil = (HrmCommonUtil) ApplicationContextProvider.getBean("hrmCommonUtil");
|
||||
// simpleEmployee = hrmCommonUtil.getSimpleEmployee(ElogSeviceUtils.getLongValue(employeeId));
|
||||
// } catch (Exception e) {
|
||||
// logger.error("Exception", e);
|
||||
// }
|
||||
// if (simpleEmployee != null) {
|
||||
// if (StringUtils.isNotBlank(simpleEmployee.getUsername())) {
|
||||
// return simpleEmployee.getUsername();
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
//
|
||||
// return "";
|
||||
// }
|
||||
|
||||
// /**
|
||||
// * 获取rpc信息(客户端ip和来源设备)
|
||||
// *
|
||||
// * @param context
|
||||
// */
|
||||
// public static void initRpcInfo(LoggerContext context) {
|
||||
// String device = "";
|
||||
// String clientIp = "";
|
||||
// String traceId = "";
|
||||
// try {
|
||||
// device = RpcContext.getContext().getAttachment(EteamsConstant.DEVICE);
|
||||
// clientIp = RpcContext.getContext().getAttachment(EteamsConstant.CLIENT_IP);
|
||||
// traceId = RpcContext.getContext().getAttachment(ApmConstant.TRACE_ID);
|
||||
// logger.info("rpc调用获取到 device:{},clientIp:{},traceId:{}", device, clientIp, traceId);
|
||||
// } catch (Exception e) {
|
||||
// logger.error("Exception", e);
|
||||
// }
|
||||
// if (StringUtils.isEmpty(context.getDevice()) && StringUtils.isNotEmpty(device)) {
|
||||
// context.setDevice(device);
|
||||
// }
|
||||
// if (StringUtils.isEmpty(context.getFromTerminal()) && StringUtils.isNotEmpty(device)) {
|
||||
// context.setFromTerminal(getFromTerminal(device));
|
||||
// }
|
||||
//
|
||||
// if (StringUtils.isEmpty(context.getClientIp()) && StringUtils.isNotEmpty(clientIp)) {
|
||||
// context.setClientIp(clientIp);
|
||||
// }
|
||||
// if (StringUtils.isEmpty(context.getBelongMainId()) && StringUtils.isNotEmpty(traceId)) {
|
||||
// context.setBelongMainId(traceId);
|
||||
// }
|
||||
// }
|
||||
|
||||
public static String getFromTerminal(String device) {
|
||||
String setFT = "";
|
||||
if (StringUtils.isNotEmpty(device)) {
|
||||
if (!device.contains("wxwork") && device.contains("MicroMessenger")) {//来自微信
|
||||
setFT = FromTerminalType.MICO_MSG.getCode();
|
||||
} else if (device.contains("wxwork") && device.contains("MicroMessenger")) {//企业微信
|
||||
setFT = FromTerminalType.WECHAT.getCode();
|
||||
} else if (device.contains("iPhone") && device.contains("Mac")) {//来自 Iphone
|
||||
setFT = FromTerminalType.IOS.getCode();
|
||||
} else if (device.contains("Mac OS") && !device.contains("iPhone") && device.contains("weapp-pc")) {//来自 mac_client
|
||||
setFT = FromTerminalType.MAC_CLIENT.getCode();//mac_client
|
||||
} else if (!device.contains("wxwork") && device.contains("Mobile")) {//移动端
|
||||
setFT = FromTerminalType.H5.getCode();
|
||||
} else if (device.contains("Android") && !device.contains("wxwork")) {//来自安卓 包含安卓并且不包含微信
|
||||
setFT = FromTerminalType.ANDROID.getCode();
|
||||
} else {//pc
|
||||
setFT = FromTerminalType.PC.getCode();
|
||||
}
|
||||
}
|
||||
return setFT;
|
||||
}
|
||||
|
||||
/**
|
||||
* sql连接条件注入sql
|
||||
*
|
||||
* @param condition
|
||||
* @return
|
||||
*/
|
||||
public static String checkConditionSql(String condition) {
|
||||
if ("AND".equalsIgnoreCase(condition) ||
|
||||
"OR".equalsIgnoreCase(condition)
|
||||
) {
|
||||
return condition;
|
||||
}
|
||||
return "AND";
|
||||
}
|
||||
|
||||
public static String checkTypeSql(String type) {
|
||||
if ("LIKE".equalsIgnoreCase(type) ||
|
||||
"IN".equalsIgnoreCase(type) ||
|
||||
"!<>".equalsIgnoreCase(type) ||
|
||||
"!=".equalsIgnoreCase(type) ||
|
||||
"BETWEEN".equalsIgnoreCase(type) ||
|
||||
"IS NULL".equalsIgnoreCase(type) ||
|
||||
"IS NULL".equalsIgnoreCase(type) ||
|
||||
"=".equalsIgnoreCase(type) ||
|
||||
"IS NOT NULL".equalsIgnoreCase(type)) {
|
||||
return type;
|
||||
}
|
||||
return "=";
|
||||
}
|
||||
|
||||
/**
|
||||
* sql条件防止注入
|
||||
*
|
||||
* @param value
|
||||
* @return
|
||||
*/
|
||||
public static String checkValSql(String value) {
|
||||
if (StringUtils.isBlank(value)) {
|
||||
return "";
|
||||
}
|
||||
Pattern p = Pattern.compile("\\s+");
|
||||
Matcher m = p.matcher(value);
|
||||
String val = m.replaceAll(" ");
|
||||
String[] keywords = {"master ", "truncate ", "declare ", "alert ", "create ", "drop ", " version",
|
||||
"show ", "table ", "index ", "insert ", "into ", "from ",
|
||||
"select ", "delete ", "update ", "mid ", "master ", "char ","union "};
|
||||
|
||||
String replaceStr = val.replaceAll(" ", "");
|
||||
if (replaceStr.contains("1=1") || replaceStr.contains(";")) {
|
||||
return "-1";
|
||||
}
|
||||
int count = 0;
|
||||
String filterVal = "";
|
||||
for (String keyddlword : keywords) {
|
||||
if (val.toLowerCase().contains(keyddlword)) {
|
||||
count++;
|
||||
if (count == 1) {
|
||||
filterVal = keyddlword;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (count > 2) {
|
||||
return filterVal;
|
||||
}
|
||||
// value = SecurityUtil.ecodeForSql(value);
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* 压缩工具类-
|
||||
*
|
||||
* @param str
|
||||
* @return desc:version 0.0.1 基于jdk自带 GZIP 压缩。最后转成base64。
|
||||
* 市面上有其他压缩像jdk 的 deflate 可以设置压缩级别,但是都是主动的,需要改业务方法,
|
||||
* snappy 压缩适用于大数据压缩。大数据量比较快 hadoop首选,但是压缩后比例比较大。
|
||||
* xz 下的 压缩比率大,但是解压比较慢-不提倡,空间换时间了
|
||||
* common下的压缩其实和jdk差不多,网上说优于jdk,但是相差不大。
|
||||
* weaver 压缩基于jdk
|
||||
*/
|
||||
public static String compress(String str) {
|
||||
if (str == null || str.trim().length() == 0) {
|
||||
return str;
|
||||
}
|
||||
try (ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
GZIPOutputStream gzip = new GZIPOutputStream(out)) {
|
||||
gzip.write(str.getBytes());
|
||||
gzip.close();
|
||||
return Base64.getEncoder().encodeToString(out.toByteArray());
|
||||
} catch (Exception e) {
|
||||
logger.error("压缩失败", e.getMessage());
|
||||
return str;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 解压缩
|
||||
*
|
||||
* @param str
|
||||
* @return
|
||||
*/
|
||||
public static String uncompress(String str) {
|
||||
byte[] decode = Base64.getDecoder().decode(str);
|
||||
if (str == null || str.trim().length() == 0) {
|
||||
return str;
|
||||
}
|
||||
try (ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
ByteArrayInputStream in = new ByteArrayInputStream(decode)) {
|
||||
GZIPInputStream ungzip = new GZIPInputStream(in);
|
||||
byte[] buffer = new byte[2048];
|
||||
int n;
|
||||
while ((n = ungzip.read(buffer)) >= 0) {
|
||||
out.write(buffer, 0, n);
|
||||
}
|
||||
return new String(out.toByteArray());
|
||||
} catch (Exception e) {
|
||||
logger.error("解缩失败:{}", e.getMessage());
|
||||
return str;
|
||||
}
|
||||
}
|
||||
|
||||
public static Boolean checkIsNumber(Object obj) {
|
||||
if (obj == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return StringUtils.isNumeric(obj.toString());
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -1,713 +0,0 @@
|
|||
package com.engine.salary.elog.util;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.engine.salary.elog.entity.dto.LoggerContext;
|
||||
import com.engine.salary.elog.enums.FromTerminalType;
|
||||
import com.engine.salary.elog.threadlocal.ElogThreadLocal;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.dubbo.common.utils.CollectionUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
import weaver.hrm.User;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
import java.util.*;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
import java.util.zip.GZIPOutputStream;
|
||||
|
||||
/**
|
||||
* @ClassName: ElogUtils
|
||||
* @Description TODO
|
||||
* @Author tanghj
|
||||
* @Date 2021/3/12 14:17
|
||||
*/
|
||||
@Component
|
||||
public class ElogUtils {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(ElogUtils.class);
|
||||
|
||||
|
||||
|
||||
private static final String TABLE_SPACER = "_";
|
||||
private static final String TABLE_SUFFIX = "logs";
|
||||
private static final String DETAIL_TABLE_SUFFIX = "_detail";
|
||||
public static final String BASE_TABLE = "BASE_ELOG_TABLE";
|
||||
|
||||
public String getApplicationName() {
|
||||
return applicationName;
|
||||
}
|
||||
|
||||
public void setApplicationName(String applicationName) {
|
||||
this.applicationName = applicationName;
|
||||
}
|
||||
|
||||
// @Value("${spring.application.name}")
|
||||
public static String applicationName;
|
||||
|
||||
|
||||
|
||||
public static String getTableName(String module, String function) {
|
||||
return getTableName(module, function, false);
|
||||
}
|
||||
|
||||
public static String getTableName(String module, String function, boolean isDetail) {
|
||||
String tablename = module + TABLE_SPACER + function + TABLE_SUFFIX + (isDetail ? DETAIL_TABLE_SUFFIX : "");
|
||||
// SecurityUtil.sqlCheck(tablename);
|
||||
return tablename;
|
||||
}
|
||||
|
||||
/**
|
||||
* String 转枚举
|
||||
*
|
||||
* @param c
|
||||
* @param string
|
||||
* @param <T>
|
||||
* @return
|
||||
*/
|
||||
public static <T extends Enum<T>> T getEnumFromString(Class<T> c, String string) {
|
||||
if (c != null && string != null) {
|
||||
try {
|
||||
return Enum.valueOf(c, string.trim().toUpperCase());
|
||||
} catch (IllegalArgumentException ex) {
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取ip地址
|
||||
*
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
public static String getIp(HttpServletRequest request) {
|
||||
String ipAddress = request.getHeader("x-forwarded-for");
|
||||
String unknown = "unknown";
|
||||
if (ipAddress == null || ipAddress.length() == 0 || unknown.equalsIgnoreCase(ipAddress)) {
|
||||
ipAddress = request.getHeader("Proxy-Client-IP");
|
||||
}
|
||||
if (ipAddress == null || ipAddress.length() == 0 || unknown.equalsIgnoreCase(ipAddress)) {
|
||||
ipAddress = request.getHeader("WL-Proxy-Client-IP");
|
||||
}
|
||||
if (ipAddress == null || ipAddress.length() == 0 || unknown.equalsIgnoreCase(ipAddress)) {
|
||||
ipAddress = request.getRemoteAddr();
|
||||
String benji = "127.0.0.1";
|
||||
String bj = "0:0:0:0:0:0:0:1";
|
||||
if (benji.equals(ipAddress) || bj.equals(ipAddress)) {
|
||||
///根据网卡取本机配置的IP
|
||||
InetAddress inet = null;
|
||||
try {
|
||||
inet = InetAddress.getLocalHost();
|
||||
} catch (UnknownHostException e) {
|
||||
logger.error("UnknownHostException", e);
|
||||
}
|
||||
if (inet != null) {
|
||||
ipAddress = inet.getHostAddress();
|
||||
}
|
||||
}
|
||||
}
|
||||
///对于通过多个代理的情况,第一个IP为客户端真实IP,多个IP按照','分割
|
||||
int i = 15;
|
||||
String s = ",";
|
||||
if (ipAddress != null && ipAddress.length() > i) {
|
||||
if (ipAddress.indexOf(s) > 0) {
|
||||
ipAddress = ipAddress.substring(0, ipAddress.indexOf(","));
|
||||
}
|
||||
}
|
||||
return ipAddress;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取设备信息
|
||||
*
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
public static String getDevice(HttpServletRequest request) {
|
||||
return request.getHeader("User-Agent");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取来自终端的信息
|
||||
*
|
||||
* @param context
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
public static void getFromTerminal(LoggerContext context, HttpServletRequest request) {
|
||||
String fromTerminal = context.getFromTerminal();
|
||||
if (StringUtils.isEmpty(fromTerminal)) {
|
||||
String device = getDevice(request);
|
||||
String setFT = "";
|
||||
if (StringUtils.isNotEmpty(device)) {
|
||||
context.setFromTerminal(getFromTerminal(device));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void initRequestInfo(HttpServletRequest request, LoggerContext context) {
|
||||
if (StringUtils.isEmpty(context.getRequestUrl())) {
|
||||
context.setRequestUrl(getRequestUrl(request));
|
||||
}
|
||||
if (StringUtils.isEmpty(context.getRequestUri())) {
|
||||
context.setRequestUri(getRequestMethod(request) + ":" + getRequestUri(request));
|
||||
}
|
||||
//if (context.getParams() == null) {
|
||||
//默认记录params,此参数给true时 或报表服务,不记录
|
||||
if (!context.getParamsIgnore() && !applicationName.equalsIgnoreCase("weaver-edcreportd-service")) {
|
||||
context.setParams(getRequstParam(request,context));
|
||||
}
|
||||
// }
|
||||
if (StringUtils.isEmpty(context.getClientIp())) {
|
||||
context.setClientIp(getIp(request));
|
||||
}
|
||||
if (StringUtils.isEmpty(context.getDevice())) {
|
||||
context.setDevice(getDevice(request));
|
||||
}
|
||||
if (StringUtils.isEmpty(context.getFromTerminal())) {
|
||||
context.setFromTerminal(getFromTerminal(getDevice(request)));
|
||||
}
|
||||
if (StringUtils.isEmpty(context.getBelongMainId())) {
|
||||
context.setBelongMainId(getTraceId(request));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static String getTraceId(HttpServletRequest request) {
|
||||
String traceId = request.getHeader("traceId");
|
||||
if (StringUtils.isNotBlank(traceId)) {
|
||||
//System.out.println("traceId:====="+traceId);
|
||||
return traceId;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* @param request
|
||||
* @return localhost:9080/api/fs/demo/updateReport
|
||||
*/
|
||||
public static String getRequestUrl(HttpServletRequest request) {
|
||||
if (Objects.isNull(request) || Objects.isNull(request.getRequestURL())) {
|
||||
return null;
|
||||
}
|
||||
return request.getRequestURL().toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param request
|
||||
* @return /api/fs/demo/updateReport
|
||||
*/
|
||||
public static String getRequestUri(HttpServletRequest request) {
|
||||
return request.getRequestURI();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param request
|
||||
* @return GET/POST
|
||||
*/
|
||||
public static String getRequestMethod(HttpServletRequest request) {
|
||||
return request.getMethod();
|
||||
}
|
||||
|
||||
public static Map getRequstParam(HttpServletRequest request, LoggerContext context) {
|
||||
return request2Map(request, context);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前方法中的日志实体类
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static LoggerContext currentElogContext() {
|
||||
return ElogThreadLocal.currentLoggerContext();
|
||||
}
|
||||
|
||||
public static Map<String, Object> request2Map(HttpServletRequest request, LoggerContext context) {
|
||||
// 参数Map
|
||||
Map properties = request.getParameterMap();
|
||||
// 返回值Map
|
||||
Map<String, Object> returnMap = new HashMap<String, Object>();
|
||||
Iterator<Map.Entry> entries = properties.entrySet().iterator();
|
||||
Map.Entry entry;
|
||||
String name = "";
|
||||
Object value = null;
|
||||
while (entries.hasNext()) {
|
||||
entry = (Map.Entry) entries.next();
|
||||
name = (String) entry.getKey();
|
||||
Object valueObj = entry.getValue();
|
||||
if (null == valueObj) {
|
||||
value = null;
|
||||
} else if (valueObj instanceof String[]) {
|
||||
String[] values = (String[]) valueObj;
|
||||
if (values.length == 1) {
|
||||
value = values[0];
|
||||
} else {
|
||||
value = values;
|
||||
}
|
||||
} else {
|
||||
value = valueObj.toString();
|
||||
}
|
||||
returnMap.put(name, value);
|
||||
}
|
||||
//放入ip
|
||||
returnMap.put("param_ip", getIp(request));
|
||||
returnMap.put("request_header_user_agent", request.getHeader("user-agent"));
|
||||
JSONObject body = ElogThreadLocal.getRequestBody();
|
||||
if (body != null) {
|
||||
// returnMap.put("request_body", body);
|
||||
setReturnMapBody(returnMap,context.getParamsBodyKeys(),body);
|
||||
}
|
||||
return returnMap;
|
||||
}
|
||||
|
||||
public static void setReturnMapBody(Map<String, Object> returnMap,List<String> keys,JSONObject body) {
|
||||
//模块没设置则全部记录
|
||||
if (CollectionUtils.isEmpty(keys)) {
|
||||
returnMap.put("request_body", body);
|
||||
}else {
|
||||
JSONObject newBody = new JSONObject();
|
||||
for (String key : keys) {
|
||||
newBody.put(key,body.get(key));
|
||||
}
|
||||
returnMap.put("request_body", newBody);
|
||||
}
|
||||
}
|
||||
|
||||
public static int getIntValue(String v) {
|
||||
return getIntValue(v, -1);
|
||||
}
|
||||
|
||||
public static int getIntValue(String v, int def) {
|
||||
try {
|
||||
return Integer.parseInt(v);
|
||||
} catch (Exception var3) {
|
||||
return def;
|
||||
}
|
||||
}
|
||||
|
||||
public static long getLongValue(String v) {
|
||||
return getLongValue(v, -1l);
|
||||
}
|
||||
|
||||
public static long getLongValue(String v, long def) {
|
||||
try {
|
||||
return Long.parseLong(v);
|
||||
} catch (Exception var3) {
|
||||
return def;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 将对象转换程字符串
|
||||
*
|
||||
* @param obj 目标对象
|
||||
* @param def 如果为null时的默认值
|
||||
* @return
|
||||
*/
|
||||
public static String null2String(Object obj, String def) {
|
||||
return obj == null ? def : obj.toString();
|
||||
}
|
||||
|
||||
public static String null2String(Object obj) {
|
||||
return null2String(obj, "");
|
||||
}
|
||||
|
||||
public static int getIntValue(Object obj, int def) {
|
||||
try {
|
||||
return Integer.parseInt(null2String(obj));
|
||||
} catch (Exception ex) {
|
||||
return def;
|
||||
}
|
||||
}
|
||||
|
||||
// public static Page getPage() {
|
||||
// HttpServletRequest request = getRequest();
|
||||
// String num = request.getParameter("pageNum");
|
||||
// String size = request.getParameter("pageSize");
|
||||
//
|
||||
// Page page = new Page(ElogUtils.getIntValue(num, 1), ElogUtils.getIntValue(size, 10));
|
||||
// return page;
|
||||
// }
|
||||
|
||||
// public static void main(String[] args) {
|
||||
// //System.out.println(getTableName("select", "from"));
|
||||
// //DataTypeEnum columnTypeEnum = getEnumFromString(DataTypeEnum.class, "varchar");
|
||||
// }
|
||||
|
||||
public static List switchString(List<Map> list) {
|
||||
if (list != null) {
|
||||
return list.stream().map(m -> {
|
||||
Set<Map.Entry> en = m.entrySet();
|
||||
for (Map.Entry entry : en) {
|
||||
if (entry.getValue() != null) {
|
||||
entry.setValue(String.valueOf(entry.getValue()));
|
||||
}
|
||||
}
|
||||
return m;
|
||||
}).collect(Collectors.toList());
|
||||
} else {
|
||||
return list;
|
||||
}
|
||||
}
|
||||
|
||||
public static List switchComplexString(List<Map> list) {
|
||||
if (list != null) {
|
||||
return list.stream().map(m -> {
|
||||
Iterator<Map.Entry> iterator = m.entrySet().iterator();
|
||||
while (iterator.hasNext()) {
|
||||
Map.Entry next = iterator.next();
|
||||
if (next.getValue() != null) {
|
||||
if (next.getValue() instanceof Map && "parmas".equals(next.getKey())) {
|
||||
next.setValue(String.valueOf(next.getValue()));
|
||||
}
|
||||
if (next.getValue() instanceof List) {
|
||||
} else {
|
||||
next.setValue(String.valueOf(next.getValue()));
|
||||
}
|
||||
}
|
||||
}
|
||||
return m;
|
||||
}).collect(Collectors.toList());
|
||||
} else {
|
||||
return list;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取rpc信息(客户端ip和来源设备)
|
||||
*
|
||||
* @param context
|
||||
*/
|
||||
public static void initRpcInfo(LoggerContext context) {
|
||||
User user = context.getUser();
|
||||
if(user == null){
|
||||
return;
|
||||
}
|
||||
String device = user.getLogintype();
|
||||
String clientIp = user.getLoginip();
|
||||
String traceId = "";
|
||||
if (StringUtils.isEmpty(context.getDevice()) && StringUtils.isNotEmpty(device)) {
|
||||
context.setDevice(device);
|
||||
}
|
||||
if (StringUtils.isEmpty(context.getFromTerminal()) && StringUtils.isNotEmpty(device)) {
|
||||
context.setFromTerminal(getFromTerminal(device));
|
||||
}
|
||||
|
||||
if (StringUtils.isEmpty(context.getClientIp()) && StringUtils.isNotEmpty(clientIp)) {
|
||||
context.setClientIp(clientIp);
|
||||
}
|
||||
if (StringUtils.isEmpty(context.getBelongMainId()) && StringUtils.isNotEmpty(traceId)) {
|
||||
context.setBelongMainId(traceId);
|
||||
}
|
||||
}
|
||||
|
||||
public static String getFromTerminal(String device) {
|
||||
String setFT = "";
|
||||
if (StringUtils.isNotEmpty(device)) {
|
||||
if (!device.contains("wxwork") && device.contains("MicroMessenger")) {//来自微信
|
||||
setFT = FromTerminalType.MICO_MSG.getCode();
|
||||
} else if (device.contains("wxwork") && device.contains("MicroMessenger")) {//企业微信
|
||||
setFT = FromTerminalType.WECHAT.getCode();
|
||||
} else if (device.contains("iPhone") && device.contains("Mac")) {//来自 Iphone
|
||||
setFT = FromTerminalType.IOS.getCode();
|
||||
} else if (device.contains("Mac OS") && !device.contains("iPhone") && device.contains("weapp-pc")) {//来自 mac_client
|
||||
setFT = FromTerminalType.MAC_CLIENT.getCode();//mac_client
|
||||
} else if (!device.contains("wxwork") && device.contains("Mobile")) {//移动端
|
||||
setFT = FromTerminalType.H5.getCode();
|
||||
} else if (device.contains("Android") && !device.contains("wxwork")) {//来自安卓 包含安卓并且不包含微信
|
||||
setFT = FromTerminalType.ANDROID.getCode();
|
||||
} else {//pc
|
||||
setFT = FromTerminalType.PC.getCode();
|
||||
}
|
||||
}
|
||||
return setFT;
|
||||
}
|
||||
|
||||
/**
|
||||
* sql连接条件注入sql
|
||||
*
|
||||
* @param condition
|
||||
* @return
|
||||
*/
|
||||
public static String checkConditionSql(String condition) {
|
||||
if ("AND".equalsIgnoreCase(condition) ||
|
||||
"OR".equalsIgnoreCase(condition)
|
||||
) {
|
||||
return condition;
|
||||
}
|
||||
return "AND";
|
||||
}
|
||||
|
||||
public static String checkTypeSql(String type) {
|
||||
if ("LIKE".equalsIgnoreCase(type) ||
|
||||
"IN".equalsIgnoreCase(type) ||
|
||||
"!<>".equalsIgnoreCase(type) ||
|
||||
"!=".equalsIgnoreCase(type) ||
|
||||
"BETWEEN".equalsIgnoreCase(type) ||
|
||||
"IS NULL".equalsIgnoreCase(type) ||
|
||||
"IS NULL".equalsIgnoreCase(type) ||
|
||||
"=".equalsIgnoreCase(type) ||
|
||||
"IS NOT NULL".equalsIgnoreCase(type)) {
|
||||
return type;
|
||||
}
|
||||
return "=";
|
||||
}
|
||||
|
||||
/**
|
||||
* sql条件防止注入
|
||||
*
|
||||
* @param value
|
||||
* @return
|
||||
*/
|
||||
public static String checkValSql(String value) {
|
||||
Pattern p = Pattern.compile("\\s+");
|
||||
Matcher m = p.matcher(value);
|
||||
String val = m.replaceAll(" ");
|
||||
String[] keywords = {"master", "truncate", "declare", "alert", "create", "drop", "version",
|
||||
"show", "table", "index", "insert", "into", "from",
|
||||
"insert", "select", "delete", "update", "chr", "mid", "master", "truncate", "char", "declare", "union"};
|
||||
|
||||
|
||||
int count = 0;
|
||||
String filterVal = "";
|
||||
for (String keyddlword : keywords) {
|
||||
if (val.toLowerCase().contains(keyddlword)) {
|
||||
count++;
|
||||
if (count == 1) {
|
||||
filterVal = keyddlword;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (count > 2) {
|
||||
return filterVal;
|
||||
}
|
||||
// value = SecurityUtil.ecodeForSql(value);
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* 压缩工具类-
|
||||
*
|
||||
* @param str
|
||||
* @return desc:version 0.0.1 基于jdk自带 GZIP 压缩。最后转成base64。
|
||||
* 市面上有其他压缩像jdk 的 deflate 可以设置压缩级别,但是都是主动的,需要改业务方法,
|
||||
* snappy 压缩适用于大数据压缩。大数据量比较快 hadoop首选,但是压缩后比例比较大。
|
||||
* xz 下的 压缩比率大,但是解压比较慢-不提倡,空间换时间了
|
||||
* common下的压缩其实和jdk差不多,网上说优于jdk,但是相差不大。
|
||||
* weaver 压缩基于jdk
|
||||
*/
|
||||
public static String compress(String str) {
|
||||
if (str == null || str.trim().length() == 0) {
|
||||
return str;
|
||||
}
|
||||
try (ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
GZIPOutputStream gzip = new GZIPOutputStream(out)) {
|
||||
gzip.write(str.getBytes());
|
||||
gzip.close();
|
||||
return Base64.getEncoder().encodeToString(out.toByteArray());
|
||||
} catch (Exception e) {
|
||||
logger.error("压缩失败", e.getMessage());
|
||||
return str;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 解压缩
|
||||
*
|
||||
* @param str
|
||||
* @return
|
||||
*/
|
||||
public static String uncompress(String str) {
|
||||
byte[] decode = Base64.getDecoder().decode(str);
|
||||
if (str == null || str.trim().length() == 0) {
|
||||
return str;
|
||||
}
|
||||
try (ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
ByteArrayInputStream in = new ByteArrayInputStream(decode)) {
|
||||
GZIPInputStream ungzip = new GZIPInputStream(in);
|
||||
byte[] buffer = new byte[2048];
|
||||
int n;
|
||||
while ((n = ungzip.read(buffer)) >= 0) {
|
||||
out.write(buffer, 0, n);
|
||||
}
|
||||
return new String(out.toByteArray());
|
||||
} catch (Exception e) {
|
||||
logger.error("解缩失败:{}", e.getMessage());
|
||||
return str;
|
||||
}
|
||||
}
|
||||
|
||||
public static <T> LoggerContext<T> getEsField(LoggerContext<T> context, String field) {
|
||||
|
||||
switch (field.toLowerCase()) {
|
||||
case "interfacename":
|
||||
context.setInterfaceName("");
|
||||
break;
|
||||
case "operatetype":
|
||||
context.setOperateType("");
|
||||
break;
|
||||
case "operatedesc":
|
||||
context.setOperatedesc("");
|
||||
break;
|
||||
case "params":
|
||||
context.setParamsStr("ES");
|
||||
break;
|
||||
case "clientip":
|
||||
context.setClientIp("");
|
||||
break;
|
||||
case "groupnamelabel":
|
||||
context.setGroupNameLabel("");
|
||||
break;
|
||||
case "redoservice":
|
||||
context.setRedoService("");
|
||||
break;
|
||||
case "redocontext":
|
||||
context.setRedoContextStr("");
|
||||
break;
|
||||
case "cancelservice":
|
||||
context.setCancelService("");
|
||||
break;
|
||||
case "cancelcontext":
|
||||
context.setCancelContextStr("");
|
||||
break;
|
||||
case "device":
|
||||
context.setDevice("");
|
||||
break;
|
||||
case "groupid":
|
||||
context.setGroupId("");
|
||||
break;
|
||||
case "belongmainid":
|
||||
context.setBelongMainId("");
|
||||
break;
|
||||
case "requesturl":
|
||||
context.setRequestUrl("");
|
||||
break;
|
||||
case "requesturi":
|
||||
context.setRequestUri("");
|
||||
break;
|
||||
case "log_result":
|
||||
context.setResult("");
|
||||
break;
|
||||
case "fromterminal":
|
||||
context.setFromTerminal("");
|
||||
break;
|
||||
case "resultdesc":
|
||||
context.setResultDesc("");
|
||||
break;
|
||||
case "old_content":
|
||||
context.setOld_content("");
|
||||
break;
|
||||
case "link_type":
|
||||
context.setLink_type("");
|
||||
break;
|
||||
}
|
||||
|
||||
return context;
|
||||
}
|
||||
|
||||
public static String[] getESfields(String value) {
|
||||
String[] split = value.split(",");
|
||||
List<String> list = new ArrayList<>();
|
||||
for (String s : split) {
|
||||
switch (s.toLowerCase()) {
|
||||
case "interfacename":
|
||||
list.add("interfacename");
|
||||
break;
|
||||
case "operatetype":
|
||||
list.add("operatetype");
|
||||
break;
|
||||
case "operatedesc":
|
||||
list.add("operatedesc");
|
||||
break;
|
||||
case "params":
|
||||
list.add("params");
|
||||
break;
|
||||
case "clientip":
|
||||
list.add("clientip");
|
||||
break;
|
||||
case "groupnamelabel":
|
||||
list.add("groupnamelabel");
|
||||
break;
|
||||
case "redoservice":
|
||||
list.add("redoservice");
|
||||
break;
|
||||
case "redocontext":
|
||||
list.add("redocontext");
|
||||
break;
|
||||
case "cancelservice":
|
||||
list.add("cancelservice");
|
||||
break;
|
||||
case "cancelcontext":
|
||||
list.add("cancelcontext");
|
||||
break;
|
||||
case "device":
|
||||
list.add("device");
|
||||
break;
|
||||
case "groupid":
|
||||
list.add("groupid");
|
||||
break;
|
||||
case "belongmainid":
|
||||
list.add("belongmainid");
|
||||
break;
|
||||
case "requesturl":
|
||||
list.add("requesturl");
|
||||
break;
|
||||
case "requesturi":
|
||||
list.add("requesturi");
|
||||
break;
|
||||
case "log_result":
|
||||
list.add("logResult");
|
||||
break;
|
||||
case "fromterminal":
|
||||
list.add("fromterminal");
|
||||
break;
|
||||
case "resultdesc":
|
||||
list.add("resultdesc");
|
||||
break;
|
||||
case "old_content":
|
||||
list.add("oldContent");
|
||||
break;
|
||||
case "link_type":
|
||||
list.add("linkType");
|
||||
break;
|
||||
}
|
||||
}
|
||||
//list转为数组
|
||||
if (list.size() > 0) {
|
||||
String[] strings = list.toArray(new String[list.size()]);
|
||||
return strings;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static String handleClobColumn(String value) {
|
||||
// 处理超长字符串,oracle插入报错ORA-01704: string literal too long
|
||||
if (StringUtils.isBlank(value)){
|
||||
return "";
|
||||
}
|
||||
StringBuilder formatValue = new StringBuilder();
|
||||
String[] split = StrUtil.split(value, 1000);
|
||||
for (int i = 0; i < split.length; i++) {
|
||||
formatValue.append("TO_CLOB('").append(split[i]).append("')");
|
||||
if (i != split.length - 1) {
|
||||
formatValue.append("||");
|
||||
}
|
||||
}
|
||||
return formatValue.toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,94 +0,0 @@
|
|||
package com.engine.salary.elog.util;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @ClassName: FieldNameMap
|
||||
* @Description TODO
|
||||
* @Author tanghj
|
||||
* @Date 2021/3/31 14:27
|
||||
*/
|
||||
public class FieldNameMap {
|
||||
|
||||
private static Map<String, String> mainFieldNameMap = new HashMap<>();
|
||||
|
||||
private static Map<String, String> detailFieldNameMap = new HashMap<>();
|
||||
|
||||
private static Map<String, Map<String, String>> mainCusFieldNameMap = new HashMap<>();
|
||||
|
||||
private static Map<String, Map<String, String>> detailCusFieldNameMap = new HashMap<>();
|
||||
|
||||
|
||||
public static void setMainFieldName(Map<String, String> fieldNameMap) {
|
||||
mainFieldNameMap.putAll(fieldNameMap);
|
||||
}
|
||||
|
||||
public static void setDetailFieldName(Map<String, String> fieldNameMap) {
|
||||
detailFieldNameMap.putAll(fieldNameMap);
|
||||
}
|
||||
|
||||
public static void setMainCusFieldName(String module, String function, Map<String, String> fieldNameMap) {
|
||||
mainCusFieldNameMap.put(getKey(module, function), fieldNameMap);
|
||||
}
|
||||
|
||||
public static void setDetailCusFieldName(String module, String function, Map<String, String> fieldNameMap) {
|
||||
detailCusFieldNameMap.put(getKey(module, function), fieldNameMap);
|
||||
}
|
||||
|
||||
|
||||
public static String getMainFieldNameMap(String module, String function, String key) {
|
||||
|
||||
String str = key.toLowerCase();
|
||||
if(mainFieldNameMap.containsKey(str)) {
|
||||
return StringUtils.isNotEmpty(mainFieldNameMap.get(str)) ? mainFieldNameMap.get(str) : key;
|
||||
} else {
|
||||
return getMainCusFieldNameMap(module, function,key);
|
||||
}
|
||||
}
|
||||
|
||||
public static String getDetailFieldNameMap(String module, String function, String key) {
|
||||
key = key.toLowerCase();
|
||||
if(detailFieldNameMap.containsKey(key)) {
|
||||
return StringUtils.isNotEmpty(detailFieldNameMap.get(key)) ? detailFieldNameMap.get(key) : key;
|
||||
} else {
|
||||
return getDetailCusFieldNameMap(module, function, key);
|
||||
}
|
||||
}
|
||||
|
||||
public static String getMainCusFieldNameMap(String module, String function, String key) {
|
||||
|
||||
if(mainCusFieldNameMap.containsKey(getKey(module, function))) {
|
||||
if(mainCusFieldNameMap.get(getKey(module, function)).containsKey(key)) {
|
||||
return StringUtils.isNotEmpty(mainCusFieldNameMap.get(getKey(module, function)).get(key)) ?
|
||||
mainCusFieldNameMap.get(getKey(module, function)).get(key) :
|
||||
key;
|
||||
} else {
|
||||
return key;
|
||||
}
|
||||
} else {
|
||||
return key;
|
||||
}
|
||||
}
|
||||
|
||||
public static String getDetailCusFieldNameMap(String module, String function, String key) {
|
||||
|
||||
if(detailCusFieldNameMap.containsKey(getKey(module, function))) {
|
||||
if(detailCusFieldNameMap.get(getKey(module, function)).containsKey(key)) {
|
||||
return StringUtils.isNotEmpty(detailCusFieldNameMap.get(getKey(module, function)).get(key)) ?
|
||||
detailCusFieldNameMap.get(getKey(module, function)).get(key) :
|
||||
key;
|
||||
} else {
|
||||
return key;
|
||||
}
|
||||
} else {
|
||||
return key;
|
||||
}
|
||||
}
|
||||
|
||||
private static String getKey(String module, String function) {
|
||||
return module + "@" + function;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,630 +0,0 @@
|
|||
package com.engine.salary.elog.util;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.alibaba.fastjson.parser.Feature;
|
||||
import com.alibaba.fastjson.serializer.SerializerFeature;
|
||||
import com.engine.salary.constant.SalaryDefaultTenantConstant;
|
||||
import com.engine.salary.elog.annotation.ElogTransform;
|
||||
import com.engine.salary.elog.async.LoggerMessageListener;
|
||||
import com.engine.salary.elog.entity.dto.LoggerContext;
|
||||
import com.engine.salary.elog.entity.dto.LoggerDetailContext;
|
||||
import com.engine.salary.elog.entity.dto.TableChangeBean;
|
||||
import com.engine.salary.util.db.IdGenerator;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import weaver.hrm.User;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @ClassName: LoggerTemplate
|
||||
* @Description 日志基本功能类
|
||||
* @Author tanghj
|
||||
* @Date 2021/2/10 14:18
|
||||
*/
|
||||
//@Component
|
||||
public class LoggerTemplate {
|
||||
protected String function = "common";
|
||||
|
||||
protected String module;
|
||||
|
||||
protected String logCenterQueue = "Elog_cneterlogQueue";
|
||||
|
||||
public static final String AUDITLOGQUEUE = "AuditLog";
|
||||
public static final String ELOG = "Elog";
|
||||
|
||||
protected String localQueue;
|
||||
|
||||
protected String moduleName;
|
||||
|
||||
protected static String applicationName;
|
||||
|
||||
public void setApplicationName(String applicationName) {
|
||||
LoggerTemplate.applicationName = applicationName;
|
||||
}
|
||||
|
||||
public String getApplicationName() {
|
||||
return applicationName;
|
||||
}
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(LoggerTemplate.class);
|
||||
|
||||
protected static String publishkitGroup;
|
||||
|
||||
public void setPublishkitGroup(String publishkitGroup) {
|
||||
LoggerTemplate.publishkitGroup = publishkitGroup;
|
||||
}
|
||||
|
||||
public String getPublishkitGroup() {
|
||||
return publishkitGroup;
|
||||
}
|
||||
|
||||
|
||||
LoggerMessageListener loggerMessageListener = new LoggerMessageListener();
|
||||
|
||||
/**
|
||||
* 写入日志消息队列
|
||||
*
|
||||
* @param context 日志实体
|
||||
*/
|
||||
public void write(LoggerContext context) {
|
||||
this.write(context, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 写入日志消息队列
|
||||
*
|
||||
* @param context 日志实体
|
||||
* @param isLocal true 存储本地, false不存储本地
|
||||
*/
|
||||
public void write(LoggerContext context, boolean isLocal) {
|
||||
String elogLocalQueue = ELOG + this.applicationName;
|
||||
if (StringUtils.isEmpty(this.localQueue))
|
||||
this.localQueue = (StringUtils.isNotEmpty(this.moduleName) ? this.moduleName : elogLocalQueue) + "LocalQueue" + this.publishkitGroup;
|
||||
try {
|
||||
handleContext(context);
|
||||
} catch (Exception e) {
|
||||
logger.error("handleContext方法异常!{}", e.getMessage(), e);
|
||||
}
|
||||
loggerMessageListener.receiveold(context);
|
||||
|
||||
}
|
||||
|
||||
// public void writeLocal(LoggerContext context){
|
||||
// String elogLocalQueue = ELOG + this.applicationName;
|
||||
// if(StringUtils.isEmpty(this.localQueue))
|
||||
// this.localQueue = (StringUtils.isNotEmpty(this.moduleName) ? this.moduleName : elogLocalQueue) + "LocalQueue" + this.publishkitGroup;
|
||||
// AsyncBean<LoggerContext> asyncBean = new AsyncBean<>();
|
||||
// handleContext(context);
|
||||
// if (context.getWeakElogReocrd() && CollectionUtils.isEmpty(context.getDetailContexts() )) {
|
||||
// logger.info("日志弱控且没有明细记录,不记录日志,modulename:{},functionname:{}",context.getModuleName(),context.getFunctionName());
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// try {
|
||||
// asyncBean.setMessage(context);
|
||||
// asyncBean.setQueue(localQueue);
|
||||
// asyncClient.send(asyncBean);
|
||||
// } catch (Exception e) {
|
||||
// logger.error("发送writeLocal-mq消息异常!{}",e.getMessage(),e);
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
// public void checkAsyncBean(AsyncBean asyncBean) {
|
||||
// int length = JSON.toJSON(asyncBean).toString().getBytes(StandardCharsets.UTF_8).length / 1000;
|
||||
// boolean checkPass = length <= 5120;
|
||||
// if (!checkPass)
|
||||
// throw new RuntimeException("消息体超出5M,不支持发送!");
|
||||
// }
|
||||
|
||||
// /**
|
||||
// * 没有明细变化可以不写入日志
|
||||
// * @param context 日志信息
|
||||
// * @param isLocal 是否写入本地
|
||||
// * @param notChangeDetailSendLog 没有明细变化不写入日志
|
||||
// */
|
||||
// public void write(LoggerContext context, boolean isLocal,boolean notChangeDetailSendLog){
|
||||
// String elogLocalQueue = ELOG + this.applicationName;
|
||||
// if(StringUtils.isEmpty(this.localQueue))
|
||||
// this.localQueue = (StringUtils.isNotEmpty(this.moduleName) ? this.moduleName : elogLocalQueue) + "LocalQueue";
|
||||
// AsyncBean<LoggerContext> asyncBean = new AsyncBean<>();
|
||||
// handleContext(context);
|
||||
//
|
||||
// if (notChangeDetailSendLog && (context.getDetailContexts() == null || context.getDetailContexts().size() == 0)) {
|
||||
// return;
|
||||
// }
|
||||
// try {
|
||||
// asyncBean.setMessage(context);
|
||||
// asyncBean.setQueue(logCenterQueue);
|
||||
// asyncClient.send(asyncBean);
|
||||
// writeHrmLog(context);
|
||||
// if(isLocal) {
|
||||
// asyncBean.setQueue(localQueue);
|
||||
// asyncClient.send(asyncBean);
|
||||
// }
|
||||
// } catch (Exception e) {
|
||||
// logger.error("发送mq消息异常!{}",e.getMessage(),e);
|
||||
// }
|
||||
//
|
||||
// }
|
||||
|
||||
// /**
|
||||
// * 支持了向其他模块服务发送业务日志
|
||||
// * @param context
|
||||
// * @param isLocal
|
||||
// * @param moduleName
|
||||
// */
|
||||
// public void write(LoggerContext context, boolean isLocal, String moduleName){
|
||||
//
|
||||
// if(StringUtils.isNotEmpty(moduleName)) {
|
||||
// String localQueue = moduleName + "LocalQueue";
|
||||
// // context.setModuleName(moduleName);
|
||||
// AsyncBean<LoggerContext> asyncBean = new AsyncBean<>();
|
||||
// handleContext(context);
|
||||
// try {
|
||||
// asyncBean.setMessage(context);
|
||||
// asyncBean.setQueue(logCenterQueue);
|
||||
// asyncClient.send(asyncBean);
|
||||
// writeHrmLog(context);
|
||||
// if(isLocal) {
|
||||
// asyncBean.setQueue(localQueue);
|
||||
// asyncClient.send(asyncBean);
|
||||
// }
|
||||
// } catch (Exception e) {
|
||||
// logger.error("发送mq消息异常!:{}",e.getMessage());
|
||||
// }
|
||||
// } else {
|
||||
// write(context, isLocal);
|
||||
// }
|
||||
//
|
||||
// }
|
||||
|
||||
// public void writeHrmLog(LoggerContext context) {
|
||||
// AsyncBean<LoggerContext> asyncBean = new AsyncBean<>();
|
||||
// handleContext(context);
|
||||
// asyncBean.setMessage(context);
|
||||
// //asyncBean.setTopic(WRITEAUDITLOGTOPIC);
|
||||
// asyncBean.setQueue(AUDITLOGQUEUE);
|
||||
// asyncClient.send(asyncBean);
|
||||
//
|
||||
// }
|
||||
|
||||
// /**
|
||||
// * 支持了向其他模块服务发送业务日志
|
||||
// * @param context
|
||||
// * @param isLocal
|
||||
// * @param moduleName
|
||||
// */
|
||||
// public void write(LoggerContext context, boolean isLocal, String moduleName,String functionName,String queueName){
|
||||
//
|
||||
// if (StringUtils.isNotEmpty(moduleName) && StringUtils.isNotEmpty(functionName)) {
|
||||
// context.setModuleName(moduleName);
|
||||
// context.setFunctionName(functionName);
|
||||
// this.localQueue = queueName + "LocalQueue";
|
||||
// AsyncBean<LoggerContext> asyncBean = new AsyncBean<>();
|
||||
// handleContext(context);
|
||||
// try {
|
||||
// asyncBean.setMessage(context);
|
||||
// asyncBean.setQueue(logCenterQueue);
|
||||
// asyncClient.send(asyncBean);
|
||||
// writeHrmLog(context);
|
||||
// if (isLocal) {
|
||||
// asyncBean.setQueue(localQueue);
|
||||
// asyncClient.send(asyncBean);
|
||||
// }
|
||||
// } catch (Exception e) {
|
||||
// logger.error("发送mq消息异常!,{}!",e);
|
||||
// }
|
||||
// } else {
|
||||
// write(context, isLocal);
|
||||
// }
|
||||
//
|
||||
// }
|
||||
|
||||
private void handleContext(LoggerContext context) {
|
||||
if (StringUtils.isEmpty(context.getModuleName()))
|
||||
context.setModuleName(module);
|
||||
if (StringUtils.isEmpty(context.getFunctionName()))
|
||||
context.setFunctionName(function);
|
||||
if (!(context.getId() > 0))
|
||||
context.setId(IdGenerator.generate());
|
||||
if (StringUtils.isEmpty(context.getUuid())) {
|
||||
context.setUuid(UUID.randomUUID().toString().replace("-", ""));
|
||||
}
|
||||
|
||||
context.setTempParams(null);
|
||||
String employeeId = Optional.ofNullable(context.getUser()).map(User::getUID).orElse(0).toString();
|
||||
String tenantKey = SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY;
|
||||
String userName = Optional.ofNullable(context.getUser()).map(User::getUsername).orElse("").toString();
|
||||
if (StringUtils.isEmpty(context.getOperator()) && StringUtils.isNotEmpty(employeeId)) {
|
||||
context.setOperator(employeeId + "");
|
||||
}
|
||||
if (StringUtils.isEmpty(context.getTenant_key()) && StringUtils.isNotEmpty(tenantKey)) {
|
||||
context.setTenant_key(tenantKey);
|
||||
}
|
||||
if (StringUtils.isEmpty(context.getOperatorName()) && StringUtils.isNotEmpty(userName)) {
|
||||
context.setOperatorName(userName);
|
||||
}
|
||||
//}
|
||||
|
||||
if (StringUtils.isBlank(context.getOperator()) || "null".equals(context.getOperator())) {
|
||||
context.setOperator("-1");
|
||||
}
|
||||
if (StringUtils.isBlank(context.getTargetId()) || "null".equals(context.getTargetId())) {
|
||||
context.setTargetId("-1");
|
||||
}
|
||||
|
||||
// RequestAttributes requestAttributes = SalaryContext.get().getRequestAttributesSafely();
|
||||
// if ((requestAttributes instanceof ServletRequestAttributes)) {
|
||||
// HttpServletRequest request = ((ServletRequestAttributes) requestAttributes).getRequest();
|
||||
// ElogUtils.initRequestInfo(request, context);
|
||||
// } else {
|
||||
// if (StringUtils.isEmpty(context.getRequestUrl())) {
|
||||
// context.setRequestUrl("非http请求");
|
||||
// }
|
||||
// ElogUtils.initRpcInfo(context);
|
||||
// }
|
||||
ElogUtils.initRpcInfo(context);
|
||||
|
||||
List<TableChangeBean> changeBeans = context.getChangeValues();
|
||||
|
||||
List<LoggerDetailContext> valueChangeList = new ArrayList<>();
|
||||
int showOrder = 0;
|
||||
if (changeBeans != null)
|
||||
for (TableChangeBean changeBean : changeBeans) {
|
||||
if (changeBean != null && (changeBean.getNewValue() != null || changeBean.getOldValue() != null)) {
|
||||
String uuid = UUID.randomUUID().toString().replace("-", "");
|
||||
ApiModel apiModel = null;
|
||||
ElogTransform tableTransform = null;
|
||||
JSONObject newJo = new JSONObject();
|
||||
JSONObject oldJo = new JSONObject();
|
||||
JSONObject valueChange = JSONObject.parseObject(JSONObject.toJSONString(changeBean, SerializerFeature.WriteDateUseDateFormat), Feature.OrderedField);
|
||||
Field[] fields = null;
|
||||
if (changeBean.getNewValue() != null) {
|
||||
apiModel = changeBean.getNewValue().getClass().getAnnotation(ApiModel.class);
|
||||
tableTransform = changeBean.getNewValue().getClass().getAnnotation(ElogTransform.class);
|
||||
//fields = changeBean.getNewValue().getClass().getDeclaredFields();
|
||||
fields = getAllFields(changeBean.getNewValue().getClass());
|
||||
newJo = valueChange.getJSONObject("newValue");
|
||||
} else {
|
||||
apiModel = changeBean.getOldValue().getClass().getAnnotation(ApiModel.class);
|
||||
tableTransform = changeBean.getOldValue().getClass().getAnnotation(ElogTransform.class);
|
||||
//fields = changeBean.getOldValue().getClass().getDeclaredFields();
|
||||
fields = getAllFields(changeBean.getOldValue().getClass());
|
||||
}
|
||||
if (changeBean.getOldValue() != null) {
|
||||
oldJo = valueChange.getJSONObject("oldValue");
|
||||
}
|
||||
if ((apiModel != null || tableTransform != null) && fields != null) {
|
||||
|
||||
for (Field field : fields) {
|
||||
if (StringUtils.isEmpty(newJo.getString(field.getName())) && StringUtils.isEmpty(oldJo.getString(field.getName()))) {
|
||||
continue;
|
||||
}
|
||||
if (StringUtils.isNotEmpty(newJo.getString(field.getName())) && newJo.getString(field.getName()).equals(oldJo.getString(field.getName()))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
ApiModelProperty apiModelProperty = field.getAnnotation(ApiModelProperty.class);
|
||||
ElogTransform fieldElogTransform = field.getAnnotation(ElogTransform.class);
|
||||
LoggerDetailContext valueChangeBean = new LoggerDetailContext();
|
||||
if (fieldElogTransform != null && fieldElogTransform.ignore()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
//todo 若analyticList为true 且 新旧值属于JSONArray 解析List<T>
|
||||
if (fieldElogTransform != null && fieldElogTransform.analyticList() && fieldElogTransform.analyticListClass() != void.class) {
|
||||
analyticListMethod(field, newJo, oldJo, valueChangeList, fieldElogTransform);
|
||||
continue;
|
||||
}
|
||||
|
||||
valueChangeBean.setUuid(uuid);
|
||||
valueChangeBean.setTableName(tableTransform != null && StringUtils.isNotEmpty(tableTransform.name()) ? tableTransform.name() : changeBean.getTableName());
|
||||
valueChangeBean.setTableNameDesc(tableTransform != null && StringUtils.isNotEmpty(tableTransform.tablename()) ? tableTransform.tablename() : "");
|
||||
valueChangeBean.setTableNameLabelId(tableTransform != null && tableTransform.labelId() != -1 ? tableTransform.labelId() + "" : "");
|
||||
valueChangeBean.setIsDetail(changeBean.getIsDetail());
|
||||
valueChangeBean.setFieldName(field.getName());
|
||||
valueChangeBean.setFieldDesc(fieldElogTransform != null ? fieldElogTransform.name() : apiModelProperty != null ? apiModelProperty.value() : field.getName());
|
||||
valueChangeBean.setFieldNameLabelId(fieldElogTransform != null ? fieldElogTransform.labelId() + "" : "-1");
|
||||
valueChangeBean.setDataid(StringUtils.isNotEmpty(changeBean.getDataid()) ? changeBean.getDataid() :
|
||||
StringUtils.isNoneEmpty(newJo.getString("id")) ? newJo.getString("id") : oldJo.getString("id"));
|
||||
valueChangeBean.setBelongDataid(StringUtils.isNotEmpty(changeBean.getBelongDataid()) ? changeBean.getBelongDataid() : "");
|
||||
|
||||
valueChangeBean.setNewValue(newJo.getString(field.getName()));
|
||||
valueChangeBean.setOldValue(oldJo.getString(field.getName()));
|
||||
valueChangeBean.setCreator(-1l);
|
||||
try {
|
||||
extracted(newJo, oldJo, field, fieldElogTransform, valueChangeBean);
|
||||
} catch (Exception e) {
|
||||
logger.error("转换出错:{}", e);
|
||||
//System.out.println("转换出错:" + e.getMessage());
|
||||
}
|
||||
|
||||
|
||||
valueChangeBean.setShoworder(showOrder++);
|
||||
valueChangeList.add(valueChangeBean);
|
||||
}
|
||||
} else {
|
||||
Set<String> keys = new HashSet<>();
|
||||
for (String key : (Set<String>) newJo.keySet()) {
|
||||
keys.add(key);
|
||||
if (newJo.getString(key).equals(oldJo.getString(key))) {
|
||||
continue;
|
||||
}
|
||||
LoggerDetailContext valueChangeBean = new LoggerDetailContext();
|
||||
valueChangeBean.setUuid(uuid);
|
||||
valueChangeBean.setTableName(changeBean.getTableName());
|
||||
valueChangeBean.setIsDetail(changeBean.getIsDetail());
|
||||
valueChangeBean.setDataid(StringUtils.isNotEmpty(changeBean.getDataid()) ? changeBean.getDataid() :
|
||||
StringUtils.isNoneEmpty(newJo.getString("id")) ? newJo.getString("id") : oldJo.getString("id"));
|
||||
valueChangeBean.setBelongDataid(StringUtils.isNotEmpty(changeBean.getBelongDataid()) ? changeBean.getBelongDataid() : "");
|
||||
valueChangeBean.setFieldName(key);
|
||||
valueChangeBean.setFieldDesc(key);
|
||||
valueChangeBean.setNewValue(newJo.getString(key));
|
||||
valueChangeBean.setOldValue(oldJo.getString(key));
|
||||
valueChangeBean.setShoworder(showOrder++);
|
||||
valueChangeBean.setCreator(-1l);
|
||||
valueChangeList.add(valueChangeBean);
|
||||
}
|
||||
for (String key : (Set<String>) oldJo.keySet()) {
|
||||
if (keys.contains(key))
|
||||
continue;
|
||||
keys.add(key);
|
||||
if (oldJo.getString(key).equals(newJo.getString(key))) {
|
||||
continue;
|
||||
}
|
||||
LoggerDetailContext valueChangeBean = new LoggerDetailContext();
|
||||
valueChangeBean.setTableName(changeBean.getTableName());
|
||||
valueChangeBean.setIsDetail(changeBean.getIsDetail());
|
||||
valueChangeBean.setFieldName(key);
|
||||
valueChangeBean.setFieldDesc(key);
|
||||
valueChangeBean.setNewValue(newJo.getString(key));
|
||||
valueChangeBean.setOldValue(oldJo.getString(key));
|
||||
valueChangeBean.setShoworder(showOrder++);
|
||||
valueChangeBean.setCreator(-1l);
|
||||
valueChangeList.add(valueChangeBean);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (valueChangeList.size() > 0)
|
||||
context.setDetailContexts(valueChangeList);
|
||||
}
|
||||
|
||||
|
||||
private void analyticListMethod(Field field, JSONObject newJo, JSONObject oldJo, List<LoggerDetailContext> valueChangeList, ElogTransform tableTransform) {
|
||||
JSONArray newValueArr = newJo.get(field.getName()) == null ? new JSONArray() : (JSONArray) newJo.get(field.getName());
|
||||
JSONArray oldvalueArr = oldJo.get(field.getName()) == null ? new JSONArray() : (JSONArray) oldJo.get(field.getName());
|
||||
Field[] allFields = getAllFields(tableTransform.analyticListClass());
|
||||
|
||||
|
||||
Boolean oldvalueIsNull = false;
|
||||
Boolean newvalueIsNull = false;
|
||||
|
||||
if (oldvalueArr.size() == 0) {
|
||||
oldvalueIsNull = true;
|
||||
}
|
||||
if (newValueArr.size() == 0) {
|
||||
newvalueIsNull = true;
|
||||
}
|
||||
if ((oldvalueIsNull && newvalueIsNull) || (!oldvalueIsNull && !newvalueIsNull && oldvalueArr.size() != newValueArr.size())) {
|
||||
//如果新、旧没值或新旧值list数量对不上 直接返回
|
||||
return;
|
||||
}
|
||||
|
||||
JSONArray foreachArr = oldvalueIsNull ? newValueArr : oldvalueArr;
|
||||
|
||||
//遍历list
|
||||
for (int i = 0; i < foreachArr.size(); i++) {
|
||||
//默认另一个list关系是一一对应的
|
||||
JSONObject oldValue = oldvalueIsNull ? new JSONObject() : (JSONObject) oldvalueArr.get(i);
|
||||
JSONObject newValue = newvalueIsNull ? new JSONObject() : (JSONObject) newValueArr.get(i);
|
||||
|
||||
//dataid uuid showOrder
|
||||
long dataid = IdGenerator.generate();
|
||||
String uuid = UUID.randomUUID().toString().replace("-", "");
|
||||
int showOrder = 0;
|
||||
|
||||
//遍历字段
|
||||
for (Field allField : allFields) {
|
||||
if (StringUtils.isEmpty(newValue.getString(allField.getName())) && StringUtils.isEmpty(oldValue.getString(allField.getName()))) {
|
||||
continue;
|
||||
}
|
||||
if (StringUtils.isNotEmpty(newValue.getString(allField.getName())) && newValue.getString(allField.getName()).equals(oldValue.getString(allField.getName()))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
ApiModelProperty apiModelProperty = allField.getAnnotation(ApiModelProperty.class);
|
||||
ElogTransform fieldElogTransform = allField.getAnnotation(ElogTransform.class);
|
||||
LoggerDetailContext valueChangeBean = new LoggerDetailContext();
|
||||
|
||||
valueChangeBean.setUuid(uuid);
|
||||
valueChangeBean.setTableName(tableTransform != null && StringUtils.isNotEmpty(tableTransform.name()) ? tableTransform.name() : field.getName());
|
||||
valueChangeBean.setTableNameDesc(tableTransform != null && StringUtils.isNotEmpty(tableTransform.tablename()) ? tableTransform.tablename() : "");
|
||||
valueChangeBean.setTableNameLabelId(tableTransform != null && tableTransform.labelId() != -1 ? tableTransform.labelId() + "" : "");
|
||||
valueChangeBean.setIsDetail(1);
|
||||
valueChangeBean.setFieldName(allField.getName());
|
||||
valueChangeBean.setNewValue(newValue.getString(allField.getName()));
|
||||
valueChangeBean.setOldValue(oldValue.getString(allField.getName()));
|
||||
valueChangeBean.setCreator(-1l);
|
||||
valueChangeBean.setBelongDataid("");
|
||||
valueChangeBean.setDataid(String.valueOf(dataid));
|
||||
|
||||
if (fieldElogTransform != null) {
|
||||
if (fieldElogTransform.ignore()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
valueChangeBean.setFieldDesc(fieldElogTransform != null ? fieldElogTransform.name() : apiModelProperty != null ? apiModelProperty.value() : field.getName());
|
||||
valueChangeBean.setFieldNameLabelId(fieldElogTransform != null ? fieldElogTransform.labelId() + "" : "-1");
|
||||
|
||||
try {
|
||||
extracted(newValue, oldValue, allField, fieldElogTransform, valueChangeBean);
|
||||
} catch (Exception e) {
|
||||
logger.error("转换出错", e);
|
||||
//System.out.println("转换出错:" + e.getMessage());
|
||||
}
|
||||
|
||||
valueChangeBean.setShoworder(showOrder++);
|
||||
} else {
|
||||
valueChangeBean.setFieldDesc(allField.getName());
|
||||
valueChangeBean.setShoworder(showOrder++);
|
||||
|
||||
}
|
||||
valueChangeList.add(valueChangeBean);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void extracted(JSONObject newJo, JSONObject oldJo, Field field, ElogTransform fieldElogTransform, LoggerDetailContext valueChangeBean) {
|
||||
JSONObject jo = null;
|
||||
if (fieldElogTransform != null && StringUtils.isNotEmpty(fieldElogTransform.valuesKVPairs())) {
|
||||
jo = JSONObject.parseObject(fieldElogTransform.valuesKVPairs());
|
||||
if (jo != null) {
|
||||
valueChangeBean.setNewRealValue(jo.getString(newJo.getString(field.getName())));
|
||||
valueChangeBean.setOldRealValue(jo.getString(oldJo.getString(field.getName())));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setModuleName(String moduleName) {
|
||||
this.moduleName = moduleName;
|
||||
}
|
||||
|
||||
public void setLocalQueue(String localQueue) {
|
||||
this.localQueue = localQueue;
|
||||
}
|
||||
|
||||
public String getFunction() {
|
||||
return function;
|
||||
}
|
||||
|
||||
public void setFunction(String function) {
|
||||
this.function = function;
|
||||
}
|
||||
|
||||
public String getModule() {
|
||||
return module;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取日志实体类
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public LoggerContext getContext() {
|
||||
|
||||
LoggerContext loggerContext = new LoggerContext();
|
||||
loggerContext.setUuid(UUID.randomUUID().toString().replace("-", ""));
|
||||
loggerContext.setModuleName(this.module);
|
||||
loggerContext.setFunctionName(this.function);
|
||||
|
||||
return loggerContext;
|
||||
|
||||
}
|
||||
|
||||
public void setModule(String module) {
|
||||
this.module = module;
|
||||
}
|
||||
|
||||
// public void setAsyncClient(AsyncClient asyncClient) {
|
||||
// this.asyncClient = asyncClient;
|
||||
// }
|
||||
|
||||
|
||||
public static Field[] getAllFields(Class obj) {
|
||||
Class superclass = obj.getSuperclass();
|
||||
Field[] superField = null;
|
||||
//获取父类
|
||||
if (superclass != Object.class) {
|
||||
superField = superclass.getDeclaredFields();
|
||||
}
|
||||
//获取当前类
|
||||
Field[] nowfield = obj.getDeclaredFields();
|
||||
return addFields(superField, nowfield);
|
||||
}
|
||||
|
||||
public static Field[] addFields(Field[] superFields, Field[] fields) {
|
||||
|
||||
return ArrayUtils.addAll(superFields, fields);
|
||||
|
||||
}
|
||||
|
||||
public void write(List<LoggerContext> context, boolean isLocal) {
|
||||
context.forEach(loggerContext -> {
|
||||
this.write(loggerContext, isLocal);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public void write(List<LoggerContext> context) {
|
||||
context.forEach(loggerContext -> {
|
||||
this.write(loggerContext);
|
||||
});
|
||||
}
|
||||
|
||||
// public void writeAsync(LoggerContext context, boolean isLocal){
|
||||
// String applicationNameBak = this.applicationName;
|
||||
// String localQueueBak = this.localQueue;
|
||||
// String moduleNameBak = this.moduleName;
|
||||
// String pk = this.publishkitGroup;
|
||||
// LocalRunnable localRunnable = new LocalRunnable() {
|
||||
// @Override
|
||||
// public void execute() {
|
||||
// String localQueueBakBak = localQueueBak;
|
||||
// String elogLocalQueue = ELOG + applicationNameBak;
|
||||
// if(StringUtils.isEmpty(localQueueBakBak))
|
||||
// localQueueBakBak = (StringUtils.isNotEmpty(moduleNameBak) ? moduleNameBak : elogLocalQueue) + "LocalQueue" + pk;
|
||||
// AsyncBean<LoggerContext> asyncBean = new AsyncBean<>();
|
||||
// handleContext(context);
|
||||
// if (context.getWeakElogReocrd() && CollectionUtils.isEmpty(context.getDetailContexts() )) {
|
||||
// logger.info("日志弱控且没有明细记录,不记录日志,modulename:{},functionname:{}",context.getModuleName(),context.getFunctionName());
|
||||
// return;
|
||||
// }
|
||||
// try {
|
||||
// asyncBean.setMessage(context);
|
||||
// asyncBean.setQueue(logCenterQueue);
|
||||
// checkAsyncBean(asyncBean);//检查消息体大小
|
||||
// asyncClient.send(asyncBean);
|
||||
// writeHrmLog(context);
|
||||
// if(isLocal) {
|
||||
// asyncBean.setQueue(localQueueBakBak);
|
||||
// asyncClient.send(asyncBean);
|
||||
// }
|
||||
// } catch (Exception e) {
|
||||
// logger.error("发送mq消息异常!{}",e.getMessage(),e);
|
||||
// }
|
||||
// }
|
||||
// };
|
||||
// ThreadPoolUtil.fixedPoolExecute(ModulePoolEnum.OTHER, "LoggerTemplate_writeAsync", localRunnable);
|
||||
//
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 回滚队列
|
||||
// *
|
||||
// * @param context
|
||||
// */
|
||||
// public void writeRollBack(LoggerContext context){
|
||||
// String elogRollBackQueue = ELOG + this.applicationName + "RollBackQueue" + this.publishkitGroup;
|
||||
// AsyncBean<LoggerContext> asyncBean = new AsyncBean<>();
|
||||
//
|
||||
// try {
|
||||
// asyncBean.setMessage(context);
|
||||
// asyncBean.setQueue(elogRollBackQueue);
|
||||
// checkAsyncBean(asyncBean);//检查消息体大小
|
||||
// asyncClient.send(asyncBean);
|
||||
// } catch (Exception e) {
|
||||
// logger.error("发送mq消息异常!{}",e.getMessage(),e);
|
||||
// }
|
||||
// }
|
||||
|
||||
}
|
||||
|
|
@ -1,21 +0,0 @@
|
|||
package com.engine.salary.elog.util;
|
||||
|
||||
/**
|
||||
* @ClassName: LoggerTemplateBuilder
|
||||
* @Description 日志基本类构造器
|
||||
* @Author tanghj
|
||||
* @Date 2021/2/10 14:18
|
||||
*/
|
||||
public class LoggerTemplateBuilder {
|
||||
|
||||
public static LoggerTemplate build(String module){
|
||||
return build(module, "common");
|
||||
}
|
||||
public static LoggerTemplate build(String module, String function){
|
||||
LoggerTemplate loggerTemplate = new LoggerTemplate();
|
||||
loggerTemplate.setFunction(function);
|
||||
loggerTemplate.setModule(module);
|
||||
|
||||
return loggerTemplate;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,200 +0,0 @@
|
|||
package com.engine.salary.elog.web;
|
||||
|
||||
import com.engine.common.util.ServiceUtil;
|
||||
import com.engine.salary.elog.entity.param.ELogGetLogParam;
|
||||
import com.engine.salary.elog.entity.param.GetDetailChangesParam;
|
||||
import com.engine.salary.elog.service.ILoggerTableService;
|
||||
import com.engine.salary.elog.service.impl.LoggerTableService;
|
||||
import com.engine.salary.util.ResponseResult;
|
||||
import com.engine.salary.util.page.PageInfo;
|
||||
import io.swagger.v3.oas.annotations.parameters.RequestBody;
|
||||
import weaver.hrm.HrmUserVarify;
|
||||
import weaver.hrm.User;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.core.Context;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class LoggerTableController {
|
||||
|
||||
private ILoggerTableService getLoggerTableService(User user) {
|
||||
return ServiceUtil.getService(LoggerTableService.class, user);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取日志
|
||||
*
|
||||
* @param request
|
||||
* @param response
|
||||
* @param data
|
||||
* @return
|
||||
*/
|
||||
@POST
|
||||
@Path("/getLogs")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
public String getLogs(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody String data) {
|
||||
User user = HrmUserVarify.getUser(request, response);
|
||||
return new ResponseResult<String, PageInfo>(user).run(getLoggerTableService(user)::queryLogs, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取日志(卡片)
|
||||
*
|
||||
* @param request
|
||||
* @param response
|
||||
* @param data
|
||||
* @return
|
||||
*/
|
||||
@POST
|
||||
@Path("/getCardLogs")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
public String carddatas(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody String data) {
|
||||
User user = HrmUserVarify.getUser(request, response);
|
||||
return new ResponseResult<String, List<Map<String, Object>>>(user).run(getLoggerTableService(user)::queryCardLogList, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取单条操作记录的更新明细
|
||||
* @param request
|
||||
* @param response
|
||||
* @param param
|
||||
* @return
|
||||
*/
|
||||
@POST
|
||||
@Path("/getDetailChanges")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
public String getDetailChanges(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody GetDetailChangesParam param) {
|
||||
User user = HrmUserVarify.getUser(request, response);
|
||||
return new ResponseResult<GetDetailChangesParam, List>(user).run(getLoggerTableService(user)::getDetailChanges, param);
|
||||
}
|
||||
// @ApiOperation("获取单条操作记录的更新明细")
|
||||
// @POST
|
||||
// @Path("/getDetailChanges")
|
||||
// @Produces(MediaType.APPLICATION_JSON)
|
||||
// public String getDetailChanges(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody String data) {
|
||||
// User user = HrmUserVarify.getUser(request, response);
|
||||
// return new ResponseResult<String, List<Map<String, Object>>>(user).run(getLoggerTableService(user)::getDetailChanges, data);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 获取单条操作记录的更新明细(分页)
|
||||
// *
|
||||
// * @param module 服务(模块)名
|
||||
// * @param function 方法名
|
||||
// * @param mainid 主键id
|
||||
// * @param detailTransMethod 转换方法
|
||||
// * @param current 页码
|
||||
// * @param pageSize 每页条数
|
||||
// * @return WeaTable
|
||||
// */
|
||||
// @ApiOperation("获取单条操作记录的更新明细(分页)")
|
||||
// @RequestMapping(path = "getDetailChangePages", method = {RequestMethod.GET, RequestMethod.POST})
|
||||
// @WeaPermission(publicPermission = true)
|
||||
// public WeaResult<WeaTable> getDetailChangePages(@PathVariable("module") @ApiParam("服务(模块)名") String module,
|
||||
// @PathVariable("function") @ApiParam("方法名") String function,
|
||||
// @RequestParam("mainid") @ApiParam("主键id") String mainid,
|
||||
// @RequestParam("detailTransMethod") @ApiParam("转换方法") String detailTransMethod,
|
||||
// @RequestParam("page") @ApiParam("页码") String current,
|
||||
// @RequestParam("pageSize") @ApiParam("每页条数") String pageSize) {
|
||||
// return WeaResult.success(getLoggerTableService(user).getDetailChangePages(module, function, mainid, detailTransMethod, current, pageSize));
|
||||
// }
|
||||
|
||||
/**
|
||||
* 获取日志列表
|
||||
*
|
||||
* @param request
|
||||
* @param response
|
||||
* @param param
|
||||
* @return
|
||||
*/
|
||||
@POST
|
||||
@Path("/datas")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
public String datas(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody ELogGetLogParam param) {
|
||||
User user = HrmUserVarify.getUser(request, response);
|
||||
return new ResponseResult<ELogGetLogParam, List>(user).run(getLoggerTableService(user)::queryLogList, param);
|
||||
}
|
||||
|
||||
|
||||
// @ApiOperation("获取日志总数")
|
||||
// @RequestMapping(path = "counts", method = {RequestMethod.GET, RequestMethod.POST})
|
||||
// @WeaPermission(publicPermission = true)
|
||||
// public WeaResult<Map<String, Object>> counts(@PathVariable("module") @ApiParam("服务(模块)名") String module,
|
||||
// @PathVariable("function") @ApiParam("方法名") String function) {
|
||||
// return WeaResult.success(getLoggerTableService(user).countLog(module, function), "success");
|
||||
// }
|
||||
//
|
||||
// @ApiOperation("获取明细日志列表")
|
||||
// @RequestMapping(path = "detaildatas", method = {RequestMethod.GET, RequestMethod.POST})
|
||||
// @WeaPermission(publicPermission = true)
|
||||
// public WeaResult<List<Map<String, Object>>> detaildatas(@PathVariable("module") @ApiParam("服务(模块)名") String module,
|
||||
// @PathVariable("function") @ApiParam("方法名") String function,
|
||||
// @Param("pageSize") @ApiParam("每页多少数据") String pageSize,
|
||||
// @Param("current") @ApiParam("当前页") String current,
|
||||
// @Param("mainId") @ApiParam("主表id") String mainId,
|
||||
// @ApiParam("查询条件") String condition) {
|
||||
//
|
||||
// if ("datasecurity".equals(module) && "auditLog".equals(function)) {
|
||||
// try {
|
||||
// ILoggerTableService tableService = ApplicationContextProvider.getBean("auditLogService", ILoggerTableService.class);
|
||||
// if (tableService != null) {
|
||||
// List<Map<String, Object>> list = tableService.queryDetailLogList(module, function, current, pageSize, condition, mainId);
|
||||
// return WeaResult.success(list);
|
||||
// }
|
||||
// } catch (Exception e) {
|
||||
//
|
||||
// }
|
||||
// }
|
||||
// List<Map<String, Object>> list = getLoggerTableService(user).queryDetailLogList(module, function, current, pageSize, condition, mainId);
|
||||
// return WeaResult.success(list);
|
||||
// }
|
||||
//
|
||||
// @ApiOperation("获取日志总数")
|
||||
// @RequestMapping(path = "detailcounts", method = {RequestMethod.GET, RequestMethod.POST})
|
||||
// @WeaPermission(publicPermission = true)
|
||||
// public WeaResult<Map<String, Object>> detailcounts(@PathVariable("module") @ApiParam("服务(模块)名") String module,
|
||||
// @PathVariable("function") @ApiParam("方法名") String function,
|
||||
// @Param("mainId") @ApiParam("主表id") String mainId) {
|
||||
// return WeaResult.success(getLoggerTableService(user).countDestailLog(module, function, mainId), "success");
|
||||
// }
|
||||
//
|
||||
// @ApiOperation("根据traceId获取链路列表")
|
||||
// @RequestMapping(path = "queryLogTraceInfo", method = {RequestMethod.GET, RequestMethod.POST})
|
||||
// @WeaPermission(publicPermission = true)
|
||||
// public WeaResult<WeaTable> queryLogTraceInfo(@PathVariable("module") @ApiParam("服务(模块)名") String module,
|
||||
// @PathVariable("function") @ApiParam("方法名") String function,
|
||||
// @Param("traceId") @ApiParam("traceId") String traceId,
|
||||
// @Param("currentPage") @ApiParam("currentPage") Integer currentPage,
|
||||
// @Param("pageSize") @ApiParam("pageSize") Integer pageSize,
|
||||
// @Param("traceTransMethod") @ApiParam("traceTransMethod") String traceTransMethod
|
||||
// ) {
|
||||
//
|
||||
// if ("datasecurity".equals(module) && "auditLog".equals(function)) {
|
||||
// try {
|
||||
// ILoggerTableService tableService = ApplicationContextProvider.getBean("auditLogService", ILoggerTableService.class);
|
||||
// if (tableService != null) {
|
||||
// return WeaResult.success(tableService.queryElogTraceInfo(traceId, module, function, currentPage, pageSize, traceTransMethod), "success");
|
||||
// }
|
||||
// } catch (Exception e) {
|
||||
//
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// return WeaResult.success(getLoggerTableService(user).queryElogTraceInfo(traceId, module, function, currentPage, pageSize, traceTransMethod), "success");
|
||||
// }
|
||||
//
|
||||
// @ApiOperation("日志下载")
|
||||
// @RequestMapping(path = "downloadLog", method = {RequestMethod.GET, RequestMethod.POST})
|
||||
// @WeaPermission(publicPermission = true)
|
||||
// public WeaResult<BatchDocumentMessage> downloadLog(@RequestBody(required = false) @ApiParam("数据") String data) {
|
||||
//
|
||||
// BatchDocumentMessage message = getLoggerTableService(user).downloadLog(data);
|
||||
// return WeaResult.success(message);
|
||||
// }
|
||||
}
|
||||
|
|
@ -1,30 +0,0 @@
|
|||
package com.engine.salary.mapper.elog;
|
||||
|
||||
import com.engine.salary.elog.entity.dto.TableColumnBean;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
public interface ElogTableCheckerMapper {
|
||||
Long getVersion(@Param("mainTable") String mainTable);
|
||||
|
||||
void recordVersion(@Param("id") long id, @Param("mainTable") String mainTable, @Param("version") long version);
|
||||
|
||||
void createMainTable(@Param("mainTable") String mainTable);
|
||||
|
||||
void createDetailTable(@Param("detailTable") String detailTable);
|
||||
|
||||
List<TableColumnBean> getTableStructure(@Param("tableName") String tableName);
|
||||
|
||||
void createElogTable(@Param("createElogSql") String createElogSql);
|
||||
|
||||
Map getTableIndex(@Param("tableName") String tableName, @Param("columnName") String columnName);
|
||||
|
||||
Map getDataBase();
|
||||
|
||||
void createTableIndex(@Param("tableName") String tableName, @Param("columnName") String columnName, @Param("id") long id);
|
||||
|
||||
List<String> getAllExistTables(@Param("tableNames") Set<String> tables);
|
||||
}
|
||||
|
|
@ -1,451 +0,0 @@
|
|||
<?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.engine.salary.mapper.elog.ElogTableCheckerMapper">
|
||||
<insert id="recordVersion">
|
||||
insert into hrsa_elog_version (id, maintable, version) values (#{id},#{mainTable},#{version})
|
||||
</insert>
|
||||
<select id="getVersion" resultType="java.lang.Long">
|
||||
select version from hrsa_elog_version where maintable = #{mainTable}
|
||||
</select>
|
||||
<update id="createMainTable">
|
||||
create table ${mainTable}
|
||||
(
|
||||
id bigint comment 'ID',
|
||||
create_time datetime default current_timestamp ,
|
||||
update_time datetime default current_timestamp ,
|
||||
creator bigint,
|
||||
delete_type int,
|
||||
tenant_key varchar(10),
|
||||
uuid char(36),
|
||||
log_date datetime default current_timestamp ,
|
||||
log_operator varchar(50),
|
||||
operatorName varchar(50),
|
||||
targetId varchar(50),
|
||||
targetName text,
|
||||
modulename varchar(100),
|
||||
functionname varchar(100),
|
||||
interfaceName varchar(100),
|
||||
requesturl varchar(200),
|
||||
requesturi varchar(200),
|
||||
operateType varchar(50),
|
||||
operatetypename varchar(100),
|
||||
operatedesc varchar(1000),
|
||||
params longtext,
|
||||
belongmainid varchar(36),
|
||||
clientIp varchar(50),
|
||||
groupid varchar(50),
|
||||
device varchar(200),
|
||||
groupNameLabel varchar(500),
|
||||
redoService varchar(200),
|
||||
redoContext longtext,
|
||||
cancelService varchar(200),
|
||||
cancelContext longtext,
|
||||
totalruntime bigint,
|
||||
mainruntime bigint,
|
||||
log_result varchar(100),
|
||||
fromterminal varchar(100),
|
||||
resultdesc text,
|
||||
old_content varchar(1000),
|
||||
link_type varchar(20),
|
||||
link_id bigint,
|
||||
old_link_id bigint,
|
||||
PRIMARY KEY (id)
|
||||
)
|
||||
</update>
|
||||
<update id="createMainTable" databaseId="oracle">
|
||||
|
||||
create table ${mainTable}
|
||||
(
|
||||
id number(*,0) not null primary key,
|
||||
create_time date default sysdate,
|
||||
update_time date default sysdate,
|
||||
creator number(*,0),
|
||||
delete_type number(*,0),
|
||||
tenant_key varchar2(10),
|
||||
uuid varchar2(36),
|
||||
log_date date default sysdate,
|
||||
log_operator varchar2(50),
|
||||
operatorName varchar2(50),
|
||||
targetId varchar2(50),
|
||||
targetName varchar2(4000),
|
||||
modulename varchar2(100),
|
||||
functionname varchar2(100),
|
||||
interfaceName varchar2(100),
|
||||
requesturl varchar2(200),
|
||||
requesturi varchar2(200),
|
||||
operateType varchar2(50),
|
||||
operatetypename varchar2(100),
|
||||
operatedesc varchar2(1000),
|
||||
params clob,
|
||||
belongmainid varchar2(36),
|
||||
clientIp varchar2(200),
|
||||
groupid varchar2(50),
|
||||
device varchar2(200),
|
||||
groupNameLabel varchar2(500),
|
||||
redoService varchar2(200),
|
||||
redoContext varchar2(4000),
|
||||
cancelService varchar2(200),
|
||||
cancelContext varchar2(4000),
|
||||
totalruntime number(*,0),
|
||||
mainruntime number(*,0),
|
||||
log_result varchar2(4000),
|
||||
fromterminal varchar2(100),
|
||||
resultdesc varchar2(4000),
|
||||
old_content varchar2(1000),
|
||||
link_type varchar2(20),
|
||||
link_id number(*,0),
|
||||
old_link_id number(*,0)
|
||||
)
|
||||
</update>
|
||||
<update id="createMainTable" databaseId="sqlserver">
|
||||
create table ${mainTable}
|
||||
(
|
||||
id bigint not null primary key,
|
||||
create_time datetime default getdate(),
|
||||
update_time datetime default getdate(),
|
||||
creator bigint default '-1',
|
||||
delete_type bigint default 0,
|
||||
tenant_key nvarchar(10),
|
||||
uuid nvarchar(36),
|
||||
log_date datetime default getdate(),
|
||||
device nvarchar(500),
|
||||
log_operator bigint default '-1',
|
||||
operatorname nvarchar(100),
|
||||
targetid bigint default '-1',
|
||||
targetname nvarchar(3000),
|
||||
modulename nvarchar(100),
|
||||
functionname nvarchar(100),
|
||||
interfacename nvarchar(100),
|
||||
requesturl nvarchar(200),
|
||||
requesturi nvarchar(200),
|
||||
operatetype nvarchar(50),
|
||||
operatetypename nvarchar(100),
|
||||
operatedesc nvarchar(3000),
|
||||
params nvarchar(max),
|
||||
belongmainid nvarchar(36),
|
||||
clientip nvarchar(200),
|
||||
groupid nvarchar(50),
|
||||
groupnamelabel nvarchar(1000),
|
||||
redoservice nvarchar(200),
|
||||
redocontext nvarchar(3000),
|
||||
cancelservice nvarchar(200),
|
||||
cancelcontext nvarchar(3000),
|
||||
totalruntime bigint default 0,
|
||||
mainruntime bigint default 0,
|
||||
log_result nvarchar(100),
|
||||
fromterminal nvarchar(100),
|
||||
resultdesc nvarchar(3000),
|
||||
old_content nvarchar(3000),
|
||||
link_type nvarchar(20),
|
||||
link_id bigint default 0,
|
||||
old_link_id bigint default 0
|
||||
)
|
||||
</update>
|
||||
<update id="createMainTable" databaseId="postgresql">
|
||||
create table ${mainTable}
|
||||
(
|
||||
id int8 not null primary key,
|
||||
create_time timestamp default current_timestamp,
|
||||
update_time timestamp default current_timestamp,
|
||||
creator int8,
|
||||
delete_type int,
|
||||
tenant_key varchar(10),
|
||||
uuid varchar(36),
|
||||
log_date timestamp default current_timestamp,
|
||||
log_operator varchar(50),
|
||||
operatorName varchar(50),
|
||||
targetId varchar(50),
|
||||
targetName text,
|
||||
modulename varchar(100),
|
||||
functionname varchar(100),
|
||||
interfaceName varchar(100),
|
||||
requesturl varchar(200),
|
||||
requesturi varchar(200),
|
||||
operateType varchar(50),
|
||||
operatetypename varchar(100),
|
||||
operatedesc varchar(1000),
|
||||
params text,
|
||||
belongmainid varchar(36),
|
||||
clientIp varchar(200),
|
||||
groupid varchar(50),
|
||||
device varchar(200),
|
||||
groupNameLabel varchar(500),
|
||||
redoService varchar(200),
|
||||
redoContext text,
|
||||
cancelService varchar(200),
|
||||
cancelContext text,
|
||||
totalruntime int4,
|
||||
mainruntime int4,
|
||||
log_result varchar(100),
|
||||
fromterminal varchar(100),
|
||||
resultdesc text,
|
||||
old_content varchar(1000),
|
||||
link_type varchar(20),
|
||||
link_id int4,
|
||||
old_link_id int4
|
||||
)
|
||||
</update>
|
||||
<update id="createDetailTable">
|
||||
create table ${detailTable}
|
||||
(
|
||||
id bigint not null primary key,
|
||||
create_time datetime default current_timestamp ,
|
||||
update_time datetime default current_timestamp ,
|
||||
creator bigint,
|
||||
delete_type int,
|
||||
tenant_key varchar(10),
|
||||
uuid varchar(36),
|
||||
mainid varchar(36),
|
||||
dataid varchar(50),
|
||||
belongdataid varchar(50),
|
||||
tableName varchar(200),
|
||||
tablenamelabelid varchar(50),
|
||||
tablenamedesc varchar(50),
|
||||
fieldName varchar(200),
|
||||
fieldnamelabelid varchar(200),
|
||||
newValue longtext,
|
||||
oldValue longtext,
|
||||
newrealvalue longtext,
|
||||
oldrealvalue longtext,
|
||||
fieldDesc varchar(200),
|
||||
showorder int default 0,
|
||||
isdetail int default 0
|
||||
)
|
||||
</update>
|
||||
<update id="createDetailTable" databaseId="postgresql">
|
||||
create table ${detailTable}
|
||||
(
|
||||
id int8 not null primary key,
|
||||
create_time timestamp default current_timestamp ,
|
||||
update_time timestamp default current_timestamp ,
|
||||
creator int8,
|
||||
delete_type int8,
|
||||
tenant_key varchar(10),
|
||||
uuid varchar(36),
|
||||
mainid varchar(36),
|
||||
dataid varchar(50),
|
||||
belongdataid varchar(50),
|
||||
tableName varchar(200),
|
||||
tablenamelabelid varchar(50),
|
||||
tablenamedesc varchar(50),
|
||||
fieldName varchar(200),
|
||||
fieldnamelabelid varchar(200),
|
||||
newValue text,
|
||||
oldValue text,
|
||||
newrealvalue text,
|
||||
oldrealvalue text,
|
||||
fieldDesc varchar(200),
|
||||
showorder int8 default 0,
|
||||
isdetail int8 default 0
|
||||
)
|
||||
</update>
|
||||
<update id="createDetailTable" databaseId="oracle">
|
||||
create table ${detailTable}
|
||||
(
|
||||
id number(*,0) not null primary key,
|
||||
create_time date default sysdate,
|
||||
update_time date default sysdate,
|
||||
creator number(*,0),
|
||||
delete_type number(*,0),
|
||||
tenant_key varchar2(10),
|
||||
uuid varchar2(36),
|
||||
mainid varchar2(36),
|
||||
dataid varchar2(50),
|
||||
belongdataid varchar2(50),
|
||||
tableName varchar2(200),
|
||||
tablenamelabelid varchar2(50),
|
||||
tablenamedesc varchar2(50),
|
||||
fieldName varchar2(200),
|
||||
fieldnamelabelid varchar2(200),
|
||||
newValue CLOB,
|
||||
oldValue CLOB,
|
||||
newrealvalue CLOB,
|
||||
oldrealvalue CLOB,
|
||||
fieldDesc varchar2(200),
|
||||
showorder number(*,0) default 0,
|
||||
isdetail number(*,0) default 0
|
||||
)
|
||||
</update>
|
||||
<update id="createDetailTable" databaseId="sqlserver">
|
||||
create table ${detailTable}
|
||||
(
|
||||
id bigint not null primary key,
|
||||
create_time datetime default getdate(),
|
||||
update_time datetime default getdate(),
|
||||
creator bigint,
|
||||
delete_type bigint,
|
||||
tenant_key nvarchar(10),
|
||||
uuid nvarchar(36),
|
||||
mainid nvarchar(36),
|
||||
dataid nvarchar(50),
|
||||
belongdataid nvarchar(50),
|
||||
tableName nvarchar(200),
|
||||
tablenamelabelid nvarchar(50),
|
||||
tablenamedesc nvarchar(50),
|
||||
fieldName nvarchar(200),
|
||||
fieldnamelabelid nvarchar(200),
|
||||
newValue nvarchar(max),
|
||||
oldValue nvarchar(max),
|
||||
newrealvalue nvarchar(max),
|
||||
oldrealvalue nvarchar(max),
|
||||
fieldDesc varchar(200),
|
||||
showorder bigint default 0,
|
||||
isdetail bigint default 0
|
||||
)
|
||||
</update>
|
||||
|
||||
|
||||
<!-- 获取表结构 -->
|
||||
<select id="getTableStructure" resultType="com.engine.salary.elog.entity.dto.TableColumnBean" >
|
||||
SELECT
|
||||
COLUMN_NAME columnName,
|
||||
DATA_TYPE dataTypeStr,
|
||||
COLUMN_TYPE columnType,
|
||||
CHARACTER_MAXIMUM_LENGTH fieldLength,
|
||||
IS_NULLABLE isNullableStr,
|
||||
COLUMN_DEFAULT columnDefault,
|
||||
COLUMN_COMMENT columnComment
|
||||
FROM
|
||||
INFORMATION_SCHEMA.COLUMNS
|
||||
where
|
||||
table_name = #{tableName}
|
||||
and TABLE_SCHEMA = (select database())
|
||||
</select>
|
||||
<select id="getTableStructure" resultType="com.engine.salary.elog.entity.dto.TableColumnBean" databaseId="postgresql">
|
||||
select *
|
||||
from pg_tables
|
||||
where tableowner = (select current_user)
|
||||
and tablename = #{tableName}
|
||||
</select>
|
||||
<select id="getTableStructure" resultType="com.engine.salary.elog.entity.dto.TableColumnBean" databaseId="oracle">
|
||||
SELECT
|
||||
COLUMN_NAME columnName
|
||||
FROM
|
||||
user_tab_columns
|
||||
where
|
||||
TABLE_NAME=UPPER(#{tableName})
|
||||
</select>
|
||||
<select id="getTableStructure" resultType="com.engine.salary.elog.entity.dto.TableColumnBean" databaseId="sqlserver">
|
||||
SELECT
|
||||
COLUMN_NAME columnName
|
||||
FROM
|
||||
INFORMATION_SCHEMA.COLUMNS
|
||||
where
|
||||
table_name = #{tableName}
|
||||
and TABLE_catalog = (select DB_NAME())
|
||||
</select>
|
||||
|
||||
<update id="createElogTable">
|
||||
${createElogSql}
|
||||
</update>
|
||||
|
||||
<!--查询表索引信息-->
|
||||
<select id="getTableIndex" resultType="java.util.Map">
|
||||
SELECT COLUMN_KEY
|
||||
FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE TABLE_NAME = #{tableName}
|
||||
AND COLUMN_NAME = #{columnName}
|
||||
AND TABLE_SCHEMA = (SELECT DATABASE()) LIMIT 1
|
||||
</select>
|
||||
<select id="getTableIndex" resultType="java.util.Map" databaseId="postgresql">
|
||||
SELECT COLUMN_KEY
|
||||
FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE TABLE_NAME = #{tableName}
|
||||
AND COLUMN_NAME = #{columnName}
|
||||
AND TABLE_SCHEMA = (SELECT current_database()) limit 1 offset 0
|
||||
</select>
|
||||
<select id="getTableIndex" resultType="java.util.Map" databaseId="oracle">
|
||||
SELECT *
|
||||
FROM user_ind_columns
|
||||
WHERE TABLE_NAME = UPPER(#{tableName})
|
||||
AND COLUMN_NAME = UPPER(#{columnName})
|
||||
|
||||
</select>
|
||||
<select id="getTableIndex" resultType="java.util.Map" databaseId="sqlserver">
|
||||
SELECT a.name,
|
||||
c.name,
|
||||
d.name
|
||||
FROM sysindexes a
|
||||
JOIN sysindexkeys b ON
|
||||
a.id = b.id
|
||||
AND a.indid = b.indid
|
||||
JOIN sysobjects c ON
|
||||
b.id = c.id
|
||||
JOIN syscolumns d ON
|
||||
b.id = d.id
|
||||
AND b.colid = d.colid
|
||||
WHERE a.indid NOT IN (0,
|
||||
255)
|
||||
AND c.name = #{tableName}
|
||||
and d.name = #{columnName}
|
||||
|
||||
</select>
|
||||
|
||||
<!--查询表索引信息-->
|
||||
<select id="getDataBase" resultType="java.util.Map">
|
||||
SELECT DATABASE() as databasename
|
||||
</select>
|
||||
<select id="getDataBase" resultType="java.util.Map" databaseId="postgresql">
|
||||
SELECT current_database() as databasename
|
||||
</select>
|
||||
<select id="getDataBase" resultType="java.util.Map" databaseId="oracle">
|
||||
SELECT user as databasename
|
||||
</select>
|
||||
<select id="getDataBase" resultType="java.util.Map" databaseId="sqlserver">
|
||||
SELECT db_name() as databasename
|
||||
</select>
|
||||
|
||||
<update id="createTableIndex">
|
||||
create index idx${id} on ${tableName} (${columnName})
|
||||
</update>
|
||||
|
||||
<update id="createTableIndex" databaseId="oracle">
|
||||
create index idx${id} on ${tableName} (${columnName})
|
||||
</update>
|
||||
|
||||
<update id="createTableIndex" databaseId="sqlserver">
|
||||
create index idx${id} on ${tableName} (${columnName})
|
||||
</update>
|
||||
|
||||
<select id="getAllExistTables" resultType="java.lang.String">
|
||||
SELECT TABLE_NAME
|
||||
FROM INFORMATION_SCHEMA.TABLES
|
||||
WHERE TABLE_SCHEMA = (SELECT DATABASE())
|
||||
AND TABLE_NAME IN
|
||||
<foreach collection="tableNames" item="tableName" open="(" separator="," close=")">
|
||||
#{tableName}
|
||||
</foreach>
|
||||
</select>
|
||||
|
||||
<select id="getAllExistTables" resultType="java.lang.String" databaseId="oracle">
|
||||
SELECT
|
||||
TABLE_NAME
|
||||
FROM
|
||||
USER_TABLES
|
||||
WHERE TABLE_NAME IN
|
||||
<foreach collection="tableNames" item="tableName" open="(" separator="," close=")">
|
||||
UPPER(#{tableName})
|
||||
</foreach>
|
||||
</select>
|
||||
|
||||
<select id="getAllExistTables" resultType="java.lang.String" databaseId="sqlserver">
|
||||
SELECT table_name
|
||||
FROM INFORMATION_SCHEMA.TABLES
|
||||
WHERE TABLE_catalog = (select DB_NAME())
|
||||
AND table_name IN
|
||||
<foreach collection="tableNames" item="tableName" open="(" separator="," close=")">
|
||||
#{tableName}
|
||||
</foreach>
|
||||
</select>
|
||||
|
||||
<select id="getAllExistTables" resultType="java.lang.String" databaseId="postgresql">
|
||||
SELECT tablename
|
||||
FROM pg_tables
|
||||
WHERE tableowner = (select current_user)
|
||||
AND tablename IN
|
||||
<foreach collection="tableNames" item="tableName" open="(" separator="," close=")">
|
||||
#{tableName}
|
||||
</foreach>
|
||||
</select>
|
||||
</mapper>
|
||||
|
|
@ -1,45 +0,0 @@
|
|||
package com.engine.salary.mapper.elog;
|
||||
|
||||
|
||||
import com.engine.salary.elog.entity.dto.LoggerContext;
|
||||
import com.engine.salary.elog.entity.dto.LoggerDetailContext;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @ClassName: LocalElogAopDaoMapper
|
||||
* @Description 本地操作日志持久层
|
||||
* @Author tanghj
|
||||
* @Date 2021/2/24 9:35
|
||||
*/
|
||||
public interface LocalElogAopDaoMapper {
|
||||
|
||||
int insertElogContext(@Param(value="logContent") LoggerContext loggerContext,
|
||||
@Param(value="cusColumns")String cusColumns ,
|
||||
@Param(value="cusValus")String cusValus,
|
||||
@Param(value="tableName")String tableName);
|
||||
|
||||
|
||||
|
||||
int insertElogDetail(@Param(value="detailContext") LoggerDetailContext loggerDetailContext,
|
||||
@Param(value="mainid")String mainid,
|
||||
@Param(value="cusColumns")String cusColumns ,
|
||||
@Param(value="cusValus")String cusValus,
|
||||
@Param(value="detailTableName")String tableName);
|
||||
|
||||
|
||||
Integer queryElogContextById(@Param(value="id")Long id,
|
||||
@Param(value="tableName")String tableName);
|
||||
|
||||
void batchInsertDetail(@Param("sql") String sql);
|
||||
|
||||
void insertElogDetailPrepared(@Param("tablename") String detailTableName, @Param("list") List<LoggerDetailContext> detailContexts, @Param("mainid") String mainid);
|
||||
|
||||
void insertElogDetailPreparedHasCustonInfo(@Param("tablename") String detailTableName, @Param("list") List<LoggerDetailContext> detailContexts, @Param("mainid") String mainid, @Param(value="cusColumns")String cusColumns);
|
||||
|
||||
void rollBackElogById(@Param("id") Long id,@Param("tableName") String tableName);
|
||||
|
||||
void rollBackDetailElogByUUID(@Param("mainid") String uuid,@Param("tableName") String detailTableName);
|
||||
|
||||
}
|
||||
|
|
@ -1,170 +0,0 @@
|
|||
<?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.engine.salary.mapper.elog.LocalElogAopDaoMapper">
|
||||
|
||||
<insert id="insertElogContext">
|
||||
insert into ${tableName} (id, uuid, log_date, tenant_key, modulename, functionName, operatetypename,
|
||||
log_operator, operatorname, targetid, targetname, interfacename, operatetype,
|
||||
operatedesc,
|
||||
params, clientIp, groupnamelabel, redoservice, redocontext, cancelservice,
|
||||
cancelcontext, device, groupid,
|
||||
belongMainId, requestUrl, requestUri, totalRunTime, mainRunTime, log_result,
|
||||
fromTerminal, resultDesc, old_content,
|
||||
link_type, link_id, old_link_id, create_time, update_time, delete_type, creator
|
||||
${cusColumns})
|
||||
values (#{logContent.id}, #{logContent.uuid}, #{logContent.date},
|
||||
#{logContent.tenant_key}, #{logContent.moduleName}, #{logContent.functionName},
|
||||
#{logContent.operateTypeName}, #{logContent.logOperator}, #{logContent.operatorName},
|
||||
#{logContent.logTargetid}
|
||||
, #{logContent.targetName}, #{logContent.interfaceName}, #{logContent.operateType},
|
||||
#{logContent.operatedesc},
|
||||
#{logContent.paramsStr}, #{logContent.clientIp}, #{logContent.groupNameLabel},
|
||||
#{logContent.redoService},
|
||||
#{logContent.redoContextStr}, #{logContent.cancelService}, #{logContent.cancelContextStr},
|
||||
#{logContent.device}, #{logContent.groupId},
|
||||
#{logContent.belongMainId}, #{logContent.requestUrl}, #{logContent.requestUri},
|
||||
#{logContent.totalRunTime}, #{logContent.mainRunTime}
|
||||
, #{logContent.result}, #{logContent.fromTerminal}, #{logContent.resultDesc},
|
||||
#{logContent.old_content}, #{logContent.link_type}
|
||||
, #{logContent.link_id}, #{logContent.old_link_id}, #{logContent.create_time},
|
||||
#{logContent.update_time}, #{logContent.delete_type}, #{logContent.logOperator}
|
||||
${cusValus})
|
||||
</insert>
|
||||
|
||||
<insert id="insertElogDetail">
|
||||
insert into ${detailTableName} (id, mainid, uuid, tablename, fieldname, newvalue, oldvalue,
|
||||
fielddesc, showorder, dataid, belongDataid, isDetail, tenant_key, creator,
|
||||
newRealValue, oldRealValue, tableNameDesc,
|
||||
tableNameLabelId, fieldNameLabelId, create_time, update_time
|
||||
${cusColumns})
|
||||
values (#{detailContext.id}, #{mainid}, #{detailContext.uuid}, #{detailContext.tableName},
|
||||
#{detailContext.fieldName}, #{detailContext.newValue},
|
||||
#{detailContext.oldValue}, #{detailContext.fieldDesc}, #{detailContext.showorder},
|
||||
#{detailContext.dataid},
|
||||
#{detailContext.belongDataid}, #{detailContext.isDetail}, #{detailContext.tenant_key},
|
||||
#{detailContext.creator}, #{detailContext.newRealValue}
|
||||
, #{detailContext.oldRealValue}, #{detailContext.tableNameDesc}, #{detailContext.tableNameLabelId},
|
||||
#{detailContext.fieldNameLabelId}, #{detailContext.create_time}, #{detailContext.update_time}
|
||||
${cusValus})
|
||||
</insert>
|
||||
<insert id="batchInsertDetail">
|
||||
${sql}
|
||||
</insert>
|
||||
|
||||
|
||||
<select id="queryElogContextById" resultType="java.lang.Integer">
|
||||
select 1
|
||||
from ${tableName}
|
||||
where id = #{id}
|
||||
</select>
|
||||
|
||||
|
||||
<insert id="insertElogDetailPrepared">
|
||||
insert into ${tablename} (id, mainid, uuid, tablename, fieldname, newvalue, oldvalue,
|
||||
fielddesc, showorder, dataid, belongDataid, isDetail, tenant_key,creator, newRealValue,
|
||||
oldRealValue,tableNameDesc,
|
||||
tableNameLabelId,fieldNameLabelId, create_time, update_time,delete_type)
|
||||
values
|
||||
<foreach collection="list" item="detailContext" separator=",">
|
||||
( #{detailContext.id},#{mainid}, #{detailContext.uuid}, #{detailContext.tableName},
|
||||
#{detailContext.fieldName}, #{detailContext.newValue},
|
||||
#{detailContext.oldValue}, #{detailContext.fieldDesc}, #{detailContext.showorder}, #{detailContext.dataid},
|
||||
#{detailContext.belongDataid}, #{detailContext.isDetail},
|
||||
#{detailContext.tenant_key},#{detailContext.creator}, #{detailContext.newRealValue}
|
||||
, #{detailContext.oldRealValue}, #{detailContext.tableNameDesc}, #{detailContext.tableNameLabelId},
|
||||
#{detailContext.fieldNameLabelId}
|
||||
, #{detailContext.create_time}, #{detailContext.update_time}, #{detailContext.delete_type})
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<insert id="insertElogDetailPrepared" databaseId="sqlserver">
|
||||
<foreach collection="list" item="detailContext" separator=";">
|
||||
insert into ${tablename} (id, mainid, uuid, tablename, fieldname, newvalue, oldvalue,
|
||||
fielddesc, showorder, dataid, belongDataid, isDetail, tenant_key,creator, newRealValue,
|
||||
oldRealValue,tableNameDesc,
|
||||
tableNameLabelId,fieldNameLabelId, create_time, update_time,delete_type)
|
||||
VALUES
|
||||
(
|
||||
#{detailContext.id},#{mainid}, #{detailContext.uuid}, #{detailContext.tableName},
|
||||
#{detailContext.fieldName}, #{detailContext.newValue},
|
||||
#{detailContext.oldValue}, #{detailContext.fieldDesc}, #{detailContext.showorder}, #{detailContext.dataid},
|
||||
#{detailContext.belongDataid}, #{detailContext.isDetail},
|
||||
#{detailContext.tenant_key},#{detailContext.creator}, #{detailContext.newRealValue}
|
||||
, #{detailContext.oldRealValue}, #{detailContext.tableNameDesc}, #{detailContext.tableNameLabelId},
|
||||
#{detailContext.fieldNameLabelId}
|
||||
, #{detailContext.create_time}, #{detailContext.update_time}, #{detailContext.delete_type}
|
||||
)
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<insert id="insertElogDetailPreparedHasCustonInfo">
|
||||
insert into ${tablename} (id, mainid, uuid, tablename, fieldname, newvalue, oldvalue,
|
||||
fielddesc, showorder, dataid, belongDataid, isDetail, tenant_key,creator, newRealValue,
|
||||
oldRealValue,tableNameDesc,
|
||||
tableNameLabelId,fieldNameLabelId, create_time, update_time
|
||||
${cusColumns})
|
||||
values
|
||||
<foreach collection="list" item="detailContext" separator=",">
|
||||
( #{detailContext.id},#{mainid}, #{detailContext.uuid}, #{detailContext.tableName},
|
||||
#{detailContext.fieldName}, #{detailContext.newValue},
|
||||
#{detailContext.oldValue}, #{detailContext.fieldDesc}, #{detailContext.showorder}, #{detailContext.dataid},
|
||||
#{detailContext.belongDataid}, #{detailContext.isDetail},
|
||||
#{detailContext.tenant_key},#{detailContext.creator}, #{detailContext.newRealValue}
|
||||
, #{detailContext.oldRealValue}, #{detailContext.tableNameDesc}, #{detailContext.tableNameLabelId},
|
||||
#{detailContext.fieldNameLabelId}
|
||||
, #{detailContext.create_time}, #{detailContext.update_time}
|
||||
${detailContext.cusValus})
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<update id="rollBackElogById">
|
||||
update ${tableName}
|
||||
set delete_type = 3
|
||||
where id = #{id}
|
||||
</update>
|
||||
<update id="rollBackDetailElogByUUID">
|
||||
update ${tableName}
|
||||
set delete_type = 3
|
||||
where mainid = #{mainid}
|
||||
</update>
|
||||
|
||||
<insert id="insertElogDetailPrepared" databaseId="oracle">
|
||||
insert into ${tablename} (id, mainid, uuid, tablename, fieldname, newvalue, oldvalue,
|
||||
fielddesc, showorder, dataid, belongDataid, isDetail, tenant_key,creator, newRealValue,
|
||||
oldRealValue,tableNameDesc,
|
||||
tableNameLabelId,fieldNameLabelId, create_time, update_time,delete_type)
|
||||
<foreach collection="list" item="detailContext" separator=" union all ">
|
||||
SELECT #{detailContext.id},#{mainid}, #{detailContext.uuid}, #{detailContext.tableName},
|
||||
#{detailContext.fieldName}, #{detailContext.newValue},
|
||||
#{detailContext.oldValue}, #{detailContext.fieldDesc}, #{detailContext.showorder}, #{detailContext.dataid},
|
||||
#{detailContext.belongDataid}, #{detailContext.isDetail},
|
||||
#{detailContext.tenant_key},#{detailContext.creator}, #{detailContext.newRealValue}
|
||||
, #{detailContext.oldRealValue}, #{detailContext.tableNameDesc}, #{detailContext.tableNameLabelId},
|
||||
#{detailContext.fieldNameLabelId}
|
||||
, #{detailContext.create_time}, #{detailContext.update_time}, #{detailContext.delete_type}
|
||||
FROM DUAL
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<insert id="insertElogDetailPreparedHasCustonInfo" databaseId="oracle">
|
||||
insert into ${tablename} (id, mainid, uuid, tablename, fieldname, newvalue, oldvalue,
|
||||
fielddesc, showorder, dataid, belongDataid, isDetail, tenant_key,creator, newRealValue,
|
||||
oldRealValue,tableNameDesc,
|
||||
tableNameLabelId,fieldNameLabelId, create_time, update_time
|
||||
${cusColumns})
|
||||
<foreach collection="list" item="detailContext" separator=" union all ">
|
||||
SELECT #{detailContext.id},#{mainid}, #{detailContext.uuid}, #{detailContext.tableName},
|
||||
#{detailContext.fieldName}, #{detailContext.newValue},
|
||||
#{detailContext.oldValue}, #{detailContext.fieldDesc}, #{detailContext.showorder}, #{detailContext.dataid},
|
||||
#{detailContext.belongDataid}, #{detailContext.isDetail},
|
||||
#{detailContext.tenant_key},#{detailContext.creator}, #{detailContext.newRealValue}
|
||||
, #{detailContext.oldRealValue}, #{detailContext.tableNameDesc}, #{detailContext.tableNameLabelId},
|
||||
#{detailContext.fieldNameLabelId}
|
||||
, #{detailContext.create_time}, #{detailContext.update_time}
|
||||
${detailContext.cusValus}
|
||||
FROM DUAL
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
</mapper>
|
||||
|
|
@ -1,219 +0,0 @@
|
|||
package com.engine.salary.mapper.elog;
|
||||
|
||||
import com.engine.salary.elog.entity.dto.LoggerContext;
|
||||
import com.engine.salary.elog.entity.dto.ReadInfoEntity;
|
||||
import com.github.pagehelper.Page;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @ClassName: LocalElogDao
|
||||
* @Description 本地操作日志持久层
|
||||
* @Author tanghj
|
||||
* @Date 2021/2/24 9:35
|
||||
*/
|
||||
public interface LocalElogDaoMapper {
|
||||
|
||||
|
||||
List<Map<String, Object>> queryCardElogList(@Param(value = "logContent") LoggerContext loggerContext,
|
||||
@Param("limit") String limit,
|
||||
@Param(value = "tableName") String tableName,
|
||||
@Param(value = "conditionSql") String conditionSql);
|
||||
|
||||
List<Map> queryElogList(@Param(value = "page") Page page,
|
||||
@Param(value = "logContent") LoggerContext loggerContext,
|
||||
@Param("limit") String limit,
|
||||
@Param(value = "tableName") String tableName,
|
||||
@Param(value = "conditionSql") String conditionSql,
|
||||
@Param(value = "columns") String columns);
|
||||
|
||||
List<Map> queryElogListPapi(@Param(value = "page") Page page,
|
||||
@Param(value = "logContent") LoggerContext loggerContext,
|
||||
@Param("limit") String limit,
|
||||
@Param(value = "tableName") String tableName,
|
||||
@Param(value = "conditionSql") String conditionSql,
|
||||
@Param(value = "columns") String columns);
|
||||
|
||||
// @WeaDataPermission(mainDataTable = "#{mainDataTable}",
|
||||
// permissionId = "#{permissionId}",
|
||||
// permissionType = "#{permissionType}",
|
||||
// mainDataTableAlias = "#{mainDataTableAlias}",
|
||||
// primaryKey = "#{primaryKey}",
|
||||
// permissionTargetId = "#{permissionTargetId}",
|
||||
// permissionConfigSourceId = "#{permissionConfigSourceId}",
|
||||
// permissionExcept = "true")
|
||||
List<Map> queryElogList(@Param(value = "page") Page page, @Param(value = "logContent") LoggerContext loggerContext,
|
||||
@Param("limit") String limit,
|
||||
@Param(value = "tableName") String tableName,
|
||||
@Param(value = "conditionSql") String conditionSql,
|
||||
@Param(value = "mainDataTable") String mainDataTable,
|
||||
@Param(value = "permissionId") String permissionId,
|
||||
@Param(value = "permissionType") String permissionType,
|
||||
@Param(value = "mainDataTableAlias") String mainDataTableAlias,
|
||||
@Param(value = "primaryKey") String primaryKey,
|
||||
@Param(value = "permissionTargetId") String permissionTargetId,
|
||||
@Param(value = "permissionConfigSourceId") String permissionConfigSourceId,
|
||||
@Param(value = "columns") String columns
|
||||
);
|
||||
|
||||
// @WeaDataPermission(mainDataTable = "#{mainDataTable}",
|
||||
// permissionId = "#{permissionId}",
|
||||
// permissionType = "#{permissionType}",
|
||||
// mainDataTableAlias = "#{mainDataTableAlias}",
|
||||
// primaryKey = "#{primaryKey}",
|
||||
// permissionExcept = "true")
|
||||
List<Map> queryElogListPapi(@Param(value = "page") Page page, @Param(value = "logContent") LoggerContext loggerContext,
|
||||
@Param("limit") String limit,
|
||||
@Param(value = "tableName") String tableName,
|
||||
@Param(value = "conditionSql") String conditionSql,
|
||||
@Param(value = "mainDataTable") String mainDataTable,
|
||||
@Param(value = "permissionId") String permissionId,
|
||||
@Param(value = "permissionType") String permissionType,
|
||||
@Param(value = "mainDataTableAlias") String mainDataTableAlias,
|
||||
@Param(value = "primaryKey") String primaryKey,
|
||||
@Param(value = "columns") String columns
|
||||
);
|
||||
|
||||
List<Map> queryAllChanges(@Param(value = "tableName") String tableName, @Param("mainid") String mainid);
|
||||
|
||||
Map<String, Object> elogCount(@Param(value = "logContent") LoggerContext loggerContext,
|
||||
@Param(value = "tableName") String tableName,
|
||||
@Param(value = "conditionSql") String conditionSql);
|
||||
|
||||
Map<String, Object> elogCountPapi(@Param(value = "logContent") LoggerContext loggerContext,
|
||||
@Param(value = "tableName") String tableName,
|
||||
@Param(value = "conditionSql") String conditionSql);
|
||||
|
||||
|
||||
// @WeaDataPermission(mainDataTable = "#{mainDataTable}",
|
||||
// permissionId = "#{permissionId}",
|
||||
// permissionType = "#{permissionType}",
|
||||
// mainDataTableAlias = "#{mainDataTableAlias}",
|
||||
// primaryKey = "#{primaryKey}",
|
||||
// permissionTargetId = "#{permissionTargetId}",
|
||||
// permissionConfigSourceId = "#{permissionConfigSourceId}",
|
||||
// permissionExcept = "true")
|
||||
Map<String, Object> elogCountByMorePermission(@Param(value = "logContent") LoggerContext loggerContext,
|
||||
@Param(value = "tableName") String tableName,
|
||||
@Param(value = "conditionSql") String conditionSql,
|
||||
@Param(value = "mainDataTable") String mainDataTable,
|
||||
@Param(value = "permissionId") String permissionId,
|
||||
@Param(value = "permissionType") String permissionType,
|
||||
@Param(value = "mainDataTableAlias") String mainDataTableAlias,
|
||||
@Param(value = "primaryKey") String primaryKey,
|
||||
@Param(value = "permissionTargetId") String permissionTargetId,
|
||||
@Param(value = "permissionConfigSourceId") String permissionConfigSourceId);
|
||||
|
||||
// @WeaDataPermission(mainDataTable = "#{mainDataTable}",
|
||||
// permissionId = "#{permissionId}",
|
||||
// permissionType = "#{permissionType}",
|
||||
// mainDataTableAlias = "#{mainDataTableAlias}",
|
||||
// primaryKey = "#{primaryKey}",
|
||||
// permissionTargetId = "#{permissionTargetId}",
|
||||
// permissionConfigSourceId = "#{permissionConfigSourceId}",
|
||||
// permissionCount = "count(*)",
|
||||
// permissionExcept = "true")
|
||||
Long elogCountOnlyNum(@Param(value = "logContent") LoggerContext loggerContext,
|
||||
@Param(value = "tableName") String tableName,
|
||||
@Param(value = "conditionSql") String conditionSql,
|
||||
@Param(value = "mainDataTable") String mainDataTable,
|
||||
@Param(value = "permissionId") String permissionId,
|
||||
@Param(value = "permissionType") String permissionType,
|
||||
@Param(value = "mainDataTableAlias") String mainDataTableAlias,
|
||||
@Param(value = "primaryKey") String primaryKey,
|
||||
@Param(value = "permissionTargetId") String permissionTargetId,
|
||||
@Param(value = "permissionConfigSourceId") String permissionConfigSourceId);
|
||||
|
||||
|
||||
// @WeaDataPermission(mainDataTable = "#{mainDataTable}",
|
||||
// permissionId = "#{permissionId}",
|
||||
// permissionType = "#{permissionType}",
|
||||
// mainDataTableAlias = "#{mainDataTableAlias}",
|
||||
// primaryKey = "#{primaryKey}",
|
||||
// permissionExcept = "true")
|
||||
Map<String, Object> elogCount(@Param(value = "logContent") LoggerContext loggerContext,
|
||||
@Param(value = "tableName") String tableName,
|
||||
@Param(value = "conditionSql") String conditionSql,
|
||||
@Param(value = "mainDataTable") String mainDataTable,
|
||||
@Param(value = "permissionId") String permissionId,
|
||||
@Param(value = "permissionType") String permissionType,
|
||||
@Param(value = "mainDataTableAlias") String mainDataTableAlias,
|
||||
@Param(value = "primaryKey") String primaryKey);
|
||||
|
||||
// @WeaDataPermission(mainDataTable = "#{mainDataTable}",
|
||||
// permissionId = "#{permissionId}",
|
||||
// permissionType = "#{permissionType}",
|
||||
// mainDataTableAlias = "#{mainDataTableAlias}",
|
||||
// primaryKey = "#{primaryKey}",
|
||||
// permissionExcept = "true")
|
||||
Map<String, Object> elogCountPapi(@Param(value = "logContent") LoggerContext loggerContext,
|
||||
@Param(value = "tableName") String tableName,
|
||||
@Param(value = "conditionSql") String conditionSql,
|
||||
@Param(value = "mainDataTable") String mainDataTable,
|
||||
@Param(value = "permissionId") String permissionId,
|
||||
@Param(value = "permissionType") String permissionType,
|
||||
@Param(value = "mainDataTableAlias") String mainDataTableAlias,
|
||||
@Param(value = "primaryKey") String primaryKey);
|
||||
|
||||
|
||||
List<Map> queryDetailElogList(@Param(value = "logContent") LoggerContext loggerContext,
|
||||
@Param("limit") String limit,
|
||||
@Param(value = "tableName") String tableName,
|
||||
@Param(value = "conditionSql") String conditionSql);
|
||||
|
||||
Map<String, Object> elogDetailCount(@Param(value = "logContent") LoggerContext loggerContext,
|
||||
@Param(value = "tableName") String tableName,
|
||||
@Param(value = "conditionSql") String conditionSql);
|
||||
|
||||
// List<SimpleEmployee> queryOperators(@Param(value = "tableName") String tableName,
|
||||
// @Param(value = "targetId") String targetId,
|
||||
// @Param(value = "operateType") String operateType);
|
||||
|
||||
List<ReadInfoEntity> queryReadInfoOperators(@Param(value = "tableName") String tableName,
|
||||
@Param(value = "targetId") String targetId,
|
||||
@Param(value = "operateType") String operateType,
|
||||
@Param(value = "flag") Boolean flag);
|
||||
|
||||
List<ReadInfoEntity> queryReadInfoDateOperators(@Param(value = "tableName") String tableName,
|
||||
@Param(value = "targetId") String targetId,
|
||||
@Param(value = "operateType") String operateType,
|
||||
@Param(value = "flag") Boolean flag,
|
||||
@Param(value = "startDate") String startDate,
|
||||
@Param(value = "endDate") String endDate);
|
||||
|
||||
List<Map> queryAllMainData(@Param(value = "tableName") String tableName, @Param("uuid") String uuid);
|
||||
|
||||
List<Map> queryAllMainChanges(@Param(value = "tableName") String tableName, @Param("mainid") String mainid);
|
||||
|
||||
List<Map> queryAllDetailChanges(@Param(value = "tableName") String tableName, @Param("mainid") String mainid);
|
||||
|
||||
Integer queryElogContextById(@Param(value = "id") Long id,
|
||||
@Param(value = "tableName") String tableName);
|
||||
|
||||
List<Map> queryElogTraceInfo(@Param(value = "traceId") String traceId,
|
||||
@Param(value = "tableName") String tableName,
|
||||
@Param(value = "offset") Integer offset,
|
||||
@Param(value = "pageSize") Integer pageSize);
|
||||
|
||||
int queryElogTraceInfoCount(@Param(value = "traceId") String traceId,
|
||||
@Param(value = "tableName") String tableName);
|
||||
|
||||
List queryLogInfoByCustom(@Param(value = "tableName") String tableName,
|
||||
@Param(value = "sql") String sql);
|
||||
|
||||
List queryAllChangesData(@Param("tableName") String tableName, @Param("mainid") String mainid);
|
||||
|
||||
List<ReadInfoEntity> queryTenantKeyOperators(@Param(value = "tableName") String tableName,
|
||||
@Param(value = "tenantKey") String tenantKey,
|
||||
@Param(value = "targetId") String targetId,
|
||||
@Param(value = "operateType") String operateType,
|
||||
@Param(value = "flag") Boolean flag);
|
||||
|
||||
List<Map> queryAllChangesDataPages(@Param("tableName") String tableName,
|
||||
@Param("mainid") String mainid,
|
||||
@Param(value = "page") Page page);
|
||||
|
||||
Integer queryAllChangesPageCounts(@Param("tableName") String tableName, @Param("mainid") String mainid);
|
||||
}
|
||||
|
|
@ -1,412 +0,0 @@
|
|||
<?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.engine.salary.mapper.elog.LocalElogDaoMapper">
|
||||
<select id="queryElogList" resultType="java.util.Map">
|
||||
select ${columns},DATE_FORMAT(log_date,"%Y-%m-%d %H:%i:%S") createdate from ${tableName}
|
||||
where modulename = #{logContent.moduleName} and functionname = #{logContent.functionName}
|
||||
and delete_type = 0
|
||||
<if test="conditionSql != null">${conditionSql}</if>
|
||||
order by log_date desc ,id desc
|
||||
</select>
|
||||
<select id="queryElogList" resultType="java.util.Map" databaseId="postgresql">
|
||||
select ${columns},to_char(log_date::timestamp,'YYYY-MM-DD HH24:MI:SS') createdate from ${tableName}
|
||||
where modulename = #{logContent.moduleName} and functionname = #{logContent.functionName}
|
||||
|
||||
<if test="conditionSql != null">${conditionSql}</if>
|
||||
order by log_date desc ,id desc
|
||||
</select>
|
||||
<select id="queryElogList" resultType="java.util.Map" databaseId="oracle">
|
||||
select d.*,to_char(d.log_date,'yyyy-mm-dd HH24:mi:ss') createdate from ${tableName} d
|
||||
where modulename = #{logContent.moduleName} and functionname = #{logContent.functionName}
|
||||
|
||||
<if test="conditionSql != null">${conditionSql}</if>
|
||||
order by d.log_date desc ,id desc
|
||||
</select>
|
||||
<select id="queryElogList" resultType="java.util.Map" databaseId="sqlserver">
|
||||
select ${columns},convert(nvarchar(19),log_date,120) createdate from ${tableName}
|
||||
where modulename = #{logContent.moduleName} and functionname = #{logContent.functionName}
|
||||
|
||||
<if test="conditionSql != null">${conditionSql}</if>
|
||||
order by log_date desc ,id desc
|
||||
</select>
|
||||
|
||||
<select id="queryElogListPapi" resultType="java.util.Map">
|
||||
select ${columns},DATE_FORMAT(log_date,"%Y-%m-%d %H:%i:%S") createdate from ${tableName}
|
||||
where modulename = #{logContent.moduleName} and functionname = #{logContent.functionName}
|
||||
and delete_type = 0
|
||||
<if test="conditionSql != null">${conditionSql}</if>
|
||||
order by log_date desc ,id desc
|
||||
</select>
|
||||
<select id="queryElogListPapi" resultType="java.util.Map" databaseId="postgresql">
|
||||
select ${columns},to_char(log_date::timestamp,'YYYY-MM-DD HH24:MI:SS') createdate from ${tableName}
|
||||
where modulename = #{logContent.moduleName} and functionname = #{logContent.functionName}
|
||||
<if test="conditionSql != null">${conditionSql}</if>
|
||||
order by log_date desc ,id desc
|
||||
</select>
|
||||
<select id="queryElogListPapi" resultType="java.util.Map" databaseId="oracle">
|
||||
select d.*,to_char(d.log_date,'yyyy-mm-dd HH24:mi:ss') createdate from ${tableName} d
|
||||
where modulename = #{logContent.moduleName} and functionname = #{logContent.functionName}
|
||||
<if test="conditionSql != null">${conditionSql}</if>
|
||||
order by d.log_date desc ,id desc
|
||||
</select>
|
||||
<select id="queryElogListPapi" resultType="java.util.Map" databaseId="sqlserver">
|
||||
select ${columns},convert(nvarchar(19),log_date,120) createdate from ${tableName}
|
||||
where modulename = #{logContent.moduleName} and functionname = #{logContent.functionName}
|
||||
<if test="conditionSql != null">${conditionSql}</if>
|
||||
order by log_date desc ,id desc
|
||||
</select>
|
||||
|
||||
<select id="queryCardElogList" resultType="java.util.Map">
|
||||
select ${columns}, DATE_FORMAT(log_date,"%Y-%m-%d %H:%i:%S") createdate,
|
||||
uuid from ${tableName}
|
||||
where modulename = #{logContent.moduleName} and functionname = #{logContent.functionName}
|
||||
|
||||
<if test="conditionSql != null">#{conditionSql}</if>
|
||||
order by log_date desc ,id desc
|
||||
</select>
|
||||
<select id="queryCardElogList" resultType="java.util.Map" databaseId="postgresql">
|
||||
select ${columns}, to_char(log_date::timestamp,'YYYY-MM-DD HH24:MI:SS') createdate,
|
||||
uuid from ${tableName}
|
||||
where modulename = #{logContent.moduleName} and functionname = #{logContent.functionName}
|
||||
|
||||
<if test="conditionSql != null">#{conditionSql}</if>
|
||||
order by log_date desc ,id desc
|
||||
</select>
|
||||
<select id="queryCardElogList" resultType="java.util.Map" databaseId="oracle">
|
||||
select ${columns}, to_char(log_date,'yyyy-mm-dd HH24:mi:ss') createdate,
|
||||
uuid from ${tableName}
|
||||
where modulename = #{logContent.moduleName} and functionname = #{logContent.functionName}
|
||||
|
||||
<if test="conditionSql != null">#{conditionSql}</if>
|
||||
order by log_date desc ,id desc
|
||||
</select>
|
||||
<select id="queryCardElogList" resultType="java.util.Map" databaseId="sqlserver">
|
||||
select ${columns}, convert(nvarchar(19),log_date,120) createdate,
|
||||
uuid from ${tableName}
|
||||
where modulename = #{logContent.moduleName} and functionname = #{logContent.functionName}
|
||||
|
||||
<if test="conditionSql != null">#{conditionSql}</if>
|
||||
order by log_date desc ,id desc
|
||||
</select>
|
||||
|
||||
|
||||
<select id="elogCountByMorePermission" resultType="java.util.Map">
|
||||
select count(1) counts from ${tableName}
|
||||
where modulename = #{logContent.moduleName} and functionname = #{logContent.functionName}
|
||||
|
||||
<if test="conditionSql != null">${conditionSql}</if>
|
||||
</select>
|
||||
|
||||
<select id="elogCount" resultType="java.util.Map">
|
||||
select count(1) counts from ${tableName}
|
||||
where modulename = #{logContent.moduleName} and functionname = #{logContent.functionName}
|
||||
|
||||
<if test="logContent.operator != null and logContent.operator !=''">
|
||||
and log_operator = #{logContent.operator}
|
||||
</if>
|
||||
<if test="conditionSql != null">${conditionSql}</if>
|
||||
</select>
|
||||
|
||||
<select id="elogCountPapi" resultType="java.util.Map">
|
||||
select count(1) counts from ${tableName}
|
||||
where modulename = #{logContent.moduleName} and functionname = #{logContent.functionName}
|
||||
and delete_type = 0
|
||||
<if test="logContent.operator != null and logContent.operator !=''">
|
||||
and log_operator = #{logContent.operator}
|
||||
</if>
|
||||
<if test="conditionSql != null">${conditionSql}</if>
|
||||
</select>
|
||||
|
||||
|
||||
<select id="queryDetailElogList" resultType="java.util.Map">
|
||||
select *,DATE_FORMAT(create_time,"%Y-%m-%d %H:%i:%S") createdate from ${tableName}
|
||||
where mainid = #{logContent.uuid}
|
||||
|
||||
<if test="conditionSql != null">#{conditionSql}</if>
|
||||
order by log_date desc ,id desc
|
||||
</select>
|
||||
<select id="queryDetailElogList" resultType="java.util.Map" databaseId="postgresql">
|
||||
select *,to_char(create_time::timestamp,'YYYY-MM-DD HH24:MI:SS') createdate from ${tableName}
|
||||
where mainid = #{logContent.uuid}
|
||||
|
||||
<if test="conditionSql != null">#{conditionSql}</if>
|
||||
order by log_date desc ,id desc
|
||||
</select>
|
||||
<select id="queryDetailElogList" resultType="java.util.Map" databaseId="oracle">
|
||||
select *,to_char(create_time,'yyyy-mm-dd HH24:mi:ss') createdate from ${tableName}
|
||||
where mainid = #{logContent.uuid}
|
||||
|
||||
<if test="conditionSql != null">#{conditionSql}</if>
|
||||
order by log_date desc ,id desc
|
||||
</select>
|
||||
<select id="queryDetailElogList" resultType="java.util.Map" databaseId="sqlserver">
|
||||
select *,convert(nvarchar(19),create_time,120) createdate from ${tableName}
|
||||
where mainid = #{logContent.uuid}
|
||||
|
||||
<if test="conditionSql != null">#{conditionSql}</if>
|
||||
order by log_date desc ,id desc
|
||||
</select>
|
||||
|
||||
<select id="queryAllChanges" resultType="java.util.Map">
|
||||
select *
|
||||
from ${tableName}
|
||||
where mainid = #{mainid}
|
||||
</select>
|
||||
|
||||
<select id="queryAllMainData" resultType="java.util.Map">
|
||||
select *
|
||||
from ${tableName}
|
||||
where uuid = #{uuid}
|
||||
</select>
|
||||
|
||||
<select id="queryAllMainChanges" resultType="java.util.Map">
|
||||
select *
|
||||
from ${tableName}
|
||||
where mainid = #{mainid}
|
||||
and isdetail = '0'
|
||||
</select>
|
||||
|
||||
<select id="queryAllDetailChanges" resultType="java.util.Map">
|
||||
select *
|
||||
from ${tableName}
|
||||
where mainid = #{mainid}
|
||||
and isdetail = '1'
|
||||
</select>
|
||||
|
||||
<select id="elogDetailCount" resultType="java.util.Map">
|
||||
select count(1) counts from ${tableName}
|
||||
where mainid = #{logContent.uuid}
|
||||
|
||||
<if test="conditionSql != null">#{conditionSql}</if>
|
||||
</select>
|
||||
|
||||
<!-- <select id="queryOperators" resultType="com.weaver.teams.domain.user.SimpleEmployee">-->
|
||||
<!-- select log_operator id, max(log_date) updateTime-->
|
||||
<!-- from ${tableName}-->
|
||||
<!-- where targetid = #{targetId}-->
|
||||
<!-- and operatetype = #{operateType}-->
|
||||
<!-- group by log_operator-->
|
||||
<!-- order by updateTime desc-->
|
||||
<!-- </select>-->
|
||||
<select id="queryReadInfoOperators" resultType="com.engine.salary.elog.entity.dto.ReadInfoEntity">
|
||||
select log_operator employeeId, max(log_date) date
|
||||
from ${tableName}
|
||||
where targetid = #{targetId}
|
||||
and operatetype = #{operateType}
|
||||
group by log_operator
|
||||
order by log_date desc
|
||||
</select>
|
||||
|
||||
<select id="queryReadInfoOperators" resultType="com.engine.salary.elog.entity.dto.ReadInfoEntity" databaseId="postgresql">
|
||||
select log_operator employeeId, max(log_date) date
|
||||
from ${tableName}
|
||||
where targetid = #{targetId}
|
||||
and operatetype = #{operateType}
|
||||
group by log_operator
|
||||
order by date desc
|
||||
</select>
|
||||
|
||||
<select id="queryReadInfoOperators" resultType="com.engine.salary.elog.entity.dto.ReadInfoEntity" databaseId="oracle">
|
||||
select log_operator employeeId, max(log_date) "date"
|
||||
from ${tableName}
|
||||
where targetid = #{targetId}
|
||||
and operatetype = #{operateType}
|
||||
group by log_operator
|
||||
order by "date" desc
|
||||
</select>
|
||||
<select id="queryReadInfoOperators" resultType="com.engine.salary.elog.entity.dto.ReadInfoEntity" databaseId="sqlserver">
|
||||
select log_operator employeeId, max(log_date) "date"
|
||||
from ${tableName}
|
||||
where targetid = #{targetId}
|
||||
and operatetype = #{operateType}
|
||||
group by log_operator
|
||||
order by "date" desc
|
||||
</select>
|
||||
|
||||
<select id="queryReadInfoDateOperators" resultType="com.engine.salary.elog.entity.dto.ReadInfoEntity">
|
||||
select log_operator employeeId, max(log_date) date from ${tableName} where targetid = #{targetId} and
|
||||
operatetype = #{operateType}
|
||||
<if test="startDate != null">
|
||||
AND log_date <![CDATA[ >= ]]> #{startDate}
|
||||
</if>
|
||||
<if test="endDate != null">
|
||||
AND log_date <![CDATA[ <= ]]> #{endDate}
|
||||
</if>
|
||||
group by log_operator order by log_date desc
|
||||
</select>
|
||||
|
||||
<select id="queryReadInfoDateOperators" resultType="com.engine.salary.elog.entity.dto.ReadInfoEntity"
|
||||
databaseId="postgresql">
|
||||
select log_operator employeeId, max(log_date) date from ${tableName} where targetid = #{targetId} and
|
||||
operatetype = #{operateType}
|
||||
<if test="startDate != null">
|
||||
AND log_date <![CDATA[ >= ]]> #{startDate}
|
||||
</if>
|
||||
<if test="endDate != null">
|
||||
AND log_date <![CDATA[ <= ]]> #{endDate}
|
||||
</if>
|
||||
group by log_operator order by date desc
|
||||
</select>
|
||||
|
||||
<select id="queryReadInfoDateOperators" resultType="com.engine.salary.elog.entity.dto.ReadInfoEntity" databaseId="oracle">
|
||||
select log_operator employeeId, max(log_date) "date" from ${tableName} where targetid = #{targetId} and
|
||||
operatetype = #{operateType}
|
||||
<if test="startDate != null">
|
||||
AND log_date <![CDATA[ >= ]]> TO_DATE(#{startDate}, 'SYYYY-MM-DD HH24:MI:SS')
|
||||
</if>
|
||||
<if test="endDate != null">
|
||||
AND log_date <![CDATA[ <= ]]> TO_DATE(#{endDate}, 'SYYYY-MM-DD HH24:MI:SS')
|
||||
</if>
|
||||
group by log_operator order by "date" desc
|
||||
</select>
|
||||
|
||||
<select id="queryReadInfoDateOperators" resultType="com.engine.salary.elog.entity.dto.ReadInfoEntity"
|
||||
databaseId="sqlserver">
|
||||
select log_operator employeeId, max(log_date) "date" from ${tableName} where targetid = #{targetId} and
|
||||
operatetype = #{operateType}
|
||||
<if test="startDate != null">
|
||||
AND log_date <![CDATA[ >= ]]> #{startDate}
|
||||
</if>
|
||||
<if test="endDate != null">
|
||||
AND log_date <![CDATA[ <= ]]> #{endDate}
|
||||
</if>
|
||||
group by log_operator order by "date" desc
|
||||
</select>
|
||||
|
||||
|
||||
<select id="queryElogContextById" resultType="java.lang.Integer">
|
||||
select 1
|
||||
from ${tableName}
|
||||
where id = #{id}
|
||||
</select>
|
||||
|
||||
<select id="queryElogTraceInfo" resultType="java.util.Map">
|
||||
select operatorname,
|
||||
targetname,
|
||||
modulename,
|
||||
operatetypename,
|
||||
DATE_FORMAT(log_date, "%Y-%m-%d %H:%i:%S") createdate
|
||||
from ${tableName}
|
||||
where belongmainid = #{traceId}
|
||||
order by log_date desc, id desc LIMIT #{offset}, #{pageSize}
|
||||
</select>
|
||||
<select id="queryElogTraceInfo" resultType="java.util.Map" databaseId="postgresql">
|
||||
select operatorname,
|
||||
targetname,
|
||||
modulename,
|
||||
operatetypename,
|
||||
to_char(log_date::timestamp, 'YYYY-MM-DD HH24:MI:SS') createdate
|
||||
from ${tableName}
|
||||
where belongmainid = #{traceId}
|
||||
order by log_date desc, id desc limit #{pageSize}
|
||||
offset #{offset}
|
||||
|
||||
</select>
|
||||
<select id="queryElogTraceInfo" resultType="java.util.Map" databaseId="oracle">
|
||||
SELECT operatorname, targetname, modulename, operatetypename
|
||||
FROM (SELECT TMP.*, ROWNUM ROW_ID
|
||||
FROM (select t.*, to_char(log_date, 'yyyy-mm-dd HH24:mi:ss') createdate
|
||||
from ${tableName} t
|
||||
where belongmainid = #{traceId}
|
||||
order by log_date desc, id desc) TMP
|
||||
WHERE ROWNUM <= (#{pageSize} + #{offset}))
|
||||
WHERE ROW_ID > #{offset}
|
||||
|
||||
|
||||
</select>
|
||||
<select id="queryElogTraceInfo" resultType="java.util.Map" databaseId="sqlserver">
|
||||
select atmp.operatorname, atmp.targetname, atmp.modulename, atmp.operatetypename
|
||||
from (select atmp.*, row_number() over(order by log_date desc ,id desc ) as rownumber
|
||||
from (select top(#{pageSize}) atmp.*
|
||||
from (select *, convert(nvarchar(19), log_date, 120) createdate
|
||||
from ${tableName}
|
||||
where belongmainid = #{traceId}) atmp
|
||||
order by log_date desc, id desc) atmp) atmp
|
||||
where rownumber > #{offset}
|
||||
order by log_date desc, id desc
|
||||
|
||||
|
||||
</select>
|
||||
|
||||
<select id="queryElogTraceInfoCount" resultType="java.lang.Integer">
|
||||
select count(id) id
|
||||
from ${tableName}
|
||||
where belongmainid = #{traceId}
|
||||
</select>
|
||||
|
||||
<select id="queryLogInfoByCustom" resultType="java.util.Map">
|
||||
select * from ${tableName}
|
||||
<where>${sql}</where>
|
||||
</select>
|
||||
|
||||
<select id="queryAllChangesData" resultType="java.util.Map">
|
||||
select *
|
||||
from ${tableName}
|
||||
where mainid = #{mainid}
|
||||
order by showorder asc, id asc
|
||||
</select>
|
||||
|
||||
<select id="queryTenantKeyOperators" resultType="com.engine.salary.elog.entity.dto.ReadInfoEntity">
|
||||
select log_operator employeeId, max(log_date) date
|
||||
from ${tableName}
|
||||
where tenant_key = #{tenantKey}
|
||||
and targetid = #{targetId}
|
||||
and operatetype = #{operateType}
|
||||
group by log_operator
|
||||
order by date desc
|
||||
</select>
|
||||
|
||||
<select id="queryTenantKeyOperators" resultType="com.engine.salary.elog.entity.dto.ReadInfoEntity" databaseId="postgresql">
|
||||
select log_operator employeeId, max(log_date) date
|
||||
from ${tableName}
|
||||
where tenant_key = #{tenantKey}
|
||||
and targetid = #{targetId}
|
||||
and operatetype = #{operateType}
|
||||
group by log_operator
|
||||
order by date desc
|
||||
</select>
|
||||
|
||||
|
||||
<select id="queryTenantKeyOperators" resultType="com.engine.salary.elog.entity.dto.ReadInfoEntity" databaseId="oracle">
|
||||
select log_operator employeeId, max(log_date) "date"
|
||||
from ${tableName}
|
||||
where tenant_key = #{tenantKey}
|
||||
and targetid = #{targetId}
|
||||
and operatetype = #{operateType}
|
||||
group by log_operator
|
||||
order by "date" desc
|
||||
</select>
|
||||
<select id="queryTenantKeyOperators" resultType="com.engine.salary.elog.entity.dto.ReadInfoEntity" databaseId="sqlserver">
|
||||
select log_operator employeeId, max(log_date) "date"
|
||||
from ${tableName}
|
||||
where tenant_key = #{tenantKey}
|
||||
and targetid = #{targetId}
|
||||
and operatetype = #{operateType}
|
||||
group by log_operator
|
||||
order by "date" desc
|
||||
</select>
|
||||
|
||||
<select id="queryAllChangesDataPages" resultType="java.util.Map">
|
||||
select *
|
||||
from ${tableName}
|
||||
where mainid = #{mainid}
|
||||
order by showorder asc, id asc
|
||||
</select>
|
||||
|
||||
|
||||
<select id="queryAllChangesPageCounts" resultType="java.lang.Integer">
|
||||
select count(*)
|
||||
from ${tableName}
|
||||
where mainid = #{mainid}
|
||||
</select>
|
||||
<select id="elogCountOnlyNum" resultType="java.lang.Long">
|
||||
select count(*) from ${tableName}
|
||||
where modulename = #{logContent.moduleName} and functionname = #{logContent.functionName}
|
||||
and delete_type = 0
|
||||
<if test="logContent.operator != null and logContent.operator !=''">
|
||||
and log_operator = #{logContent.operator}
|
||||
</if>
|
||||
<if test="conditionSql != null">${conditionSql}</if>
|
||||
</select>
|
||||
</mapper>
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
package com.engine.salary.mapper.elog;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public interface QueryCurretValusMapper {
|
||||
|
||||
Map queryValues(String sql);
|
||||
}
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
<?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.engine.salary.mapper.elog.QueryCurretValusMapper">
|
||||
|
||||
<select id="queryValues" resultType="java.util.Map">
|
||||
${querySql} limit 1
|
||||
</select>
|
||||
</mapper>
|
||||
Loading…
Reference in New Issue