正在显示
31 个修改的文件
包含
1813 行增加
和
26 行删除
| @@ -669,6 +669,148 @@ | @@ -669,6 +669,148 @@ | ||
| 669 | ] | 669 | ] |
| 670 | } | 670 | } |
| 671 | }, | 671 | }, |
| 672 | + "v1/system/account": { | ||
| 673 | + "post": { | ||
| 674 | + "summary": "系统新增账号", | ||
| 675 | + "operationId": "systemUserAccountSave", | ||
| 676 | + "responses": { | ||
| 677 | + "200": { | ||
| 678 | + "description": "A successful response.", | ||
| 679 | + "schema": { | ||
| 680 | + "$ref": "#/definitions/SystemUserAccountSaveResponse" | ||
| 681 | + } | ||
| 682 | + } | ||
| 683 | + }, | ||
| 684 | + "parameters": [ | ||
| 685 | + { | ||
| 686 | + "name": "body", | ||
| 687 | + "in": "body", | ||
| 688 | + "required": true, | ||
| 689 | + "schema": { | ||
| 690 | + "$ref": "#/definitions/SystemUserAccountSaveRequest" | ||
| 691 | + } | ||
| 692 | + } | ||
| 693 | + ], | ||
| 694 | + "requestBody": {}, | ||
| 695 | + "tags": [ | ||
| 696 | + "user" | ||
| 697 | + ] | ||
| 698 | + } | ||
| 699 | + }, | ||
| 700 | + "v1/system/account/enable": { | ||
| 701 | + "post": { | ||
| 702 | + "summary": "系统启用/禁用账号", | ||
| 703 | + "operationId": "systemUserAccountEnable", | ||
| 704 | + "responses": { | ||
| 705 | + "200": { | ||
| 706 | + "description": "A successful response.", | ||
| 707 | + "schema": { | ||
| 708 | + "$ref": "#/definitions/SystemUserAccountEnableResponse" | ||
| 709 | + } | ||
| 710 | + } | ||
| 711 | + }, | ||
| 712 | + "parameters": [ | ||
| 713 | + { | ||
| 714 | + "name": "body", | ||
| 715 | + "in": "body", | ||
| 716 | + "required": true, | ||
| 717 | + "schema": { | ||
| 718 | + "$ref": "#/definitions/SystemUserAccountEnableRequest" | ||
| 719 | + } | ||
| 720 | + } | ||
| 721 | + ], | ||
| 722 | + "requestBody": {}, | ||
| 723 | + "tags": [ | ||
| 724 | + "user" | ||
| 725 | + ] | ||
| 726 | + } | ||
| 727 | + }, | ||
| 728 | + "v1/system/account/search": { | ||
| 729 | + "post": { | ||
| 730 | + "summary": "系统搜索账号", | ||
| 731 | + "operationId": "systemUserAccountSearch", | ||
| 732 | + "responses": { | ||
| 733 | + "200": { | ||
| 734 | + "description": "A successful response.", | ||
| 735 | + "schema": { | ||
| 736 | + "$ref": "#/definitions/SystemUserAccountSearchResponse" | ||
| 737 | + } | ||
| 738 | + } | ||
| 739 | + }, | ||
| 740 | + "parameters": [ | ||
| 741 | + { | ||
| 742 | + "name": "body", | ||
| 743 | + "in": "body", | ||
| 744 | + "required": true, | ||
| 745 | + "schema": { | ||
| 746 | + "$ref": "#/definitions/SystemUserAccountSearchRequest" | ||
| 747 | + } | ||
| 748 | + } | ||
| 749 | + ], | ||
| 750 | + "requestBody": {}, | ||
| 751 | + "tags": [ | ||
| 752 | + "user" | ||
| 753 | + ] | ||
| 754 | + } | ||
| 755 | + }, | ||
| 756 | + "v1/system/account/{id}": { | ||
| 757 | + "get": { | ||
| 758 | + "summary": "系统账号详情", | ||
| 759 | + "operationId": "systemUserAccountGet", | ||
| 760 | + "responses": { | ||
| 761 | + "200": { | ||
| 762 | + "description": "A successful response.", | ||
| 763 | + "schema": { | ||
| 764 | + "$ref": "#/definitions/SystemUserAccountGetResponse" | ||
| 765 | + } | ||
| 766 | + } | ||
| 767 | + }, | ||
| 768 | + "parameters": [ | ||
| 769 | + { | ||
| 770 | + "name": "id", | ||
| 771 | + "in": "path", | ||
| 772 | + "required": true, | ||
| 773 | + "type": "string" | ||
| 774 | + } | ||
| 775 | + ], | ||
| 776 | + "requestBody": {}, | ||
| 777 | + "tags": [ | ||
| 778 | + "user" | ||
| 779 | + ] | ||
| 780 | + }, | ||
| 781 | + "put": { | ||
| 782 | + "summary": "系统更新账号", | ||
| 783 | + "operationId": "systemUserAccountUpdate", | ||
| 784 | + "responses": { | ||
| 785 | + "200": { | ||
| 786 | + "description": "A successful response.", | ||
| 787 | + "schema": { | ||
| 788 | + "$ref": "#/definitions/SystemUserAccountUpdateResponse" | ||
| 789 | + } | ||
| 790 | + } | ||
| 791 | + }, | ||
| 792 | + "parameters": [ | ||
| 793 | + { | ||
| 794 | + "name": "id", | ||
| 795 | + "in": "path", | ||
| 796 | + "required": true, | ||
| 797 | + "type": "string" | ||
| 798 | + }, | ||
| 799 | + { | ||
| 800 | + "name": "body", | ||
| 801 | + "in": "body", | ||
| 802 | + "required": true, | ||
| 803 | + "schema": { | ||
| 804 | + "$ref": "#/definitions/SystemUserAccountUpdateRequest" | ||
| 805 | + } | ||
| 806 | + } | ||
| 807 | + ], | ||
| 808 | + "requestBody": {}, | ||
| 809 | + "tags": [ | ||
| 810 | + "user" | ||
| 811 | + ] | ||
| 812 | + } | ||
| 813 | + }, | ||
| 672 | "v1/system/article/search": { | 814 | "v1/system/article/search": { |
| 673 | "post": { | 815 | "post": { |
| 674 | "summary": "管理后台获取文章列表", | 816 | "summary": "管理后台获取文章列表", |
| @@ -1078,6 +1220,120 @@ | @@ -1078,6 +1220,120 @@ | ||
| 1078 | ] | 1220 | ] |
| 1079 | } | 1221 | } |
| 1080 | }, | 1222 | }, |
| 1223 | + "v1/system/user/search": { | ||
| 1224 | + "post": { | ||
| 1225 | + "summary": "搜索用户", | ||
| 1226 | + "operationId": "systemUserSearch", | ||
| 1227 | + "responses": { | ||
| 1228 | + "200": { | ||
| 1229 | + "description": "A successful response.", | ||
| 1230 | + "schema": { | ||
| 1231 | + "$ref": "#/definitions/SystemUserSearchResponse" | ||
| 1232 | + } | ||
| 1233 | + } | ||
| 1234 | + }, | ||
| 1235 | + "parameters": [ | ||
| 1236 | + { | ||
| 1237 | + "name": "body", | ||
| 1238 | + "in": "body", | ||
| 1239 | + "required": true, | ||
| 1240 | + "schema": { | ||
| 1241 | + "$ref": "#/definitions/SystemUserSearchRequest" | ||
| 1242 | + } | ||
| 1243 | + } | ||
| 1244 | + ], | ||
| 1245 | + "requestBody": {}, | ||
| 1246 | + "tags": [ | ||
| 1247 | + "user" | ||
| 1248 | + ] | ||
| 1249 | + } | ||
| 1250 | + }, | ||
| 1251 | + "v1/system/user/statistics": { | ||
| 1252 | + "post": { | ||
| 1253 | + "summary": "用户统计", | ||
| 1254 | + "operationId": "systemUserStatistics", | ||
| 1255 | + "responses": { | ||
| 1256 | + "200": { | ||
| 1257 | + "description": "A successful response.", | ||
| 1258 | + "schema": { | ||
| 1259 | + "$ref": "#/definitions/UserStatisticsResponse" | ||
| 1260 | + } | ||
| 1261 | + } | ||
| 1262 | + }, | ||
| 1263 | + "parameters": [ | ||
| 1264 | + { | ||
| 1265 | + "name": "body", | ||
| 1266 | + "in": "body", | ||
| 1267 | + "required": true, | ||
| 1268 | + "schema": { | ||
| 1269 | + "$ref": "#/definitions/UserStatisticsRequest" | ||
| 1270 | + } | ||
| 1271 | + } | ||
| 1272 | + ], | ||
| 1273 | + "requestBody": {}, | ||
| 1274 | + "tags": [ | ||
| 1275 | + "user" | ||
| 1276 | + ] | ||
| 1277 | + } | ||
| 1278 | + }, | ||
| 1279 | + "v1/system/user/{id}": { | ||
| 1280 | + "get": { | ||
| 1281 | + "summary": "用户详情", | ||
| 1282 | + "operationId": "systemUserGet", | ||
| 1283 | + "responses": { | ||
| 1284 | + "200": { | ||
| 1285 | + "description": "A successful response.", | ||
| 1286 | + "schema": { | ||
| 1287 | + "$ref": "#/definitions/SystemUserGetResponse" | ||
| 1288 | + } | ||
| 1289 | + } | ||
| 1290 | + }, | ||
| 1291 | + "parameters": [ | ||
| 1292 | + { | ||
| 1293 | + "name": "id", | ||
| 1294 | + "in": "path", | ||
| 1295 | + "required": true, | ||
| 1296 | + "type": "string" | ||
| 1297 | + } | ||
| 1298 | + ], | ||
| 1299 | + "requestBody": {}, | ||
| 1300 | + "tags": [ | ||
| 1301 | + "user" | ||
| 1302 | + ] | ||
| 1303 | + }, | ||
| 1304 | + "put": { | ||
| 1305 | + "summary": "更新用户", | ||
| 1306 | + "operationId": "systemUserUpdate", | ||
| 1307 | + "responses": { | ||
| 1308 | + "200": { | ||
| 1309 | + "description": "A successful response.", | ||
| 1310 | + "schema": { | ||
| 1311 | + "$ref": "#/definitions/SystemUserUpdateResponse" | ||
| 1312 | + } | ||
| 1313 | + } | ||
| 1314 | + }, | ||
| 1315 | + "parameters": [ | ||
| 1316 | + { | ||
| 1317 | + "name": "id", | ||
| 1318 | + "in": "path", | ||
| 1319 | + "required": true, | ||
| 1320 | + "type": "string" | ||
| 1321 | + }, | ||
| 1322 | + { | ||
| 1323 | + "name": "body", | ||
| 1324 | + "in": "body", | ||
| 1325 | + "required": true, | ||
| 1326 | + "schema": { | ||
| 1327 | + "$ref": "#/definitions/SystemUserUpdateRequest" | ||
| 1328 | + } | ||
| 1329 | + } | ||
| 1330 | + ], | ||
| 1331 | + "requestBody": {}, | ||
| 1332 | + "tags": [ | ||
| 1333 | + "user" | ||
| 1334 | + ] | ||
| 1335 | + } | ||
| 1336 | + }, | ||
| 1081 | "v1/user/mylike": { | 1337 | "v1/user/mylike": { |
| 1082 | "post": { | 1338 | "post": { |
| 1083 | "summary": "我点赞的文章或评论", | 1339 | "summary": "我点赞的文章或评论", |
| @@ -2810,6 +3066,26 @@ | @@ -2810,6 +3066,26 @@ | ||
| 2810 | "position" | 3066 | "position" |
| 2811 | ] | 3067 | ] |
| 2812 | }, | 3068 | }, |
| 3069 | + "StatisticsItem": { | ||
| 3070 | + "type": "object", | ||
| 3071 | + "properties": { | ||
| 3072 | + "itemFlag": { | ||
| 3073 | + "type": "integer", | ||
| 3074 | + "format": "int32", | ||
| 3075 | + "description": " 1:他的帖子 2:他的评论/回复 4:他收到的赞 8:TA的圆桌讨论 16:被采纳" | ||
| 3076 | + }, | ||
| 3077 | + "value": { | ||
| 3078 | + "type": "number", | ||
| 3079 | + "format": "double", | ||
| 3080 | + "description": " 统计值" | ||
| 3081 | + } | ||
| 3082 | + }, | ||
| 3083 | + "title": "StatisticsItem", | ||
| 3084 | + "required": [ | ||
| 3085 | + "itemFlag", | ||
| 3086 | + "value" | ||
| 3087 | + ] | ||
| 3088 | + }, | ||
| 2813 | "SystemArticleGetRequest": { | 3089 | "SystemArticleGetRequest": { |
| 2814 | "type": "object", | 3090 | "type": "object", |
| 2815 | "properties": { | 3091 | "properties": { |
| @@ -3055,32 +3331,308 @@ | @@ -3055,32 +3331,308 @@ | ||
| 3055 | "list" | 3331 | "list" |
| 3056 | ] | 3332 | ] |
| 3057 | }, | 3333 | }, |
| 3058 | - "SystemUserInfoRequest": { | ||
| 3059 | - "type": "object", | ||
| 3060 | - "title": "SystemUserInfoRequest" | ||
| 3061 | - }, | ||
| 3062 | - "SystemUserInfoResponse": { | 3334 | + "SystemUser": { |
| 3063 | "type": "object", | 3335 | "type": "object", |
| 3064 | "properties": { | 3336 | "properties": { |
| 3065 | - "userId": { | 3337 | + "id": { |
| 3066 | "type": "integer", | 3338 | "type": "integer", |
| 3067 | - "format": "int64" | 3339 | + "format": "int64", |
| 3340 | + "description": " 用户ID" | ||
| 3068 | }, | 3341 | }, |
| 3069 | - "userName": { | ||
| 3070 | - "type": "string" | 3342 | + "name": { |
| 3343 | + "type": "string", | ||
| 3344 | + "description": " 名称" | ||
| 3071 | }, | 3345 | }, |
| 3072 | "avatar": { | 3346 | "avatar": { |
| 3073 | - "type": "string" | ||
| 3074 | - }, | ||
| 3075 | - "companyId": { | ||
| 3076 | - "type": "integer", | ||
| 3077 | - "format": "int64" | 3347 | + "type": "string", |
| 3348 | + "description": " 头像" | ||
| 3078 | }, | 3349 | }, |
| 3079 | - "companyName": { | ||
| 3080 | - "type": "string" | ||
| 3081 | - } | 3350 | + "phone": { |
| 3351 | + "type": "string", | ||
| 3352 | + "description": " 手机号 唯一" | ||
| 3082 | }, | 3353 | }, |
| 3083 | - "title": "SystemUserInfoResponse", | 3354 | + "position": { |
| 3355 | + "type": "string", | ||
| 3356 | + "description": " 职位" | ||
| 3357 | + }, | ||
| 3358 | + "enable": { | ||
| 3359 | + "type": "integer", | ||
| 3360 | + "format": "int32", | ||
| 3361 | + "description": " 启用状态 1:启用 2:禁用" | ||
| 3362 | + }, | ||
| 3363 | + "departments": { | ||
| 3364 | + "type": "array", | ||
| 3365 | + "items": { | ||
| 3366 | + "type": "integer", | ||
| 3367 | + "format": "int64" | ||
| 3368 | + }, | ||
| 3369 | + "description": " 所属部门" | ||
| 3370 | + }, | ||
| 3371 | + "accountFrom": { | ||
| 3372 | + "type": "string", | ||
| 3373 | + "description": " 账号来源 后台新增、扫码注册" | ||
| 3374 | + }, | ||
| 3375 | + "createdAt": { | ||
| 3376 | + "type": "integer", | ||
| 3377 | + "format": "int64", | ||
| 3378 | + "description": " 注册时间" | ||
| 3379 | + }, | ||
| 3380 | + "roles": { | ||
| 3381 | + "type": "array", | ||
| 3382 | + "items": { | ||
| 3383 | + "type": "integer", | ||
| 3384 | + "format": "int64" | ||
| 3385 | + }, | ||
| 3386 | + "description": " 角色" | ||
| 3387 | + }, | ||
| 3388 | + "rolesDesc": { | ||
| 3389 | + "type": "string", | ||
| 3390 | + "description": " 角色描述" | ||
| 3391 | + }, | ||
| 3392 | + "departmentsDesc": { | ||
| 3393 | + "type": "string", | ||
| 3394 | + "description": " 部门描述" | ||
| 3395 | + } | ||
| 3396 | + }, | ||
| 3397 | + "title": "SystemUser", | ||
| 3398 | + "required": [ | ||
| 3399 | + "id", | ||
| 3400 | + "name", | ||
| 3401 | + "avatar", | ||
| 3402 | + "phone", | ||
| 3403 | + "position", | ||
| 3404 | + "enable", | ||
| 3405 | + "departments", | ||
| 3406 | + "accountFrom", | ||
| 3407 | + "createdAt", | ||
| 3408 | + "roles", | ||
| 3409 | + "rolesDesc", | ||
| 3410 | + "departmentsDesc" | ||
| 3411 | + ] | ||
| 3412 | + }, | ||
| 3413 | + "SystemUserAccountEnableRequest": { | ||
| 3414 | + "type": "object", | ||
| 3415 | + "properties": { | ||
| 3416 | + "userIds": { | ||
| 3417 | + "type": "array", | ||
| 3418 | + "items": { | ||
| 3419 | + "type": "integer", | ||
| 3420 | + "format": "int64" | ||
| 3421 | + }, | ||
| 3422 | + "description": " 用户ID列表" | ||
| 3423 | + }, | ||
| 3424 | + "status": { | ||
| 3425 | + "type": "integer", | ||
| 3426 | + "format": "int32", | ||
| 3427 | + "description": " 状态 1:启用 2:禁用" | ||
| 3428 | + } | ||
| 3429 | + }, | ||
| 3430 | + "title": "SystemUserAccountEnableRequest", | ||
| 3431 | + "required": [ | ||
| 3432 | + "userIds", | ||
| 3433 | + "status" | ||
| 3434 | + ] | ||
| 3435 | + }, | ||
| 3436 | + "SystemUserAccountEnableResponse": { | ||
| 3437 | + "type": "object", | ||
| 3438 | + "title": "SystemUserAccountEnableResponse" | ||
| 3439 | + }, | ||
| 3440 | + "SystemUserAccountGetRequest": { | ||
| 3441 | + "type": "object", | ||
| 3442 | + "properties": { | ||
| 3443 | + "id": { | ||
| 3444 | + "type": "integer", | ||
| 3445 | + "format": "int64" | ||
| 3446 | + } | ||
| 3447 | + }, | ||
| 3448 | + "title": "SystemUserAccountGetRequest", | ||
| 3449 | + "required": [ | ||
| 3450 | + "id" | ||
| 3451 | + ] | ||
| 3452 | + }, | ||
| 3453 | + "SystemUserAccountGetResponse": { | ||
| 3454 | + "type": "object", | ||
| 3455 | + "properties": { | ||
| 3456 | + "user": { | ||
| 3457 | + "$ref": "#/definitions/SystemUser" | ||
| 3458 | + } | ||
| 3459 | + }, | ||
| 3460 | + "title": "SystemUserAccountGetResponse", | ||
| 3461 | + "required": [ | ||
| 3462 | + "user" | ||
| 3463 | + ] | ||
| 3464 | + }, | ||
| 3465 | + "SystemUserAccountSaveRequest": { | ||
| 3466 | + "type": "object", | ||
| 3467 | + "properties": { | ||
| 3468 | + "name": { | ||
| 3469 | + "type": "string", | ||
| 3470 | + "description": " 名称" | ||
| 3471 | + }, | ||
| 3472 | + "phone": { | ||
| 3473 | + "type": "string", | ||
| 3474 | + "description": " 手机号 唯一" | ||
| 3475 | + }, | ||
| 3476 | + "enable": { | ||
| 3477 | + "type": "integer", | ||
| 3478 | + "format": "int32", | ||
| 3479 | + "description": " 启用状态 1:启用 2:禁用" | ||
| 3480 | + }, | ||
| 3481 | + "roles": { | ||
| 3482 | + "type": "array", | ||
| 3483 | + "items": { | ||
| 3484 | + "type": "integer", | ||
| 3485 | + "format": "int64" | ||
| 3486 | + }, | ||
| 3487 | + "description": " 角色" | ||
| 3488 | + } | ||
| 3489 | + }, | ||
| 3490 | + "title": "SystemUserAccountSaveRequest", | ||
| 3491 | + "required": [ | ||
| 3492 | + "name", | ||
| 3493 | + "phone", | ||
| 3494 | + "enable", | ||
| 3495 | + "roles" | ||
| 3496 | + ] | ||
| 3497 | + }, | ||
| 3498 | + "SystemUserAccountSaveResponse": { | ||
| 3499 | + "type": "object", | ||
| 3500 | + "title": "SystemUserAccountSaveResponse" | ||
| 3501 | + }, | ||
| 3502 | + "SystemUserAccountSearchRequest": { | ||
| 3503 | + "type": "object", | ||
| 3504 | + "properties": { | ||
| 3505 | + "page": { | ||
| 3506 | + "type": "integer", | ||
| 3507 | + "format": "int32" | ||
| 3508 | + }, | ||
| 3509 | + "size": { | ||
| 3510 | + "type": "integer", | ||
| 3511 | + "format": "int32" | ||
| 3512 | + }, | ||
| 3513 | + "name": { | ||
| 3514 | + "type": "string", | ||
| 3515 | + "description": " 名称" | ||
| 3516 | + }, | ||
| 3517 | + "phone": { | ||
| 3518 | + "type": "string", | ||
| 3519 | + "description": " 手机号 唯一" | ||
| 3520 | + }, | ||
| 3521 | + "roleId": { | ||
| 3522 | + "type": "integer", | ||
| 3523 | + "format": "int64", | ||
| 3524 | + "description": " 角色权限" | ||
| 3525 | + }, | ||
| 3526 | + "enable": { | ||
| 3527 | + "type": "integer", | ||
| 3528 | + "format": "int32", | ||
| 3529 | + "description": " 启用状态 1:启用 2:禁用" | ||
| 3530 | + }, | ||
| 3531 | + "beginTime": { | ||
| 3532 | + "type": "integer", | ||
| 3533 | + "format": "int64", | ||
| 3534 | + "description": " 注册日期-开始" | ||
| 3535 | + }, | ||
| 3536 | + "endTime": { | ||
| 3537 | + "type": "integer", | ||
| 3538 | + "format": "int64", | ||
| 3539 | + "description": " 注册日期-结束" | ||
| 3540 | + } | ||
| 3541 | + }, | ||
| 3542 | + "title": "SystemUserAccountSearchRequest", | ||
| 3543 | + "required": [ | ||
| 3544 | + "page", | ||
| 3545 | + "size" | ||
| 3546 | + ] | ||
| 3547 | + }, | ||
| 3548 | + "SystemUserAccountSearchResponse": { | ||
| 3549 | + "type": "object", | ||
| 3550 | + "properties": { | ||
| 3551 | + "list": { | ||
| 3552 | + "type": "array", | ||
| 3553 | + "items": { | ||
| 3554 | + "$ref": "#/definitions/SystemUser" | ||
| 3555 | + } | ||
| 3556 | + }, | ||
| 3557 | + "total": { | ||
| 3558 | + "type": "integer", | ||
| 3559 | + "format": "int64" | ||
| 3560 | + } | ||
| 3561 | + }, | ||
| 3562 | + "title": "SystemUserAccountSearchResponse", | ||
| 3563 | + "required": [ | ||
| 3564 | + "list", | ||
| 3565 | + "total" | ||
| 3566 | + ] | ||
| 3567 | + }, | ||
| 3568 | + "SystemUserAccountUpdateRequest": { | ||
| 3569 | + "type": "object", | ||
| 3570 | + "properties": { | ||
| 3571 | + "id": { | ||
| 3572 | + "type": "integer", | ||
| 3573 | + "format": "int64" | ||
| 3574 | + } | ||
| 3575 | + }, | ||
| 3576 | + "title": "SystemUserAccountUpdateRequest", | ||
| 3577 | + "required": [ | ||
| 3578 | + "id" | ||
| 3579 | + ] | ||
| 3580 | + }, | ||
| 3581 | + "SystemUserAccountUpdateResponse": { | ||
| 3582 | + "type": "object", | ||
| 3583 | + "title": "SystemUserAccountUpdateResponse" | ||
| 3584 | + }, | ||
| 3585 | + "SystemUserGetRequest": { | ||
| 3586 | + "type": "object", | ||
| 3587 | + "properties": { | ||
| 3588 | + "id": { | ||
| 3589 | + "type": "integer", | ||
| 3590 | + "format": "int64" | ||
| 3591 | + } | ||
| 3592 | + }, | ||
| 3593 | + "title": "SystemUserGetRequest", | ||
| 3594 | + "required": [ | ||
| 3595 | + "id" | ||
| 3596 | + ] | ||
| 3597 | + }, | ||
| 3598 | + "SystemUserGetResponse": { | ||
| 3599 | + "type": "object", | ||
| 3600 | + "properties": { | ||
| 3601 | + "user": { | ||
| 3602 | + "$ref": "#/definitions/SystemUser" | ||
| 3603 | + } | ||
| 3604 | + }, | ||
| 3605 | + "title": "SystemUserGetResponse", | ||
| 3606 | + "required": [ | ||
| 3607 | + "user" | ||
| 3608 | + ] | ||
| 3609 | + }, | ||
| 3610 | + "SystemUserInfoRequest": { | ||
| 3611 | + "type": "object", | ||
| 3612 | + "title": "SystemUserInfoRequest" | ||
| 3613 | + }, | ||
| 3614 | + "SystemUserInfoResponse": { | ||
| 3615 | + "type": "object", | ||
| 3616 | + "properties": { | ||
| 3617 | + "userId": { | ||
| 3618 | + "type": "integer", | ||
| 3619 | + "format": "int64" | ||
| 3620 | + }, | ||
| 3621 | + "userName": { | ||
| 3622 | + "type": "string" | ||
| 3623 | + }, | ||
| 3624 | + "avatar": { | ||
| 3625 | + "type": "string" | ||
| 3626 | + }, | ||
| 3627 | + "companyId": { | ||
| 3628 | + "type": "integer", | ||
| 3629 | + "format": "int64" | ||
| 3630 | + }, | ||
| 3631 | + "companyName": { | ||
| 3632 | + "type": "string" | ||
| 3633 | + } | ||
| 3634 | + }, | ||
| 3635 | + "title": "SystemUserInfoResponse", | ||
| 3084 | "required": [ | 3636 | "required": [ |
| 3085 | "userId", | 3637 | "userId", |
| 3086 | "userName", | 3638 | "userName", |
| @@ -3089,6 +3641,101 @@ | @@ -3089,6 +3641,101 @@ | ||
| 3089 | "companyName" | 3641 | "companyName" |
| 3090 | ] | 3642 | ] |
| 3091 | }, | 3643 | }, |
| 3644 | + "SystemUserSearchRequest": { | ||
| 3645 | + "type": "object", | ||
| 3646 | + "properties": { | ||
| 3647 | + "page": { | ||
| 3648 | + "type": "integer", | ||
| 3649 | + "format": "int32" | ||
| 3650 | + }, | ||
| 3651 | + "size": { | ||
| 3652 | + "type": "integer", | ||
| 3653 | + "format": "int32" | ||
| 3654 | + }, | ||
| 3655 | + "name": { | ||
| 3656 | + "type": "string", | ||
| 3657 | + "description": " 名称" | ||
| 3658 | + }, | ||
| 3659 | + "phone": { | ||
| 3660 | + "type": "string", | ||
| 3661 | + "description": " 手机号 唯一" | ||
| 3662 | + }, | ||
| 3663 | + "position": { | ||
| 3664 | + "type": "string", | ||
| 3665 | + "description": " 职位" | ||
| 3666 | + }, | ||
| 3667 | + "enable": { | ||
| 3668 | + "type": "integer", | ||
| 3669 | + "format": "int32", | ||
| 3670 | + "description": " 启用状态 1:启用 2:禁用" | ||
| 3671 | + }, | ||
| 3672 | + "departmentId": { | ||
| 3673 | + "type": "integer", | ||
| 3674 | + "format": "int64", | ||
| 3675 | + "description": " 所属部门" | ||
| 3676 | + } | ||
| 3677 | + }, | ||
| 3678 | + "title": "SystemUserSearchRequest", | ||
| 3679 | + "required": [ | ||
| 3680 | + "page", | ||
| 3681 | + "size" | ||
| 3682 | + ] | ||
| 3683 | + }, | ||
| 3684 | + "SystemUserSearchResponse": { | ||
| 3685 | + "type": "object", | ||
| 3686 | + "properties": { | ||
| 3687 | + "list": { | ||
| 3688 | + "type": "array", | ||
| 3689 | + "items": { | ||
| 3690 | + "$ref": "#/definitions/SystemUser" | ||
| 3691 | + } | ||
| 3692 | + }, | ||
| 3693 | + "total": { | ||
| 3694 | + "type": "integer", | ||
| 3695 | + "format": "int64" | ||
| 3696 | + } | ||
| 3697 | + }, | ||
| 3698 | + "title": "SystemUserSearchResponse", | ||
| 3699 | + "required": [ | ||
| 3700 | + "list", | ||
| 3701 | + "total" | ||
| 3702 | + ] | ||
| 3703 | + }, | ||
| 3704 | + "SystemUserUpdateRequest": { | ||
| 3705 | + "type": "object", | ||
| 3706 | + "properties": { | ||
| 3707 | + "id": { | ||
| 3708 | + "type": "integer", | ||
| 3709 | + "format": "int64" | ||
| 3710 | + }, | ||
| 3711 | + "avatar": { | ||
| 3712 | + "type": "string", | ||
| 3713 | + "description": " 头像" | ||
| 3714 | + }, | ||
| 3715 | + "position": { | ||
| 3716 | + "type": "string", | ||
| 3717 | + "description": " 职位" | ||
| 3718 | + }, | ||
| 3719 | + "departments": { | ||
| 3720 | + "type": "array", | ||
| 3721 | + "items": { | ||
| 3722 | + "type": "integer", | ||
| 3723 | + "format": "int64" | ||
| 3724 | + }, | ||
| 3725 | + "description": " 所属部门" | ||
| 3726 | + } | ||
| 3727 | + }, | ||
| 3728 | + "title": "SystemUserUpdateRequest", | ||
| 3729 | + "required": [ | ||
| 3730 | + "id", | ||
| 3731 | + "position", | ||
| 3732 | + "departments" | ||
| 3733 | + ] | ||
| 3734 | + }, | ||
| 3735 | + "SystemUserUpdateResponse": { | ||
| 3736 | + "type": "object", | ||
| 3737 | + "title": "SystemUserUpdateResponse" | ||
| 3738 | + }, | ||
| 3092 | "TagCreateRequest": { | 3739 | "TagCreateRequest": { |
| 3093 | "type": "object", | 3740 | "type": "object", |
| 3094 | "properties": { | 3741 | "properties": { |
| @@ -3548,6 +4195,40 @@ | @@ -3548,6 +4195,40 @@ | ||
| 3548 | "name" | 4195 | "name" |
| 3549 | ] | 4196 | ] |
| 3550 | }, | 4197 | }, |
| 4198 | + "UserStatisticsRequest": { | ||
| 4199 | + "type": "object", | ||
| 4200 | + "properties": { | ||
| 4201 | + "userId": { | ||
| 4202 | + "type": "integer", | ||
| 4203 | + "format": "int64" | ||
| 4204 | + }, | ||
| 4205 | + "itemFlag": { | ||
| 4206 | + "type": "integer", | ||
| 4207 | + "format": "int32", | ||
| 4208 | + "description": " 1:他的帖子 2:他的评论/回复 4:他收到的赞 8:TA的圆桌讨论 16:被采纳" | ||
| 4209 | + } | ||
| 4210 | + }, | ||
| 4211 | + "title": "UserStatisticsRequest", | ||
| 4212 | + "required": [ | ||
| 4213 | + "userId", | ||
| 4214 | + "itemFlag" | ||
| 4215 | + ] | ||
| 4216 | + }, | ||
| 4217 | + "UserStatisticsResponse": { | ||
| 4218 | + "type": "object", | ||
| 4219 | + "properties": { | ||
| 4220 | + "list": { | ||
| 4221 | + "type": "array", | ||
| 4222 | + "items": { | ||
| 4223 | + "$ref": "#/definitions/StatisticsItem" | ||
| 4224 | + } | ||
| 4225 | + } | ||
| 4226 | + }, | ||
| 4227 | + "title": "UserStatisticsResponse", | ||
| 4228 | + "required": [ | ||
| 4229 | + "list" | ||
| 4230 | + ] | ||
| 4231 | + }, | ||
| 3551 | "WhichUserLikeArticle": { | 4232 | "WhichUserLikeArticle": { |
| 3552 | "type": "object", | 4233 | "type": "object", |
| 3553 | "properties": { | 4234 | "properties": { |
| @@ -215,6 +215,36 @@ service Core { | @@ -215,6 +215,36 @@ service Core { | ||
| 215 | @doc "系统用户信息" | 215 | @doc "系统用户信息" |
| 216 | @handler systemUserInfo | 216 | @handler systemUserInfo |
| 217 | post /system/user/info(SystemUserInfoRequest) returns (SystemUserInfoResponse) | 217 | post /system/user/info(SystemUserInfoRequest) returns (SystemUserInfoResponse) |
| 218 | + @doc "用户统计" | ||
| 219 | + @handler systemUserStatistics | ||
| 220 | + post /system/user/statistics (UserStatisticsRequest) returns (UserStatisticsResponse) | ||
| 221 | + | ||
| 222 | + @doc "用户详情" | ||
| 223 | + @handler systemUserGet | ||
| 224 | + get /system/user/:id (SystemUserGetRequest) returns (SystemUserGetResponse) | ||
| 225 | + @doc "更新用户" | ||
| 226 | + @handler systemUserUpdate | ||
| 227 | + put /system/user/:id (SystemUserUpdateRequest) returns (SystemUserUpdateResponse) | ||
| 228 | + @doc "搜索用户" | ||
| 229 | + @handler systemUserSearch | ||
| 230 | + post /system/user/search (SystemUserSearchRequest) returns (SystemUserSearchResponse) | ||
| 231 | + | ||
| 232 | + | ||
| 233 | + @doc "系统账号详情" | ||
| 234 | + @handler systemUserAccountGet | ||
| 235 | + get /system/account/:id (SystemUserAccountGetRequest) returns (SystemUserAccountGetResponse) | ||
| 236 | + @doc "系统新增账号" | ||
| 237 | + @handler systemUserAccountSave | ||
| 238 | + post /system/account (SystemUserAccountSaveRequest) returns (SystemUserAccountSaveResponse) | ||
| 239 | + @doc "系统启用/禁用账号" | ||
| 240 | + @handler systemUserAccountEnable | ||
| 241 | + post /system/account/enable (SystemUserAccountEnableRequest) returns (SystemUserAccountEnableResponse) | ||
| 242 | + @doc "系统更新账号" | ||
| 243 | + @handler systemUserAccountUpdate | ||
| 244 | + put /system/account/:id (SystemUserAccountUpdateRequest) returns (SystemUserAccountUpdateResponse) | ||
| 245 | + @doc "系统搜索账号" | ||
| 246 | + @handler systemUserAccountSearch | ||
| 247 | + post /system/account/search (SystemUserAccountSearchRequest) returns (SystemUserAccountSearchResponse) | ||
| 218 | } | 248 | } |
| 219 | 249 | ||
| 220 | type( | 250 | type( |
| @@ -228,4 +258,101 @@ type( | @@ -228,4 +258,101 @@ type( | ||
| 228 | CompanyId int64 `json:"companyId"` | 258 | CompanyId int64 `json:"companyId"` |
| 229 | CompanyName string `json:"companyName"` | 259 | CompanyName string `json:"companyName"` |
| 230 | } | 260 | } |
| 261 | + UserStatisticsRequest{ | ||
| 262 | + UserId int64 `json:"userId"` | ||
| 263 | + ItemFlag int `json:"itemFlag"` // 1:他的帖子 2:他的评论/回复 4:他收到的赞 8:TA的圆桌讨论 16:被采纳 | ||
| 264 | + } | ||
| 265 | + UserStatisticsResponse{ | ||
| 266 | + List []StatisticsItem `json:"list"` | ||
| 267 | + } | ||
| 268 | + StatisticsItem{ | ||
| 269 | + ItemFlag int `json:"itemFlag"` // 1:他的帖子 2:他的评论/回复 4:他收到的赞 8:TA的圆桌讨论 16:被采纳 | ||
| 270 | + Value float64 `json:"value"` // 统计值 | ||
| 271 | + } | ||
| 272 | + | ||
| 273 | + SystemUserGetRequest { | ||
| 274 | + Id int64 `path:"id"` | ||
| 275 | + } | ||
| 276 | + SystemUserGetResponse struct{ | ||
| 277 | + User SystemUser `json:"user"` | ||
| 278 | + } | ||
| 279 | + SystemUser struct{ | ||
| 280 | + Id int64 `json:"id"` // 用户ID | ||
| 281 | + Name string `json:"name"` // 名称 | ||
| 282 | + Avatar string `json:"avatar"` // 头像 | ||
| 283 | + Phone string `json:"phone"` // 手机号 唯一 | ||
| 284 | + Position string `json:"position"` // 职位 | ||
| 285 | + Enable int `json:"enable"` // 启用状态 1:启用 2:禁用 | ||
| 286 | + Departments []int64 `json:"departments"` // 所属部门 | ||
| 287 | + AccountFrom string `json:"accountFrom"` // 账号来源 后台新增、扫码注册 | ||
| 288 | + CreatedAt int64 `json:"createdAt"` // 注册时间 | ||
| 289 | + Roles []int64 `json:"roles"` // 角色 | ||
| 290 | + RolesDesc string `json:"rolesDesc"` // 角色描述 | ||
| 291 | + DepartmentsDesc string `json:"departmentsDesc"` // 部门描述 | ||
| 292 | + } | ||
| 293 | + | ||
| 294 | + SystemUserUpdateRequest struct{ | ||
| 295 | + Id int64 `path:"id"` | ||
| 296 | + Avatar string `json:"avatar,optional"` // 头像 | ||
| 297 | + Position string `json:"position"` // 职位 | ||
| 298 | + Departments []int64 `json:"departments"` // 所属部门 | ||
| 299 | + } | ||
| 300 | + SystemUserUpdateResponse struct{} | ||
| 301 | + | ||
| 302 | + SystemUserSearchRequest struct{ | ||
| 303 | + Page int `json:"page"` | ||
| 304 | + Size int `json:"size"` | ||
| 305 | + Name string `json:"name,optional"` // 名称 | ||
| 306 | + Phone string `json:"phone,optional"` // 手机号 唯一 | ||
| 307 | + Position string `json:"position,optional"` // 职位 | ||
| 308 | + Enable int `json:"enable,optional"` // 启用状态 1:启用 2:禁用 | ||
| 309 | + DepartmentId int64 `json:"departmentId,optional"` // 所属部门 | ||
| 310 | + } | ||
| 311 | + SystemUserSearchResponse{ | ||
| 312 | + List []SystemUser `json:"list"` | ||
| 313 | + Total int64 `json:"total"` | ||
| 314 | + } | ||
| 315 | + | ||
| 316 | + SystemUserAccountGetRequest { | ||
| 317 | + Id int64 `path:"id"` | ||
| 318 | + } | ||
| 319 | + SystemUserAccountGetResponse struct{ | ||
| 320 | + User SystemUser `json:"user"` | ||
| 321 | + } | ||
| 322 | + | ||
| 323 | + SystemUserAccountSaveRequest struct{ | ||
| 324 | + Name string `json:"name"` // 名称 | ||
| 325 | + Phone string `json:"phone"` // 手机号 唯一 | ||
| 326 | + Enable int `json:"enable"` // 启用状态 1:启用 2:禁用 | ||
| 327 | + Roles []int64 `json:"roles"` // 角色 | ||
| 328 | + } | ||
| 329 | + SystemUserAccountSaveResponse struct{ | ||
| 330 | + | ||
| 331 | + } | ||
| 332 | + SystemUserAccountEnableRequest struct{ | ||
| 333 | + UserIds []int64 `json:"userIds"` // 用户ID列表 | ||
| 334 | + Status int `json:"status"` // 状态 1:启用 2:禁用 | ||
| 335 | + } | ||
| 336 | + SystemUserAccountEnableResponse struct{ | ||
| 337 | + | ||
| 338 | + } | ||
| 339 | + SystemUserAccountUpdateRequest struct{ | ||
| 340 | + Id int64 `path:"id"` | ||
| 341 | + } | ||
| 342 | + SystemUserAccountUpdateResponse struct{} | ||
| 343 | + | ||
| 344 | + SystemUserAccountSearchRequest struct{ | ||
| 345 | + Page int `json:"page"` | ||
| 346 | + Size int `json:"size"` | ||
| 347 | + Name string `json:"name,optional"` // 名称 | ||
| 348 | + Phone string `json:"phone,optional"` // 手机号 唯一 | ||
| 349 | + RoleId int64 `json:"roleId,optional"` // 角色权限 | ||
| 350 | + Enable int `json:"enable,optional"` // 启用状态 1:启用 2:禁用 | ||
| 351 | + BeginTime int64 `json:"beginTime,optional"` // 注册日期-开始 | ||
| 352 | + EndTime int64 `json:"endTime,optional"` // 注册日期-结束 | ||
| 353 | + } | ||
| 354 | + SystemUserAccountSearchResponse{ | ||
| 355 | + List []SystemUser `json:"list"` | ||
| 356 | + Total int64 `json:"total"` | ||
| 357 | + } | ||
| 231 | ) | 358 | ) |
| @@ -170,6 +170,51 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { | @@ -170,6 +170,51 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { | ||
| 170 | Path: "/system/user/info", | 170 | Path: "/system/user/info", |
| 171 | Handler: user.SystemUserInfoHandler(serverCtx), | 171 | Handler: user.SystemUserInfoHandler(serverCtx), |
| 172 | }, | 172 | }, |
| 173 | + { | ||
| 174 | + Method: http.MethodPost, | ||
| 175 | + Path: "/system/user/statistics", | ||
| 176 | + Handler: user.SystemUserStatisticsHandler(serverCtx), | ||
| 177 | + }, | ||
| 178 | + { | ||
| 179 | + Method: http.MethodGet, | ||
| 180 | + Path: "/system/user/:id", | ||
| 181 | + Handler: user.SystemUserGetHandler(serverCtx), | ||
| 182 | + }, | ||
| 183 | + { | ||
| 184 | + Method: http.MethodPut, | ||
| 185 | + Path: "/system/user/:id", | ||
| 186 | + Handler: user.SystemUserUpdateHandler(serverCtx), | ||
| 187 | + }, | ||
| 188 | + { | ||
| 189 | + Method: http.MethodPost, | ||
| 190 | + Path: "/system/user/search", | ||
| 191 | + Handler: user.SystemUserSearchHandler(serverCtx), | ||
| 192 | + }, | ||
| 193 | + { | ||
| 194 | + Method: http.MethodGet, | ||
| 195 | + Path: "/system/account/:id", | ||
| 196 | + Handler: user.SystemUserAccountGetHandler(serverCtx), | ||
| 197 | + }, | ||
| 198 | + { | ||
| 199 | + Method: http.MethodPost, | ||
| 200 | + Path: "/system/account", | ||
| 201 | + Handler: user.SystemUserAccountSaveHandler(serverCtx), | ||
| 202 | + }, | ||
| 203 | + { | ||
| 204 | + Method: http.MethodPost, | ||
| 205 | + Path: "/system/account/enable", | ||
| 206 | + Handler: user.SystemUserAccountEnableHandler(serverCtx), | ||
| 207 | + }, | ||
| 208 | + { | ||
| 209 | + Method: http.MethodPut, | ||
| 210 | + Path: "/system/account/:id", | ||
| 211 | + Handler: user.SystemUserAccountUpdateHandler(serverCtx), | ||
| 212 | + }, | ||
| 213 | + { | ||
| 214 | + Method: http.MethodPost, | ||
| 215 | + Path: "/system/account/search", | ||
| 216 | + Handler: user.SystemUserAccountSearchHandler(serverCtx), | ||
| 217 | + }, | ||
| 173 | }, | 218 | }, |
| 174 | rest.WithJwt(serverCtx.Config.SystemAuth.AccessSecret), | 219 | rest.WithJwt(serverCtx.Config.SystemAuth.AccessSecret), |
| 175 | rest.WithPrefix("/v1"), | 220 | rest.WithPrefix("/v1"), |
| 1 | +package user | ||
| 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/user" | ||
| 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 SystemUserAccountEnableHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | ||
| 14 | + return func(w http.ResponseWriter, r *http.Request) { | ||
| 15 | + var req types.SystemUserAccountEnableRequest | ||
| 16 | + if err := httpx.Parse(r, &req); err != nil { | ||
| 17 | + httpx.ErrorCtx(r.Context(), w, err) | ||
| 18 | + return | ||
| 19 | + } | ||
| 20 | + | ||
| 21 | + l := user.NewSystemUserAccountEnableLogic(r.Context(), svcCtx) | ||
| 22 | + resp, err := l.SystemUserAccountEnable(&req) | ||
| 23 | + result.HttpResult(r, w, resp, err) | ||
| 24 | + } | ||
| 25 | +} |
| 1 | +package user | ||
| 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/user" | ||
| 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 SystemUserAccountGetHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | ||
| 14 | + return func(w http.ResponseWriter, r *http.Request) { | ||
| 15 | + var req types.SystemUserAccountGetRequest | ||
| 16 | + if err := httpx.Parse(r, &req); err != nil { | ||
| 17 | + httpx.ErrorCtx(r.Context(), w, err) | ||
| 18 | + return | ||
| 19 | + } | ||
| 20 | + | ||
| 21 | + l := user.NewSystemUserAccountGetLogic(r.Context(), svcCtx) | ||
| 22 | + resp, err := l.SystemUserAccountGet(&req) | ||
| 23 | + result.HttpResult(r, w, resp, err) | ||
| 24 | + } | ||
| 25 | +} |
| 1 | +package user | ||
| 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/user" | ||
| 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 SystemUserAccountSaveHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | ||
| 14 | + return func(w http.ResponseWriter, r *http.Request) { | ||
| 15 | + var req types.SystemUserAccountSaveRequest | ||
| 16 | + if err := httpx.Parse(r, &req); err != nil { | ||
| 17 | + httpx.ErrorCtx(r.Context(), w, err) | ||
| 18 | + return | ||
| 19 | + } | ||
| 20 | + | ||
| 21 | + l := user.NewSystemUserAccountSaveLogic(r.Context(), svcCtx) | ||
| 22 | + resp, err := l.SystemUserAccountSave(&req) | ||
| 23 | + result.HttpResult(r, w, resp, err) | ||
| 24 | + } | ||
| 25 | +} |
| 1 | +package user | ||
| 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/user" | ||
| 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 SystemUserAccountSearchHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | ||
| 14 | + return func(w http.ResponseWriter, r *http.Request) { | ||
| 15 | + var req types.SystemUserAccountSearchRequest | ||
| 16 | + if err := httpx.Parse(r, &req); err != nil { | ||
| 17 | + httpx.ErrorCtx(r.Context(), w, err) | ||
| 18 | + return | ||
| 19 | + } | ||
| 20 | + | ||
| 21 | + l := user.NewSystemUserAccountSearchLogic(r.Context(), svcCtx) | ||
| 22 | + resp, err := l.SystemUserAccountSearch(&req) | ||
| 23 | + result.HttpResult(r, w, resp, err) | ||
| 24 | + } | ||
| 25 | +} |
| 1 | +package user | ||
| 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/user" | ||
| 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 SystemUserAccountUpdateHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | ||
| 14 | + return func(w http.ResponseWriter, r *http.Request) { | ||
| 15 | + var req types.SystemUserAccountUpdateRequest | ||
| 16 | + if err := httpx.Parse(r, &req); err != nil { | ||
| 17 | + httpx.ErrorCtx(r.Context(), w, err) | ||
| 18 | + return | ||
| 19 | + } | ||
| 20 | + | ||
| 21 | + l := user.NewSystemUserAccountUpdateLogic(r.Context(), svcCtx) | ||
| 22 | + resp, err := l.SystemUserAccountUpdate(&req) | ||
| 23 | + result.HttpResult(r, w, resp, err) | ||
| 24 | + } | ||
| 25 | +} |
| 1 | +package user | ||
| 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/user" | ||
| 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 SystemUserGetHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | ||
| 14 | + return func(w http.ResponseWriter, r *http.Request) { | ||
| 15 | + var req types.SystemUserGetRequest | ||
| 16 | + if err := httpx.Parse(r, &req); err != nil { | ||
| 17 | + httpx.ErrorCtx(r.Context(), w, err) | ||
| 18 | + return | ||
| 19 | + } | ||
| 20 | + | ||
| 21 | + l := user.NewSystemUserGetLogic(r.Context(), svcCtx) | ||
| 22 | + resp, err := l.SystemUserGet(&req) | ||
| 23 | + result.HttpResult(r, w, resp, err) | ||
| 24 | + } | ||
| 25 | +} |
| 1 | package user | 1 | package user |
| 2 | 2 | ||
| 3 | import ( | 3 | import ( |
| 4 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/result" | ||
| 4 | "net/http" | 5 | "net/http" |
| 5 | 6 | ||
| 6 | "github.com/zeromicro/go-zero/rest/httpx" | 7 | "github.com/zeromicro/go-zero/rest/httpx" |
| @@ -19,10 +20,6 @@ func SystemUserInfoHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | @@ -19,10 +20,6 @@ func SystemUserInfoHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | ||
| 19 | 20 | ||
| 20 | l := user.NewSystemUserInfoLogic(r.Context(), svcCtx) | 21 | l := user.NewSystemUserInfoLogic(r.Context(), svcCtx) |
| 21 | resp, err := l.SystemUserInfo(&req) | 22 | 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 | - } | 23 | + result.HttpResult(r, w, resp, err) |
| 27 | } | 24 | } |
| 28 | } | 25 | } |
| 1 | +package user | ||
| 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/user" | ||
| 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 SystemUserSearchHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | ||
| 14 | + return func(w http.ResponseWriter, r *http.Request) { | ||
| 15 | + var req types.SystemUserSearchRequest | ||
| 16 | + if err := httpx.Parse(r, &req); err != nil { | ||
| 17 | + httpx.ErrorCtx(r.Context(), w, err) | ||
| 18 | + return | ||
| 19 | + } | ||
| 20 | + | ||
| 21 | + l := user.NewSystemUserSearchLogic(r.Context(), svcCtx) | ||
| 22 | + resp, err := l.SystemUserSearch(&req) | ||
| 23 | + result.HttpResult(r, w, resp, err) | ||
| 24 | + } | ||
| 25 | +} |
| 1 | +package user | ||
| 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/user" | ||
| 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 SystemUserStatisticsHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | ||
| 14 | + return func(w http.ResponseWriter, r *http.Request) { | ||
| 15 | + var req types.UserStatisticsRequest | ||
| 16 | + if err := httpx.Parse(r, &req); err != nil { | ||
| 17 | + httpx.ErrorCtx(r.Context(), w, err) | ||
| 18 | + return | ||
| 19 | + } | ||
| 20 | + | ||
| 21 | + l := user.NewSystemUserStatisticsLogic(r.Context(), svcCtx) | ||
| 22 | + resp, err := l.SystemUserStatistics(&req) | ||
| 23 | + result.HttpResult(r, w, resp, err) | ||
| 24 | + } | ||
| 25 | +} |
| 1 | +package user | ||
| 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/user" | ||
| 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 SystemUserUpdateHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | ||
| 14 | + return func(w http.ResponseWriter, r *http.Request) { | ||
| 15 | + var req types.SystemUserUpdateRequest | ||
| 16 | + if err := httpx.Parse(r, &req); err != nil { | ||
| 17 | + httpx.ErrorCtx(r.Context(), w, err) | ||
| 18 | + return | ||
| 19 | + } | ||
| 20 | + | ||
| 21 | + l := user.NewSystemUserUpdateLogic(r.Context(), svcCtx) | ||
| 22 | + resp, err := l.SystemUserUpdate(&req) | ||
| 23 | + result.HttpResult(r, w, resp, err) | ||
| 24 | + } | ||
| 25 | +} |
| @@ -75,6 +75,7 @@ func (l *MiniUserApplyJoinCompanyLogic) MiniUserApplyJoinCompany(req *types.Mini | @@ -75,6 +75,7 @@ func (l *MiniUserApplyJoinCompanyLogic) MiniUserApplyJoinCompany(req *types.Mini | ||
| 75 | AccountFrom: domain.AccountFromQr, | 75 | AccountFrom: domain.AccountFromQr, |
| 76 | Departments: make([]int64, 0), | 76 | Departments: make([]int64, 0), |
| 77 | } | 77 | } |
| 78 | + user.WithName(name) | ||
| 78 | if user, err = l.svcCtx.UserRepository.Insert(ctx, conn, user); err != nil { | 79 | if user, err = l.svcCtx.UserRepository.Insert(ctx, conn, user); err != nil { |
| 79 | return err | 80 | return err |
| 80 | } | 81 | } |
| 1 | +package user | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "context" | ||
| 5 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/db/transaction" | ||
| 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 SystemUserAccountEnableLogic struct { | ||
| 17 | + logx.Logger | ||
| 18 | + ctx context.Context | ||
| 19 | + svcCtx *svc.ServiceContext | ||
| 20 | +} | ||
| 21 | + | ||
| 22 | +func NewSystemUserAccountEnableLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SystemUserAccountEnableLogic { | ||
| 23 | + return &SystemUserAccountEnableLogic{ | ||
| 24 | + Logger: logx.WithContext(ctx), | ||
| 25 | + ctx: ctx, | ||
| 26 | + svcCtx: svcCtx, | ||
| 27 | + } | ||
| 28 | +} | ||
| 29 | + | ||
| 30 | +func (l *SystemUserAccountEnableLogic) SystemUserAccountEnable(req *types.SystemUserAccountEnableRequest) (resp *types.SystemUserAccountEnableResponse, err error) { | ||
| 31 | + var ( | ||
| 32 | + conn = l.svcCtx.DefaultDBConn() | ||
| 33 | + users []*domain.User | ||
| 34 | + userToken = contextdata.GetUserTokenFromCtx(l.ctx) | ||
| 35 | + ) | ||
| 36 | + if _, users, err = l.svcCtx.UserRepository.Find(l.ctx, conn, domain.IndexCompanyId(userToken.CompanyId)().MustWithKV("ids", req.UserIds).WithFindOnly()); err != nil { | ||
| 37 | + return nil, xerr.NewErrMsgErr("公司不存在", err) | ||
| 38 | + } | ||
| 39 | + if err = transaction.UseTrans(l.ctx, l.svcCtx.DB, func(ctx context.Context, conn transaction.Conn) error { | ||
| 40 | + for _, user := range users { | ||
| 41 | + if user.Enable == req.Status { | ||
| 42 | + continue | ||
| 43 | + } | ||
| 44 | + user.Enable = req.Status | ||
| 45 | + if user, err = l.svcCtx.UserRepository.UpdateWithVersion(ctx, conn, user); err != nil { | ||
| 46 | + return err | ||
| 47 | + } | ||
| 48 | + } | ||
| 49 | + return nil | ||
| 50 | + }, true); err != nil { | ||
| 51 | + return nil, xerr.NewErrMsgErr("更新启用状态失败", err) | ||
| 52 | + } | ||
| 53 | + return | ||
| 54 | +} |
| 1 | +package user | ||
| 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 | + "strings" | ||
| 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 SystemUserAccountGetLogic struct { | ||
| 17 | + logx.Logger | ||
| 18 | + ctx context.Context | ||
| 19 | + svcCtx *svc.ServiceContext | ||
| 20 | +} | ||
| 21 | + | ||
| 22 | +func NewSystemUserAccountGetLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SystemUserAccountGetLogic { | ||
| 23 | + return &SystemUserAccountGetLogic{ | ||
| 24 | + Logger: logx.WithContext(ctx), | ||
| 25 | + ctx: ctx, | ||
| 26 | + svcCtx: svcCtx, | ||
| 27 | + } | ||
| 28 | +} | ||
| 29 | + | ||
| 30 | +func (l *SystemUserAccountGetLogic) SystemUserAccountGet(req *types.SystemUserAccountGetRequest) (resp *types.SystemUserAccountGetResponse, err error) { | ||
| 31 | + var ( | ||
| 32 | + conn = l.svcCtx.DefaultDBConn() | ||
| 33 | + user *domain.User | ||
| 34 | + userToken = contextdata.GetUserTokenFromCtx(l.ctx) | ||
| 35 | + departments []*domain.Department | ||
| 36 | + roles []*domain.Role | ||
| 37 | + ) | ||
| 38 | + if user, err = l.svcCtx.UserRepository.FindOne(l.ctx, conn, req.Id); err != nil { | ||
| 39 | + return nil, xerr.NewErrMsgErr("公司不存在", err) | ||
| 40 | + } | ||
| 41 | + if userToken.CompanyId != user.CompanyId { | ||
| 42 | + return nil, xerr.NewErrMsgErr("无权限访问改用户", err) | ||
| 43 | + } | ||
| 44 | + if len(user.Departments) > 0 { | ||
| 45 | + _, departments, err = l.svcCtx.DepartmentRepository.Find(l.ctx, conn, domain.IndexCompanyId(userToken.CompanyId)().MustWithKV("ids", user.Departments)) | ||
| 46 | + if err != nil { | ||
| 47 | + return nil, xerr.NewErrMsgErr("获取账号详情失败", err) | ||
| 48 | + } | ||
| 49 | + } | ||
| 50 | + if len(user.Roles) > 0 { | ||
| 51 | + _, roles, err = l.svcCtx.RoleRepository.Find(l.ctx, conn, domain.IndexCompanyId(userToken.CompanyId)().MustWithKV("ids", user.Roles)) | ||
| 52 | + if err != nil { | ||
| 53 | + return nil, xerr.NewErrMsgErr("获取账号详情失败", err) | ||
| 54 | + } | ||
| 55 | + } | ||
| 56 | + departmentsDesc := domain.Values(departments, func(item *domain.Department) string { | ||
| 57 | + return item.Name | ||
| 58 | + }) | ||
| 59 | + rolesDesc := domain.Values(roles, func(item *domain.Role) string { | ||
| 60 | + return item.Name | ||
| 61 | + }) | ||
| 62 | + item := NewSystemUser(user) | ||
| 63 | + item.DepartmentsDesc = strings.Join(departmentsDesc, "、") | ||
| 64 | + item.RolesDesc = strings.Join(rolesDesc, "、") | ||
| 65 | + resp = &types.SystemUserAccountGetResponse{ | ||
| 66 | + User: item, | ||
| 67 | + } | ||
| 68 | + return | ||
| 69 | +} | ||
| 70 | + | ||
| 71 | +func NewSystemUser(item *domain.User) types.SystemUser { | ||
| 72 | + result := types.SystemUser{ | ||
| 73 | + Id: item.Id, | ||
| 74 | + Name: item.Name, | ||
| 75 | + Avatar: item.Avatar, | ||
| 76 | + Phone: item.Phone, | ||
| 77 | + Position: item.Position, | ||
| 78 | + Enable: item.Enable, | ||
| 79 | + Departments: item.Departments, | ||
| 80 | + Roles: item.Roles, | ||
| 81 | + AccountFrom: item.AccountFrom, | ||
| 82 | + CreatedAt: item.CreatedAt, | ||
| 83 | + } | ||
| 84 | + return result | ||
| 85 | +} |
| 1 | +package user | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "context" | ||
| 5 | + "fmt" | ||
| 6 | + "github.com/pkg/errors" | ||
| 7 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/db/transaction" | ||
| 8 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain" | ||
| 9 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/contextdata" | ||
| 10 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/tool" | ||
| 11 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr" | ||
| 12 | + | ||
| 13 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | ||
| 14 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" | ||
| 15 | + | ||
| 16 | + "github.com/zeromicro/go-zero/core/logx" | ||
| 17 | +) | ||
| 18 | + | ||
| 19 | +type SystemUserAccountSaveLogic struct { | ||
| 20 | + logx.Logger | ||
| 21 | + ctx context.Context | ||
| 22 | + svcCtx *svc.ServiceContext | ||
| 23 | +} | ||
| 24 | + | ||
| 25 | +func NewSystemUserAccountSaveLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SystemUserAccountSaveLogic { | ||
| 26 | + return &SystemUserAccountSaveLogic{ | ||
| 27 | + Logger: logx.WithContext(ctx), | ||
| 28 | + ctx: ctx, | ||
| 29 | + svcCtx: svcCtx, | ||
| 30 | + } | ||
| 31 | +} | ||
| 32 | + | ||
| 33 | +func (l *SystemUserAccountSaveLogic) SystemUserAccountSave(req *types.SystemUserAccountSaveRequest) (resp *types.SystemUserAccountSaveResponse, err error) { | ||
| 34 | + var ( | ||
| 35 | + conn = l.svcCtx.DefaultDBConn() | ||
| 36 | + company *domain.Company | ||
| 37 | + user *domain.User | ||
| 38 | + name = fmt.Sprintf("用户%s", tool.Krand(6, tool.KC_RAND_KIND_NUM)) | ||
| 39 | + userToken = contextdata.GetUserTokenFromCtx(l.ctx) | ||
| 40 | + ) | ||
| 41 | + if req.Name != "" { | ||
| 42 | + name = req.Name | ||
| 43 | + } | ||
| 44 | + if company, err = l.svcCtx.CompanyRepository.FindOne(l.ctx, conn, userToken.CompanyId); err != nil { | ||
| 45 | + return nil, xerr.NewErrMsgErr("公司不存在", err) | ||
| 46 | + } | ||
| 47 | + if user, err = l.svcCtx.UserRepository.FindOneByCompanyIdAndPhone(l.ctx, conn, company.Id, req.Phone, []int{domain.UserAuditStatusWait, domain.UserAuditStatusPassed}); err != nil { | ||
| 48 | + if errors.Is(err, domain.ErrNotFound) { | ||
| 49 | + err = nil | ||
| 50 | + } | ||
| 51 | + } | ||
| 52 | + if err != nil { | ||
| 53 | + return nil, xerr.NewErrMsgErr("申请失败", err) | ||
| 54 | + } | ||
| 55 | + if err = transaction.UseTrans(l.ctx, l.svcCtx.DB, func(ctx context.Context, conn transaction.Conn) error { | ||
| 56 | + user = &domain.User{ | ||
| 57 | + CompanyId: company.Id, | ||
| 58 | + Phone: req.Phone, | ||
| 59 | + Name: name, | ||
| 60 | + Flag: domain.UserCommon, | ||
| 61 | + Enable: req.Enable, | ||
| 62 | + Roles: make([]int64, 0), | ||
| 63 | + Follower: make([]int64, 0), | ||
| 64 | + Following: make([]int64, 0), | ||
| 65 | + AccountFrom: domain.AccountFromMr, | ||
| 66 | + Departments: make([]int64, 0), | ||
| 67 | + AuditStatus: domain.UserAuditStatusPassed, | ||
| 68 | + } | ||
| 69 | + user.WithName(name) | ||
| 70 | + for _, roleId := range req.Roles { | ||
| 71 | + user.AddRole(roleId) | ||
| 72 | + } | ||
| 73 | + if user, err = l.svcCtx.UserRepository.Insert(ctx, conn, user); err != nil { | ||
| 74 | + return err | ||
| 75 | + } | ||
| 76 | + return nil | ||
| 77 | + }, true); err != nil { | ||
| 78 | + return nil, xerr.NewErrMsgErr("添加用户失败", err) | ||
| 79 | + } | ||
| 80 | + resp = &types.SystemUserAccountSaveResponse{} | ||
| 81 | + return | ||
| 82 | +} |
| 1 | +package user | ||
| 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 | + "strings" | ||
| 10 | + | ||
| 11 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | ||
| 12 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" | ||
| 13 | + | ||
| 14 | + "github.com/zeromicro/go-zero/core/logx" | ||
| 15 | +) | ||
| 16 | + | ||
| 17 | +type SystemUserAccountSearchLogic struct { | ||
| 18 | + logx.Logger | ||
| 19 | + ctx context.Context | ||
| 20 | + svcCtx *svc.ServiceContext | ||
| 21 | +} | ||
| 22 | + | ||
| 23 | +func NewSystemUserAccountSearchLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SystemUserAccountSearchLogic { | ||
| 24 | + return &SystemUserAccountSearchLogic{ | ||
| 25 | + Logger: logx.WithContext(ctx), | ||
| 26 | + ctx: ctx, | ||
| 27 | + svcCtx: svcCtx, | ||
| 28 | + } | ||
| 29 | +} | ||
| 30 | + | ||
| 31 | +func (l *SystemUserAccountSearchLogic) SystemUserAccountSearch(req *types.SystemUserAccountSearchRequest) (resp *types.SystemUserAccountSearchResponse, err error) { | ||
| 32 | + var ( | ||
| 33 | + conn = l.svcCtx.DefaultDBConn() | ||
| 34 | + users []*domain.User | ||
| 35 | + userToken = contextdata.GetUserTokenFromCtx(l.ctx) | ||
| 36 | + total int64 | ||
| 37 | + departmentMap = make(map[int64]*domain.Department) | ||
| 38 | + roleMap = make(map[int64]*domain.Role) | ||
| 39 | + ) | ||
| 40 | + queryOptions := domain.IndexCompanyId(userToken.CompanyId)().WithOffsetLimit(req.Page, req.Size).WithOrder("id desc"). | ||
| 41 | + WithKV("likeName", req.Name). | ||
| 42 | + WithKV("likePhone", req.Phone). | ||
| 43 | + WithKV("roleId", req.RoleId). | ||
| 44 | + WithKV("enable", req.Enable). | ||
| 45 | + WithKV("beginTime", req.BeginTime). | ||
| 46 | + WithKV("endTime", req.EndTime) | ||
| 47 | + if total, users, err = l.svcCtx.UserRepository.Find(l.ctx, conn, queryOptions); err != nil { | ||
| 48 | + return nil, xerr.NewErr(err) | ||
| 49 | + } | ||
| 50 | + resp = &types.SystemUserAccountSearchResponse{ | ||
| 51 | + Total: total, | ||
| 52 | + List: make([]types.SystemUser, 0), | ||
| 53 | + } | ||
| 54 | + lo.ForEach(users, func(item *domain.User, index int) { | ||
| 55 | + var departments []string | ||
| 56 | + for _, id := range item.Departments { | ||
| 57 | + if department, _ := domain.LazyLoad(departmentMap, l.ctx, conn, id, l.svcCtx.DepartmentRepository.FindOne); department != nil { | ||
| 58 | + departments = append(departments, department.Name) | ||
| 59 | + } | ||
| 60 | + } | ||
| 61 | + var roles []string | ||
| 62 | + for _, id := range item.Roles { | ||
| 63 | + if role, _ := domain.LazyLoad(roleMap, l.ctx, conn, id, l.svcCtx.RoleRepository.FindOne); role != nil { | ||
| 64 | + roles = append(roles, role.Name) | ||
| 65 | + } | ||
| 66 | + } | ||
| 67 | + user := NewSystemUser(item) | ||
| 68 | + user.RolesDesc = strings.Join(roles, "、") | ||
| 69 | + user.DepartmentsDesc = strings.Join(departments, "、") | ||
| 70 | + resp.List = append(resp.List, user) | ||
| 71 | + }) | ||
| 72 | + return | ||
| 73 | +} |
| 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 SystemUserAccountUpdateLogic struct { | ||
| 13 | + logx.Logger | ||
| 14 | + ctx context.Context | ||
| 15 | + svcCtx *svc.ServiceContext | ||
| 16 | +} | ||
| 17 | + | ||
| 18 | +func NewSystemUserAccountUpdateLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SystemUserAccountUpdateLogic { | ||
| 19 | + return &SystemUserAccountUpdateLogic{ | ||
| 20 | + Logger: logx.WithContext(ctx), | ||
| 21 | + ctx: ctx, | ||
| 22 | + svcCtx: svcCtx, | ||
| 23 | + } | ||
| 24 | +} | ||
| 25 | + | ||
| 26 | +func (l *SystemUserAccountUpdateLogic) SystemUserAccountUpdate(req *types.SystemUserAccountUpdateRequest) (resp *types.SystemUserAccountUpdateResponse, err error) { | ||
| 27 | + // todo: add your logic here and delete this line | ||
| 28 | + | ||
| 29 | + return | ||
| 30 | +} |
| 1 | +package user | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "context" | ||
| 5 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | ||
| 6 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" | ||
| 7 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain" | ||
| 8 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/contextdata" | ||
| 9 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr" | ||
| 10 | + "strings" | ||
| 11 | + | ||
| 12 | + "github.com/zeromicro/go-zero/core/logx" | ||
| 13 | +) | ||
| 14 | + | ||
| 15 | +type SystemUserGetLogic struct { | ||
| 16 | + logx.Logger | ||
| 17 | + ctx context.Context | ||
| 18 | + svcCtx *svc.ServiceContext | ||
| 19 | +} | ||
| 20 | + | ||
| 21 | +func NewSystemUserGetLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SystemUserGetLogic { | ||
| 22 | + return &SystemUserGetLogic{ | ||
| 23 | + Logger: logx.WithContext(ctx), | ||
| 24 | + ctx: ctx, | ||
| 25 | + svcCtx: svcCtx, | ||
| 26 | + } | ||
| 27 | +} | ||
| 28 | + | ||
| 29 | +func (l *SystemUserGetLogic) SystemUserGet(req *types.SystemUserGetRequest) (resp *types.SystemUserGetResponse, err error) { | ||
| 30 | + var ( | ||
| 31 | + user *domain.User | ||
| 32 | + conn = l.svcCtx.DefaultDBConn() | ||
| 33 | + userToken = contextdata.GetUserTokenFromCtx(l.ctx) | ||
| 34 | + ) | ||
| 35 | + if user, err = l.svcCtx.UserRepository.FindOne(l.ctx, conn, req.Id); err != nil { | ||
| 36 | + return nil, xerr.NewErrMsgErr("用户不存在", err) | ||
| 37 | + } | ||
| 38 | + var roles []*domain.Role | ||
| 39 | + if len(user.Roles) > 0 { | ||
| 40 | + _, roles, err = l.svcCtx.RoleRepository.Find(l.ctx, conn, domain.IndexCompanyId(userToken.CompanyId)().MustWithKV("ids", user.Roles)) | ||
| 41 | + if err != nil { | ||
| 42 | + return nil, xerr.NewErrMsgErr("获取账号详情失败", err) | ||
| 43 | + } | ||
| 44 | + } | ||
| 45 | + rolesDesc := domain.Values(roles, func(item *domain.Role) string { | ||
| 46 | + return item.Name | ||
| 47 | + }) | ||
| 48 | + userItem := NewSystemUser(user) | ||
| 49 | + userItem.RolesDesc = strings.Join(rolesDesc, "、") | ||
| 50 | + resp = &types.SystemUserGetResponse{ | ||
| 51 | + User: userItem, | ||
| 52 | + } | ||
| 53 | + return | ||
| 54 | +} |
| @@ -2,7 +2,6 @@ package user | @@ -2,7 +2,6 @@ package user | ||
| 2 | 2 | ||
| 3 | import ( | 3 | import ( |
| 4 | "context" | 4 | "context" |
| 5 | - | ||
| 6 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | 5 | "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" | 6 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" |
| 8 | 7 | ||
| @@ -24,7 +23,6 @@ func NewSystemUserInfoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Sy | @@ -24,7 +23,6 @@ func NewSystemUserInfoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Sy | ||
| 24 | } | 23 | } |
| 25 | 24 | ||
| 26 | func (l *SystemUserInfoLogic) SystemUserInfo(req *types.SystemUserInfoRequest) (resp *types.SystemUserInfoResponse, err error) { | 25 | func (l *SystemUserInfoLogic) SystemUserInfo(req *types.SystemUserInfoRequest) (resp *types.SystemUserInfoResponse, err error) { |
| 27 | - // todo: add your logic here and delete this line | ||
| 28 | 26 | ||
| 29 | return | 27 | return |
| 30 | } | 28 | } |
| 1 | +package user | ||
| 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 | + "strings" | ||
| 10 | + | ||
| 11 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | ||
| 12 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" | ||
| 13 | + | ||
| 14 | + "github.com/zeromicro/go-zero/core/logx" | ||
| 15 | +) | ||
| 16 | + | ||
| 17 | +type SystemUserSearchLogic struct { | ||
| 18 | + logx.Logger | ||
| 19 | + ctx context.Context | ||
| 20 | + svcCtx *svc.ServiceContext | ||
| 21 | +} | ||
| 22 | + | ||
| 23 | +func NewSystemUserSearchLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SystemUserSearchLogic { | ||
| 24 | + return &SystemUserSearchLogic{ | ||
| 25 | + Logger: logx.WithContext(ctx), | ||
| 26 | + ctx: ctx, | ||
| 27 | + svcCtx: svcCtx, | ||
| 28 | + } | ||
| 29 | +} | ||
| 30 | + | ||
| 31 | +func (l *SystemUserSearchLogic) SystemUserSearch(req *types.SystemUserSearchRequest) (resp *types.SystemUserSearchResponse, err error) { | ||
| 32 | + var ( | ||
| 33 | + conn = l.svcCtx.DefaultDBConn() | ||
| 34 | + users []*domain.User | ||
| 35 | + userToken = contextdata.GetUserTokenFromCtx(l.ctx) | ||
| 36 | + total int64 | ||
| 37 | + roleMap = make(map[int64]*domain.Role) | ||
| 38 | + ) | ||
| 39 | + queryOptions := domain.IndexCompanyId(userToken.CompanyId)().WithOffsetLimit(req.Page, req.Size).WithOrder("id desc"). | ||
| 40 | + WithKV("likeName", req.Name). | ||
| 41 | + WithKV("likePhone", req.Phone). | ||
| 42 | + WithKV("likePosition", req.Position). | ||
| 43 | + WithKV("enable", req.Enable). | ||
| 44 | + WithKV("departmentId", req.DepartmentId) | ||
| 45 | + if total, users, err = l.svcCtx.UserRepository.Find(l.ctx, conn, queryOptions); err != nil { | ||
| 46 | + return nil, xerr.NewErr(err) | ||
| 47 | + } | ||
| 48 | + resp = &types.SystemUserSearchResponse{ | ||
| 49 | + Total: total, | ||
| 50 | + List: make([]types.SystemUser, 0), | ||
| 51 | + } | ||
| 52 | + lo.ForEach(users, func(item *domain.User, index int) { | ||
| 53 | + var roles []string | ||
| 54 | + for _, id := range item.Roles { | ||
| 55 | + if role, _ := domain.LazyLoad(roleMap, l.ctx, conn, id, l.svcCtx.RoleRepository.FindOne); role != nil { | ||
| 56 | + roles = append(roles, role.Name) | ||
| 57 | + } | ||
| 58 | + } | ||
| 59 | + user := NewSystemUser(item) | ||
| 60 | + user.RolesDesc = strings.Join(roles, "、") | ||
| 61 | + resp.List = append(resp.List, user) | ||
| 62 | + }) | ||
| 63 | + | ||
| 64 | + return | ||
| 65 | +} |
| 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 SystemUserStatisticsLogic struct { | ||
| 13 | + logx.Logger | ||
| 14 | + ctx context.Context | ||
| 15 | + svcCtx *svc.ServiceContext | ||
| 16 | +} | ||
| 17 | + | ||
| 18 | +func NewSystemUserStatisticsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SystemUserStatisticsLogic { | ||
| 19 | + return &SystemUserStatisticsLogic{ | ||
| 20 | + Logger: logx.WithContext(ctx), | ||
| 21 | + ctx: ctx, | ||
| 22 | + svcCtx: svcCtx, | ||
| 23 | + } | ||
| 24 | +} | ||
| 25 | + | ||
| 26 | +func (l *SystemUserStatisticsLogic) SystemUserStatistics(req *types.UserStatisticsRequest) (resp *types.UserStatisticsResponse, err error) { | ||
| 27 | + // todo: add your logic here and delete this line | ||
| 28 | + | ||
| 29 | + return | ||
| 30 | +} |
| 1 | +package user | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "context" | ||
| 5 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/db/transaction" | ||
| 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 SystemUserUpdateLogic struct { | ||
| 17 | + logx.Logger | ||
| 18 | + ctx context.Context | ||
| 19 | + svcCtx *svc.ServiceContext | ||
| 20 | +} | ||
| 21 | + | ||
| 22 | +func NewSystemUserUpdateLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SystemUserUpdateLogic { | ||
| 23 | + return &SystemUserUpdateLogic{ | ||
| 24 | + Logger: logx.WithContext(ctx), | ||
| 25 | + ctx: ctx, | ||
| 26 | + svcCtx: svcCtx, | ||
| 27 | + } | ||
| 28 | +} | ||
| 29 | + | ||
| 30 | +func (l *SystemUserUpdateLogic) SystemUserUpdate(req *types.SystemUserUpdateRequest) (resp *types.SystemUserUpdateResponse, err error) { | ||
| 31 | + var ( | ||
| 32 | + userToken = contextdata.GetUserTokenFromCtx(l.ctx) | ||
| 33 | + user *domain.User | ||
| 34 | + conn = l.svcCtx.DefaultDBConn() | ||
| 35 | + ) | ||
| 36 | + if user, err = l.svcCtx.UserRepository.FindOne(l.ctx, conn, req.Id); err != nil { | ||
| 37 | + return nil, xerr.NewErrMsgErr("用户不存在", err) | ||
| 38 | + } | ||
| 39 | + if user.CompanyId != userToken.CompanyId { | ||
| 40 | + return nil, xerr.NewErrMsgErr("无权限更改", err) | ||
| 41 | + } | ||
| 42 | + user.Avatar = req.Avatar | ||
| 43 | + user.Position = req.Position | ||
| 44 | + user.Departments = req.Departments | ||
| 45 | + user.WithName(user.Name) | ||
| 46 | + if err = transaction.UseTrans(l.ctx, l.svcCtx.DB, func(ctx context.Context, conn transaction.Conn) error { | ||
| 47 | + if user, err = l.svcCtx.UserRepository.UpdateWithVersion(ctx, conn, user); err != nil { | ||
| 48 | + return err | ||
| 49 | + } | ||
| 50 | + return nil | ||
| 51 | + }, true); err != nil { | ||
| 52 | + return nil, xerr.NewErrMsgErr("更新用户信息失败", err) | ||
| 53 | + } | ||
| 54 | + resp = &types.SystemUserUpdateResponse{} | ||
| 55 | + return | ||
| 56 | +} |
| @@ -515,6 +515,117 @@ type SystemUserInfoResponse struct { | @@ -515,6 +515,117 @@ type SystemUserInfoResponse struct { | ||
| 515 | CompanyName string `json:"companyName"` | 515 | CompanyName string `json:"companyName"` |
| 516 | } | 516 | } |
| 517 | 517 | ||
| 518 | +type UserStatisticsRequest struct { | ||
| 519 | + UserId int64 `json:"userId"` | ||
| 520 | + ItemFlag int `json:"itemFlag"` // 1:他的帖子 2:他的评论/回复 4:他收到的赞 8:TA的圆桌讨论 16:被采纳 | ||
| 521 | +} | ||
| 522 | + | ||
| 523 | +type UserStatisticsResponse struct { | ||
| 524 | + List []StatisticsItem `json:"list"` | ||
| 525 | +} | ||
| 526 | + | ||
| 527 | +type StatisticsItem struct { | ||
| 528 | + ItemFlag int `json:"itemFlag"` // 1:他的帖子 2:他的评论/回复 4:他收到的赞 8:TA的圆桌讨论 16:被采纳 | ||
| 529 | + Value float64 `json:"value"` // 统计值 | ||
| 530 | +} | ||
| 531 | + | ||
| 532 | +type SystemUserGetRequest struct { | ||
| 533 | + Id int64 `path:"id"` | ||
| 534 | +} | ||
| 535 | + | ||
| 536 | +type SystemUserGetResponse struct { | ||
| 537 | + User SystemUser `json:"user"` | ||
| 538 | +} | ||
| 539 | + | ||
| 540 | +type SystemUser struct { | ||
| 541 | + Id int64 `json:"id"` // 用户ID | ||
| 542 | + Name string `json:"name"` // 名称 | ||
| 543 | + Avatar string `json:"avatar"` // 头像 | ||
| 544 | + Phone string `json:"phone"` // 手机号 唯一 | ||
| 545 | + Position string `json:"position"` // 职位 | ||
| 546 | + Enable int `json:"enable"` // 启用状态 1:启用 2:禁用 | ||
| 547 | + Departments []int64 `json:"departments"` // 所属部门 | ||
| 548 | + AccountFrom string `json:"accountFrom"` // 账号来源 后台新增、扫码注册 | ||
| 549 | + CreatedAt int64 `json:"createdAt"` // 注册时间 | ||
| 550 | + Roles []int64 `json:"roles"` // 角色 | ||
| 551 | + RolesDesc string `json:"rolesDesc"` // 角色描述 | ||
| 552 | + DepartmentsDesc string `json:"departmentsDesc"` // 部门描述 | ||
| 553 | +} | ||
| 554 | + | ||
| 555 | +type SystemUserUpdateRequest struct { | ||
| 556 | + Id int64 `path:"id"` | ||
| 557 | + Avatar string `json:"avatar,optional"` // 头像 | ||
| 558 | + Position string `json:"position"` // 职位 | ||
| 559 | + Departments []int64 `json:"departments"` // 所属部门 | ||
| 560 | +} | ||
| 561 | + | ||
| 562 | +type SystemUserUpdateResponse struct { | ||
| 563 | +} | ||
| 564 | + | ||
| 565 | +type SystemUserSearchRequest struct { | ||
| 566 | + Page int `json:"page"` | ||
| 567 | + Size int `json:"size"` | ||
| 568 | + Name string `json:"name,optional"` // 名称 | ||
| 569 | + Phone string `json:"phone,optional"` // 手机号 唯一 | ||
| 570 | + Position string `json:"position,optional"` // 职位 | ||
| 571 | + Enable int `json:"enable,optional"` // 启用状态 1:启用 2:禁用 | ||
| 572 | + DepartmentId int64 `json:"departmentId,optional"` // 所属部门 | ||
| 573 | +} | ||
| 574 | + | ||
| 575 | +type SystemUserSearchResponse struct { | ||
| 576 | + List []SystemUser `json:"list"` | ||
| 577 | + Total int64 `json:"total"` | ||
| 578 | +} | ||
| 579 | + | ||
| 580 | +type SystemUserAccountGetRequest struct { | ||
| 581 | + Id int64 `path:"id"` | ||
| 582 | +} | ||
| 583 | + | ||
| 584 | +type SystemUserAccountGetResponse struct { | ||
| 585 | + User SystemUser `json:"user"` | ||
| 586 | +} | ||
| 587 | + | ||
| 588 | +type SystemUserAccountSaveRequest struct { | ||
| 589 | + Name string `json:"name"` // 名称 | ||
| 590 | + Phone string `json:"phone"` // 手机号 唯一 | ||
| 591 | + Enable int `json:"enable"` // 启用状态 1:启用 2:禁用 | ||
| 592 | + Roles []int64 `json:"roles"` // 角色 | ||
| 593 | +} | ||
| 594 | + | ||
| 595 | +type SystemUserAccountSaveResponse struct { | ||
| 596 | +} | ||
| 597 | + | ||
| 598 | +type SystemUserAccountEnableRequest struct { | ||
| 599 | + UserIds []int64 `json:"userIds"` // 用户ID列表 | ||
| 600 | + Status int `json:"status"` // 状态 1:启用 2:禁用 | ||
| 601 | +} | ||
| 602 | + | ||
| 603 | +type SystemUserAccountEnableResponse struct { | ||
| 604 | +} | ||
| 605 | + | ||
| 606 | +type SystemUserAccountUpdateRequest struct { | ||
| 607 | + Id int64 `path:"id"` | ||
| 608 | +} | ||
| 609 | + | ||
| 610 | +type SystemUserAccountUpdateResponse struct { | ||
| 611 | +} | ||
| 612 | + | ||
| 613 | +type SystemUserAccountSearchRequest struct { | ||
| 614 | + Page int `json:"page"` | ||
| 615 | + Size int `json:"size"` | ||
| 616 | + Name string `json:"name,optional"` // 名称 | ||
| 617 | + Phone string `json:"phone,optional"` // 手机号 唯一 | ||
| 618 | + RoleId int64 `json:"roleId,optional"` // 角色权限 | ||
| 619 | + Enable int `json:"enable,optional"` // 启用状态 1:启用 2:禁用 | ||
| 620 | + BeginTime int64 `json:"beginTime,optional"` // 注册日期-开始 | ||
| 621 | + EndTime int64 `json:"endTime,optional"` // 注册日期-结束 | ||
| 622 | +} | ||
| 623 | + | ||
| 624 | +type SystemUserAccountSearchResponse struct { | ||
| 625 | + List []SystemUser `json:"list"` | ||
| 626 | + Total int64 `json:"total"` | ||
| 627 | +} | ||
| 628 | + | ||
| 518 | type CompanySearchRequest struct { | 629 | type CompanySearchRequest struct { |
| 519 | Page int `json:"page,optional"` | 630 | Page int `json:"page,optional"` |
| 520 | Size int `json:"size,optional"` | 631 | Size int `json:"size,optional"` |
| @@ -14,6 +14,7 @@ type User struct { | @@ -14,6 +14,7 @@ type User struct { | ||
| 14 | Roles []int64 `gorm:"type:jsonb;serializer:json"` // 角色 | 14 | Roles []int64 `gorm:"type:jsonb;serializer:json"` // 角色 |
| 15 | Flag int // 标识 1:管理员 2:普通用户 (有绑定角色是管理员) | 15 | Flag int // 标识 1:管理员 2:普通用户 (有绑定角色是管理员) |
| 16 | Name string // 名称 | 16 | Name string // 名称 |
| 17 | + PinYinName string | ||
| 17 | Avatar string // 头像 | 18 | Avatar string // 头像 |
| 18 | Phone string // 手机号 唯一 | 19 | Phone string // 手机号 唯一 |
| 19 | Position string // 职位 | 20 | Position string // 职位 |
| @@ -2,6 +2,7 @@ package repository | @@ -2,6 +2,7 @@ package repository | ||
| 2 | 2 | ||
| 3 | import ( | 3 | import ( |
| 4 | "context" | 4 | "context" |
| 5 | + "fmt" | ||
| 5 | "github.com/jinzhu/copier" | 6 | "github.com/jinzhu/copier" |
| 6 | "github.com/pkg/errors" | 7 | "github.com/pkg/errors" |
| 7 | "github.com/tiptok/gocomm/pkg/cache" | 8 | "github.com/tiptok/gocomm/pkg/cache" |
| @@ -141,7 +142,7 @@ func (repository *UserRepository) Find(ctx context.Context, conn transaction.Con | @@ -141,7 +142,7 @@ func (repository *UserRepository) Find(ctx context.Context, conn transaction.Con | ||
| 141 | total int64 | 142 | total int64 |
| 142 | ) | 143 | ) |
| 143 | queryFunc := func() (interface{}, error) { | 144 | queryFunc := func() (interface{}, error) { |
| 144 | - tx = tx.Model(&ms).Order("id asc") | 145 | + tx = tx.Model(&ms) |
| 145 | if v, ok := queryOptions["companyId"]; ok { | 146 | if v, ok := queryOptions["companyId"]; ok { |
| 146 | tx.Where("company_id = ?", v) | 147 | tx.Where("company_id = ?", v) |
| 147 | } | 148 | } |
| @@ -154,6 +155,34 @@ func (repository *UserRepository) Find(ctx context.Context, conn transaction.Con | @@ -154,6 +155,34 @@ func (repository *UserRepository) Find(ctx context.Context, conn transaction.Con | ||
| 154 | if v, ok := queryOptions["auditStatus"]; ok { | 155 | if v, ok := queryOptions["auditStatus"]; ok { |
| 155 | tx.Where("audit_status in (?)", v) | 156 | tx.Where("audit_status in (?)", v) |
| 156 | } | 157 | } |
| 158 | + | ||
| 159 | + // 列表查询条件 | ||
| 160 | + if v, ok := queryOptions["likeName"]; ok { | ||
| 161 | + tx.Where("name like ? ", fmt.Sprintf("%%%v%%", v)) | ||
| 162 | + } | ||
| 163 | + if v, ok := queryOptions["likePhone"]; ok { | ||
| 164 | + tx.Where("phone like ? ", fmt.Sprintf("%%%v%%", v)) | ||
| 165 | + } | ||
| 166 | + if v, ok := queryOptions["departmentId"]; ok { | ||
| 167 | + tx.Where(fmt.Sprintf("departments @>'[%v]'", v)) | ||
| 168 | + } | ||
| 169 | + if v, ok := queryOptions["roleId"]; ok { | ||
| 170 | + tx.Where(fmt.Sprintf("roles @>'[%v]'", v)) | ||
| 171 | + } | ||
| 172 | + if v, ok := queryOptions["enable"]; ok { | ||
| 173 | + tx.Where("enable = ?", v) | ||
| 174 | + } | ||
| 175 | + if v, ok := queryOptions["beginTime"]; ok { | ||
| 176 | + tx.Where("created_at >= ?", v) | ||
| 177 | + } | ||
| 178 | + if v, ok := queryOptions["endTime"]; ok { | ||
| 179 | + tx.Where("created_at < ?", v) | ||
| 180 | + } | ||
| 181 | + if v, ok := queryOptions["orderBy"]; ok { | ||
| 182 | + tx.Order(v) | ||
| 183 | + } else { | ||
| 184 | + tx.Order("id asc") | ||
| 185 | + } | ||
| 157 | if total, tx = transaction.PaginationAndCount(ctx, tx, queryOptions, &ms); tx.Error != nil { | 186 | if total, tx = transaction.PaginationAndCount(ctx, tx, queryOptions, &ms); tx.Error != nil { |
| 158 | return dms, tx.Error | 187 | return dms, tx.Error |
| 159 | } | 188 | } |
| @@ -64,6 +64,10 @@ func (options QueryOptions) WithFindOnly() QueryOptions { | @@ -64,6 +64,10 @@ func (options QueryOptions) WithFindOnly() QueryOptions { | ||
| 64 | options["findOnly"] = true | 64 | options["findOnly"] = true |
| 65 | return options | 65 | return options |
| 66 | } | 66 | } |
| 67 | +func (options QueryOptions) WithOrder(order string) QueryOptions { | ||
| 68 | + options["orderBy"] = order | ||
| 69 | + return options | ||
| 70 | +} | ||
| 67 | 71 | ||
| 68 | func LazyLoad[K comparable, T any](source map[K]T, ctx context.Context, conn transaction.Conn, k K, load func(context.Context, transaction.Conn, K) (T, error)) (T, error) { | 72 | func LazyLoad[K comparable, T any](source map[K]T, ctx context.Context, conn transaction.Conn, k K, load func(context.Context, transaction.Conn, K) (T, error)) (T, error) { |
| 69 | if v, ok := source[k]; ok { | 73 | if v, ok := source[k]; ok { |
| @@ -77,6 +81,15 @@ func LazyLoad[K comparable, T any](source map[K]T, ctx context.Context, conn tra | @@ -77,6 +81,15 @@ func LazyLoad[K comparable, T any](source map[K]T, ctx context.Context, conn tra | ||
| 77 | } | 81 | } |
| 78 | } | 82 | } |
| 79 | 83 | ||
| 84 | +func Values[T any, V any](list []T, each func(item T) V) []V { | ||
| 85 | + var result []V | ||
| 86 | + for _, item := range list { | ||
| 87 | + value := each(item) | ||
| 88 | + result = append(result, value) | ||
| 89 | + } | ||
| 90 | + return result | ||
| 91 | +} | ||
| 92 | + | ||
| 80 | /*************** 索引函数 ****************/ | 93 | /*************** 索引函数 ****************/ |
| 81 | func IndexCompanyId(companyId int64) IndexQueryOptionFunc { | 94 | func IndexCompanyId(companyId int64) IndexQueryOptionFunc { |
| 82 | return func() QueryOptions { | 95 | return func() QueryOptions { |
| @@ -5,6 +5,7 @@ import ( | @@ -5,6 +5,7 @@ import ( | ||
| 5 | "fmt" | 5 | "fmt" |
| 6 | "github.com/samber/lo" | 6 | "github.com/samber/lo" |
| 7 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/db/transaction" | 7 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/db/transaction" |
| 8 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/tool" | ||
| 8 | ) | 9 | ) |
| 9 | 10 | ||
| 10 | type User struct { | 11 | type User struct { |
| @@ -14,6 +15,7 @@ type User struct { | @@ -14,6 +15,7 @@ type User struct { | ||
| 14 | Roles []int64 `json:"roleId,omitempty"` // 角色 | 15 | Roles []int64 `json:"roleId,omitempty"` // 角色 |
| 15 | Flag int `json:"flag,omitempty"` // 标识 1:管理员 2:普通用户 (有绑定角色是管理员) | 16 | Flag int `json:"flag,omitempty"` // 标识 1:管理员 2:普通用户 (有绑定角色是管理员) |
| 16 | Name string `json:"name,omitempty"` // 名称 | 17 | Name string `json:"name,omitempty"` // 名称 |
| 18 | + PinYinName string `json:"pin_yin_name"` // 拼音名 | ||
| 17 | Avatar string `json:"avatar,omitempty"` // 头像 | 19 | Avatar string `json:"avatar,omitempty"` // 头像 |
| 18 | Phone string `json:"phone,omitempty"` // 手机号 唯一 | 20 | Phone string `json:"phone,omitempty"` // 手机号 唯一 |
| 19 | Position string `json:"position,omitempty"` // 职位 | 21 | Position string `json:"position,omitempty"` // 职位 |
| @@ -111,6 +113,7 @@ func (m *User) AddRole(roleId int64) { | @@ -111,6 +113,7 @@ func (m *User) AddRole(roleId int64) { | ||
| 111 | return | 113 | return |
| 112 | } | 114 | } |
| 113 | m.Roles = append(m.Roles, roleId) | 115 | m.Roles = append(m.Roles, roleId) |
| 116 | + m.Flag = lo.Ternary(len(m.Roles) > 0, UserAdmin, UserCommon) | ||
| 114 | } | 117 | } |
| 115 | 118 | ||
| 116 | // RemoveRole 移除角色 | 119 | // RemoveRole 移除角色 |
| @@ -121,6 +124,12 @@ func (m *User) RemoveRole(roleId int64) { | @@ -121,6 +124,12 @@ func (m *User) RemoveRole(roleId int64) { | ||
| 121 | m.Roles = lo.Without(m.Roles, roleId) | 124 | m.Roles = lo.Without(m.Roles, roleId) |
| 122 | } | 125 | } |
| 123 | 126 | ||
| 127 | +func (m *User) WithName(name string) *User { | ||
| 128 | + m.Name = name | ||
| 129 | + m.PinYinName = tool.ToPinYin(name, " ") | ||
| 130 | + return m | ||
| 131 | +} | ||
| 132 | + | ||
| 124 | type ( | 133 | type ( |
| 125 | LoginCreator interface { | 134 | LoginCreator interface { |
| 126 | WechatLogin(r WechatLoginRequest) (*LoginInfo, error) | 135 | WechatLogin(r WechatLoginRequest) (*LoginInfo, error) |
| @@ -72,6 +72,7 @@ require ( | @@ -72,6 +72,7 @@ require ( | ||
| 72 | github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect | 72 | github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect |
| 73 | github.com/modern-go/reflect2 v1.0.2 // indirect | 73 | github.com/modern-go/reflect2 v1.0.2 // indirect |
| 74 | github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 // indirect | 74 | github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 // indirect |
| 75 | + github.com/mozillazg/go-pinyin v0.20.0 // indirect | ||
| 75 | github.com/onsi/gomega v1.26.0 // indirect | 76 | github.com/onsi/gomega v1.26.0 // indirect |
| 76 | github.com/openzipkin/zipkin-go v0.4.1 // indirect | 77 | github.com/openzipkin/zipkin-go v0.4.1 // indirect |
| 77 | github.com/pelletier/go-toml v1.8.1 // indirect | 78 | github.com/pelletier/go-toml v1.8.1 // indirect |
pkg/tool/pinyin.go
0 → 100644
| 1 | +package tool | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "github.com/mozillazg/go-pinyin" | ||
| 5 | + "strings" | ||
| 6 | +) | ||
| 7 | + | ||
| 8 | +func ToPinYin(hans string, sep string) string { | ||
| 9 | + a := pinyin.NewArgs() | ||
| 10 | + tmp := pinyin.Pinyin(hans, a) | ||
| 11 | + result := make([]string, 0) | ||
| 12 | + for i := range tmp { | ||
| 13 | + result = append(result, tmp[i]...) | ||
| 14 | + } | ||
| 15 | + py := strings.Join(result, sep) | ||
| 16 | + if len(py) == 0 { | ||
| 17 | + return strings.ToLower(hans) | ||
| 18 | + } | ||
| 19 | + return py | ||
| 20 | +} |
-
请 注册 或 登录 后发表评论