正在显示
19 个修改的文件
包含
28 行增加
和
19 行删除
@@ -30,7 +30,7 @@ type Article struct { | @@ -30,7 +30,7 @@ type Article struct { | ||
30 | CountRead int // 浏览数量 | 30 | CountRead int // 浏览数量 |
31 | CountComment int // 评论数量 | 31 | CountComment int // 评论数量 |
32 | Tags []int64 `gorm:"type:jsonb;serializer:json"` //定性标签 | 32 | Tags []int64 `gorm:"type:jsonb;serializer:json"` //定性标签 |
33 | - Show int // 评论的展示状态(0显示、1不显示) | 33 | + Show int // 评论的展示状态(1显示、2不显示) |
34 | Summary string // 内容概要 | 34 | Summary string // 内容概要 |
35 | MatchUrl map[string]string `gorm:"type:jsonb;serializer:json"` // 匹配文章内容中的url文本 | 35 | MatchUrl map[string]string `gorm:"type:jsonb;serializer:json"` // 匹配文章内容中的url文本 |
36 | } | 36 | } |
@@ -44,7 +44,7 @@ func (repository *ArticleAndTagRepository) Update(ctx context.Context, conn tran | @@ -44,7 +44,7 @@ func (repository *ArticleAndTagRepository) Update(ctx context.Context, conn tran | ||
44 | return nil, err | 44 | return nil, err |
45 | } | 45 | } |
46 | queryFunc := func() (interface{}, error) { | 46 | queryFunc := func() (interface{}, error) { |
47 | - tx = tx.Model(m).Updates(m) | 47 | + tx = tx.Model(m).Save(m) |
48 | return nil, tx.Error | 48 | return nil, tx.Error |
49 | } | 49 | } |
50 | if _, err = repository.Query(queryFunc, m.CacheKeyFunc()); err != nil { | 50 | if _, err = repository.Query(queryFunc, m.CacheKeyFunc()); err != nil { |
@@ -42,7 +42,7 @@ func (repository *ArticleBackupRepository) Update(ctx context.Context, conn tran | @@ -42,7 +42,7 @@ func (repository *ArticleBackupRepository) Update(ctx context.Context, conn tran | ||
42 | return nil, err | 42 | return nil, err |
43 | } | 43 | } |
44 | queryFunc := func() (interface{}, error) { | 44 | queryFunc := func() (interface{}, error) { |
45 | - tx = tx.Model(m).Updates(m) | 45 | + tx = tx.Model(m).Save(m) |
46 | return nil, tx.Error | 46 | return nil, tx.Error |
47 | } | 47 | } |
48 | if _, err = repository.Query(queryFunc, m.CacheKeyFunc()); err != nil { | 48 | if _, err = repository.Query(queryFunc, m.CacheKeyFunc()); err != nil { |
@@ -46,7 +46,7 @@ func (repository *ArticleCommentRepository) Update(ctx context.Context, conn tra | @@ -46,7 +46,7 @@ func (repository *ArticleCommentRepository) Update(ctx context.Context, conn tra | ||
46 | return nil, err | 46 | return nil, err |
47 | } | 47 | } |
48 | queryFunc := func() (interface{}, error) { | 48 | queryFunc := func() (interface{}, error) { |
49 | - tx = tx.Model(m).Updates(m) | 49 | + tx = tx.Model(m).Save(m) |
50 | return nil, tx.Error | 50 | return nil, tx.Error |
51 | } | 51 | } |
52 | if _, err = repository.Query(queryFunc, m.CacheKeyFunc()); err != nil { | 52 | if _, err = repository.Query(queryFunc, m.CacheKeyFunc()); err != nil { |
@@ -42,7 +42,7 @@ func (repository *ArticleDraftRepository) Update(ctx context.Context, conn trans | @@ -42,7 +42,7 @@ func (repository *ArticleDraftRepository) Update(ctx context.Context, conn trans | ||
42 | return nil, err | 42 | return nil, err |
43 | } | 43 | } |
44 | queryFunc := func() (interface{}, error) { | 44 | queryFunc := func() (interface{}, error) { |
45 | - tx = tx.Model(m).Updates(m) | 45 | + tx = tx.Model(m).Save(m) |
46 | return nil, tx.Error | 46 | return nil, tx.Error |
47 | } | 47 | } |
48 | if _, err = repository.Query(queryFunc, m.CacheKeyFunc()); err != nil { | 48 | if _, err = repository.Query(queryFunc, m.CacheKeyFunc()); err != nil { |
@@ -66,7 +66,7 @@ func (repository *ArticleTagRepository) Update(ctx context.Context, conn transac | @@ -66,7 +66,7 @@ func (repository *ArticleTagRepository) Update(ctx context.Context, conn transac | ||
66 | return nil, err | 66 | return nil, err |
67 | } | 67 | } |
68 | queryFunc := func() (interface{}, error) { | 68 | queryFunc := func() (interface{}, error) { |
69 | - tx = tx.Model(m).Updates(m) | 69 | + tx = tx.Model(m).Save(m) |
70 | return nil, tx.Error | 70 | return nil, tx.Error |
71 | } | 71 | } |
72 | if _, err = repository.Query(queryFunc, m.CacheKeyFunc()); err != nil { | 72 | if _, err = repository.Query(queryFunc, m.CacheKeyFunc()); err != nil { |
@@ -3,6 +3,7 @@ package repository | @@ -3,6 +3,7 @@ package repository | ||
3 | import ( | 3 | import ( |
4 | "context" | 4 | "context" |
5 | "fmt" | 5 | "fmt" |
6 | + | ||
6 | "github.com/jinzhu/copier" | 7 | "github.com/jinzhu/copier" |
7 | "github.com/pkg/errors" | 8 | "github.com/pkg/errors" |
8 | "github.com/tiptok/gocomm/pkg/cache" | 9 | "github.com/tiptok/gocomm/pkg/cache" |
@@ -43,7 +44,7 @@ func (repository *CompanyRepository) Update(ctx context.Context, conn transactio | @@ -43,7 +44,7 @@ func (repository *CompanyRepository) Update(ctx context.Context, conn transactio | ||
43 | return nil, err | 44 | return nil, err |
44 | } | 45 | } |
45 | queryFunc := func() (interface{}, error) { | 46 | queryFunc := func() (interface{}, error) { |
46 | - tx = tx.Model(m).Updates(m) | 47 | + tx = tx.Model(m).Save(m) |
47 | return nil, tx.Error | 48 | return nil, tx.Error |
48 | } | 49 | } |
49 | if _, err = repository.Query(queryFunc, m.CacheKeyFunc()); err != nil { | 50 | if _, err = repository.Query(queryFunc, m.CacheKeyFunc()); err != nil { |
@@ -2,6 +2,7 @@ package repository | @@ -2,6 +2,7 @@ package repository | ||
2 | 2 | ||
3 | import ( | 3 | import ( |
4 | "context" | 4 | "context" |
5 | + | ||
5 | "github.com/jinzhu/copier" | 6 | "github.com/jinzhu/copier" |
6 | "github.com/pkg/errors" | 7 | "github.com/pkg/errors" |
7 | "github.com/tiptok/gocomm/pkg/cache" | 8 | "github.com/tiptok/gocomm/pkg/cache" |
@@ -42,7 +43,7 @@ func (repository *DepartmentRepository) Update(ctx context.Context, conn transac | @@ -42,7 +43,7 @@ func (repository *DepartmentRepository) Update(ctx context.Context, conn transac | ||
42 | return nil, err | 43 | return nil, err |
43 | } | 44 | } |
44 | queryFunc := func() (interface{}, error) { | 45 | queryFunc := func() (interface{}, error) { |
45 | - tx = tx.Model(m).Updates(m) | 46 | + tx = tx.Model(m).Save(m) |
46 | return nil, tx.Error | 47 | return nil, tx.Error |
47 | } | 48 | } |
48 | if _, err = repository.Query(queryFunc, m.CacheKeyFunc()); err != nil { | 49 | if _, err = repository.Query(queryFunc, m.CacheKeyFunc()); err != nil { |
@@ -2,6 +2,7 @@ package repository | @@ -2,6 +2,7 @@ package repository | ||
2 | 2 | ||
3 | import ( | 3 | import ( |
4 | "context" | 4 | "context" |
5 | + | ||
5 | "github.com/jinzhu/copier" | 6 | "github.com/jinzhu/copier" |
6 | "github.com/pkg/errors" | 7 | "github.com/pkg/errors" |
7 | "github.com/tiptok/gocomm/pkg/cache" | 8 | "github.com/tiptok/gocomm/pkg/cache" |
@@ -42,7 +43,7 @@ func (repository *DiscussionAcceptRepository) Update(ctx context.Context, conn t | @@ -42,7 +43,7 @@ func (repository *DiscussionAcceptRepository) Update(ctx context.Context, conn t | ||
42 | return nil, err | 43 | return nil, err |
43 | } | 44 | } |
44 | queryFunc := func() (interface{}, error) { | 45 | queryFunc := func() (interface{}, error) { |
45 | - tx = tx.Model(m).Updates(m) | 46 | + tx = tx.Model(m).Save(m) |
46 | return nil, tx.Error | 47 | return nil, tx.Error |
47 | } | 48 | } |
48 | if _, err = repository.Query(queryFunc, m.CacheKeyFunc()); err != nil { | 49 | if _, err = repository.Query(queryFunc, m.CacheKeyFunc()); err != nil { |
@@ -2,6 +2,7 @@ package repository | @@ -2,6 +2,7 @@ package repository | ||
2 | 2 | ||
3 | import ( | 3 | import ( |
4 | "context" | 4 | "context" |
5 | + | ||
5 | "github.com/jinzhu/copier" | 6 | "github.com/jinzhu/copier" |
6 | "github.com/pkg/errors" | 7 | "github.com/pkg/errors" |
7 | "github.com/tiptok/gocomm/pkg/cache" | 8 | "github.com/tiptok/gocomm/pkg/cache" |
@@ -42,7 +43,7 @@ func (repository *DiscussionOpinionRepository) Update(ctx context.Context, conn | @@ -42,7 +43,7 @@ func (repository *DiscussionOpinionRepository) Update(ctx context.Context, conn | ||
42 | return nil, err | 43 | return nil, err |
43 | } | 44 | } |
44 | queryFunc := func() (interface{}, error) { | 45 | queryFunc := func() (interface{}, error) { |
45 | - tx = tx.Model(m).Updates(m) | 46 | + tx = tx.Model(m).Save(m) |
46 | return nil, tx.Error | 47 | return nil, tx.Error |
47 | } | 48 | } |
48 | if _, err = repository.Query(queryFunc, m.CacheKeyFunc()); err != nil { | 49 | if _, err = repository.Query(queryFunc, m.CacheKeyFunc()); err != nil { |
@@ -2,6 +2,7 @@ package repository | @@ -2,6 +2,7 @@ package repository | ||
2 | 2 | ||
3 | import ( | 3 | import ( |
4 | "context" | 4 | "context" |
5 | + | ||
5 | "github.com/jinzhu/copier" | 6 | "github.com/jinzhu/copier" |
6 | "github.com/pkg/errors" | 7 | "github.com/pkg/errors" |
7 | "github.com/tiptok/gocomm/pkg/cache" | 8 | "github.com/tiptok/gocomm/pkg/cache" |
@@ -42,7 +43,7 @@ func (repository *DiscussionRepository) Update(ctx context.Context, conn transac | @@ -42,7 +43,7 @@ func (repository *DiscussionRepository) Update(ctx context.Context, conn transac | ||
42 | return nil, err | 43 | return nil, err |
43 | } | 44 | } |
44 | queryFunc := func() (interface{}, error) { | 45 | queryFunc := func() (interface{}, error) { |
45 | - tx = tx.Model(m).Updates(m) | 46 | + tx = tx.Model(m).Save(m) |
46 | return nil, tx.Error | 47 | return nil, tx.Error |
47 | } | 48 | } |
48 | if _, err = repository.Query(queryFunc, m.CacheKeyFunc()); err != nil { | 49 | if _, err = repository.Query(queryFunc, m.CacheKeyFunc()); err != nil { |
@@ -43,7 +43,7 @@ func (repository *MessageBusinessRepository) Update(ctx context.Context, conn tr | @@ -43,7 +43,7 @@ func (repository *MessageBusinessRepository) Update(ctx context.Context, conn tr | ||
43 | return nil, err | 43 | return nil, err |
44 | } | 44 | } |
45 | queryFunc := func() (interface{}, error) { | 45 | queryFunc := func() (interface{}, error) { |
46 | - tx = tx.Model(m).Updates(m) | 46 | + tx = tx.Model(m).Save(m) |
47 | return nil, tx.Error | 47 | return nil, tx.Error |
48 | } | 48 | } |
49 | if _, err = repository.Query(queryFunc, m.CacheKeyFunc()); err != nil { | 49 | if _, err = repository.Query(queryFunc, m.CacheKeyFunc()); err != nil { |
@@ -43,7 +43,7 @@ func (repository *MessageSystemRepository) Update(ctx context.Context, conn tran | @@ -43,7 +43,7 @@ func (repository *MessageSystemRepository) Update(ctx context.Context, conn tran | ||
43 | return nil, err | 43 | return nil, err |
44 | } | 44 | } |
45 | queryFunc := func() (interface{}, error) { | 45 | queryFunc := func() (interface{}, error) { |
46 | - tx = tx.Model(m).Updates(m) | 46 | + tx = tx.Model(m).Save(m) |
47 | return nil, tx.Error | 47 | return nil, tx.Error |
48 | } | 48 | } |
49 | if _, err = repository.Query(queryFunc, m.CacheKeyFunc()); err != nil { | 49 | if _, err = repository.Query(queryFunc, m.CacheKeyFunc()); err != nil { |
@@ -2,6 +2,7 @@ package repository | @@ -2,6 +2,7 @@ package repository | ||
2 | 2 | ||
3 | import ( | 3 | import ( |
4 | "context" | 4 | "context" |
5 | + | ||
5 | "github.com/jinzhu/copier" | 6 | "github.com/jinzhu/copier" |
6 | "github.com/pkg/errors" | 7 | "github.com/pkg/errors" |
7 | "github.com/tiptok/gocomm/pkg/cache" | 8 | "github.com/tiptok/gocomm/pkg/cache" |
@@ -42,7 +43,7 @@ func (repository *RoleRepository) Update(ctx context.Context, conn transaction.C | @@ -42,7 +43,7 @@ func (repository *RoleRepository) Update(ctx context.Context, conn transaction.C | ||
42 | return nil, err | 43 | return nil, err |
43 | } | 44 | } |
44 | queryFunc := func() (interface{}, error) { | 45 | queryFunc := func() (interface{}, error) { |
45 | - tx = tx.Model(m).Updates(m) | 46 | + tx = tx.Model(m).Save(m) |
46 | return nil, tx.Error | 47 | return nil, tx.Error |
47 | } | 48 | } |
48 | if _, err = repository.Query(queryFunc, m.CacheKeyFunc()); err != nil { | 49 | if _, err = repository.Query(queryFunc, m.CacheKeyFunc()); err != nil { |
@@ -2,6 +2,7 @@ package repository | @@ -2,6 +2,7 @@ package repository | ||
2 | 2 | ||
3 | import ( | 3 | import ( |
4 | "context" | 4 | "context" |
5 | + | ||
5 | "github.com/jinzhu/copier" | 6 | "github.com/jinzhu/copier" |
6 | "github.com/pkg/errors" | 7 | "github.com/pkg/errors" |
7 | "github.com/tiptok/gocomm/pkg/cache" | 8 | "github.com/tiptok/gocomm/pkg/cache" |
@@ -42,7 +43,7 @@ func (repository *UserFollowRepository) Update(ctx context.Context, conn transac | @@ -42,7 +43,7 @@ func (repository *UserFollowRepository) Update(ctx context.Context, conn transac | ||
42 | return nil, err | 43 | return nil, err |
43 | } | 44 | } |
44 | queryFunc := func() (interface{}, error) { | 45 | queryFunc := func() (interface{}, error) { |
45 | - tx = tx.Model(m).Updates(m) | 46 | + tx = tx.Model(m).Save(m) |
46 | return nil, tx.Error | 47 | return nil, tx.Error |
47 | } | 48 | } |
48 | if _, err = repository.Query(queryFunc, m.CacheKeyFunc()); err != nil { | 49 | if _, err = repository.Query(queryFunc, m.CacheKeyFunc()); err != nil { |
@@ -42,7 +42,7 @@ func (repository *UserLoveFlagRepository) Update(ctx context.Context, conn trans | @@ -42,7 +42,7 @@ func (repository *UserLoveFlagRepository) Update(ctx context.Context, conn trans | ||
42 | return nil, err | 42 | return nil, err |
43 | } | 43 | } |
44 | queryFunc := func() (interface{}, error) { | 44 | queryFunc := func() (interface{}, error) { |
45 | - tx = tx.Model(m).Updates(m) | 45 | + tx = tx.Model(m).Save(m) |
46 | return nil, tx.Error | 46 | return nil, tx.Error |
47 | } | 47 | } |
48 | if _, err = repository.Query(queryFunc, m.CacheKeyFunc()); err != nil { | 48 | if _, err = repository.Query(queryFunc, m.CacheKeyFunc()); err != nil { |
@@ -43,7 +43,7 @@ func (repository *UserReadArticleRepository) Update(ctx context.Context, conn tr | @@ -43,7 +43,7 @@ func (repository *UserReadArticleRepository) Update(ctx context.Context, conn tr | ||
43 | return nil, err | 43 | return nil, err |
44 | } | 44 | } |
45 | queryFunc := func() (interface{}, error) { | 45 | queryFunc := func() (interface{}, error) { |
46 | - tx = tx.Model(m).Updates(m) | 46 | + tx = tx.Model(m).Save(m) |
47 | return nil, tx.Error | 47 | return nil, tx.Error |
48 | } | 48 | } |
49 | if _, err = repository.Query(queryFunc, m.CacheKeyFunc()); err != nil { | 49 | if _, err = repository.Query(queryFunc, m.CacheKeyFunc()); err != nil { |
@@ -3,6 +3,7 @@ package repository | @@ -3,6 +3,7 @@ package repository | ||
3 | import ( | 3 | import ( |
4 | "context" | 4 | "context" |
5 | "fmt" | 5 | "fmt" |
6 | + | ||
6 | "github.com/jinzhu/copier" | 7 | "github.com/jinzhu/copier" |
7 | "github.com/pkg/errors" | 8 | "github.com/pkg/errors" |
8 | "github.com/tiptok/gocomm/pkg/cache" | 9 | "github.com/tiptok/gocomm/pkg/cache" |
@@ -43,7 +44,7 @@ func (repository *UserRepository) Update(ctx context.Context, conn transaction.C | @@ -43,7 +44,7 @@ func (repository *UserRepository) Update(ctx context.Context, conn transaction.C | ||
43 | return nil, err | 44 | return nil, err |
44 | } | 45 | } |
45 | queryFunc := func() (interface{}, error) { | 46 | queryFunc := func() (interface{}, error) { |
46 | - tx = tx.Model(m).Updates(m) | 47 | + tx = tx.Model(m).Save(m) |
47 | return nil, tx.Error | 48 | return nil, tx.Error |
48 | } | 49 | } |
49 | if _, err = repository.Query(queryFunc, m.CacheKeyFunc()); err != nil { | 50 | if _, err = repository.Query(queryFunc, m.CacheKeyFunc()); err != nil { |
@@ -2,6 +2,7 @@ package repository | @@ -2,6 +2,7 @@ package repository | ||
2 | 2 | ||
3 | import ( | 3 | import ( |
4 | "context" | 4 | "context" |
5 | + | ||
5 | "github.com/jinzhu/copier" | 6 | "github.com/jinzhu/copier" |
6 | "github.com/pkg/errors" | 7 | "github.com/pkg/errors" |
7 | "github.com/tiptok/gocomm/pkg/cache" | 8 | "github.com/tiptok/gocomm/pkg/cache" |
@@ -42,7 +43,7 @@ func (repository *UserRoleRepository) Update(ctx context.Context, conn transacti | @@ -42,7 +43,7 @@ func (repository *UserRoleRepository) Update(ctx context.Context, conn transacti | ||
42 | return nil, err | 43 | return nil, err |
43 | } | 44 | } |
44 | queryFunc := func() (interface{}, error) { | 45 | queryFunc := func() (interface{}, error) { |
45 | - tx = tx.Model(m).Updates(m) | 46 | + tx = tx.Model(m).Save(m) |
46 | return nil, tx.Error | 47 | return nil, tx.Error |
47 | } | 48 | } |
48 | if _, err = repository.Query(queryFunc, m.CacheKeyFunc()); err != nil { | 49 | if _, err = repository.Query(queryFunc, m.CacheKeyFunc()); err != nil { |
-
请 注册 或 登录 后发表评论