正在显示
8 个修改的文件
包含
121 行增加
和
11 行删除
@@ -30,9 +30,13 @@ service Core { | @@ -30,9 +30,13 @@ service Core { | ||
30 | @handler MiniSetUserLike | 30 | @handler MiniSetUserLike |
31 | post /article/user_like/set (MiniSetUserLikeRequset) returns (MiniSetUserLikeResponse) | 31 | post /article/user_like/set (MiniSetUserLikeRequset) returns (MiniSetUserLikeResponse) |
32 | 32 | ||
33 | + @doc "小程序获取文章的编辑记录" | ||
34 | + @handler MiniArticleBackupSearch | ||
35 | + post /article_backup/search (MiniArticleSearchMeRequest) returns (MiniArticleSearchMeResponse) | ||
36 | + | ||
33 | @doc "小程序获取我发布的文章" | 37 | @doc "小程序获取我发布的文章" |
34 | @handler MiniArticleSearchMe | 38 | @handler MiniArticleSearchMe |
35 | - post /article/search/me (MiniArticleSearchMeRequest) returns (MiniArticleSearchMeResponse) | 39 | + post /article/search/me (MiniArticleBackupSearchRequest) returns (MiniArticleBackupSearchResponse) |
36 | 40 | ||
37 | } | 41 | } |
38 | 42 |
@@ -125,6 +125,28 @@ type ( | @@ -125,6 +125,28 @@ type ( | ||
125 | } | 125 | } |
126 | ) | 126 | ) |
127 | 127 | ||
128 | +// 小程序端获取文章的编辑记录 | ||
129 | + | ||
130 | +type ( | ||
131 | + MiniArticleBackupSearchRequest { | ||
132 | + Page int `json:"page"` | ||
133 | + Size int `json:"size"` | ||
134 | + ArticleId int `json:"articleId"` | ||
135 | + CompanyId int64 `json:",optional"` // 服务端自动获取 | ||
136 | + } | ||
137 | + MiniArticleBackupSearchResponse { | ||
138 | + Total int `json:"total"` | ||
139 | + List []MiniArticleBackupItem `json:"list"` | ||
140 | + } | ||
141 | + MiniArticleBackupItem { | ||
142 | + Id int `json:"id"` | ||
143 | + Content string `json:"content"` | ||
144 | + Images []string `json:"images"` | ||
145 | + CreatedAt int `json:"createdAt"` | ||
146 | + Location Location `json:"location"` | ||
147 | + } | ||
148 | +) | ||
149 | + | ||
128 | //管理后台获取文章详情 | 150 | //管理后台获取文章详情 |
129 | type ( | 151 | type ( |
130 | SystemArticleGetRequest { | 152 | SystemArticleGetRequest { |
1 | +package article | ||
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/article" | ||
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 MiniArticleBackupSearchHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | ||
15 | + return func(w http.ResponseWriter, r *http.Request) { | ||
16 | + var req types.MiniArticleSearchMeRequest | ||
17 | + if err := httpx.Parse(r, &req); err != nil { | ||
18 | + httpx.ErrorCtx(r.Context(), w, err) | ||
19 | + return | ||
20 | + } | ||
21 | + | ||
22 | + l := article.NewMiniArticleBackupSearchLogic(r.Context(), svcCtx) | ||
23 | + token := contextdata.GetUserTokenFromCtx(r.Context()) | ||
24 | + req.CompanyId = token.CompanyId | ||
25 | + resp, err := l.MiniArticleBackupSearch(&req) | ||
26 | + result.HttpResult(r, w, resp, err) | ||
27 | + } | ||
28 | +} |
@@ -7,6 +7,8 @@ import ( | @@ -7,6 +7,8 @@ import ( | ||
7 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/article" | 7 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/article" |
8 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | 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" | 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" | ||
10 | ) | 12 | ) |
11 | 13 | ||
12 | func SystemGetArticleHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | 14 | func SystemGetArticleHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { |
@@ -18,11 +20,9 @@ func SystemGetArticleHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | @@ -18,11 +20,9 @@ func SystemGetArticleHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | ||
18 | } | 20 | } |
19 | 21 | ||
20 | l := article.NewSystemGetArticleLogic(r.Context(), svcCtx) | 22 | l := article.NewSystemGetArticleLogic(r.Context(), svcCtx) |
23 | + token := contextdata.GetUserTokenFromCtx(r.Context()) | ||
24 | + req.CompanyId = token.CompanyId | ||
21 | resp, err := l.SystemGetArticle(&req) | 25 | resp, err := l.SystemGetArticle(&req) |
22 | - if err != nil { | ||
23 | - httpx.ErrorCtx(r.Context(), w, err) | ||
24 | - } else { | ||
25 | - httpx.OkJsonCtx(r.Context(), w, resp) | ||
26 | - } | 26 | + result.HttpResult(r, w, resp, err) |
27 | } | 27 | } |
28 | } | 28 | } |
@@ -7,6 +7,8 @@ import ( | @@ -7,6 +7,8 @@ import ( | ||
7 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/article" | 7 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/article" |
8 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | 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" | 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" | ||
10 | ) | 12 | ) |
11 | 13 | ||
12 | func SystemSearchArticleHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | 14 | func SystemSearchArticleHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { |
@@ -18,11 +20,10 @@ func SystemSearchArticleHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | @@ -18,11 +20,10 @@ func SystemSearchArticleHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | ||
18 | } | 20 | } |
19 | 21 | ||
20 | l := article.NewSystemSearchArticleLogic(r.Context(), svcCtx) | 22 | l := article.NewSystemSearchArticleLogic(r.Context(), svcCtx) |
23 | + | ||
24 | + token := contextdata.GetUserTokenFromCtx(r.Context()) | ||
25 | + req.CompanyId = token.CompanyId | ||
21 | resp, err := l.SystemSearchArticle(&req) | 26 | resp, err := l.SystemSearchArticle(&req) |
22 | - if err != nil { | ||
23 | - httpx.ErrorCtx(r.Context(), w, err) | ||
24 | - } else { | ||
25 | - httpx.OkJsonCtx(r.Context(), w, resp) | ||
26 | - } | 27 | + result.HttpResult(r, w, resp, err) |
27 | } | 28 | } |
28 | } | 29 | } |
@@ -199,6 +199,11 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { | @@ -199,6 +199,11 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { | ||
199 | }, | 199 | }, |
200 | { | 200 | { |
201 | Method: http.MethodPost, | 201 | Method: http.MethodPost, |
202 | + Path: "/article_backup/search", | ||
203 | + Handler: article.MiniArticleBackupSearchHandler(serverCtx), | ||
204 | + }, | ||
205 | + { | ||
206 | + Method: http.MethodPost, | ||
202 | Path: "/article/search/me", | 207 | Path: "/article/search/me", |
203 | Handler: article.MiniArticleSearchMeHandler(serverCtx), | 208 | Handler: article.MiniArticleSearchMeHandler(serverCtx), |
204 | }, | 209 | }, |
1 | +package article | ||
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 MiniArticleBackupSearchLogic struct { | ||
13 | + logx.Logger | ||
14 | + ctx context.Context | ||
15 | + svcCtx *svc.ServiceContext | ||
16 | +} | ||
17 | + | ||
18 | +func NewMiniArticleBackupSearchLogic(ctx context.Context, svcCtx *svc.ServiceContext) *MiniArticleBackupSearchLogic { | ||
19 | + return &MiniArticleBackupSearchLogic{ | ||
20 | + Logger: logx.WithContext(ctx), | ||
21 | + ctx: ctx, | ||
22 | + svcCtx: svcCtx, | ||
23 | + } | ||
24 | +} | ||
25 | + | ||
26 | +func (l *MiniArticleBackupSearchLogic) MiniArticleBackupSearch(req *types.MiniArticleSearchMeRequest) (resp *types.MiniArticleSearchMeResponse, err error) { | ||
27 | + // todo: add your logic here and delete this line | ||
28 | + | ||
29 | + return | ||
30 | +} |
@@ -384,6 +384,26 @@ type MiniSetUserLikeResponse struct { | @@ -384,6 +384,26 @@ type MiniSetUserLikeResponse struct { | ||
384 | Count int `json:"count"` //现有的点赞数量 | 384 | Count int `json:"count"` //现有的点赞数量 |
385 | } | 385 | } |
386 | 386 | ||
387 | +type MiniArticleBackupSearchRequest struct { | ||
388 | + Page int `json:"page"` | ||
389 | + Size int `json:"size"` | ||
390 | + ArticleId int `json:"articleId"` | ||
391 | + CompanyId int64 `json:",optional"` // 服务端自动获取 | ||
392 | +} | ||
393 | + | ||
394 | +type MiniArticleBackupSearchResponse struct { | ||
395 | + Total int `json:"total"` | ||
396 | + List []MiniArticleBackupItem `json:"list"` | ||
397 | +} | ||
398 | + | ||
399 | +type MiniArticleBackupItem struct { | ||
400 | + Id int `json:"id"` | ||
401 | + Content string `json:"content"` | ||
402 | + Images []string `json:"images"` | ||
403 | + CreatedAt int `json:"createdAt"` | ||
404 | + Location Location `json:"location"` | ||
405 | +} | ||
406 | + | ||
387 | type SystemArticleGetRequest struct { | 407 | type SystemArticleGetRequest struct { |
388 | Id int64 `path:"id"` //id | 408 | Id int64 `path:"id"` //id |
389 | CompanyId int64 `path:",optional"` | 409 | CompanyId int64 `path:",optional"` |
-
请 注册 或 登录 后发表评论