作者 tangxvhui

Merge branch 'dev' into test

... ... @@ -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),
... ...
... ... @@ -28,6 +28,9 @@ func NewMiniArticleSearchMeLogic(ctx context.Context, svcCtx *svc.ServiceContext
// MiniArticleSearchMe 获取我发布的文章
func (l *MiniArticleSearchMeLogic) MiniArticleSearchMe(req *types.MiniArticleSearchMeRequest) (resp *types.MiniArticleSearchMeResponse, err error) {
var conn = l.svcCtx.DefaultDBConn()
if req.Size > 100 {
req.Size = 100
}
queryOptions := domain.NewQueryOptions().
WithOffsetLimit(req.Page, req.Size).
MustWithKV("authorId", req.AuthorId)
... ...
... ... @@ -5,7 +5,7 @@ import (
"strconv"
"strings"
"text/template"
"unicode"
"unicode/utf8"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
... ... @@ -39,13 +39,10 @@ func (l *MiniCreateArticleLogic) MiniCreateArticle(req *types.MiniArticleCreateR
// 检查文字数量
wordNum := 0
for i := range req.Section {
for _, word := range req.Section[i] {
if !unicode.IsSpace(word) {
wordNum++
}
}
num := utf8.RuneCountInString(req.Section[i])
wordNum += num
}
if wordNum > 1000 {
if wordNum >= 1000 {
return nil, xerr.NewErrMsgErr("最多只能输入1000字", err)
}
// 检查发布人
... ...
... ... @@ -28,7 +28,9 @@ func NewMiniSearchArticleDraftMeLogic(ctx context.Context, svcCtx *svc.ServiceCo
// 查询我的草稿箱内容列表
func (l *MiniSearchArticleDraftMeLogic) MiniSearchArticleDraftMe(req *types.MiniArticleDraftSearchMeRequest) (resp *types.MiniArticleDraftSearchMeResponse, err error) {
var conn = l.svcCtx.DefaultDBConn()
if req.Size > 100 {
req.Size = 100
}
queryOption := domain.NewQueryOptions().
WithOffsetLimit(req.Page, req.Size).
MustWithKV("authorId", req.AuthorId)
... ...
... ... @@ -29,7 +29,9 @@ func NewMiniSearchArticlePageLogic(ctx context.Context, svcCtx *svc.ServiceConte
func (l *MiniSearchArticlePageLogic) MiniSearchArticlePage(req *types.MiniSearchArticleRequest) (resp *types.MiniSearchArticleResponse, err error) {
var conn = l.svcCtx.DefaultDBConn()
if req.Size > 100 {
req.Size = 100
}
cnt, articleList, err := l.svcCtx.ArticleRepository.CustomSearchBy(l.ctx, conn, req.UserId, req.CompanyId,
req.TagCategory, req.TagId, [2]int64{req.BeginTime, req.EndTime}, req.SearchWord, req.Page, req.Size)
if err != nil {
... ...
... ... @@ -3,6 +3,7 @@ package article
import (
"context"
"strconv"
"unicode/utf8"
"strings"
... ... @@ -42,6 +43,17 @@ func (l *SystemUpdateArticleLogic) SystemUpdateArticle(req *types.SystemArticleU
//TargetUser 设定为分发给所有人,清空 WhoRead
req.WhoRead = make([]int64, 0)
}
// 检查文字数量
wordNum := 0
for i := range req.Section {
num := utf8.RuneCountInString(req.Section[i].Content)
wordNum += num
}
if wordNum >= 1000 {
return nil, xerr.NewErrMsgErr("最多只能输入1000字", err)
}
// 获取当前用户信息
userMe, err := l.svcCtx.ApiAuthService.MeInfo(l.ctx, authlib.RequestUserMeQuery{Token: req.AccessToken})
if err != nil {
... ...
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"`
... ...