正在显示
6 个修改的文件
包含
136 行增加
和
0 行删除
@@ -34,6 +34,10 @@ service Core { | @@ -34,6 +34,10 @@ service Core { | ||
34 | @handler MiniArticleMarkUserRead | 34 | @handler MiniArticleMarkUserRead |
35 | post /article/mark/user_read (MiniArticleMarkUserReadRequest) returns (MiniArticleMarkUserReadResponse) | 35 | post /article/mark/user_read (MiniArticleMarkUserReadRequest) returns (MiniArticleMarkUserReadResponse) |
36 | 36 | ||
37 | + @doc "小程序获取文章浏览记录" | ||
38 | + @handler MiniArticleMarkList | ||
39 | + post /article/mark/list (MiniArticleMarkListRequest) returns (MiniArticleMarkListResponse) | ||
40 | + | ||
37 | @doc "小程序获取我发布的文章" | 41 | @doc "小程序获取我发布的文章" |
38 | @handler MiniArticleSearchMe | 42 | @handler MiniArticleSearchMe |
39 | post /article/search/me (MiniArticleSearchMeRequest) returns (MiniArticleSearchMeResponse) | 43 | post /article/search/me (MiniArticleSearchMeRequest) returns (MiniArticleSearchMeResponse) |
@@ -160,6 +160,29 @@ type ( | @@ -160,6 +160,29 @@ type ( | ||
160 | } | 160 | } |
161 | ) | 161 | ) |
162 | 162 | ||
163 | +type ( | ||
164 | + MiniArticleMarkListRequest { | ||
165 | + Page int `json:"page"` | ||
166 | + Size int `json:"size"` | ||
167 | + } | ||
168 | + | ||
169 | + MiniArticleMarkListResponse { | ||
170 | + Total int64 `json:"total"` | ||
171 | + List []MiniArticleMarkItem `json:"list"` | ||
172 | + } | ||
173 | + | ||
174 | + MiniArticleMarkItem { | ||
175 | + Id int64 `json:"id"` | ||
176 | + CompanyId int64 `json:"companyId"` | ||
177 | + UserId int64 `json:"userId"` | ||
178 | + ArticleId int64 `json:"articleId"` | ||
179 | + Title string `json:"title"` | ||
180 | + Author SimpleUser `json:"author"` // 发布人 | ||
181 | + UpdatedAt int64 `json:"updatedAt"` | ||
182 | + } | ||
183 | + | ||
184 | +) | ||
185 | + | ||
163 | //管理后台获取文章详情 | 186 | //管理后台获取文章详情 |
164 | type ( | 187 | type ( |
165 | SystemArticleGetRequest { | 188 | SystemArticleGetRequest { |
1 | +package article | ||
2 | + | ||
3 | +import ( | ||
4 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/result" | ||
5 | + "net/http" | ||
6 | + | ||
7 | + "github.com/zeromicro/go-zero/rest/httpx" | ||
8 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/article" | ||
9 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | ||
10 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" | ||
11 | +) | ||
12 | + | ||
13 | +func MiniArticleMarkListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | ||
14 | + return func(w http.ResponseWriter, r *http.Request) { | ||
15 | + var req types.MiniArticleMarkListRequest | ||
16 | + if err := httpx.Parse(r, &req); err != nil { | ||
17 | + httpx.ErrorCtx(r.Context(), w, err) | ||
18 | + return | ||
19 | + } | ||
20 | + | ||
21 | + l := article.NewMiniArticleMarkListLogic(r.Context(), svcCtx) | ||
22 | + resp, err := l.MiniArticleMarkList(&req) | ||
23 | + result.HttpResult(r, w, resp, err) | ||
24 | + } | ||
25 | +} |
@@ -215,6 +215,11 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { | @@ -215,6 +215,11 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { | ||
215 | }, | 215 | }, |
216 | { | 216 | { |
217 | Method: http.MethodPost, | 217 | Method: http.MethodPost, |
218 | + Path: "/article/mark/list", | ||
219 | + Handler: article.MiniArticleMarkListHandler(serverCtx), | ||
220 | + }, | ||
221 | + { | ||
222 | + Method: http.MethodPost, | ||
218 | Path: "/article/search/me", | 223 | Path: "/article/search/me", |
219 | Handler: article.MiniArticleSearchMeHandler(serverCtx), | 224 | Handler: article.MiniArticleSearchMeHandler(serverCtx), |
220 | }, | 225 | }, |
1 | +package article | ||
2 | + | ||
3 | +import ( | ||
4 | + "context" | ||
5 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain" | ||
6 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/contextdata" | ||
7 | + | ||
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 | + | ||
11 | + "github.com/zeromicro/go-zero/core/logx" | ||
12 | +) | ||
13 | + | ||
14 | +type MiniArticleMarkListLogic struct { | ||
15 | + logx.Logger | ||
16 | + ctx context.Context | ||
17 | + svcCtx *svc.ServiceContext | ||
18 | +} | ||
19 | + | ||
20 | +func NewMiniArticleMarkListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *MiniArticleMarkListLogic { | ||
21 | + return &MiniArticleMarkListLogic{ | ||
22 | + Logger: logx.WithContext(ctx), | ||
23 | + ctx: ctx, | ||
24 | + svcCtx: svcCtx, | ||
25 | + } | ||
26 | +} | ||
27 | + | ||
28 | +func (l *MiniArticleMarkListLogic) MiniArticleMarkList(req *types.MiniArticleMarkListRequest) (resp *types.MiniArticleMarkListResponse, err error) { | ||
29 | + var userToken = contextdata.GetUserTokenFromCtx(l.ctx) | ||
30 | + | ||
31 | + total, list, err := l.svcCtx.UserReadArticleRepository.Find(l.ctx, l.svcCtx.DefaultDBConn(), domain.NewQueryOptions(). | ||
32 | + WithOffsetLimit(req.Page, req.Size). | ||
33 | + WithKV("userId", userToken.UserId)) | ||
34 | + if err != nil { | ||
35 | + return nil, err | ||
36 | + } | ||
37 | + resp = &types.MiniArticleMarkListResponse{} | ||
38 | + resp.Total = total | ||
39 | + resp.List = make([]types.MiniArticleMarkItem, 0) | ||
40 | + for _, item := range list { | ||
41 | + to := types.MiniArticleMarkItem{ | ||
42 | + Id: item.Id, | ||
43 | + CompanyId: item.CompanyId, | ||
44 | + ArticleId: item.ArticleId, | ||
45 | + Title: item.Title, | ||
46 | + Author: types.SimpleUser{ | ||
47 | + Id: item.Author.Id, | ||
48 | + CompanyId: item.Author.CompanyId, | ||
49 | + CompanyName: item.Author.Company, | ||
50 | + Name: item.Author.Name, | ||
51 | + Avatar: item.Author.Avatar, | ||
52 | + Position: item.Author.Position, | ||
53 | + }, | ||
54 | + UpdatedAt: item.UpdatedAt, | ||
55 | + } | ||
56 | + resp.List = append(resp.List, to) | ||
57 | + } | ||
58 | + return resp, nil | ||
59 | +} |
@@ -460,6 +460,26 @@ type MiniArticleMarkUserReadResponse struct { | @@ -460,6 +460,26 @@ type MiniArticleMarkUserReadResponse struct { | ||
460 | Id int64 `json:"id"` | 460 | Id int64 `json:"id"` |
461 | } | 461 | } |
462 | 462 | ||
463 | +type MiniArticleMarkListRequest struct { | ||
464 | + Page int `json:"page"` | ||
465 | + Size int `json:"size"` | ||
466 | +} | ||
467 | + | ||
468 | +type MiniArticleMarkListResponse struct { | ||
469 | + Total int64 `json:"total"` | ||
470 | + List []MiniArticleMarkItem `json:"list"` | ||
471 | +} | ||
472 | + | ||
473 | +type MiniArticleMarkItem struct { | ||
474 | + Id int64 `json:"id"` | ||
475 | + CompanyId int64 `json:"companyId"` | ||
476 | + UserId int64 `json:"userId"` | ||
477 | + ArticleId int64 `json:"articleId"` | ||
478 | + Title string `json:"title"` | ||
479 | + Author SimpleUser `json:"author"` // 发布人 | ||
480 | + UpdatedAt int64 `json:"updatedAt"` | ||
481 | +} | ||
482 | + | ||
463 | type SystemArticleGetRequest struct { | 483 | type SystemArticleGetRequest struct { |
464 | Id int64 `path:"id"` //id | 484 | Id int64 `path:"id"` //id |
465 | CompanyId int64 `path:",optional"` | 485 | CompanyId int64 `path:",optional"` |
-
请 注册 或 登录 后发表评论