|
@@ -5,6 +5,8 @@ import ( |
|
@@ -5,6 +5,8 @@ import ( |
5
|
|
5
|
|
6
|
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
|
6
|
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
|
7
|
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
|
7
|
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
|
|
|
8
|
+ "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/db/transaction"
|
|
|
9
|
+ "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain"
|
8
|
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr"
|
10
|
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr"
|
9
|
|
11
|
|
10
|
"github.com/zeromicro/go-zero/core/logx"
|
12
|
"github.com/zeromicro/go-zero/core/logx"
|
|
@@ -26,24 +28,47 @@ func NewSystemEditAticleCommentLoveLogic(ctx context.Context, svcCtx *svc.Servic |
|
@@ -26,24 +28,47 @@ func NewSystemEditAticleCommentLoveLogic(ctx context.Context, svcCtx *svc.Servic |
26
|
|
28
|
|
27
|
func (l *SystemEditAticleCommentLoveLogic) SystemEditAticleCommentLove(req *types.SystemEditCommentLoveRequest) (resp *types.SystemEditCommentLoveResponse, err error) {
|
29
|
func (l *SystemEditAticleCommentLoveLogic) SystemEditAticleCommentLove(req *types.SystemEditCommentLoveRequest) (resp *types.SystemEditCommentLoveResponse, err error) {
|
28
|
var conn = l.svcCtx.DefaultDBConn()
|
30
|
var conn = l.svcCtx.DefaultDBConn()
|
29
|
- if req.CountAdminLove < 0 {
|
31
|
+
|
|
|
32
|
+ if len(req.ParamList) > 0 {
|
|
|
33
|
+ return &types.SystemEditCommentLoveResponse{}, nil
|
|
|
34
|
+ }
|
|
|
35
|
+ paramMap := map[int64]int{}
|
|
|
36
|
+ ids := []int64{}
|
|
|
37
|
+ for _, val := range req.ParamList {
|
|
|
38
|
+ if val.CountAdminLove < 0 {
|
30
|
return nil, xerr.NewErrMsg("运营点赞数不能小于0")
|
39
|
return nil, xerr.NewErrMsg("运营点赞数不能小于0")
|
31
|
}
|
40
|
}
|
32
|
- commetInfo, err := l.svcCtx.ArticleCommentRepository.FindOne(l.ctx, conn, req.Id)
|
41
|
+ ids = append(ids, val.Id)
|
|
|
42
|
+ paramMap[val.Id] = val.CountAdminLove
|
|
|
43
|
+ }
|
|
|
44
|
+
|
|
|
45
|
+ queryOption := domain.NewQueryOptions().WithFindOnly().MustWithKV("ids", ids)
|
|
|
46
|
+ _, commetList, err := l.svcCtx.ArticleCommentRepository.Find(l.ctx, conn, queryOption)
|
33
|
if err != nil {
|
47
|
if err != nil {
|
34
|
return nil, xerr.NewErrMsgErr("编辑评论信息失败", err)
|
48
|
return nil, xerr.NewErrMsgErr("编辑评论信息失败", err)
|
35
|
}
|
49
|
}
|
36
|
- if commetInfo.CompanyId != req.CompanyId {
|
|
|
37
|
- return nil, xerr.NewErrMsg("没有操作权限")
|
50
|
+ resp = &types.SystemEditCommentLoveResponse{}
|
|
|
51
|
+ for _, val := range commetList {
|
|
|
52
|
+ if u, ok := paramMap[val.Id]; ok {
|
|
|
53
|
+ val.CountAdminLove = u
|
|
|
54
|
+ resp.ParamList = append(resp.ParamList, types.SystemEditLove{
|
|
|
55
|
+ Id: val.Id,
|
|
|
56
|
+ CountAdminLove: val.CountAdminLove,
|
|
|
57
|
+ })
|
38
|
}
|
58
|
}
|
39
|
-
|
|
|
40
|
- commetInfo.CountAdminLove = req.CountAdminLove
|
|
|
41
|
- _, err = l.svcCtx.ArticleCommentRepository.Update(l.ctx, conn, commetInfo)
|
59
|
+ }
|
|
|
60
|
+ err = transaction.UseTrans(l.ctx, conn.DB(), func(ctx context.Context, c transaction.Conn) error {
|
|
|
61
|
+ for _, val := range commetList {
|
|
|
62
|
+ _, err := l.svcCtx.ArticleCommentRepository.Update(ctx, c, val)
|
42
|
if err != nil {
|
63
|
if err != nil {
|
43
|
- return nil, xerr.NewErrMsgErr("编辑评论信息失败", err)
|
64
|
+ return err
|
44
|
}
|
65
|
}
|
45
|
- resp = &types.SystemEditCommentLoveResponse{
|
|
|
46
|
- Id: commetInfo.Id,
|
|
|
47
|
}
|
66
|
}
|
48
|
- return
|
67
|
+ return nil
|
|
|
68
|
+ }, true)
|
|
|
69
|
+ if err != nil {
|
|
|
70
|
+ return nil, xerr.NewErrMsgErr("编辑评论信息失败", err)
|
|
|
71
|
+ }
|
|
|
72
|
+
|
|
|
73
|
+ return resp, nil
|
49
|
} |
74
|
} |