...
|
...
|
@@ -4,9 +4,11 @@ import ( |
|
|
"fmt"
|
|
|
"github.com/tiptok/gocomm/xa/eda"
|
|
|
"gitlab.fjmaimaimai.com/mmm-go/partner/pkg/application/factory"
|
|
|
"gitlab.fjmaimaimai.com/mmm-go/partner/pkg/constant"
|
|
|
"gitlab.fjmaimaimai.com/mmm-go/partner/pkg/domain"
|
|
|
"gitlab.fjmaimaimai.com/mmm-go/partner/pkg/domain/event"
|
|
|
"gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/domain_service"
|
|
|
http_gateway "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/svr"
|
|
|
"gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/utils"
|
|
|
"gitlab.fjmaimaimai.com/mmm-go/partner/pkg/log"
|
|
|
"gitlab.fjmaimaimai.com/mmm-go/partner/pkg/protocol"
|
...
|
...
|
@@ -315,10 +317,10 @@ func CenterCompanys(header *protocol.RequestHeader, request *protocolx.CenterCom |
|
|
rsp.Partner, _ = loginSvr.PartnerStaticInfo()
|
|
|
rsp.Manager, _ = loginSvr.ManagerStaticInfo()
|
|
|
//没有有效人的时候
|
|
|
//if rsp.Partner ==nil && rsp.Manager ==nil{
|
|
|
// err = protocol.NewErrWithMessage(2002) //账号禁用
|
|
|
// return
|
|
|
//}
|
|
|
if !loginSvr.AvailableCompany {
|
|
|
err = protocol.NewErrWithMessage(10008) //账号禁用
|
|
|
return
|
|
|
}
|
|
|
|
|
|
var nickName string
|
|
|
if len(loginSvr.Users) > 0 {
|
...
|
...
|
@@ -364,6 +366,11 @@ func Companys(header *protocol.RequestHeader, request *protocolx.CompanysRequest |
|
|
loginSvr.Init(claim.Phone)
|
|
|
rsp.Partner, _ = loginSvr.PartnerStaticInfo()
|
|
|
rsp.Manager, _ = loginSvr.ManagerStaticInfo()
|
|
|
//没有有效人的时候
|
|
|
if !loginSvr.AvailableCompany {
|
|
|
err = protocol.NewErrWithMessage(4140, err) //账号禁用
|
|
|
return
|
|
|
}
|
|
|
err = transactionContext.CommitTransaction()
|
|
|
return
|
|
|
}
|
...
|
...
|
@@ -374,7 +381,9 @@ func LoginV2(header *protocol.RequestHeader, request *protocol.LoginRequestV2) ( |
|
|
transactionContext, _ = factory.CreateTransactionContext(nil)
|
|
|
PartnerInfoRepository, _ = factory.CreatePartnerInfoRepositoryIn(transactionContext)
|
|
|
UsersRepository, _ = factory.CreateUsersRepository(transactionContext)
|
|
|
CompanyRepository, _ = factory.CreateCompanyRepository(transactionContext)
|
|
|
userId int64
|
|
|
adminApiGateway = http_gateway.NewHttplibBusinessAdminApiServiceGateway()
|
|
|
)
|
|
|
rsp = &protocol.LoginResponse{}
|
|
|
if err = transactionContext.StartTransaction(); err != nil {
|
...
|
...
|
@@ -387,15 +396,35 @@ func LoginV2(header *protocol.RequestHeader, request *protocol.LoginRequestV2) ( |
|
|
err = protocol.NewErrWithMessage(4140, err)
|
|
|
return
|
|
|
}
|
|
|
if company, e := CompanyRepository.FindOne(map[string]interface{}{"id": request.Cid, "enable": 1}); e != nil || company == nil {
|
|
|
err = protocol.NewErrWithMessage(10007, err)
|
|
|
return
|
|
|
}
|
|
|
switch request.IdType {
|
|
|
case int(protocolx.AdminTypePartner):
|
|
|
if p, e := PartnerInfoRepository.FindOne(map[string]interface{}{"account": claim.Phone, "companyId": request.Cid, "status": 1}); e == nil {
|
|
|
if p, e := PartnerInfoRepository.FindOne(map[string]interface{}{"account": claim.Phone, "companyId": request.Cid}); e == nil {
|
|
|
userId = p.Id
|
|
|
if !p.IsEnable() {
|
|
|
err = protocol.NewErrWithMessage(10006, err) //当前账号已被禁用
|
|
|
return
|
|
|
}
|
|
|
}
|
|
|
break
|
|
|
case int(protocolx.AdminTypeManager):
|
|
|
if p, e := UsersRepository.FindOne(map[string]interface{}{"phone": claim.Phone, "companyId": request.Cid, "status": 1}); e == nil {
|
|
|
if p, e := UsersRepository.FindOne(map[string]interface{}{"phone": claim.Phone, "companyId": request.Cid}); e == nil {
|
|
|
userId = p.Id
|
|
|
if !p.IsEnable() {
|
|
|
err = protocol.NewErrWithMessage(10006, err) //当前账号已被禁用
|
|
|
return
|
|
|
}
|
|
|
}
|
|
|
//校验模块权限
|
|
|
if userId != 0 {
|
|
|
if code, e := adminApiGateway.UserAuth(userId, constant.BUSINESS_ADMIN_PLATFORM_ID); e != nil || code != 0 {
|
|
|
log.Debug("【检查权限】", userId, "【公司】", request.Cid, "【错误】:", code, e.Error())
|
|
|
err = protocol.NewErrWithMessage(10008, err) // 抱歉,企业管理员未帮您开通权限
|
|
|
return
|
|
|
}
|
|
|
}
|
|
|
break
|
|
|
default:
|
...
|
...
|
@@ -403,7 +432,7 @@ func LoginV2(header *protocol.RequestHeader, request *protocol.LoginRequestV2) ( |
|
|
return
|
|
|
}
|
|
|
if userId == 0 {
|
|
|
err = protocol.NewErrWithMessage(502, err) //账号不存在
|
|
|
err = protocol.NewErrWithMessage(10001, err) //账号不存在
|
|
|
return
|
|
|
}
|
|
|
//根据simnum + cid
|
...
|
...
|
|