增加系统业务配置操作日志功能,与系统日志菜单分离,增加相关国际化字典,并更新国际化部分翻译
This commit is contained in:
@@ -35,6 +35,17 @@ public class SysLog extends BaseEntity<SysLog>{
|
||||
private Long consumerTime;//消费时间
|
||||
|
||||
private Integer functionId;//功能菜单id
|
||||
private String compileIds;//配置编译id
|
||||
private String cfgIds;//界面配置id
|
||||
private Integer compileId;//配置编译id
|
||||
private Integer cfgId;//界面配置id
|
||||
private String methodName;//功能方法名称
|
||||
private Integer auditState;//审核状态
|
||||
private Integer action;//GK动作
|
||||
private String operation;//操作说明
|
||||
private String functionName;//功能名称
|
||||
private Integer isValid;//配置有效状态
|
||||
|
||||
|
||||
public Long getConsumerTime() {
|
||||
return consumerTime;
|
||||
@@ -165,6 +176,86 @@ public class SysLog extends BaseEntity<SysLog>{
|
||||
this.functionId = functionId;
|
||||
}
|
||||
|
||||
public Integer getCompileId() {
|
||||
return compileId;
|
||||
}
|
||||
|
||||
public void setCompileId(Integer compileId) {
|
||||
this.compileId = compileId;
|
||||
}
|
||||
|
||||
public String getMethodName() {
|
||||
return methodName;
|
||||
}
|
||||
|
||||
public void setMethodName(String methodName) {
|
||||
this.methodName = methodName;
|
||||
}
|
||||
|
||||
public Integer getAuditState() {
|
||||
return auditState;
|
||||
}
|
||||
|
||||
public void setAuditState(Integer auditState) {
|
||||
this.auditState = auditState;
|
||||
}
|
||||
|
||||
public Integer getAction() {
|
||||
return action;
|
||||
}
|
||||
|
||||
public void setAction(Integer action) {
|
||||
this.action = action;
|
||||
}
|
||||
|
||||
public String getCompileIds() {
|
||||
return compileIds;
|
||||
}
|
||||
|
||||
public void setCompileIds(String compileIds) {
|
||||
this.compileIds = compileIds;
|
||||
}
|
||||
|
||||
public String getCfgIds() {
|
||||
return cfgIds;
|
||||
}
|
||||
|
||||
public void setCfgIds(String cfgIds) {
|
||||
this.cfgIds = cfgIds;
|
||||
}
|
||||
|
||||
public Integer getCfgId() {
|
||||
return cfgId;
|
||||
}
|
||||
|
||||
public void setCfgId(Integer cfgId) {
|
||||
this.cfgId = cfgId;
|
||||
}
|
||||
|
||||
public String getOperation() {
|
||||
return operation;
|
||||
}
|
||||
|
||||
public void setOperation(String operation) {
|
||||
this.operation = operation;
|
||||
}
|
||||
|
||||
public String getFunctionName() {
|
||||
return functionName;
|
||||
}
|
||||
|
||||
public void setFunctionName(String functionName) {
|
||||
this.functionName = functionName;
|
||||
}
|
||||
|
||||
public Integer getIsValid() {
|
||||
return isValid;
|
||||
}
|
||||
|
||||
public void setIsValid(Integer isValid) {
|
||||
this.isValid = isValid;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置请求参数
|
||||
* @param paramMap
|
||||
|
||||
@@ -67,7 +67,26 @@ public class LogUtils {
|
||||
}else{
|
||||
log.setFunctionId(Integer.parseInt(request.getParameter("functionId")));
|
||||
}
|
||||
if(!StringUtil.isEmpty(request.getParameter("compileId"))){
|
||||
log.setCompileIds(request.getParameter("compileId"));
|
||||
}else{
|
||||
log.setCompileIds(request.getParameter("compileIds"));
|
||||
}
|
||||
|
||||
if(!StringUtil.isEmpty(request.getParameter("cfgId"))){
|
||||
log.setCfgIds(request.getParameter("cfgId"));
|
||||
}else{
|
||||
log.setCfgIds(request.getParameter("ids"));
|
||||
}
|
||||
if(!StringUtil.isEmpty(request.getParameter("isAudit"))){
|
||||
log.setAuditState(Integer.parseInt(request.getParameter("isAudit")));
|
||||
}
|
||||
if(!StringUtil.isEmpty(request.getParameter("action"))){
|
||||
log.setAction(Integer.parseInt(request.getParameter("action")));
|
||||
}
|
||||
if(!(StringUtil.isEmpty(request.getParameter("isValid")))){
|
||||
log.setIsValid(Integer.parseInt(request.getParameter("isValid")));
|
||||
}
|
||||
// 异步保存日志
|
||||
new SaveLogThread(log, handler, ex).start();
|
||||
}
|
||||
@@ -96,6 +115,7 @@ public class LogUtils {
|
||||
String permission = "";
|
||||
if (handler instanceof HandlerMethod){
|
||||
Method m = ((HandlerMethod)handler).getMethod();
|
||||
log.setMethodName(m.getName());
|
||||
RequiresPermissions rp = m.getAnnotation(RequiresPermissions.class);
|
||||
permission = (rp != null ? StringUtils.join(rp.value(), ",") : "");
|
||||
}
|
||||
@@ -104,11 +124,44 @@ public class LogUtils {
|
||||
}
|
||||
// 如果有异常,设置异常信息
|
||||
log.setException(Exceptions.getStackTraceAsString(ex));
|
||||
// 如果无标题并无异常日志,则不保存信息
|
||||
if (StringUtils.isBlank(log.getTitle()) && StringUtils.isBlank(log.getException())){
|
||||
// 如果无标题并无异常日志并且无具体的功能id(非业务配置的操作),则不保存信息
|
||||
if ((StringUtils.isBlank(log.getTitle()) && StringUtils.isBlank(log.getException()) && (log.getFunctionId()==null || log.getFunctionId()==0))){
|
||||
return;
|
||||
}
|
||||
// 保存日志信息
|
||||
if(log.getFunctionId()!=null
|
||||
&& log.getFunctionId()!=0 ){
|
||||
String functionName = DictUtils.getDictLabel("SYS_SERVICE_FUNCTION", log.getFunctionId().toString());
|
||||
if(!StringUtil.isEmpty(log.getMethodName())){
|
||||
String operation = DictUtils.getDictLabel("SYS_SERVICE_OPERATION", log.getMethodName());
|
||||
if("saveOrUpdate".equals(operation)){
|
||||
if (log.getCfgId()!=null || log.getCfgIds()!=null || log.getCompileId()!=null || log.getCompileIds()!=null){
|
||||
log.setOperation("edit");
|
||||
}else{
|
||||
log.setOperation("add");
|
||||
}
|
||||
}else{
|
||||
log.setOperation(operation);
|
||||
}
|
||||
}
|
||||
if(log.getOperation()!=null && !"默认".equals(log.getOperation()) && !"默认".equals(functionName)){
|
||||
log.setFunctionName(functionName);
|
||||
if(!StringUtil.isEmpty(log.getCompileIds())){
|
||||
for(String compileId:StringUtils.split(log.getCompileIds(),",")){
|
||||
log.setCompileId(Integer.parseInt(compileId));
|
||||
logDao.insertCfgOperationLog(log);
|
||||
}
|
||||
}else if(!StringUtil.isEmpty(log.getCfgIds())){
|
||||
for(String cfgId:StringUtils.split(log.getCfgIds(),",")){
|
||||
log.setCfgId(Integer.parseInt(cfgId));
|
||||
logDao.insertCfgOperationLog(log);
|
||||
}
|
||||
}else{
|
||||
logDao.insertCfgOperationLog(log);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
logDao.insert(log);
|
||||
}
|
||||
}
|
||||
@@ -202,7 +255,6 @@ public class LogUtils {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CacheUtils.put(CACHE_MENU_NAME_PATH_MAP, menuMap);
|
||||
CacheUtils.put(CACHE_MENU_NAME_PATH_MAP2, menuMap2);
|
||||
}
|
||||
@@ -240,7 +292,6 @@ public class LogUtils {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
System.out.println(menuNamePath);
|
||||
return menuNamePath;
|
||||
}
|
||||
|
||||
|
||||
@@ -24,4 +24,11 @@ public class SysLogController extends BaseController {
|
||||
return "/sys/logList";
|
||||
}
|
||||
|
||||
@RequiresPermissions("sys:cfgOperationLog:view")
|
||||
@RequestMapping(value = {"cfgOperationLogList"})
|
||||
public String cfgOperationLogList(SysLog sysLog, HttpServletRequest request, HttpServletResponse response, Model model) {
|
||||
Page<SysLog> page = logService.findCfgOperationLogPage(new Page<SysLog>(request, response), sysLog);
|
||||
model.addAttribute("page", page);
|
||||
return "/sys/cfgOperationLogList";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
package com.nis.web.dao;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.nis.domain.SysLog;
|
||||
@MyBatisDao
|
||||
public interface SysLogDao extends CrudDao<SysLog>{
|
||||
|
||||
public void insertCfgOperationLog(SysLog log);
|
||||
public List<SysLog> findCfgOperationLogList(SysLog log);
|
||||
}
|
||||
@@ -28,6 +28,26 @@
|
||||
ORDER BY a.create_date DESC
|
||||
</select>
|
||||
|
||||
<select id="findCfgOperationLogList" resultType="sysLog">
|
||||
SELECT
|
||||
a.*
|
||||
FROM sys_cfg_operation_log a
|
||||
WHERE a.create_date BETWEEN #{beginDate} AND #{endDate}
|
||||
<if test="functionName != null and functionName != ''">
|
||||
AND a.function_name=#{functionName}
|
||||
</if>
|
||||
<if test="createBy != null and createBy != ''">
|
||||
AND a.create_by = #{createBy}
|
||||
</if>
|
||||
<if test="operation != null and operation != ''">
|
||||
AND a.operation=#{operation}
|
||||
</if>
|
||||
<if test="exception != null and exception != ''">
|
||||
AND a.state = 0
|
||||
</if>
|
||||
ORDER BY a.create_date DESC
|
||||
</select>
|
||||
|
||||
|
||||
<insert id="insert" parameterType="sysLog" useGeneratedKeys="true" keyProperty="id" >
|
||||
INSERT INTO sys_log(
|
||||
@@ -59,4 +79,49 @@
|
||||
)
|
||||
</insert>
|
||||
|
||||
<insert id="insertCfgOperationLog" parameterType="sysLog" useGeneratedKeys="true" keyProperty="id" >
|
||||
INSERT INTO sys_cfg_operation_log(
|
||||
type,
|
||||
title,
|
||||
create_by,
|
||||
create_date,
|
||||
remote_addr,
|
||||
user_agent,
|
||||
request_uri,
|
||||
method,
|
||||
state,
|
||||
consumer_time,
|
||||
params,
|
||||
exception,
|
||||
compile_id,
|
||||
cfg_id,
|
||||
function_id,
|
||||
method_name,
|
||||
audit_state,
|
||||
action,
|
||||
operation,
|
||||
function_name
|
||||
) VALUES (
|
||||
#{type},
|
||||
#{title},
|
||||
#{createBy},
|
||||
#{createDate},
|
||||
#{remoteAddr},
|
||||
#{userAgent},
|
||||
#{requestUri},
|
||||
#{method},
|
||||
#{state},
|
||||
#{consumerTime},
|
||||
#{params},
|
||||
#{exception},
|
||||
#{compileId},
|
||||
#{cfgId},
|
||||
#{functionId},
|
||||
#{methodName},
|
||||
#{auditState},
|
||||
#{action},
|
||||
#{operation},
|
||||
#{functionName}
|
||||
)
|
||||
</insert>
|
||||
</mapper>
|
||||
@@ -1,5 +1,8 @@
|
||||
package com.nis.web.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.nis.domain.Page;
|
||||
@@ -9,8 +12,9 @@ import com.nis.web.dao.SysLogDao;
|
||||
|
||||
@Service
|
||||
public class LogService extends CrudService<SysLogDao, SysLog> {
|
||||
|
||||
public Page<SysLog> findPage(Page<SysLog> page, SysLog sysLog) {
|
||||
@Autowired
|
||||
protected SysLogDao sysLogDao;
|
||||
public Page<SysLog> findPage(Page<SysLog> page, SysLog sysLog) {
|
||||
|
||||
// 设置默认时间范围,默认当前月
|
||||
if (sysLog.getBeginDate() == null){
|
||||
@@ -24,4 +28,17 @@ public Page<SysLog> findPage(Page<SysLog> page, SysLog sysLog) {
|
||||
|
||||
}
|
||||
|
||||
public Page<SysLog> findCfgOperationLogPage(Page<SysLog> page, SysLog sysLog) {
|
||||
|
||||
// 设置默认时间范围,默认当前月
|
||||
if (sysLog.getBeginDate() == null){
|
||||
sysLog.setBeginDate(DateUtils.setDays(DateUtils.parseDate(DateUtils.getDate()), 1));
|
||||
}
|
||||
if (sysLog.getEndDate() == null){
|
||||
sysLog.setEndDate(DateUtils.addMonths(sysLog.getBeginDate(), 1));
|
||||
}
|
||||
sysLog.setPage(page);
|
||||
List<SysLog> list = sysLogDao.findCfgOperationLogList(sysLog);
|
||||
return page.setList(list);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user