27 lines
875 B
Go
27 lines
875 B
Go
package operations
|
|
|
|
import (
|
|
"time"
|
|
|
|
"gorm.io/gorm"
|
|
|
|
adminModels "git.ilapage.cn/ila/yovision/Sense/server/app/admin/models"
|
|
)
|
|
|
|
type Audit struct {
|
|
Action, Method, Status, Username, ClientIP, Route, Remark string
|
|
UserID int
|
|
At time.Time
|
|
}
|
|
|
|
func WriteAudit(db *gorm.DB, input Audit) error {
|
|
model := adminModels.SysOperaLog{
|
|
Title: "运维中心", BusinessType: "other", Method: "operations.API." + input.Action,
|
|
RequestMethod: input.Method, OperatorType: "1", OperName: input.Username, OperUrl: input.Route,
|
|
OperIp: input.ClientIP, Status: input.Status, OperTime: input.At.UTC(), Remark: input.Remark,
|
|
CreatedAt: input.At.UTC(), UpdatedAt: input.At.UTC(),
|
|
}
|
|
model.CreateBy, model.UpdateBy = input.UserID, input.UserID
|
|
return db.Create(&model).Error
|
|
}
|