37 lines
1.4 KiB
Go
37 lines
1.4 KiB
Go
package model
|
||
|
||
import (
|
||
"gorm.io/gorm"
|
||
"hospital-open-api/global"
|
||
"time"
|
||
)
|
||
|
||
// HospitalDepartmentCustom 医院科室表-自定义
|
||
type HospitalDepartmentCustom struct {
|
||
DepartmentCustomId int64 `gorm:"column:department_custom_id;type:bigint(19);primary_key;comment:主键id" json:"department_custom_id"`
|
||
DepartmentId int64 `gorm:"column:department_id;type:bigint(19);comment:医院科室-标准id" json:"department_id"`
|
||
DepartmentCustomName string `gorm:"column:department_custom_name;type:varchar(100);comment:科室名称-自定义" json:"department_custom_name"`
|
||
DepartmentName string `gorm:"column:department_name;type:varchar(255);comment:科室名称-标准" json:"department_name"`
|
||
DepartmentCode string `gorm:"column:department_code;type:varchar(100);comment:科室编码-标准" json:"department_code"`
|
||
DepartmentStatus int `gorm:"column:department_status;type:tinyint(1);default:1;comment:状态(1:正常 2:删除)" json:"department_status"`
|
||
Model
|
||
}
|
||
|
||
func (m *HospitalDepartmentCustom) TableName() string {
|
||
return "gdxz_hospital_department_custom"
|
||
}
|
||
|
||
func (m *HospitalDepartmentCustom) BeforeCreate(tx *gorm.DB) error {
|
||
if m.DepartmentCustomId == 0 {
|
||
m.DepartmentCustomId = 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
|
||
}
|