...
|
...
|
@@ -343,7 +343,13 @@ func PasswordLogin(header *protocol.RequestHeader, request *protocol.LoginReques |
|
|
return
|
|
|
}
|
|
|
|
|
|
// 企业平台-多公司登录
|
|
|
/**
|
|
|
* @Author SteveChan
|
|
|
* @Description //TODO 企业平台-多公司登录,判断是否高管
|
|
|
* @Date 15:01 2021/1/12
|
|
|
* @Param
|
|
|
* @return
|
|
|
**/
|
|
|
func CompaniesLogin(header *protocol.RequestHeader, request *protocolx.CenterCompanysRequest) (v interface{}, err error) {
|
|
|
var (
|
|
|
transactionContext, _ = factory.CreateTransactionContext(nil)
|
...
|
...
|
@@ -371,9 +377,9 @@ func CompaniesLogin(header *protocol.RequestHeader, request *protocolx.CenterCom |
|
|
|
|
|
// 通过短信验证码登录的游客,注册一个账号到配置的公司去(ios审核使用)
|
|
|
if request.GrantType == protocol.LoginBySmsCode {
|
|
|
e := loginSvr.RegistryGuest(request.Phone)
|
|
|
if e != nil {
|
|
|
log.Error(e)
|
|
|
guestLoginErr := loginSvr.RegistryGuest(request.Phone)
|
|
|
if guestLoginErr != nil {
|
|
|
log.Error(guestLoginErr)
|
|
|
}
|
|
|
}
|
|
|
|
...
|
...
|
@@ -475,7 +481,13 @@ func CompaniesLogin(header *protocol.RequestHeader, request *protocolx.CenterCom |
|
|
return
|
|
|
}
|
|
|
|
|
|
// 企业平台-多公司登录 - 通过凭证
|
|
|
/**
|
|
|
* @Author SteveChan
|
|
|
* @Description //TODO 企业平台-多公司登录 - 通过凭证,判断是否高管
|
|
|
* @Date 15:00 2021/1/12
|
|
|
* @Param
|
|
|
* @return
|
|
|
**/
|
|
|
func CompaniesLoginByCredential(header *protocol.RequestHeader, request *protocolx.CompanysRequest) (rsp *protocolx.CompanysResponse, err error) {
|
|
|
var (
|
|
|
transactionContext, _ = factory.CreateTransactionContext(nil)
|
...
|
...
|
@@ -505,8 +517,22 @@ func CompaniesLoginByCredential(header *protocol.RequestHeader, request *protoco |
|
|
|
|
|
// loginSvr 初始化
|
|
|
loginSvr.Init(claim.Phone)
|
|
|
|
|
|
// 判断是否高管
|
|
|
ok, loginErr := loginSvr.CheckIsSenior(claim.Phone, 0)
|
|
|
if loginErr != nil {
|
|
|
err = protocol.NewErrWithMessage(10001)
|
|
|
return
|
|
|
}
|
|
|
|
|
|
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 !loginSvr.HasAvailableCompany {
|
|
|
err = protocol.NewErrWithMessage(4140, err) //账号禁用
|
|
|
return
|
...
|
...
|
@@ -552,6 +578,15 @@ func LoginV2(header *protocol.RequestHeader, request *protocol.LoginRequestV2) ( |
|
|
}
|
|
|
switch request.IdType {
|
|
|
case int(protocolx.AdminTypePartner):
|
|
|
// 用户信息检索
|
|
|
if p, e := UsersRepository.FindOne(map[string]interface{}{"phone": claim.Phone, "companyId": request.Cid, "deleteAtIsNull": true}); e == nil {
|
|
|
userId = p.Id
|
|
|
if !p.IsEnable() {
|
|
|
err = protocol.NewErrWithMessage(10006, err) //当前账号已被禁用
|
|
|
return
|
|
|
}
|
|
|
}
|
|
|
// 合伙人检索
|
|
|
if p, e := PartnerInfoRepository.FindOne(map[string]interface{}{"account": claim.Phone, "companyId": request.Cid, "deleteAtIsNull": true}); e == nil {
|
|
|
userId = p.Id
|
|
|
if !p.IsEnable() {
|
...
|
...
|
@@ -572,6 +607,7 @@ func LoginV2(header *protocol.RequestHeader, request *protocol.LoginRequestV2) ( |
|
|
}
|
|
|
break
|
|
|
case int(protocolx.AdminTypeManager):
|
|
|
// 用户信息检索
|
|
|
if p, e := UsersRepository.FindOne(map[string]interface{}{"phone": claim.Phone, "companyId": request.Cid, "deleteAtIsNull": true}); e == nil {
|
|
|
userId = p.Id
|
|
|
if !p.IsEnable() {
|
...
|
...
|
@@ -592,6 +628,7 @@ func LoginV2(header *protocol.RequestHeader, request *protocol.LoginRequestV2) ( |
|
|
err = protocol.NewErrWithMessage(2, fmt.Errorf("idType :%v not in range (1,2)", request.IdType)) //用户类型有误
|
|
|
return
|
|
|
}
|
|
|
|
|
|
if userId == 0 {
|
|
|
err = protocol.NewErrWithMessage(10001, err) //账号不存在
|
|
|
return
|
...
|
...
|
|