作者 tangxvhui

更新 模型接口

@@ -55,7 +55,7 @@ type ( @@ -55,7 +55,7 @@ type (
55 CountRead int `json:"countRead"` // 浏览数量 55 CountRead int `json:"countRead"` // 浏览数量
56 Show int `json:"show"` // 评论的展示状态(0显示、1不显示) 56 Show int `json:"show"` // 评论的展示状态(0显示、1不显示)
57 Edit int `json:"edit"` // 文章是否存在变更记录 (0 不存在 1存在) 57 Edit int `json:"edit"` // 文章是否存在变更记录 (0 不存在 1存在)
58 - MeLoveFlag int `json:"meLoveFlag"` //当前人员对文章的点赞标识 58 + MeLoveFlag int `json:"meLoveFlag"` // 当前人员对文章的点赞标识 (0 没有点赞 1有点赞)
59 } 59 }
60 ArticleSection { 60 ArticleSection {
61 Id int64 `json:"id"` //段落id 61 Id int64 `json:"id"` //段落id
@@ -31,6 +31,10 @@ service Core { @@ -31,6 +31,10 @@ service Core {
31 @doc "小程序展示单个文章的评论" 31 @doc "小程序展示单个文章的评论"
32 @handler MiniGetArticleComment 32 @handler MiniGetArticleComment
33 get /article_comment/:id (MiniGetArticleCommentRequest) returns (MiniGetArticleCommentResponse) 33 get /article_comment/:id (MiniGetArticleCommentRequest) returns (MiniGetArticleCommentResponse)
  34 +
  35 + @doc "小程序展示删除文章评论"
  36 + @handler MiniDeleteArticleComment
  37 + delete /article_comment/:id (MiniDeleteArticleCommentRequest) returns (MiniDeleteArticleCommentResponse)
34 } 38 }
35 39
36 // 40 //
@@ -119,17 +123,29 @@ type ( @@ -119,17 +123,29 @@ type (
119 CountAdminLove int `json:"countAdminLove"` // 运营点赞数量 123 CountAdminLove int `json:"countAdminLove"` // 运营点赞数量
120 AtWho []CommentAuthor `json:"atWho"` // 填写评论时@的人 124 AtWho []CommentAuthor `json:"atWho"` // 填写评论时@的人
121 CreatedAt int64 `json:"createdAt"` // 125 CreatedAt int64 `json:"createdAt"` //
122 - MeLoveFlag int `json:"meLoveFlag"` //当前人员对评论的点赞标识 126 + MeLoveFlag int `json:"meLoveFlag"` //当前人员对评论的点赞标识 (0 没有点赞 1有点赞)
123 } 127 }
124 ) 128 )
125 129
126 // 小程序获取单个文章的评论 130 // 小程序获取单个文章的评论
127 type ( 131 type (
128 MiniGetArticleCommentRequest { 132 MiniGetArticleCommentRequest {
129 - CommentId int64 `json:"commentId"` 133 + CommentId int64 `path:"commentId"`
130 CompanyId int64 `json:",optional"` 134 CompanyId int64 `json:",optional"`
131 } 135 }
132 MiniGetArticleCommentResponse { 136 MiniGetArticleCommentResponse {
133 ArticleCommentAndReply 137 ArticleCommentAndReply
134 } 138 }
  139 +)
  140 +
  141 +// 小程序删除单个文章的评论
  142 +type (
  143 + MiniDeleteArticleCommentRequest {
  144 + CommentId int64 `json:"commentId"`
  145 + UserId int64 `json:",optional"`
  146 + CompanyId int64 `json:",optional"`
  147 + }
  148 + MiniDeleteArticleCommentResponse {
  149 + Id int64 `json:"id"`
  150 + }
135 ) 151 )
  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/contextdata"
  11 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/result"
  12 +)
  13 +
  14 +func MiniDeleteArticleCommentHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
  15 + return func(w http.ResponseWriter, r *http.Request) {
  16 + var req types.MiniDeleteArticleCommentRequest
  17 + if err := httpx.Parse(r, &req); err != nil {
  18 + httpx.ErrorCtx(r.Context(), w, err)
  19 + return
  20 + }
  21 +
  22 + l := comment.NewMiniDeleteArticleCommentLogic(r.Context(), svcCtx)
  23 + token := contextdata.GetUserTokenFromCtx(r.Context())
  24 + req.CompanyId = token.CompanyId
  25 + req.UserId = token.UserId
  26 + resp, err := l.MiniDeleteArticleComment(&req)
  27 + result.HttpResult(r, w, resp, err)
  28 + }
  29 +}
@@ -40,6 +40,11 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { @@ -40,6 +40,11 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
40 Path: "/article_comment/:id", 40 Path: "/article_comment/:id",
41 Handler: comment.MiniGetArticleCommentHandler(serverCtx), 41 Handler: comment.MiniGetArticleCommentHandler(serverCtx),
42 }, 42 },
  43 + {
  44 + Method: http.MethodDelete,
  45 + Path: "/article_comment/:id",
  46 + Handler: comment.MiniDeleteArticleCommentHandler(serverCtx),
  47 + },
43 }, 48 },
44 rest.WithJwt(serverCtx.Config.MiniAuth.AccessSecret), 49 rest.WithJwt(serverCtx.Config.MiniAuth.AccessSecret),
45 rest.WithPrefix("/v1/mini"), 50 rest.WithPrefix("/v1/mini"),
  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 +
  9 + "github.com/zeromicro/go-zero/core/logx"
  10 +)
  11 +
  12 +type MiniDeleteArticleCommentLogic struct {
  13 + logx.Logger
  14 + ctx context.Context
  15 + svcCtx *svc.ServiceContext
  16 +}
  17 +
  18 +func NewMiniDeleteArticleCommentLogic(ctx context.Context, svcCtx *svc.ServiceContext) *MiniDeleteArticleCommentLogic {
  19 + return &MiniDeleteArticleCommentLogic{
  20 + Logger: logx.WithContext(ctx),
  21 + ctx: ctx,
  22 + svcCtx: svcCtx,
  23 + }
  24 +}
  25 +
  26 +func (l *MiniDeleteArticleCommentLogic) MiniDeleteArticleComment(req *types.MiniDeleteArticleCommentRequest) (resp *types.MiniDeleteArticleCommentResponse, err error) {
  27 + // todo: add your logic here and delete this line
  28 +
  29 + return
  30 +}
@@ -113,6 +113,7 @@ func (l *MiniGetArticleCommentLogic) MiniGetArticleComment(req *types.MiniGetArt @@ -113,6 +113,7 @@ func (l *MiniGetArticleCommentLogic) MiniGetArticleComment(req *types.MiniGetArt
113 CountAdminLove: val.CountAdminLove, 113 CountAdminLove: val.CountAdminLove,
114 AtWho: []types.CommentAuthor{}, 114 AtWho: []types.CommentAuthor{},
115 CreatedAt: val.CreatedAt, 115 CreatedAt: val.CreatedAt,
  116 + MeLoveFlag: 0,
116 } 117 }
117 for _, val2 := range val.AtWho { 118 for _, val2 := range val.AtWho {
118 reply.AtWho = append(reply.AtWho, types.CommentAuthor{ 119 reply.AtWho = append(reply.AtWho, types.CommentAuthor{
@@ -78,11 +78,11 @@ type ArticleCommentItem struct { @@ -78,11 +78,11 @@ type ArticleCommentItem struct {
78 CountAdminLove int `json:"countAdminLove"` // 运营点赞数量 78 CountAdminLove int `json:"countAdminLove"` // 运营点赞数量
79 AtWho []CommentAuthor `json:"atWho"` // 填写评论时@的人 79 AtWho []CommentAuthor `json:"atWho"` // 填写评论时@的人
80 CreatedAt int64 `json:"createdAt"` // 80 CreatedAt int64 `json:"createdAt"` //
81 - MeLoveFlag int `json:"meLoveFlag"` //当前人员对评论的点赞标识 81 + MeLoveFlag int `json:"meLoveFlag"` //当前人员对评论的点赞标识 (0 没有点赞 1有点赞)
82 } 82 }
83 83
84 type MiniGetArticleCommentRequest struct { 84 type MiniGetArticleCommentRequest struct {
85 - CommentId int64 `json:"commentId"` 85 + CommentId int64 `path:"commentId"`
86 CompanyId int64 `json:",optional"` 86 CompanyId int64 `json:",optional"`
87 } 87 }
88 88
@@ -90,6 +90,16 @@ type MiniGetArticleCommentResponse struct { @@ -90,6 +90,16 @@ type MiniGetArticleCommentResponse struct {
90 ArticleCommentAndReply 90 ArticleCommentAndReply
91 } 91 }
92 92
  93 +type MiniDeleteArticleCommentRequest struct {
  94 + CommentId int64 `json:"commentId"`
  95 + UserId int64 `json:",optional"`
  96 + CompanyId int64 `json:",optional"`
  97 +}
  98 +
  99 +type MiniDeleteArticleCommentResponse struct {
  100 + Id int64 `json:"id"`
  101 +}
  102 +
93 type MessageSystemRequest struct { 103 type MessageSystemRequest struct {
94 Page int `json:"page"` 104 Page int `json:"page"`
95 Size int `json:"size"` 105 Size int `json:"size"`
@@ -567,7 +577,7 @@ type MiniArticleGetResponse struct { @@ -567,7 +577,7 @@ type MiniArticleGetResponse struct {
567 CountRead int `json:"countRead"` // 浏览数量 577 CountRead int `json:"countRead"` // 浏览数量
568 Show int `json:"show"` // 评论的展示状态(0显示、1不显示) 578 Show int `json:"show"` // 评论的展示状态(0显示、1不显示)
569 Edit int `json:"edit"` // 文章是否存在变更记录 (0 不存在 1存在) 579 Edit int `json:"edit"` // 文章是否存在变更记录 (0 不存在 1存在)
570 - MeLoveFlag int `json:"meLoveFlag"` //当前人员对文章的点赞标识 580 + MeLoveFlag int `json:"meLoveFlag"` // 当前人员对文章的点赞标识 (0 没有点赞 1有点赞)
571 } 581 }
572 582
573 type ArticleSection struct { 583 type ArticleSection struct {