✨ Introducing new features. 字段变更审计功能

This commit is contained in:
lbw committed 2023-02-27 23:25:45 +08:00
1 parent 32bfde0552
commit 80ff07f744
11 files changed
+479 -54

No files matched your search

+64 -52
View File
@@ -38,13 +38,14 @@
<xxl.job.version>2.3.0</xxl.job.version>
<aliyun.version>3.0.52.ALL</aliyun.version>
<aws.version>1.11.543</aws.version>
<javers.version>6.10.0</javers.version>
<seata.version>1.6.1</seata.version>
<asm.version>7.1</asm.version>
<log4j2.version>2.17.1</log4j2.version>
<javaformat.plugin.version>0.0.23</javaformat.plugin.version>
<docker.plugin.version>0.33.0</docker.plugin.version>
<cloud.plugin.version>1.0.0</cloud.plugin.version>
<sentinel.version>1.8.4</sentinel.version>
<sentinel.version>1.8.4</sentinel.version>
</properties>
<dependencyManagement>
@@ -54,6 +55,11 @@
<artifactId>pigx-common-core</artifactId>
<version>${pigx.version}</version>
</dependency>
<dependency>
<groupId>com.pig4cloud</groupId>
<artifactId>pigx-common-audit</artifactId>
<version>${pigx.version}</version>
</dependency>
<dependency>
<groupId>com.pig4cloud</groupId>
<artifactId>pigx-common-data</artifactId>
@@ -150,23 +156,23 @@
<version>${pigx.version}</version>
</dependency>
<dependency>
<groupId>com.pig4cloud</groupId>
<artifactId>pigx-app-server-api</artifactId>
<version>${pigx.version}</version>
</dependency>
<dependency>
<groupId>com.pig4cloud</groupId>
<artifactId>pigx-app-server-api</artifactId>
<version>${pigx.version}</version>
</dependency>
<dependency>
<groupId>org.ow2.asm</groupId>
<artifactId>asm</artifactId>
<version>${asm.version}</version>
</dependency>
<!-- seata kryo 序列化-->
<dependency>
<groupId>io.seata</groupId>
<artifactId>seata-serializer-kryo</artifactId>
<version>${seata.version}</version>
</dependency>
<dependency>
<groupId>org.ow2.asm</groupId>
<artifactId>asm</artifactId>
<version>${asm.version}</version>
</dependency>
<!-- seata kryo 序列化-->
<dependency>
<groupId>io.seata</groupId>
<artifactId>seata-serializer-kryo</artifactId>
<version>${seata.version}</version>
</dependency>
<!--mybatis plus extension,包含了mybatis plus core-->
<dependency>
<groupId>com.baomidou</groupId>
@@ -225,6 +231,12 @@
<artifactId>fastjson</artifactId>
<version>${fastjson.version}</version>
</dependency>
<!-- 对象对比工具-->
<dependency>
<groupId>org.javers</groupId>
<artifactId>javers-core</artifactId>
<version>${javers.version}</version>
</dependency>
<!--springdoc -->
<dependency>
<groupId>org.springdoc</groupId>
@@ -317,41 +329,41 @@
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>com.alibaba.csp</groupId>
<artifactId>sentinel-core</artifactId>
<version>${sentinel.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>com.alibaba.csp</groupId>
<artifactId>sentinel-web-servlet</artifactId>
<version>${sentinel.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>com.alibaba.csp</groupId>
<artifactId>sentinel-transport-simple-http</artifactId>
<version>${sentinel.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>com.alibaba.csp</groupId>
<artifactId>sentinel-parameter-flow-control</artifactId>
<version>${sentinel.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>com.alibaba.csp</groupId>
<artifactId>sentinel-api-gateway-adapter-common</artifactId>
<version>${sentinel.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>com.alibaba.csp</groupId>
<artifactId>sentinel-core</artifactId>
<version>${sentinel.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>com.alibaba.csp</groupId>
<artifactId>sentinel-web-servlet</artifactId>
<version>${sentinel.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>com.alibaba.csp</groupId>
<artifactId>sentinel-transport-simple-http</artifactId>
<version>${sentinel.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>com.alibaba.csp</groupId>
<artifactId>sentinel-parameter-flow-control</artifactId>
<version>${sentinel.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>com.alibaba.csp</groupId>
<artifactId>sentinel-api-gateway-adapter-common</artifactId>
<version>${sentinel.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
@@ -53,7 +53,6 @@ public class PigxBearerTokenExtractor implements BearerTokenResolver {
this.urlProperties = urlProperties;
}
@Override
public String resolve(HttpServletRequest request) {
boolean match = urlProperties.getIgnoreUrls().stream()
+1
View File
@@ -33,6 +33,7 @@
<description>pigx 公共聚合模块</description>
<modules>
<module>pigx-common-audit</module>
<module>pigx-common-bom</module>
<module>pigx-common-core</module>
<module>pigx-common-data</module>
@@ -0,0 +1,100 @@
/*
* Copyright (c) 2018-2025, lengleng All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the pig4cloud.com developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: lengleng (wangiegie@gmail.com)
*/
package com.pig4cloud.pigx.admin.api.entity;
import com.baomidou.mybatisplus.annotation.*;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.time.LocalDateTime;
/**
* 审计记录表
*
* @author pigx code generator
* @date 2023-02-27 22:33:30
*/
@Data
@TableName("sys_audit_log")
@EqualsAndHashCode(callSuper = true)
@Schema(description = "审计记录表")
public class SysAuditLog extends Model<SysAuditLog> {
private static final long serialVersionUID = 1L;
/**
* 主键
*/
@TableId(type = IdType.ASSIGN_ID)
@Schema(description = "主键")
private Long id;
/**
* 审计名称
*/
@Schema(description = "审计名称")
private String auditName;
/**
* 字段名称
*/
@Schema(description = "字段名称")
private String auditField;
/**
* 变更前值
*/
@Schema(description = "变更前值")
private String beforeVal;
/**
* 变更后值
*/
@Schema(description = "变更后值")
private String afterVal;
/**
* 操作人
*/
@Schema(description = "操作人")
private String createBy;
/**
* 操作时间
*/
@Schema(description = "操作时间")
@TableField(fill = FieldFill.INSERT)
private LocalDateTime createTime;
/**
* 删除标记
*/
@TableLogic
@Schema(description = "删除标记")
@TableField(fill = FieldFill.INSERT)
private String delFlag;
/**
* 租户ID
*/
@Schema(description = "租户ID", hidden = true)
private Long tenantId;
}
@@ -0,0 +1,49 @@
/*
*
* Copyright (c) 2018-2025, lengleng All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the pig4cloud.com developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: lengleng (wangiegie@gmail.com)
*
*/
package com.pig4cloud.pigx.admin.api.feign;
import com.pig4cloud.pigx.admin.api.entity.SysAuditLog;
import com.pig4cloud.pigx.common.core.constant.SecurityConstants;
import com.pig4cloud.pigx.common.core.constant.ServiceNameConstants;
import com.pig4cloud.pigx.common.core.util.R;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;
import java.util.List;
/**
* @author lengleng
* @date 2023-02-27
*/
@FeignClient(contextId = "remoteAuditLogService", value = ServiceNameConstants.UPMS_SERVICE)
public interface RemoteAuditLogService {
/**
* 保存日志
* @param auditLogList 日志实体 列表
* @param from 是否内部调用
* @return succes、false
*/
@PostMapping("/audit")
R<Boolean> saveLog(@RequestBody List<SysAuditLog> auditLogList, @RequestHeader(SecurityConstants.FROM) String from);
}
@@ -7,4 +7,5 @@ com.pig4cloud.pigx.common.feign.PigxFeignAutoConfiguration=\
com.pig4cloud.pigx.admin.api.feign.RemoteTenantService,\
com.pig4cloud.pigx.admin.api.feign.RemoteTokenService,\
com.pig4cloud.pigx.admin.api.feign.RemoteUserService,\
com.pig4cloud.pigx.admin.api.feign.RemoteDictService
com.pig4cloud.pigx.admin.api.feign.RemoteDictService,\
com.pig4cloud.pigx.admin.api.feign.RemoteAuditLogService
@@ -0,0 +1,128 @@
/*
* Copyright (c) 2018-2025, lengleng All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the pig4cloud.com developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: lengleng (wangiegie@gmail.com)
*/
package com.pig4cloud.pigx.admin.controller;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.pig4cloud.pigx.common.core.util.R;
import com.pig4cloud.pigx.common.log.annotation.SysLog;
import com.pig4cloud.pigx.admin.api.entity.SysAuditLog;
import com.pig4cloud.pigx.admin.service.SysAuditLogService;
import com.pig4cloud.pigx.common.security.annotation.Inner;
import org.springframework.security.access.prepost.PreAuthorize;
import com.pig4cloud.pigx.common.excel.annotation.ResponseExcel;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import org.springframework.http.HttpHeaders;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* 审计记录表
*
* @author pigx code generator
* @date 2023-02-27 22:33:30
*/
@RestController
@RequiredArgsConstructor
@RequestMapping("/audit")
@Tag(description = "sysauditlog", name = "审计记录表管理")
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
public class SysAuditLogController {
private final SysAuditLogService sysAuditLogService;
/**
* 分页查询
* @param page 分页对象
* @param sysAuditLog 审计记录表
* @return
*/
@Operation(summary = "分页查询", description = "分页查询")
@GetMapping("/page")
@PreAuthorize("@pms.hasPermission('admin_sysauditlog_view')")
public R getSysAuditLogPage(Page page, SysAuditLog sysAuditLog) {
return R.ok(sysAuditLogService.page(page, Wrappers.query(sysAuditLog)));
}
/**
* 通过id查询审计记录表
* @param id id
* @return R
*/
@Operation(summary = "通过id查询", description = "通过id查询")
@GetMapping("/{id}")
@PreAuthorize("@pms.hasPermission('admin_sysauditlog_view')")
public R getById(@PathVariable("id") Long id) {
return R.ok(sysAuditLogService.getById(id));
}
/**
* 新增审计记录表 (异步插入)
* @param auditLogList 审计记录
* @return R
*/
@Inner
@PostMapping
@Operation(summary = "新增审计记录表", description = "新增审计记录表")
public R save(@RequestBody List<SysAuditLog> auditLogList) {
return R.ok(sysAuditLogService.saveBatch(auditLogList));
}
/**
* 修改审计记录表
* @param sysAuditLog 审计记录表
* @return R
*/
@Operation(summary = "修改审计记录表", description = "修改审计记录表")
@SysLog("修改审计记录表")
@PutMapping
@PreAuthorize("@pms.hasPermission('admin_sysauditlog_edit')")
public R updateById(@RequestBody SysAuditLog sysAuditLog) {
return R.ok(sysAuditLogService.updateById(sysAuditLog));
}
/**
* 通过id删除审计记录表
* @param id id
* @return R
*/
@Operation(summary = "通过id删除审计记录表", description = "通过id删除审计记录表")
@SysLog("通过id删除审计记录表")
@DeleteMapping("/{id}")
@PreAuthorize("@pms.hasPermission('admin_sysauditlog_del')")
public R removeById(@PathVariable Long id) {
return R.ok(sysAuditLogService.removeById(id));
}
/**
* 导出excel 表格
* @param sysAuditLog 查询条件
* @return excel 文件流
*/
@ResponseExcel
@GetMapping("/export")
@PreAuthorize("@pms.hasPermission('admin_sysauditlog_export')")
public List<SysAuditLog> export(SysAuditLog sysAuditLog) {
return sysAuditLogService.list(Wrappers.query(sysAuditLog));
}
}
@@ -0,0 +1,33 @@
/*
* Copyright (c) 2018-2025, lengleng All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the pig4cloud.com developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: lengleng (wangiegie@gmail.com)
*/
package com.pig4cloud.pigx.admin.mapper;
import com.pig4cloud.pigx.common.data.datascope.PigxBaseMapper;
import com.pig4cloud.pigx.admin.api.entity.SysAuditLog;
import org.apache.ibatis.annotations.Mapper;
/**
* 审计记录表
*
* @author pigx code generator
* @date 2023-02-27 22:33:30
*/
@Mapper
public interface SysAuditLogMapper extends PigxBaseMapper<SysAuditLog> {
}
@@ -0,0 +1,31 @@
/*
* Copyright (c) 2018-2025, lengleng All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the pig4cloud.com developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: lengleng (wangiegie@gmail.com)
*/
package com.pig4cloud.pigx.admin.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.pig4cloud.pigx.admin.api.entity.SysAuditLog;
/**
* 审计记录表
*
* @author pigx code generator
* @date 2023-02-27 22:33:30
*/
public interface SysAuditLogService extends IService<SysAuditLog> {
}
@@ -0,0 +1,34 @@
/*
* Copyright (c) 2018-2025, lengleng All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the pig4cloud.com developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: lengleng (wangiegie@gmail.com)
*/
package com.pig4cloud.pigx.admin.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.pig4cloud.pigx.admin.api.entity.SysAuditLog;
import com.pig4cloud.pigx.admin.mapper.SysAuditLogMapper;
import com.pig4cloud.pigx.admin.service.SysAuditLogService;
import org.springframework.stereotype.Service;
/**
* 审计记录表
*
* @author pigx code generator
* @date 2023-02-27 22:33:30
*/
@Service
public class SysAuditLogServiceImpl extends ServiceImpl<SysAuditLogMapper, SysAuditLog> implements SysAuditLogService {
}
@@ -0,0 +1,37 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~
~ Copyright (c) 2018-2025, lengleng All rights reserved.
~
~ Redistribution and use in source and binary forms, with or without
~ modification, are permitted provided that the following conditions are met:
~
~ Redistributions of source code must retain the above copyright notice,
~ this list of conditions and the following disclaimer.
~ Redistributions in binary form must reproduce the above copyright
~ notice, this list of conditions and the following disclaimer in the
~ documentation and/or other materials provided with the distribution.
~ Neither the name of the pig4cloud.com developer nor the names of its
~ contributors may be used to endorse or promote products derived from
~ this software without specific prior written permission.
~ Author: lengleng (wangiegie@gmail.com)
~
-->
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.pig4cloud.pigx.admin.mapper.SysAuditLogMapper">
<resultMap id="sysAuditLogMap" type="com.pig4cloud.pigx.admin.api.entity.SysAuditLog">
<id property="id" column="id"/>
<result property="auditName" column="audit_name"/>
<result property="auditField" column="audit_field"/>
<result property="beforeVal" column="before_val"/>
<result property="afterVal" column="after_val"/>
<result property="createBy" column="create_by"/>
<result property="createTime" column="create_time"/>
<result property="delFlg" column="del_flg"/>
<result property="tenantId" column="tenant_id"/>
</resultMap>
</mapper>