作者 tangxvhui

调整Increase** sql 语句

... ... @@ -216,6 +216,7 @@ func (repository *ArticleRepository) IncreaseCountLove(ctx context.Context, conn
queryFunc := func() (interface{}, error) {
tx = tx.Model(m).Updates(map[string]interface{}{
"count_love": gorm.Expr("count_love+?", incr),
"version": gorm.Expr("version+1"),
})
return nil, tx.Error
}
... ... @@ -236,7 +237,10 @@ func (repository *ArticleRepository) IncreaseCountRead(ctx context.Context, conn
return err
}
queryFunc := func() (interface{}, error) {
tx = tx.Model(m).Update("count_read", gorm.Expr("count_read+?", incr))
tx = tx.Model(m).Updates(map[string]interface{}{
"version": gorm.Expr("version+1"),
"count_read": gorm.Expr("count_read+?", incr),
})
return nil, tx.Error
}
if _, err = repository.Query(queryFunc, m.CacheKeyFunc()); err != nil {
... ... @@ -256,7 +260,10 @@ func (repository *ArticleRepository) IncreaseCountComment(ctx context.Context, c
return err
}
queryFunc := func() (interface{}, error) {
tx = tx.Model(m).Update("count_comment", gorm.Expr("count_comment+?", incr))
tx = tx.Model(m).Updates(map[string]interface{}{
"version": gorm.Expr("version+1"),
"count_comment": gorm.Expr("count_comment+?", incr),
})
return nil, tx.Error
}
if _, err = repository.Query(queryFunc, m.CacheKeyFunc()); err != nil {
... ...