-
Notifications
You must be signed in to change notification settings - Fork 81
/
model_auditlogs.go
54 lines (50 loc) · 1.69 KB
/
model_auditlogs.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// Copyright 2022 The kubegems.io Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package models
import (
"time"
"gorm.io/datatypes"
"gorm.io/gorm"
)
/*
审计日志的描述格式为:
{用户名} {时间} {操作}
操作:
{动作,增删查改} {资源类型} {资源名字}
*/
// AuditLog 审计日志表
type AuditLog struct {
ID uint `gorm:"primarykey"`
CreatedAt time.Time `gorm:"index"`
UpdatedAt time.Time
DeletedAt gorm.DeletedAt `gorm:"index"`
// 操作用户
Username string `gorm:"type:varchar(50)"`
// 所属租户
Tenant string `gorm:"type:varchar(50)"`
// 操作模块 (资源类型,租户,项目,环境,报警规则等等)
Module string `gorm:"type:varchar(512)"`
// 模块名字
Name string `gorm:"type:varchar(512)"`
// 动作名字 (启用,禁用,开启,关闭,添加,删除,修改等)
Action string `gorm:"type:varchar(255)"`
// 是否成功 请求是否成功
Success bool
// 客户端ip 发起请求的客户端IP
ClientIP string `gorm:"type:varchar(255)"`
// 标签 记录一些额外的环境租户等数据信息
Labels datatypes.JSON
// 原始数据 记录的是request和response以及http_code
RawData datatypes.JSON
}