case-open-api/api/model/BasicHospital.go

41 lines
1.6 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 (
"case-open-api/global"
"gorm.io/gorm"
"time"
)
// BasicHospital 基础数据-医院
type BasicHospital struct {
HospitalId int64 `gorm:"column:hospital_id;type:bigint(19);primary_key;comment:主键id" json:"hospital_id"`
HospitalIden string `gorm:"column:hospital_iden;type:varchar(50);comment:app唯一标识" json:"hospital_iden"`
HospitalName string `gorm:"column:hospital_name;type:varchar(100);comment:医院名称" json:"hospital_name"`
Source int `gorm:"column:source;type:tinyint(1);comment:来源2:肝胆相照 3:佳动例);NOT NULL" json:"source"`
HospitalLevel string `gorm:"column:hospital_level;type:varchar(20);comment:医院等级" json:"hospital_level"`
DoctorNumber int `gorm:"column:doctor_number;type:int(5);default:0;comment:医生数量" json:"doctor_number"`
Province string `gorm:"column:province;type:varchar(50);comment:省份" json:"province"`
City string `gorm:"column:city;type:varchar(50);comment:城市" json:"city"`
County string `gorm:"column:county;type:varchar(50);comment:区县" json:"county"`
Address string `gorm:"column:address;type:varchar(255);comment:地址" json:"address"`
Model
}
func (m *BasicHospital) TableName() string {
return "basic_hospital"
}
func (m *BasicHospital) BeforeCreate(tx *gorm.DB) error {
if m.HospitalId == 0 {
m.HospitalId = 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
}