作者 tangxvhui

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

... ... @@ -76,6 +76,10 @@ service Core {
@doc "管理后台变更评论"
@handler SystemEditAticleComment
post /article_comment/edit (SystemEditCommentRequest)returns (SystemEditCommentResponse)
@doc "编辑评论的运营点赞数"
@handler SystemEditAticleCommentLove
post /article_comment/edit/love (SystemEditCommentLoveRequest)returns (SystemEditCommentLoveResponse)
}
//评论的填写人
... ... @@ -367,4 +371,17 @@ type (
SystemEditCommentResponse {
Id int64 `json:"id"`
}
)
// 管理后台变更评论的运营点赞
type (
SystemEditCommentLoveRequest {
CompanyId int64 `json:",optional"`
Id int64 `json:"id"`
CountAdminLove int `json:"countAdminLove,optional"`
}
SystemEditCommentLoveResponse {
Id int64 `json:"id"`
}
)
\ No newline at end of file
... ...
... ... @@ -15,7 +15,7 @@ func SystemEditAticleCommentHandler(svcCtx *svc.ServiceContext) http.HandlerFunc
return func(w http.ResponseWriter, r *http.Request) {
var req types.SystemEditCommentRequest
if err := httpx.Parse(r, &req); err != nil {
httpx.ErrorCtx(r.Context(), w, err)
result.HttpResult(r, w, nil, err)
return
}
... ...
package comment
import (
"net/http"
"github.com/zeromicro/go-zero/rest/httpx"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/comment"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/result"
)
// 单独编辑评论的运营点赞数量
func SystemEditAticleCommentLoveHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.SystemEditCommentLoveRequest
if err := httpx.Parse(r, &req); err != nil {
result.HttpResult(r, w, nil, err)
return
}
l := comment.NewSystemEditAticleCommentLoveLogic(r.Context(), svcCtx)
resp, err := l.SystemEditAticleCommentLove(&req)
result.HttpResult(r, w, resp, err)
}
}
... ...
... ... @@ -133,6 +133,11 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
Path: "/article_comment/edit",
Handler: comment.SystemEditAticleCommentHandler(serverCtx),
},
{
Method: http.MethodPost,
Path: "/article_comment/edit/love",
Handler: comment.SystemEditAticleCommentLoveHandler(serverCtx),
},
}...,
),
rest.WithJwt(serverCtx.Config.SystemAuth.AccessSecret),
... ...
package comment
import (
"context"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr"
"github.com/zeromicro/go-zero/core/logx"
)
type SystemEditAticleCommentLoveLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewSystemEditAticleCommentLoveLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SystemEditAticleCommentLoveLogic {
return &SystemEditAticleCommentLoveLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}
func (l *SystemEditAticleCommentLoveLogic) SystemEditAticleCommentLove(req *types.SystemEditCommentLoveRequest) (resp *types.SystemEditCommentLoveResponse, err error) {
var conn = l.svcCtx.DefaultDBConn()
if req.CountAdminLove < 0 {
return nil, xerr.NewErrMsg("运营点赞数不能小于0")
}
commetInfo, err := l.svcCtx.ArticleCommentRepository.FindOne(l.ctx, conn, req.Id)
if err != nil {
return nil, xerr.NewErrMsgErr("编辑评论信息失败", err)
}
if commetInfo.CompanyId != req.CompanyId {
return nil, xerr.NewErrMsg("没有操作权限")
}
commetInfo.CountAdminLove = req.CountAdminLove
_, err = l.svcCtx.ArticleCommentRepository.Update(l.ctx, conn, commetInfo)
if err != nil {
return nil, xerr.NewErrMsgErr("编辑评论信息失败", err)
}
resp = &types.SystemEditCommentLoveResponse{
Id: commetInfo.Id,
}
return
}
... ...
... ... @@ -275,6 +275,16 @@ type SystemEditCommentResponse struct {
Id int64 `json:"id"`
}
type SystemEditCommentLoveRequest struct {
CompanyId int64 `json:",optional"`
Id int64 `json:"id"`
CountAdminLove int `json:"countAdminLove,optional"`
}
type SystemEditCommentLoveResponse struct {
Id int64 `json:"id"`
}
type MessageRequest struct {
Page int `json:"page"`
Size int `json:"size"`
... ...