新增操作记录日志

This commit is contained in:
2023-09-14 14:38:21 +08:00
parent 16615530de
commit e1887b52e7
8 changed files with 192 additions and 7 deletions
+36
View File
@@ -0,0 +1,36 @@
package model
import (
"gorm.io/gorm"
"hospital-admin-api/global"
"time"
)
// OrderOperationLog 订单操作日志表
type OrderOperationLog struct {
OperationLogId int64 `gorm:"column:operation_log_id;type:bigint(19);primary_key;comment:主键id" json:"operation_log_id"`
OrderId int64 `gorm:"column:order_id;type:bigint(19);comment:订单id" json:"order_id"`
OrderNo string `gorm:"column:order_no;type:varchar(255);comment:系统订单编号" json:"order_no"`
OrderType int `gorm:"column:order_type;type:tinyint(1);comment:订单类型(1:问诊 2:药品 3:检测)" json:"order_type"`
OperatorId int64 `gorm:"column:operator_id;type:bigint(19);comment:操作人id(后台用户)" json:"operator_id"`
OperationContent string `gorm:"column:operation_content;type:varchar(255);comment:操作内容" json:"operation_content"`
Model
}
func (m *OrderOperationLog) TableName() string {
return "gdxz_order_operation_log"
}
func (m *OrderOperationLog) BeforeCreate(tx *gorm.DB) error {
if m.OperationLogId == 0 {
m.OperationLogId = global.Snowflake.Generate().Int64()
}
m.CreatedAt = LocalTime(time.Now())
tx.Statement.SetColumn("CreatedAt", m.CreatedAt)
m.UpdatedAt = LocalTime(time.Now())
tx.Statement.SetColumn("UpdatedAt", m.UpdatedAt)
return nil
}