添加日志的操作人和时间的完整性

This commit is contained in:
sh
2026-02-04 23:13:13 +08:00
parent f7f31ae0fa
commit a5af4b6615
17 changed files with 361 additions and 25 deletions

View File

@@ -7,9 +7,11 @@ import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.EncryptDecryptUtil;
import com.ruoyi.common.utils.poi.ExcelUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.quickssl.api.CryptoClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
@@ -29,6 +31,8 @@ public class BussinessOperlogController extends BaseController
{
@Autowired
private IBussinessOperLogService operLogService;
@Autowired
private EncryptDecryptUtil encryptDecryptUtil;
@PreAuthorize("@ss.hasPermi('monitor:operlog:list')")
@GetMapping("/list")
@@ -37,6 +41,21 @@ public class BussinessOperlogController extends BaseController
{
startPage();
List<BussinessOperLog> list = operLogService.selectOperLogList(operLog);
for(BussinessOperLog bussinessOperLog:list){
boolean verifyName;
boolean verifyTime;
try {
verifyName=encryptDecryptUtil.sm3Verify(bussinessOperLog.getOperName(),bussinessOperLog.getOperNameCipher());
verifyTime=encryptDecryptUtil.sm3Verify(bussinessOperLog.getOperTime(),bussinessOperLog.getOperTimeCipher());
} catch (CryptoClient.CryptoException e) {
verifyName = false;
verifyTime = false;
}
if(!verifyTime || !verifyName){
System.out.println("完整性校验失败:{}==========="+bussinessOperLog.getOperId());
return error(500,"日志数据已被篡改,请联系管理员确定!");
}
}
return getDataTable(list);
}

View File

@@ -20,6 +20,7 @@ import com.ruoyi.common.core.domain.entity.Company;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.EncryptDecryptUtil;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.bean.BeanUtils;
@@ -27,6 +28,7 @@ import com.ruoyi.common.utils.poi.ExcelUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.collections4.CollectionUtils;
import org.quickssl.api.CryptoClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
@@ -66,6 +68,8 @@ public class CmsJobController extends BaseController
private IJobApplyService iJobApplyService;
@Autowired
private IAppReviewJobService iAppReviewJobService;
@Autowired
private EncryptDecryptUtil encryptDecryptUtil;
/**
* 查询岗位列表
*/
@@ -455,10 +459,15 @@ public class CmsJobController extends BaseController
@ApiOperation("岗位上架")
@PutMapping("/jobUp/{jobId}")
public AjaxResult jobUp(@PathVariable("jobId") Long jobId){
public AjaxResult jobUp(@PathVariable("jobId") Long jobId) throws CryptoClient.CryptoException {
String aa=encryptDecryptUtil.sm3Hash("2026-02-04 19:10:13");
System.out.println(aa);
System.out.println(encryptDecryptUtil.sm3Verify("2026-02-04 19:10:13",aa));
if(jobId==null){
return error("岗位id为空");
}
return toAjax(jobService.jobUp(jobId));
}
}

View File

@@ -87,7 +87,7 @@ public class BussinessOperLog extends BaseEntity
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "操作时间", width = 30, dateFormat = "yyyy-MM-dd")
@ApiModelProperty("操作时间")
private Date operTime;
private String operTime;
@Excel(name = "消耗时间")
@ApiModelProperty("消耗时间")
@@ -95,4 +95,10 @@ public class BussinessOperLog extends BaseEntity
@ApiModelProperty("业务类型数组")
private Integer[] businessTypes;
@ApiModelProperty("时间完整性")
private String operTimeCipher;
@ApiModelProperty("操作人完整性")
private String operNameCipher;
}

View File

@@ -25,13 +25,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</resultMap>
<sql id="selectOperLogVo">
select oper_id, title, business_type, method, request_method, operator_type, oper_name, dept_name, oper_url, oper_ip, oper_location, oper_param, json_result, status, error_msg, oper_time, cost_time
select oper_id, title, business_type, method, request_method, operator_type, oper_name, dept_name, oper_url, oper_ip, oper_location, oper_param, json_result, status, error_msg, oper_time, cost_time,oper_time_cipher,oper_name_cipher
from bussiness_oper_log
</sql>
<insert id="insertOperlog" parameterType="BussinessOperLog">
insert into bussiness_oper_log(title, business_type, method, request_method, operator_type, oper_name, dept_name, oper_url, oper_ip, oper_location, oper_param, json_result, status, error_msg, cost_time, oper_time)
values (#{title}, #{businessType}, #{method}, #{requestMethod}, #{operatorType}, #{operName}, #{deptName}, #{operUrl}, #{operIp}, #{operLocation}, #{operParam}, #{jsonResult}, #{status}, #{errorMsg}, #{costTime}, sysdate())
insert into bussiness_oper_log(title, business_type, method, request_method, operator_type, oper_name, dept_name, oper_url, oper_ip, oper_location, oper_param, json_result, status, error_msg, cost_time, oper_time,oper_time_cipher,oper_name_cipher)
values (#{title}, #{businessType}, #{method}, #{requestMethod}, #{operatorType}, #{operName}, #{deptName}, #{operUrl}, #{operIp}, #{operLocation}, #{operParam}, #{jsonResult}, #{status}, #{errorMsg}, #{costTime},#{operTime},#{operTimeCipher},#{operNameCipher})
</insert>
<select id="selectOperLogList" parameterType="BussinessOperLog" resultMap="SysOperLogResult">