package topic import ( "github.com/golangkit/formatime" "live/app/lib/db" ) type TopicSubstance struct { db.BaseModel Id uint `gorm:"column:id" json:"id"` UserId uint `gorm:"column:user_id" json:"userId"` TopicId uint `gorm:"column:topic_id" json:"topicId"` CreatedAt formatime.Second `gorm:"column:created_at" json:"createdAt"` } // @Title 添加参与人 func (t *TopicSubstance) AddSubstance(userId, topicId uint) uint { if userId <= 0 || topicId <= 0 { return 0 } result := TopicSubstance{ UserId: userId, TopicId: topicId, } t.GetDb().Create(&result) return result.Id } // @Title 获取参与人信息 func (t *TopicSubstance) GetSubstanceByUserIdAndTopicId(userId, topicId uint) (result TopicSubstance) { if userId <= 0 || topicId <= 0 { return } t.GetDb().Model(t).First(&result, "user_id = ? and topic_id = ?", userId, topicId) return }