hospital-admin-api/api/model/doctorIntroductionRecord.go

38 lines
1.5 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-admin-api/global"
"time"
)
type DoctorIntroductionRecord struct {
RecordId int64 `gorm:"column:record_id;type:bigint(19);primary_key;comment:主键id" json:"record_id"`
DoctorId int64 `gorm:"column:doctor_id;type:bigint(19);comment:医生id;NOT NULL" json:"doctor_id"`
IntroductionStatus int `gorm:"column:introduction_status;type:tinyint(1);default:1;comment:个人简介审核状态0:未审核 1:审核通过 2:审核中 3:审核失败);NOT NULL" json:"introduction_status"`
Avatar string `gorm:"column:avatar;type:varchar(255);comment:头像" json:"avatar"`
BeGoodAt string `gorm:"column:be_good_at;type:text;comment:擅长" json:"be_good_at"`
BriefIntroduction string `gorm:"column:brief_introduction;type:text;comment:医生简介" json:"brief_introduction"`
ExpertiseIds string `gorm:"column:expertise_ids;type:varchar(1000);comment:专长id逗号分隔" json:"expertise_ids"`
Model
UserDoctor *UserDoctor `gorm:"foreignKey:DoctorId;references:doctor_id" json:"user_doctor"` // 医生
}
func (m *DoctorIntroductionRecord) TableName() string {
return "gdxz_doctor_introduction_record"
}
func (m *DoctorIntroductionRecord) BeforeCreate(tx *gorm.DB) error {
if m.RecordId == 0 {
m.RecordId = 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
}