...
|
...
|
@@ -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
|
|
|
} |
...
|
...
|
|