package yb_message import ( "hongze/hongze_yb/global" ) // Update 更新对应字段数据 func (ym *YbMessage) Update(updateCols []string) (err error) { err = global.DEFAULT_MYSQL.Model(ym).Select(updateCols).Updates(*ym).Error return } // SetBatchRead 批量设置已读 func SetBatchRead(userId uint64, msgType int)(err error) { var pars []interface{} pars = append(pars, userId) sql := ` UPDATE yb_message set is_read = 1, modify_time=NOW() WHERE user_id = ? and is_read = 0 ` if msgType > 0 { sql += " and type= ?" pars = append(pars, msgType) } err = global.DEFAULT_MYSQL.Exec(sql, pars...).Error return }