正在显示
17 个修改的文件
包含
365 行增加
和
33 行删除
此 diff 太大无法显示。
@@ -78,7 +78,7 @@ service Core { | @@ -78,7 +78,7 @@ service Core { | ||
78 | @server( | 78 | @server( |
79 | prefix: v1/system | 79 | prefix: v1/system |
80 | group: article | 80 | group: article |
81 | - jwt: MiniAuth | 81 | + jwt: SystemAuth |
82 | ) | 82 | ) |
83 | service Core { | 83 | service Core { |
84 | @doc "管理后台获取文章内容详情" | 84 | @doc "管理后台获取文章内容详情" |
@@ -88,4 +88,8 @@ service Core { | @@ -88,4 +88,8 @@ service Core { | ||
88 | @doc "管理后台获取文章列表" | 88 | @doc "管理后台获取文章列表" |
89 | @handler SystemSearchArticle | 89 | @handler SystemSearchArticle |
90 | post /article/search (SystemArticleSearchRequest) returns (SystemArticleSearchResponse) | 90 | post /article/search (SystemArticleSearchRequest) returns (SystemArticleSearchResponse) |
91 | + | ||
92 | + @doc "管理后台获取我发布的文章" | ||
93 | + @handler SystemArticleSearchMe | ||
94 | + post /article/search/me (SystemArticleSearchMeRequest) returns (SystemArticleSearchMeResponse) | ||
91 | } | 95 | } |
@@ -88,6 +88,18 @@ type ( | @@ -88,6 +88,18 @@ type ( | ||
88 | CountComment int `json:"CountComment"` //评论数量 | 88 | CountComment int `json:"CountComment"` //评论数量 |
89 | Show int `json:"show"` //是否隐藏 [0显示、1不显示] | 89 | Show int `json:"show"` //是否隐藏 [0显示、1不显示] |
90 | } | 90 | } |
91 | + | ||
92 | + SystemArticleSearchMeRequest { | ||
93 | + Page int `json:"page"` | ||
94 | + Size int `json:"size"` | ||
95 | + AuthorId int64 `json:"authorId"` // 用户 | ||
96 | + BeginTime int64 `json:"beginTime,optional"` // 开始时间 | ||
97 | + EndTime int64 `json:"endTime,optional"` // 结束时间 | ||
98 | + } | ||
99 | + SystemArticleSearchMeResponse { | ||
100 | + Total int `json:"total"` | ||
101 | + List []ArticleSearchMe `json:"list"` | ||
102 | + } | ||
91 | ) | 103 | ) |
92 | 104 | ||
93 | //小程序端获取文章有哪些人进行了点赞 | 105 | //小程序端获取文章有哪些人进行了点赞 |
@@ -45,6 +45,19 @@ service Core { | @@ -45,6 +45,19 @@ service Core { | ||
45 | post /article_comment/at_who/list (MiniArticleCommentAtWhoRequest) returns (MiniArticleCommentAtWhoResponse) | 45 | post /article_comment/at_who/list (MiniArticleCommentAtWhoRequest) returns (MiniArticleCommentAtWhoResponse) |
46 | } | 46 | } |
47 | 47 | ||
48 | +// 后台接口 | ||
49 | +@server( | ||
50 | + prefix: v1/system | ||
51 | + group: comment | ||
52 | + middleware: LoginStatusCheck | ||
53 | + jwt: SystemAuth | ||
54 | +) | ||
55 | +service Core { | ||
56 | + @doc "小程序获取回复@人可选列表" | ||
57 | + @handler SystemArticleCommentSearchMe | ||
58 | + post /article_comment/search/me (SystemArticleCommentSearchMeRequest) returns (SystemArticleCommentSearchMeResponse) | ||
59 | +} | ||
60 | + | ||
48 | // | 61 | // |
49 | // 小程序获取回复@人可选列表 | 62 | // 小程序获取回复@人可选列表 |
50 | type ( | 63 | type ( |
@@ -138,6 +151,7 @@ type ( | @@ -138,6 +151,7 @@ type ( | ||
138 | AtWho []CommentAtWho `json:"atWho"` // 填写评论时@的人 | 151 | AtWho []CommentAtWho `json:"atWho"` // 填写评论时@的人 |
139 | CreatedAt int64 `json:"createdAt"` // | 152 | CreatedAt int64 `json:"createdAt"` // |
140 | MeLoveFlag int `json:"meLoveFlag"` //当前人员对评论的点赞标识 (0 没有点赞 1有点赞) | 153 | MeLoveFlag int `json:"meLoveFlag"` //当前人员对评论的点赞标识 (0 没有点赞 1有点赞) |
154 | + Content string `json:"content"` // 评论的内容 | ||
141 | } | 155 | } |
142 | ) | 156 | ) |
143 | 157 | ||
@@ -190,3 +204,17 @@ type ( | @@ -190,3 +204,17 @@ type ( | ||
190 | List []CommentAtWho `json:"list"` | 204 | List []CommentAtWho `json:"list"` |
191 | } | 205 | } |
192 | ) | 206 | ) |
207 | + | ||
208 | +type( | ||
209 | + SystemArticleCommentSearchMeRequest{ | ||
210 | + Page int `json:"page"` | ||
211 | + Size int `json:"size"` | ||
212 | + AuthorId int64 `json:"authorId"` // 用户 | ||
213 | + BeginTime int64 `json:"beginTime,optional"` // 开始时间 | ||
214 | + EndTime int64 `json:"endTime,optional"` // 结束时间 | ||
215 | + } | ||
216 | + SystemArticleCommentSearchMeResponse{ | ||
217 | + List []ArticleCommentItem `json:"list"` | ||
218 | + Total int64 `json:"total"` | ||
219 | + } | ||
220 | +) |
@@ -261,11 +261,13 @@ type( | @@ -261,11 +261,13 @@ type( | ||
261 | Code string `json:"code"` | 261 | Code string `json:"code"` |
262 | } | 262 | } |
263 | UserStatisticsRequest{ | 263 | UserStatisticsRequest{ |
264 | - UserId int64 `json:"userId"` | ||
265 | - ItemFlag int `json:"itemFlag"` // 1:他的帖子 2:他的评论/回复 4:他收到的赞 8:TA的圆桌讨论 16:被采纳 | 264 | + UserId int64 `json:"userId,optional"` |
265 | + ItemFlag int `json:"itemFlag"` //0:默认查询所有 1:他的帖子 2:他的评论/回复 4:他收到的赞 8:TA的圆桌讨论 16:被采纳 | ||
266 | } | 266 | } |
267 | UserStatisticsResponse{ | 267 | UserStatisticsResponse{ |
268 | - List []StatisticsItem `json:"list"` | 268 | + TotalArticle int `json:"totalArticle"` |
269 | + TotalComment int `json:"totalComment"` | ||
270 | + TotalLoved int `json:"totalLoved"` | ||
269 | } | 271 | } |
270 | StatisticsItem{ | 272 | StatisticsItem{ |
271 | ItemFlag int `json:"itemFlag"` // 1:他的帖子 2:他的评论/回复 4:他收到的赞 8:TA的圆桌讨论 16:被采纳 | 273 | ItemFlag int `json:"itemFlag"` // 1:他的帖子 2:他的评论/回复 4:他收到的赞 8:TA的圆桌讨论 16:被采纳 |
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 SystemArticleSearchMeHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | ||
14 | + return func(w http.ResponseWriter, r *http.Request) { | ||
15 | + var req types.SystemArticleSearchMeRequest | ||
16 | + if err := httpx.Parse(r, &req); err != nil { | ||
17 | + httpx.ErrorCtx(r.Context(), w, err) | ||
18 | + return | ||
19 | + } | ||
20 | + | ||
21 | + l := article.NewSystemArticleSearchMeLogic(r.Context(), svcCtx) | ||
22 | + resp, err := l.SystemArticleSearchMe(&req) | ||
23 | + result.HttpResult(r, w, resp, err) | ||
24 | + } | ||
25 | +} |
1 | +package comment | ||
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/comment" | ||
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 SystemArticleCommentSearchMeHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | ||
14 | + return func(w http.ResponseWriter, r *http.Request) { | ||
15 | + var req types.SystemArticleCommentSearchMeRequest | ||
16 | + if err := httpx.Parse(r, &req); err != nil { | ||
17 | + httpx.ErrorCtx(r.Context(), w, err) | ||
18 | + return | ||
19 | + } | ||
20 | + | ||
21 | + l := comment.NewSystemArticleCommentSearchMeLogic(r.Context(), svcCtx) | ||
22 | + resp, err := l.SystemArticleCommentSearchMe(&req) | ||
23 | + result.HttpResult(r, w, resp, err) | ||
24 | + } | ||
25 | +} |
@@ -61,6 +61,21 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { | @@ -61,6 +61,21 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { | ||
61 | ) | 61 | ) |
62 | 62 | ||
63 | server.AddRoutes( | 63 | server.AddRoutes( |
64 | + rest.WithMiddlewares( | ||
65 | + []rest.Middleware{serverCtx.LoginStatusCheck}, | ||
66 | + []rest.Route{ | ||
67 | + { | ||
68 | + Method: http.MethodPost, | ||
69 | + Path: "/article_comment/search/me", | ||
70 | + Handler: comment.SystemArticleCommentSearchMeHandler(serverCtx), | ||
71 | + }, | ||
72 | + }..., | ||
73 | + ), | ||
74 | + rest.WithJwt(serverCtx.Config.SystemAuth.AccessSecret), | ||
75 | + rest.WithPrefix("/v1/system"), | ||
76 | + ) | ||
77 | + | ||
78 | + server.AddRoutes( | ||
64 | []rest.Route{ | 79 | []rest.Route{ |
65 | { | 80 | { |
66 | Method: http.MethodPost, | 81 | Method: http.MethodPost, |
@@ -371,8 +386,13 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { | @@ -371,8 +386,13 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { | ||
371 | Path: "/article/search", | 386 | Path: "/article/search", |
372 | Handler: article.SystemSearchArticleHandler(serverCtx), | 387 | Handler: article.SystemSearchArticleHandler(serverCtx), |
373 | }, | 388 | }, |
389 | + { | ||
390 | + Method: http.MethodPost, | ||
391 | + Path: "/article/search/me", | ||
392 | + Handler: article.SystemArticleSearchMeHandler(serverCtx), | ||
374 | }, | 393 | }, |
375 | - rest.WithJwt(serverCtx.Config.MiniAuth.AccessSecret), | 394 | + }, |
395 | + rest.WithJwt(serverCtx.Config.SystemAuth.AccessSecret), | ||
376 | rest.WithPrefix("/v1/system"), | 396 | rest.WithPrefix("/v1/system"), |
377 | ) | 397 | ) |
378 | 398 |
@@ -42,19 +42,24 @@ func (l *MiniArticleSearchMeLogic) MiniArticleSearchMe(req *types.MiniArticleSea | @@ -42,19 +42,24 @@ func (l *MiniArticleSearchMeLogic) MiniArticleSearchMe(req *types.MiniArticleSea | ||
42 | List: make([]types.ArticleSearchMe, len(articleList)), | 42 | List: make([]types.ArticleSearchMe, len(articleList)), |
43 | } | 43 | } |
44 | for i := range articleList { | 44 | for i := range articleList { |
45 | + resp.List[i] = NewArticle(articleList[i]) | ||
46 | + } | ||
47 | + return | ||
48 | +} | ||
49 | + | ||
50 | +func NewArticle(article *domain.Article) types.ArticleSearchMe { | ||
45 | images := []string{} | 51 | images := []string{} |
46 | - for _, val2 := range articleList[i].Images { | 52 | + for _, val2 := range article.Images { |
47 | images = append(images, val2.Url) | 53 | images = append(images, val2.Url) |
48 | } | 54 | } |
49 | - resp.List[i] = types.ArticleSearchMe{ | ||
50 | - Id: articleList[i].Id, | ||
51 | - Title: articleList[i].Title, | 55 | + articleSearchMe := types.ArticleSearchMe{ |
56 | + Id: article.Id, | ||
57 | + Title: article.Title, | ||
52 | Images: images, | 58 | Images: images, |
53 | - CreatedAt: articleList[i].CreatedAt, | ||
54 | - CountLove: articleList[i].CountLove, | ||
55 | - CountComment: articleList[i].CountComment, | ||
56 | - Show: int(articleList[i].Show), | ||
57 | - } | 59 | + CreatedAt: article.CreatedAt, |
60 | + CountLove: article.CountLove, | ||
61 | + CountComment: article.CountComment, | ||
62 | + Show: int(article.Show), | ||
58 | } | 63 | } |
59 | - return | 64 | + return articleSearchMe |
60 | } | 65 | } |
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 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr" | ||
8 | + | ||
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 | + "github.com/zeromicro/go-zero/core/logx" | ||
13 | +) | ||
14 | + | ||
15 | +type SystemArticleSearchMeLogic struct { | ||
16 | + logx.Logger | ||
17 | + ctx context.Context | ||
18 | + svcCtx *svc.ServiceContext | ||
19 | +} | ||
20 | + | ||
21 | +func NewSystemArticleSearchMeLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SystemArticleSearchMeLogic { | ||
22 | + return &SystemArticleSearchMeLogic{ | ||
23 | + Logger: logx.WithContext(ctx), | ||
24 | + ctx: ctx, | ||
25 | + svcCtx: svcCtx, | ||
26 | + } | ||
27 | +} | ||
28 | + | ||
29 | +func (l *SystemArticleSearchMeLogic) SystemArticleSearchMe(req *types.SystemArticleSearchMeRequest) (resp *types.SystemArticleSearchMeResponse, err error) { | ||
30 | + var ( | ||
31 | + conn = l.svcCtx.DefaultDBConn() | ||
32 | + userToken = contextdata.GetUserTokenFromCtx(l.ctx) | ||
33 | + ) | ||
34 | + queryOptions := domain.NewQueryOptions(). | ||
35 | + WithOffsetLimit(req.Page, req.Size). | ||
36 | + MustWithKV("authorId", req.AuthorId). | ||
37 | + WithKV("beginCreatedAt", req.BeginTime). | ||
38 | + WithKV("endCreatedAt", req.EndTime) | ||
39 | + | ||
40 | + cnt, articleList, err := l.svcCtx.ArticleRepository.Find(l.ctx, conn, userToken.CompanyId, queryOptions) | ||
41 | + if err != nil { | ||
42 | + return &types.SystemArticleSearchMeResponse{}, xerr.NewErrMsgErr("获取文章列表失败", err) | ||
43 | + } | ||
44 | + | ||
45 | + resp = &types.SystemArticleSearchMeResponse{ | ||
46 | + Total: int(cnt), | ||
47 | + List: make([]types.ArticleSearchMe, len(articleList)), | ||
48 | + } | ||
49 | + for i := range articleList { | ||
50 | + resp.List[i] = NewArticle(articleList[i]) | ||
51 | + } | ||
52 | + return | ||
53 | +} |
@@ -51,6 +51,23 @@ func (l *MiniTop5ArticleCommentLogic) MiniTop5ArticleComment(req *types.MiniTop5 | @@ -51,6 +51,23 @@ func (l *MiniTop5ArticleCommentLogic) MiniTop5ArticleComment(req *types.MiniTop5 | ||
51 | List: make([]types.ArticleCommentItem, len(commentList)), | 51 | List: make([]types.ArticleCommentItem, len(commentList)), |
52 | } | 52 | } |
53 | for i, val := range commentList { | 53 | for i, val := range commentList { |
54 | + item := NewArticleCommentItem(val) | ||
55 | + | ||
56 | + if _, ok := flagMap[val.Id]; ok { | ||
57 | + item.MeLoveFlag = 1 | ||
58 | + } | ||
59 | + for _, val2 := range val.AtWho { | ||
60 | + item.AtWho = append(item.AtWho, types.CommentAtWho{ | ||
61 | + Id: val2.Id, | ||
62 | + Name: val2.Name, | ||
63 | + }) | ||
64 | + } | ||
65 | + resp.List[i] = item | ||
66 | + } | ||
67 | + return | ||
68 | +} | ||
69 | + | ||
70 | +func NewArticleCommentItem(val *domain.ArticleComment) types.ArticleCommentItem { | ||
54 | item := types.ArticleCommentItem{ | 71 | item := types.ArticleCommentItem{ |
55 | Id: val.Id, | 72 | Id: val.Id, |
56 | Pid: val.Pid, | 73 | Pid: val.Pid, |
@@ -80,18 +97,7 @@ func (l *MiniTop5ArticleCommentLogic) MiniTop5ArticleComment(req *types.MiniTop5 | @@ -80,18 +97,7 @@ func (l *MiniTop5ArticleCommentLogic) MiniTop5ArticleComment(req *types.MiniTop5 | ||
80 | AtWho: []types.CommentAtWho{}, | 97 | AtWho: []types.CommentAtWho{}, |
81 | CreatedAt: val.CreatedAt, | 98 | CreatedAt: val.CreatedAt, |
82 | MeLoveFlag: 0, | 99 | MeLoveFlag: 0, |
100 | + Content: val.Content, | ||
83 | } | 101 | } |
84 | - | ||
85 | - if _, ok := flagMap[val.Id]; ok { | ||
86 | - item.MeLoveFlag = 1 | ||
87 | - } | ||
88 | - for _, val2 := range val.AtWho { | ||
89 | - item.AtWho = append(item.AtWho, types.CommentAtWho{ | ||
90 | - Id: val2.Id, | ||
91 | - Name: val2.Name, | ||
92 | - }) | ||
93 | - } | ||
94 | - resp.List[i] = item | ||
95 | - } | ||
96 | - return | 102 | + return item |
97 | } | 103 | } |
1 | +package comment | ||
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 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr" | ||
8 | + | ||
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 | + "github.com/zeromicro/go-zero/core/logx" | ||
13 | +) | ||
14 | + | ||
15 | +type SystemArticleCommentSearchMeLogic struct { | ||
16 | + logx.Logger | ||
17 | + ctx context.Context | ||
18 | + svcCtx *svc.ServiceContext | ||
19 | +} | ||
20 | + | ||
21 | +func NewSystemArticleCommentSearchMeLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SystemArticleCommentSearchMeLogic { | ||
22 | + return &SystemArticleCommentSearchMeLogic{ | ||
23 | + Logger: logx.WithContext(ctx), | ||
24 | + ctx: ctx, | ||
25 | + svcCtx: svcCtx, | ||
26 | + } | ||
27 | +} | ||
28 | + | ||
29 | +func (l *SystemArticleCommentSearchMeLogic) SystemArticleCommentSearchMe(req *types.SystemArticleCommentSearchMeRequest) (resp *types.SystemArticleCommentSearchMeResponse, err error) { | ||
30 | + var ( | ||
31 | + conn = l.svcCtx.DefaultDBConn() | ||
32 | + userToken = contextdata.GetUserTokenFromCtx(l.ctx) | ||
33 | + ) | ||
34 | + queryOptions := domain.IndexCompanyId(userToken.CompanyId)(). | ||
35 | + WithOffsetLimit(req.Page, req.Size). | ||
36 | + MustWithKV("fromUserId", req.AuthorId). | ||
37 | + WithKV("beginCreatedAt", req.BeginTime). | ||
38 | + WithKV("endCreatedAt", req.EndTime) | ||
39 | + | ||
40 | + cnt, articleList, err := l.svcCtx.ArticleCommentRepository.Find(l.ctx, conn, queryOptions) | ||
41 | + if err != nil { | ||
42 | + return &types.SystemArticleCommentSearchMeResponse{}, xerr.NewErrMsgErr("获取评论回复列表失败", err) | ||
43 | + } | ||
44 | + | ||
45 | + resp = &types.SystemArticleCommentSearchMeResponse{ | ||
46 | + Total: cnt, | ||
47 | + List: make([]types.ArticleCommentItem, len(articleList)), | ||
48 | + } | ||
49 | + for i := range articleList { | ||
50 | + resp.List[i] = NewArticleCommentItem(articleList[i]) | ||
51 | + } | ||
52 | + return | ||
53 | +} |
@@ -2,6 +2,8 @@ package user | @@ -2,6 +2,8 @@ package user | ||
2 | 2 | ||
3 | import ( | 3 | import ( |
4 | "context" | 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" | ||
5 | 7 | ||
6 | "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" |
7 | "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" |
@@ -24,7 +26,58 @@ func NewSystemUserStatisticsLogic(ctx context.Context, svcCtx *svc.ServiceContex | @@ -24,7 +26,58 @@ func NewSystemUserStatisticsLogic(ctx context.Context, svcCtx *svc.ServiceContex | ||
24 | } | 26 | } |
25 | 27 | ||
26 | func (l *SystemUserStatisticsLogic) SystemUserStatistics(req *types.UserStatisticsRequest) (resp *types.UserStatisticsResponse, err error) { | 28 | func (l *SystemUserStatisticsLogic) SystemUserStatistics(req *types.UserStatisticsRequest) (resp *types.UserStatisticsResponse, err error) { |
27 | - // todo: add your logic here and delete this line | 29 | + var ( |
30 | + userId = req.UserId | ||
31 | + userToken = contextdata.GetUserTokenFromCtx(l.ctx) | ||
32 | + ) | ||
33 | + s := StatisticsItems(l.ctx, l.svcCtx, userToken.CompanyId, userId, req.ItemFlag) | ||
34 | + resp = &types.UserStatisticsResponse{ | ||
35 | + TotalArticle: s.TotalArticle, | ||
36 | + TotalComment: s.TotalComment, | ||
37 | + TotalLoved: s.TotalLoved, | ||
38 | + } | ||
39 | + return | ||
40 | +} | ||
28 | 41 | ||
42 | +func StatisticsItems(ctx context.Context, svcCtx *svc.ServiceContext, companyId, userId int64, itemFlag int) (s Statistics) { | ||
43 | + var conn = svcCtx.DefaultDBConn() | ||
44 | + s = Statistics{} | ||
45 | + if itemFlag == 0 { | ||
46 | + itemFlag = -1 | ||
47 | + } | ||
48 | + if (itemFlag & TotalArticle) > 0 { | ||
49 | + var total int64 | ||
50 | + total, _, _ = svcCtx.ArticleRepository.Find(ctx, conn, companyId, domain.NewQueryOptions().WithCountOnly().MustWithKV("authorId", userId)) | ||
51 | + s.TotalArticle = int(total) | ||
52 | + } | ||
53 | + if (itemFlag & TotalComment) > 0 { | ||
54 | + var total int64 | ||
55 | + total, _, _ = svcCtx.ArticleCommentRepository.Find(ctx, conn, domain.IndexCompanyId(companyId)().WithCountOnly().MustWithKV("fromUserId", userId)) | ||
56 | + s.TotalComment = int(total) | ||
57 | + } | ||
58 | + if (itemFlag & TotalLoved) > 0 { | ||
59 | + var total int64 | ||
60 | + total, _, _ = svcCtx.UserLoveFlagRepository.Find(ctx, conn, domain.IndexCompanyId(companyId)().WithCountOnly().MustWithKV("userId", userId)) | ||
61 | + s.TotalComment = int(total) | ||
62 | + } | ||
29 | return | 63 | return |
30 | } | 64 | } |
65 | + | ||
66 | +type Statistics struct { | ||
67 | + TotalArticle int `json:"totalArticle"` | ||
68 | + TotalComment int `json:"totalComment"` | ||
69 | + TotalLoved int `json:"totalLoved"` | ||
70 | +} | ||
71 | + | ||
72 | +const ( | ||
73 | + TotalArticle = 1 | ||
74 | + TotalComment = 2 | ||
75 | + TotalLoved = 4 | ||
76 | +) | ||
77 | + | ||
78 | +func NewStatisticsItem(itemFlag int, value float64) types.StatisticsItem { | ||
79 | + return types.StatisticsItem{ | ||
80 | + ItemFlag: itemFlag, | ||
81 | + Value: value, | ||
82 | + } | ||
83 | +} |
@@ -86,6 +86,7 @@ type ArticleCommentItem struct { | @@ -86,6 +86,7 @@ type ArticleCommentItem struct { | ||
86 | AtWho []CommentAtWho `json:"atWho"` // 填写评论时@的人 | 86 | AtWho []CommentAtWho `json:"atWho"` // 填写评论时@的人 |
87 | CreatedAt int64 `json:"createdAt"` // | 87 | CreatedAt int64 `json:"createdAt"` // |
88 | MeLoveFlag int `json:"meLoveFlag"` //当前人员对评论的点赞标识 (0 没有点赞 1有点赞) | 88 | MeLoveFlag int `json:"meLoveFlag"` //当前人员对评论的点赞标识 (0 没有点赞 1有点赞) |
89 | + Content string `json:"content"` // 评论的内容 | ||
89 | } | 90 | } |
90 | 91 | ||
91 | type MiniGetArticleCommentRequest struct { | 92 | type MiniGetArticleCommentRequest struct { |
@@ -128,6 +129,19 @@ type MiniArticleCommentAtWhoResponse struct { | @@ -128,6 +129,19 @@ type MiniArticleCommentAtWhoResponse struct { | ||
128 | List []CommentAtWho `json:"list"` | 129 | List []CommentAtWho `json:"list"` |
129 | } | 130 | } |
130 | 131 | ||
132 | +type SystemArticleCommentSearchMeRequest struct { | ||
133 | + Page int `json:"page"` | ||
134 | + Size int `json:"size"` | ||
135 | + AuthorId int64 `json:"authorId"` // 用户 | ||
136 | + BeginTime int64 `json:"beginTime,optional"` // 开始时间 | ||
137 | + EndTime int64 `json:"endTime,optional"` // 结束时间 | ||
138 | +} | ||
139 | + | ||
140 | +type SystemArticleCommentSearchMeResponse struct { | ||
141 | + List []ArticleCommentItem `json:"list"` | ||
142 | + Total int64 `json:"total"` | ||
143 | +} | ||
144 | + | ||
131 | type MessageSystemRequest struct { | 145 | type MessageSystemRequest struct { |
132 | Page int `json:"page"` | 146 | Page int `json:"page"` |
133 | Size int `json:"size"` | 147 | Size int `json:"size"` |
@@ -427,12 +441,14 @@ type SystemUserInfoResponse struct { | @@ -427,12 +441,14 @@ type SystemUserInfoResponse struct { | ||
427 | } | 441 | } |
428 | 442 | ||
429 | type UserStatisticsRequest struct { | 443 | type UserStatisticsRequest struct { |
430 | - UserId int64 `json:"userId"` | ||
431 | - ItemFlag int `json:"itemFlag"` // 1:他的帖子 2:他的评论/回复 4:他收到的赞 8:TA的圆桌讨论 16:被采纳 | 444 | + UserId int64 `json:"userId,optional"` |
445 | + ItemFlag int `json:"itemFlag"` //0:默认查询所有 1:他的帖子 2:他的评论/回复 4:他收到的赞 8:TA的圆桌讨论 16:被采纳 | ||
432 | } | 446 | } |
433 | 447 | ||
434 | type UserStatisticsResponse struct { | 448 | type UserStatisticsResponse struct { |
435 | - List []StatisticsItem `json:"list"` | 449 | + TotalArticle int `json:"totalArticle"` |
450 | + TotalComment int `json:"totalComment"` | ||
451 | + TotalLoved int `json:"totalLoved"` | ||
436 | } | 452 | } |
437 | 453 | ||
438 | type StatisticsItem struct { | 454 | type StatisticsItem struct { |
@@ -639,6 +655,19 @@ type ArticleSearchMe struct { | @@ -639,6 +655,19 @@ type ArticleSearchMe struct { | ||
639 | Show int `json:"show"` //是否隐藏 [0显示、1不显示] | 655 | Show int `json:"show"` //是否隐藏 [0显示、1不显示] |
640 | } | 656 | } |
641 | 657 | ||
658 | +type SystemArticleSearchMeRequest struct { | ||
659 | + Page int `json:"page"` | ||
660 | + Size int `json:"size"` | ||
661 | + AuthorId int64 `json:"authorId"` // 用户 | ||
662 | + BeginTime int64 `json:"beginTime,optional"` // 开始时间 | ||
663 | + EndTime int64 `json:"endTime,optional"` // 结束时间 | ||
664 | +} | ||
665 | + | ||
666 | +type SystemArticleSearchMeResponse struct { | ||
667 | + Total int `json:"total"` | ||
668 | + List []ArticleSearchMe `json:"list"` | ||
669 | +} | ||
670 | + | ||
642 | type MiniUserLikeArticleRequest struct { | 671 | type MiniUserLikeArticleRequest struct { |
643 | ArticleId int64 `json:"articleId"` // 文章id | 672 | ArticleId int64 `json:"articleId"` // 文章id |
644 | CompanyId int64 `json:",optional"` //公司id | 673 | CompanyId int64 `json:",optional"` //公司id |
@@ -137,10 +137,18 @@ func (repository *ArticleCommentRepository) Find(ctx context.Context, conn trans | @@ -137,10 +137,18 @@ func (repository *ArticleCommentRepository) Find(ctx context.Context, conn trans | ||
137 | if v, ok := queryOptions["sectionId"]; ok { | 137 | if v, ok := queryOptions["sectionId"]; ok { |
138 | tx = tx.Where("section_id=?", v) | 138 | tx = tx.Where("section_id=?", v) |
139 | } | 139 | } |
140 | - | ||
141 | if v, ok := queryOptions["companyId"]; ok { | 140 | if v, ok := queryOptions["companyId"]; ok { |
142 | tx = tx.Where("company_id=?", v) | 141 | tx = tx.Where("company_id=?", v) |
143 | } | 142 | } |
143 | + if v, ok := queryOptions["fromUserId"]; ok { | ||
144 | + tx = tx.Where("from_user_id=?", v) | ||
145 | + } | ||
146 | + if v, ok := queryOptions["beginCreatedAt"]; ok { | ||
147 | + tx = tx.Where("created_at >= ?", v) | ||
148 | + } | ||
149 | + if v, ok := queryOptions["endCreatedAt"]; ok { | ||
150 | + tx = tx.Where("created_at < ?", v) | ||
151 | + } | ||
144 | 152 | ||
145 | if total, tx = transaction.PaginationAndCount(ctx, tx, queryOptions, &ms); tx.Error != nil { | 153 | if total, tx = transaction.PaginationAndCount(ctx, tx, queryOptions, &ms); tx.Error != nil { |
146 | return dms, tx.Error | 154 | return dms, tx.Error |
@@ -127,6 +127,12 @@ func (repository *ArticleRepository) Find(ctx context.Context, conn transaction. | @@ -127,6 +127,12 @@ func (repository *ArticleRepository) Find(ctx context.Context, conn transaction. | ||
127 | if v, ok := queryOptions["authorId"]; ok { | 127 | if v, ok := queryOptions["authorId"]; ok { |
128 | tx = tx.Where("author_id = ?", v) | 128 | tx = tx.Where("author_id = ?", v) |
129 | } | 129 | } |
130 | + if v, ok := queryOptions["beginCreatedAt"]; ok { | ||
131 | + tx = tx.Where("created_at >= ?", v) | ||
132 | + } | ||
133 | + if v, ok := queryOptions["endCreatedAt"]; ok { | ||
134 | + tx = tx.Where("created_at < ?", v) | ||
135 | + } | ||
130 | 136 | ||
131 | if total, tx = transaction.PaginationAndCount(ctx, tx, queryOptions, &ms); tx.Error != nil { | 137 | if total, tx = transaction.PaginationAndCount(ctx, tx, queryOptions, &ms); tx.Error != nil { |
132 | return dms, tx.Error | 138 | return dms, tx.Error |
@@ -126,6 +126,9 @@ func (repository *UserLoveFlagRepository) Find(ctx context.Context, conn transac | @@ -126,6 +126,9 @@ func (repository *UserLoveFlagRepository) Find(ctx context.Context, conn transac | ||
126 | if v, ok := queryOptions["commentId"]; ok { | 126 | if v, ok := queryOptions["commentId"]; ok { |
127 | tx = tx.Where("comment_id=?", v) | 127 | tx = tx.Where("comment_id=?", v) |
128 | } | 128 | } |
129 | + if v, ok := queryOptions["companyId"]; ok { | ||
130 | + tx = tx.Where("company_id=?", v) | ||
131 | + } | ||
129 | if v, ok := queryOptions["userId"]; ok { | 132 | if v, ok := queryOptions["userId"]; ok { |
130 | tx = tx.Where("user_id=?", v) | 133 | tx = tx.Where("user_id=?", v) |
131 | } | 134 | } |
-
请 注册 或 登录 后发表评论