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

35 lines
972 B
Go

package model
import (
"gorm.io/gorm"
"hospital-admin-api/global"
"time"
)
// AdminDept 后台-部门表
type AdminDept struct {
DeptId int64 `gorm:"column:dept_id;type:bigint(19);primary_key;comment:主键id" json:"dept_id"`
ParentId int64 `gorm:"column:parent_id;type:bigint(19);comment:本表父级id" json:"parent_id"`
DeptName string `gorm:"column:dept_name;type:varchar(255);comment:部门名称" json:"dept_name"`
DeptStatus int `gorm:"column:dept_status;type:tinyint(1);default:1;comment:部门状态(1:正常 2:删除)" json:"dept_status"`
Model
}
func (m *AdminDept) TableName() string {
return "gdxz_admin_dept"
}
func (m *AdminDept) BeforeCreate(tx *gorm.DB) error {
if m.DeptId == 0 {
m.DeptId = 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
}