正在显示
11 个修改的文件
包含
133 行增加
和
10 行删除
| @@ -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 | //评论的填写人 |
| @@ -368,3 +372,16 @@ type ( | @@ -368,3 +372,16 @@ type ( | ||
| 368 | Id int64 `json:"id"` | 372 | Id int64 `json:"id"` |
| 369 | } | 373 | } |
| 370 | ) | 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 | + } | ||
| 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), |
| @@ -28,6 +28,9 @@ func NewMiniArticleSearchMeLogic(ctx context.Context, svcCtx *svc.ServiceContext | @@ -28,6 +28,9 @@ func NewMiniArticleSearchMeLogic(ctx context.Context, svcCtx *svc.ServiceContext | ||
| 28 | // MiniArticleSearchMe 获取我发布的文章 | 28 | // MiniArticleSearchMe 获取我发布的文章 |
| 29 | func (l *MiniArticleSearchMeLogic) MiniArticleSearchMe(req *types.MiniArticleSearchMeRequest) (resp *types.MiniArticleSearchMeResponse, err error) { | 29 | func (l *MiniArticleSearchMeLogic) MiniArticleSearchMe(req *types.MiniArticleSearchMeRequest) (resp *types.MiniArticleSearchMeResponse, err error) { |
| 30 | var conn = l.svcCtx.DefaultDBConn() | 30 | var conn = l.svcCtx.DefaultDBConn() |
| 31 | + if req.Size > 100 { | ||
| 32 | + req.Size = 100 | ||
| 33 | + } | ||
| 31 | queryOptions := domain.NewQueryOptions(). | 34 | queryOptions := domain.NewQueryOptions(). |
| 32 | WithOffsetLimit(req.Page, req.Size). | 35 | WithOffsetLimit(req.Page, req.Size). |
| 33 | MustWithKV("authorId", req.AuthorId) | 36 | MustWithKV("authorId", req.AuthorId) |
| @@ -5,7 +5,7 @@ import ( | @@ -5,7 +5,7 @@ import ( | ||
| 5 | "strconv" | 5 | "strconv" |
| 6 | "strings" | 6 | "strings" |
| 7 | "text/template" | 7 | "text/template" |
| 8 | - "unicode" | 8 | + "unicode/utf8" |
| 9 | 9 | ||
| 10 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | 10 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" |
| 11 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" | 11 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" |
| @@ -39,13 +39,10 @@ func (l *MiniCreateArticleLogic) MiniCreateArticle(req *types.MiniArticleCreateR | @@ -39,13 +39,10 @@ func (l *MiniCreateArticleLogic) MiniCreateArticle(req *types.MiniArticleCreateR | ||
| 39 | // 检查文字数量 | 39 | // 检查文字数量 |
| 40 | wordNum := 0 | 40 | wordNum := 0 |
| 41 | for i := range req.Section { | 41 | for i := range req.Section { |
| 42 | - for _, word := range req.Section[i] { | ||
| 43 | - if !unicode.IsSpace(word) { | ||
| 44 | - wordNum++ | 42 | + num := utf8.RuneCountInString(req.Section[i]) |
| 43 | + wordNum += num | ||
| 45 | } | 44 | } |
| 46 | - } | ||
| 47 | - } | ||
| 48 | - if wordNum > 1000 { | 45 | + if wordNum >= 1000 { |
| 49 | return nil, xerr.NewErrMsgErr("最多只能输入1000字", err) | 46 | return nil, xerr.NewErrMsgErr("最多只能输入1000字", err) |
| 50 | } | 47 | } |
| 51 | // 检查发布人 | 48 | // 检查发布人 |
| @@ -28,7 +28,9 @@ func NewMiniSearchArticleDraftMeLogic(ctx context.Context, svcCtx *svc.ServiceCo | @@ -28,7 +28,9 @@ func NewMiniSearchArticleDraftMeLogic(ctx context.Context, svcCtx *svc.ServiceCo | ||
| 28 | // 查询我的草稿箱内容列表 | 28 | // 查询我的草稿箱内容列表 |
| 29 | func (l *MiniSearchArticleDraftMeLogic) MiniSearchArticleDraftMe(req *types.MiniArticleDraftSearchMeRequest) (resp *types.MiniArticleDraftSearchMeResponse, err error) { | 29 | func (l *MiniSearchArticleDraftMeLogic) MiniSearchArticleDraftMe(req *types.MiniArticleDraftSearchMeRequest) (resp *types.MiniArticleDraftSearchMeResponse, err error) { |
| 30 | var conn = l.svcCtx.DefaultDBConn() | 30 | var conn = l.svcCtx.DefaultDBConn() |
| 31 | - | 31 | + if req.Size > 100 { |
| 32 | + req.Size = 100 | ||
| 33 | + } | ||
| 32 | queryOption := domain.NewQueryOptions(). | 34 | queryOption := domain.NewQueryOptions(). |
| 33 | WithOffsetLimit(req.Page, req.Size). | 35 | WithOffsetLimit(req.Page, req.Size). |
| 34 | MustWithKV("authorId", req.AuthorId) | 36 | MustWithKV("authorId", req.AuthorId) |
| @@ -29,7 +29,9 @@ func NewMiniSearchArticlePageLogic(ctx context.Context, svcCtx *svc.ServiceConte | @@ -29,7 +29,9 @@ func NewMiniSearchArticlePageLogic(ctx context.Context, svcCtx *svc.ServiceConte | ||
| 29 | func (l *MiniSearchArticlePageLogic) MiniSearchArticlePage(req *types.MiniSearchArticleRequest) (resp *types.MiniSearchArticleResponse, err error) { | 29 | func (l *MiniSearchArticlePageLogic) MiniSearchArticlePage(req *types.MiniSearchArticleRequest) (resp *types.MiniSearchArticleResponse, err error) { |
| 30 | 30 | ||
| 31 | var conn = l.svcCtx.DefaultDBConn() | 31 | var conn = l.svcCtx.DefaultDBConn() |
| 32 | - | 32 | + if req.Size > 100 { |
| 33 | + req.Size = 100 | ||
| 34 | + } | ||
| 33 | cnt, articleList, err := l.svcCtx.ArticleRepository.CustomSearchBy(l.ctx, conn, req.UserId, req.CompanyId, | 35 | cnt, articleList, err := l.svcCtx.ArticleRepository.CustomSearchBy(l.ctx, conn, req.UserId, req.CompanyId, |
| 34 | req.TagCategory, req.TagId, [2]int64{req.BeginTime, req.EndTime}, req.SearchWord, req.Page, req.Size) | 36 | req.TagCategory, req.TagId, [2]int64{req.BeginTime, req.EndTime}, req.SearchWord, req.Page, req.Size) |
| 35 | if err != nil { | 37 | if err != nil { |
| @@ -3,6 +3,7 @@ package article | @@ -3,6 +3,7 @@ package article | ||
| 3 | import ( | 3 | import ( |
| 4 | "context" | 4 | "context" |
| 5 | "strconv" | 5 | "strconv" |
| 6 | + "unicode/utf8" | ||
| 6 | 7 | ||
| 7 | "strings" | 8 | "strings" |
| 8 | 9 | ||
| @@ -42,6 +43,17 @@ func (l *SystemUpdateArticleLogic) SystemUpdateArticle(req *types.SystemArticleU | @@ -42,6 +43,17 @@ func (l *SystemUpdateArticleLogic) SystemUpdateArticle(req *types.SystemArticleU | ||
| 42 | //TargetUser 设定为分发给所有人,清空 WhoRead | 43 | //TargetUser 设定为分发给所有人,清空 WhoRead |
| 43 | req.WhoRead = make([]int64, 0) | 44 | req.WhoRead = make([]int64, 0) |
| 44 | } | 45 | } |
| 46 | + | ||
| 47 | + // 检查文字数量 | ||
| 48 | + wordNum := 0 | ||
| 49 | + for i := range req.Section { | ||
| 50 | + num := utf8.RuneCountInString(req.Section[i].Content) | ||
| 51 | + wordNum += num | ||
| 52 | + } | ||
| 53 | + if wordNum >= 1000 { | ||
| 54 | + return nil, xerr.NewErrMsgErr("最多只能输入1000字", err) | ||
| 55 | + } | ||
| 56 | + | ||
| 45 | // 获取当前用户信息 | 57 | // 获取当前用户信息 |
| 46 | userMe, err := l.svcCtx.ApiAuthService.MeInfo(l.ctx, authlib.RequestUserMeQuery{Token: req.AccessToken}) | 58 | userMe, err := l.svcCtx.ApiAuthService.MeInfo(l.ctx, authlib.RequestUserMeQuery{Token: req.AccessToken}) |
| 47 | if err != nil { | 59 | if err != nil { |
| 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"` |
-
请 注册 或 登录 后发表评论