hospital-open-api/api/model/hospitalDepartmentCustom.go
2023-08-31 17:32:45 +08:00

37 lines
1.4 KiB
Go
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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
}