作者 tangxvhui

Merge branch 'dev' into test

... ... @@ -376,12 +376,14 @@ type (
// 管理后台变更评论的运营点赞
type (
SystemEditCommentLoveRequest {
CompanyId int64 `json:",optional"`
CompanyId int64 `json:",optional"`
ParamList []SystemEditLove `json:"paramList"`
}
SystemEditLove {
Id int64 `json:"id"`
CountAdminLove int `json:"countAdminLove,optional"`
}
SystemEditCommentLoveResponse {
Id int64 `json:"id"`
ParamList []SystemEditLove `json:"paramList"`
}
)
\ No newline at end of file
... ...
... ... @@ -7,6 +7,7 @@ import (
"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/contextdata"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/result"
)
... ... @@ -18,7 +19,8 @@ func SystemEditAticleCommentLoveHandler(svcCtx *svc.ServiceContext) http.Handler
result.HttpResult(r, w, nil, err)
return
}
token := contextdata.GetUserTokenFromCtx(r.Context())
req.CompanyId = token.CompanyId
l := comment.NewSystemEditAticleCommentLoveLogic(r.Context(), svcCtx)
resp, err := l.SystemEditAticleCommentLove(&req)
result.HttpResult(r, w, resp, err)
... ...
... ... @@ -5,6 +5,8 @@ import (
"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/cmd/discuss/interanl/pkg/db/transaction"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr"
"github.com/zeromicro/go-zero/core/logx"
... ... @@ -26,24 +28,50 @@ func NewSystemEditAticleCommentLoveLogic(ctx context.Context, svcCtx *svc.Servic
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")
if len(req.ParamList) > 0 {
return &types.SystemEditCommentLoveResponse{}, nil
}
paramMap := map[int64]int{}
ids := []int64{}
for _, val := range req.ParamList {
if val.CountAdminLove < 0 {
return nil, xerr.NewErrMsg("运营点赞数不能小于0")
}
ids = append(ids, val.Id)
paramMap[val.Id] = val.CountAdminLove
}
commetInfo, err := l.svcCtx.ArticleCommentRepository.FindOne(l.ctx, conn, req.Id)
queryOption := domain.NewQueryOptions().WithFindOnly().MustWithKV("ids", ids)
_, commetList, err := l.svcCtx.ArticleCommentRepository.Find(l.ctx, conn, queryOption)
if err != nil {
return nil, xerr.NewErrMsgErr("编辑评论信息失败", err)
}
if commetInfo.CompanyId != req.CompanyId {
return nil, xerr.NewErrMsg("没有操作权限")
resp = &types.SystemEditCommentLoveResponse{}
for _, val := range commetList {
if val.CompanyId != req.CompanyId {
return nil, xerr.NewErrMsg("没有操作权限")
}
if u, ok := paramMap[val.Id]; ok {
val.CountAdminLove = u
resp.ParamList = append(resp.ParamList, types.SystemEditLove{
Id: val.Id,
CountAdminLove: val.CountAdminLove,
})
}
}
commetInfo.CountAdminLove = req.CountAdminLove
_, err = l.svcCtx.ArticleCommentRepository.Update(l.ctx, conn, commetInfo)
err = transaction.UseTrans(l.ctx, conn.DB(), func(ctx context.Context, c transaction.Conn) error {
for _, val := range commetList {
_, err := l.svcCtx.ArticleCommentRepository.UpdateWithVersion(ctx, c, val)
if err != nil {
return err
}
}
return nil
}, true)
if err != nil {
return nil, xerr.NewErrMsgErr("编辑评论信息失败", err)
}
resp = &types.SystemEditCommentLoveResponse{
Id: commetInfo.Id,
}
return
return resp, nil
}
... ...
... ... @@ -276,13 +276,17 @@ type SystemEditCommentResponse struct {
}
type SystemEditCommentLoveRequest struct {
CompanyId int64 `json:",optional"`
CompanyId int64 `json:",optional"`
ParamList []SystemEditLove `json:"paramList"`
}
type SystemEditLove struct {
Id int64 `json:"id"`
CountAdminLove int `json:"countAdminLove,optional"`
}
type SystemEditCommentLoveResponse struct {
Id int64 `json:"id"`
ParamList []SystemEditLove `json:"paramList"`
}
type MessageRequest struct {
... ...