合并分支 'dev' 到 'test'
fix:公司列表 查看合并请求 !28
正在显示
1 个修改的文件
包含
27 行增加
和
11 行删除
@@ -476,19 +476,22 @@ func CompaniesLogin(header *protocol.RequestHeader, request *protocolx.CenterCom | @@ -476,19 +476,22 @@ func CompaniesLogin(header *protocol.RequestHeader, request *protocolx.CenterCom | ||
476 | // 添加手机对应的凭证 | 476 | // 添加手机对应的凭证 |
477 | userAuth.NewRedisUserCredential(request.Phone).AddAuth(rsp.Credentials) | 477 | userAuth.NewRedisUserCredential(request.Phone).AddAuth(rsp.Credentials) |
478 | 478 | ||
479 | - //v = map[string]interface{}{"center": rsp} | ||
480 | - | ||
481 | // 判断是否高管 | 479 | // 判断是否高管 |
482 | if isSenior { | 480 | if isSenior { |
483 | v = map[string]interface{}{"center": rsp} | 481 | v = map[string]interface{}{"center": rsp} |
484 | } else { | 482 | } else { |
485 | - rsp.Partner.(map[string]interface{})["companys"] = rsp.Manager.(map[string]interface{})["companys"] | 483 | + var companies []interface{} |
484 | + for _, company := range rsp.Manager.(map[string]interface{})["companys"].([]struct{}) { | ||
485 | + companies = append(companies, company) | ||
486 | + } | ||
487 | + for _, company := range rsp.Partner.(map[string]interface{})["companys"].([]*domain_service.Company) { | ||
488 | + companies = append(companies, company) | ||
489 | + } | ||
490 | + rsp.Partner = companies | ||
486 | rsp.Manager.(map[string]interface{})["companys"] = []struct{}{} | 491 | rsp.Manager.(map[string]interface{})["companys"] = []struct{}{} |
487 | v = map[string]interface{}{"center": rsp} | 492 | v = map[string]interface{}{"center": rsp} |
488 | } | 493 | } |
489 | 494 | ||
490 | - v = map[string]interface{}{"center": rsp} | ||
491 | - | ||
492 | err = transactionContext.CommitTransaction() | 495 | err = transactionContext.CommitTransaction() |
493 | return | 496 | return |
494 | } | 497 | } |
@@ -505,6 +508,7 @@ func CompaniesLoginByCredential(header *protocol.RequestHeader, request *protoco | @@ -505,6 +508,7 @@ func CompaniesLoginByCredential(header *protocol.RequestHeader, request *protoco | ||
505 | transactionContext, _ = factory.CreateTransactionContext(nil) | 508 | transactionContext, _ = factory.CreateTransactionContext(nil) |
506 | loginSvr = domain_service.NewPgLoginService(transactionContext) | 509 | loginSvr = domain_service.NewPgLoginService(transactionContext) |
507 | claim *utils.UserTokenClaims | 510 | claim *utils.UserTokenClaims |
511 | + isSenior bool | ||
508 | ) | 512 | ) |
509 | rsp = &protocolx.CompanysResponse{} | 513 | rsp = &protocolx.CompanysResponse{} |
510 | if err = transactionContext.StartTransaction(); err != nil { | 514 | if err = transactionContext.StartTransaction(); err != nil { |
@@ -530,16 +534,28 @@ func CompaniesLoginByCredential(header *protocol.RequestHeader, request *protoco | @@ -530,16 +534,28 @@ func CompaniesLoginByCredential(header *protocol.RequestHeader, request *protoco | ||
530 | // loginSvr 初始化 | 534 | // loginSvr 初始化 |
531 | loginSvr.Init(claim.Phone) | 535 | loginSvr.Init(claim.Phone) |
532 | 536 | ||
533 | - // 判断是否高管 | ||
534 | - //ok, _ := loginSvr.CheckIsSenior(claim.Phone, claim.CompanyId) | 537 | + // 高管初始化 |
538 | + _ = loginSvr.InitSenior(claim.Phone) | ||
539 | + if len(loginSvr.Users) == 0 { | ||
540 | + isSenior = false | ||
541 | + } else { | ||
542 | + isSenior = true | ||
543 | + } | ||
535 | 544 | ||
536 | rsp.Partner, _ = loginSvr.PartnerStaticInfo() | 545 | rsp.Partner, _ = loginSvr.PartnerStaticInfo() |
537 | rsp.Manager, _ = loginSvr.ManagerStaticInfo() | 546 | rsp.Manager, _ = loginSvr.ManagerStaticInfo() |
538 | 547 | ||
539 | - //if !ok { // 非高管普通用户 | ||
540 | - // rsp.Partner.(map[string]interface{})["companys"] = rsp.Manager.(map[string]interface{})["companys"] | ||
541 | - // rsp.Manager.(map[string]interface{})["companys"] = []struct{}{} | ||
542 | - //} | 548 | + if !isSenior { // 非高管普通用户 |
549 | + var companies []interface{} | ||
550 | + for _, company := range rsp.Manager.(map[string]interface{})["companys"].([]struct{}) { | ||
551 | + companies = append(companies, company) | ||
552 | + } | ||
553 | + for _, company := range rsp.Partner.(map[string]interface{})["companys"].([]*domain_service.Company) { | ||
554 | + companies = append(companies, company) | ||
555 | + } | ||
556 | + rsp.Partner = companies | ||
557 | + rsp.Manager.(map[string]interface{})["companys"] = []struct{}{} | ||
558 | + } | ||
543 | 559 | ||
544 | if !loginSvr.HasAvailableCompany { | 560 | if !loginSvr.HasAvailableCompany { |
545 | err = protocol.NewErrWithMessage(4140, err) //账号禁用 | 561 | err = protocol.NewErrWithMessage(4140, err) //账号禁用 |
-
请 注册 或 登录 后发表评论