记录操作日志
This commit is contained in:
parent
7103eb0c73
commit
2175d7ca6a
|
|
@ -6,7 +6,10 @@ INSERT INTO jcl_field_extendgroup
|
|||
VALUES(2, 2, '基本信息', 1, 0, '2022-06-17', '2022-06-17', NULL, '1', 1, 0);
|
||||
INSERT INTO jcl_field_extendgroup
|
||||
(id, extend_type, group_name, creator, delete_type, create_time, update_time, pid, is_show, show_order, is_system_default)
|
||||
VALUES(3, 3, '基本信息', 1, 0, '2022-06-17', '2022-06-17', NULL, '1', 1, 0);
|
||||
VALUES(3, 3, '基础信息', 1, 0, '2022-06-17', '2022-06-17', NULL, '1', 1, 0);
|
||||
INSERT INTO jcl_field_extendgroup
|
||||
(id, extend_type, group_name, creator, delete_type, create_time, update_time, pid, is_show, show_order, is_system_default)
|
||||
VALUES(4, 4, '基本信息', 1, 0, '2022-06-17', '2022-06-17', NULL, '1', 1, 0);
|
||||
INSERT INTO jcl_field_extendgroup
|
||||
(id, extend_type, group_name, creator, delete_type, create_time, update_time, pid, is_show, show_order, is_system_default)
|
||||
VALUES(5, 3, '职务', 1, 0, '2022-07-05', '2022-07-05', 3, '1', 1, 1);
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ import java.util.Date;
|
|||
)
|
||||
public class LogViewVO {
|
||||
|
||||
@OrganizationTableColumn(text = "操作时间", width = "20%", column = "create_time",transmethod = "com.engine.organization.transmethod.LogViewTransMethod.getDateTimeFormat")
|
||||
@OrganizationTableColumn(text = "操作时间", width = "20%", column = "create_time", transmethod = "com.engine.organization.transmethod.LogViewTransMethod.getDateTimeFormat")
|
||||
private Date createTime;
|
||||
|
||||
@OrganizationTableColumn(text = "操作者", width = "16%", column = "operator_name")
|
||||
|
|
@ -51,7 +51,7 @@ public class LogViewVO {
|
|||
@OrganizationTableColumn(text = "操作IP", width = "16%", column = "client_ip")
|
||||
private String clientIp;
|
||||
|
||||
@OrganizationTableColumn(text = "操作参数", width = "16%", column = "params_str")
|
||||
@OrganizationTableColumn(text = "操作参数", width = "16%", column = "params_str", display = false)
|
||||
private String paramsStr;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,8 @@
|
|||
package com.engine.organization.transmethod;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.alibaba.fastjson.serializer.SerializerFeature;
|
||||
import com.engine.organization.enums.OperateTypeEnum;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
|
||||
|
|
@ -39,10 +42,24 @@ public class LogViewTransMethod {
|
|||
return "";
|
||||
}
|
||||
|
||||
public String getDateTimeFormat(String dateTime){
|
||||
if(StringUtils.isNotBlank(dateTime)){
|
||||
dateTime = dateTime.substring(0,dateTime.length() - 2);
|
||||
public String getDateTimeFormat(String dateTime) {
|
||||
if (StringUtils.isNotBlank(dateTime)) {
|
||||
dateTime = dateTime.substring(0, dateTime.length() - 2);
|
||||
}
|
||||
return dateTime;
|
||||
}
|
||||
|
||||
public static String getFormatJson(String jsonStr) {
|
||||
if (StringUtils.isNotBlank(jsonStr)) {
|
||||
try {
|
||||
JSONObject object = JSONObject.parseObject(jsonStr);
|
||||
jsonStr = JSON.toJSONString(object, SerializerFeature.PrettyFormat, SerializerFeature.WriteMapNullValue,
|
||||
SerializerFeature.WriteDateUseDateFormat);
|
||||
jsonStr= jsonStr.replace("\n","<br/>").replace("\t","    ");
|
||||
} catch (Exception e) {
|
||||
return jsonStr;
|
||||
}
|
||||
}
|
||||
return jsonStr;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSON;
|
|||
import com.engine.core.impl.Service;
|
||||
import com.engine.organization.entity.LoggerContext;
|
||||
import com.engine.organization.entity.logview.bo.FieldBaseEquator;
|
||||
import com.engine.organization.transmethod.LogViewTransMethod;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
|
@ -30,6 +31,7 @@ public class OrganizationWrapper extends Service {
|
|||
Method method = clazz.getEnclosingMethod();
|
||||
LoggerContext loggerContext;
|
||||
if (null != before) {
|
||||
String formatJson = LogViewTransMethod.getFormatJson(params);
|
||||
if (null != after) {
|
||||
FieldBaseEquator fieldBaseEquator = new FieldBaseEquator();
|
||||
List<String> diffFields = fieldBaseEquator.getDiffFields(before, after);
|
||||
|
|
@ -40,10 +42,10 @@ public class OrganizationWrapper extends Service {
|
|||
for (int i = 0; i < diffFields.size(); i++) {
|
||||
message.append(i + 1).append(".").append(diffFields.get(i)).append("<br/>");
|
||||
}
|
||||
loggerContext = LoggerContext.builder().operatorId(user.getUID()).value(value).clientIp(user.getLoginip()).paramsStr(params).operatorName(user.getLastname()).message(message.toString()).build();
|
||||
loggerContext = LoggerContext.builder().operatorId(user.getUID()).value(value).clientIp(user.getLoginip()).paramsStr(formatJson).operatorName(user.getLastname()).message(message.toString()).build();
|
||||
|
||||
} else {
|
||||
loggerContext = LoggerContext.builder().operatorId(user.getUID()).value(value).clientIp(user.getLoginip()).paramsStr(params).operatorName(user.getLastname()).message(JSON.toJSONString(before)).build();
|
||||
loggerContext = LoggerContext.builder().operatorId(user.getUID()).value(value).clientIp(user.getLoginip()).paramsStr(formatJson).operatorName(user.getLastname()).message(JSON.toJSONString(before)).build();
|
||||
}
|
||||
LogAspect logAspect = new LogAspect(clazz, method, loggerContext);
|
||||
logAspect.start();
|
||||
|
|
|
|||
Loading…
Reference in New Issue