作者 tangxvhui

添加接口 编辑某个评论的运营点赞

@@ -76,6 +76,10 @@ service Core { @@ -76,6 +76,10 @@ service Core {
76 @doc "管理后台变更评论" 76 @doc "管理后台变更评论"
77 @handler SystemEditAticleComment 77 @handler SystemEditAticleComment
78 post /article_comment/edit (SystemEditCommentRequest)returns (SystemEditCommentResponse) 78 post /article_comment/edit (SystemEditCommentRequest)returns (SystemEditCommentResponse)
  79 +
  80 + @doc "编辑评论的运营点赞数"
  81 + @handler SystemEditAticleCommentLove
  82 + post /article_comment/edit/love (SystemEditCommentLoveRequest)returns (SystemEditCommentLoveResponse)
79 } 83 }
80 84
81 //评论的填写人 85 //评论的填写人
@@ -367,4 +371,17 @@ type ( @@ -367,4 +371,17 @@ type (
367 SystemEditCommentResponse { 371 SystemEditCommentResponse {
368 Id int64 `json:"id"` 372 Id int64 `json:"id"`
369 } 373 }
  374 +)
  375 +
  376 +// 管理后台变更评论的运营点赞
  377 +type (
  378 + SystemEditCommentLoveRequest {
  379 + CompanyId int64 `json:",optional"`
  380 + Id int64 `json:"id"`
  381 + CountAdminLove int `json:"countAdminLove,optional"`
  382 + }
  383 +
  384 + SystemEditCommentLoveResponse {
  385 + Id int64 `json:"id"`
  386 + }
370 ) 387 )
@@ -15,7 +15,7 @@ func SystemEditAticleCommentHandler(svcCtx *svc.ServiceContext) http.HandlerFunc @@ -15,7 +15,7 @@ func SystemEditAticleCommentHandler(svcCtx *svc.ServiceContext) http.HandlerFunc
15 return func(w http.ResponseWriter, r *http.Request) { 15 return func(w http.ResponseWriter, r *http.Request) {
16 var req types.SystemEditCommentRequest 16 var req types.SystemEditCommentRequest
17 if err := httpx.Parse(r, &req); err != nil { 17 if err := httpx.Parse(r, &req); err != nil {
18 - httpx.ErrorCtx(r.Context(), w, err) 18 + result.HttpResult(r, w, nil, err)
19 return 19 return
20 } 20 }
21 21
  1 +package comment
  2 +
  3 +import (
  4 + "net/http"
  5 +
  6 + "github.com/zeromicro/go-zero/rest/httpx"
  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"
  9 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
  10 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/result"
  11 +)
  12 +
  13 +// 单独编辑评论的运营点赞数量
  14 +func SystemEditAticleCommentLoveHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
  15 + return func(w http.ResponseWriter, r *http.Request) {
  16 + var req types.SystemEditCommentLoveRequest
  17 + if err := httpx.Parse(r, &req); err != nil {
  18 + result.HttpResult(r, w, nil, err)
  19 + return
  20 + }
  21 +
  22 + l := comment.NewSystemEditAticleCommentLoveLogic(r.Context(), svcCtx)
  23 + resp, err := l.SystemEditAticleCommentLove(&req)
  24 + result.HttpResult(r, w, resp, err)
  25 + }
  26 +}
@@ -133,6 +133,11 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { @@ -133,6 +133,11 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
133 Path: "/article_comment/edit", 133 Path: "/article_comment/edit",
134 Handler: comment.SystemEditAticleCommentHandler(serverCtx), 134 Handler: comment.SystemEditAticleCommentHandler(serverCtx),
135 }, 135 },
  136 + {
  137 + Method: http.MethodPost,
  138 + Path: "/article_comment/edit/love",
  139 + Handler: comment.SystemEditAticleCommentLoveHandler(serverCtx),
  140 + },
136 }..., 141 }...,
137 ), 142 ),
138 rest.WithJwt(serverCtx.Config.SystemAuth.AccessSecret), 143 rest.WithJwt(serverCtx.Config.SystemAuth.AccessSecret),
  1 +package comment
  2 +
  3 +import (
  4 + "context"
  5 +
  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"
  8 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr"
  9 +
  10 + "github.com/zeromicro/go-zero/core/logx"
  11 +)
  12 +
  13 +type SystemEditAticleCommentLoveLogic struct {
  14 + logx.Logger
  15 + ctx context.Context
  16 + svcCtx *svc.ServiceContext
  17 +}
  18 +
  19 +func NewSystemEditAticleCommentLoveLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SystemEditAticleCommentLoveLogic {
  20 + return &SystemEditAticleCommentLoveLogic{
  21 + Logger: logx.WithContext(ctx),
  22 + ctx: ctx,
  23 + svcCtx: svcCtx,
  24 + }
  25 +}
  26 +
  27 +func (l *SystemEditAticleCommentLoveLogic) SystemEditAticleCommentLove(req *types.SystemEditCommentLoveRequest) (resp *types.SystemEditCommentLoveResponse, err error) {
  28 + var conn = l.svcCtx.DefaultDBConn()
  29 + if req.CountAdminLove < 0 {
  30 + return nil, xerr.NewErrMsg("运营点赞数不能小于0")
  31 + }
  32 + commetInfo, err := l.svcCtx.ArticleCommentRepository.FindOne(l.ctx, conn, req.Id)
  33 + if err != nil {
  34 + return nil, xerr.NewErrMsgErr("编辑评论信息失败", err)
  35 + }
  36 + if commetInfo.CompanyId != req.CompanyId {
  37 + return nil, xerr.NewErrMsg("没有操作权限")
  38 + }
  39 +
  40 + commetInfo.CountAdminLove = req.CountAdminLove
  41 + _, err = l.svcCtx.ArticleCommentRepository.Update(l.ctx, conn, commetInfo)
  42 + if err != nil {
  43 + return nil, xerr.NewErrMsgErr("编辑评论信息失败", err)
  44 + }
  45 + resp = &types.SystemEditCommentLoveResponse{
  46 + Id: commetInfo.Id,
  47 + }
  48 + return
  49 +}
@@ -275,6 +275,16 @@ type SystemEditCommentResponse struct { @@ -275,6 +275,16 @@ type SystemEditCommentResponse struct {
275 Id int64 `json:"id"` 275 Id int64 `json:"id"`
276 } 276 }
277 277
  278 +type SystemEditCommentLoveRequest struct {
  279 + CompanyId int64 `json:",optional"`
  280 + Id int64 `json:"id"`
  281 + CountAdminLove int `json:"countAdminLove,optional"`
  282 +}
  283 +
  284 +type SystemEditCommentLoveResponse struct {
  285 + Id int64 `json:"id"`
  286 +}
  287 +
278 type MessageRequest struct { 288 type MessageRequest struct {
279 Page int `json:"page"` 289 Page int `json:"page"`
280 Size int `json:"size"` 290 Size int `json:"size"`