|
@@ -27,9 +27,11 @@ func NewMiniBusinessLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Mini |
|
@@ -27,9 +27,11 @@ func NewMiniBusinessLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Mini |
27
|
}
|
27
|
}
|
28
|
|
28
|
|
29
|
func (l *MiniBusinessLogic) MiniBusiness(req *types.MessageBusinessRequest) (resp *types.MessageBusinessResponse, err error) {
|
29
|
func (l *MiniBusinessLogic) MiniBusiness(req *types.MessageBusinessRequest) (resp *types.MessageBusinessResponse, err error) {
|
|
|
30
|
+ var userToken = contextdata.GetUserTokenFromCtx(l.ctx)
|
|
|
31
|
+ var conn = l.svcCtx.DefaultDBConn()
|
30
|
var msgType = req.Type
|
32
|
var msgType = req.Type
|
31
|
|
33
|
|
32
|
- total, list, err := l.svcCtx.MessageBusinessRepository.Find(l.ctx, l.svcCtx.DefaultDBConn(), domain.NewQueryOptions().
|
34
|
+ total, list, err := l.svcCtx.MessageBusinessRepository.Find(l.ctx, conn, domain.NewQueryOptions().
|
33
|
WithOffsetLimit(req.Page, req.Size).
|
35
|
WithOffsetLimit(req.Page, req.Size).
|
34
|
WithKV("type", msgType))
|
36
|
WithKV("type", msgType))
|
35
|
if err != nil {
|
37
|
if err != nil {
|
|
@@ -96,11 +98,10 @@ func (l *MiniBusinessLogic) MiniBusiness(req *types.MessageBusinessRequest) (res |
|
@@ -96,11 +98,10 @@ func (l *MiniBusinessLogic) MiniBusiness(req *types.MessageBusinessRequest) (res |
96
|
|
98
|
|
97
|
// 获取公司
|
99
|
// 获取公司
|
98
|
if len(companyIds) > 0 {
|
100
|
if len(companyIds) > 0 {
|
99
|
- _, companyList, err := l.svcCtx.CompanyRepository.Find(l.ctx, l.svcCtx.DefaultDBConn(),
|
|
|
100
|
- domain.NewQueryOptions().
|
|
|
101
|
- WithFindOnly().
|
|
|
102
|
- WithKV("ids", userIds).
|
|
|
103
|
- WithKV("limit", len(userIds)))
|
101
|
+ _, companyList, err := l.svcCtx.CompanyRepository.Find(l.ctx, conn, domain.NewQueryOptions().
|
|
|
102
|
+ WithFindOnly().
|
|
|
103
|
+ WithKV("ids", userIds).
|
|
|
104
|
+ WithKV("limit", len(userIds)))
|
104
|
if err != nil {
|
105
|
if err != nil {
|
105
|
return nil, err
|
106
|
return nil, err
|
106
|
}
|
107
|
}
|
|
@@ -111,11 +112,10 @@ func (l *MiniBusinessLogic) MiniBusiness(req *types.MessageBusinessRequest) (res |
|
@@ -111,11 +112,10 @@ func (l *MiniBusinessLogic) MiniBusiness(req *types.MessageBusinessRequest) (res |
111
|
|
112
|
|
112
|
// 获取用户
|
113
|
// 获取用户
|
113
|
if len(userIds) > 0 {
|
114
|
if len(userIds) > 0 {
|
114
|
- _, userList, err := l.svcCtx.UserRepository.Find(l.ctx, l.svcCtx.DefaultDBConn(),
|
|
|
115
|
- domain.NewQueryOptions().
|
|
|
116
|
- WithFindOnly().
|
|
|
117
|
- WithKV("ids", userIds).
|
|
|
118
|
- WithKV("limit", len(userIds)))
|
115
|
+ _, userList, err := l.svcCtx.UserRepository.Find(l.ctx, conn, domain.NewQueryOptions().
|
|
|
116
|
+ WithFindOnly().
|
|
|
117
|
+ WithKV("ids", userIds).
|
|
|
118
|
+ WithKV("limit", len(userIds)))
|
119
|
if err != nil {
|
119
|
if err != nil {
|
120
|
return nil, err
|
120
|
return nil, err
|
121
|
}
|
121
|
}
|
|
@@ -126,11 +126,10 @@ func (l *MiniBusinessLogic) MiniBusiness(req *types.MessageBusinessRequest) (res |
|
@@ -126,11 +126,10 @@ func (l *MiniBusinessLogic) MiniBusiness(req *types.MessageBusinessRequest) (res |
126
|
|
126
|
|
127
|
// 获取评论
|
127
|
// 获取评论
|
128
|
if len(commentIds) > 0 {
|
128
|
if len(commentIds) > 0 {
|
129
|
- _, commentList, err := l.svcCtx.CommentRepository.Find(l.ctx, l.svcCtx.DefaultDBConn(),
|
|
|
130
|
- domain.NewQueryOptions().
|
|
|
131
|
- WithFindOnly().
|
|
|
132
|
- WithKV("ids", commentIds).
|
|
|
133
|
- WithKV("limit", len(commentIds)))
|
129
|
+ _, commentList, err := l.svcCtx.CommentRepository.Find(l.ctx, conn, domain.NewQueryOptions().
|
|
|
130
|
+ WithFindOnly().
|
|
|
131
|
+ WithKV("ids", commentIds).
|
|
|
132
|
+ WithKV("limit", len(commentIds)))
|
134
|
if err != nil {
|
133
|
if err != nil {
|
135
|
return nil, err
|
134
|
return nil, err
|
136
|
}
|
135
|
}
|
|
@@ -141,11 +140,10 @@ func (l *MiniBusinessLogic) MiniBusiness(req *types.MessageBusinessRequest) (res |
|
@@ -141,11 +140,10 @@ func (l *MiniBusinessLogic) MiniBusiness(req *types.MessageBusinessRequest) (res |
141
|
|
140
|
|
142
|
// 获取文章数据
|
141
|
// 获取文章数据
|
143
|
if len(articleIds) > 0 {
|
142
|
if len(articleIds) > 0 {
|
144
|
- _, articleList, err := l.svcCtx.ArticleRepository.Find(l.ctx, l.svcCtx.DefaultDBConn(), 0,
|
|
|
145
|
- domain.NewQueryOptions().
|
|
|
146
|
- WithFindOnly().
|
|
|
147
|
- WithKV("ids", articleIds).
|
|
|
148
|
- WithKV("limit", len(articleIds)))
|
143
|
+ _, articleList, err := l.svcCtx.ArticleRepository.Find(l.ctx, conn, userToken.CompanyId, domain.NewQueryOptions().
|
|
|
144
|
+ WithFindOnly().
|
|
|
145
|
+ WithKV("ids", articleIds).
|
|
|
146
|
+ WithKV("limit", len(articleIds)))
|
149
|
if err != nil {
|
147
|
if err != nil {
|
150
|
return nil, err
|
148
|
return nil, err
|
151
|
}
|
149
|
}
|
|
@@ -156,18 +154,18 @@ func (l *MiniBusinessLogic) MiniBusiness(req *types.MessageBusinessRequest) (res |
|
@@ -156,18 +154,18 @@ func (l *MiniBusinessLogic) MiniBusiness(req *types.MessageBusinessRequest) (res |
156
|
|
154
|
|
157
|
for _, item := range list {
|
155
|
for _, item := range list {
|
158
|
to := types.MessageBusinessItem{
|
156
|
to := types.MessageBusinessItem{
|
159
|
- Id: item.Id,
|
|
|
160
|
- Type: int(item.Type),
|
|
|
161
|
- OptType: int(item.OptType),
|
|
|
162
|
- CompanyId: item.CompanyId,
|
|
|
163
|
- UserId: item.UserId,
|
|
|
164
|
- RecipientId: item.RecipientId,
|
|
|
165
|
- ArticleId: item.ArticleId,
|
|
|
166
|
- CommentId: item.CommentId,
|
|
|
167
|
- DiscussionId: item.DiscussionId,
|
|
|
168
|
- DiscussionOpinionId: item.DiscussionOpinionId,
|
|
|
169
|
- Content: item.Content,
|
|
|
170
|
- CreatedAt: item.CreatedAt,
|
157
|
+ Id: item.Id,
|
|
|
158
|
+ Type: int(item.Type),
|
|
|
159
|
+ OptType: int(item.OptType),
|
|
|
160
|
+ CompanyId: item.CompanyId,
|
|
|
161
|
+ UserId: item.UserId,
|
|
|
162
|
+ RecipientId: item.RecipientId,
|
|
|
163
|
+ ArticleId: item.ArticleId,
|
|
|
164
|
+ CommentId: item.CommentId,
|
|
|
165
|
+ //DiscussionId: item.DiscussionId,
|
|
|
166
|
+ //DiscussionOpinionId: item.DiscussionOpinionId,
|
|
|
167
|
+ Content: item.Content,
|
|
|
168
|
+ CreatedAt: item.CreatedAt,
|
171
|
}
|
169
|
}
|
172
|
|
170
|
|
173
|
if v, ok := userIdMap[item.UserId]; ok {
|
171
|
if v, ok := userIdMap[item.UserId]; ok {
|