case-api/api/model/ProjectPlatformDoctor.go
2025-03-07 16:57:28 +08:00

36 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 (
"case-api/global"
"gorm.io/gorm"
"time"
)
// ProjectPlatformDoctor 关联平台-白名单-医生
type ProjectPlatformDoctor struct {
WhiteDoctorId int64 `gorm:"column:white_doctor_id;type:bigint(19);primary_key;comment:主键id" json:"white_doctor_id"`
ProjectPlatformId int64 `gorm:"column:project_platform_id;type:bigint(19);comment:关联id;NOT NULL" json:"project_platform_id"`
UserId int64 `gorm:"column:user_id;type:bigint(19);comment:关联用户id" json:"user_id"`
Status int `gorm:"column:status;type:tinyint(1);default:1;comment:状态1:正常 2:禁用)" json:"status"`
Model
User []*User `gorm:"foreignKey:UserId;references:user_id" json:"user"`
}
func (m *ProjectPlatformDoctor) TableName() string {
return "project_platform_doctor"
}
func (m *ProjectPlatformDoctor) BeforeCreate(tx *gorm.DB) error {
if m.WhiteDoctorId == 0 {
m.WhiteDoctorId = 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
}