作者 郑周

Merge remote-tracking branch 'origin/dev' into dev

正在显示 44 个修改的文件 包含 2561 行增加522 行删除
1 syntax = "v1" 1 syntax = "v1"
2 2
3 -import "core/article_type.api"  
4 import "core/comment.api" 3 import "core/comment.api"
5 import "core/message.api" 4 import "core/message.api"
6 import "core/article_tag.api" 5 import "core/article_tag.api"
7 import "core/user.api" 6 import "core/user.api"
8 import "core/company.api" 7 import "core/company.api"
  8 +import "core/article_type.api"
9 import "core/article.api" 9 import "core/article.api"
10 import "core/role.api" 10 import "core/role.api"
11 import "core/department.api" 11 import "core/department.api"
@@ -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": {
@@ -8,11 +8,10 @@ type Location { @@ -8,11 +8,10 @@ type Location {
8 } 8 }
9 9
10 // 人员的简单展示信息 10 // 人员的简单展示信息
11 -type Author { 11 +type ArticleAuthor {
12 Id int64 `json:"id"` // 人员id 12 Id int64 `json:"id"` // 人员id
13 Name string `json:"name"` // 人员的名字 13 Name string `json:"name"` // 人员的名字
14 Avatar string `json:"avatar"` // 人员头像URL 14 Avatar string `json:"avatar"` // 人员头像URL
15 - Group string `json:"group"` // 人员的分组  
16 Position string `json:"position"` // 职位 15 Position string `json:"position"` // 职位
17 Company string `json:"company"` // 公司 16 Company string `json:"company"` // 公司
18 } 17 }
@@ -37,13 +36,14 @@ type ( @@ -37,13 +36,14 @@ type (
37 type ( 36 type (
38 MiniArticleGetRequest { 37 MiniArticleGetRequest {
39 Id int64 `path:"id"` //id 38 Id int64 `path:"id"` //id
40 - CompanyId int64 `path:",optional"` 39 + CompanyId int64 `path:",optional"`//当前公司
  40 + UserId int `path:",optional"` //当前用户
41 } 41 }
42 MiniArticleGetResponse { 42 MiniArticleGetResponse {
43 Id int64 `json:"id"` //id 43 Id int64 `json:"id"` //id
44 Title string `json:"title"` //标题 44 Title string `json:"title"` //标题
45 AuthorId int64 `json:"authorId"` //发布人id 45 AuthorId int64 `json:"authorId"` //发布人id
46 - Author Author `json:"author"` //发布人 46 + Author ArticleAuthor `json:"author"` //发布人
47 CreatedAt int64 `json:"createdAt"` //文章的发布时间 47 CreatedAt int64 `json:"createdAt"` //文章的发布时间
48 Section []ArticleSection `json:"section"` //文章的文本内容 48 Section []ArticleSection `json:"section"` //文章的文本内容
49 Images []string `json:"images"` //图片 49 Images []string `json:"images"` //图片
@@ -55,6 +55,7 @@ type ( @@ -55,6 +55,7 @@ type (
55 CountRead int `json:"countRead"` // 浏览数量 55 CountRead int `json:"countRead"` // 浏览数量
56 Show int `json:"show"` // 评论的展示状态(0显示、1不显示) 56 Show int `json:"show"` // 评论的展示状态(0显示、1不显示)
57 Edit int `json:"edit"` // 文章是否存在变更记录 (0 不存在 1存在) 57 Edit int `json:"edit"` // 文章是否存在变更记录 (0 不存在 1存在)
  58 + MeLoveFlag int `json:"meLoveFlag"` //当前人员对文章的点赞标识
58 } 59 }
59 ArticleSection { 60 ArticleSection {
60 Id int64 `json:"id"` //段落id 61 Id int64 `json:"id"` //段落id
@@ -160,7 +161,7 @@ type ( @@ -160,7 +161,7 @@ type (
160 } 161 }
161 ) 162 )
162 163
163 -//创建文章到草稿箱 164 +//小程序端创建文章到草稿箱
164 type ( 165 type (
165 MiniArticleDraftCreateRequest { 166 MiniArticleDraftCreateRequest {
166 CompanyId int64 `json:",optional"` 167 CompanyId int64 `json:",optional"`
@@ -179,7 +180,7 @@ type ( @@ -179,7 +180,7 @@ type (
179 } 180 }
180 ) 181 )
181 182
182 -//更新文章草稿 183 +//小程序端更新文章草稿
183 type ( 184 type (
184 MiniArticleDraftUpdateRequest { 185 MiniArticleDraftUpdateRequest {
185 Id int64 `json:"id"` 186 Id int64 `json:"id"`
@@ -199,7 +200,7 @@ type ( @@ -199,7 +200,7 @@ type (
199 } 200 }
200 ) 201 )
201 202
202 -//获取我的草稿列表 203 +//小程序端获取我的草稿列表
203 type ( 204 type (
204 MiniArticleDraftSearchMeRequest { 205 MiniArticleDraftSearchMeRequest {
205 CompanyId int64 `json:",optional"` // 公司id 206 CompanyId int64 `json:",optional"` // 公司id
@@ -222,7 +223,7 @@ type ( @@ -222,7 +223,7 @@ type (
222 } 223 }
223 ) 224 )
224 225
225 -//获取我的草稿内容 226 +//小程序端获取我的草稿内容
226 type ( 227 type (
227 MiniArticleDraftGetMeRequest { 228 MiniArticleDraftGetMeRequest {
228 CompanyId int64 `path:",optional"` // 公司id 229 CompanyId int64 `path:",optional"` // 公司id
@@ -242,7 +243,7 @@ type ( @@ -242,7 +243,7 @@ type (
242 } 243 }
243 ) 244 )
244 245
245 -//删除我的草稿内容 246 +// 小程序端删除我的草稿内容
246 type ( 247 type (
247 MiniArticleDraftDeleteMeRequest { 248 MiniArticleDraftDeleteMeRequest {
248 CompanyId int64 `path:",optional"` // 公司id 249 CompanyId int64 `path:",optional"` // 公司id
@@ -254,7 +255,7 @@ type ( @@ -254,7 +255,7 @@ type (
254 Id int64 `json:"id"` // 255 Id int64 `json:"id"` //
255 } 256 }
256 ) 257 )
257 - 258 +// 小程序端获取我的浏览记录
258 type ( 259 type (
259 MiniArticleMarkListRequest { 260 MiniArticleMarkListRequest {
260 Page int `json:"page"` 261 Page int `json:"page"`
@@ -275,9 +276,11 @@ type ( @@ -275,9 +276,11 @@ type (
275 Author SimpleUser `json:"author"` // 发布人 276 Author SimpleUser `json:"author"` // 发布人
276 UpdatedAt int64 `json:"updatedAt"` 277 UpdatedAt int64 `json:"updatedAt"`
277 } 278 }
278 -  
279 ) 279 )
280 280
  281 +
  282 +
  283 +
281 //管理后台获取文章详情 284 //管理后台获取文章详情
282 type ( 285 type (
283 SystemArticleGetRequest { 286 SystemArticleGetRequest {
@@ -294,7 +297,7 @@ type ( @@ -294,7 +297,7 @@ type (
294 Id int64 `json:"id"` // id 297 Id int64 `json:"id"` // id
295 Title string `json:"title"` // 标题 298 Title string `json:"title"` // 标题
296 AuthorId int64 `json:"authorId"` // 发布人id 299 AuthorId int64 `json:"authorId"` // 发布人id
297 - Author Author `json:"author"` // 发布人 300 + Author ArticleAuthor `json:"author"` // 发布人
298 CreatedAt int64 `json:"createdAt"` // 文章的发布时间 301 CreatedAt int64 `json:"createdAt"` // 文章的发布时间
299 Section []ArticleSection `json:"section"` // 文章的文本内容 302 Section []ArticleSection `json:"section"` // 文章的文本内容
300 Images []string `json:"images"` // 图片 303 Images []string `json:"images"` // 图片
1 syntax = "v1" 1 syntax = "v1"
2 2
3 info( 3 info(
4 - title: "天联鹰蜓"  
5 - desc: "天联鹰蜓"  
6 - author: "email" 4 + title: "评论相关"
  5 + desc: "编辑处理文章的评论"
  6 + author: "author"
7 email: "email" 7 email: "email"
8 version: "v1" 8 version: "v1"
9 ) 9 )
10 10
11 // 小程序接口 11 // 小程序接口
12 @server( 12 @server(
13 - prefix: v1 13 + prefix: v1/mini
14 group: comment 14 group: comment
15 jwt: MiniAuth 15 jwt: MiniAuth
16 ) 16 )
17 service Core { 17 service Core {
18 - @doc "小程序评论"  
19 - @handler miniComment  
20 - get /mini/comment (CommentRequest) returns (CommentResposne) 18 +
  19 + @doc "小程序获取回复@人可选列表"
  20 + @handler MiniArticleCommentAtUser
  21 + post /article_comment/at_user/select (MiniArticleCommentAtUserRequest) returns (MiniArticleCommentAtUserResponse)
  22 +
  23 + @doc "小程序填写文章的评论"
  24 + @handler MiniCreateArticleComment
  25 + post /article_comment (MiniCreateArticleCommentRequest) returns (MiniCreateArticleCommentResponse)
21 } 26 }
22 27
23 -// 后台接口  
24 -@server(  
25 - prefix: v1  
26 - group: comment  
27 - jwt: SystemAuth 28 +//
  29 +// 小程序获取回复@人可选列表
  30 +type (
  31 + MiniArticleCommentAtUserRequest {
  32 + ArtitceId int64 `json:"articleId"`
  33 + }
  34 +
  35 + MiniArticleCommentAtUserResponse {
  36 + }
28 ) 37 )
29 -service Core {  
30 - @doc "系统评论"  
31 - @handler systemComment  
32 - get /system/comment (CommentRequest) returns (CommentResposne) 38 +
  39 +//评论的填写人
  40 +type CommentAuthor {
  41 + Id int64 `json:"id"` // 人员id
  42 + Name string `json:"name"` // 人员的名字
  43 + Avatar string `json:"avatar"` // 人员头像URL
  44 + Position string `json:"position"` // 职位
  45 + Company string `json:"company"` // 公司
33 } 46 }
34 47
  48 +// 小程序填写文章的评论
35 type ( 49 type (
36 - CommentRequest {  
37 - }  
38 - CommentResposne {  
39 - List []Comment `json:"list"` 50 + MiniCreateArticleCommentRequest {
  51 + ArtitcleId int64 `json:"articleId"` // 文章id
  52 + SectionId int64 `json:"sectionId"` // 段落id
  53 + FromUserId int64 `json:",optional"` // 填写文章的人,服务端自动获取
  54 + CompanyId int64 `json:",optional"` // 服务端自动获取
  55 + Pid int64 `json:"commnet"` // 回复那个评论的id
  56 + Content string `json:"content"` // 评论的内容
  57 + AtWho []int64 `json:"atWho"` // 填写评论时@的人
40 } 58 }
41 59
42 - Comment { 60 + MiniCreateArticleCommentResponse {
  61 + Id int64 `json:"id"`
  62 + Pid int64 `json:"pid"`
  63 + TopId int64 `json:"topId"`
  64 + ArtitcleId int64 `json:"articleId"` // 文章id
  65 + SectionId int64 `json:"sectionId"` // 段落id
  66 + FromUserId int64 `json:"fromUserId"` // 填写评论的人
  67 + FromUser CommentAuthor `json:"fromUser"` // 填写评论的人
  68 + ToUserId int64 `json:"toUserId"` // 回复哪个人
  69 + ToUser CommentAuthor `json:"toUser"` // 回复哪个人
  70 + SectionContent string `json:"sectionContent"` // 引用的文章内容文本
  71 + CountReply int `json:"countReply"` // 回复数量
  72 + CountUserLove int `json:"countUserLove"` // 用户点赞数量
  73 + CountAdminLove int `json:"countAdminLove"` // 运营点赞数量
  74 + AtWho []CommentAuthor `json:"atWho"` // 填写评论时@的人
43 } 75 }
44 ) 76 )
@@ -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 )
@@ -9,16 +9,16 @@ import ( @@ -9,16 +9,16 @@ import (
9 "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" 9 "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
10 ) 10 )
11 11
12 -func MiniCommentHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 12 +func MiniArticleCommentAtUserHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
13 return func(w http.ResponseWriter, r *http.Request) { 13 return func(w http.ResponseWriter, r *http.Request) {
14 - var req types.CommentRequest 14 + var req types.MiniArticleCommentAtUserRequest
15 if err := httpx.Parse(r, &req); err != nil { 15 if err := httpx.Parse(r, &req); err != nil {
16 httpx.ErrorCtx(r.Context(), w, err) 16 httpx.ErrorCtx(r.Context(), w, err)
17 return 17 return
18 } 18 }
19 19
20 - l := comment.NewMiniCommentLogic(r.Context(), svcCtx)  
21 - resp, err := l.MiniComment(&req) 20 + l := comment.NewMiniArticleCommentAtUserLogic(r.Context(), svcCtx)
  21 + resp, err := l.MiniArticleCommentAtUser(&req)
22 if err != nil { 22 if err != nil {
23 httpx.ErrorCtx(r.Context(), w, err) 23 httpx.ErrorCtx(r.Context(), w, err)
24 } else { 24 } else {
@@ -7,22 +7,22 @@ import ( @@ -7,22 +7,22 @@ import (
7 "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/comment" 7 "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/comment"
8 "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" 8 "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
9 "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" 9 "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
  10 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/contextdata"
  11 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/result"
10 ) 12 )
11 13
12 -func SystemCommentHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 14 +func MiniCreateArticleCommentHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
13 return func(w http.ResponseWriter, r *http.Request) { 15 return func(w http.ResponseWriter, r *http.Request) {
14 - var req types.CommentRequest 16 + var req types.MiniCreateArticleCommentRequest
15 if err := httpx.Parse(r, &req); err != nil { 17 if err := httpx.Parse(r, &req); err != nil {
16 httpx.ErrorCtx(r.Context(), w, err) 18 httpx.ErrorCtx(r.Context(), w, err)
17 return 19 return
18 } 20 }
19 -  
20 - l := comment.NewSystemCommentLogic(r.Context(), svcCtx)  
21 - resp, err := l.SystemComment(&req)  
22 - if err != nil {  
23 - httpx.ErrorCtx(r.Context(), w, err)  
24 - } else {  
25 - httpx.OkJsonCtx(r.Context(), w, resp)  
26 - } 21 + l := comment.NewMiniCreateArticleCommentLogic(r.Context(), svcCtx)
  22 + token := contextdata.GetUserTokenFromCtx(r.Context())
  23 + req.CompanyId = token.CompanyId
  24 + req.FromUserId = token.UserId
  25 + resp, err := l.MiniCreateArticleComment(&req)
  26 + result.HttpResult(r, w, resp, err)
27 } 27 }
28 } 28 }
@@ -21,25 +21,18 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { @@ -21,25 +21,18 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
21 server.AddRoutes( 21 server.AddRoutes(
22 []rest.Route{ 22 []rest.Route{
23 { 23 {
24 - Method: http.MethodGet,  
25 - Path: "/mini/comment",  
26 - Handler: comment.MiniCommentHandler(serverCtx),  
27 - }, 24 + Method: http.MethodPost,
  25 + Path: "/article_comment/at_user/select",
  26 + Handler: comment.MiniArticleCommentAtUserHandler(serverCtx),
28 }, 27 },
29 - rest.WithJwt(serverCtx.Config.MiniAuth.AccessSecret),  
30 - rest.WithPrefix("/v1"),  
31 - )  
32 -  
33 - server.AddRoutes(  
34 - []rest.Route{  
35 { 28 {
36 - Method: http.MethodGet,  
37 - Path: "/system/comment",  
38 - Handler: comment.SystemCommentHandler(serverCtx), 29 + Method: http.MethodPost,
  30 + Path: "/article_comment",
  31 + Handler: comment.MiniCreateArticleCommentHandler(serverCtx),
39 }, 32 },
40 }, 33 },
41 - rest.WithJwt(serverCtx.Config.SystemAuth.AccessSecret),  
42 - rest.WithPrefix("/v1"), 34 + rest.WithJwt(serverCtx.Config.MiniAuth.AccessSecret),
  35 + rest.WithPrefix("/v1/mini"),
43 ) 36 )
44 37
45 server.AddRoutes( 38 server.AddRoutes(
@@ -171,6 +164,51 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { @@ -171,6 +164,51 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
171 Path: "/system/user/info", 164 Path: "/system/user/info",
172 Handler: user.SystemUserInfoHandler(serverCtx), 165 Handler: user.SystemUserInfoHandler(serverCtx),
173 }, 166 },
  167 + {
  168 + Method: http.MethodPost,
  169 + Path: "/system/user/statistics",
  170 + Handler: user.SystemUserStatisticsHandler(serverCtx),
  171 + },
  172 + {
  173 + Method: http.MethodGet,
  174 + Path: "/system/user/:id",
  175 + Handler: user.SystemUserGetHandler(serverCtx),
  176 + },
  177 + {
  178 + Method: http.MethodPut,
  179 + Path: "/system/user/:id",
  180 + Handler: user.SystemUserUpdateHandler(serverCtx),
  181 + },
  182 + {
  183 + Method: http.MethodPost,
  184 + Path: "/system/user/search",
  185 + Handler: user.SystemUserSearchHandler(serverCtx),
  186 + },
  187 + {
  188 + Method: http.MethodGet,
  189 + Path: "/system/account/:id",
  190 + Handler: user.SystemUserAccountGetHandler(serverCtx),
  191 + },
  192 + {
  193 + Method: http.MethodPost,
  194 + Path: "/system/account",
  195 + Handler: user.SystemUserAccountSaveHandler(serverCtx),
  196 + },
  197 + {
  198 + Method: http.MethodPost,
  199 + Path: "/system/account/enable",
  200 + Handler: user.SystemUserAccountEnableHandler(serverCtx),
  201 + },
  202 + {
  203 + Method: http.MethodPut,
  204 + Path: "/system/account/:id",
  205 + Handler: user.SystemUserAccountUpdateHandler(serverCtx),
  206 + },
  207 + {
  208 + Method: http.MethodPost,
  209 + Path: "/system/account/search",
  210 + Handler: user.SystemUserAccountSearchHandler(serverCtx),
  211 + },
174 }, 212 },
175 rest.WithJwt(serverCtx.Config.SystemAuth.AccessSecret), 213 rest.WithJwt(serverCtx.Config.SystemAuth.AccessSecret),
176 rest.WithPrefix("/v1"), 214 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 +}
@@ -43,19 +43,10 @@ func (l *MiniCreateArticleLogic) MiniCreateArticle(req *types.MiniArticleCreateR @@ -43,19 +43,10 @@ func (l *MiniCreateArticleLogic) MiniCreateArticle(req *types.MiniArticleCreateR
43 Id: author.Id, 43 Id: author.Id,
44 Name: author.Name, 44 Name: author.Name,
45 Avatar: author.Avatar, 45 Avatar: author.Avatar,
46 - GroupId: 0,  
47 - Group: "",  
48 Position: author.Position, 46 Position: author.Position,
49 Company: companyInfo.Name, 47 Company: companyInfo.Name,
50 CompanyId: author.CompanyId, 48 CompanyId: author.CompanyId,
51 } 49 }
52 - if author.DepartmentId > 0 {  
53 - department, err := l.svcCtx.DepartmentRepository.FindOne(l.ctx, conn, author.DepartmentId)  
54 - if err == nil {  
55 - articleAuthor.GroupId = department.Id  
56 - articleAuthor.Group = department.Name  
57 - }  
58 - }  
59 if len(req.Images) > 9 { 50 if len(req.Images) > 9 {
60 return nil, xerr.NewErrMsg("图片数量最多9张") 51 return nil, xerr.NewErrMsg("图片数量最多9张")
61 } 52 }
@@ -38,7 +38,10 @@ func (l *MiniGetArticleLogic) MiniGetArticle(req *types.MiniArticleGetRequest) ( @@ -38,7 +38,10 @@ func (l *MiniGetArticleLogic) MiniGetArticle(req *types.MiniArticleGetRequest) (
38 return nil, xerr.NewErrMsg("没有查看权限") 38 return nil, xerr.NewErrMsg("没有查看权限")
39 } 39 }
40 40
  41 + //TODO 检查可查看人
  42 +
41 if articleInfo.Show == domain.ArticleShowDisable { 43 if articleInfo.Show == domain.ArticleShowDisable {
  44 + // 文章内容不显示
42 resp = &types.MiniArticleGetResponse{ 45 resp = &types.MiniArticleGetResponse{
43 Id: articleInfo.Id, 46 Id: articleInfo.Id,
44 Title: articleInfo.Title, 47 Title: articleInfo.Title,
@@ -54,6 +57,20 @@ func (l *MiniGetArticleLogic) MiniGetArticle(req *types.MiniArticleGetRequest) ( @@ -54,6 +57,20 @@ func (l *MiniGetArticleLogic) MiniGetArticle(req *types.MiniArticleGetRequest) (
54 if err != nil { 57 if err != nil {
55 return nil, xerr.NewErrMsgErr("读取文章内容失败", err) 58 return nil, xerr.NewErrMsgErr("读取文章内容失败", err)
56 } 59 }
  60 + var meLoveFlag int
  61 + if req.UserId > 0 {
  62 + // 获取我对文章的点赞标识
  63 + queryOption = domain.NewQueryOptions().
  64 + WithCountOnly().
  65 + MustWithKV("articleId", articleInfo.Id).
  66 + MustWithKV("commentId", 0).
  67 + MustWithKV("userId", req.UserId)
  68 + cnt, _, _ := l.svcCtx.UserLoveFlagRepository.Find(l.ctx, conn, queryOption)
  69 + if cnt > 0 {
  70 + meLoveFlag = 1
  71 + }
  72 + }
  73 +
57 sortBy := domain.SortArticleSection(sectionList) 74 sortBy := domain.SortArticleSection(sectionList)
58 sort.Sort(sortBy) 75 sort.Sort(sortBy)
59 articleSection := []types.ArticleSection{} 76 articleSection := []types.ArticleSection{}
@@ -70,11 +87,11 @@ func (l *MiniGetArticleLogic) MiniGetArticle(req *types.MiniArticleGetRequest) ( @@ -70,11 +87,11 @@ func (l *MiniGetArticleLogic) MiniGetArticle(req *types.MiniArticleGetRequest) (
70 Id: articleInfo.Id, 87 Id: articleInfo.Id,
71 Title: articleInfo.Title, 88 Title: articleInfo.Title,
72 AuthorId: articleInfo.AuthorId, 89 AuthorId: articleInfo.AuthorId,
73 - Author: types.Author{ 90 + Author: types.ArticleAuthor{
74 Id: articleInfo.Author.Id, 91 Id: articleInfo.Author.Id,
75 Name: articleInfo.Author.Name, 92 Name: articleInfo.Author.Name,
76 Avatar: articleInfo.Author.Avatar, 93 Avatar: articleInfo.Author.Avatar,
77 - Group: articleInfo.Author.Group, 94 + // Group: articleInfo.Author.Group,
78 Position: articleInfo.Author.Position, 95 Position: articleInfo.Author.Position,
79 Company: articleInfo.Author.Company, 96 Company: articleInfo.Author.Company,
80 }, 97 },
@@ -93,6 +110,7 @@ func (l *MiniGetArticleLogic) MiniGetArticle(req *types.MiniArticleGetRequest) ( @@ -93,6 +110,7 @@ func (l *MiniGetArticleLogic) MiniGetArticle(req *types.MiniArticleGetRequest) (
93 CountRead: articleInfo.CountRead, 110 CountRead: articleInfo.CountRead,
94 Show: int(articleInfo.Show), 111 Show: int(articleInfo.Show),
95 Edit: 0, 112 Edit: 0,
  113 + MeLoveFlag: meLoveFlag,
96 } 114 }
97 if articleInfo.CreatedAt != articleInfo.UpdatedAt { 115 if articleInfo.CreatedAt != articleInfo.UpdatedAt {
98 resp.Edit = 1 116 resp.Edit = 1
@@ -9,21 +9,21 @@ import ( @@ -9,21 +9,21 @@ import (
9 "github.com/zeromicro/go-zero/core/logx" 9 "github.com/zeromicro/go-zero/core/logx"
10 ) 10 )
11 11
12 -type MiniCommentLogic struct { 12 +type MiniArticleCommentAtUserLogic struct {
13 logx.Logger 13 logx.Logger
14 ctx context.Context 14 ctx context.Context
15 svcCtx *svc.ServiceContext 15 svcCtx *svc.ServiceContext
16 } 16 }
17 17
18 -func NewMiniCommentLogic(ctx context.Context, svcCtx *svc.ServiceContext) *MiniCommentLogic {  
19 - return &MiniCommentLogic{ 18 +func NewMiniArticleCommentAtUserLogic(ctx context.Context, svcCtx *svc.ServiceContext) *MiniArticleCommentAtUserLogic {
  19 + return &MiniArticleCommentAtUserLogic{
20 Logger: logx.WithContext(ctx), 20 Logger: logx.WithContext(ctx),
21 ctx: ctx, 21 ctx: ctx,
22 svcCtx: svcCtx, 22 svcCtx: svcCtx,
23 } 23 }
24 } 24 }
25 25
26 -func (l *MiniCommentLogic) MiniComment(req *types.CommentRequest) (resp *types.CommentResposne, err error) { 26 +func (l *MiniArticleCommentAtUserLogic) MiniArticleCommentAtUser(req *types.MiniArticleCommentAtUserRequest) (resp *types.MiniArticleCommentAtUserResponse, err error) {
27 // todo: add your logic here and delete this line 27 // todo: add your logic here and delete this line
28 28
29 return 29 return
  1 +package comment
  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 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/db/transaction"
  9 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain"
  10 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr"
  11 +
  12 + "text/template"
  13 +
  14 + "github.com/zeromicro/go-zero/core/logx"
  15 +)
  16 +
  17 +type MiniCreateArticleCommentLogic struct {
  18 + logx.Logger
  19 + ctx context.Context
  20 + svcCtx *svc.ServiceContext
  21 +}
  22 +
  23 +func NewMiniCreateArticleCommentLogic(ctx context.Context, svcCtx *svc.ServiceContext) *MiniCreateArticleCommentLogic {
  24 + return &MiniCreateArticleCommentLogic{
  25 + Logger: logx.WithContext(ctx),
  26 + ctx: ctx,
  27 + svcCtx: svcCtx,
  28 + }
  29 +}
  30 +
  31 +// 填写评论
  32 +func (l *MiniCreateArticleCommentLogic) MiniCreateArticleComment(req *types.MiniCreateArticleCommentRequest) (resp *types.MiniCreateArticleCommentResponse, err error) {
  33 + var conn = l.svcCtx.DefaultDBConn()
  34 + // 获取评论填写人的信息
  35 + fromUser, err := l.svcCtx.UserRepository.FindOne(l.ctx, conn, req.FromUserId)
  36 + if err != nil {
  37 + return nil, xerr.NewErrMsgErr("获取评论人信息失败", err)
  38 + }
  39 + companyInfo, err := l.svcCtx.CompanyRepository.FindOne(l.ctx, conn, req.CompanyId)
  40 + if err != nil {
  41 + return nil, xerr.NewErrMsgErr("获取公司信息失败", err)
  42 + }
  43 + // 获取文章
  44 + articleInfo, err := l.svcCtx.ArticleRepository.FindOne(l.ctx, conn, req.ArtitcleId)
  45 + if err != nil {
  46 + return nil, xerr.NewErrMsgErr("获取文章信息失败", err)
  47 + }
  48 + if articleInfo.CompanyId != req.CompanyId {
  49 + return nil, xerr.NewErrMsg("没有评论权限")
  50 + }
  51 + //查看评论权限,
  52 + //临时注释
  53 + // if len(articleInfo.WhoReview) > 0 {
  54 + // ok := lo.IndexOf(articleInfo.WhoReview, req.FromUserId)
  55 + // if ok < 0 {
  56 + // return nil, xerr.NewErrMsg("没有评论权限")
  57 + // }
  58 + // }
  59 + // 对段落进行评论
  60 + var selctionInfo *domain.ArticleSection
  61 + if req.SectionId > 0 {
  62 + //获取段落
  63 + selctionInfo, err = l.svcCtx.ArticleSectionRepository.FindOne(l.ctx, conn, req.SectionId)
  64 + if err != nil {
  65 + return nil, xerr.NewErrMsgErr("获取文章段落信息失败", err)
  66 + }
  67 + if selctionInfo.ArticleId != articleInfo.Id {
  68 + return nil, xerr.NewErrMsg("获取文章段落信息失败")
  69 + }
  70 + }
  71 + // 回复哪个评论
  72 + var pComment *domain.ArticleComment
  73 + if req.Pid > 0 {
  74 + pComment, err = l.svcCtx.ArticleCommentRepository.FindOne(l.ctx, conn, req.Pid)
  75 + if err != nil {
  76 + return nil, xerr.NewErrMsgErr("获取上一层级的评论信息失败", err)
  77 + }
  78 +
  79 + if pComment.ArticleId != articleInfo.Id {
  80 + if err != nil {
  81 + return nil, xerr.NewErrMsg("评论信息与文章不匹配")
  82 + }
  83 + }
  84 + }
  85 + var atWhoList []*domain.User
  86 + if len(req.AtWho) > 0 {
  87 + queryOption := domain.NewQueryOptions().WithFindOnly().WithKV("ids", req.AtWho)
  88 + _, atWhoList, err = l.svcCtx.UserRepository.Find(l.ctx, conn, queryOption)
  89 + if err != nil {
  90 + return nil, xerr.NewErrMsgErr("检查@的人员失败", err)
  91 + }
  92 + }
  93 + // 处理文本内容
  94 + // content:=
  95 + content := template.HTMLEscapeString(req.Content)
  96 +
  97 + newComment := domain.ArticleComment{
  98 + Id: 0,
  99 + CompanyId: req.CompanyId,
  100 + CreatedAt: 0,
  101 + UpdatedAt: 0,
  102 + DeletedAt: 0,
  103 + Version: 0,
  104 + Pid: req.Pid,
  105 + TopId: 0,
  106 + ArticleId: req.ArtitcleId,
  107 + SectionId: req.SectionId,
  108 + SectionContent: "",
  109 + FromUserId: req.FromUserId,
  110 + FromUser: domain.UserSimple{
  111 + Id: fromUser.Id,
  112 + Name: fromUser.Name,
  113 + Avatar: fromUser.Avatar,
  114 + Position: fromUser.Position,
  115 + Company: companyInfo.Name,
  116 + CompanyId: companyInfo.Id,
  117 + },
  118 + ToUserId: 0,
  119 + ToUser: domain.UserSimple{},
  120 + Content: content,
  121 + CountReply: 0,
  122 + CountUserLove: 0,
  123 + CountAdminLove: 0,
  124 + Show: 0,
  125 + AtWho: []domain.UserSimple{},
  126 + }
  127 +
  128 + if selctionInfo != nil {
  129 + newComment.SectionContent = selctionInfo.Content
  130 + }
  131 + if pComment != nil {
  132 + newComment.TopId = pComment.TopId
  133 + if pComment.TopId == 0 {
  134 + newComment.TopId = pComment.Id
  135 + }
  136 + newComment.ToUser = pComment.FromUser
  137 + newComment.ToUserId = pComment.FromUserId
  138 + newComment.SectionId = pComment.SectionId
  139 + }
  140 + for i := range atWhoList {
  141 + newComment.AtWho = append(newComment.AtWho, domain.UserSimple{
  142 + Id: atWhoList[i].Id,
  143 + Name: atWhoList[i].Name,
  144 + Avatar: atWhoList[i].Avatar,
  145 + Position: atWhoList[i].Position,
  146 + Company: companyInfo.Name,
  147 + CompanyId: companyInfo.Id,
  148 + })
  149 + }
  150 + //保存数据
  151 + err = transaction.UseTrans(l.ctx, conn.DB(), func(ctx context.Context, c transaction.Conn) error {
  152 + // 增加平评论计数
  153 + err = l.svcCtx.ArticleRepository.IncreaseCountComment(ctx, c, 1, articleInfo)
  154 + if err != nil {
  155 + return err
  156 + }
  157 + //保存评论
  158 + _, err = l.svcCtx.ArticleCommentRepository.Insert(ctx, c, &newComment)
  159 + if err != nil {
  160 + return err
  161 + }
  162 + return nil
  163 + }, true)
  164 +
  165 + if err != nil {
  166 + return nil, xerr.NewErrMsgErr("保存评论失败", err)
  167 + }
  168 +
  169 + resp = &types.MiniCreateArticleCommentResponse{
  170 + Id: newComment.Id,
  171 + Pid: newComment.Pid,
  172 + TopId: newComment.TopId,
  173 + ArtitcleId: newComment.ArticleId,
  174 + SectionId: newComment.ArticleId,
  175 + FromUserId: newComment.FromUserId,
  176 + FromUser: types.CommentAuthor{
  177 + Id: newComment.FromUser.Id,
  178 + Name: newComment.FromUser.Name,
  179 + Avatar: newComment.FromUser.Avatar,
  180 + Position: newComment.FromUser.Position,
  181 + Company: newComment.FromUser.Company,
  182 + },
  183 + ToUserId: newComment.ToUserId,
  184 + ToUser: types.CommentAuthor{
  185 + Id: newComment.ToUser.Id,
  186 + Name: newComment.ToUser.Name,
  187 + Avatar: newComment.ToUser.Avatar,
  188 + Position: newComment.ToUser.Position,
  189 + Company: newComment.ToUser.Company,
  190 + },
  191 + SectionContent: newComment.SectionContent,
  192 + CountReply: 0,
  193 + CountUserLove: 0,
  194 + CountAdminLove: 0,
  195 + AtWho: []types.CommentAuthor{},
  196 + }
  197 +
  198 + for _, val := range newComment.AtWho {
  199 + resp.AtWho = append(resp.AtWho, types.CommentAuthor{
  200 + Id: val.Id,
  201 + Name: val.Name,
  202 + Avatar: val.Avatar,
  203 + Position: val.Position,
  204 + Company: val.Company,
  205 + })
  206 + }
  207 +
  208 + return resp, nil
  209 +}
@@ -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 comment 1 +package user
2 2
3 import ( 3 import (
4 "context" 4 "context"
@@ -9,21 +9,21 @@ import ( @@ -9,21 +9,21 @@ import (
9 "github.com/zeromicro/go-zero/core/logx" 9 "github.com/zeromicro/go-zero/core/logx"
10 ) 10 )
11 11
12 -type SystemCommentLogic struct { 12 +type SystemUserStatisticsLogic struct {
13 logx.Logger 13 logx.Logger
14 ctx context.Context 14 ctx context.Context
15 svcCtx *svc.ServiceContext 15 svcCtx *svc.ServiceContext
16 } 16 }
17 17
18 -func NewSystemCommentLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SystemCommentLogic {  
19 - return &SystemCommentLogic{ 18 +func NewSystemUserStatisticsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SystemUserStatisticsLogic {
  19 + return &SystemUserStatisticsLogic{
20 Logger: logx.WithContext(ctx), 20 Logger: logx.WithContext(ctx),
21 ctx: ctx, 21 ctx: ctx,
22 svcCtx: svcCtx, 22 svcCtx: svcCtx,
23 } 23 }
24 } 24 }
25 25
26 -func (l *SystemCommentLogic) SystemComment(req *types.CommentRequest) (resp *types.CommentResposne, err error) { 26 +func (l *SystemUserStatisticsLogic) SystemUserStatistics(req *types.UserStatisticsRequest) (resp *types.UserStatisticsResponse, err error) {
27 // todo: add your logic here and delete this line 27 // todo: add your logic here and delete this line
28 28
29 return 29 return
  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 +}
1 // Code generated by goctl. DO NOT EDIT. 1 // Code generated by goctl. DO NOT EDIT.
2 package types 2 package types
3 3
4 -type Location struct {  
5 - Longitude float64 `json:"longitude,optional"` //经度  
6 - Latitude float64 `json:"latitude,optional"` //纬度  
7 - Descript string `json:"descript,optional"` //地点描述 4 +type MiniArticleCommentAtUserRequest struct {
  5 + ArtitceId int64 `json:"articleId"`
8 } 6 }
9 7
10 -type Author struct { 8 +type MiniArticleCommentAtUserResponse struct {
  9 +}
  10 +
  11 +type CommentAuthor struct {
11 Id int64 `json:"id"` // 人员id 12 Id int64 `json:"id"` // 人员id
12 Name string `json:"name"` // 人员的名字 13 Name string `json:"name"` // 人员的名字
13 Avatar string `json:"avatar"` // 人员头像URL 14 Avatar string `json:"avatar"` // 人员头像URL
14 - Group string `json:"group"` // 人员的分组  
15 Position string `json:"position"` // 职位 15 Position string `json:"position"` // 职位
16 Company string `json:"company"` // 公司 16 Company string `json:"company"` // 公司
17 } 17 }
18 18
19 -type MiniArticleCreateRequest struct {  
20 - Title string `json:"title"` //标题  
21 - Section []string `json:"section"` //文章的文本内容  
22 - AuthorId int64 `json:"authorId,optional"` //发布人id  
23 - Images []string `json:"images,optional"` //图片  
24 - WhoRead []int64 `json:"whoRead,optional"` //谁可查看  
25 - WhoReview []int64 `json:"whoReview,optional"` //谁可评论  
26 - Location Location `json:"location,optional"` //定位坐标 19 +type MiniCreateArticleCommentRequest struct {
  20 + ArtitcleId int64 `json:"articleId"` // 文章id
  21 + SectionId int64 `json:"sectionId"` // 段落id
  22 + FromUserId int64 `json:",optional"` // 填写文章的人,服务端自动获取
  23 + CompanyId int64 `json:",optional"` // 服务端自动获取
  24 + Pid int64 `json:"commnet"` // 回复那个评论的id
  25 + Content string `json:"content"` // 评论的内容
  26 + AtWho []int64 `json:"atWho"` // 填写评论时@的人
27 } 27 }
28 28
29 -type MiniArticleCreateResponse struct { 29 +type MiniCreateArticleCommentResponse struct {
30 Id int64 `json:"id"` 30 Id int64 `json:"id"`
  31 + Pid int64 `json:"pid"`
  32 + TopId int64 `json:"topId"`
  33 + ArtitcleId int64 `json:"articleId"` // 文章id
  34 + SectionId int64 `json:"sectionId"` // 段落id
  35 + FromUserId int64 `json:"fromUserId"` // 填写评论的人
  36 + FromUser CommentAuthor `json:"fromUser"` // 填写评论的人
  37 + ToUserId int64 `json:"toUserId"` // 回复哪个人
  38 + ToUser CommentAuthor `json:"toUser"` // 回复哪个人
  39 + SectionContent string `json:"sectionContent"` // 引用的文章内容文本
  40 + CountReply int `json:"countReply"` // 回复数量
  41 + CountUserLove int `json:"countUserLove"` // 用户点赞数量
  42 + CountAdminLove int `json:"countAdminLove"` // 运营点赞数量
  43 + AtWho []CommentAuthor `json:"atWho"` // 填写评论时@的人
31 } 44 }
32 45
33 -type MiniArticleGetRequest struct {  
34 - Id int64 `path:"id"` //id  
35 - CompanyId int64 `path:",optional"`  
36 -}  
37 -  
38 -type MiniArticleGetResponse struct {  
39 - Id int64 `json:"id"` //id  
40 - Title string `json:"title"` //标题  
41 - AuthorId int64 `json:"authorId"` //发布人id  
42 - Author Author `json:"author"` //发布人  
43 - CreatedAt int64 `json:"createdAt"` //文章的发布时间  
44 - Section []ArticleSection `json:"section"` //文章的文本内容  
45 - Images []string `json:"images"` //图片  
46 - WhoRead []int64 `json:"whoRead"` //谁可查看  
47 - WhoReview []int64 `json:"whoReview"` //谁可评论  
48 - Location Location `json:"location"` //定位坐标  
49 - CountLove int `json:"countLove"` // 点赞数量  
50 - CountComment int `json:"countComment"` // 评论数量  
51 - CountRead int `json:"countRead"` // 浏览数量  
52 - Show int `json:"show"` // 评论的展示状态(0显示、1不显示)  
53 - Edit int `json:"edit"` // 文章是否存在变更记录 (0 不存在 1存在)  
54 -}  
55 -  
56 -type ArticleSection struct {  
57 - Id int64 `json:"id"` //段落id  
58 - Content string `json:"content"` // 文本内容  
59 - SortBy int `json:"sortBy"` // 排序  
60 - TotalComment int `json:"totalComment"` // 评论的数量  
61 -}  
62 -  
63 -type MiniArticleSearchMeRequest struct {  
64 - AuthorId int64 `json:",optional"`  
65 - CompanyId int64 `json:",optional"` 46 +type MessageSystemRequest struct {
66 Page int `json:"page"` 47 Page int `json:"page"`
67 Size int `json:"size"` 48 Size int `json:"size"`
68 } 49 }
69 50
70 -type MiniArticleSearchMeResponse struct {  
71 - Total int `json:"total"`  
72 - List []ArticleSearchMe `json:"list"`  
73 -}  
74 -  
75 -type ArticleSearchMe struct {  
76 - Id int64 `json:"id"` //id  
77 - Title string `json:"title"` //标题  
78 - Images []string `json:"images"` //图片  
79 - CreatedAt int64 `json:"createdAt"` //文章的创建日期  
80 - CountLove int `json:"countLove"` //点赞数量  
81 - CountComment int `json:"CountComment"` //评论数量  
82 - Show int `json:"show"` //是否隐藏 [0显示、1不显示]  
83 -}  
84 -  
85 -type MiniUserLikeArticleRequest struct {  
86 - ArticleId int64 `json:"articleId"` // 文章id  
87 - CompanyId int64 `json:",optional"` //公司id  
88 - Page int `json:"page"` //分页,第几页  
89 - Size int `json:"size"` //分页,每页几条  
90 -}  
91 -  
92 -type MiniUserLikeArticleResponse struct {  
93 - Total int64 `json:"total"` //总数  
94 - List []WhichUserLikeArticle `json:"list"` //列表  
95 -}  
96 -  
97 -type WhichUserLikeArticle struct {  
98 - ArticleId int64 `json:"articleId"` // 文章id  
99 - UserId int64 `json:"userId"` // 人员id  
100 - Name string `json:"name"` // 人员名称  
101 - Avatar string `json:"avatar"` // 人员头像  
102 - CreatedAt int64 `json:"createdAt"` // 点赞记录的时间  
103 -}  
104 -  
105 -type MiniSetUserLikeRequset struct {  
106 - ArticleId int64 `json:"articleId"` //文章id  
107 - CommentId int64 `json:"commentId"` //评论id  
108 - UserId int64 `json:",optional"` //操作人  
109 - Flag int `json:"flag"` //点赞标志 1、点赞 2 、取消点赞 51 +type MessageSystemResponse struct {
  52 + List []MessageSystemItem `json:"list"`
  53 + Total int64 `json:"total"`
110 } 54 }
111 55
112 -type MiniSetUserLikeResponse struct {  
113 - ArticleId int64 `json:"articleId"` //文章id  
114 - CommentId int64 `json:"commentId"` //评论id  
115 - Count int `json:"count"` //现有的点赞数量 56 +type MessageSystemItem struct {
  57 + Id int64 `json:"id"` // ID
  58 + Type int `json:"type"` // 系统分类
  59 + Title string `json:"title"` // 标题
  60 + Content string `json:"content"` // 内容
  61 + CreatedAt int64 `json:"createdAt"` // 创建时间
116 } 62 }
117 63
118 -type MiniArticleBackupSearchRequest struct { 64 +type MessageBusinessRequest struct {
  65 + Type int `json:"type"`
119 Page int `json:"page"` 66 Page int `json:"page"`
120 Size int `json:"size"` 67 Size int `json:"size"`
121 - ArticleId int `json:"articleId"`  
122 - CompanyId int64 `json:",optional"` // 服务端自动获取  
123 } 68 }
124 69
125 -type MiniArticleBackupSearchResponse struct { 70 +type MessageBusinessResponse struct {
  71 + List []MessageBusinessItem `json:"list"`
126 Total int64 `json:"total"` 72 Total int64 `json:"total"`
127 - List []MiniArticleBackupItem `json:"list"`  
128 } 73 }
129 74
130 -type MiniArticleBackupItem struct { 75 +type MessageBusinessItem struct {
131 Id int64 `json:"id"` 76 Id int64 `json:"id"`
132 - Title string `json:"title"`  
133 - Content string `json:"content"`  
134 - Images []string `json:"images"`  
135 - CreatedAt int64 `json:"createdAt"`  
136 - Location Location `json:"location"` 77 + Type int `json:"type"` // 分类 (1回复 2点赞 3被采纳)
  78 + OptType int `json:"optType"` // 操作类型(1针对文章、1针对评论、2针对圆桌)
  79 + CompanyId int64 `json:"companyId"` // 操作人公司ID
  80 + UserId int64 `json:"userId"` // 操作人用户ID
  81 + RecipientId int64 `json:"recipientId"` // 接收者ID
  82 + ArticleId int64 `json:"articleId"` // 文章ID
  83 + CommentId int64 `json:"commentId"` // 评论ID
  84 + DiscussionId int64 `json:"discussionId"` // 圆桌ID
  85 + DiscussionOpinionId int64 `json:"discussionOpinionId"` // 观点ID
  86 + Content string `json:"content"` // 消息内容
  87 + CreatedAt int64 `json:"createdAt"` // 创建时间
  88 + User *SimpleUser `json:"user"` // 操作人
  89 + Article *SimpleArticle `json:"article"` // 文章
  90 + Comment *SimpleComment `json:"comment"` // 评论(不一定是自己,可能是被人@到)
137 } 91 }
138 92
139 -type MiniArticleMarkUserReadRequest struct {  
140 - UserId int64 `json:",optional"` // 当前操作人  
141 - CompanyId int64 `json:",optional"` // 当前公司  
142 - ArticleId int64 `json:"articleId"` // 文章id 93 +type SimpleUser struct {
  94 + Id int64 `json:"id"`
  95 + CompanyId int64 `json:"companyId,omitempty"` // 公司ID
  96 + CompanyName string `json:"companyName,omitempty"` // 公司名称
  97 + Name string `json:"name,omitempty"` // 名称
  98 + Avatar string `json:"avatar,omitempty"` // 头像
  99 + Position string `json:"position,omitempty"` // 职位
143 } 100 }
144 101
145 -type MiniArticleMarkUserReadResponse struct { 102 +type SimpleArticle struct {
146 Id int64 `json:"id"` 103 Id int64 `json:"id"`
  104 + Title string `json:"title"` // 文章标题
  105 + Summary string `json:"summary"` // 文章概要
  106 + CountLove int `json:"countLove"` // 点赞数量
  107 + CountComment int `json:"countComment"` // 评论数量
  108 + Show int `json:"show"` // 文章的展示状态(0显示、1不显示)
147 } 109 }
148 110
149 -type MiniArticleDraftCreateRequest struct {  
150 - CompanyId int64 `json:",optional"`  
151 - AuthorId int64 `json:",optional"` // 发布人  
152 - Template int `json:"template"` // 使用哪个模板进行编辑 0、无 1、演绎式 2、归纳式  
153 - Section []string `json:"section"` // 填写的内容  
154 - Title string `json:"title"` // 标题  
155 - Images []string `json:"images"` // 图片  
156 - WhoRead []int64 `json:"whoRead"` // 谁可以看  
157 - WhoReview []int64 `json:"whoReview"` // 评论人  
158 - Location Location `json:"location"` // 坐标 111 +type TagCreateRequest struct {
  112 + CompanyId int64 `json:"companyId"`
  113 + Image string `json:"image"`
  114 + Name string `json:"name"` // 标签名称
  115 + Group string `json:"group"` // 标签分类
  116 + Remark string `json:"remark,optional"` // 备注
159 } 117 }
160 118
161 -type MiniArticleDraftCreateResponse struct { 119 +type TagCreateResponse struct {
162 Id int64 `json:"id"` 120 Id int64 `json:"id"`
163 } 121 }
164 122
165 -type MiniArticleDraftUpdateRequest struct { 123 +type TagEditRequest struct {
166 Id int64 `json:"id"` 124 Id int64 `json:"id"`
167 - CompanyId int64 `json:",optional"`  
168 - AuthorId int64 `json:",optional"` // 发布人  
169 - Template int `json:"template"` // 使用哪个模板进行编辑 0、无 1、演绎式 2、归纳式  
170 - Section []string `json:"section"` // 填写的内容  
171 - Title string `json:"title"` // 标题  
172 - Images []string `json:"images"` // 图片  
173 - WhoRead []int64 `json:"whoRead"` // 谁可以看  
174 - WhoReview []int64 `json:"whoReview"` // 评论人  
175 - Location Location `json:"location"` // 坐标 125 + CompanyId int64 `json:"-"`
  126 + Image string `json:"image"`
  127 + Name string `json:"name"` // 标签名称
  128 + Group string `json:"group"` // 标签分类
  129 + Remark string `json:"remark,optional"` // 备注
176 } 130 }
177 131
178 -type MiniArticleDraftUpdateResponse struct { 132 +type TagEditResponse struct {
179 Id int64 `json:"id"` 133 Id int64 `json:"id"`
180 } 134 }
181 135
182 -type MiniArticleDraftSearchMeRequest struct {  
183 - CompanyId int64 `json:",optional"` // 公司id  
184 - AuthorId int64 `json:",optional"` // 发布人 136 +type TagGetRequest struct {
  137 + Id int64 `path:"id"`
  138 + CompanyId int64 `path:"-"`
  139 +}
  140 +
  141 +type TagGetResponse struct {
  142 + Id int64 `json:"id"`
  143 + Image string `json:"image"`
  144 + Name string `json:"name"` // 标签名称
  145 + Group string `json:"group"` // 标签分类
  146 + Remark string `json:"remark"` // 备注
  147 +}
  148 +
  149 +type TagListRequest struct {
185 Page int `json:"page"` 150 Page int `json:"page"`
186 Size int `json:"size"` 151 Size int `json:"size"`
  152 + CompanyId int64 `json:"-"`
  153 + TagName string `json:"tagName,optional"`
  154 + Group string `json:"group,optional"`
  155 + Remark string `json:"remark,optional"`
187 } 156 }
188 157
189 -type MiniArticleDraftSearchMeResponse struct { 158 +type TagListResponse struct {
190 Total int64 `json:"total"` 159 Total int64 `json:"total"`
191 - List []MiniArticleDraftItem `json:"list"` 160 + List []TagItem `json:"list"`
192 } 161 }
193 162
194 -type MiniArticleDraftItem struct { 163 +type TagItem struct {
195 Id int64 `json:"id"` 164 Id int64 `json:"id"`
196 - Template int `json:"template"` // 使用哪个模板进行编辑 0、无 1、演绎式 2、归纳式  
197 - Section []string `json:"section"` // 填写的内容  
198 - Title string `json:"title"` // 标题  
199 - Images []string `json:"images"` // 图片 165 + Image string `json:"image"`
  166 + Name string `json:"name"` // 标签名称
  167 + Group string `json:"group"` // 标签分类
  168 + Remark string `json:"remark"` // 备注
200 CreatedAt int64 `json:"createdAt"` 169 CreatedAt int64 `json:"createdAt"`
201 } 170 }
202 171
203 -type MiniArticleDraftGetMeRequest struct {  
204 - CompanyId int64 `path:",optional"` // 公司id  
205 - AuthorId int64 `path:",optional"` // 发布人 172 +type TagDeleteRequest struct {
206 Id int64 `path:"id"` 173 Id int64 `path:"id"`
  174 + CompanyId int64 `path:"-"`
207 } 175 }
208 176
209 -type MiniArticleDraftGetMeResponse struct {  
210 - Id int64 `json:"id"` //  
211 - Template int `json:"template"` // 使用哪个模板进行编辑 0、无 1、演绎式 2、归纳式  
212 - Section []string `json:"Section"` // 填写的内容  
213 - Title string `json:"title"` // 标题  
214 - Images []string `json:"images"` // 图片  
215 - WhoRead []int64 `json:"whoRead"` // 谁可以看  
216 - WhoReview []int64 `json:"whoReview"` // 评论人  
217 - Location Location `json:"location"` // 坐标 177 +type TagDeleteResponse struct {
  178 + Id int64 `json:"id"`
218 } 179 }
219 180
220 -type MiniArticleDraftDeleteMeRequest struct {  
221 - CompanyId int64 `path:",optional"` // 公司id  
222 - AuthorId int64 `path:",optional"` // 发布人  
223 - Id int64 `path:"id"` 181 +type MiniUserLoginRequest struct {
  182 + LoginType string `json:"loginType"` // 登录类型 wechat-login whchat-phone-login phone-password-login phone-smscode-login
  183 + WechatAuthCode string `json:"wechatAuthcode,optional"` // 微信登录 授权码
  184 + WechatEncryptedData string `json:"wechatEncryptedData,optional"` // 微信登录 加密数据
  185 + WechatIV string `json:"wechatIV,optional"` // 微信登录 加密算法初始向量
  186 + Phone string `json:"phone,optional"` // 手机号
  187 + Password string `json:"password,optional"` // 密码
  188 + SmsCode string `json:"smsCode,optional"` // 短信验证码
224 } 189 }
225 190
226 -type MiniArticleDraftDeleteMeResponse struct {  
227 - Id int64 `json:"id"` //  
228 -}  
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 -  
250 -type SystemArticleGetRequest struct {  
251 - Id int64 `path:"id"` //id  
252 - CompanyId int64 `path:",optional"`  
253 -}  
254 -  
255 -type UserShowName struct {  
256 - Id int `json:"id"`  
257 - Name int `json:"name"`  
258 -}  
259 -  
260 -type SystemArticleGetResponse struct {  
261 - Id int64 `json:"id"` // id  
262 - Title string `json:"title"` // 标题  
263 - AuthorId int64 `json:"authorId"` // 发布人id  
264 - Author Author `json:"author"` // 发布人  
265 - CreatedAt int64 `json:"createdAt"` // 文章的发布时间  
266 - Section []ArticleSection `json:"section"` // 文章的文本内容  
267 - Images []string `json:"images"` // 图片  
268 - WhoRead []int64 `json:"whoRead"` // 谁可查看  
269 - WhoReadInfo []UserShowName `json:"whoReadInfo"` // 谁可查看  
270 - WhoReview []int64 `json:"whoReview"` // 谁可评论  
271 - WhoReviewInfo []UserShowName `json:"whoReviewInfo"` // 谁可评论  
272 - Location Location `json:"location"` // 定位坐标  
273 - CountLove int `json:"countLove"` // 点赞数量  
274 - CountComment int `json:"countComment"` // 评论数量  
275 - CountRead int `json:"countRead"` // 浏览数量  
276 - Show int `json:"show"` // 评论的展示状态(0显示、1不显示)  
277 -}  
278 -  
279 -type SystemArticleSearchRequest struct {  
280 - CompanyId int64 `json:",optional"`  
281 - Page int `json:"page"`  
282 - Size int `json:"size"`  
283 -}  
284 -  
285 -type SystemArticleSearchResponse struct {  
286 - Total int `json:"total"`  
287 - List []SystemArticleSearch `json:"list"`  
288 -}  
289 -  
290 -type SystemArticleSearch struct {  
291 - Id int64 `json:"id"` //id  
292 - Title string `json:"title"` //标题  
293 - Author string `json:"author"` //发布人  
294 - Images []string `json:"images"` //图片  
295 - CreatedAt int64 `json:"createdAt"` //文章的创建日期  
296 - CountLove int `json:"countLove"` //点赞数量  
297 - CountComment int `json:"CountComment"` //评论数量  
298 - Show int `json:"show"` //是否隐藏 [0显示、1不显示]  
299 - Tags []string `json:"tags"` //标签  
300 - TargetUser int `json:"targetUser"` //分发方式 [0分发给所有人、1分发给指定的人]  
301 -}  
302 -  
303 -type CommentRequest struct {  
304 -}  
305 -  
306 -type CommentResposne struct {  
307 - List []Comment `json:"list"`  
308 -}  
309 -  
310 -type Comment struct {  
311 -}  
312 -  
313 -type MessageSystemRequest struct {  
314 - Page int `json:"page"`  
315 - Size int `json:"size"`  
316 -}  
317 -  
318 -type MessageSystemResponse struct {  
319 - List []MessageSystemItem `json:"list"`  
320 - Total int64 `json:"total"`  
321 -}  
322 -  
323 -type MessageSystemItem struct {  
324 - Id int64 `json:"id"` // ID  
325 - Type int `json:"type"` // 系统分类  
326 - Title string `json:"title"` // 标题  
327 - Content string `json:"content"` // 内容  
328 - CreatedAt int64 `json:"createdAt"` // 创建时间  
329 -}  
330 -  
331 -type MessageBusinessRequest struct {  
332 - Type int `json:"type"`  
333 - Page int `json:"page"`  
334 - Size int `json:"size"`  
335 -}  
336 -  
337 -type MessageBusinessResponse struct {  
338 - List []MessageBusinessItem `json:"list"`  
339 - Total int64 `json:"total"`  
340 -}  
341 -  
342 -type MessageBusinessItem struct {  
343 - Id int64 `json:"id"`  
344 - Type int `json:"type"` // 分类 (1回复 2点赞 3被采纳)  
345 - OptType int `json:"optType"` // 操作类型(1针对文章、1针对评论、2针对圆桌)  
346 - CompanyId int64 `json:"companyId"` // 操作人公司ID  
347 - UserId int64 `json:"userId"` // 操作人用户ID  
348 - RecipientId int64 `json:"recipientId"` // 接收者ID  
349 - ArticleId int64 `json:"articleId"` // 文章ID  
350 - CommentId int64 `json:"commentId"` // 评论ID  
351 - DiscussionId int64 `json:"discussionId"` // 圆桌ID  
352 - DiscussionOpinionId int64 `json:"discussionOpinionId"` // 观点ID  
353 - Content string `json:"content"` // 消息内容  
354 - CreatedAt int64 `json:"createdAt"` // 创建时间  
355 - User *SimpleUser `json:"user"` // 操作人  
356 - Article *SimpleArticle `json:"article"` // 文章  
357 - Comment *SimpleComment `json:"comment"` // 评论(不一定是自己,可能是被人@到)  
358 -}  
359 -  
360 -type SimpleUser struct {  
361 - Id int64 `json:"id"`  
362 - CompanyId int64 `json:"companyId,omitempty"` // 公司ID  
363 - CompanyName string `json:"companyName,omitempty"` // 公司名称  
364 - Name string `json:"name,omitempty"` // 名称  
365 - Avatar string `json:"avatar,omitempty"` // 头像  
366 - Position string `json:"position,omitempty"` // 职位  
367 -}  
368 -  
369 -type SimpleArticle struct {  
370 - Id int64 `json:"id"`  
371 - Title string `json:"title"` // 文章标题  
372 - Summary string `json:"summary"` // 文章概要  
373 - CountLove int `json:"countLove"` // 点赞数量  
374 - CountComment int `json:"countComment"` // 评论数量  
375 - Show int `json:"show"` // 文章的展示状态(0显示、1不显示)  
376 -}  
377 -  
378 -type TagCreateRequest struct {  
379 - CompanyId int64 `json:"companyId"`  
380 - Image string `json:"image"`  
381 - Name string `json:"name"` // 标签名称  
382 - Group string `json:"group"` // 标签分类  
383 - Remark string `json:"remark,optional"` // 备注  
384 -}  
385 -  
386 -type TagCreateResponse struct {  
387 - Id int64 `json:"id"`  
388 -}  
389 -  
390 -type TagEditRequest struct {  
391 - Id int64 `json:"id"`  
392 - CompanyId int64 `json:"-"`  
393 - Image string `json:"image"`  
394 - Name string `json:"name"` // 标签名称  
395 - Group string `json:"group"` // 标签分类  
396 - Remark string `json:"remark,optional"` // 备注  
397 -}  
398 -  
399 -type TagEditResponse struct {  
400 - Id int64 `json:"id"`  
401 -}  
402 -  
403 -type TagGetRequest struct {  
404 - Id int64 `path:"id"`  
405 - CompanyId int64 `path:"-"`  
406 -}  
407 -  
408 -type TagGetResponse struct {  
409 - Id int64 `json:"id"`  
410 - Image string `json:"image"`  
411 - Name string `json:"name"` // 标签名称  
412 - Group string `json:"group"` // 标签分类  
413 - Remark string `json:"remark"` // 备注  
414 -}  
415 -  
416 -type TagListRequest struct {  
417 - Page int `json:"page"`  
418 - Size int `json:"size"`  
419 - CompanyId int64 `json:"-"`  
420 - TagName string `json:"tagName,optional"`  
421 - Group string `json:"group,optional"`  
422 - Remark string `json:"remark,optional"`  
423 -}  
424 -  
425 -type TagListResponse struct {  
426 - Total int64 `json:"total"`  
427 - List []TagItem `json:"list"`  
428 -}  
429 -  
430 -type TagItem struct {  
431 - Id int64 `json:"id"`  
432 - Image string `json:"image"`  
433 - Name string `json:"name"` // 标签名称  
434 - Group string `json:"group"` // 标签分类  
435 - Remark string `json:"remark"` // 备注  
436 - CreatedAt int64 `json:"createdAt"`  
437 -}  
438 -  
439 -type TagDeleteRequest struct {  
440 - Id int64 `path:"id"`  
441 - CompanyId int64 `path:"-"`  
442 -}  
443 -  
444 -type TagDeleteResponse struct {  
445 - Id int64 `json:"id"`  
446 -}  
447 -  
448 -type MiniUserLoginRequest struct {  
449 - LoginType string `json:"loginType"` // 登录类型 wechat-login whchat-phone-login phone-password-login phone-smscode-login  
450 - WechatAuthCode string `json:"wechatAuthcode,optional"` // 微信登录 授权码  
451 - WechatEncryptedData string `json:"wechatEncryptedData,optional"` // 微信登录 加密数据  
452 - WechatIV string `json:"wechatIV,optional"` // 微信登录 加密算法初始向量  
453 - Phone string `json:"phone,optional"` // 手机号  
454 - Password string `json:"password,optional"` // 密码  
455 - SmsCode string `json:"smsCode,optional"` // 短信验证码  
456 -}  
457 -  
458 -type MiniUserLoginResponse struct {  
459 - Token string `json:"token"` // x-token  
460 - Phone string `json:"phone"` // 手机号  
461 - Message string `json:"message"` // 失败消息(审核中,注册成功等待审核)  
462 - Success bool `json:"success"` // 成功标识 191 +type MiniUserLoginResponse struct {
  192 + Token string `json:"token"` // x-token
  193 + Phone string `json:"phone"` // 手机号
  194 + Message string `json:"message"` // 失败消息(审核中,注册成功等待审核)
  195 + Success bool `json:"success"` // 成功标识
463 } 196 }
464 197
465 type MiniUserSwitchAccountRequest struct { 198 type MiniUserSwitchAccountRequest struct {
@@ -606,24 +339,435 @@ type SystemUserInfoResponse struct { @@ -606,24 +339,435 @@ type SystemUserInfoResponse struct {
606 CompanyName string `json:"companyName"` 339 CompanyName string `json:"companyName"`
607 } 340 }
608 341
609 -type CompanySearchRequest struct {  
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"` // 按用户搜索(用户所加入的企业)  
614 - Code string `json:"code,optional"` // 按编码搜索 342 +type UserStatisticsRequest struct {
  343 + UserId int64 `json:"userId"`
  344 + ItemFlag int `json:"itemFlag"` // 1:他的帖子 2:他的评论/回复 4:他收到的赞 8:TA的圆桌讨论 16:被采纳
615 } 345 }
616 346
617 -type CompanySearchResponse struct {  
618 - List []Company `json:"list"`  
619 - Total int64 `json:"total"` 347 +type UserStatisticsResponse struct {
  348 + List []StatisticsItem `json:"list"`
620 } 349 }
621 350
622 -type Company struct {  
623 - Id int64 `json:"id,omitempty"` // 唯一标识  
624 - Name string `json:"name,omitempty"` // 名称  
625 - Code string `json:"code,omitempty"` // 编码(搜索使用,4位字母数字)  
626 - Logo string `json:"logo,omitempty"` // 公司LOGO 351 +type StatisticsItem struct {
  352 + ItemFlag int `json:"itemFlag"` // 1:他的帖子 2:他的评论/回复 4:他收到的赞 8:TA的圆桌讨论 16:被采纳
  353 + Value float64 `json:"value"` // 统计值
  354 +}
  355 +
  356 +type SystemUserGetRequest struct {
  357 + Id int64 `path:"id"`
  358 +}
  359 +
  360 +type SystemUserGetResponse struct {
  361 + User SystemUser `json:"user"`
  362 +}
  363 +
  364 +type SystemUser struct {
  365 + Id int64 `json:"id"` // 用户ID
  366 + Name string `json:"name"` // 名称
  367 + Avatar string `json:"avatar"` // 头像
  368 + Phone string `json:"phone"` // 手机号 唯一
  369 + Position string `json:"position"` // 职位
  370 + Enable int `json:"enable"` // 启用状态 1:启用 2:禁用
  371 + Departments []int64 `json:"departments"` // 所属部门
  372 + AccountFrom string `json:"accountFrom"` // 账号来源 后台新增、扫码注册
  373 + CreatedAt int64 `json:"createdAt"` // 注册时间
  374 + Roles []int64 `json:"roles"` // 角色
  375 + RolesDesc string `json:"rolesDesc"` // 角色描述
  376 + DepartmentsDesc string `json:"departmentsDesc"` // 部门描述
  377 +}
  378 +
  379 +type SystemUserUpdateRequest struct {
  380 + Id int64 `path:"id"`
  381 + Avatar string `json:"avatar,optional"` // 头像
  382 + Position string `json:"position"` // 职位
  383 + Departments []int64 `json:"departments"` // 所属部门
  384 +}
  385 +
  386 +type SystemUserUpdateResponse struct {
  387 +}
  388 +
  389 +type SystemUserSearchRequest struct {
  390 + Page int `json:"page"`
  391 + Size int `json:"size"`
  392 + Name string `json:"name,optional"` // 名称
  393 + Phone string `json:"phone,optional"` // 手机号 唯一
  394 + Position string `json:"position,optional"` // 职位
  395 + Enable int `json:"enable,optional"` // 启用状态 1:启用 2:禁用
  396 + DepartmentId int64 `json:"departmentId,optional"` // 所属部门
  397 +}
  398 +
  399 +type SystemUserSearchResponse struct {
  400 + List []SystemUser `json:"list"`
  401 + Total int64 `json:"total"`
  402 +}
  403 +
  404 +type SystemUserAccountGetRequest struct {
  405 + Id int64 `path:"id"`
  406 +}
  407 +
  408 +type SystemUserAccountGetResponse struct {
  409 + User SystemUser `json:"user"`
  410 +}
  411 +
  412 +type SystemUserAccountSaveRequest struct {
  413 + Name string `json:"name"` // 名称
  414 + Phone string `json:"phone"` // 手机号 唯一
  415 + Enable int `json:"enable"` // 启用状态 1:启用 2:禁用
  416 + Roles []int64 `json:"roles"` // 角色
  417 +}
  418 +
  419 +type SystemUserAccountSaveResponse struct {
  420 +}
  421 +
  422 +type SystemUserAccountEnableRequest struct {
  423 + UserIds []int64 `json:"userIds"` // 用户ID列表
  424 + Status int `json:"status"` // 状态 1:启用 2:禁用
  425 +}
  426 +
  427 +type SystemUserAccountEnableResponse struct {
  428 +}
  429 +
  430 +type SystemUserAccountUpdateRequest struct {
  431 + Id int64 `path:"id"`
  432 +}
  433 +
  434 +type SystemUserAccountUpdateResponse struct {
  435 +}
  436 +
  437 +type SystemUserAccountSearchRequest struct {
  438 + Page int `json:"page"`
  439 + Size int `json:"size"`
  440 + Name string `json:"name,optional"` // 名称
  441 + Phone string `json:"phone,optional"` // 手机号 唯一
  442 + RoleId int64 `json:"roleId,optional"` // 角色权限
  443 + Enable int `json:"enable,optional"` // 启用状态 1:启用 2:禁用
  444 + BeginTime int64 `json:"beginTime,optional"` // 注册日期-开始
  445 + EndTime int64 `json:"endTime,optional"` // 注册日期-结束
  446 +}
  447 +
  448 +type SystemUserAccountSearchResponse struct {
  449 + List []SystemUser `json:"list"`
  450 + Total int64 `json:"total"`
  451 +}
  452 +
  453 +type CompanySearchRequest struct {
  454 + Page int `json:"page,optional"`
  455 + Size int `json:"size,optional"`
  456 + Flag int `json:"flag,optional"` // 1:用户已加入的 2:用户未加入的公司
  457 + UserId int64 `json:"userId,optional"` // 按用户搜索(用户所加入的企业)
  458 + Code string `json:"code,optional"` // 按编码搜索
  459 +}
  460 +
  461 +type CompanySearchResponse struct {
  462 + List []Company `json:"list"`
  463 + Total int64 `json:"total"`
  464 +}
  465 +
  466 +type Company struct {
  467 + Id int64 `json:"id,omitempty"` // 唯一标识
  468 + Name string `json:"name,omitempty"` // 名称
  469 + Code string `json:"code,omitempty"` // 编码(搜索使用,4位字母数字)
  470 + Logo string `json:"logo,omitempty"` // 公司LOGO
  471 +}
  472 +
  473 +type Location struct {
  474 + Longitude float64 `json:"longitude,optional"` //经度
  475 + Latitude float64 `json:"latitude,optional"` //纬度
  476 + Descript string `json:"descript,optional"` //地点描述
  477 +}
  478 +
  479 +type ArticleAuthor struct {
  480 + Id int64 `json:"id"` // 人员id
  481 + Name string `json:"name"` // 人员的名字
  482 + Avatar string `json:"avatar"` // 人员头像URL
  483 + Position string `json:"position"` // 职位
  484 + Company string `json:"company"` // 公司
  485 +}
  486 +
  487 +type MiniArticleCreateRequest struct {
  488 + Title string `json:"title"` //标题
  489 + Section []string `json:"section"` //文章的文本内容
  490 + AuthorId int64 `json:"authorId,optional"` //发布人id
  491 + Images []string `json:"images,optional"` //图片
  492 + WhoRead []int64 `json:"whoRead,optional"` //谁可查看
  493 + WhoReview []int64 `json:"whoReview,optional"` //谁可评论
  494 + Location Location `json:"location,optional"` //定位坐标
  495 +}
  496 +
  497 +type MiniArticleCreateResponse struct {
  498 + Id int64 `json:"id"`
  499 +}
  500 +
  501 +type MiniArticleGetRequest struct {
  502 + Id int64 `path:"id"` //id
  503 + CompanyId int64 `path:",optional"` //当前公司
  504 + UserId int `path:",optional"` //当前用户
  505 +}
  506 +
  507 +type MiniArticleGetResponse struct {
  508 + Id int64 `json:"id"` //id
  509 + Title string `json:"title"` //标题
  510 + AuthorId int64 `json:"authorId"` //发布人id
  511 + Author ArticleAuthor `json:"author"` //发布人
  512 + CreatedAt int64 `json:"createdAt"` //文章的发布时间
  513 + Section []ArticleSection `json:"section"` //文章的文本内容
  514 + Images []string `json:"images"` //图片
  515 + WhoRead []int64 `json:"whoRead"` //谁可查看
  516 + WhoReview []int64 `json:"whoReview"` //谁可评论
  517 + Location Location `json:"location"` //定位坐标
  518 + CountLove int `json:"countLove"` // 点赞数量
  519 + CountComment int `json:"countComment"` // 评论数量
  520 + CountRead int `json:"countRead"` // 浏览数量
  521 + Show int `json:"show"` // 评论的展示状态(0显示、1不显示)
  522 + Edit int `json:"edit"` // 文章是否存在变更记录 (0 不存在 1存在)
  523 + MeLoveFlag int `json:"meLoveFlag"` //当前人员对文章的点赞标识
  524 +}
  525 +
  526 +type ArticleSection struct {
  527 + Id int64 `json:"id"` //段落id
  528 + Content string `json:"content"` // 文本内容
  529 + SortBy int `json:"sortBy"` // 排序
  530 + TotalComment int `json:"totalComment"` // 评论的数量
  531 +}
  532 +
  533 +type MiniArticleSearchMeRequest struct {
  534 + AuthorId int64 `json:",optional"`
  535 + CompanyId int64 `json:",optional"`
  536 + Page int `json:"page"`
  537 + Size int `json:"size"`
  538 +}
  539 +
  540 +type MiniArticleSearchMeResponse struct {
  541 + Total int `json:"total"`
  542 + List []ArticleSearchMe `json:"list"`
  543 +}
  544 +
  545 +type ArticleSearchMe struct {
  546 + Id int64 `json:"id"` //id
  547 + Title string `json:"title"` //标题
  548 + Images []string `json:"images"` //图片
  549 + CreatedAt int64 `json:"createdAt"` //文章的创建日期
  550 + CountLove int `json:"countLove"` //点赞数量
  551 + CountComment int `json:"CountComment"` //评论数量
  552 + Show int `json:"show"` //是否隐藏 [0显示、1不显示]
  553 +}
  554 +
  555 +type MiniUserLikeArticleRequest struct {
  556 + ArticleId int64 `json:"articleId"` // 文章id
  557 + CompanyId int64 `json:",optional"` //公司id
  558 + Page int `json:"page"` //分页,第几页
  559 + Size int `json:"size"` //分页,每页几条
  560 +}
  561 +
  562 +type MiniUserLikeArticleResponse struct {
  563 + Total int64 `json:"total"` //总数
  564 + List []WhichUserLikeArticle `json:"list"` //列表
  565 +}
  566 +
  567 +type WhichUserLikeArticle struct {
  568 + ArticleId int64 `json:"articleId"` // 文章id
  569 + UserId int64 `json:"userId"` // 人员id
  570 + Name string `json:"name"` // 人员名称
  571 + Avatar string `json:"avatar"` // 人员头像
  572 + CreatedAt int64 `json:"createdAt"` // 点赞记录的时间
  573 +}
  574 +
  575 +type MiniSetUserLikeRequset struct {
  576 + ArticleId int64 `json:"articleId"` //文章id
  577 + CommentId int64 `json:"commentId"` //评论id
  578 + UserId int64 `json:",optional"` //操作人
  579 + Flag int `json:"flag"` //点赞标志 1、点赞 2 、取消点赞
  580 +}
  581 +
  582 +type MiniSetUserLikeResponse struct {
  583 + ArticleId int64 `json:"articleId"` //文章id
  584 + CommentId int64 `json:"commentId"` //评论id
  585 + Count int `json:"count"` //现有的点赞数量
  586 +}
  587 +
  588 +type MiniArticleBackupSearchRequest struct {
  589 + Page int `json:"page"`
  590 + Size int `json:"size"`
  591 + ArticleId int `json:"articleId"`
  592 + CompanyId int64 `json:",optional"` // 服务端自动获取
  593 +}
  594 +
  595 +type MiniArticleBackupSearchResponse struct {
  596 + Total int64 `json:"total"`
  597 + List []MiniArticleBackupItem `json:"list"`
  598 +}
  599 +
  600 +type MiniArticleBackupItem struct {
  601 + Id int64 `json:"id"`
  602 + Title string `json:"title"`
  603 + Content string `json:"content"`
  604 + Images []string `json:"images"`
  605 + CreatedAt int64 `json:"createdAt"`
  606 + Location Location `json:"location"`
  607 +}
  608 +
  609 +type MiniArticleMarkUserReadRequest struct {
  610 + UserId int64 `json:",optional"` // 当前操作人
  611 + CompanyId int64 `json:",optional"` // 当前公司
  612 + ArticleId int64 `json:"articleId"` // 文章id
  613 +}
  614 +
  615 +type MiniArticleMarkUserReadResponse struct {
  616 + Id int64 `json:"id"`
  617 +}
  618 +
  619 +type MiniArticleDraftCreateRequest struct {
  620 + CompanyId int64 `json:",optional"`
  621 + AuthorId int64 `json:",optional"` // 发布人
  622 + Template int `json:"template"` // 使用哪个模板进行编辑 0、无 1、演绎式 2、归纳式
  623 + Section []string `json:"section"` // 填写的内容
  624 + Title string `json:"title"` // 标题
  625 + Images []string `json:"images"` // 图片
  626 + WhoRead []int64 `json:"whoRead"` // 谁可以看
  627 + WhoReview []int64 `json:"whoReview"` // 评论人
  628 + Location Location `json:"location"` // 坐标
  629 +}
  630 +
  631 +type MiniArticleDraftCreateResponse struct {
  632 + Id int64 `json:"id"`
  633 +}
  634 +
  635 +type MiniArticleDraftUpdateRequest struct {
  636 + Id int64 `json:"id"`
  637 + CompanyId int64 `json:",optional"`
  638 + AuthorId int64 `json:",optional"` // 发布人
  639 + Template int `json:"template"` // 使用哪个模板进行编辑 0、无 1、演绎式 2、归纳式
  640 + Section []string `json:"section"` // 填写的内容
  641 + Title string `json:"title"` // 标题
  642 + Images []string `json:"images"` // 图片
  643 + WhoRead []int64 `json:"whoRead"` // 谁可以看
  644 + WhoReview []int64 `json:"whoReview"` // 评论人
  645 + Location Location `json:"location"` // 坐标
  646 +}
  647 +
  648 +type MiniArticleDraftUpdateResponse struct {
  649 + Id int64 `json:"id"`
  650 +}
  651 +
  652 +type MiniArticleDraftSearchMeRequest struct {
  653 + CompanyId int64 `json:",optional"` // 公司id
  654 + AuthorId int64 `json:",optional"` // 发布人
  655 + Page int `json:"page"`
  656 + Size int `json:"size"`
  657 +}
  658 +
  659 +type MiniArticleDraftSearchMeResponse struct {
  660 + Total int64 `json:"total"`
  661 + List []MiniArticleDraftItem `json:"list"`
  662 +}
  663 +
  664 +type MiniArticleDraftItem struct {
  665 + Id int64 `json:"id"`
  666 + Template int `json:"template"` // 使用哪个模板进行编辑 0、无 1、演绎式 2、归纳式
  667 + Section []string `json:"section"` // 填写的内容
  668 + Title string `json:"title"` // 标题
  669 + Images []string `json:"images"` // 图片
  670 + CreatedAt int64 `json:"createdAt"`
  671 +}
  672 +
  673 +type MiniArticleDraftGetMeRequest struct {
  674 + CompanyId int64 `path:",optional"` // 公司id
  675 + AuthorId int64 `path:",optional"` // 发布人
  676 + Id int64 `path:"id"`
  677 +}
  678 +
  679 +type MiniArticleDraftGetMeResponse struct {
  680 + Id int64 `json:"id"` //
  681 + Template int `json:"template"` // 使用哪个模板进行编辑 0、无 1、演绎式 2、归纳式
  682 + Section []string `json:"Section"` // 填写的内容
  683 + Title string `json:"title"` // 标题
  684 + Images []string `json:"images"` // 图片
  685 + WhoRead []int64 `json:"whoRead"` // 谁可以看
  686 + WhoReview []int64 `json:"whoReview"` // 评论人
  687 + Location Location `json:"location"` // 坐标
  688 +}
  689 +
  690 +type MiniArticleDraftDeleteMeRequest struct {
  691 + CompanyId int64 `path:",optional"` // 公司id
  692 + AuthorId int64 `path:",optional"` // 发布人
  693 + Id int64 `path:"id"`
  694 +}
  695 +
  696 +type MiniArticleDraftDeleteMeResponse struct {
  697 + Id int64 `json:"id"` //
  698 +}
  699 +
  700 +type MiniArticleMarkListRequest struct {
  701 + Page int `json:"page"`
  702 + Size int `json:"size"`
  703 +}
  704 +
  705 +type MiniArticleMarkListResponse struct {
  706 + Total int64 `json:"total"`
  707 + List []MiniArticleMarkItem `json:"list"`
  708 +}
  709 +
  710 +type MiniArticleMarkItem struct {
  711 + Id int64 `json:"id"`
  712 + CompanyId int64 `json:"companyId"`
  713 + UserId int64 `json:"userId"`
  714 + ArticleId int64 `json:"articleId"`
  715 + Title string `json:"title"`
  716 + Author SimpleUser `json:"author"` // 发布人
  717 + UpdatedAt int64 `json:"updatedAt"`
  718 +}
  719 +
  720 +type SystemArticleGetRequest struct {
  721 + Id int64 `path:"id"` //id
  722 + CompanyId int64 `path:",optional"`
  723 +}
  724 +
  725 +type UserShowName struct {
  726 + Id int `json:"id"`
  727 + Name int `json:"name"`
  728 +}
  729 +
  730 +type SystemArticleGetResponse struct {
  731 + Id int64 `json:"id"` // id
  732 + Title string `json:"title"` // 标题
  733 + AuthorId int64 `json:"authorId"` // 发布人id
  734 + Author ArticleAuthor `json:"author"` // 发布人
  735 + CreatedAt int64 `json:"createdAt"` // 文章的发布时间
  736 + Section []ArticleSection `json:"section"` // 文章的文本内容
  737 + Images []string `json:"images"` // 图片
  738 + WhoRead []int64 `json:"whoRead"` // 谁可查看
  739 + WhoReadInfo []UserShowName `json:"whoReadInfo"` // 谁可查看
  740 + WhoReview []int64 `json:"whoReview"` // 谁可评论
  741 + WhoReviewInfo []UserShowName `json:"whoReviewInfo"` // 谁可评论
  742 + Location Location `json:"location"` // 定位坐标
  743 + CountLove int `json:"countLove"` // 点赞数量
  744 + CountComment int `json:"countComment"` // 评论数量
  745 + CountRead int `json:"countRead"` // 浏览数量
  746 + Show int `json:"show"` // 评论的展示状态(0显示、1不显示)
  747 +}
  748 +
  749 +type SystemArticleSearchRequest struct {
  750 + CompanyId int64 `json:",optional"`
  751 + Page int `json:"page"`
  752 + Size int `json:"size"`
  753 +}
  754 +
  755 +type SystemArticleSearchResponse struct {
  756 + Total int `json:"total"`
  757 + List []SystemArticleSearch `json:"list"`
  758 +}
  759 +
  760 +type SystemArticleSearch struct {
  761 + Id int64 `json:"id"` //id
  762 + Title string `json:"title"` //标题
  763 + Author string `json:"author"` //发布人
  764 + Images []string `json:"images"` //图片
  765 + CreatedAt int64 `json:"createdAt"` //文章的创建日期
  766 + CountLove int `json:"countLove"` //点赞数量
  767 + CountComment int `json:"CountComment"` //评论数量
  768 + Show int `json:"show"` //是否隐藏 [0显示、1不显示]
  769 + Tags []string `json:"tags"` //标签
  770 + TargetUser int `json:"targetUser"` //分发方式 [0分发给所有人、1分发给指定的人]
627 } 771 }
628 772
629 type RoleGetRequest struct { 773 type RoleGetRequest struct {
@@ -20,12 +20,13 @@ type ArticleComment struct { @@ -20,12 +20,13 @@ type ArticleComment struct {
20 Pid int64 // 对哪个评论进行回复 20 Pid int64 // 对哪个评论进行回复
21 TopId int64 // 归属于最上级的哪个评论 21 TopId int64 // 归属于最上级的哪个评论
22 ArticleId int64 // 文章id 22 ArticleId int64 // 文章id
23 - ArticleSectionId int64 // 文本内容id 23 + SectionId int64 // 文本内容id
24 SectionContent string // 引用的文章内容文本 24 SectionContent string // 引用的文章内容文本
25 FromUserId int64 // 谁填写的评论 25 FromUserId int64 // 谁填写的评论
26 FromUser domain.UserSimple `gorm:"type:jsonb;serializer:json"` // 谁填写的评论 26 FromUser domain.UserSimple `gorm:"type:jsonb;serializer:json"` // 谁填写的评论
27 ToUserId int64 // 回复谁的评论 27 ToUserId int64 // 回复谁的评论
28 ToUser domain.UserSimple `gorm:"type:jsonb;serializer:json"` // 回复谁的评论 28 ToUser domain.UserSimple `gorm:"type:jsonb;serializer:json"` // 回复谁的评论
  29 + AtWho []domain.UserSimple `gorm:"type:jsonb;serializer:json"` // 填写评论@的人
29 Content string // 评论内容 30 Content string // 评论内容
30 CountReply int // 回复数量 31 CountReply int // 回复数量
31 CountUserLove int // 用户点赞数量 32 CountUserLove int // 用户点赞数量
@@ -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 // 职位
@@ -151,7 +151,7 @@ func (repository *ArticleCommentRepository) ModelToDomainModel(from *models.Arti @@ -151,7 +151,7 @@ func (repository *ArticleCommentRepository) ModelToDomainModel(from *models.Arti
151 Pid: from.Pid, 151 Pid: from.Pid,
152 TopId: from.TopId, 152 TopId: from.TopId,
153 ArticleId: from.ArticleId, 153 ArticleId: from.ArticleId,
154 - ArticleSectionId: from.ArticleSectionId, 154 + SectionId: from.SectionId,
155 SectionContent: from.SectionContent, 155 SectionContent: from.SectionContent,
156 FromUserId: from.FromUserId, 156 FromUserId: from.FromUserId,
157 FromUser: from.FromUser, 157 FromUser: from.FromUser,
@@ -178,7 +178,7 @@ func (repository *ArticleCommentRepository) DomainModelToModel(from *domain.Arti @@ -178,7 +178,7 @@ func (repository *ArticleCommentRepository) DomainModelToModel(from *domain.Arti
178 Pid: from.Pid, 178 Pid: from.Pid,
179 TopId: from.TopId, 179 TopId: from.TopId,
180 ArticleId: from.ArticleId, 180 ArticleId: from.ArticleId,
181 - ArticleSectionId: from.ArticleSectionId, 181 + SectionId: from.SectionId,
182 SectionContent: from.SectionContent, 182 SectionContent: from.SectionContent,
183 FromUserId: from.FromUserId, 183 FromUserId: from.FromUserId,
184 FromUser: from.FromUser, 184 FromUser: from.FromUser,
@@ -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 }
@@ -17,7 +17,7 @@ type ArticleComment struct { @@ -17,7 +17,7 @@ type ArticleComment struct {
17 Pid int64 `json:"pid"` // 对哪个评论进行回复 17 Pid int64 `json:"pid"` // 对哪个评论进行回复
18 TopId int64 `json:"topId"` // 归属于最上级的哪个评论 18 TopId int64 `json:"topId"` // 归属于最上级的哪个评论
19 ArticleId int64 `json:"articleId"` // 文章id 19 ArticleId int64 `json:"articleId"` // 文章id
20 - ArticleSectionId int64 `json:"articleSectionId"` // 文本内容id 20 + SectionId int64 `json:"sectionId"` // 文本段落内容id
21 SectionContent string `json:"sectionContent"` // 引用的文章内容文本 21 SectionContent string `json:"sectionContent"` // 引用的文章内容文本
22 FromUserId int64 `json:"fromUserId"` // 谁填写的评论 22 FromUserId int64 `json:"fromUserId"` // 谁填写的评论
23 FromUser UserSimple `json:"fromUser"` // 谁填写的评论 23 FromUser UserSimple `json:"fromUser"` // 谁填写的评论
@@ -28,6 +28,7 @@ type ArticleComment struct { @@ -28,6 +28,7 @@ type ArticleComment struct {
28 CountUserLove int `json:"countUserLove"` // 用户点赞数量 28 CountUserLove int `json:"countUserLove"` // 用户点赞数量
29 CountAdminLove int `json:"countAdminLove"` // 运营点赞数量 29 CountAdminLove int `json:"countAdminLove"` // 运营点赞数量
30 Show CommentShow `json:"showState"` // 评论的展示状态(0显示、1不显示) 30 Show CommentShow `json:"showState"` // 评论的展示状态(0显示、1不显示)
  31 + AtWho []UserSimple `json:"atWho"` // 填写评论时@的人
31 // ...more 32 // ...more
32 } 33 }
33 34
@@ -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 {
@@ -32,8 +32,8 @@ type UserSimple struct { @@ -32,8 +32,8 @@ type UserSimple struct {
32 Id int64 `json:"id"` // 人员id 32 Id int64 `json:"id"` // 人员id
33 Name string `json:"name"` // 人员的名字 33 Name string `json:"name"` // 人员的名字
34 Avatar string `json:"avatar,omitempty"` // 人员头像URL 34 Avatar string `json:"avatar,omitempty"` // 人员头像URL
35 - GroupId int64 `json:"groupId,omitempty"`  
36 - Group string `json:"group,omitempty"` // 人员的分组 35 + // GroupId int64 `json:"groupId"` //分组id
  36 + //Group string `json:"group,omitempty"` // 人员的分组
37 Position string `json:"position,omitempty"` // 职位 37 Position string `json:"position,omitempty"` // 职位
38 Company string `json:"company,omitempty"` // 公司 38 Company string `json:"company,omitempty"` // 公司
39 CompanyId int64 `json:"companyId"` 39 CompanyId int64 `json:"companyId"`
@@ -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)
@@ -6,6 +6,7 @@ require ( @@ -6,6 +6,7 @@ require (
6 github.com/golang-jwt/jwt/v4 v4.5.0 6 github.com/golang-jwt/jwt/v4 v4.5.0
7 github.com/jinzhu/copier v0.4.0 7 github.com/jinzhu/copier v0.4.0
8 github.com/jinzhu/now v1.1.5 8 github.com/jinzhu/now v1.1.5
  9 + github.com/mozillazg/go-pinyin v0.20.0
9 github.com/pkg/errors v0.9.1 10 github.com/pkg/errors v0.9.1
10 github.com/samber/lo v1.38.1 11 github.com/samber/lo v1.38.1
11 github.com/silenceper/wechat/v2 v2.1.4 12 github.com/silenceper/wechat/v2 v2.1.4
  1 +package tool
  2 +
  3 +import (
  4 + "strings"
  5 +
  6 + "github.com/mozillazg/go-pinyin"
  7 +)
  8 +
  9 +func ToPinYin(hans string, sep string) string {
  10 + a := pinyin.NewArgs()
  11 + tmp := pinyin.Pinyin(hans, a)
  12 + result := make([]string, 0)
  13 + for i := range tmp {
  14 + result = append(result, tmp[i]...)
  15 + }
  16 + py := strings.Join(result, sep)
  17 + if len(py) == 0 {
  18 + return strings.ToLower(hans)
  19 + }
  20 + return py
  21 +}