Merge remote-tracking branch 'origin/dev' into dev
# Conflicts: # cmd/discuss/api/dsl/core.json
正在显示
27 个修改的文件
包含
356 行增加
和
446 行删除
| @@ -15,119 +15,6 @@ | @@ -15,119 +15,6 @@ | ||
| 15 | "application/json" | 15 | "application/json" |
| 16 | ], | 16 | ], |
| 17 | "paths": { | 17 | "paths": { |
| 18 | - "v1/mini/article_tag": { | ||
| 19 | - "delete": { | ||
| 20 | - "summary": "后台删除文章标签", | ||
| 21 | - "operationId": "DeleteTag", | ||
| 22 | - "responses": { | ||
| 23 | - "200": { | ||
| 24 | - "description": "A successful response.", | ||
| 25 | - "schema": { | ||
| 26 | - "$ref": "#/definitions/TagDeleteResponse" | ||
| 27 | - } | ||
| 28 | - } | ||
| 29 | - }, | ||
| 30 | - "parameters": [ | ||
| 31 | - { | ||
| 32 | - "name": "body", | ||
| 33 | - "in": "body", | ||
| 34 | - "required": true, | ||
| 35 | - "schema": { | ||
| 36 | - "$ref": "#/definitions/TagDeleteRequest" | ||
| 37 | - } | ||
| 38 | - } | ||
| 39 | - ], | ||
| 40 | - "requestBody": {}, | ||
| 41 | - "tags": [ | ||
| 42 | - "tags" | ||
| 43 | - ] | ||
| 44 | - }, | ||
| 45 | - "post": { | ||
| 46 | - "summary": "后台创建文章标签", | ||
| 47 | - "operationId": "CreateTag", | ||
| 48 | - "responses": { | ||
| 49 | - "200": { | ||
| 50 | - "description": "A successful response.", | ||
| 51 | - "schema": { | ||
| 52 | - "$ref": "#/definitions/TagCreateResponse" | ||
| 53 | - } | ||
| 54 | - } | ||
| 55 | - }, | ||
| 56 | - "parameters": [ | ||
| 57 | - { | ||
| 58 | - "name": "body", | ||
| 59 | - "in": "body", | ||
| 60 | - "required": true, | ||
| 61 | - "schema": { | ||
| 62 | - "$ref": "#/definitions/TagCreateRequest" | ||
| 63 | - } | ||
| 64 | - } | ||
| 65 | - ], | ||
| 66 | - "requestBody": {}, | ||
| 67 | - "tags": [ | ||
| 68 | - "tags" | ||
| 69 | - ] | ||
| 70 | - }, | ||
| 71 | - "put": { | ||
| 72 | - "summary": "后台编辑文章标签", | ||
| 73 | - "operationId": "EditTag", | ||
| 74 | - "responses": { | ||
| 75 | - "200": { | ||
| 76 | - "description": "A successful response.", | ||
| 77 | - "schema": { | ||
| 78 | - "$ref": "#/definitions/TagEditResponse" | ||
| 79 | - } | ||
| 80 | - } | ||
| 81 | - }, | ||
| 82 | - "parameters": [ | ||
| 83 | - { | ||
| 84 | - "name": "body", | ||
| 85 | - "in": "body", | ||
| 86 | - "required": true, | ||
| 87 | - "schema": { | ||
| 88 | - "$ref": "#/definitions/TagEditRequest" | ||
| 89 | - } | ||
| 90 | - } | ||
| 91 | - ], | ||
| 92 | - "requestBody": {}, | ||
| 93 | - "tags": [ | ||
| 94 | - "tags" | ||
| 95 | - ] | ||
| 96 | - } | ||
| 97 | - }, | ||
| 98 | - "v1/mini/article_tag/{id}": { | ||
| 99 | - "get": { | ||
| 100 | - "summary": "后台获取文章标签", | ||
| 101 | - "operationId": "GetTag", | ||
| 102 | - "responses": { | ||
| 103 | - "200": { | ||
| 104 | - "description": "A successful response.", | ||
| 105 | - "schema": { | ||
| 106 | - "$ref": "#/definitions/TagGetResponse" | ||
| 107 | - } | ||
| 108 | - } | ||
| 109 | - }, | ||
| 110 | - "parameters": [ | ||
| 111 | - { | ||
| 112 | - "name": "id", | ||
| 113 | - "in": "path", | ||
| 114 | - "required": true, | ||
| 115 | - "type": "string" | ||
| 116 | - }, | ||
| 117 | - { | ||
| 118 | - "name": "id", | ||
| 119 | - "in": "query", | ||
| 120 | - "required": true, | ||
| 121 | - "type": "integer", | ||
| 122 | - "format": "int64" | ||
| 123 | - } | ||
| 124 | - ], | ||
| 125 | - "requestBody": {}, | ||
| 126 | - "tags": [ | ||
| 127 | - "tags" | ||
| 128 | - ] | ||
| 129 | - } | ||
| 130 | - }, | ||
| 131 | "v1/mini/comment": { | 18 | "v1/mini/comment": { |
| 132 | "get": { | 19 | "get": { |
| 133 | "summary": "小程序评论", | 20 | "summary": "小程序评论", |
| @@ -210,7 +97,7 @@ | @@ -210,7 +97,7 @@ | ||
| 210 | "200": { | 97 | "200": { |
| 211 | "description": "A successful response.", | 98 | "description": "A successful response.", |
| 212 | "schema": { | 99 | "schema": { |
| 213 | - "$ref": "#/definitions/MessageSystemResponse" | 100 | + "$ref": "#/definitions/MessageBusinessResponse" |
| 214 | } | 101 | } |
| 215 | } | 102 | } |
| 216 | }, | 103 | }, |
| @@ -836,11 +723,6 @@ | @@ -836,11 +723,6 @@ | ||
| 836 | "content": { | 723 | "content": { |
| 837 | "type": "string", | 724 | "type": "string", |
| 838 | "description": " 内容" | 725 | "description": " 内容" |
| 839 | - }, | ||
| 840 | - "createdAt": { | ||
| 841 | - "type": "integer", | ||
| 842 | - "format": "int64", | ||
| 843 | - "description": " 创建时间" | ||
| 844 | } | 726 | } |
| 845 | }, | 727 | }, |
| 846 | "title": "MessageSystemItem", | 728 | "title": "MessageSystemItem", |
| @@ -848,8 +730,7 @@ | @@ -848,8 +730,7 @@ | ||
| 848 | "id", | 730 | "id", |
| 849 | "type", | 731 | "type", |
| 850 | "title", | 732 | "title", |
| 851 | - "content", | ||
| 852 | - "createdAt" | 733 | + "content" |
| 853 | ] | 734 | ] |
| 854 | }, | 735 | }, |
| 855 | "MessageSystemRequest": { | 736 | "MessageSystemRequest": { |
| @@ -917,11 +798,17 @@ | @@ -917,11 +798,17 @@ | ||
| 917 | "type": "integer", | 798 | "type": "integer", |
| 918 | "format": "int64", | 799 | "format": "int64", |
| 919 | "description": " 用户ID" | 800 | "description": " 用户ID" |
| 801 | + }, | ||
| 802 | + "status": { | ||
| 803 | + "type": "integer", | ||
| 804 | + "format": "int32", | ||
| 805 | + "description": " 审核状态 1:审核通过 2:拒绝" | ||
| 920 | } | 806 | } |
| 921 | }, | 807 | }, |
| 922 | "title": "MiniUserAuditRequest", | 808 | "title": "MiniUserAuditRequest", |
| 923 | "required": [ | 809 | "required": [ |
| 924 | - "userId" | 810 | + "userId", |
| 811 | + "status" | ||
| 925 | ] | 812 | ] |
| 926 | }, | 813 | }, |
| 927 | "MiniUserDepartmentUsersRequest": { | 814 | "MiniUserDepartmentUsersRequest": { |
| @@ -1051,247 +938,6 @@ | @@ -1051,247 +938,6 @@ | ||
| 1051 | "success" | 938 | "success" |
| 1052 | ] | 939 | ] |
| 1053 | }, | 940 | }, |
| 1054 | - "TagCreateRequest": { | ||
| 1055 | - "type": "object", | ||
| 1056 | - "properties": { | ||
| 1057 | - "companyId": { | ||
| 1058 | - "type": "integer", | ||
| 1059 | - "format": "int64" | ||
| 1060 | - }, | ||
| 1061 | - "image": { | ||
| 1062 | - "type": "string" | ||
| 1063 | - }, | ||
| 1064 | - "name": { | ||
| 1065 | - "type": "string", | ||
| 1066 | - "description": " 标签名称" | ||
| 1067 | - }, | ||
| 1068 | - "group": { | ||
| 1069 | - "type": "string", | ||
| 1070 | - "description": " 标签分类" | ||
| 1071 | - }, | ||
| 1072 | - "remark": { | ||
| 1073 | - "type": "string", | ||
| 1074 | - "description": " 备注" | ||
| 1075 | - } | ||
| 1076 | - }, | ||
| 1077 | - "title": "TagCreateRequest", | ||
| 1078 | - "required": [ | ||
| 1079 | - "companyId", | ||
| 1080 | - "image", | ||
| 1081 | - "name", | ||
| 1082 | - "group", | ||
| 1083 | - "remark" | ||
| 1084 | - ] | ||
| 1085 | - }, | ||
| 1086 | - "TagCreateResponse": { | ||
| 1087 | - "type": "object", | ||
| 1088 | - "properties": { | ||
| 1089 | - "id": { | ||
| 1090 | - "type": "integer", | ||
| 1091 | - "format": "int64" | ||
| 1092 | - } | ||
| 1093 | - }, | ||
| 1094 | - "title": "TagCreateResponse", | ||
| 1095 | - "required": [ | ||
| 1096 | - "id" | ||
| 1097 | - ] | ||
| 1098 | - }, | ||
| 1099 | - "TagDeleteRequest": { | ||
| 1100 | - "type": "object", | ||
| 1101 | - "properties": { | ||
| 1102 | - "id": { | ||
| 1103 | - "type": "integer", | ||
| 1104 | - "format": "int64" | ||
| 1105 | - } | ||
| 1106 | - }, | ||
| 1107 | - "title": "TagDeleteRequest", | ||
| 1108 | - "required": [ | ||
| 1109 | - "id" | ||
| 1110 | - ] | ||
| 1111 | - }, | ||
| 1112 | - "TagDeleteResponse": { | ||
| 1113 | - "type": "object", | ||
| 1114 | - "properties": { | ||
| 1115 | - "id": { | ||
| 1116 | - "type": "integer", | ||
| 1117 | - "format": "int64" | ||
| 1118 | - } | ||
| 1119 | - }, | ||
| 1120 | - "title": "TagDeleteResponse", | ||
| 1121 | - "required": [ | ||
| 1122 | - "id" | ||
| 1123 | - ] | ||
| 1124 | - }, | ||
| 1125 | - "TagEditRequest": { | ||
| 1126 | - "type": "object", | ||
| 1127 | - "properties": { | ||
| 1128 | - "id": { | ||
| 1129 | - "type": "integer", | ||
| 1130 | - "format": "int64" | ||
| 1131 | - }, | ||
| 1132 | - "companyId": { | ||
| 1133 | - "type": "integer", | ||
| 1134 | - "format": "int64" | ||
| 1135 | - }, | ||
| 1136 | - "image": { | ||
| 1137 | - "type": "string" | ||
| 1138 | - }, | ||
| 1139 | - "name": { | ||
| 1140 | - "type": "string", | ||
| 1141 | - "description": " 标签名称" | ||
| 1142 | - }, | ||
| 1143 | - "group": { | ||
| 1144 | - "type": "string", | ||
| 1145 | - "description": " 标签分类" | ||
| 1146 | - }, | ||
| 1147 | - "remark": { | ||
| 1148 | - "type": "string", | ||
| 1149 | - "description": " 备注" | ||
| 1150 | - } | ||
| 1151 | - }, | ||
| 1152 | - "title": "TagEditRequest", | ||
| 1153 | - "required": [ | ||
| 1154 | - "id", | ||
| 1155 | - "companyId", | ||
| 1156 | - "image", | ||
| 1157 | - "name", | ||
| 1158 | - "group", | ||
| 1159 | - "remark" | ||
| 1160 | - ] | ||
| 1161 | - }, | ||
| 1162 | - "TagEditResponse": { | ||
| 1163 | - "type": "object", | ||
| 1164 | - "properties": { | ||
| 1165 | - "id": { | ||
| 1166 | - "type": "integer", | ||
| 1167 | - "format": "int64" | ||
| 1168 | - } | ||
| 1169 | - }, | ||
| 1170 | - "title": "TagEditResponse", | ||
| 1171 | - "required": [ | ||
| 1172 | - "id" | ||
| 1173 | - ] | ||
| 1174 | - }, | ||
| 1175 | - "TagGetRequest": { | ||
| 1176 | - "type": "object", | ||
| 1177 | - "properties": { | ||
| 1178 | - "id": { | ||
| 1179 | - "type": "integer", | ||
| 1180 | - "format": "int64" | ||
| 1181 | - } | ||
| 1182 | - }, | ||
| 1183 | - "title": "TagGetRequest", | ||
| 1184 | - "required": [ | ||
| 1185 | - "id" | ||
| 1186 | - ] | ||
| 1187 | - }, | ||
| 1188 | - "TagGetResponse": { | ||
| 1189 | - "type": "object", | ||
| 1190 | - "properties": { | ||
| 1191 | - "id": { | ||
| 1192 | - "type": "integer", | ||
| 1193 | - "format": "int64" | ||
| 1194 | - }, | ||
| 1195 | - "image": { | ||
| 1196 | - "type": "string" | ||
| 1197 | - }, | ||
| 1198 | - "name": { | ||
| 1199 | - "type": "string", | ||
| 1200 | - "description": " 标签名称" | ||
| 1201 | - }, | ||
| 1202 | - "group": { | ||
| 1203 | - "type": "string", | ||
| 1204 | - "description": " 标签分类" | ||
| 1205 | - }, | ||
| 1206 | - "remark": { | ||
| 1207 | - "type": "string", | ||
| 1208 | - "description": " 备注" | ||
| 1209 | - } | ||
| 1210 | - }, | ||
| 1211 | - "title": "TagGetResponse", | ||
| 1212 | - "required": [ | ||
| 1213 | - "id", | ||
| 1214 | - "image", | ||
| 1215 | - "name", | ||
| 1216 | - "group", | ||
| 1217 | - "remark" | ||
| 1218 | - ] | ||
| 1219 | - }, | ||
| 1220 | - "TagItem": { | ||
| 1221 | - "type": "object", | ||
| 1222 | - "properties": { | ||
| 1223 | - "id": { | ||
| 1224 | - "type": "integer", | ||
| 1225 | - "format": "int64" | ||
| 1226 | - }, | ||
| 1227 | - "image": { | ||
| 1228 | - "type": "string" | ||
| 1229 | - }, | ||
| 1230 | - "name": { | ||
| 1231 | - "type": "string", | ||
| 1232 | - "description": " 标签名称" | ||
| 1233 | - }, | ||
| 1234 | - "group": { | ||
| 1235 | - "type": "string", | ||
| 1236 | - "description": " 标签分类" | ||
| 1237 | - }, | ||
| 1238 | - "remark": { | ||
| 1239 | - "type": "string", | ||
| 1240 | - "description": " 备注" | ||
| 1241 | - }, | ||
| 1242 | - "createdAt": { | ||
| 1243 | - "type": "integer", | ||
| 1244 | - "format": "int64" | ||
| 1245 | - } | ||
| 1246 | - }, | ||
| 1247 | - "title": "TagItem", | ||
| 1248 | - "required": [ | ||
| 1249 | - "id", | ||
| 1250 | - "image", | ||
| 1251 | - "name", | ||
| 1252 | - "group", | ||
| 1253 | - "remark", | ||
| 1254 | - "createdAt" | ||
| 1255 | - ] | ||
| 1256 | - }, | ||
| 1257 | - "TagListRequest": { | ||
| 1258 | - "type": "object", | ||
| 1259 | - "properties": { | ||
| 1260 | - "page": { | ||
| 1261 | - "type": "integer", | ||
| 1262 | - "format": "int32" | ||
| 1263 | - }, | ||
| 1264 | - "size": { | ||
| 1265 | - "type": "integer", | ||
| 1266 | - "format": "int32" | ||
| 1267 | - } | ||
| 1268 | - }, | ||
| 1269 | - "title": "TagListRequest", | ||
| 1270 | - "required": [ | ||
| 1271 | - "page", | ||
| 1272 | - "size" | ||
| 1273 | - ] | ||
| 1274 | - }, | ||
| 1275 | - "TagListResponse": { | ||
| 1276 | - "type": "object", | ||
| 1277 | - "properties": { | ||
| 1278 | - "total": { | ||
| 1279 | - "type": "integer", | ||
| 1280 | - "format": "int32" | ||
| 1281 | - }, | ||
| 1282 | - "list": { | ||
| 1283 | - "type": "array", | ||
| 1284 | - "items": { | ||
| 1285 | - "$ref": "#/definitions/TagItem" | ||
| 1286 | - } | ||
| 1287 | - } | ||
| 1288 | - }, | ||
| 1289 | - "title": "TagListResponse", | ||
| 1290 | - "required": [ | ||
| 1291 | - "total", | ||
| 1292 | - "list" | ||
| 1293 | - ] | ||
| 1294 | - }, | ||
| 1295 | "User": { | 941 | "User": { |
| 1296 | "type": "object", | 942 | "type": "object", |
| 1297 | "properties": { | 943 | "properties": { |
| @@ -1335,6 +981,11 @@ | @@ -1335,6 +981,11 @@ | ||
| 1335 | "UserItem": { | 981 | "UserItem": { |
| 1336 | "type": "object", | 982 | "type": "object", |
| 1337 | "properties": { | 983 | "properties": { |
| 984 | + "id": { | ||
| 985 | + "type": "integer", | ||
| 986 | + "format": "int64", | ||
| 987 | + "description": " 用户ID" | ||
| 988 | + }, | ||
| 1338 | "companyId": { | 989 | "companyId": { |
| 1339 | "type": "integer", | 990 | "type": "integer", |
| 1340 | "format": "int64", | 991 | "format": "int64", |
| @@ -1403,6 +1054,7 @@ | @@ -1403,6 +1054,7 @@ | ||
| 1403 | }, | 1054 | }, |
| 1404 | "title": "UserItem", | 1055 | "title": "UserItem", |
| 1405 | "required": [ | 1056 | "required": [ |
| 1057 | + "id", | ||
| 1406 | "companyId", | 1058 | "companyId", |
| 1407 | "departmentId", | 1059 | "departmentId", |
| 1408 | "roleId", | 1060 | "roleId", |
| @@ -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 { | ||
| 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 | + } | ||
| 29 | return | 70 | return |
| 30 | } | 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 | ||
| 136 | +} |
| @@ -165,6 +165,7 @@ type MiniUserApplyJoinCompanyResponse struct { | @@ -165,6 +165,7 @@ type MiniUserApplyJoinCompanyResponse struct { | ||
| 165 | 165 | ||
| 166 | type MiniUserAuditRequest struct { | 166 | type MiniUserAuditRequest struct { |
| 167 | UserId int64 `json:"userId"` // 用户ID | 167 | UserId int64 `json:"userId"` // 用户ID |
| 168 | + Status int `json:"status"` // 审核状态 1:审核通过 2:拒绝 | ||
| 168 | } | 169 | } |
| 169 | 170 | ||
| 170 | type MiniUserDepartmentUsersRequest struct { | 171 | type MiniUserDepartmentUsersRequest struct { |
| @@ -176,6 +177,7 @@ type MiniUserDepartmentUsersResponse struct { | @@ -176,6 +177,7 @@ type MiniUserDepartmentUsersResponse struct { | ||
| 176 | } | 177 | } |
| 177 | 178 | ||
| 178 | type UserItem struct { | 179 | type UserItem struct { |
| 180 | + Id int64 `json:"id,omitempty"` // 用户ID | ||
| 179 | CompanyId int64 `json:"companyId,omitempty"` // 公司ID | 181 | CompanyId int64 `json:"companyId,omitempty"` // 公司ID |
| 180 | DepartmentId int64 `json:"departmentId,omitempty"` // 部门ID | 182 | DepartmentId int64 `json:"departmentId,omitempty"` // 部门ID |
| 181 | Roles []int64 `json:"roleId,omitempty"` // 角色 | 183 | 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 { |
-
请 注册 或 登录 后发表评论