package modelbookimg import ( "key_performance_indicators/overall" "strings" ) // 文档属性 type BookAttribute struct { Id int64 `json:"id" gorm:"primaryKey;column:b_id;type:bigint unsigned;not null;auto_increment;comment:ID"` FileId int64 `json:"fileid" gorm:"column:b_file_id;type:bigint unsigned;not null;default:0;comment:文档ID"` UserId int64 `json:"userid" gorm:"column:b_userid;type:bigint unsigned;not null;default:0;comment:阅读人ID"` Time int64 `json:"time" gorm:"column:b_time;type:bigint unsigned;not null;default:0;comment:阅读时间"` Type int `json:"type" gorm:"column:b_type;type:tinyint unsigned;not null;default:1;comment:类型 (1:阅读量;2:收藏数;3:赞;4:踩)"` Stater int `json:"stater" gorm:"column:b_stater;type:tinyint unsigned;not null;default:1;comment:状态(1:有效;2:无效)"` EiteTime int64 `json:"eitetime" gorm:"column:b_eite_time;type:bigint unsigned;not null;default:0;comment:编辑时间"` Source int `json:"source" gorm:"column:b_source;type:tinyint unsigned;not null;default:1;comment:来源(1:文档类;2:文档类评论;3:问题;4:问题答案;5:问题答案评论)"` } func (ba *BookAttribute) TableName() string { return "bookattribute" } // 编辑文档属性内容 func (cont *BookAttribute) EiteCont(whereMap interface{}, saveData interface{}) (err error) { err = overall.CONSTANT_DB_FILE_BOOK.Model(&cont).Where(whereMap).Updates(saveData).Error return } // 获取文档属性内容 func (cont *BookAttribute) 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 *BookAttribute) DelCont(whereMap interface{}) (err error) { err = overall.CONSTANT_DB_FILE_BOOK.Where(whereMap).Delete(&cont).Error return }