Skip to content

Commit f6516b5

Browse files
committed
新增审计记录保存及查询功能 by claude code
1 parent dec9d75 commit f6516b5

12 files changed

Lines changed: 503 additions & 48 deletions

File tree

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Build and Push with Jib
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
tags: [ 'v*' ]
7+
pull_request:
8+
branches: [ master ]
9+
10+
jobs:
11+
build-and-push:
12+
runs-on: ubuntu-latest
13+
env:
14+
REGISTRY_URL: 'ccr.ccs.tencentyun.com/opensabre' # 替换为你的镜像提交地址
15+
16+
steps:
17+
- name: Checkout Code
18+
uses: actions/checkout@v4
19+
20+
- name: Set up JDK
21+
uses: actions/setup-java@v4
22+
with:
23+
java-version: '21' # 或你项目使用的JDK版本
24+
distribution: 'temurin'
25+
26+
- name: Build and Push with Jib
27+
run: mvn compile jib:build -Dsecret.id=${{ secrets.DOCKER_CLOUD_SECRET_ID }} -Dsecret.key=${{ secrets.DOCKER_CLOUD_SECRET_KEY }}

pom.xml

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
<parent>
2323
<artifactId>opensabre-base-dependencies</artifactId>
2424
<groupId>io.github.opensabre</groupId>
25-
<version>0.1.1</version>
25+
<version>0.1.2</version>
2626
</parent>
2727

2828
<properties>
@@ -53,15 +53,6 @@
5353
<groupId>io.github.opensabre</groupId>
5454
<artifactId>opensabre-starter-cache</artifactId>
5555
</dependency>
56-
<!--security资源服务-->
57-
<dependency>
58-
<groupId>org.springframework.boot</groupId>
59-
<artifactId>spring-boot-starter-oauth2-resource-server</artifactId>
60-
</dependency>
61-
<dependency>
62-
<groupId>org.springframework.boot</groupId>
63-
<artifactId>spring-boot-starter-oauth2-client</artifactId>
64-
</dependency>
6556
<!--测试框架-->
6657
<dependency>
6758
<groupId>org.springframework.boot</groupId>
@@ -112,8 +103,8 @@
112103
</plugin>
113104
<!-- docker镜像构建 -->
114105
<plugin>
115-
<groupId>com.spotify</groupId>
116-
<artifactId>dockerfile-maven-plugin</artifactId>
106+
<groupId>com.google.cloud.tools</groupId>
107+
<artifactId>jib-maven-plugin</artifactId>
117108
</plugin>
118109
</plugins>
119110
</build>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package io.github.opensabre.sysadmin.dao;
2+
3+
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
4+
import io.github.opensabre.sysadmin.model.po.AuditLog;
5+
import org.apache.ibatis.annotations.Mapper;
6+
7+
/**
8+
* 审计日志数据访问接口
9+
*/
10+
@Mapper
11+
public interface AuditLogMapper extends BaseMapper<AuditLog> {
12+
}
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
package io.github.opensabre.sysadmin.model.form;
2+
3+
import io.github.opensabre.boot.annotations.OperationType;
4+
import io.github.opensabre.common.web.entity.form.BaseForm;
5+
import io.github.opensabre.sysadmin.model.po.AuditLog;
6+
import io.swagger.v3.oas.annotations.media.Schema;
7+
import jakarta.validation.constraints.NotBlank;
8+
import jakarta.validation.constraints.NotNull;
9+
import lombok.Data;
10+
import lombok.EqualsAndHashCode;
11+
12+
import java.util.Date;
13+
14+
@Data
15+
@Schema
16+
@EqualsAndHashCode(callSuper = true)
17+
public class AuditLogForm extends BaseForm<AuditLog> {
18+
19+
@Schema(title = "操作类型")
20+
@NotNull(message = "操作类型不能为空")
21+
private OperationType operationType;
22+
23+
@Schema(title = "操作时间")
24+
@NotNull(message = "操作时间不能为空")
25+
private Date operationTime;
26+
27+
@Schema(title = "操作人用户名")
28+
@NotBlank(message = "操作人用户名不能为空")
29+
private String operatorUsername;
30+
31+
@Schema(title = "操作描述")
32+
private String description;
33+
34+
@Schema(title = "操作模块")
35+
@NotBlank(message = "操作模块不能为空")
36+
private String module;
37+
38+
@Schema(title = "操作IP地址")
39+
private String clientIp;
40+
41+
@Schema(title = "操作终端的User-Agent")
42+
private String userAgent;
43+
44+
@Schema(title = "请求方法,GET/POST/PUT/DELETE")
45+
private String requestMethod;
46+
47+
@Schema(title = "请求URL")
48+
private String requestUrl;
49+
50+
@Schema(title = "请求参数报文")
51+
private String request;
52+
53+
@Schema(title = "请求返回报文")
54+
private String response;
55+
56+
@Schema(title = "错误信息")
57+
private String errorMessage;
58+
59+
@Schema(title = "执行时间(毫秒)")
60+
private Long executionTime;
61+
62+
@Schema(title = "操作目标关键值")
63+
private String targetKey;
64+
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
package io.github.opensabre.sysadmin.model.form;
2+
3+
import io.github.opensabre.boot.annotations.OperationType;
4+
import io.github.opensabre.persistence.entity.form.BaseQueryForm;
5+
import lombok.Data;
6+
import lombok.EqualsAndHashCode;
7+
8+
import java.time.LocalDateTime;
9+
import io.github.opensabre.sysadmin.model.param.AuditLogQueryParam;
10+
/**
11+
* 审计日志查询表单
12+
*/
13+
@Data
14+
@EqualsAndHashCode(callSuper = true)
15+
public class AuditLogQueryForm extends BaseQueryForm<AuditLogQueryParam> {
16+
17+
/**
18+
* 操作类型
19+
*/
20+
private OperationType operationType;
21+
22+
/**
23+
* 操作开始时间
24+
*/
25+
private LocalDateTime operationStartTime;
26+
27+
/**
28+
* 操作结束时间
29+
*/
30+
private LocalDateTime operationEndTime;
31+
32+
/**
33+
* 操作人用户名
34+
*/
35+
private String operatorUsername;
36+
37+
/**
38+
* 操作模块
39+
*/
40+
private String module;
41+
42+
/**
43+
* 操作IP地址
44+
*/
45+
private String clientIp;
46+
47+
/**
48+
* 操作目标ID
49+
*/
50+
private String targetKey;
51+
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
package io.github.opensabre.sysadmin.model.param;
2+
3+
import io.github.opensabre.boot.annotations.OperationType;
4+
import io.github.opensabre.persistence.entity.param.BaseParam;
5+
import lombok.Data;
6+
import lombok.EqualsAndHashCode;
7+
8+
import java.time.LocalDateTime;
9+
10+
/**
11+
* 审计日志查询参数
12+
*/
13+
@Data
14+
@EqualsAndHashCode(callSuper = true)
15+
public class AuditLogQueryParam extends BaseParam {
16+
17+
/**
18+
* 操作类型
19+
*/
20+
private OperationType operationType;
21+
22+
/**
23+
* 操作开始时间
24+
*/
25+
private LocalDateTime operationStartTime;
26+
27+
/**
28+
* 操作结束时间
29+
*/
30+
private LocalDateTime operationEndTime;
31+
32+
/**
33+
* 操作人用户名
34+
*/
35+
private String operatorUsername;
36+
37+
/**
38+
* 操作模块
39+
*/
40+
private String module;
41+
42+
/**
43+
* 操作IP地址
44+
*/
45+
private String clientIp;
46+
47+
/**
48+
* 操作目标ID
49+
*/
50+
private String targetKey;
51+
}
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
package io.github.opensabre.sysadmin.model.po;
2+
3+
import com.baomidou.mybatisplus.annotation.TableName;
4+
import io.github.opensabre.boot.annotations.OperationType;
5+
import io.github.opensabre.persistence.entity.po.BasePo;
6+
import lombok.*;
7+
8+
import java.util.Date;
9+
10+
/**
11+
* 审计日志实体
12+
*/
13+
@Data
14+
@Builder
15+
@NoArgsConstructor
16+
@AllArgsConstructor
17+
@TableName("base_sys_audit_log")
18+
@EqualsAndHashCode(callSuper = true)
19+
public class AuditLog extends BasePo {
20+
21+
/**
22+
* 操作类型
23+
*/
24+
private OperationType operationType;
25+
26+
/**
27+
* 操作时间
28+
*/
29+
private Date operationTime;
30+
31+
/**
32+
* 操作人用户名
33+
*/
34+
private String operatorUsername;
35+
36+
/**
37+
* 操作描述
38+
*/
39+
private String description;
40+
41+
/**
42+
* 操作模块
43+
*/
44+
private String module;
45+
46+
/**
47+
* 操作IP地址
48+
*/
49+
private String clientIp;
50+
51+
/**
52+
* 用户代理
53+
*/
54+
private String userAgent;
55+
56+
/**
57+
* 请求方法
58+
*/
59+
private String requestMethod;
60+
61+
/**
62+
* 请求URL
63+
*/
64+
private String requestUrl;
65+
66+
/**
67+
* 请求参数
68+
*/
69+
private String request;
70+
71+
/**
72+
* 操作结果
73+
*/
74+
private String response;
75+
76+
/**
77+
* 错误信息
78+
*/
79+
private String errorMessage;
80+
81+
/**
82+
* 执行时间(毫秒)
83+
*/
84+
private Long executionTime;
85+
86+
/**
87+
* 操作目标关键key
88+
*/
89+
private String targetKey;
90+
}

0 commit comments

Comments
 (0)