接口已全部新增完毕

This commit is contained in:
2024-12-30 17:52:46 +08:00
parent 29632f7d50
commit 90c2cf1ce0
10 changed files with 323 additions and 22 deletions
+9 -7
View File
@@ -8,13 +8,15 @@ import (
// CaseUser 统计数据-病例-用户
type CaseUser struct {
CaseUserId int64 `gorm:"column:case_user_id;type:bigint(19);primary_key;comment:主键id" json:"case_user_id"`
CaseId int64 `gorm:"column:case_id;type:bigint(19);comment:所属病例id;NOT NULL" json:"case_id"`
PlatformId int64 `gorm:"column:platform_id;type:bigint(19);comment:用户所属平台id;NOT NULL" json:"platform_id"`
UserId int64 `gorm:"column:user_id;type:bigint(19);comment:用户id;NOT NULL" json:"user_id"`
ShareUserIden string `gorm:"column:share_user_iden;type:varchar(100);comment:分享人标识" json:"share_user_iden"`
ReadDuration int `gorm:"column:read_duration;type:int(5);default:0;comment:阅读时长(秒)" json:"read_duration"`
TotalScore int `gorm:"column:total_score;type:int(5);default:0;comment:单个病例领取总积分" json:"total_score"`
CaseUserId int64 `gorm:"column:case_user_id;type:bigint(19);primary_key;comment:主键id" json:"case_user_id"`
CaseId int64 `gorm:"column:case_id;type:bigint(19);comment:所属病例id;NOT NULL" json:"case_id"`
PlatformId int64 `gorm:"column:platform_id;type:bigint(19);comment:用户所属平台id;NOT NULL" json:"platform_id"`
UserId int64 `gorm:"column:user_id;type:bigint(19);comment:用户id;NOT NULL" json:"user_id"`
ShareUserIden string `gorm:"column:share_user_iden;type:varchar(100);comment:分享人标识" json:"share_user_iden"`
ReadDuration int `gorm:"column:read_duration;type:int(5);default:0;comment:阅读时长(秒)" json:"read_duration"`
TotalScore int `gorm:"column:total_score;type:int(5);default:0;comment:单个病例领取总积分" json:"total_score"`
StartTime LocalTime `gorm:"column:start_time;type:datetime;comment:开始参与时间" json:"start_time"`
EndTime LocalTime `gorm:"column:end_time;type:datetime;comment:结束参与时间" json:"end_time"`
Model
Platform *Platform `gorm:"foreignKey:PlatformId;references:platform_id" json:"platform"`
User *User `gorm:"foreignKey:UserId;references:user_id" json:"user"`
+1 -1
View File
@@ -20,7 +20,7 @@ type UserAnswerRecord struct {
}
func (m *UserAnswerRecord) TableName() string {
return "user_answer_records"
return "user_answer_record"
}
func (m *UserAnswerRecord) BeforeCreate(tx *gorm.DB) error {
+37
View File
@@ -0,0 +1,37 @@
package model
import (
"case-open-api/global"
"gorm.io/gorm"
"time"
)
// UserBehaviorRecord 用户操作记录
type UserBehaviorRecord struct {
RecordId int64 `gorm:"column:record_id;type:bigint(19);primary_key;comment:主键id" json:"record_id"`
CaseId int64 `gorm:"column:case_id;type:bigint(19);comment:病例id;NOT NULL" json:"case_id"`
PlatformId int64 `gorm:"column:platform_id;type:bigint(19);comment:平台id;NOT NULL" json:"platform_id"`
UserId int64 `gorm:"column:user_id;type:bigint(19);comment:用户id;NOT NULL" json:"user_id"`
Step string `gorm:"column:step;type:varchar(100);comment:步骤名称" json:"step"`
StartTime LocalTime `gorm:"column:start_time;type:datetime;comment:开始时间" json:"start_time"`
EndTime LocalTime `gorm:"column:end_time;type:datetime;comment:结束时间" json:"end_time"`
Model
}
func (m *UserBehaviorRecord) TableName() string {
return "user_behavior_record"
}
func (m *UserBehaviorRecord) 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
}