package modelbookimg import ( "key_performance_indicators/overall" "strings" ) // 评论列表 type DiscussMsg struct { Id int64 `json:"id" gorm:"primaryKey;column:dis_id;type:bigint unsigned;not null;auto_increment;comment:ID"` FileId int64 `json:"fileid" gorm:"column:dis_file_id;type:bigint unsigned;not null;default:0;comment:文档ID"` UserId int64 `json:"userid" gorm:"column:dis_user_id;type:bigint unsigned;not null;default:0;comment:评论人ID"` Prent int64 `json:"prent" gorm:"column:dis_prent;type:bigint unsigned;not null;default:0;comment:归属(0:评论源)"` Cont string `json:"cont" gorm:"column:dis_cont;type:text;comment:评论内容"` Time int64 `json:"time" gorm:"column:dis_time;type:bigint unsigned;default:0;comment:评论时间"` Stater int `json:"stater" gorm:"column:dis_stater;type:tinyint unsigned;not null;default:1;comment:状态(1:审核;2:发布;3:下架;4:删除)"` Source int `json:"source" gorm:"column:dis_source;type:tinyint unsigned;not null;default:1;comment:来源(1:文档类;2:文档类评论;3:问题;4:问题答案;5:问题答案评论)"` UserJson string `json:"userjson" gorm:"column:dis_user_json;type:mediumtext;comment:评论人基本信息"` EiteTime int64 `json:"eitetime" gorm:"column:dis_eite_time;type:bigint unsigned;not null;default:0;comment:修改时间"` } func (dm *DiscussMsg) TableName() string { return "discussmsg" } // 编辑评论列表内容 func (cont *DiscussMsg) EiteCont(whereMap interface{}, saveData interface{}) (err error) { err = overall.CONSTANT_DB_FILE_BOOK.Model(&cont).Where(whereMap).Updates(saveData).Error return } // 获取评论列表内容 func (cont *DiscussMsg) GetCont(whereMap interface{}, field ...string) (err error) { gormDb := overall.CONSTANT_DB_FILE_BOOK.Model(&cont) if len(field) > 0 { fieldStr := strings.Join(field, ",") gormDb = gormDb.Select(fieldStr) } gormDb = gormDb.Where(whereMap) err = gormDb.First(&cont).Error return } // 删除内容 func (cont *DiscussMsg) DelCont(whereMap interface{}) (err error) { err = overall.CONSTANT_DB_FILE_BOOK.Where(whereMap).Delete(&cont).Error return }