refactor🎨 : 系统登录日志和操作日志代码优化

This commit is contained in:
zhangwenjian committed 2020-10-27 11:38:49 +08:00
1 parent 55112db749
commit 199fc180b7
23 files changed
+1081 -915

No files matched your search

+38
View File
@@ -0,0 +1,38 @@
package system
import (
"gorm.io/gorm"
"go-admin/common/models"
"time"
)
type SysLoginLog struct {
gorm.Model
models.ControlBy
Username string `json:"username" gorm:"type:varchar(128);comment:用户名"` //
Status string `json:"status" gorm:"type:varchar(4);comment:状态"` //
Ipaddr string `json:"ipaddr" gorm:"type:varchar(255);comment:ip地址"` //
LoginLocation string `json:"loginLocation" gorm:"type:varchar(255);comment:归属地"` //
Browser string `json:"browser" gorm:"type:varchar(255);comment:浏览器"` //
Os string `json:"os" gorm:"type:varchar(255);comment:系统"` //
Platform string `json:"platform" gorm:"type:varchar(255);comment:固件"` //
LoginTime time.Time `json:"loginTime" gorm:"type:timestamp;comment:登录时间"` //
Remark string `json:"remark" gorm:"type:varchar(255);comment:备注"` //
Msg string `json:"msg" gorm:"type:varchar(255);comment:信息"` //
}
func (SysLoginLog) TableName() string {
return "sys_login_log"
}
func (e *SysLoginLog) Generate() models.ActiveRecord {
o := *e
return &o
}
func (e *SysLoginLog) GetId() interface{} {
return e.ID
}
+46
View File
@@ -0,0 +1,46 @@
package system
import (
"gorm.io/gorm"
"go-admin/common/models"
"time"
)
type SysOperaLog struct {
gorm.Model
models.ControlBy
Title string `json:"title" gorm:"type:varchar(255);comment:操作模块"` //
BusinessType string `json:"businessType" gorm:"type:varchar(128);comment:操作类型"` //
BusinessTypes string `json:"businessTypes" gorm:"type:varchar(128);comment:BusinessTypes"` //
Method string `json:"method" gorm:"type:varchar(128);comment:函数"` //
RequestMethod string `json:"requestMethod" gorm:"type:varchar(128);comment:请求方式"` //
OperatorType string `json:"operatorType" gorm:"type:varchar(128);comment:操作类型"` //
OperName string `json:"operName" gorm:"type:varchar(128);comment:操作者"` //
DeptName string `json:"deptName" gorm:"type:varchar(128);comment:部门名称"` //
OperUrl string `json:"operUrl" gorm:"type:varchar(255);comment:访问地址"` //
OperIp string `json:"operIp" gorm:"type:varchar(128);comment:客户端ip"` //
OperLocation string `json:"operLocation" gorm:"type:varchar(128);comment:访问位置"` //
OperParam string `json:"operParam" gorm:"type:varchar(255);comment:请求参数"` //
Status string `json:"status" gorm:"type:varchar(4);comment:操作状态"` //
OperTime time.Time `json:"operTime" gorm:"type:timestamp;comment:操作时间"` //
JsonResult string `json:"jsonResult" gorm:"type:varchar(255);comment:返回数据"` //
Remark string `json:"remark" gorm:"type:varchar(255);comment:备注"` //
LatencyTime string `json:"latencyTime" gorm:"type:varchar(128);comment:耗时"` //
UserAgent string `json:"userAgent" gorm:"type:varchar(255);comment:ua"` //
}
func (SysOperaLog) TableName() string {
return "sys_opera_log"
}
func (e *SysOperaLog) Generate() models.ActiveRecord {
o := *e
return &o
}
func (e *SysOperaLog) GetId() interface{} {
return e.ID
}