正在显示
4 个修改的文件
包含
54 行增加
和
18 行删除
@@ -376,12 +376,14 @@ type ( | @@ -376,12 +376,14 @@ type ( | ||
376 | // 管理后台变更评论的运营点赞 | 376 | // 管理后台变更评论的运营点赞 |
377 | type ( | 377 | type ( |
378 | SystemEditCommentLoveRequest { | 378 | SystemEditCommentLoveRequest { |
379 | - CompanyId int64 `json:",optional"` | 379 | + CompanyId int64 `json:",optional"` |
380 | + ParamList []SystemEditLove `json:"paramList"` | ||
381 | + } | ||
382 | + SystemEditLove { | ||
380 | Id int64 `json:"id"` | 383 | Id int64 `json:"id"` |
381 | CountAdminLove int `json:"countAdminLove,optional"` | 384 | CountAdminLove int `json:"countAdminLove,optional"` |
382 | } | 385 | } |
383 | - | ||
384 | SystemEditCommentLoveResponse { | 386 | SystemEditCommentLoveResponse { |
385 | - Id int64 `json:"id"` | 387 | + ParamList []SystemEditLove `json:"paramList"` |
386 | } | 388 | } |
387 | ) | 389 | ) |
@@ -7,6 +7,7 @@ import ( | @@ -7,6 +7,7 @@ import ( | ||
7 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/comment" | 7 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/comment" |
8 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | 8 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" |
9 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" | 9 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" |
10 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/contextdata" | ||
10 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/result" | 11 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/result" |
11 | ) | 12 | ) |
12 | 13 | ||
@@ -18,7 +19,8 @@ func SystemEditAticleCommentLoveHandler(svcCtx *svc.ServiceContext) http.Handler | @@ -18,7 +19,8 @@ func SystemEditAticleCommentLoveHandler(svcCtx *svc.ServiceContext) http.Handler | ||
18 | result.HttpResult(r, w, nil, err) | 19 | result.HttpResult(r, w, nil, err) |
19 | return | 20 | return |
20 | } | 21 | } |
21 | - | 22 | + token := contextdata.GetUserTokenFromCtx(r.Context()) |
23 | + req.CompanyId = token.CompanyId | ||
22 | l := comment.NewSystemEditAticleCommentLoveLogic(r.Context(), svcCtx) | 24 | l := comment.NewSystemEditAticleCommentLoveLogic(r.Context(), svcCtx) |
23 | resp, err := l.SystemEditAticleCommentLove(&req) | 25 | resp, err := l.SystemEditAticleCommentLove(&req) |
24 | result.HttpResult(r, w, resp, err) | 26 | result.HttpResult(r, w, resp, err) |
@@ -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,50 @@ func NewSystemEditAticleCommentLoveLogic(ctx context.Context, svcCtx *svc.Servic | @@ -26,24 +28,50 @@ 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 { | ||
30 | - return nil, xerr.NewErrMsg("运营点赞数不能小于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 { | ||
39 | + return nil, xerr.NewErrMsg("运营点赞数不能小于0") | ||
40 | + } | ||
41 | + ids = append(ids, val.Id) | ||
42 | + paramMap[val.Id] = val.CountAdminLove | ||
31 | } | 43 | } |
32 | - commetInfo, err := l.svcCtx.ArticleCommentRepository.FindOne(l.ctx, conn, req.Id) | 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 val.CompanyId != req.CompanyId { | ||
53 | + return nil, xerr.NewErrMsg("没有操作权限") | ||
54 | + } | ||
55 | + if u, ok := paramMap[val.Id]; ok { | ||
56 | + val.CountAdminLove = u | ||
57 | + resp.ParamList = append(resp.ParamList, types.SystemEditLove{ | ||
58 | + Id: val.Id, | ||
59 | + CountAdminLove: val.CountAdminLove, | ||
60 | + }) | ||
61 | + } | ||
38 | } | 62 | } |
39 | - | ||
40 | - commetInfo.CountAdminLove = req.CountAdminLove | ||
41 | - _, err = l.svcCtx.ArticleCommentRepository.Update(l.ctx, conn, commetInfo) | 63 | + err = transaction.UseTrans(l.ctx, conn.DB(), func(ctx context.Context, c transaction.Conn) error { |
64 | + for _, val := range commetList { | ||
65 | + _, err := l.svcCtx.ArticleCommentRepository.UpdateWithVersion(ctx, c, val) | ||
66 | + if err != nil { | ||
67 | + return err | ||
68 | + } | ||
69 | + } | ||
70 | + return nil | ||
71 | + }, true) | ||
42 | if err != nil { | 72 | if err != nil { |
43 | return nil, xerr.NewErrMsgErr("编辑评论信息失败", err) | 73 | return nil, xerr.NewErrMsgErr("编辑评论信息失败", err) |
44 | } | 74 | } |
45 | - resp = &types.SystemEditCommentLoveResponse{ | ||
46 | - Id: commetInfo.Id, | ||
47 | - } | ||
48 | - return | 75 | + |
76 | + return resp, nil | ||
49 | } | 77 | } |
@@ -276,13 +276,17 @@ type SystemEditCommentResponse struct { | @@ -276,13 +276,17 @@ type SystemEditCommentResponse struct { | ||
276 | } | 276 | } |
277 | 277 | ||
278 | type SystemEditCommentLoveRequest struct { | 278 | type SystemEditCommentLoveRequest struct { |
279 | - CompanyId int64 `json:",optional"` | 279 | + CompanyId int64 `json:",optional"` |
280 | + ParamList []SystemEditLove `json:"paramList"` | ||
281 | +} | ||
282 | + | ||
283 | +type SystemEditLove struct { | ||
280 | Id int64 `json:"id"` | 284 | Id int64 `json:"id"` |
281 | CountAdminLove int `json:"countAdminLove,optional"` | 285 | CountAdminLove int `json:"countAdminLove,optional"` |
282 | } | 286 | } |
283 | 287 | ||
284 | type SystemEditCommentLoveResponse struct { | 288 | type SystemEditCommentLoveResponse struct { |
285 | - Id int64 `json:"id"` | 289 | + ParamList []SystemEditLove `json:"paramList"` |
286 | } | 290 | } |
287 | 291 | ||
288 | type MessageRequest struct { | 292 | type MessageRequest struct { |
-
请 注册 或 登录 后发表评论