...
|
...
|
@@ -203,16 +203,14 @@ func (repository *ArticleRepository) DomainModelToModel(from *domain.Article) (* |
|
|
}
|
|
|
|
|
|
// 点赞数量变动
|
|
|
func (repository *ArticleRepository) IncreaseCountLove(ctx context.Context, conn transaction.Conn, incr int, dm *domain.Article) error {
|
|
|
func (repository *ArticleRepository) IncreaseCountLove(ctx context.Context, conn transaction.Conn, incr int, articleId int64) error {
|
|
|
//
|
|
|
var (
|
|
|
err error
|
|
|
m *models.Article
|
|
|
tx = conn.DB()
|
|
|
)
|
|
|
if m, err = repository.DomainModelToModel(dm); err != nil {
|
|
|
return err
|
|
|
}
|
|
|
m = &models.Article{Id: articleId}
|
|
|
queryFunc := func() (interface{}, error) {
|
|
|
tx = tx.Model(m).Updates(map[string]interface{}{
|
|
|
"count_love": gorm.Expr("count_love+?", incr),
|
...
|
...
|
@@ -227,15 +225,13 @@ func (repository *ArticleRepository) IncreaseCountLove(ctx context.Context, conn |
|
|
}
|
|
|
|
|
|
// 浏览数量变动
|
|
|
func (repository *ArticleRepository) IncreaseCountRead(ctx context.Context, conn transaction.Conn, incr int, dm *domain.Article) error {
|
|
|
func (repository *ArticleRepository) IncreaseCountRead(ctx context.Context, conn transaction.Conn, incr int, articleId int64) error {
|
|
|
var (
|
|
|
err error
|
|
|
m *models.Article
|
|
|
tx = conn.DB()
|
|
|
)
|
|
|
if m, err = repository.DomainModelToModel(dm); err != nil {
|
|
|
return err
|
|
|
}
|
|
|
m = &models.Article{Id: articleId}
|
|
|
queryFunc := func() (interface{}, error) {
|
|
|
tx = tx.Model(m).Updates(map[string]interface{}{
|
|
|
"version": gorm.Expr("version+1"),
|
...
|
...
|
@@ -250,15 +246,13 @@ func (repository *ArticleRepository) IncreaseCountRead(ctx context.Context, conn |
|
|
}
|
|
|
|
|
|
// 评论数量变动
|
|
|
func (repository *ArticleRepository) IncreaseCountComment(ctx context.Context, conn transaction.Conn, incr int, dm *domain.Article) error {
|
|
|
func (repository *ArticleRepository) IncreaseCountComment(ctx context.Context, conn transaction.Conn, incr int, articleId int64) error {
|
|
|
var (
|
|
|
err error
|
|
|
m *models.Article
|
|
|
tx = conn.DB()
|
|
|
)
|
|
|
if m, err = repository.DomainModelToModel(dm); err != nil {
|
|
|
return err
|
|
|
}
|
|
|
m = &models.Article{Id: articleId}
|
|
|
queryFunc := func() (interface{}, error) {
|
|
|
tx = tx.Model(m).Updates(map[string]interface{}{
|
|
|
"version": gorm.Expr("version+1"),
|
...
|
...
|
|