updateRelationCount 更新关注或粉丝计数器
(tx *gorm.DB, userID int64, field string, delta int64, timestamp int64)
| 186 | |
| 187 | // updateRelationCount 更新关注或粉丝计数器 |
| 188 | func (r *relationDAO) updateRelationCount(tx *gorm.DB, userID int64, field string, delta int64, timestamp int64) error { |
| 189 | return tx.Clauses(clause.OnConflict{ |
| 190 | Columns: []clause.Column{{Name: "user_id"}}, |
| 191 | DoUpdates: clause.Assignments(map[string]interface{}{ |
| 192 | field: gorm.Expr(field+" + ?", delta), |
| 193 | "updated_at": timestamp, |
| 194 | }), |
| 195 | }).Create(&RelationCount{ |
| 196 | UserID: userID, |
| 197 | CreatedAt: timestamp, |
| 198 | UpdatedAt: timestamp, |
| 199 | }).Error |
| 200 | } |
no test coverage detected