case-open-api/api/model/ProjectPlatform.go
2024-12-30 16:34:26 +08:00

45 lines
2.3 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-open-api/global"
"gorm.io/gorm"
"time"
)
// ProjectPlatform 项目表-关联平台
type ProjectPlatform struct {
ProjectPlatformId int64 `gorm:"column:project_platform_id;type:bigint(19);primary_key;comment:主键id" json:"project_platform_id"`
PlatformId int64 `gorm:"column:platform_id;type:bigint(19);comment:主键id;NOT NULL" json:"platform_id"`
ProjectId int64 `gorm:"column:project_id;type:bigint(19);comment:项目id;NOT NULL" json:"project_id"`
Status int `gorm:"column:status;type:tinyint(1);default:1;comment:状态1:正常 2:禁用)" json:"status"`
IsWelfare int `gorm:"column:is_welfare;type:tinyint(1);default:1;comment:是否开启福利0:否 1:是)" json:"is_welfare"`
ReadDuration int `gorm:"column:read_duration;type:int(10);comment:阅读时长(秒)" json:"read_duration"`
SingleCaseScore int `gorm:"column:single_case_score;type:int(10);comment:单个病例总积分" json:"single_case_score"`
CompleteRead int `gorm:"column:complete_read;type:int(10);comment:完成阅读积分" json:"complete_read"`
CompleteReadTime int `gorm:"column:complete_read_time;type:int(10);comment:完成阅读时间积分" json:"complete_read_time"`
FirstHighQuality int `gorm:"column:first_high_quality;type:int(10);comment:首次优质留言积分" json:"first_high_quality"`
OnceMoreHighQuality int `gorm:"column:once_more_high_quality;type:int(10);comment:再次优质留言积分" json:"once_more_high_quality"`
IsWhite int `gorm:"column:is_white;type:tinyint(1);default:0;comment:是否开启白名单0:否 1:是)" json:"is_white"`
WhiteType int `gorm:"column:white_type;type:tinyint(1);comment:白名单类型1:医院 2:医生 3:动态)" json:"white_type"`
Model
Platform *Platform `gorm:"foreignKey:PlatformId;references:platform_id" json:"platform"`
}
func (m *ProjectPlatform) TableName() string {
return "project_platform"
}
func (m *ProjectPlatform) BeforeCreate(tx *gorm.DB) error {
if m.ProjectPlatformId == 0 {
m.ProjectPlatformId = 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
}