Merge branch 'dev' of http://gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss into dev
正在显示
15 个修改的文件
包含
507 行增加
和
27 行删除
@@ -257,7 +257,7 @@ | @@ -257,7 +257,7 @@ | ||
257 | }, | 257 | }, |
258 | "v1/mini/company/search": { | 258 | "v1/mini/company/search": { |
259 | "post": { | 259 | "post": { |
260 | - "summary": "公司搜索", | 260 | + "summary": "公司搜索(公开的)", |
261 | "operationId": "miniCompanySearch", | 261 | "operationId": "miniCompanySearch", |
262 | "responses": { | 262 | "responses": { |
263 | "200": { | 263 | "200": { |
@@ -283,6 +283,34 @@ | @@ -283,6 +283,34 @@ | ||
283 | ] | 283 | ] |
284 | } | 284 | } |
285 | }, | 285 | }, |
286 | + "v1/mini/company/search-joined": { | ||
287 | + "post": { | ||
288 | + "summary": "搜索已加入的公司", | ||
289 | + "operationId": "miniCompanySearchJoined", | ||
290 | + "responses": { | ||
291 | + "200": { | ||
292 | + "description": "A successful response.", | ||
293 | + "schema": { | ||
294 | + "$ref": "#/definitions/CompanySearchResponse" | ||
295 | + } | ||
296 | + } | ||
297 | + }, | ||
298 | + "parameters": [ | ||
299 | + { | ||
300 | + "name": "body", | ||
301 | + "in": "body", | ||
302 | + "required": true, | ||
303 | + "schema": { | ||
304 | + "$ref": "#/definitions/CompanySearchRequest" | ||
305 | + } | ||
306 | + } | ||
307 | + ], | ||
308 | + "requestBody": {}, | ||
309 | + "tags": [ | ||
310 | + "company" | ||
311 | + ] | ||
312 | + } | ||
313 | + }, | ||
286 | "v1/mini/message/business": { | 314 | "v1/mini/message/business": { |
287 | "post": { | 315 | "post": { |
288 | "summary": "业务消息", | 316 | "summary": "业务消息", |
@@ -1022,6 +1050,34 @@ | @@ -1022,6 +1050,34 @@ | ||
1022 | ] | 1050 | ] |
1023 | } | 1051 | } |
1024 | }, | 1052 | }, |
1053 | + "v1/system/user/info": { | ||
1054 | + "post": { | ||
1055 | + "summary": "系统用户信息", | ||
1056 | + "operationId": "systemUserInfo", | ||
1057 | + "responses": { | ||
1058 | + "200": { | ||
1059 | + "description": "A successful response.", | ||
1060 | + "schema": { | ||
1061 | + "$ref": "#/definitions/SystemUserInfoResponse" | ||
1062 | + } | ||
1063 | + } | ||
1064 | + }, | ||
1065 | + "parameters": [ | ||
1066 | + { | ||
1067 | + "name": "body", | ||
1068 | + "in": "body", | ||
1069 | + "required": true, | ||
1070 | + "schema": { | ||
1071 | + "$ref": "#/definitions/SystemUserInfoRequest" | ||
1072 | + } | ||
1073 | + } | ||
1074 | + ], | ||
1075 | + "requestBody": {}, | ||
1076 | + "tags": [ | ||
1077 | + "user" | ||
1078 | + ] | ||
1079 | + } | ||
1080 | + }, | ||
1025 | "v1/user/mylike": { | 1081 | "v1/user/mylike": { |
1026 | "post": { | 1082 | "post": { |
1027 | "summary": "我点赞的文章或评论", | 1083 | "summary": "我点赞的文章或评论", |
@@ -1300,21 +1356,22 @@ | @@ -1300,21 +1356,22 @@ | ||
1300 | "type": "integer", | 1356 | "type": "integer", |
1301 | "format": "int32" | 1357 | "format": "int32" |
1302 | }, | 1358 | }, |
1359 | + "flag": { | ||
1360 | + "type": "integer", | ||
1361 | + "format": "int32", | ||
1362 | + "description": " 1:用户已加入的 2:用户未加入的公司" | ||
1363 | + }, | ||
1303 | "userId": { | 1364 | "userId": { |
1304 | "type": "integer", | 1365 | "type": "integer", |
1305 | "format": "int64", | 1366 | "format": "int64", |
1306 | - "description": " 按用户搜索" | 1367 | + "description": " 按用户搜索(用户所加入的企业)" |
1307 | }, | 1368 | }, |
1308 | "code": { | 1369 | "code": { |
1309 | "type": "string", | 1370 | "type": "string", |
1310 | "description": " 按编码搜索" | 1371 | "description": " 按编码搜索" |
1311 | } | 1372 | } |
1312 | }, | 1373 | }, |
1313 | - "title": "CompanySearchRequest", | ||
1314 | - "required": [ | ||
1315 | - "page", | ||
1316 | - "size" | ||
1317 | - ] | 1374 | + "title": "CompanySearchRequest" |
1318 | }, | 1375 | }, |
1319 | "CompanySearchResponse": { | 1376 | "CompanySearchResponse": { |
1320 | "type": "object", | 1377 | "type": "object", |
@@ -2998,6 +3055,40 @@ | @@ -2998,6 +3055,40 @@ | ||
2998 | "list" | 3055 | "list" |
2999 | ] | 3056 | ] |
3000 | }, | 3057 | }, |
3058 | + "SystemUserInfoRequest": { | ||
3059 | + "type": "object", | ||
3060 | + "title": "SystemUserInfoRequest" | ||
3061 | + }, | ||
3062 | + "SystemUserInfoResponse": { | ||
3063 | + "type": "object", | ||
3064 | + "properties": { | ||
3065 | + "userId": { | ||
3066 | + "type": "integer", | ||
3067 | + "format": "int64" | ||
3068 | + }, | ||
3069 | + "userName": { | ||
3070 | + "type": "string" | ||
3071 | + }, | ||
3072 | + "avatar": { | ||
3073 | + "type": "string" | ||
3074 | + }, | ||
3075 | + "companyId": { | ||
3076 | + "type": "integer", | ||
3077 | + "format": "int64" | ||
3078 | + }, | ||
3079 | + "companyName": { | ||
3080 | + "type": "string" | ||
3081 | + } | ||
3082 | + }, | ||
3083 | + "title": "SystemUserInfoResponse", | ||
3084 | + "required": [ | ||
3085 | + "userId", | ||
3086 | + "userName", | ||
3087 | + "avatar", | ||
3088 | + "companyId", | ||
3089 | + "companyName" | ||
3090 | + ] | ||
3091 | + }, | ||
3001 | "TagCreateRequest": { | 3092 | "TagCreateRequest": { |
3002 | "type": "object", | 3093 | "type": "object", |
3003 | "properties": { | 3094 | "properties": { |
@@ -32,6 +32,10 @@ service Core { | @@ -32,6 +32,10 @@ service Core { | ||
32 | @handler MiniArticleMarkUserRead | 32 | @handler MiniArticleMarkUserRead |
33 | post /article/mark/user_read (MiniArticleMarkUserReadRequest) returns (MiniArticleMarkUserReadResponse) | 33 | post /article/mark/user_read (MiniArticleMarkUserReadRequest) returns (MiniArticleMarkUserReadResponse) |
34 | 34 | ||
35 | + @doc "小程序获取文章浏览记录" | ||
36 | + @handler MiniArticleMarkList | ||
37 | + post /article/mark/list (MiniArticleMarkListRequest) returns (MiniArticleMarkListResponse) | ||
38 | + | ||
35 | @doc "小程序获取我发布的文章" | 39 | @doc "小程序获取我发布的文章" |
36 | @handler MiniArticleSearchMe | 40 | @handler MiniArticleSearchMe |
37 | post /article/search/me (MiniArticleSearchMeRequest) returns (MiniArticleSearchMeResponse) | 41 | post /article/search/me (MiniArticleSearchMeRequest) returns (MiniArticleSearchMeResponse) |
@@ -255,6 +255,29 @@ type ( | @@ -255,6 +255,29 @@ type ( | ||
255 | } | 255 | } |
256 | ) | 256 | ) |
257 | 257 | ||
258 | +type ( | ||
259 | + MiniArticleMarkListRequest { | ||
260 | + Page int `json:"page"` | ||
261 | + Size int `json:"size"` | ||
262 | + } | ||
263 | + | ||
264 | + MiniArticleMarkListResponse { | ||
265 | + Total int64 `json:"total"` | ||
266 | + List []MiniArticleMarkItem `json:"list"` | ||
267 | + } | ||
268 | + | ||
269 | + MiniArticleMarkItem { | ||
270 | + Id int64 `json:"id"` | ||
271 | + CompanyId int64 `json:"companyId"` | ||
272 | + UserId int64 `json:"userId"` | ||
273 | + ArticleId int64 `json:"articleId"` | ||
274 | + Title string `json:"title"` | ||
275 | + Author SimpleUser `json:"author"` // 发布人 | ||
276 | + UpdatedAt int64 `json:"updatedAt"` | ||
277 | + } | ||
278 | + | ||
279 | +) | ||
280 | + | ||
258 | //管理后台获取文章详情 | 281 | //管理后台获取文章详情 |
259 | type ( | 282 | type ( |
260 | SystemArticleGetRequest { | 283 | SystemArticleGetRequest { |
@@ -14,7 +14,7 @@ info( | @@ -14,7 +14,7 @@ info( | ||
14 | group: company | 14 | group: company |
15 | ) | 15 | ) |
16 | service Core { | 16 | service Core { |
17 | - @doc "公司搜索" | 17 | + @doc "公司搜索(公开的)" |
18 | @handler miniCompanySearch | 18 | @handler miniCompanySearch |
19 | post /mini/company/search(CompanySearchRequest) returns (CompanySearchResponse) | 19 | post /mini/company/search(CompanySearchRequest) returns (CompanySearchResponse) |
20 | } | 20 | } |
@@ -23,6 +23,18 @@ service Core { | @@ -23,6 +23,18 @@ service Core { | ||
23 | @server( | 23 | @server( |
24 | prefix: v1 | 24 | prefix: v1 |
25 | group: company | 25 | group: company |
26 | + jwt : MiniAuth | ||
27 | +) | ||
28 | +service Core { | ||
29 | + @doc "搜索已加入的公司" | ||
30 | + @handler miniCompanySearchJoined | ||
31 | + post /mini/company/search-joined(CompanySearchRequest) returns (CompanySearchResponse) | ||
32 | +} | ||
33 | + | ||
34 | +// 小程序接口 | ||
35 | +@server( | ||
36 | + prefix: v1 | ||
37 | + group: company | ||
26 | jwt : SystemAuth | 38 | jwt : SystemAuth |
27 | ) | 39 | ) |
28 | service Core { | 40 | service Core { |
@@ -33,9 +45,10 @@ service Core { | @@ -33,9 +45,10 @@ service Core { | ||
33 | 45 | ||
34 | type ( | 46 | type ( |
35 | CompanySearchRequest struct{ | 47 | CompanySearchRequest struct{ |
36 | - Page int `json:"page"` | ||
37 | - Size int `json:"size"` | ||
38 | - UserId int64 `json:"userId,optional"` // 按用户搜索 | 48 | + Page int `json:"page,optional"` |
49 | + Size int `json:"size,optional"` | ||
50 | + Flag int `json:"flag,optional"` // 1:用户已加入的 2:用户未加入的公司 | ||
51 | + UserId int64 `json:"userId,optional"` // 按用户搜索(用户所加入的企业) | ||
39 | Code string `json:"code,optional"` // 按编码搜索 | 52 | Code string `json:"code,optional"` // 按编码搜索 |
40 | } | 53 | } |
41 | CompanySearchResponse{ | 54 | CompanySearchResponse{ |
@@ -206,13 +206,26 @@ type ( | @@ -206,13 +206,26 @@ type ( | ||
206 | 206 | ||
207 | 207 | ||
208 | // 后台接口 | 208 | // 后台接口 |
209 | -//@server( | ||
210 | -// prefix: v1 | ||
211 | -// group: user | ||
212 | -// jwt: SystemAuth | ||
213 | -//) | ||
214 | -//service Core { | ||
215 | -// @doc "系统评论" | ||
216 | -// @handler systemUser | ||
217 | -// get /system/user () returns () | ||
218 | -//} | ||
209 | +@server( | ||
210 | + prefix: v1 | ||
211 | + group: user | ||
212 | + jwt: SystemAuth | ||
213 | +) | ||
214 | +service Core { | ||
215 | + @doc "系统用户信息" | ||
216 | + @handler systemUserInfo | ||
217 | + post /system/user/info(SystemUserInfoRequest) returns (SystemUserInfoResponse) | ||
218 | +} | ||
219 | + | ||
220 | +type( | ||
221 | + SystemUserInfoRequest{ | ||
222 | + | ||
223 | + } | ||
224 | + SystemUserInfoResponse{ | ||
225 | + UserId int64 `json:"userId"` | ||
226 | + UserName string `json:"userName"` | ||
227 | + Avatar string `json:"avatar"` | ||
228 | + CompanyId int64 `json:"companyId"` | ||
229 | + CompanyName string `json:"companyName"` | ||
230 | + } | ||
231 | +) |
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 | +} |
1 | +package company | ||
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/company" | ||
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 MiniCompanySearchJoinedHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | ||
14 | + return func(w http.ResponseWriter, r *http.Request) { | ||
15 | + var req types.CompanySearchRequest | ||
16 | + if err := httpx.Parse(r, &req); err != nil { | ||
17 | + httpx.ErrorCtx(r.Context(), w, err) | ||
18 | + return | ||
19 | + } | ||
20 | + | ||
21 | + l := company.NewMiniCompanySearchJoinedLogic(r.Context(), svcCtx) | ||
22 | + resp, err := l.MiniCompanySearchJoined(&req) | ||
23 | + result.HttpResult(r, w, resp, err) | ||
24 | + } | ||
25 | +} |
@@ -167,6 +167,18 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { | @@ -167,6 +167,18 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { | ||
167 | []rest.Route{ | 167 | []rest.Route{ |
168 | { | 168 | { |
169 | Method: http.MethodPost, | 169 | Method: http.MethodPost, |
170 | + Path: "/system/user/info", | ||
171 | + Handler: user.SystemUserInfoHandler(serverCtx), | ||
172 | + }, | ||
173 | + }, | ||
174 | + rest.WithJwt(serverCtx.Config.SystemAuth.AccessSecret), | ||
175 | + rest.WithPrefix("/v1"), | ||
176 | + ) | ||
177 | + | ||
178 | + server.AddRoutes( | ||
179 | + []rest.Route{ | ||
180 | + { | ||
181 | + Method: http.MethodPost, | ||
170 | Path: "/mini/company/search", | 182 | Path: "/mini/company/search", |
171 | Handler: company.MiniCompanySearchHandler(serverCtx), | 183 | Handler: company.MiniCompanySearchHandler(serverCtx), |
172 | }, | 184 | }, |
@@ -178,6 +190,18 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { | @@ -178,6 +190,18 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { | ||
178 | []rest.Route{ | 190 | []rest.Route{ |
179 | { | 191 | { |
180 | Method: http.MethodPost, | 192 | Method: http.MethodPost, |
193 | + Path: "/mini/company/search-joined", | ||
194 | + Handler: company.MiniCompanySearchJoinedHandler(serverCtx), | ||
195 | + }, | ||
196 | + }, | ||
197 | + rest.WithJwt(serverCtx.Config.MiniAuth.AccessSecret), | ||
198 | + rest.WithPrefix("/v1"), | ||
199 | + ) | ||
200 | + | ||
201 | + server.AddRoutes( | ||
202 | + []rest.Route{ | ||
203 | + { | ||
204 | + Method: http.MethodPost, | ||
181 | Path: "/system/company/search", | 205 | Path: "/system/company/search", |
182 | Handler: company.SystemCompanySearchHandler(serverCtx), | 206 | Handler: company.SystemCompanySearchHandler(serverCtx), |
183 | }, | 207 | }, |
@@ -215,6 +239,11 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { | @@ -215,6 +239,11 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { | ||
215 | }, | 239 | }, |
216 | { | 240 | { |
217 | Method: http.MethodPost, | 241 | Method: http.MethodPost, |
242 | + Path: "/article/mark/list", | ||
243 | + Handler: article.MiniArticleMarkListHandler(serverCtx), | ||
244 | + }, | ||
245 | + { | ||
246 | + Method: http.MethodPost, | ||
218 | Path: "/article/search/me", | 247 | Path: "/article/search/me", |
219 | Handler: article.MiniArticleSearchMeHandler(serverCtx), | 248 | Handler: article.MiniArticleSearchMeHandler(serverCtx), |
220 | }, | 249 | }, |
1 | +package user | ||
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/user" | ||
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 SystemUserInfoHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | ||
13 | + return func(w http.ResponseWriter, r *http.Request) { | ||
14 | + var req types.SystemUserInfoRequest | ||
15 | + if err := httpx.Parse(r, &req); err != nil { | ||
16 | + httpx.ErrorCtx(r.Context(), w, err) | ||
17 | + return | ||
18 | + } | ||
19 | + | ||
20 | + l := user.NewSystemUserInfoLogic(r.Context(), svcCtx) | ||
21 | + resp, err := l.SystemUserInfo(&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 | + "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 | +} |
1 | +package company | ||
2 | + | ||
3 | +import ( | ||
4 | + "context" | ||
5 | + "github.com/samber/lo" | ||
6 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain" | ||
7 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/contextdata" | ||
8 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr" | ||
9 | + | ||
10 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | ||
11 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" | ||
12 | + | ||
13 | + "github.com/zeromicro/go-zero/core/logx" | ||
14 | +) | ||
15 | + | ||
16 | +type MiniCompanySearchJoinedLogic struct { | ||
17 | + logx.Logger | ||
18 | + ctx context.Context | ||
19 | + svcCtx *svc.ServiceContext | ||
20 | +} | ||
21 | + | ||
22 | +func NewMiniCompanySearchJoinedLogic(ctx context.Context, svcCtx *svc.ServiceContext) *MiniCompanySearchJoinedLogic { | ||
23 | + return &MiniCompanySearchJoinedLogic{ | ||
24 | + Logger: logx.WithContext(ctx), | ||
25 | + ctx: ctx, | ||
26 | + svcCtx: svcCtx, | ||
27 | + } | ||
28 | +} | ||
29 | + | ||
30 | +func (l *MiniCompanySearchJoinedLogic) MiniCompanySearchJoined(req *types.CompanySearchRequest) (resp *types.CompanySearchResponse, err error) { | ||
31 | + var ( | ||
32 | + conn = l.svcCtx.DefaultDBConn() | ||
33 | + companyList []*domain.Company | ||
34 | + total int64 | ||
35 | + userToken = contextdata.GetUserTokenFromCtx(l.ctx) | ||
36 | + user *domain.User | ||
37 | + companyIds []int64 | ||
38 | + ) | ||
39 | + queryOptions := domain.NewQueryOptions() | ||
40 | + if req.Page != 0 { | ||
41 | + queryOptions.WithOffsetLimit(req.Page, req.Size) | ||
42 | + } | ||
43 | + user, err = l.svcCtx.UserRepository.FindOne(l.ctx, conn, userToken.UserId) | ||
44 | + if err != nil { | ||
45 | + return nil, xerr.NewErrMsgErr("账号有误", err) | ||
46 | + } | ||
47 | + resp = &types.CompanySearchResponse{ | ||
48 | + List: make([]types.Company, 0), | ||
49 | + } | ||
50 | + _, users, _ := l.svcCtx.UserRepository.Find(l.ctx, conn, domain.NewQueryOptions(). | ||
51 | + MustWithKV("phone", user.Phone). | ||
52 | + MustWithKV("auditStatus", []int{domain.UserAuditStatusPassed}). | ||
53 | + WithFindOnly()) | ||
54 | + lo.ForEach(users, func(item *domain.User, index int) { | ||
55 | + companyIds = append(companyIds, item.CompanyId) | ||
56 | + }) | ||
57 | + if req.Flag == 1 { | ||
58 | + total, companyList, err = l.svcCtx.CompanyRepository.Find(l.ctx, conn, queryOptions.MustWithKV("ids", companyIds)) | ||
59 | + if err != nil { | ||
60 | + return nil, xerr.NewErrMsgErr("公司列表获取失败", err) | ||
61 | + } | ||
62 | + } else { | ||
63 | + total, companyList, err = l.svcCtx.CompanyRepository.Find(l.ctx, conn, queryOptions.MustWithKV("excludeIds", companyIds)) | ||
64 | + if err != nil { | ||
65 | + return nil, xerr.NewErrMsgErr("公司列表获取失败", err) | ||
66 | + } | ||
67 | + } | ||
68 | + lo.ForEach(companyList, func(item *domain.Company, index int) { | ||
69 | + resp.List = append(resp.List, NewCompany(item)) | ||
70 | + }) | ||
71 | + resp.Total = total | ||
72 | + return | ||
73 | +} |
@@ -2,9 +2,11 @@ package company | @@ -2,9 +2,11 @@ package company | ||
2 | 2 | ||
3 | import ( | 3 | import ( |
4 | "context" | 4 | "context" |
5 | - | 5 | + "github.com/samber/lo" |
6 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | 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" | 7 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" |
8 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain" | ||
9 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr" | ||
8 | 10 | ||
9 | "github.com/zeromicro/go-zero/core/logx" | 11 | "github.com/zeromicro/go-zero/core/logx" |
10 | ) | 12 | ) |
@@ -24,7 +26,37 @@ func NewMiniCompanySearchLogic(ctx context.Context, svcCtx *svc.ServiceContext) | @@ -24,7 +26,37 @@ func NewMiniCompanySearchLogic(ctx context.Context, svcCtx *svc.ServiceContext) | ||
24 | } | 26 | } |
25 | 27 | ||
26 | func (l *MiniCompanySearchLogic) MiniCompanySearch(req *types.CompanySearchRequest) (resp *types.CompanySearchResponse, err error) { | 28 | func (l *MiniCompanySearchLogic) MiniCompanySearch(req *types.CompanySearchRequest) (resp *types.CompanySearchResponse, err error) { |
27 | - // todo: add your logic here and delete this line | ||
28 | - | 29 | + var ( |
30 | + conn = l.svcCtx.DefaultDBConn() | ||
31 | + companyList []*domain.Company | ||
32 | + total int64 | ||
33 | + ) | ||
34 | + queryOptions := domain.NewQueryOptions() | ||
35 | + if req.Page != 0 { | ||
36 | + queryOptions.WithOffsetLimit(req.Page, req.Size) | ||
37 | + } | ||
38 | + if req.Code != "" { | ||
39 | + queryOptions.WithKV("code", req.Code) | ||
40 | + } | ||
41 | + total, companyList, err = l.svcCtx.CompanyRepository.Find(l.ctx, conn, queryOptions) | ||
42 | + if err != nil { | ||
43 | + return nil, xerr.NewErrMsgErr("公司列表获取失败", err) | ||
44 | + } | ||
45 | + resp = &types.CompanySearchResponse{ | ||
46 | + Total: total, | ||
47 | + List: make([]types.Company, 0), | ||
48 | + } | ||
49 | + lo.ForEach(companyList, func(item *domain.Company, index int) { | ||
50 | + resp.List = append(resp.List, NewCompany(item)) | ||
51 | + }) | ||
29 | return | 52 | return |
30 | } | 53 | } |
54 | + | ||
55 | +func NewCompany(item *domain.Company) types.Company { | ||
56 | + return types.Company{ | ||
57 | + Id: item.Id, | ||
58 | + Name: item.Name, | ||
59 | + Code: item.Code, | ||
60 | + Logo: item.Logo, | ||
61 | + } | ||
62 | +} |
1 | +package user | ||
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 SystemUserInfoLogic struct { | ||
13 | + logx.Logger | ||
14 | + ctx context.Context | ||
15 | + svcCtx *svc.ServiceContext | ||
16 | +} | ||
17 | + | ||
18 | +func NewSystemUserInfoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SystemUserInfoLogic { | ||
19 | + return &SystemUserInfoLogic{ | ||
20 | + Logger: logx.WithContext(ctx), | ||
21 | + ctx: ctx, | ||
22 | + svcCtx: svcCtx, | ||
23 | + } | ||
24 | +} | ||
25 | + | ||
26 | +func (l *SystemUserInfoLogic) SystemUserInfo(req *types.SystemUserInfoRequest) (resp *types.SystemUserInfoResponse, err error) { | ||
27 | + // todo: add your logic here and delete this line | ||
28 | + | ||
29 | + return | ||
30 | +} |
@@ -227,6 +227,26 @@ type MiniArticleDraftDeleteMeResponse struct { | @@ -227,6 +227,26 @@ type MiniArticleDraftDeleteMeResponse struct { | ||
227 | Id int64 `json:"id"` // | 227 | Id int64 `json:"id"` // |
228 | } | 228 | } |
229 | 229 | ||
230 | +type MiniArticleMarkListRequest struct { | ||
231 | + Page int `json:"page"` | ||
232 | + Size int `json:"size"` | ||
233 | +} | ||
234 | + | ||
235 | +type MiniArticleMarkListResponse struct { | ||
236 | + Total int64 `json:"total"` | ||
237 | + List []MiniArticleMarkItem `json:"list"` | ||
238 | +} | ||
239 | + | ||
240 | +type MiniArticleMarkItem struct { | ||
241 | + Id int64 `json:"id"` | ||
242 | + CompanyId int64 `json:"companyId"` | ||
243 | + UserId int64 `json:"userId"` | ||
244 | + ArticleId int64 `json:"articleId"` | ||
245 | + Title string `json:"title"` | ||
246 | + Author SimpleUser `json:"author"` // 发布人 | ||
247 | + UpdatedAt int64 `json:"updatedAt"` | ||
248 | +} | ||
249 | + | ||
230 | type SystemArticleGetRequest struct { | 250 | type SystemArticleGetRequest struct { |
231 | Id int64 `path:"id"` //id | 251 | Id int64 `path:"id"` //id |
232 | CompanyId int64 `path:",optional"` | 252 | CompanyId int64 `path:",optional"` |
@@ -575,10 +595,22 @@ type SimpleComment struct { | @@ -575,10 +595,22 @@ type SimpleComment struct { | ||
575 | Show int `json:"show"` // 评论的展示状态(0显示、1不显示) | 595 | Show int `json:"show"` // 评论的展示状态(0显示、1不显示) |
576 | } | 596 | } |
577 | 597 | ||
598 | +type SystemUserInfoRequest struct { | ||
599 | +} | ||
600 | + | ||
601 | +type SystemUserInfoResponse struct { | ||
602 | + UserId int64 `json:"userId"` | ||
603 | + UserName string `json:"userName"` | ||
604 | + Avatar string `json:"avatar"` | ||
605 | + CompanyId int64 `json:"companyId"` | ||
606 | + CompanyName string `json:"companyName"` | ||
607 | +} | ||
608 | + | ||
578 | type CompanySearchRequest struct { | 609 | type CompanySearchRequest struct { |
579 | - Page int `json:"page"` | ||
580 | - Size int `json:"size"` | ||
581 | - UserId int64 `json:"userId,optional"` // 按用户搜索 | 610 | + Page int `json:"page,optional"` |
611 | + Size int `json:"size,optional"` | ||
612 | + Flag int `json:"flag,optional"` // 1:用户已加入的 2:用户未加入的公司 | ||
613 | + UserId int64 `json:"userId,optional"` // 按用户搜索(用户所加入的企业) | ||
582 | Code string `json:"code,optional"` // 按编码搜索 | 614 | Code string `json:"code,optional"` // 按编码搜索 |
583 | } | 615 | } |
584 | 616 |
@@ -142,6 +142,9 @@ func (repository *CompanyRepository) Find(ctx context.Context, conn transaction. | @@ -142,6 +142,9 @@ func (repository *CompanyRepository) Find(ctx context.Context, conn transaction. | ||
142 | if v, ok := queryOptions["ids"]; ok { | 142 | if v, ok := queryOptions["ids"]; ok { |
143 | tx.Where("id in (?)", v) | 143 | tx.Where("id in (?)", v) |
144 | } | 144 | } |
145 | + if v, ok := queryOptions["excludeIds"]; ok { | ||
146 | + tx.Where("id not in (?)", v) | ||
147 | + } | ||
145 | if total, tx = transaction.PaginationAndCount(ctx, tx, queryOptions, &ms); tx.Error != nil { | 148 | if total, tx = transaction.PaginationAndCount(ctx, tx, queryOptions, &ms); tx.Error != nil { |
146 | return dms, tx.Error | 149 | return dms, tx.Error |
147 | } | 150 | } |
-
请 注册 或 登录 后发表评论