作者 yangfu

用户登录

正在显示 27 个修改的文件 包含 1372 行增加83 行删除
@@ -33,6 +33,364 @@ @@ -33,6 +33,364 @@
33 ] 33 ]
34 } 34 }
35 }, 35 },
  36 + "v1/mini/company/search": {
  37 + "post": {
  38 + "summary": "公司搜索",
  39 + "operationId": "miniCompanySearch",
  40 + "responses": {
  41 + "200": {
  42 + "description": "A successful response.",
  43 + "schema": {
  44 + "$ref": "#/definitions/CompanySearchResponse"
  45 + }
  46 + }
  47 + },
  48 + "parameters": [
  49 + {
  50 + "name": "body",
  51 + "in": "body",
  52 + "required": true,
  53 + "schema": {
  54 + "$ref": "#/definitions/CompanySearchRequest"
  55 + }
  56 + }
  57 + ],
  58 + "requestBody": {},
  59 + "tags": [
  60 + "company"
  61 + ]
  62 + }
  63 + },
  64 + "v1/mini/message/business": {
  65 + "post": {
  66 + "summary": "业务消息",
  67 + "operationId": "miniBusiness",
  68 + "responses": {
  69 + "200": {
  70 + "description": "A successful response.",
  71 + "schema": {
  72 + "$ref": "#/definitions/MessageBusinessResponse"
  73 + }
  74 + }
  75 + },
  76 + "parameters": [
  77 + {
  78 + "name": "body",
  79 + "in": "body",
  80 + "required": true,
  81 + "schema": {
  82 + "$ref": "#/definitions/MessageBusinessRequest"
  83 + }
  84 + }
  85 + ],
  86 + "requestBody": {},
  87 + "tags": [
  88 + "message"
  89 + ]
  90 + }
  91 + },
  92 + "v1/mini/message/system": {
  93 + "post": {
  94 + "summary": "系统消息",
  95 + "operationId": "miniSystem",
  96 + "responses": {
  97 + "200": {
  98 + "description": "A successful response.",
  99 + "schema": {
  100 + "$ref": "#/definitions/MessageBusinessResponse"
  101 + }
  102 + }
  103 + },
  104 + "parameters": [
  105 + {
  106 + "name": "body",
  107 + "in": "body",
  108 + "required": true,
  109 + "schema": {
  110 + "$ref": "#/definitions/MessageSystemRequest"
  111 + }
  112 + }
  113 + ],
  114 + "requestBody": {},
  115 + "tags": [
  116 + "message"
  117 + ]
  118 + }
  119 + },
  120 + "v1/mini/user/apply-join-company": {
  121 + "post": {
  122 + "summary": "用户申请加入公司",
  123 + "operationId": "miniUserApplyJoinCompany",
  124 + "responses": {
  125 + "200": {
  126 + "description": "A successful response.",
  127 + "schema": {
  128 + "$ref": "#/definitions/MiniUserApplyJoinCompanyResponse"
  129 + }
  130 + }
  131 + },
  132 + "parameters": [
  133 + {
  134 + "name": "body",
  135 + "in": "body",
  136 + "required": true,
  137 + "schema": {
  138 + "$ref": "#/definitions/MiniUserApplyJoinCompanyRequest"
  139 + }
  140 + }
  141 + ],
  142 + "requestBody": {},
  143 + "tags": [
  144 + "user"
  145 + ]
  146 + }
  147 + },
  148 + "v1/mini/user/audit": {
  149 + "post": {
  150 + "summary": "用户审核",
  151 + "operationId": "miniUserAudit",
  152 + "responses": {
  153 + "200": {
  154 + "description": "A successful response.",
  155 + "schema": {}
  156 + }
  157 + },
  158 + "parameters": [
  159 + {
  160 + "name": "body",
  161 + "in": "body",
  162 + "required": true,
  163 + "schema": {
  164 + "$ref": "#/definitions/MiniUserAuditRequest"
  165 + }
  166 + }
  167 + ],
  168 + "requestBody": {},
  169 + "tags": [
  170 + "user"
  171 + ]
  172 + }
  173 + },
  174 + "v1/mini/user/audit-list": {
  175 + "post": {
  176 + "summary": "用户审核列表",
  177 + "operationId": "miniUserAuditList",
  178 + "responses": {
  179 + "200": {
  180 + "description": "A successful response.",
  181 + "schema": {
  182 + "$ref": "#/definitions/UserSearchResponse"
  183 + }
  184 + }
  185 + },
  186 + "parameters": [
  187 + {
  188 + "name": "body",
  189 + "in": "body",
  190 + "required": true,
  191 + "schema": {
  192 + "$ref": "#/definitions/UserSearchRequest"
  193 + }
  194 + }
  195 + ],
  196 + "requestBody": {},
  197 + "tags": [
  198 + "user"
  199 + ]
  200 + }
  201 + },
  202 + "v1/mini/user/department-users": {
  203 + "post": {
  204 + "summary": "部门用户列表",
  205 + "operationId": "miniUserDepartmentUsers",
  206 + "responses": {
  207 + "200": {
  208 + "description": "A successful response.",
  209 + "schema": {
  210 + "$ref": "#/definitions/MiniUserInfoResponse"
  211 + }
  212 + }
  213 + },
  214 + "parameters": [
  215 + {
  216 + "name": "body",
  217 + "in": "body",
  218 + "required": true,
  219 + "schema": {
  220 + "$ref": "#/definitions/MiniUserDepartmentUsersRequest"
  221 + }
  222 + }
  223 + ],
  224 + "requestBody": {},
  225 + "tags": [
  226 + "user"
  227 + ]
  228 + }
  229 + },
  230 + "v1/mini/user/follow": {
  231 + "post": {
  232 + "summary": "关注",
  233 + "operationId": "miniUserFollow",
  234 + "responses": {
  235 + "200": {
  236 + "description": "A successful response.",
  237 + "schema": {}
  238 + }
  239 + },
  240 + "parameters": [
  241 + {
  242 + "name": "body",
  243 + "in": "body",
  244 + "required": true,
  245 + "schema": {
  246 + "$ref": "#/definitions/FollowRequest"
  247 + }
  248 + }
  249 + ],
  250 + "requestBody": {},
  251 + "tags": [
  252 + "user"
  253 + ]
  254 + }
  255 + },
  256 + "v1/mini/user/follower": {
  257 + "post": {
  258 + "summary": "关注我的人",
  259 + "operationId": "miniUserFollower",
  260 + "responses": {
  261 + "200": {
  262 + "description": "A successful response.",
  263 + "schema": {
  264 + "$ref": "#/definitions/UserSearchResponse"
  265 + }
  266 + }
  267 + },
  268 + "parameters": [
  269 + {
  270 + "name": "body",
  271 + "in": "body",
  272 + "required": true,
  273 + "schema": {
  274 + "$ref": "#/definitions/UserSearchRequest"
  275 + }
  276 + }
  277 + ],
  278 + "requestBody": {},
  279 + "tags": [
  280 + "user"
  281 + ]
  282 + }
  283 + },
  284 + "v1/mini/user/following": {
  285 + "post": {
  286 + "summary": "我关注的人",
  287 + "operationId": "miniUserFollowing",
  288 + "responses": {
  289 + "200": {
  290 + "description": "A successful response.",
  291 + "schema": {
  292 + "$ref": "#/definitions/UserSearchResponse"
  293 + }
  294 + }
  295 + },
  296 + "parameters": [
  297 + {
  298 + "name": "body",
  299 + "in": "body",
  300 + "required": true,
  301 + "schema": {
  302 + "$ref": "#/definitions/UserSearchRequest"
  303 + }
  304 + }
  305 + ],
  306 + "requestBody": {},
  307 + "tags": [
  308 + "user"
  309 + ]
  310 + }
  311 + },
  312 + "v1/mini/user/info": {
  313 + "post": {
  314 + "summary": "用户信息",
  315 + "operationId": "miniUserInfo",
  316 + "responses": {
  317 + "200": {
  318 + "description": "A successful response.",
  319 + "schema": {
  320 + "$ref": "#/definitions/MiniUserInfoResponse"
  321 + }
  322 + }
  323 + },
  324 + "parameters": [
  325 + {
  326 + "name": "body",
  327 + "in": "body",
  328 + "required": true,
  329 + "schema": {
  330 + "$ref": "#/definitions/MiniUserInfoRequest"
  331 + }
  332 + }
  333 + ],
  334 + "requestBody": {},
  335 + "tags": [
  336 + "user"
  337 + ]
  338 + }
  339 + },
  340 + "v1/mini/user/login": {
  341 + "post": {
  342 + "summary": "用户登录",
  343 + "operationId": "miniUserLogin",
  344 + "responses": {
  345 + "200": {
  346 + "description": "A successful response.",
  347 + "schema": {
  348 + "$ref": "#/definitions/MiniUserLoginResponse"
  349 + }
  350 + }
  351 + },
  352 + "parameters": [
  353 + {
  354 + "name": "body",
  355 + "in": "body",
  356 + "required": true,
  357 + "schema": {
  358 + "$ref": "#/definitions/MiniUserLoginRequest"
  359 + }
  360 + }
  361 + ],
  362 + "requestBody": {},
  363 + "tags": [
  364 + "user"
  365 + ]
  366 + }
  367 + },
  368 + "v1/mini/user/unfollow": {
  369 + "post": {
  370 + "summary": "取消关注",
  371 + "operationId": "miniUserUnFollow",
  372 + "responses": {
  373 + "200": {
  374 + "description": "A successful response.",
  375 + "schema": {}
  376 + }
  377 + },
  378 + "parameters": [
  379 + {
  380 + "name": "body",
  381 + "in": "body",
  382 + "required": true,
  383 + "schema": {
  384 + "$ref": "#/definitions/FollowRequest"
  385 + }
  386 + }
  387 + ],
  388 + "requestBody": {},
  389 + "tags": [
  390 + "user"
  391 + ]
  392 + }
  393 + },
36 "v1/system/comment": { 394 "v1/system/comment": {
37 "get": { 395 "get": {
38 "summary": "系统评论", 396 "summary": "系统评论",
@@ -50,6 +408,34 @@ @@ -50,6 +408,34 @@
50 "comment" 408 "comment"
51 ] 409 ]
52 } 410 }
  411 + },
  412 + "v1/system/company/search": {
  413 + "post": {
  414 + "summary": "公司搜索",
  415 + "operationId": "systemCompanySearch",
  416 + "responses": {
  417 + "200": {
  418 + "description": "A successful response.",
  419 + "schema": {
  420 + "$ref": "#/definitions/CompanySearchResponse"
  421 + }
  422 + }
  423 + },
  424 + "parameters": [
  425 + {
  426 + "name": "body",
  427 + "in": "body",
  428 + "required": true,
  429 + "schema": {
  430 + "$ref": "#/definitions/CompanySearchRequest"
  431 + }
  432 + }
  433 + ],
  434 + "requestBody": {},
  435 + "tags": [
  436 + "company"
  437 + ]
  438 + }
53 } 439 }
54 }, 440 },
55 "definitions": { 441 "definitions": {
@@ -75,6 +461,651 @@ @@ -75,6 +461,651 @@
75 "required": [ 461 "required": [
76 "list" 462 "list"
77 ] 463 ]
  464 + },
  465 + "Company": {
  466 + "type": "object",
  467 + "properties": {
  468 + "id": {
  469 + "type": "integer",
  470 + "format": "int64",
  471 + "description": " 唯一标识"
  472 + },
  473 + "name": {
  474 + "type": "string",
  475 + "description": " 名称"
  476 + },
  477 + "code": {
  478 + "type": "string",
  479 + "description": " 编码(搜索使用,4位字母数字)"
  480 + },
  481 + "logo": {
  482 + "type": "string",
  483 + "description": " 公司LOGO"
  484 + }
  485 + },
  486 + "title": "Company",
  487 + "required": [
  488 + "id",
  489 + "name",
  490 + "code",
  491 + "logo"
  492 + ]
  493 + },
  494 + "CompanySearchRequest": {
  495 + "type": "object",
  496 + "properties": {
  497 + "page": {
  498 + "type": "integer",
  499 + "format": "int32"
  500 + },
  501 + "size": {
  502 + "type": "integer",
  503 + "format": "int32"
  504 + },
  505 + "userId": {
  506 + "type": "integer",
  507 + "format": "int64",
  508 + "description": " 按用户搜索"
  509 + },
  510 + "code": {
  511 + "type": "string",
  512 + "description": " 按编码搜索"
  513 + }
  514 + },
  515 + "title": "CompanySearchRequest",
  516 + "required": [
  517 + "page",
  518 + "size"
  519 + ]
  520 + },
  521 + "CompanySearchResponse": {
  522 + "type": "object",
  523 + "properties": {
  524 + "list": {
  525 + "type": "array",
  526 + "items": {
  527 + "$ref": "#/definitions/Company"
  528 + }
  529 + },
  530 + "total": {
  531 + "type": "integer",
  532 + "format": "int64"
  533 + }
  534 + },
  535 + "title": "CompanySearchResponse",
  536 + "required": [
  537 + "list",
  538 + "total"
  539 + ]
  540 + },
  541 + "Department": {
  542 + "type": "object",
  543 + "properties": {
  544 + "id": {
  545 + "type": "integer",
  546 + "format": "int64",
  547 + "description": " 部门ID"
  548 + },
  549 + "companyId": {
  550 + "type": "integer",
  551 + "format": "int64",
  552 + "description": " 公司ID"
  553 + },
  554 + "parentId": {
  555 + "type": "integer",
  556 + "format": "int64",
  557 + "description": " 父级ID"
  558 + },
  559 + "name": {
  560 + "type": "string",
  561 + "description": " 部门名称"
  562 + }
  563 + },
  564 + "title": "Department",
  565 + "required": [
  566 + "id",
  567 + "companyId",
  568 + "parentId",
  569 + "name"
  570 + ]
  571 + },
  572 + "FollowRequest": {
  573 + "type": "object",
  574 + "properties": {
  575 + "userId": {
  576 + "type": "integer",
  577 + "format": "int64"
  578 + }
  579 + },
  580 + "title": "FollowRequest",
  581 + "required": [
  582 + "userId"
  583 + ]
  584 + },
  585 + "MessageBusinessItem": {
  586 + "type": "object",
  587 + "properties": {
  588 + "id": {
  589 + "type": "integer",
  590 + "format": "int64"
  591 + },
  592 + "companyId": {
  593 + "type": "integer",
  594 + "format": "int64",
  595 + "description": " 公司ID"
  596 + },
  597 + "type": {
  598 + "type": "integer",
  599 + "format": "int32",
  600 + "description": " 分类 (1回复 2点赞 3被采纳)"
  601 + },
  602 + "optType": {
  603 + "type": "integer",
  604 + "format": "int32",
  605 + "description": " 操作类型(1针对文章、1针对评论、2针对圆桌)"
  606 + },
  607 + "triggerId": {
  608 + "type": "integer",
  609 + "format": "int64",
  610 + "description": " 触发者ID"
  611 + },
  612 + "recipientId": {
  613 + "type": "integer",
  614 + "format": "int64",
  615 + "description": " 接收者ID"
  616 + },
  617 + "articleId": {
  618 + "type": "integer",
  619 + "format": "int64",
  620 + "description": " 文章ID"
  621 + },
  622 + "commentId": {
  623 + "type": "integer",
  624 + "format": "int64",
  625 + "description": " 评论ID"
  626 + },
  627 + "discussionId": {
  628 + "type": "integer",
  629 + "format": "int64",
  630 + "description": " 圆桌ID"
  631 + },
  632 + "discussionOpinionId": {
  633 + "type": "integer",
  634 + "format": "int64",
  635 + "description": " 观点ID"
  636 + },
  637 + "content": {
  638 + "type": "string",
  639 + "description": " 消息内容"
  640 + },
  641 + "createdAt": {
  642 + "type": "integer",
  643 + "format": "int64",
  644 + "description": " 创建时间"
  645 + },
  646 + "userTrigger": {
  647 + "$ref": "#/definitions/User",
  648 + "description": " 触发者"
  649 + }
  650 + },
  651 + "title": "MessageBusinessItem",
  652 + "required": [
  653 + "id",
  654 + "companyId",
  655 + "type",
  656 + "optType",
  657 + "triggerId",
  658 + "recipientId",
  659 + "articleId",
  660 + "commentId",
  661 + "discussionId",
  662 + "discussionOpinionId",
  663 + "content",
  664 + "createdAt",
  665 + "userTrigger"
  666 + ]
  667 + },
  668 + "MessageBusinessRequest": {
  669 + "type": "object",
  670 + "properties": {
  671 + "page": {
  672 + "type": "integer",
  673 + "format": "int32"
  674 + },
  675 + "size": {
  676 + "type": "integer",
  677 + "format": "int32"
  678 + }
  679 + },
  680 + "title": "MessageBusinessRequest",
  681 + "required": [
  682 + "page",
  683 + "size"
  684 + ]
  685 + },
  686 + "MessageBusinessResponse": {
  687 + "type": "object",
  688 + "properties": {
  689 + "list": {
  690 + "type": "array",
  691 + "items": {
  692 + "$ref": "#/definitions/MessageBusinessItem"
  693 + }
  694 + },
  695 + "total": {
  696 + "type": "integer",
  697 + "format": "int64"
  698 + }
  699 + },
  700 + "title": "MessageBusinessResponse",
  701 + "required": [
  702 + "list",
  703 + "total"
  704 + ]
  705 + },
  706 + "MessageSystemItem": {
  707 + "type": "object",
  708 + "properties": {
  709 + "id": {
  710 + "type": "integer",
  711 + "format": "int64",
  712 + "description": " ID"
  713 + },
  714 + "type": {
  715 + "type": "integer",
  716 + "format": "int32",
  717 + "description": " 系统分类"
  718 + },
  719 + "title": {
  720 + "type": "string",
  721 + "description": " 标题"
  722 + },
  723 + "content": {
  724 + "type": "string",
  725 + "description": " 内容"
  726 + }
  727 + },
  728 + "title": "MessageSystemItem",
  729 + "required": [
  730 + "id",
  731 + "type",
  732 + "title",
  733 + "content"
  734 + ]
  735 + },
  736 + "MessageSystemRequest": {
  737 + "type": "object",
  738 + "properties": {
  739 + "page": {
  740 + "type": "integer",
  741 + "format": "int32"
  742 + },
  743 + "size": {
  744 + "type": "integer",
  745 + "format": "int32"
  746 + }
  747 + },
  748 + "title": "MessageSystemRequest",
  749 + "required": [
  750 + "page",
  751 + "size"
  752 + ]
  753 + },
  754 + "MessageSystemResponse": {
  755 + "type": "object",
  756 + "properties": {
  757 + "list": {
  758 + "type": "array",
  759 + "items": {
  760 + "$ref": "#/definitions/MessageSystemItem"
  761 + }
  762 + },
  763 + "total": {
  764 + "type": "integer",
  765 + "format": "int64"
  766 + }
  767 + },
  768 + "title": "MessageSystemResponse",
  769 + "required": [
  770 + "list",
  771 + "total"
  772 + ]
  773 + },
  774 + "MiniUserApplyJoinCompanyRequest": {
  775 + "type": "object",
  776 + "properties": {
  777 + "phone": {
  778 + "type": "string"
  779 + },
  780 + "code": {
  781 + "type": "string"
  782 + }
  783 + },
  784 + "title": "MiniUserApplyJoinCompanyRequest",
  785 + "required": [
  786 + "phone",
  787 + "code"
  788 + ]
  789 + },
  790 + "MiniUserApplyJoinCompanyResponse": {
  791 + "type": "object",
  792 + "title": "MiniUserApplyJoinCompanyResponse"
  793 + },
  794 + "MiniUserAuditRequest": {
  795 + "type": "object",
  796 + "properties": {
  797 + "userId": {
  798 + "type": "integer",
  799 + "format": "int64",
  800 + "description": " 用户ID"
  801 + },
  802 + "status": {
  803 + "type": "integer",
  804 + "format": "int32",
  805 + "description": " 审核状态 1:审核通过 2:拒绝"
  806 + }
  807 + },
  808 + "title": "MiniUserAuditRequest",
  809 + "required": [
  810 + "userId",
  811 + "status"
  812 + ]
  813 + },
  814 + "MiniUserDepartmentUsersRequest": {
  815 + "type": "object",
  816 + "title": "MiniUserDepartmentUsersRequest"
  817 + },
  818 + "MiniUserDepartmentUsersResponse": {
  819 + "type": "object",
  820 + "properties": {
  821 + "departments": {
  822 + "type": "array",
  823 + "items": {
  824 + "$ref": "#/definitions/Department"
  825 + }
  826 + },
  827 + "users": {
  828 + "type": "array",
  829 + "items": {
  830 + "$ref": "#/definitions/UserItem"
  831 + }
  832 + }
  833 + },
  834 + "title": "MiniUserDepartmentUsersResponse",
  835 + "required": [
  836 + "departments",
  837 + "users"
  838 + ]
  839 + },
  840 + "MiniUserInfoRequest": {
  841 + "type": "object",
  842 + "title": "MiniUserInfoRequest"
  843 + },
  844 + "MiniUserInfoResponse": {
  845 + "type": "object",
  846 + "properties": {
  847 + "user": {
  848 + "$ref": "#/definitions/UserItem",
  849 + "description": " 用户信息"
  850 + },
  851 + "totalArticle": {
  852 + "type": "integer",
  853 + "format": "int64",
  854 + "description": " 累计信息发布"
  855 + },
  856 + "totalLoved": {
  857 + "type": "integer",
  858 + "format": "int64",
  859 + "description": " 累计收到的赞"
  860 + },
  861 + "totalAccepted": {
  862 + "type": "integer",
  863 + "format": "int64",
  864 + "description": " 累计被采纳"
  865 + }
  866 + },
  867 + "title": "MiniUserInfoResponse",
  868 + "required": [
  869 + "user",
  870 + "totalArticle",
  871 + "totalLoved",
  872 + "totalAccepted"
  873 + ]
  874 + },
  875 + "MiniUserLoginRequest": {
  876 + "type": "object",
  877 + "properties": {
  878 + "loginType": {
  879 + "type": "string",
  880 + "description": " 登录类型 wechat-login whchat-phone-login phone-password-login phone-smscode-login"
  881 + },
  882 + "wechatAuthcode": {
  883 + "type": "string",
  884 + "description": " 微信登录 授权码"
  885 + },
  886 + "wechatEncryptedData": {
  887 + "type": "string",
  888 + "description": " 微信登录 加密数据"
  889 + },
  890 + "wechatIV": {
  891 + "type": "string",
  892 + "description": " 微信登录 加密算法初始向量"
  893 + },
  894 + "phone": {
  895 + "type": "string",
  896 + "description": " 手机号"
  897 + },
  898 + "password": {
  899 + "type": "string",
  900 + "description": " 密码"
  901 + },
  902 + "smsCode": {
  903 + "type": "string",
  904 + "description": " 短信验证码"
  905 + }
  906 + },
  907 + "title": "MiniUserLoginRequest",
  908 + "required": [
  909 + "loginType"
  910 + ]
  911 + },
  912 + "MiniUserLoginResponse": {
  913 + "type": "object",
  914 + "properties": {
  915 + "token": {
  916 + "type": "string",
  917 + "description": " x-token"
  918 + },
  919 + "phone": {
  920 + "type": "string",
  921 + "description": " 手机号"
  922 + },
  923 + "message": {
  924 + "type": "string",
  925 + "description": " 失败消息(审核中,注册成功等待审核)"
  926 + },
  927 + "success": {
  928 + "type": "boolean",
  929 + "format": "boolean",
  930 + "description": " 成功标识"
  931 + }
  932 + },
  933 + "title": "MiniUserLoginResponse",
  934 + "required": [
  935 + "token",
  936 + "phone",
  937 + "message",
  938 + "success"
  939 + ]
  940 + },
  941 + "User": {
  942 + "type": "object",
  943 + "properties": {
  944 + "id": {
  945 + "type": "integer",
  946 + "format": "int64"
  947 + },
  948 + "companyId": {
  949 + "type": "integer",
  950 + "format": "int64",
  951 + "description": " 公司ID"
  952 + },
  953 + "departmentId": {
  954 + "type": "integer",
  955 + "format": "int64",
  956 + "description": " 部门ID"
  957 + },
  958 + "name": {
  959 + "type": "string",
  960 + "description": " 名称"
  961 + },
  962 + "avatar": {
  963 + "type": "string",
  964 + "description": " 头像"
  965 + },
  966 + "position": {
  967 + "type": "string",
  968 + "description": " 职位"
  969 + }
  970 + },
  971 + "title": "User",
  972 + "required": [
  973 + "id",
  974 + "companyId",
  975 + "departmentId",
  976 + "name",
  977 + "avatar",
  978 + "position"
  979 + ]
  980 + },
  981 + "UserItem": {
  982 + "type": "object",
  983 + "properties": {
  984 + "id": {
  985 + "type": "integer",
  986 + "format": "int64",
  987 + "description": " 用户ID"
  988 + },
  989 + "companyId": {
  990 + "type": "integer",
  991 + "format": "int64",
  992 + "description": " 公司ID"
  993 + },
  994 + "departmentId": {
  995 + "type": "integer",
  996 + "format": "int64",
  997 + "description": " 部门ID"
  998 + },
  999 + "roleId": {
  1000 + "type": "array",
  1001 + "items": {
  1002 + "type": "integer",
  1003 + "format": "int64"
  1004 + },
  1005 + "description": " 角色"
  1006 + },
  1007 + "flag": {
  1008 + "type": "integer",
  1009 + "format": "int32",
  1010 + "description": " 标识 1:管理员 2:普通用户 (有绑定角色是管理员)"
  1011 + },
  1012 + "name": {
  1013 + "type": "string",
  1014 + "description": " 名称"
  1015 + },
  1016 + "avatar": {
  1017 + "type": "string",
  1018 + "description": " 头像"
  1019 + },
  1020 + "phone": {
  1021 + "type": "string",
  1022 + "description": " 手机号 唯一"
  1023 + },
  1024 + "position": {
  1025 + "type": "string",
  1026 + "description": " 职位"
  1027 + },
  1028 + "enable": {
  1029 + "type": "integer",
  1030 + "format": "int32",
  1031 + "description": " 启用状态 1:启用 2:禁用"
  1032 + },
  1033 + "auditStatus": {
  1034 + "type": "integer",
  1035 + "format": "int32",
  1036 + "description": " 审核状态 0:待审核 1:审核通过 2:拒绝"
  1037 + },
  1038 + "followers": {
  1039 + "type": "array",
  1040 + "items": {
  1041 + "type": "integer",
  1042 + "format": "int64"
  1043 + },
  1044 + "description": " 关注我的人 (冗余)"
  1045 + },
  1046 + "following": {
  1047 + "type": "array",
  1048 + "items": {
  1049 + "type": "integer",
  1050 + "format": "int64"
  1051 + },
  1052 + "description": " 我关注的人 (冗余)"
  1053 + }
  1054 + },
  1055 + "title": "UserItem",
  1056 + "required": [
  1057 + "id",
  1058 + "companyId",
  1059 + "departmentId",
  1060 + "roleId",
  1061 + "flag",
  1062 + "name",
  1063 + "avatar",
  1064 + "phone",
  1065 + "position",
  1066 + "enable",
  1067 + "auditStatus",
  1068 + "followers",
  1069 + "following"
  1070 + ]
  1071 + },
  1072 + "UserSearchRequest": {
  1073 + "type": "object",
  1074 + "properties": {
  1075 + "page": {
  1076 + "type": "integer",
  1077 + "format": "int32"
  1078 + },
  1079 + "size": {
  1080 + "type": "integer",
  1081 + "format": "int32"
  1082 + },
  1083 + "auditFlag": {
  1084 + "$ref": "#/definitions/int",
  1085 + "description": " 按审核状态 0:待审核 1:审核通过 2:拒绝"
  1086 + }
  1087 + },
  1088 + "title": "UserSearchRequest"
  1089 + },
  1090 + "UserSearchResponse": {
  1091 + "type": "object",
  1092 + "properties": {
  1093 + "list": {
  1094 + "type": "array",
  1095 + "items": {
  1096 + "$ref": "#/definitions/UserItem"
  1097 + }
  1098 + },
  1099 + "total": {
  1100 + "type": "integer",
  1101 + "format": "int64"
  1102 + }
  1103 + },
  1104 + "title": "UserSearchResponse",
  1105 + "required": [
  1106 + "list",
  1107 + "total"
  1108 + ]
78 } 1109 }
79 }, 1110 },
80 "securityDefinitions": { 1111 "securityDefinitions": {
@@ -88,6 +88,7 @@ type( @@ -88,6 +88,7 @@ type(
88 } 88 }
89 MiniUserAuditRequest{ 89 MiniUserAuditRequest{
90 UserId int64 `json:"userId"` // 用户ID 90 UserId int64 `json:"userId"` // 用户ID
  91 + Status int `json:"status"` // 审核状态 1:审核通过 2:拒绝
91 } 92 }
92 MiniUserDepartmentUsersRequest{ 93 MiniUserDepartmentUsersRequest{
93 94
@@ -97,6 +98,7 @@ type( @@ -97,6 +98,7 @@ type(
97 Users []*UserItem `json:"users"` 98 Users []*UserItem `json:"users"`
98 } 99 }
99 UserItem { 100 UserItem {
  101 + Id int64 `json:"id,omitempty"` // 用户ID
100 CompanyId int64 `json:"companyId,omitempty"` // 公司ID 102 CompanyId int64 `json:"companyId,omitempty"` // 公司ID
101 DepartmentId int64 `json:"departmentId,omitempty"` // 部门ID 103 DepartmentId int64 `json:"departmentId,omitempty"` // 部门ID
102 Roles []int64 `json:"roleId,omitempty"` // 角色 104 Roles []int64 `json:"roleId,omitempty"` // 角色
1 package company 1 package company
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 MiniCompanySearchHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { @@ -19,10 +20,6 @@ func MiniCompanySearchHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
19 20
20 l := company.NewMiniCompanySearchLogic(r.Context(), svcCtx) 21 l := company.NewMiniCompanySearchLogic(r.Context(), svcCtx)
21 resp, err := l.MiniCompanySearch(&req) 22 resp, err := l.MiniCompanySearch(&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 company 1 package company
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 SystemCompanySearchHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { @@ -19,10 +20,6 @@ func SystemCompanySearchHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
19 20
20 l := company.NewSystemCompanySearchLogic(r.Context(), svcCtx) 21 l := company.NewSystemCompanySearchLogic(r.Context(), svcCtx)
21 resp, err := l.SystemCompanySearch(&req) 22 resp, err := l.SystemCompanySearch(&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 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 MiniUserApplyJoinCompanyHandler(svcCtx *svc.ServiceContext) http.HandlerFun @@ -19,10 +20,6 @@ func MiniUserApplyJoinCompanyHandler(svcCtx *svc.ServiceContext) http.HandlerFun
19 20
20 l := user.NewMiniUserApplyJoinCompanyLogic(r.Context(), svcCtx) 21 l := user.NewMiniUserApplyJoinCompanyLogic(r.Context(), svcCtx)
21 resp, err := l.MiniUserApplyJoinCompany(&req) 22 resp, err := l.MiniUserApplyJoinCompany(&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 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 MiniUserAuditHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { @@ -19,10 +20,6 @@ func MiniUserAuditHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
19 20
20 l := user.NewMiniUserAuditLogic(r.Context(), svcCtx) 21 l := user.NewMiniUserAuditLogic(r.Context(), svcCtx)
21 err := l.MiniUserAudit(&req) 22 err := l.MiniUserAudit(&req)
22 - if err != nil {  
23 - httpx.ErrorCtx(r.Context(), w, err)  
24 - } else {  
25 - httpx.Ok(w)  
26 - } 23 + result.HttpResult(r, w, struct{}{}, err)
27 } 24 }
28 } 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 MiniUserAuditListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { @@ -19,10 +20,6 @@ func MiniUserAuditListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
19 20
20 l := user.NewMiniUserAuditListLogic(r.Context(), svcCtx) 21 l := user.NewMiniUserAuditListLogic(r.Context(), svcCtx)
21 resp, err := l.MiniUserAuditList(&req) 22 resp, err := l.MiniUserAuditList(&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 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 MiniUserDepartmentUsersHandler(svcCtx *svc.ServiceContext) http.HandlerFunc @@ -19,10 +20,6 @@ func MiniUserDepartmentUsersHandler(svcCtx *svc.ServiceContext) http.HandlerFunc
19 20
20 l := user.NewMiniUserDepartmentUsersLogic(r.Context(), svcCtx) 21 l := user.NewMiniUserDepartmentUsersLogic(r.Context(), svcCtx)
21 resp, err := l.MiniUserDepartmentUsers(&req) 22 resp, err := l.MiniUserDepartmentUsers(&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 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 MiniUserFollowHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { @@ -19,10 +20,6 @@ func MiniUserFollowHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
19 20
20 l := user.NewMiniUserFollowLogic(r.Context(), svcCtx) 21 l := user.NewMiniUserFollowLogic(r.Context(), svcCtx)
21 err := l.MiniUserFollow(&req) 22 err := l.MiniUserFollow(&req)
22 - if err != nil {  
23 - httpx.ErrorCtx(r.Context(), w, err)  
24 - } else {  
25 - httpx.Ok(w)  
26 - } 23 + result.HttpResult(r, w, struct{}{}, err)
27 } 24 }
28 } 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 MiniUserFollowerHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { @@ -19,10 +20,6 @@ func MiniUserFollowerHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
19 20
20 l := user.NewMiniUserFollowerLogic(r.Context(), svcCtx) 21 l := user.NewMiniUserFollowerLogic(r.Context(), svcCtx)
21 resp, err := l.MiniUserFollower(&req) 22 resp, err := l.MiniUserFollower(&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 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 MiniUserFollowingHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { @@ -19,10 +20,6 @@ func MiniUserFollowingHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
19 20
20 l := user.NewMiniUserFollowingLogic(r.Context(), svcCtx) 21 l := user.NewMiniUserFollowingLogic(r.Context(), svcCtx)
21 resp, err := l.MiniUserFollowing(&req) 22 resp, err := l.MiniUserFollowing(&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 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 MiniUserInfoHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { @@ -19,10 +20,6 @@ func MiniUserInfoHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
19 20
20 l := user.NewMiniUserInfoLogic(r.Context(), svcCtx) 21 l := user.NewMiniUserInfoLogic(r.Context(), svcCtx)
21 resp, err := l.MiniUserInfo(&req) 22 resp, err := l.MiniUserInfo(&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 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 MiniUserLoginHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { @@ -19,10 +20,6 @@ func MiniUserLoginHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
19 20
20 l := user.NewMiniUserLoginLogic(r.Context(), svcCtx) 21 l := user.NewMiniUserLoginLogic(r.Context(), svcCtx)
21 resp, err := l.MiniUserLogin(&req) 22 resp, err := l.MiniUserLogin(&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 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 MiniUserUnFollowHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { @@ -19,10 +20,6 @@ func MiniUserUnFollowHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
19 20
20 l := user.NewMiniUserUnFollowLogic(r.Context(), svcCtx) 21 l := user.NewMiniUserUnFollowLogic(r.Context(), svcCtx)
21 err := l.MiniUserUnFollow(&req) 22 err := l.MiniUserUnFollow(&req)
22 - if err != nil {  
23 - httpx.ErrorCtx(r.Context(), w, err)  
24 - } else {  
25 - httpx.Ok(w)  
26 - } 23 + result.HttpResult(r, w, struct{}{}, err)
27 } 24 }
28 } 25 }
@@ -2,6 +2,10 @@ package user @@ -2,6 +2,10 @@ package user
2 2
3 import ( 3 import (
4 "context" 4 "context"
  5 + "errors"
  6 + "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/domain"
  8 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr"
5 9
6 "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" 10 "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" 11 "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
@@ -24,7 +28,46 @@ func NewMiniUserApplyJoinCompanyLogic(ctx context.Context, svcCtx *svc.ServiceCo @@ -24,7 +28,46 @@ func NewMiniUserApplyJoinCompanyLogic(ctx context.Context, svcCtx *svc.ServiceCo
24 } 28 }
25 29
26 func (l *MiniUserApplyJoinCompanyLogic) MiniUserApplyJoinCompany(req *types.MiniUserApplyJoinCompanyRequest) (resp *types.MiniUserApplyJoinCompanyResponse, err error) { 30 func (l *MiniUserApplyJoinCompanyLogic) MiniUserApplyJoinCompany(req *types.MiniUserApplyJoinCompanyRequest) (resp *types.MiniUserApplyJoinCompanyResponse, err error) {
27 - // todo: add your logic here and delete this line  
28 - 31 + var (
  32 + conn = l.svcCtx.DefaultDBConn()
  33 + company *domain.Company
  34 + user *domain.User
  35 + )
  36 + if company, err = l.svcCtx.CompanyRepository.FindOneByCode(l.ctx, conn, req.Code); err != nil {
  37 + return nil, xerr.NewErrMsgErr("公司不存在", err)
  38 + }
  39 + if user, err = l.svcCtx.UserRepository.FindOneByCompanyIdAndPhone(l.ctx, conn, company.Id, req.Phone, []int{domain.UserAuditStatusWait, domain.UserAuditStatusPassed}); err != nil {
  40 + if errors.Is(err, domain.ErrNotFound) {
  41 + err = nil
  42 + }
  43 + }
  44 + if err != nil {
  45 + return nil, xerr.NewErrMsgErr("申请失败", err)
  46 + }
  47 + if user != nil {
  48 + if user.AuditStatus == domain.UserAuditStatusWait {
  49 + return nil, xerr.NewErrMsgErr("已申请,待审核中", err)
  50 + }
  51 + if user.AuditStatus == domain.UserAuditStatusPassed {
  52 + return nil, xerr.NewErrMsgErr("公司已申请", err)
  53 + }
  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 + Enable: domain.UserEnable,
  60 + Roles: make([]int64, 0),
  61 + Follower: make([]int64, 0),
  62 + Following: make([]int64, 0),
  63 + }
  64 + if user, err = l.svcCtx.UserRepository.Insert(ctx, conn, user); err != nil {
  65 + return err
  66 + }
  67 + return nil
  68 + }, true); err != nil {
  69 + return nil, xerr.NewErrMsgErr("申请失败", err)
  70 + }
  71 + resp = &types.MiniUserApplyJoinCompanyResponse{}
29 return 72 return
30 } 73 }
@@ -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,5 @@ func NewMiniUserAuditListLogic(ctx context.Context, svcCtx *svc.ServiceContext) @@ -24,7 +23,5 @@ func NewMiniUserAuditListLogic(ctx context.Context, svcCtx *svc.ServiceContext)
24 } 23 }
25 24
26 func (l *MiniUserAuditListLogic) MiniUserAuditList(req *types.UserSearchRequest) (resp *types.UserSearchResponse, err error) { 25 func (l *MiniUserAuditListLogic) MiniUserAuditList(req *types.UserSearchRequest) (resp *types.UserSearchResponse, err error) {
27 - // todo: add your logic here and delete this line  
28 -  
29 return 26 return
30 } 27 }
@@ -2,6 +2,9 @@ package user @@ -2,6 +2,9 @@ package user
2 2
3 import ( 3 import (
4 "context" 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/xerr"
5 8
6 "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" 9 "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" 10 "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
@@ -23,8 +26,24 @@ func NewMiniUserAuditLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Min @@ -23,8 +26,24 @@ func NewMiniUserAuditLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Min
23 } 26 }
24 } 27 }
25 28
26 -func (l *MiniUserAuditLogic) MiniUserAudit(req *types.MiniUserAuditRequest) error {  
27 - // todo: add your logic here and delete this line  
28 - 29 +func (l *MiniUserAuditLogic) MiniUserAudit(req *types.MiniUserAuditRequest) (err error) {
  30 + var (
  31 + conn = l.svcCtx.DefaultDBConn()
  32 + user *domain.User
  33 + )
  34 + if user, err = l.svcCtx.UserRepository.FindOne(l.ctx, conn, req.UserId); err != nil {
  35 + return xerr.NewErrMsgErr("用户不存在", err)
  36 + }
  37 + if err = transaction.UseTrans(l.ctx, l.svcCtx.DB, func(ctx context.Context, conn transaction.Conn) error {
  38 + if err = user.Audit(req.Status); err != nil {
  39 + return err
  40 + }
  41 + if user, err = l.svcCtx.UserRepository.UpdateWithVersion(ctx, conn, user); err != nil {
  42 + return err
  43 + }
  44 + return nil
  45 + }, true); err != nil {
  46 + return xerr.NewErrMsgErr("审核失败", err)
  47 + }
29 return nil 48 return nil
30 } 49 }
@@ -2,6 +2,9 @@ package user @@ -2,6 +2,9 @@ package user
2 2
3 import ( 3 import (
4 "context" 4 "context"
  5 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain"
  6 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/contextdata"
  7 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr"
5 8
6 "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" 9 "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" 10 "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
@@ -24,7 +27,19 @@ func NewMiniUserInfoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Mini @@ -24,7 +27,19 @@ func NewMiniUserInfoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Mini
24 } 27 }
25 28
26 func (l *MiniUserInfoLogic) MiniUserInfo(req *types.MiniUserInfoRequest) (resp *types.MiniUserInfoResponse, err error) { 29 func (l *MiniUserInfoLogic) MiniUserInfo(req *types.MiniUserInfoRequest) (resp *types.MiniUserInfoResponse, err error) {
27 - // todo: add your logic here and delete this line  
28 - 30 + var (
  31 + userToken = contextdata.GetUserTokenFromCtx(l.ctx)
  32 + user *domain.User
  33 + conn = l.svcCtx.DefaultDBConn()
  34 + )
  35 + if user, err = l.svcCtx.UserRepository.FindOne(l.ctx, conn, userToken.UserId); err != nil {
  36 + return nil, xerr.NewErrMsgErr("用户不存在", err)
  37 + }
  38 + resp = &types.MiniUserInfoResponse{
  39 + User: &types.UserItem{
  40 + Id: user.Id,
  41 + Name: user.Name,
  42 + },
  43 + }
29 return 44 return
30 } 45 }
@@ -2,6 +2,13 @@ package user @@ -2,6 +2,13 @@ package user
2 2
3 import ( 3 import (
4 "context" 4 "context"
  5 + "fmt"
  6 + "github.com/silenceper/wechat/v2"
  7 + "github.com/silenceper/wechat/v2/cache"
  8 + miniConfig "github.com/silenceper/wechat/v2/miniprogram/config"
  9 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain"
  10 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/tool"
  11 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr"
5 12
6 "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" 13 "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" 14 "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
@@ -24,7 +31,106 @@ func NewMiniUserLoginLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Min @@ -24,7 +31,106 @@ func NewMiniUserLoginLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Min
24 } 31 }
25 32
26 func (l *MiniUserLoginLogic) MiniUserLogin(req *types.MiniUserLoginRequest) (resp *types.MiniUserLoginResponse, err error) { 33 func (l *MiniUserLoginLogic) MiniUserLogin(req *types.MiniUserLoginRequest) (resp *types.MiniUserLoginResponse, err error) {
27 - // todo: add your logic here and delete this line  
28 - 34 + var (
  35 + loginInfo *domain.LoginInfo
  36 + token string
  37 + loginCreator domain.LoginCreator = WXStuClientLogin{l: l}
  38 + )
  39 + switch req.LoginType {
  40 + case domain.LoginTypeWechatLogin:
  41 + loginInfo, err = loginCreator.WechatLogin(domain.WechatLoginRequest{Code: req.WechatAuthCode, EncryptedData: req.WechatEncryptedData, IV: req.WechatIV})
  42 + case domain.LoginTypeWechatPhoneLogin:
  43 + loginInfo, err = loginCreator.WechatPhoneLogin(domain.WechatLoginRequest{Code: req.WechatAuthCode, EncryptedData: req.WechatEncryptedData, IV: req.WechatIV})
  44 + case domain.LoginTypePhoneSmsCodeLogin:
  45 + loginInfo, err = loginCreator.PhoneSmsCodeLogin(req.Phone, req.SmsCode)
  46 + case domain.LoginTypePhonePasswordLogin:
  47 + loginInfo, err = loginCreator.PhonePasswordLogin(req.Phone, req.Password)
  48 + }
  49 + if err != nil {
29 return 50 return
  51 + }
  52 + var userJwtToken = tool.UserToken{}
  53 + if loginInfo.User != nil {
  54 + userJwtToken.UserId = loginInfo.User.Id
  55 + userJwtToken.CompanyId = loginInfo.User.CompanyId
  56 + userJwtToken.ClientType = "mini"
  57 + }
  58 + token, err = userJwtToken.GenerateToken(l.svcCtx.Config.MiniAuth.AccessSecret, l.svcCtx.Config.MiniAuth.AccessExpire)
  59 + if err != nil {
  60 + return nil, xerr.NewErrMsgErr("登录失败", err)
  61 + }
  62 + resp = &types.MiniUserLoginResponse{
  63 + Token: token,
  64 + Phone: loginInfo.Phone,
  65 + Success: true,
  66 + }
  67 + if loginInfo.User == nil {
  68 + resp.Success = false
  69 + }
  70 + return
  71 +}
  72 +
  73 +type WXStuClientLogin struct {
  74 + l *MiniUserLoginLogic
  75 +}
  76 +
  77 +func (c WXStuClientLogin) WechatPhoneLogin(r domain.WechatLoginRequest) (*domain.LoginInfo, error) {
  78 + code := r.Code
  79 + miniprogram := wechat.NewWechat().GetMiniProgram(&miniConfig.Config{
  80 + AppID: c.l.svcCtx.Config.Wechat.AppID,
  81 + AppSecret: c.l.svcCtx.Config.Wechat.AppSecret,
  82 + Cache: cache.NewMemory(),
  83 + })
  84 + authResult, err := miniprogram.GetAuth().GetPhoneNumber(code)
  85 + if err != nil || authResult.ErrCode != 0 || authResult.PhoneInfo.PhoneNumber == "" {
  86 + return nil, xerr.NewCodeErrMsg(xerr.ErrWxMiniAuthFailError, nil, fmt.Sprintf("发起授权请求失败1 err : %v , code : %s , authResult : %+v", err, code, authResult))
  87 + }
  88 + var (
  89 + users []*domain.User
  90 + phone = authResult.PhoneInfo.PhoneNumber
  91 + )
  92 + conn := c.l.svcCtx.DefaultDBConn()
  93 + _, users, err = c.l.svcCtx.UserRepository.Find(c.l.ctx, conn, domain.NewQueryOptions().
  94 + MustWithKV("phone", phone).
  95 + MustWithKV("auditStatus", []int{domain.UserAuditStatusPassed}))
  96 + if err != nil {
  97 + return nil, err
  98 + }
  99 + response := &domain.LoginInfo{
  100 + Phone: phone,
  101 + }
  102 + if len(users) != 0 {
  103 + response.User = users[0]
  104 + }
  105 + return response, nil
  106 +}
  107 +
  108 +func (c WXStuClientLogin) WechatLogin(r domain.WechatLoginRequest) (*domain.LoginInfo, error) {
  109 + return nil, nil
  110 +}
  111 +
  112 +func (c WXStuClientLogin) PhonePasswordLogin(phone string, password string) (*domain.LoginInfo, error) {
  113 + panic("implement me")
  114 +}
  115 +
  116 +func (c WXStuClientLogin) PhoneSmsCodeLogin(phone string, code string) (*domain.LoginInfo, error) {
  117 + var (
  118 + users []*domain.User
  119 + err error
  120 + )
  121 + conn := c.l.svcCtx.DefaultDBConn()
  122 + _, users, err = c.l.svcCtx.UserRepository.Find(c.l.ctx, conn, domain.NewQueryOptions().
  123 + MustWithKV("phone", phone).
  124 + MustWithKV("auditStatus", []int{domain.UserAuditStatusPassed}).
  125 + WithFindOnly())
  126 + if err != nil {
  127 + return nil, err
  128 + }
  129 + response := &domain.LoginInfo{
  130 + Phone: phone,
  131 + }
  132 + if len(users) != 0 {
  133 + response.User = users[0]
  134 + }
  135 + return response, nil
30 } 136 }
@@ -100,6 +100,7 @@ type MiniUserApplyJoinCompanyResponse struct { @@ -100,6 +100,7 @@ type MiniUserApplyJoinCompanyResponse struct {
100 100
101 type MiniUserAuditRequest struct { 101 type MiniUserAuditRequest struct {
102 UserId int64 `json:"userId"` // 用户ID 102 UserId int64 `json:"userId"` // 用户ID
  103 + Status int `json:"status"` // 审核状态 1:审核通过 2:拒绝
103 } 104 }
104 105
105 type MiniUserDepartmentUsersRequest struct { 106 type MiniUserDepartmentUsersRequest struct {
@@ -111,6 +112,7 @@ type MiniUserDepartmentUsersResponse struct { @@ -111,6 +112,7 @@ type MiniUserDepartmentUsersResponse struct {
111 } 112 }
112 113
113 type UserItem struct { 114 type UserItem struct {
  115 + Id int64 `json:"id,omitempty"` // 用户ID
114 CompanyId int64 `json:"companyId,omitempty"` // 公司ID 116 CompanyId int64 `json:"companyId,omitempty"` // 公司ID
115 DepartmentId int64 `json:"departmentId,omitempty"` // 部门ID 117 DepartmentId int64 `json:"departmentId,omitempty"` // 部门ID
116 Roles []int64 `json:"roleId,omitempty"` // 角色 118 Roles []int64 `json:"roleId,omitempty"` // 角色
@@ -111,6 +111,25 @@ func (repository *CompanyRepository) FindOne(ctx context.Context, conn transacti @@ -111,6 +111,25 @@ func (repository *CompanyRepository) FindOne(ctx context.Context, conn transacti
111 return repository.ModelToDomainModel(m) 111 return repository.ModelToDomainModel(m)
112 } 112 }
113 113
  114 +func (repository *CompanyRepository) FindOneByCode(ctx context.Context, conn transaction.Conn, code string) (*domain.Company, error) {
  115 + var (
  116 + err error
  117 + tx = conn.DB()
  118 + m = new(models.Company)
  119 + )
  120 + queryFunc := func() (interface{}, error) {
  121 + tx = tx.Model(m).Where("code = ?", code).First(m)
  122 + if errors.Is(tx.Error, gorm.ErrRecordNotFound) {
  123 + return nil, domain.ErrNotFound
  124 + }
  125 + return m, tx.Error
  126 + }
  127 + if _, err = repository.Query(queryFunc); err != nil {
  128 + return nil, err
  129 + }
  130 + return repository.ModelToDomainModel(m)
  131 +}
  132 +
114 func (repository *CompanyRepository) Find(ctx context.Context, conn transaction.Conn, queryOptions map[string]interface{}) (int64, []*domain.Company, error) { 133 func (repository *CompanyRepository) Find(ctx context.Context, conn transaction.Conn, queryOptions map[string]interface{}) (int64, []*domain.Company, error) {
115 var ( 134 var (
116 tx = conn.DB() 135 tx = conn.DB()
@@ -111,6 +111,28 @@ func (repository *UserRepository) FindOne(ctx context.Context, conn transaction. @@ -111,6 +111,28 @@ func (repository *UserRepository) FindOne(ctx context.Context, conn transaction.
111 return repository.ModelToDomainModel(m) 111 return repository.ModelToDomainModel(m)
112 } 112 }
113 113
  114 +func (repository *UserRepository) FindOneByCompanyIdAndPhone(ctx context.Context, conn transaction.Conn, companyId int64, phone string, status []int) (*domain.User, error) {
  115 + var (
  116 + err error
  117 + tx = conn.DB()
  118 + m = new(models.User)
  119 + )
  120 + queryFunc := func() (interface{}, error) {
  121 + tx = tx.Model(m).
  122 + Where("company_id = ?", companyId).
  123 + Where("phone = ?", phone).
  124 + Where("audit_status in (?)", status).First(m)
  125 + if errors.Is(tx.Error, gorm.ErrRecordNotFound) {
  126 + return nil, domain.ErrNotFound
  127 + }
  128 + return m, tx.Error
  129 + }
  130 + if _, err = repository.Query(queryFunc); err != nil {
  131 + return nil, err
  132 + }
  133 + return repository.ModelToDomainModel(m)
  134 +}
  135 +
114 func (repository *UserRepository) Find(ctx context.Context, conn transaction.Conn, queryOptions map[string]interface{}) (int64, []*domain.User, error) { 136 func (repository *UserRepository) Find(ctx context.Context, conn transaction.Conn, queryOptions map[string]interface{}) (int64, []*domain.User, error) {
115 var ( 137 var (
116 tx = conn.DB() 138 tx = conn.DB()
@@ -120,6 +142,12 @@ func (repository *UserRepository) Find(ctx context.Context, conn transaction.Con @@ -120,6 +142,12 @@ func (repository *UserRepository) Find(ctx context.Context, conn transaction.Con
120 ) 142 )
121 queryFunc := func() (interface{}, error) { 143 queryFunc := func() (interface{}, error) {
122 tx = tx.Model(&ms).Order("id desc") 144 tx = tx.Model(&ms).Order("id desc")
  145 + if v, ok := queryOptions["phone"]; ok {
  146 + tx.Where("phone = ?", v)
  147 + }
  148 + if v, ok := queryOptions["auditStatus"]; ok {
  149 + tx.Where("audit_status in (?)", v)
  150 + }
123 if total, tx = transaction.PaginationAndCount(ctx, tx, queryOptions, &ms); tx.Error != nil { 151 if total, tx = transaction.PaginationAndCount(ctx, tx, queryOptions, &ms); tx.Error != nil {
124 return dms, tx.Error 152 return dms, tx.Error
125 } 153 }
@@ -23,6 +23,7 @@ type CompanyRepository interface { @@ -23,6 +23,7 @@ type CompanyRepository interface {
23 UpdateWithVersion(ctx context.Context, conn transaction.Conn, dm *Company) (*Company, error) 23 UpdateWithVersion(ctx context.Context, conn transaction.Conn, dm *Company) (*Company, error)
24 Delete(ctx context.Context, conn transaction.Conn, dm *Company) (*Company, error) 24 Delete(ctx context.Context, conn transaction.Conn, dm *Company) (*Company, error)
25 FindOne(ctx context.Context, conn transaction.Conn, id int64) (*Company, error) 25 FindOne(ctx context.Context, conn transaction.Conn, id int64) (*Company, error)
  26 + FindOneByCode(ctx context.Context, conn transaction.Conn, code string) (*Company, error)
26 Find(ctx context.Context, conn transaction.Conn, queryOptions map[string]interface{}) (int64, []*Company, error) 27 Find(ctx context.Context, conn transaction.Conn, queryOptions map[string]interface{}) (int64, []*Company, error)
27 } 28 }
28 29
@@ -2,6 +2,8 @@ package domain @@ -2,6 +2,8 @@ package domain
2 2
3 import ( 3 import (
4 "context" 4 "context"
  5 + "fmt"
  6 + "github.com/samber/lo"
5 "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"
6 ) 8 )
7 9
@@ -32,6 +34,7 @@ type UserRepository interface { @@ -32,6 +34,7 @@ type UserRepository interface {
32 UpdateWithVersion(ctx context.Context, conn transaction.Conn, dm *User) (*User, error) 34 UpdateWithVersion(ctx context.Context, conn transaction.Conn, dm *User) (*User, error)
33 Delete(ctx context.Context, conn transaction.Conn, dm *User) (*User, error) 35 Delete(ctx context.Context, conn transaction.Conn, dm *User) (*User, error)
34 FindOne(ctx context.Context, conn transaction.Conn, id int64) (*User, error) 36 FindOne(ctx context.Context, conn transaction.Conn, id int64) (*User, error)
  37 + FindOneByCompanyIdAndPhone(ctx context.Context, conn transaction.Conn, companyId int64, phone string, status []int) (*User, error)
35 Find(ctx context.Context, conn transaction.Conn, queryOptions map[string]interface{}) (int64, []*User, error) 38 Find(ctx context.Context, conn transaction.Conn, queryOptions map[string]interface{}) (int64, []*User, error)
36 } 39 }
37 40
@@ -41,3 +44,51 @@ func (m *User) Identify() interface{} { @@ -41,3 +44,51 @@ func (m *User) Identify() interface{} {
41 } 44 }
42 return m.Id 45 return m.Id
43 } 46 }
  47 +
  48 +const (
  49 + UserAuditStatusWait = 0 // 审核中
  50 + UserAuditStatusPassed = 1 // 审核通过
  51 + UserAuditStatusReject = 2 // 审核拒绝
  52 +)
  53 +
  54 +const (
  55 + LoginTypeWechatLogin string = "wechat-login" // 微信登录
  56 + LoginTypeWechatPhoneLogin string = "wechat-phone-login" // 微信手机号登录
  57 + LoginTypePhonePasswordLogin string = "phone-password-login" // 手机密码登录
  58 + LoginTypePhoneSmsCodeLogin string = "phone-sms-code-login" // 手机验证码登录
  59 +)
  60 +
  61 +const (
  62 + UserEnable = 1
  63 + UserDisable = 2
  64 +)
  65 +
  66 +func (m *User) Audit(status int) error {
  67 + if !lo.Contains([]int{UserAuditStatusWait, UserAuditStatusPassed, UserAuditStatusReject}, status) {
  68 + return fmt.Errorf("unknown status:%d", status)
  69 + }
  70 + if m.AuditStatus != UserAuditStatusWait {
  71 + return fmt.Errorf("用户不是在待审核状态")
  72 + }
  73 + m.AuditStatus = status
  74 + return nil
  75 +}
  76 +
  77 +type (
  78 + LoginCreator interface {
  79 + WechatLogin(r WechatLoginRequest) (*LoginInfo, error)
  80 + PhonePasswordLogin(phone string, password string) (*LoginInfo, error)
  81 + PhoneSmsCodeLogin(phone string, code string) (*LoginInfo, error)
  82 + WechatPhoneLogin(r WechatLoginRequest) (*LoginInfo, error)
  83 + }
  84 + WechatLoginRequest struct {
  85 + Code string // 授权码
  86 + EncryptedData string // 包括敏感数据在内的完整用户信息的加密数据
  87 + IV string // 加密算法的初始向量
  88 + }
  89 + LoginInfo struct {
  90 + User *User
  91 + Phone string
  92 + Message string
  93 + }
  94 +)
@@ -7,6 +7,8 @@ require ( @@ -7,6 +7,8 @@ require (
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/pkg/errors v0.9.1 9 github.com/pkg/errors v0.9.1
  10 + github.com/samber/lo v1.38.1
  11 + github.com/silenceper/wechat/v2 v2.1.4
10 github.com/stretchr/testify v1.8.4 12 github.com/stretchr/testify v1.8.4
11 github.com/tiptok/gocomm v1.0.14 13 github.com/tiptok/gocomm v1.0.14
12 github.com/zeromicro/go-zero v1.5.5 14 github.com/zeromicro/go-zero v1.5.5
@@ -21,6 +23,7 @@ require ( @@ -21,6 +23,7 @@ require (
21 github.com/Shopify/sarama v1.37.2 // indirect 23 github.com/Shopify/sarama v1.37.2 // indirect
22 github.com/beego/beego/v2 v2.0.1 // indirect 24 github.com/beego/beego/v2 v2.0.1 // indirect
23 github.com/beorn7/perks v1.0.1 // indirect 25 github.com/beorn7/perks v1.0.1 // indirect
  26 + github.com/bradfitz/gomemcache v0.0.0-20220106215444-fb4bf637b56d // indirect
24 github.com/cenkalti/backoff/v4 v4.2.0 // indirect 27 github.com/cenkalti/backoff/v4 v4.2.0 // indirect
25 github.com/cespare/xxhash/v2 v2.2.0 // indirect 28 github.com/cespare/xxhash/v2 v2.2.0 // indirect
26 github.com/davecgh/go-spew v1.1.1 // indirect 29 github.com/davecgh/go-spew v1.1.1 // indirect
@@ -30,6 +33,7 @@ require ( @@ -30,6 +33,7 @@ require (
30 github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21 // indirect 33 github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21 // indirect
31 github.com/eapache/queue v1.1.0 // indirect 34 github.com/eapache/queue v1.1.0 // indirect
32 github.com/fatih/color v1.15.0 // indirect 35 github.com/fatih/color v1.15.0 // indirect
  36 + github.com/fatih/structs v1.1.0 // indirect
33 github.com/fsnotify/fsnotify v1.4.9 // indirect 37 github.com/fsnotify/fsnotify v1.4.9 // indirect
34 github.com/garyburd/redigo v1.6.3 // indirect 38 github.com/garyburd/redigo v1.6.3 // indirect
35 github.com/gin-contrib/sse v0.1.0 // indirect 39 github.com/gin-contrib/sse v0.1.0 // indirect
@@ -80,12 +84,16 @@ require ( @@ -80,12 +84,16 @@ require (
80 github.com/prometheus/procfs v0.10.1 // indirect 84 github.com/prometheus/procfs v0.10.1 // indirect
81 github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect 85 github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect
82 github.com/shiena/ansicolor v0.0.0-20151119151921-a422bbe96644 // indirect 86 github.com/shiena/ansicolor v0.0.0-20151119151921-a422bbe96644 // indirect
  87 + github.com/sirupsen/logrus v1.9.0 // indirect
83 github.com/spaolacci/murmur3 v1.1.0 // indirect 88 github.com/spaolacci/murmur3 v1.1.0 // indirect
84 github.com/spf13/afero v1.2.2 // indirect 89 github.com/spf13/afero v1.2.2 // indirect
85 - github.com/spf13/cast v1.3.0 // indirect 90 + github.com/spf13/cast v1.4.1 // indirect
86 github.com/spf13/jwalterweatherman v1.0.0 // indirect 91 github.com/spf13/jwalterweatherman v1.0.0 // indirect
87 github.com/spf13/pflag v1.0.5 // indirect 92 github.com/spf13/pflag v1.0.5 // indirect
88 github.com/spf13/viper v1.4.0 // indirect 93 github.com/spf13/viper v1.4.0 // indirect
  94 + github.com/tidwall/gjson v1.14.1 // indirect
  95 + github.com/tidwall/match v1.1.1 // indirect
  96 + github.com/tidwall/pretty v1.2.0 // indirect
89 github.com/ugorji/go/codec v1.1.7 // indirect 97 github.com/ugorji/go/codec v1.1.7 // indirect
90 go.opentelemetry.io/otel v1.14.0 // indirect 98 go.opentelemetry.io/otel v1.14.0 // indirect
91 go.opentelemetry.io/otel/exporters/jaeger v1.14.0 // indirect 99 go.opentelemetry.io/otel/exporters/jaeger v1.14.0 // indirect
@@ -100,6 +108,7 @@ require ( @@ -100,6 +108,7 @@ require (
100 go.opentelemetry.io/proto/otlp v0.19.0 // indirect 108 go.opentelemetry.io/proto/otlp v0.19.0 // indirect
101 go.uber.org/automaxprocs v1.5.3 // indirect 109 go.uber.org/automaxprocs v1.5.3 // indirect
102 golang.org/x/crypto v0.12.0 // indirect 110 golang.org/x/crypto v0.12.0 // indirect
  111 + golang.org/x/exp v0.0.0-20220303212507-bbda1eaf7a17 // indirect
103 golang.org/x/net v0.14.0 // indirect 112 golang.org/x/net v0.14.0 // indirect
104 golang.org/x/sys v0.11.0 // indirect 113 golang.org/x/sys v0.11.0 // indirect
105 golang.org/x/text v0.12.0 // indirect 114 golang.org/x/text v0.12.0 // indirect
@@ -9,8 +9,8 @@ import ( @@ -9,8 +9,8 @@ import (
9 ) 9 )
10 10
11 var ( 11 var (
12 - CtxKeyJwtUserId = "userId"  
13 - CtxKeyJwtCompanyId = "companyId" 12 + CtxKeyJwtUserId = "UserId"
  13 + CtxKeyJwtCompanyId = "CompanyId"
14 ) 14 )
15 15
16 func GetInt64FromCtx(ctx context.Context, key string) int64 { 16 func GetInt64FromCtx(ctx context.Context, key string) int64 {
@@ -58,8 +58,8 @@ func GetUserTokenFromCtx(ctx context.Context) UserToken { @@ -58,8 +58,8 @@ func GetUserTokenFromCtx(ctx context.Context) UserToken {
58 } 58 }
59 59
60 type UserToken struct { 60 type UserToken struct {
61 - UserId int64 `json:"userId"`  
62 - CompanyId int64 `json:"companyId"` 61 + UserId int64
  62 + CompanyId int64
63 } 63 }
64 64
65 func (tk UserToken) GenerateToken(secret string, expire int64) (string, error) { 65 func (tk UserToken) GenerateToken(secret string, expire int64) (string, error) {
@@ -21,13 +21,15 @@ func HttpResult(r *http.Request, w http.ResponseWriter, resp interface{}, err er @@ -21,13 +21,15 @@ func HttpResult(r *http.Request, w http.ResponseWriter, resp interface{}, err er
21 } 21 }
22 22
23 //错误返回 23 //错误返回
24 - errCode := xerr.ServerCommonError  
25 - errMsg := "服务器开小差啦,稍后再来试一试"  
26 - internalErr := ""  
27 - causeErr := errors.Cause(err) 24 + var (
  25 + errCode = xerr.ServerCommonError
  26 + errMsg = "服务器开小差啦,稍后再来试一试"
  27 + internalErr = ""
  28 + causeErr = errors.Cause(err)
  29 + )
28 30
29 - codeError := &xerr.CodeError{}  
30 - if ok := errors.As(causeErr, codeError); ok { // 自定义错误类型 31 + codeError, ok := causeErr.(*xerr.CodeError)
  32 + if ok { // 自定义错误类型
31 errCode = codeError.GetErrCode() 33 errCode = codeError.GetErrCode()
32 errMsg = codeError.GetErrMsg() 34 errMsg = codeError.GetErrMsg()
33 if codeError.InternalError != nil { 35 if codeError.InternalError != nil {