Files
hospital-admin-api/api/model/adminPost.go
T
2023-07-17 16:13:47 +08:00

34 lines
865 B
Go

package model
import (
"gorm.io/gorm"
"hospital-admin-api/global"
"time"
)
// AdminPost 后台-岗位表
type AdminPost struct {
PostId int64 `gorm:"column:post_id;type:bigint(19);primary_key;comment:主键id" json:"post_id"`
PostName string `gorm:"column:post_name;type:varchar(255);comment:部门名称" json:"post_name"`
PostStatus int `gorm:"column:post_status;type:tinyint(1);default:1;comment:状态(1:正常 2:删除)" json:"post_status"`
Model
}
func (m *AdminPost) TableName() string {
return "gdxz_admin_post"
}
func (m *AdminPost) BeforeCreate(tx *gorm.DB) error {
if m.PostId == 0 {
m.PostId = 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
}