正在显示
1 个修改的文件
包含
42 行增加
和
5 行删除
@@ -343,7 +343,13 @@ func PasswordLogin(header *protocol.RequestHeader, request *protocol.LoginReques | @@ -343,7 +343,13 @@ func PasswordLogin(header *protocol.RequestHeader, request *protocol.LoginReques | ||
343 | return | 343 | return |
344 | } | 344 | } |
345 | 345 | ||
346 | -// 企业平台-多公司登录 | 346 | +/** |
347 | + * @Author SteveChan | ||
348 | + * @Description //TODO 企业平台-多公司登录,判断是否高管 | ||
349 | + * @Date 15:01 2021/1/12 | ||
350 | + * @Param | ||
351 | + * @return | ||
352 | + **/ | ||
347 | func CompaniesLogin(header *protocol.RequestHeader, request *protocolx.CenterCompanysRequest) (v interface{}, err error) { | 353 | func CompaniesLogin(header *protocol.RequestHeader, request *protocolx.CenterCompanysRequest) (v interface{}, err error) { |
348 | var ( | 354 | var ( |
349 | transactionContext, _ = factory.CreateTransactionContext(nil) | 355 | transactionContext, _ = factory.CreateTransactionContext(nil) |
@@ -371,9 +377,9 @@ func CompaniesLogin(header *protocol.RequestHeader, request *protocolx.CenterCom | @@ -371,9 +377,9 @@ func CompaniesLogin(header *protocol.RequestHeader, request *protocolx.CenterCom | ||
371 | 377 | ||
372 | // 通过短信验证码登录的游客,注册一个账号到配置的公司去(ios审核使用) | 378 | // 通过短信验证码登录的游客,注册一个账号到配置的公司去(ios审核使用) |
373 | if request.GrantType == protocol.LoginBySmsCode { | 379 | if request.GrantType == protocol.LoginBySmsCode { |
374 | - e := loginSvr.RegistryGuest(request.Phone) | ||
375 | - if e != nil { | ||
376 | - log.Error(e) | 380 | + guestLoginErr := loginSvr.RegistryGuest(request.Phone) |
381 | + if guestLoginErr != nil { | ||
382 | + log.Error(guestLoginErr) | ||
377 | } | 383 | } |
378 | } | 384 | } |
379 | 385 | ||
@@ -475,7 +481,13 @@ func CompaniesLogin(header *protocol.RequestHeader, request *protocolx.CenterCom | @@ -475,7 +481,13 @@ func CompaniesLogin(header *protocol.RequestHeader, request *protocolx.CenterCom | ||
475 | return | 481 | return |
476 | } | 482 | } |
477 | 483 | ||
478 | -// 企业平台-多公司登录 - 通过凭证 | 484 | +/** |
485 | + * @Author SteveChan | ||
486 | + * @Description //TODO 企业平台-多公司登录 - 通过凭证,判断是否高管 | ||
487 | + * @Date 15:00 2021/1/12 | ||
488 | + * @Param | ||
489 | + * @return | ||
490 | + **/ | ||
479 | func CompaniesLoginByCredential(header *protocol.RequestHeader, request *protocolx.CompanysRequest) (rsp *protocolx.CompanysResponse, err error) { | 491 | func CompaniesLoginByCredential(header *protocol.RequestHeader, request *protocolx.CompanysRequest) (rsp *protocolx.CompanysResponse, err error) { |
480 | var ( | 492 | var ( |
481 | transactionContext, _ = factory.CreateTransactionContext(nil) | 493 | transactionContext, _ = factory.CreateTransactionContext(nil) |
@@ -505,8 +517,22 @@ func CompaniesLoginByCredential(header *protocol.RequestHeader, request *protoco | @@ -505,8 +517,22 @@ func CompaniesLoginByCredential(header *protocol.RequestHeader, request *protoco | ||
505 | 517 | ||
506 | // loginSvr 初始化 | 518 | // loginSvr 初始化 |
507 | loginSvr.Init(claim.Phone) | 519 | loginSvr.Init(claim.Phone) |
520 | + | ||
521 | + // 判断是否高管 | ||
522 | + ok, loginErr := loginSvr.CheckIsSenior(claim.Phone, 0) | ||
523 | + if loginErr != nil { | ||
524 | + err = protocol.NewErrWithMessage(10001) | ||
525 | + return | ||
526 | + } | ||
527 | + | ||
508 | rsp.Partner, _ = loginSvr.PartnerStaticInfo() | 528 | rsp.Partner, _ = loginSvr.PartnerStaticInfo() |
509 | rsp.Manager, _ = loginSvr.ManagerStaticInfo() | 529 | rsp.Manager, _ = loginSvr.ManagerStaticInfo() |
530 | + | ||
531 | + if !ok { // 非高管普通用户 | ||
532 | + rsp.Partner.(map[string]interface{})["companys"] = rsp.Manager.(map[string]interface{})["companys"] | ||
533 | + rsp.Manager.(map[string]interface{})["companys"] = []struct{}{} | ||
534 | + } | ||
535 | + | ||
510 | if !loginSvr.HasAvailableCompany { | 536 | if !loginSvr.HasAvailableCompany { |
511 | err = protocol.NewErrWithMessage(4140, err) //账号禁用 | 537 | err = protocol.NewErrWithMessage(4140, err) //账号禁用 |
512 | return | 538 | return |
@@ -552,6 +578,15 @@ func LoginV2(header *protocol.RequestHeader, request *protocol.LoginRequestV2) ( | @@ -552,6 +578,15 @@ func LoginV2(header *protocol.RequestHeader, request *protocol.LoginRequestV2) ( | ||
552 | } | 578 | } |
553 | switch request.IdType { | 579 | switch request.IdType { |
554 | case int(protocolx.AdminTypePartner): | 580 | case int(protocolx.AdminTypePartner): |
581 | + // 用户信息检索 | ||
582 | + if p, e := UsersRepository.FindOne(map[string]interface{}{"phone": claim.Phone, "companyId": request.Cid, "deleteAtIsNull": true}); e == nil { | ||
583 | + userId = p.Id | ||
584 | + if !p.IsEnable() { | ||
585 | + err = protocol.NewErrWithMessage(10006, err) //当前账号已被禁用 | ||
586 | + return | ||
587 | + } | ||
588 | + } | ||
589 | + // 合伙人检索 | ||
555 | if p, e := PartnerInfoRepository.FindOne(map[string]interface{}{"account": claim.Phone, "companyId": request.Cid, "deleteAtIsNull": true}); e == nil { | 590 | if p, e := PartnerInfoRepository.FindOne(map[string]interface{}{"account": claim.Phone, "companyId": request.Cid, "deleteAtIsNull": true}); e == nil { |
556 | userId = p.Id | 591 | userId = p.Id |
557 | if !p.IsEnable() { | 592 | if !p.IsEnable() { |
@@ -572,6 +607,7 @@ func LoginV2(header *protocol.RequestHeader, request *protocol.LoginRequestV2) ( | @@ -572,6 +607,7 @@ func LoginV2(header *protocol.RequestHeader, request *protocol.LoginRequestV2) ( | ||
572 | } | 607 | } |
573 | break | 608 | break |
574 | case int(protocolx.AdminTypeManager): | 609 | case int(protocolx.AdminTypeManager): |
610 | + // 用户信息检索 | ||
575 | if p, e := UsersRepository.FindOne(map[string]interface{}{"phone": claim.Phone, "companyId": request.Cid, "deleteAtIsNull": true}); e == nil { | 611 | if p, e := UsersRepository.FindOne(map[string]interface{}{"phone": claim.Phone, "companyId": request.Cid, "deleteAtIsNull": true}); e == nil { |
576 | userId = p.Id | 612 | userId = p.Id |
577 | if !p.IsEnable() { | 613 | if !p.IsEnable() { |
@@ -592,6 +628,7 @@ func LoginV2(header *protocol.RequestHeader, request *protocol.LoginRequestV2) ( | @@ -592,6 +628,7 @@ func LoginV2(header *protocol.RequestHeader, request *protocol.LoginRequestV2) ( | ||
592 | err = protocol.NewErrWithMessage(2, fmt.Errorf("idType :%v not in range (1,2)", request.IdType)) //用户类型有误 | 628 | err = protocol.NewErrWithMessage(2, fmt.Errorf("idType :%v not in range (1,2)", request.IdType)) //用户类型有误 |
593 | return | 629 | return |
594 | } | 630 | } |
631 | + | ||
595 | if userId == 0 { | 632 | if userId == 0 { |
596 | err = protocol.NewErrWithMessage(10001, err) //账号不存在 | 633 | err = protocol.NewErrWithMessage(10001, err) //账号不存在 |
597 | return | 634 | return |
-
请 注册 或 登录 后发表评论