Merge branch 'dev' of http://gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway into dev
正在显示
6 个修改的文件
包含
283 行增加
和
132 行删除
@@ -12,7 +12,7 @@ type CompanySignUpCommand struct { | @@ -12,7 +12,7 @@ type CompanySignUpCommand struct { | ||
12 | // 企业名称 | 12 | // 企业名称 |
13 | CompanyName string `cname:"企业名称" json:"companyName" valid:"Required"` | 13 | CompanyName string `cname:"企业名称" json:"companyName" valid:"Required"` |
14 | // 联系人 | 14 | // 联系人 |
15 | - Contacts string `cname:"联系人" json:"contacts" valid:"Required"` | 15 | + Contacts string `cname:"联系人" json:"userName" valid:"Required"` |
16 | // 手机号码 | 16 | // 手机号码 |
17 | Phone string `cname:"手机号码" json:"phone" valid:"Required"` | 17 | Phone string `cname:"手机号码" json:"phone" valid:"Required"` |
18 | // 规模 | 18 | // 规模 |
1 | +package command | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + "github.com/beego/beego/v2/core/validation" | ||
6 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain" | ||
7 | +) | ||
8 | + | ||
9 | +type SwitchOrgCommand struct { | ||
10 | + //操作人 | ||
11 | + Operator domain.Operator `json:"-"` | ||
12 | + // 组织ID | ||
13 | + OrgId int64 `json:"orgId"` | ||
14 | +} | ||
15 | + | ||
16 | +func (switchOrgCommand *SwitchOrgCommand) Valid(validation *validation.Validation) { | ||
17 | + | ||
18 | +} | ||
19 | + | ||
20 | +func (switchOrgCommand *SwitchOrgCommand) ValidateCommand() error { | ||
21 | + valid := validation.Validation{} | ||
22 | + b, err := valid.Valid(switchOrgCommand) | ||
23 | + if err != nil { | ||
24 | + return err | ||
25 | + } | ||
26 | + if !b { | ||
27 | + for _, validErr := range valid.Errors { | ||
28 | + return fmt.Errorf("%s %s", validErr.Key, validErr.Message) | ||
29 | + } | ||
30 | + } | ||
31 | + return nil | ||
32 | +} |
@@ -238,10 +238,250 @@ func (srv AuthService) RefreshAuthAccessToken(refreshTokenCommand *command.Refre | @@ -238,10 +238,250 @@ func (srv AuthService) RefreshAuthAccessToken(refreshTokenCommand *command.Refre | ||
238 | if err != nil { | 238 | if err != nil { |
239 | return nil, application.ThrowError(application.TRANSACTION_ERROR, "refreshToken 不可用,"+err.Error()) | 239 | return nil, application.ThrowError(application.TRANSACTION_ERROR, "refreshToken 不可用,"+err.Error()) |
240 | } | 240 | } |
241 | - phone := ltoken.Account | 241 | + token, err := srv.getToken(domain.Operator{}, ltoken) |
242 | + // phone := ltoken.Account | ||
243 | + // creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(domain.Operator{}) | ||
244 | + // userSearchResult, err := creationUserGateway.UserSearch(allied_creation_user.ReqUserSearch{ | ||
245 | + // Phone: phone, | ||
246 | + // }) | ||
247 | + // if err != nil { | ||
248 | + // return nil, application.ThrowError(application.TRANSACTION_ERROR, "用户信息获取失败,"+err.Error()) | ||
249 | + // } | ||
250 | + // //判定当前凭证的companyId,OrganizationId 是否在用户列表中 | ||
251 | + // var currentOrgIsOK bool | ||
252 | + //loopUser1: | ||
253 | + // for _, v := range userSearchResult.Users { | ||
254 | + // if v.Company.CompanyId == int(ltoken.CompanyId) { | ||
255 | + // for _, vv := range v.UserOrg { | ||
256 | + // if vv.OrgID == int(ltoken.OrgId) { | ||
257 | + // currentOrgIsOK = true | ||
258 | + // break loopUser1 | ||
259 | + // } | ||
260 | + // } | ||
261 | + // } | ||
262 | + // } | ||
263 | + // if !currentOrgIsOK { | ||
264 | + // return nil, application.ThrowError(application.TRANSACTION_ERROR, "登录的公司组织不可用") | ||
265 | + // } | ||
266 | + // | ||
267 | + // transactionContext, err := factory.CreateTransactionContext(nil) | ||
268 | + // if err != nil { | ||
269 | + // return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
270 | + // } | ||
271 | + // if err := transactionContext.StartTransaction(); err != nil { | ||
272 | + // return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
273 | + // } | ||
274 | + // defer func() { | ||
275 | + // transactionContext.RollbackTransaction() | ||
276 | + // }() | ||
277 | + // var loginAccessRepository domain.LoginAccessRepository | ||
278 | + // if loginAccessRepository, err = factory.CreateLoginAccessRepository(map[string]interface{}{ | ||
279 | + // "transactionContext": transactionContext, | ||
280 | + // }); err != nil { | ||
281 | + // return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
282 | + // } | ||
283 | + // _, lAccess, err := loginAccessRepository.Find(map[string]interface{}{ | ||
284 | + // "account": phone, | ||
285 | + // "platform": domain.LoginPlatformApp, | ||
286 | + // }) | ||
287 | + // if err != nil { | ||
288 | + // return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
289 | + // } | ||
290 | + // var currentAccess *domain.LoginAccess | ||
291 | + // if len(lAccess) > 0 { | ||
292 | + // currentAccess = lAccess[0] | ||
293 | + // currentAccess.UpdatedTime = time.Now() | ||
294 | + // } else { | ||
295 | + // currentAccess = &domain.LoginAccess{ | ||
296 | + // UserBaseId: ltoken.UserBaseId, | ||
297 | + // UserId: ltoken.UserId, | ||
298 | + // Account: ltoken.Account, | ||
299 | + // Platform: domain.LoginPlatformApp, | ||
300 | + // CompanyId: ltoken.CompanyId, | ||
301 | + // OrganizationId: ltoken.OrgId, | ||
302 | + // AccessToken: "", | ||
303 | + // RefreshToken: "", | ||
304 | + // AccessExpired: 0, | ||
305 | + // RefreshExpired: 0, | ||
306 | + // CreatedTime: time.Now(), | ||
307 | + // UpdatedTime: time.Now(), | ||
308 | + // } | ||
309 | + // } | ||
310 | + // accessTokenStr, err := ltoken.GenerateAccessToken() | ||
311 | + // if err != nil { | ||
312 | + // return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
313 | + // } | ||
314 | + // currentAccess.AccessToken = accessTokenStr | ||
315 | + // currentAccess.AccessExpired = ltoken.ExpiresAt | ||
316 | + // refreshTokenStr, err := ltoken.GenerateRefreshToken() | ||
317 | + // if err != nil { | ||
318 | + // return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
319 | + // } | ||
320 | + // currentAccess.RefreshToken = refreshTokenStr | ||
321 | + // currentAccess.RefreshExpired = ltoken.ExpiresAt | ||
322 | + // //先存数据库 | ||
323 | + // _, err = loginAccessRepository.Save(currentAccess) | ||
324 | + // if err != nil { | ||
325 | + // return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
326 | + // } | ||
327 | + // if err := transactionContext.CommitTransaction(); err != nil { | ||
328 | + // return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
329 | + // } | ||
330 | + // //后处理redis缓存 | ||
331 | + // tokenCache := cache.LoginTokenCache{} | ||
332 | + // tokenCache.RemoveAccessToken(currentAccess.Account, domain.LoginPlatformApp) | ||
333 | + // tokenCache.RemoveRefreshToken(currentAccess.Account, domain.LoginPlatformApp) | ||
334 | + // tokenCache.SaveAccessToken(currentAccess) | ||
335 | + // tokenCache.SaveRefreshToken(currentAccess) | ||
336 | + // nowTime := time.Now().Unix() | ||
337 | + // return map[string]interface{}{ | ||
338 | + // "refreshToken": accessTokenStr, | ||
339 | + // "accessToken": refreshTokenStr, | ||
340 | + // "expiresIn": currentAccess.AccessExpired - nowTime, | ||
341 | + // }, nil | ||
342 | + return token, err | ||
343 | +} | ||
344 | + | ||
345 | +//GetUserMenus 获取用户信息 | ||
346 | +func (srv AuthService) GetUserInfo(userInfoCommand *command.UserInfoCommand) (interface{}, error) { | ||
347 | + user, err := srv.getUserInfo(userInfoCommand.Operator) | ||
348 | + if err != nil { | ||
349 | + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) | ||
350 | + } | ||
351 | + return map[string]interface{}{ | ||
352 | + "user": user, | ||
353 | + }, nil | ||
354 | +} | ||
355 | + | ||
356 | +//GetUserMenus 获取用户菜单 | ||
357 | +func (srv AuthService) GetUserMenus(userMenusCommand *command.UserMenusCommand) (interface{}, error) { | ||
358 | + creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser( | ||
359 | + userMenusCommand.Operator) | ||
360 | + resultMenu, err := creationUserGateway.UserAccessMenus(allied_creation_user.ReqUserAccessMenus{ | ||
361 | + UserId: int(userMenusCommand.Operator.UserId), | ||
362 | + }) | ||
363 | + if err != nil { | ||
364 | + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) | ||
365 | + } | ||
366 | + return map[string]interface{}{ | ||
367 | + "accessMenus": resultMenu.Menus, | ||
368 | + }, nil | ||
369 | +} | ||
370 | + | ||
371 | +//GetUserMenus 获取用户组织 | ||
372 | +func (srv AuthService) GetUserOrg(userOrgCommand *command.UserOrgCommand) (interface{}, error) { | ||
373 | + creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(userOrgCommand.Operator) | ||
374 | + result, err := creationUserGateway.UserSearch(allied_creation_user.ReqUserSearch{ | ||
375 | + Offset: 0, | ||
376 | + Limit: 100, | ||
377 | + UserBaseId: userOrgCommand.Operator.UserBaseId, | ||
378 | + UserType: domain.UserTypeEmployee, | ||
379 | + EnableStatus: domain.UserStatusEnable, | ||
380 | + PullRealTime: true, | ||
381 | + }) | ||
382 | + if err != nil { | ||
383 | + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) | ||
384 | + } | ||
385 | + var res = make([]interface{}, 0) | ||
386 | + for i := range result.Users { | ||
387 | + for j := range result.Users[i].UserOrg { | ||
388 | + org := result.Users[i].UserOrg[j] | ||
389 | + res = append(res, map[string]interface{}{ | ||
390 | + "orgId": org.OrgID, | ||
391 | + "orgName": org.OrgName, | ||
392 | + }) | ||
393 | + } | ||
394 | + } | ||
395 | + return res, nil | ||
396 | +} | ||
397 | + | ||
398 | +//OrgSwitch 组织切换 | ||
399 | +func (srv AuthService) OrgSwitch(switchOrgCommand *command.SwitchOrgCommand) (interface{}, error) { | ||
400 | + | ||
401 | + return nil, nil | ||
402 | +} | ||
403 | + | ||
404 | +// CompanySignUp 企业注册 | ||
405 | +func (srv AuthService) CompanySignUp(companySignUpCommand *command.CompanySignUpCommand) (interface{}, error) { | ||
406 | + //TODO:验证码验证测试去掉,后期恢复回来 | ||
407 | + //smsServeGateway := sms_serve.NewHttplibHttplibSmsServe() | ||
408 | + //err := smsServeGateway.CheckSmsCode(companySignUpCommand.Phone, companySignUpCommand.SmsCode) | ||
409 | + //if err != nil { | ||
410 | + // return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) | ||
411 | + //} | ||
242 | creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(domain.Operator{}) | 412 | creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(domain.Operator{}) |
243 | - userSeachResult, err := creationUserGateway.UserSearch(allied_creation_user.ReqUserSearch{ | ||
244 | - Phone: phone, | 413 | + result, err := creationUserGateway.AuthCompanySignUp(allied_creation_user.ReqAuthCompanySignUp{ |
414 | + CompanyName: companySignUpCommand.CompanyName, | ||
415 | + Phone: companySignUpCommand.Phone, | ||
416 | + Password: companySignUpCommand.Password, | ||
417 | + Contacts: companySignUpCommand.Contacts, | ||
418 | + IndustryCategory: companySignUpCommand.IndustryCategory, | ||
419 | + Scale: companySignUpCommand.Scale, | ||
420 | + }) | ||
421 | + if err != nil { | ||
422 | + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) | ||
423 | + } | ||
424 | + return result, err | ||
425 | +} | ||
426 | + | ||
427 | +// ResetPassword 重置密码(找回密码) | ||
428 | +func (srv AuthService) ResetPassword(resetPasswordCommand *command.ResetPasswordCommand) (interface{}, error) { | ||
429 | + if err := resetPasswordCommand.ValidateCommand(); err != nil { | ||
430 | + return nil, application.ThrowError(application.ARG_ERROR, err.Error()) | ||
431 | + } | ||
432 | + //var phone string | ||
433 | + pcc := cache.PhoneCheckCache{} | ||
434 | + var item = &cache.PhoneCheckItem{} | ||
435 | + if err := pcc.Get(resetPasswordCommand.SmsCodeIdentity, item); err != nil { | ||
436 | + log.Logger.Error(err.Error()) | ||
437 | + return nil, application.ThrowError(application.BUSINESS_ERROR, "验证码已失效") | ||
438 | + } | ||
439 | + // 2.重置密码 | ||
440 | + creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(domain.Operator{}) | ||
441 | + result, err := creationUserGateway.AuthResetPassword(allied_creation_user.ReqAuthResetPassword{ | ||
442 | + Phone: item.Phone, | ||
443 | + Password: resetPasswordCommand.Password, | ||
444 | + }) | ||
445 | + if err != nil { | ||
446 | + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) | ||
447 | + } | ||
448 | + return result, err | ||
449 | +} | ||
450 | + | ||
451 | +func (srv AuthService) getUserInfo(operator domain.Operator) (interface{}, error) { | ||
452 | + creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser( | ||
453 | + operator) | ||
454 | + resultUser, err := creationUserGateway.UserGet(allied_creation_user.ReqGetUser{ | ||
455 | + UserId: int(operator.UserId), | ||
456 | + }) | ||
457 | + if err != nil { | ||
458 | + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) | ||
459 | + } | ||
460 | + var user = map[string]interface{}{ | ||
461 | + "userId": resultUser.UserId, | ||
462 | + "userInfo": map[string]interface{}{ | ||
463 | + "userName": resultUser.UserInfo.UserName, | ||
464 | + "userPhone": resultUser.UserInfo.Phone, | ||
465 | + "userAvatar": resultUser.UserInfo.Avatar, | ||
466 | + //"userCode": resultUser.UserInfo.UserCode, | ||
467 | + "email": resultUser.UserInfo.Email, | ||
468 | + }, | ||
469 | + "department": resultUser.Department, | ||
470 | + "company": map[string]interface{}{ | ||
471 | + "companyId": resultUser.Company.CompanyId, | ||
472 | + "companyName": resultUser.Company.CompanyName, | ||
473 | + "logo": resultUser.Company.Log, | ||
474 | + }, | ||
475 | + "im": resultUser.IM, | ||
476 | + "org": resultUser.Org, | ||
477 | + } | ||
478 | + return user, nil | ||
479 | +} | ||
480 | + | ||
481 | +func (srv AuthService) getToken(operator domain.Operator, ltoken domain.LoginToken) (interface{}, error) { | ||
482 | + creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(domain.Operator{}) | ||
483 | + userSearchResult, err := creationUserGateway.UserSearch(allied_creation_user.ReqUserSearch{ | ||
484 | + Phone: ltoken.Account, | ||
245 | }) | 485 | }) |
246 | if err != nil { | 486 | if err != nil { |
247 | return nil, application.ThrowError(application.TRANSACTION_ERROR, "用户信息获取失败,"+err.Error()) | 487 | return nil, application.ThrowError(application.TRANSACTION_ERROR, "用户信息获取失败,"+err.Error()) |
@@ -249,10 +489,10 @@ func (srv AuthService) RefreshAuthAccessToken(refreshTokenCommand *command.Refre | @@ -249,10 +489,10 @@ func (srv AuthService) RefreshAuthAccessToken(refreshTokenCommand *command.Refre | ||
249 | //判定当前凭证的companyId,OrganizationId 是否在用户列表中 | 489 | //判定当前凭证的companyId,OrganizationId 是否在用户列表中 |
250 | var currentOrgIsOK bool | 490 | var currentOrgIsOK bool |
251 | loopUser1: | 491 | loopUser1: |
252 | - for _, v := range userSeachResult.Users { | 492 | + for _, v := range userSearchResult.Users { |
253 | if v.Company.CompanyId == int(ltoken.CompanyId) { | 493 | if v.Company.CompanyId == int(ltoken.CompanyId) { |
254 | for _, vv := range v.UserOrg { | 494 | for _, vv := range v.UserOrg { |
255 | - if vv.OrgID == int(ltoken.OrgId) { | 495 | + if vv.OrgID == int(ltoken.OrgId) || vv.OrgID == int(operator.OrgId) { |
256 | currentOrgIsOK = true | 496 | currentOrgIsOK = true |
257 | break loopUser1 | 497 | break loopUser1 |
258 | } | 498 | } |
@@ -280,7 +520,7 @@ loopUser1: | @@ -280,7 +520,7 @@ loopUser1: | ||
280 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 520 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
281 | } | 521 | } |
282 | _, lAccess, err := loginAccessRepository.Find(map[string]interface{}{ | 522 | _, lAccess, err := loginAccessRepository.Find(map[string]interface{}{ |
283 | - "account": phone, | 523 | + "account": ltoken.Account, |
284 | "platform": domain.LoginPlatformApp, | 524 | "platform": domain.LoginPlatformApp, |
285 | }) | 525 | }) |
286 | if err != nil { | 526 | if err != nil { |
@@ -339,125 +579,3 @@ loopUser1: | @@ -339,125 +579,3 @@ loopUser1: | ||
339 | "expiresIn": currentAccess.AccessExpired - nowTime, | 579 | "expiresIn": currentAccess.AccessExpired - nowTime, |
340 | }, nil | 580 | }, nil |
341 | } | 581 | } |
342 | - | ||
343 | -//GetUserMenus 获取用户信息 | ||
344 | -func (srv AuthService) GetUserInfo(userInfoCommand *command.UserInfoCommand) (interface{}, error) { | ||
345 | - creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser( | ||
346 | - userInfoCommand.Operator) | ||
347 | - resultUser, err := creationUserGateway.UserGet(allied_creation_user.ReqGetUser{ | ||
348 | - UserId: int(userInfoCommand.Operator.UserId), | ||
349 | - }) | ||
350 | - if err != nil { | ||
351 | - return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) | ||
352 | - } | ||
353 | - var user = map[string]interface{}{ | ||
354 | - "userId": resultUser.UserId, | ||
355 | - "userInfo": map[string]interface{}{ | ||
356 | - "userName": resultUser.UserInfo.UserName, | ||
357 | - "userPhone": resultUser.UserInfo.Phone, | ||
358 | - "userAvatar": resultUser.UserInfo.Avatar, | ||
359 | - //"userCode": resultUser.UserInfo.UserCode, | ||
360 | - "email": resultUser.UserInfo.Email, | ||
361 | - }, | ||
362 | - "department": resultUser.Department, | ||
363 | - "company": map[string]interface{}{ | ||
364 | - "companyId": resultUser.Company.CompanyId, | ||
365 | - "companyName": resultUser.Company.CompanyName, | ||
366 | - "logo": resultUser.Company.Log, | ||
367 | - }, | ||
368 | - "im": resultUser.IM, | ||
369 | - "org": resultUser.Org, | ||
370 | - } | ||
371 | - | ||
372 | - return map[string]interface{}{ | ||
373 | - "user": user, | ||
374 | - }, nil | ||
375 | -} | ||
376 | - | ||
377 | -//GetUserMenus 获取用户菜单 | ||
378 | -func (srv AuthService) GetUserMenus(userMenusCommand *command.UserMenusCommand) (interface{}, error) { | ||
379 | - creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser( | ||
380 | - userMenusCommand.Operator) | ||
381 | - resultMenu, err := creationUserGateway.UserAccessMenus(allied_creation_user.ReqUserAccessMenus{ | ||
382 | - UserId: int(userMenusCommand.Operator.UserId), | ||
383 | - }) | ||
384 | - if err != nil { | ||
385 | - return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) | ||
386 | - } | ||
387 | - return map[string]interface{}{ | ||
388 | - "accessMenus": resultMenu.Menus, | ||
389 | - }, nil | ||
390 | -} | ||
391 | - | ||
392 | -//GetUserMenus 获取用户组织 | ||
393 | -func (srv AuthService) GetUserOrg(userOrgCommand *command.UserOrgCommand) (interface{}, error) { | ||
394 | - creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(userOrgCommand.Operator) | ||
395 | - result, err := creationUserGateway.UserSearch(allied_creation_user.ReqUserSearch{ | ||
396 | - Offset: 0, | ||
397 | - Limit: 100, | ||
398 | - UserBaseId: userOrgCommand.Operator.UserBaseId, | ||
399 | - UserType: domain.UserTypeEmployee, | ||
400 | - EnableStatus: domain.UserStatusEnable, | ||
401 | - PullRealTime: true, | ||
402 | - }) | ||
403 | - if err != nil { | ||
404 | - return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) | ||
405 | - } | ||
406 | - var res = make([]interface{}, 0) | ||
407 | - for i := range result.Users { | ||
408 | - for j := range result.Users[i].UserOrg { | ||
409 | - org := result.Users[i].UserOrg[j] | ||
410 | - res = append(res, map[string]interface{}{ | ||
411 | - "orgId": org.OrgID, | ||
412 | - "orgName": org.OrgName, | ||
413 | - }) | ||
414 | - } | ||
415 | - } | ||
416 | - return res, nil | ||
417 | -} | ||
418 | - | ||
419 | -// CompanySignUp 企业注册 | ||
420 | -func (srv AuthService) CompanySignUp(companySignUpCommand *command.CompanySignUpCommand) (interface{}, error) { | ||
421 | - smsServeGateway := sms_serve.NewHttplibHttplibSmsServe() | ||
422 | - err := smsServeGateway.CheckSmsCode(companySignUpCommand.Phone, companySignUpCommand.SmsCode) | ||
423 | - if err != nil { | ||
424 | - return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) | ||
425 | - } | ||
426 | - creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(domain.Operator{}) | ||
427 | - result, err := creationUserGateway.AuthCompanySignUp(allied_creation_user.ReqAuthCompanySignUp{ | ||
428 | - CompanyName: companySignUpCommand.CompanyName, | ||
429 | - Phone: companySignUpCommand.Phone, | ||
430 | - Password: companySignUpCommand.Password, | ||
431 | - Contacts: companySignUpCommand.Contacts, | ||
432 | - IndustryCategory: companySignUpCommand.IndustryCategory, | ||
433 | - Scale: companySignUpCommand.Scale, | ||
434 | - }) | ||
435 | - if err != nil { | ||
436 | - return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) | ||
437 | - } | ||
438 | - return result, err | ||
439 | -} | ||
440 | - | ||
441 | -// ResetPassword 重置密码(找回密码) | ||
442 | -func (srv AuthService) ResetPassword(resetPasswordCommand *command.ResetPasswordCommand) (interface{}, error) { | ||
443 | - if err := resetPasswordCommand.ValidateCommand(); err != nil { | ||
444 | - return nil, application.ThrowError(application.ARG_ERROR, err.Error()) | ||
445 | - } | ||
446 | - //var phone string | ||
447 | - pcc := cache.PhoneCheckCache{} | ||
448 | - var item = &cache.PhoneCheckItem{} | ||
449 | - if err := pcc.Get(resetPasswordCommand.SmsCodeIdentity, item); err != nil { | ||
450 | - log.Logger.Error(err.Error()) | ||
451 | - return nil, application.ThrowError(application.BUSINESS_ERROR, "验证码已失效") | ||
452 | - } | ||
453 | - // 2.重置密码 | ||
454 | - creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(domain.Operator{}) | ||
455 | - result, err := creationUserGateway.AuthResetPassword(allied_creation_user.ReqAuthResetPassword{ | ||
456 | - Phone: item.Phone, | ||
457 | - Password: resetPasswordCommand.Password, | ||
458 | - }) | ||
459 | - if err != nil { | ||
460 | - return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) | ||
461 | - } | ||
462 | - return result, err | ||
463 | -} |
@@ -29,10 +29,11 @@ func init() { | @@ -29,10 +29,11 @@ func init() { | ||
29 | web.BConfig.Listen.HTTPPort = port | 29 | web.BConfig.Listen.HTTPPort = port |
30 | } | 30 | } |
31 | } | 31 | } |
32 | + filters.SecureKeyMap["token"] = "x-mmm-accesstoken" | ||
32 | web.InsertFilter("/*", web.BeforeRouter, filters.AllowCors()) | 33 | web.InsertFilter("/*", web.BeforeRouter, filters.AllowCors()) |
33 | web.InsertFilter("/*", web.BeforeExec, filters.CreateRequstLogFilter(log.Logger)) | 34 | web.InsertFilter("/*", web.BeforeExec, filters.CreateRequstLogFilter(log.Logger)) |
34 | web.InsertFilter("/*", web.AfterExec, filters.CreateResponseLogFilter(log.Logger), web.WithReturnOnOutput(false)) | 35 | web.InsertFilter("/*", web.AfterExec, filters.CreateResponseLogFilter(log.Logger), web.WithReturnOnOutput(false)) |
35 | - web.InsertFilter("/v1/app1/*", web.BeforeExec, filters.SecureHandler( | 36 | + web.InsertFilter("/v1/app/*", web.BeforeExec, filters.SecureHandler( |
36 | filters.WithEnableCheckTimestamp(false), | 37 | filters.WithEnableCheckTimestamp(false), |
37 | filters.WithOnInvalidRequest(func(ctx *context.Context) { | 38 | filters.WithOnInvalidRequest(func(ctx *context.Context) { |
38 | headerData, _ := json.Marshal(ctx.Input.Context.Request.Header) | 39 | headerData, _ := json.Marshal(ctx.Input.Context.Request.Header) |
@@ -6,6 +6,6 @@ import ( | @@ -6,6 +6,6 @@ import ( | ||
6 | ) | 6 | ) |
7 | 7 | ||
8 | func init() { | 8 | func init() { |
9 | - web.Router("/common/dictionary/search", &common_controller.CommonController{}, "Post:GetDictionaryByCode") | 9 | + web.Router("/v1/common/dictionary/search", &common_controller.CommonController{}, "Post:GetDictionaryByCode") |
10 | //web.Router("/common/dictionary/search", &common_controller.CommonController{}, "Post:GetDictionaryByCode") | 10 | //web.Router("/common/dictionary/search", &common_controller.CommonController{}, "Post:GetDictionaryByCode") |
11 | } | 11 | } |
-
请 注册 或 登录 后发表评论