正在显示
8 个修改的文件
包含
195 行增加
和
11 行删除
@@ -37,14 +37,17 @@ service Core { | @@ -37,14 +37,17 @@ service Core { | ||
37 | } | 37 | } |
38 | 38 | ||
39 | // 管理后台接口 | 39 | // 管理后台接口 |
40 | -// @server( | ||
41 | -// prefix: v1/system | ||
42 | -// group: article | ||
43 | -// jwt: MiniAuth | ||
44 | -// ) | ||
45 | -// service Core { | ||
46 | -// @doc "管理后台获取文章内容详情" | ||
47 | -// @handler SystemGetArticle | ||
48 | -// get /article/:id (SystemArticleGetRequest) returns (SystemArticleGetResponse) | ||
49 | -// } | 40 | +@server( |
41 | + prefix: v1/system | ||
42 | + group: article | ||
43 | + jwt: MiniAuth | ||
44 | +) | ||
45 | +service Core { | ||
46 | + @doc "管理后台获取文章内容详情" | ||
47 | + @handler SystemGetArticle | ||
48 | + get /article/:id (SystemArticleGetRequest) returns (SystemArticleGetResponse) | ||
50 | 49 | ||
50 | + @doc "管理后台获取文章列表" | ||
51 | + @handler SystemSearchArticle | ||
52 | + post /article/search (SystemArticleSearchRequest) returns (SystemArticleSearchResponse) | ||
53 | +} |
@@ -157,4 +157,28 @@ type ( | @@ -157,4 +157,28 @@ type ( | ||
157 | } | 157 | } |
158 | ) | 158 | ) |
159 | 159 | ||
160 | -//管理后台获取文章列表 | ||
160 | +//管理后台获取文章列表 | ||
161 | +type ( | ||
162 | + SystemArticleSearchRequest { | ||
163 | + CompanyId int64 `json:",optional"` | ||
164 | + Page int `json:"page"` | ||
165 | + Size int `json:"size"` | ||
166 | + } | ||
167 | + | ||
168 | + SystemArticleSearchResponse { | ||
169 | + Total int `json:"total"` | ||
170 | + List []SystemArticleSearch `json:"list"` | ||
171 | + } | ||
172 | + SystemArticleSearch { | ||
173 | + Id int64 `json:"id"` //id | ||
174 | + Title string `json:"title"` //标题 | ||
175 | + Author string `json:"author"` //发布人 | ||
176 | + Images []string `json:"images"` //图片 | ||
177 | + CreatedAt int64 `json:"createdAt"` //文章的创建日期 | ||
178 | + CountLove int `json:"countLove"` //点赞数量 | ||
179 | + CountComment int `json:"CountComment"` //评论数量 | ||
180 | + Show int `json:"show"` //是否隐藏 [0显示、1不显示] | ||
181 | + Tags []string `json:"tags"` //标签 | ||
182 | + TargetUser int `json:"targetUser"` //分发方式 [0分发给所有人、1分发给指定的人] | ||
183 | + } | ||
184 | +) |
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 | +) | ||
11 | + | ||
12 | +func SystemGetArticleHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | ||
13 | + return func(w http.ResponseWriter, r *http.Request) { | ||
14 | + var req types.SystemArticleGetRequest | ||
15 | + if err := httpx.Parse(r, &req); err != nil { | ||
16 | + httpx.ErrorCtx(r.Context(), w, err) | ||
17 | + return | ||
18 | + } | ||
19 | + | ||
20 | + l := article.NewSystemGetArticleLogic(r.Context(), svcCtx) | ||
21 | + 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 | + } | ||
27 | + } | ||
28 | +} |
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 | +) | ||
11 | + | ||
12 | +func SystemSearchArticleHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | ||
13 | + return func(w http.ResponseWriter, r *http.Request) { | ||
14 | + var req types.SystemArticleSearchRequest | ||
15 | + if err := httpx.Parse(r, &req); err != nil { | ||
16 | + httpx.ErrorCtx(r.Context(), w, err) | ||
17 | + return | ||
18 | + } | ||
19 | + | ||
20 | + l := article.NewSystemSearchArticleLogic(r.Context(), svcCtx) | ||
21 | + 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 | + } | ||
28 | +} |
@@ -206,4 +206,21 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { | @@ -206,4 +206,21 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { | ||
206 | rest.WithJwt(serverCtx.Config.MiniAuth.AccessSecret), | 206 | rest.WithJwt(serverCtx.Config.MiniAuth.AccessSecret), |
207 | rest.WithPrefix("/v1/mini"), | 207 | rest.WithPrefix("/v1/mini"), |
208 | ) | 208 | ) |
209 | + | ||
210 | + server.AddRoutes( | ||
211 | + []rest.Route{ | ||
212 | + { | ||
213 | + Method: http.MethodGet, | ||
214 | + Path: "/article/:id", | ||
215 | + Handler: article.SystemGetArticleHandler(serverCtx), | ||
216 | + }, | ||
217 | + { | ||
218 | + Method: http.MethodPost, | ||
219 | + Path: "/article/search", | ||
220 | + Handler: article.SystemSearchArticleHandler(serverCtx), | ||
221 | + }, | ||
222 | + }, | ||
223 | + rest.WithJwt(serverCtx.Config.MiniAuth.AccessSecret), | ||
224 | + rest.WithPrefix("/v1/system"), | ||
225 | + ) | ||
209 | } | 226 | } |
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 SystemGetArticleLogic struct { | ||
13 | + logx.Logger | ||
14 | + ctx context.Context | ||
15 | + svcCtx *svc.ServiceContext | ||
16 | +} | ||
17 | + | ||
18 | +func NewSystemGetArticleLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SystemGetArticleLogic { | ||
19 | + return &SystemGetArticleLogic{ | ||
20 | + Logger: logx.WithContext(ctx), | ||
21 | + ctx: ctx, | ||
22 | + svcCtx: svcCtx, | ||
23 | + } | ||
24 | +} | ||
25 | + | ||
26 | +func (l *SystemGetArticleLogic) SystemGetArticle(req *types.SystemArticleGetRequest) (resp *types.SystemArticleGetResponse, err error) { | ||
27 | + // todo: add your logic here and delete this line | ||
28 | + | ||
29 | + return | ||
30 | +} |
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 SystemSearchArticleLogic struct { | ||
13 | + logx.Logger | ||
14 | + ctx context.Context | ||
15 | + svcCtx *svc.ServiceContext | ||
16 | +} | ||
17 | + | ||
18 | +func NewSystemSearchArticleLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SystemSearchArticleLogic { | ||
19 | + return &SystemSearchArticleLogic{ | ||
20 | + Logger: logx.WithContext(ctx), | ||
21 | + ctx: ctx, | ||
22 | + svcCtx: svcCtx, | ||
23 | + } | ||
24 | +} | ||
25 | + | ||
26 | +func (l *SystemSearchArticleLogic) SystemSearchArticle(req *types.SystemArticleSearchRequest) (resp *types.SystemArticleSearchResponse, err error) { | ||
27 | + // todo: add your logic here and delete this line | ||
28 | + | ||
29 | + return | ||
30 | +} |
@@ -412,3 +412,27 @@ type SystemArticleGetResponse struct { | @@ -412,3 +412,27 @@ type SystemArticleGetResponse struct { | ||
412 | CountRead int `json:"countRead"` // 浏览数量 | 412 | CountRead int `json:"countRead"` // 浏览数量 |
413 | Show int `json:"show"` // 评论的展示状态(0显示、1不显示) | 413 | Show int `json:"show"` // 评论的展示状态(0显示、1不显示) |
414 | } | 414 | } |
415 | + | ||
416 | +type SystemArticleSearchRequest struct { | ||
417 | + CompanyId int64 `json:",optional"` | ||
418 | + Page int `json:"page"` | ||
419 | + Size int `json:"size"` | ||
420 | +} | ||
421 | + | ||
422 | +type SystemArticleSearchResponse struct { | ||
423 | + Total int `json:"total"` | ||
424 | + List []SystemArticleSearch `json:"list"` | ||
425 | +} | ||
426 | + | ||
427 | +type SystemArticleSearch struct { | ||
428 | + Id int64 `json:"id"` //id | ||
429 | + Title string `json:"title"` //标题 | ||
430 | + Author string `json:"author"` //发布人 | ||
431 | + Images []string `json:"images"` //图片 | ||
432 | + CreatedAt int64 `json:"createdAt"` //文章的创建日期 | ||
433 | + CountLove int `json:"countLove"` //点赞数量 | ||
434 | + CountComment int `json:"CountComment"` //评论数量 | ||
435 | + Show int `json:"show"` //是否隐藏 [0显示、1不显示] | ||
436 | + Tags []string `json:"tags"` //标签 | ||
437 | + TargetUser int `json:"targetUser"` //分发方式 [0分发给所有人、1分发给指定的人] | ||
438 | +} |
-
请 注册 或 登录 后发表评论