...
|
...
|
@@ -476,19 +476,22 @@ func CompaniesLogin(header *protocol.RequestHeader, request *protocolx.CenterCom |
|
|
// 添加手机对应的凭证
|
|
|
userAuth.NewRedisUserCredential(request.Phone).AddAuth(rsp.Credentials)
|
|
|
|
|
|
//v = map[string]interface{}{"center": rsp}
|
|
|
|
|
|
// 判断是否高管
|
|
|
if isSenior {
|
|
|
v = map[string]interface{}{"center": rsp}
|
|
|
} else {
|
|
|
rsp.Partner.(map[string]interface{})["companys"] = rsp.Manager.(map[string]interface{})["companys"]
|
|
|
var companies []interface{}
|
|
|
for _, company := range rsp.Manager.(map[string]interface{})["companys"].([]struct{}) {
|
|
|
companies = append(companies, company)
|
|
|
}
|
|
|
for _, company := range rsp.Partner.(map[string]interface{})["companys"].([]*domain_service.Company) {
|
|
|
companies = append(companies, company)
|
|
|
}
|
|
|
rsp.Partner = companies
|
|
|
rsp.Manager.(map[string]interface{})["companys"] = []struct{}{}
|
|
|
v = map[string]interface{}{"center": rsp}
|
|
|
}
|
|
|
|
|
|
v = map[string]interface{}{"center": rsp}
|
|
|
|
|
|
err = transactionContext.CommitTransaction()
|
|
|
return
|
|
|
}
|
...
|
...
|
@@ -505,6 +508,7 @@ func CompaniesLoginByCredential(header *protocol.RequestHeader, request *protoco |
|
|
transactionContext, _ = factory.CreateTransactionContext(nil)
|
|
|
loginSvr = domain_service.NewPgLoginService(transactionContext)
|
|
|
claim *utils.UserTokenClaims
|
|
|
isSenior bool
|
|
|
)
|
|
|
rsp = &protocolx.CompanysResponse{}
|
|
|
if err = transactionContext.StartTransaction(); err != nil {
|
...
|
...
|
@@ -530,16 +534,28 @@ func CompaniesLoginByCredential(header *protocol.RequestHeader, request *protoco |
|
|
// loginSvr 初始化
|
|
|
loginSvr.Init(claim.Phone)
|
|
|
|
|
|
// 判断是否高管
|
|
|
//ok, _ := loginSvr.CheckIsSenior(claim.Phone, claim.CompanyId)
|
|
|
// 高管初始化
|
|
|
_ = loginSvr.InitSenior(claim.Phone)
|
|
|
if len(loginSvr.Users) == 0 {
|
|
|
isSenior = false
|
|
|
} else {
|
|
|
isSenior = true
|
|
|
}
|
|
|
|
|
|
rsp.Partner, _ = loginSvr.PartnerStaticInfo()
|
|
|
rsp.Manager, _ = loginSvr.ManagerStaticInfo()
|
|
|
|
|
|
//if !ok { // 非高管普通用户
|
|
|
// rsp.Partner.(map[string]interface{})["companys"] = rsp.Manager.(map[string]interface{})["companys"]
|
|
|
// rsp.Manager.(map[string]interface{})["companys"] = []struct{}{}
|
|
|
//}
|
|
|
if !isSenior { // 非高管普通用户
|
|
|
var companies []interface{}
|
|
|
for _, company := range rsp.Manager.(map[string]interface{})["companys"].([]struct{}) {
|
|
|
companies = append(companies, company)
|
|
|
}
|
|
|
for _, company := range rsp.Partner.(map[string]interface{})["companys"].([]*domain_service.Company) {
|
|
|
companies = append(companies, company)
|
|
|
}
|
|
|
rsp.Partner = companies
|
|
|
rsp.Manager.(map[string]interface{})["companys"] = []struct{}{}
|
|
|
}
|
|
|
|
|
|
if !loginSvr.HasAvailableCompany {
|
|
|
err = protocol.NewErrWithMessage(4140, err) //账号禁用
|
...
|
...
|
|