新增审计日志列表
This commit is contained in:
@@ -23,7 +23,7 @@
|
||||
AND A.Dev_Type = B.Id
|
||||
AND A.Update_By = C.Id
|
||||
<if test="devType != null and devType != ''">
|
||||
AND A.Dev_Type = '${devType}'
|
||||
AND A.Dev_Type = ${devType}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@ import com.njcn.device.service.ProgramVersionService;
|
||||
import com.njcn.web.utils.RequestUtil;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.FileCopyUtils;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
@@ -46,6 +47,7 @@ public class ProgramVersionServiceImpl extends ServiceImpl<VersionMapper, Versio
|
||||
page.setCurrent(pageNum);
|
||||
|
||||
List<VersionVO> version = programVersionMapper.getVersion(devType);
|
||||
if (!CollectionUtils.isEmpty(version)) {
|
||||
for (VersionVO vo: version) {
|
||||
if (vo.getVersionType().isEmpty()) {
|
||||
vo.setVersionType("通用");
|
||||
@@ -59,6 +61,7 @@ public class ProgramVersionServiceImpl extends ServiceImpl<VersionMapper, Versio
|
||||
List<List<VersionVO>> partition = Lists.partition(version, pageSize);
|
||||
List<VersionVO> versionVOS = partition.get(pageNum - 1);
|
||||
page.setRecords(versionVOS);
|
||||
}
|
||||
return page;
|
||||
}
|
||||
|
||||
@@ -76,7 +79,6 @@ public class ProgramVersionServiceImpl extends ServiceImpl<VersionMapper, Versio
|
||||
} else {
|
||||
version.setVersionType("");
|
||||
}
|
||||
version.setName(name);
|
||||
|
||||
byte[] b = null, bytes = null;
|
||||
try {
|
||||
|
||||
@@ -46,15 +46,6 @@ public class AuditController extends BaseController {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS,result,methodDescribe);
|
||||
}
|
||||
|
||||
// @OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
// @GetMapping("/insetAuditLog")
|
||||
// @ApiOperation("添加审计日志")
|
||||
// public HttpResult insetAuditLog(){
|
||||
// String methodDescribe = getMethodDescribe("insetAuditLog");
|
||||
// auditService.insetAuditLog();
|
||||
// return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS,null,methodDescribe);
|
||||
// }
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -3,6 +3,13 @@
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.njcn.system.mapper.AuditMapper">
|
||||
|
||||
<select id="getCount" resultType="int">
|
||||
SELECT count(id)
|
||||
FROM sys_user_log
|
||||
WHERE update_time >= #{auditParam.searchBeginTime}
|
||||
AND #{auditParam.searchEndTime} >= update_time
|
||||
</select>
|
||||
|
||||
<select id="selectAuditLog" resultType="UserLog">
|
||||
SELECT
|
||||
id,
|
||||
@@ -18,28 +25,22 @@
|
||||
create_by createBy,
|
||||
create_time createTime,
|
||||
update_by updateBy,
|
||||
update_time updateTime
|
||||
update_time updateTime,
|
||||
fail_reason failReason
|
||||
FROM
|
||||
sys_user_log
|
||||
WHERE update_time >= #{auditParam.searchBeginTime}
|
||||
AND #{auditParam.searchEndTime} >= update_time
|
||||
<!-- <if test="auditParam.userName!=null">-->
|
||||
<!-- and update_by = #{auditParam.userName}-->
|
||||
<!-- </if>-->
|
||||
<!-- <if test="auditParam.type!=null">-->
|
||||
<!-- and type = #{auditParam.type}-->
|
||||
<!-- </if>-->
|
||||
<!-- <if test="auditParam.operate!=null">-->
|
||||
<!-- and operate_type = #{auditParam.operate}-->
|
||||
<!-- </if>-->
|
||||
<if test="auditParam.userName!=null">
|
||||
and user_name = #{auditParam.userName}
|
||||
</if>
|
||||
<if test="auditParam.type!=null">
|
||||
and type = #{auditParam.type}
|
||||
</if>
|
||||
<if test="auditParam.operate!=null">
|
||||
and operate = #{auditParam.operate}
|
||||
</if>
|
||||
AND id >= (select id from sys_user_log order by id limit #{auditParam.pageNum}, 1) limit #{auditParam.pageSize}
|
||||
</select>
|
||||
|
||||
<select id="getCount" resultType="int">
|
||||
SELECT count(id)
|
||||
FROM sys_user_log
|
||||
WHERE update_time >= #{auditParam.searchBeginTime}
|
||||
AND #{auditParam.searchEndTime} >= update_time
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -8,6 +8,7 @@ import com.njcn.system.pojo.vo.AuditLogVO;
|
||||
import com.njcn.system.service.AuditService;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
@@ -42,46 +43,40 @@ public class AuditServiceImpl implements AuditService {
|
||||
|
||||
auditParam.setPageNum(auditParam.getPageSize()*(auditParam.getPageNum()-1));
|
||||
List<UserLog> userLogs = auditMapper.selectAuditLog(auditParam);
|
||||
if (!CollectionUtils.isEmpty(userLogs)) {
|
||||
for (UserLog userLog: userLogs) {
|
||||
AuditLogVO auditLogVO = new AuditLogVO();
|
||||
String ip = userLog.getIp();
|
||||
auditLogVO.setIp(userLog.getIp());
|
||||
String updateTime = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss").format(userLog.getUpdateTime());
|
||||
auditLogVO.setTime(updateTime);
|
||||
auditLogVO.setUserName(userLog.getUserName());
|
||||
auditLogVO.setOperate(userLog.getOperate());
|
||||
StringBuffer stringBuffer = new StringBuffer();
|
||||
stringBuffer.append(userLog.getUserName()).append(userLog.getUpdateBy()).append("在")
|
||||
.append(userLog.getOperateType());
|
||||
|
||||
|
||||
StringBuilder describe = new StringBuilder();
|
||||
describe.append(userLog.getUserName()).append("在").append(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm").format(userLog.getUpdateTime())).append("在").append(userLog.getIp()).append("执行了").append(userLog.getOperate()).append(",结果为");
|
||||
if (userLog.getResult()==1) {
|
||||
describe.append("成功");
|
||||
}
|
||||
if (userLog.getResult()==0) {
|
||||
describe.append("失败").append(",失败原因为").append(userLog.getFailReason());
|
||||
}
|
||||
auditLogVO.setDescribe(describe.toString());
|
||||
auditLogVO.setOperateType(userLog.getType() == 0 ? "业务事件" : "系统事件");
|
||||
auditLogVO.setResult(userLog.getResult() == 0 ? "失败" : "成功");
|
||||
auditLogVO.setIp(userLog.getIp());
|
||||
if (userLog.getLevel()==0) {
|
||||
auditLogVO.setLevel("普通");
|
||||
}if (userLog.getLevel()==1) {
|
||||
auditLogVO.setLevel("中等");
|
||||
}if (userLog.getLevel()==2) {
|
||||
auditLogVO.setLevel("严重");
|
||||
}
|
||||
auditLogVOS.add(auditLogVO);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//当前页数据
|
||||
// page.setRecords();
|
||||
|
||||
|
||||
return null;
|
||||
page.setRecords(auditLogVOS);
|
||||
return page;
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public void insetAuditLog() {
|
||||
// Audit audit = new Audit();
|
||||
// String userId = IdUtil.simpleUUID();
|
||||
// audit.setId(userId);
|
||||
// audit.setIp("225.225.225.2");
|
||||
// audit.setOperate("查询稳态趋势对比");
|
||||
// audit.setType(0);
|
||||
// audit.setResult("成功");
|
||||
// audit.setLevel("普通");
|
||||
// audit.setUserLogDescribe("正式用户组yfyw2在2022-07-12 10:38在49.72.16.99执行了查询稳态趋势对比,结果为成功");
|
||||
// audit.setUpdateBy("e9e2251e3149462aaea6c73cbda5eaa3");
|
||||
// audit.setUpdateTime(LocalDateTime.now());
|
||||
// audit.setState(0);
|
||||
// auditMapper.insert(audit);
|
||||
// }
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user