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

35 lines
1.1 KiB
Go
Raw 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"
)
// HospitalDepartment 医院科室表-标准
type HospitalDepartment struct {
DepartmentId int64 `gorm:"column:department_id;type:bigint(19);primary_key;comment:主键id" json:"department_id"`
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"`
DepartmentType int `gorm:"column:department_type;type:tinyint(1);default:0;comment:科室类型0:未知 1:肝脏病)" json:"department_type"`
Model
}
func (m *HospitalDepartment) TableName() string {
return "gdxz_hospital_department"
}
func (m *HospitalDepartment) BeforeCreate(tx *gorm.DB) error {
if m.DepartmentId == 0 {
m.DepartmentId = 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
}