增加操作历史model
This commit is contained in:
47
internal/model/operation_history.go
Normal file
47
internal/model/operation_history.go
Normal file
@@ -0,0 +1,47 @@
|
||||
// Package model 提供数据模型定义
|
||||
// 包含用户、操作历史等相关数据结构
|
||||
package model
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
// OperationHistory 代表用户操作历史记录
|
||||
type OperationHistory struct {
|
||||
// ID 记录ID
|
||||
ID uint `gorm:"primaryKey;column:id" json:"id"`
|
||||
|
||||
// UserID 用户ID
|
||||
UserID uint `gorm:"not null;column:user_id;index" json:"user_id"`
|
||||
|
||||
// Action 操作类型/指令
|
||||
Action string `gorm:"not null;column:action" json:"action"`
|
||||
|
||||
// Target 操作目标(可选)
|
||||
Target string `gorm:"column:target" json:"target"`
|
||||
|
||||
// Parameters 操作参数(可选)
|
||||
Parameters string `gorm:"column:parameters" json:"parameters"`
|
||||
|
||||
// Status 操作状态(成功/失败)
|
||||
Status string `gorm:"not null;column:status" json:"status"`
|
||||
|
||||
// Result 操作结果详情(可选)
|
||||
Result string `gorm:"column:result" json:"result"`
|
||||
|
||||
// CreatedAt 创建时间
|
||||
CreatedAt time.Time `gorm:"column:created_at" json:"created_at"`
|
||||
|
||||
// UpdatedAt 更新时间
|
||||
UpdatedAt time.Time `gorm:"column:updated_at" json:"updated_at"`
|
||||
|
||||
// DeletedAt 删除时间(用于软删除)
|
||||
DeletedAt gorm.DeletedAt `gorm:"index;column:deleted_at" json:"-"`
|
||||
}
|
||||
|
||||
// TableName 指定OperationHistory模型对应的数据库表名
|
||||
func (OperationHistory) TableName() string {
|
||||
return "operation_histories"
|
||||
}
|
||||
Reference in New Issue
Block a user