作者 yangfu

共创项目修改

... ... @@ -155,20 +155,17 @@ func (svr AuthService) SignInPassword(account string, password string, loginPlat
if err != nil {
return "", application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
ltoken := domain.LoginToken{
loginToken := domain.LoginToken{
UserId: 0,
Account: account,
Platform: loginPlatform,
CompanyId: 0,
}
authcode, err := ltoken.GenerateAuthCode()
authCode, err := loginToken.GenerateAuthCode()
if err != nil {
return "", application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
//result := map[string]string{
// "authCode": authcode,
//}
return authcode, nil
return authCode, nil
}
//SignInCaptcha 使用手机验证码登录
... ... @@ -178,17 +175,17 @@ func (svr AuthService) SignInCaptcha(phone string, captcha string, loginPlatform
if err != nil {
return "", application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
ltoken := domain.LoginToken{
loginToken := domain.LoginToken{
UserId: 0,
Account: phone,
Platform: loginPlatform,
CompanyId: 0,
}
authcode, err := ltoken.GenerateAuthCode()
authCode, err := loginToken.GenerateAuthCode()
if err != nil {
return "", application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
return authcode, nil
return authCode, nil
}
//GetAuthAccessToken 获取令牌Token
... ... @@ -196,13 +193,13 @@ func (svr AuthService) GetAuthAccessToken(accessTokenCommand *command.AccessToke
if err := accessTokenCommand.ValidateCommand(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
ltoken := &domain.LoginToken{}
err := ltoken.ParseToken(accessTokenCommand.AuthCode)
loginToken := &domain.LoginToken{}
err := loginToken.ParseToken(accessTokenCommand.AuthCode)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
ltoken.Platform = accessTokenCommand.LoginPlatform
result, err := svr.getToken(*ltoken)
loginToken.Platform = accessTokenCommand.LoginPlatform
result, err := svr.getToken(*loginToken)
return result["token"], err
}
... ... @@ -210,12 +207,12 @@ func (svr AuthService) RefreshAuthAccessToken(refreshTokenCommand *command.Refre
if err := refreshTokenCommand.ValidateCommand(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
ltoken := domain.LoginToken{}
err := ltoken.ParseToken(refreshTokenCommand.RefreshToken)
loginToken := domain.LoginToken{}
err := loginToken.ParseToken(refreshTokenCommand.RefreshToken)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, "refreshToken 不可用,"+err.Error())
}
token, err := svr.getToken(ltoken)
token, err := svr.getToken(loginToken)
return map[string]interface{}{
"access": token["token"],
}, err
... ... @@ -281,13 +278,13 @@ func (svr AuthService) OrgSwitch(switchOrgCommand *command.SwitchOrgCommand) (in
if err := switchOrgCommand.ValidateCommand(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
ltoken := domain.LoginToken{}
err := ltoken.ParseToken(switchOrgCommand.Operator.Token)
loginToken := domain.LoginToken{}
err := loginToken.ParseToken(switchOrgCommand.Operator.Token)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, "accessToken 不可用,"+err.Error())
}
ltoken.OrgId = switchOrgCommand.OrgId
token, err := svr.getToken(ltoken)
loginToken.OrgId = switchOrgCommand.OrgId
token, err := svr.getToken(loginToken)
if err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
... ... @@ -394,10 +391,10 @@ func (svr AuthService) getUserInfo(operator domain.Operator) (interface{}, error
return user, nil
}
func (svr AuthService) getToken(ltoken domain.LoginToken) (map[string]interface{}, error) {
func (svr AuthService) getToken(loginToken domain.LoginToken) (map[string]interface{}, error) {
creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(domain.Operator{})
userSearchResult, err := creationUserGateway.UserSearch(allied_creation_user.ReqUserSearch{
Phone: ltoken.Account,
Phone: loginToken.Account,
})
if err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, "用户信息获取失败,"+err.Error())
... ... @@ -408,7 +405,7 @@ func (svr AuthService) getToken(ltoken domain.LoginToken) (map[string]interface{
loopUser1:
for _, v := range userSearchResult.Users {
for _, vv := range v.UserOrg {
if vv.OrgID == int(ltoken.OrgId) {
if vv.OrgID == int(loginToken.OrgId) {
currentOrgIsOK = true
currentUser = v
break loopUser1
... ... @@ -419,7 +416,7 @@ loopUser1:
loopUser2:
for _, v := range userSearchResult.Users {
for _, vv := range v.UserOrg {
ltoken.OrgId = int64(vv.OrgID)
loginToken.OrgId = int64(vv.OrgID)
currentOrgIsOK = true
currentUser = v
break loopUser2
... ... @@ -429,9 +426,9 @@ loopUser1:
if !currentOrgIsOK {
return nil, application.ThrowError(application.TRANSACTION_ERROR, "登录的公司组织不可用")
}
ltoken.UserId = int64(currentUser.UserId)
ltoken.UserBaseId = int64(currentUser.UserBaseId)
ltoken.CompanyId = int64(currentUser.Company.CompanyId)
loginToken.UserId = int64(currentUser.UserId)
loginToken.UserBaseId = int64(currentUser.UserBaseId)
loginToken.CompanyId = int64(currentUser.Company.CompanyId)
// 2. 更新currentAccess信息
transactionContext, err := factory.CreateTransactionContext(nil)
... ... @@ -451,8 +448,8 @@ loopUser1:
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
_, lAccess, err := loginAccessRepository.Find(map[string]interface{}{
"account": ltoken.Account,
"platform": ltoken.Platform,
"account": loginToken.Account,
"platform": loginToken.Platform,
})
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
... ... @@ -461,26 +458,26 @@ loopUser1:
if len(lAccess) > 0 {
currentAccess = lAccess[0]
}
currentAccess.UserId = int64(ltoken.UserId)
currentAccess.UserBaseId = int64(ltoken.UserBaseId)
currentAccess.Account = ltoken.Account
currentAccess.Platform = ltoken.Platform
currentAccess.CompanyId = int64(ltoken.CompanyId)
currentAccess.OrganizationId = ltoken.OrgId
currentAccess.UserId = int64(loginToken.UserId)
currentAccess.UserBaseId = int64(loginToken.UserBaseId)
currentAccess.Account = loginToken.Account
currentAccess.Platform = loginToken.Platform
currentAccess.CompanyId = int64(loginToken.CompanyId)
currentAccess.OrganizationId = loginToken.OrgId
currentAccess.UpdatedTime = time.Now()
accessTokenStr, err := ltoken.GenerateAccessToken()
accessTokenStr, err := loginToken.GenerateAccessToken()
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
currentAccess.AccessToken = accessTokenStr
currentAccess.AccessExpired = ltoken.ExpiresAt
refreshTokenStr, err := ltoken.GenerateRefreshToken()
currentAccess.AccessExpired = loginToken.ExpiresAt
refreshTokenStr, err := loginToken.GenerateRefreshToken()
if err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
currentAccess.RefreshToken = refreshTokenStr
currentAccess.RefreshExpired = ltoken.ExpiresAt
currentAccess.RefreshExpired = loginToken.ExpiresAt
//存数据库
_, err = loginAccessRepository.Save(currentAccess)
... ... @@ -493,8 +490,8 @@ loopUser1:
//redis缓存
tokenCache := cache.LoginTokenCache{}
tokenCache.RemoveAccessToken(currentAccess.Account, ltoken.Platform)
tokenCache.RemoveRefreshToken(currentAccess.Account, ltoken.Platform)
tokenCache.RemoveAccessToken(currentAccess.Account, loginToken.Platform)
tokenCache.RemoveRefreshToken(currentAccess.Account, loginToken.Platform)
tokenCache.SaveAccessToken(currentAccess)
tokenCache.SaveRefreshToken(currentAccess)
nowTime := time.Now().Unix()
... ... @@ -514,7 +511,9 @@ func (svr AuthService) GetCompanyOrgsByUser(queryParam *query.GetCompanyOrgsByUs
creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(queryParam.Operator)
result, err := creationUserGateway.UserSearch(allied_creation_user.ReqUserSearch{
Phone: queryParam.Phone,
UserBaseId: queryParam.Operator.UserBaseId,
//Phone: queryParam.Phone,
UserType: domain.UserTypeEmployee,
})
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
... ... @@ -590,8 +589,8 @@ func (svr *AuthService) CaptchaInit(request *query.CaptchaInitRequest) (interfac
var rsp map[string]interface{}
var err error
newGeetest := geetest.NewGeetestLib(captchaID, privateKey, 2*time.Second)
status, responseBt := newGeetest.PreProcess("", request.UserIp)
lib := geetest.NewGeetestLib(captchaID, privateKey, 2*time.Second)
status, responseBt := lib.PreProcess("", request.UserIp)
var geetestRsp geetest.FailbackRegisterRespnse
json.Unmarshal(responseBt, &geetestRsp)
rspData := map[string]interface{}{
... ...
... ... @@ -144,5 +144,5 @@ func (srv CooperationProjectService) PersonSearchCooperationProject(projectQuery
// item := dto.ToCooperationProjectItem(&result.List[i])
// dataList = append(dataList, *item)
//}
return int(result.Total), result, nil
return int(result.Total), result.List, nil
}
... ...
... ... @@ -3,7 +3,8 @@ package dto
import "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_user"
type DepartmentUsersDto struct {
Departments []*Department `json:"departments"`
Departments []*Department `json:"departments,omitempty"`
Users []interface{} `json:"users,omitempty"`
}
type Department struct {
... ... @@ -16,7 +17,18 @@ type User struct {
UserInfo map[string]interface{} `json:"userInfo"`
}
func (dto *DepartmentUsersDto) LoadDto(subDepartment *allied_creation_user.DataOrgGetSubDepartment, userSearch *allied_creation_user.DataUserSearch) error {
func (dto *DepartmentUsersDto) LoadDto(dataType int, subDepartment *allied_creation_user.DataOrgGetSubDepartment, userSearch *allied_creation_user.DataUserSearch) error {
if dataType == 1 {
for i := range userSearch.Users {
user := userSearch.Users[i]
dto.Users = append(dto.Users, map[string]interface{}{
"userId": user.UserId,
"userInfo": user.UserInfo,
"department": user.Department,
})
}
return nil
}
var mapDepartment = make(map[int64]*Department)
for i := range subDepartment.Orgs {
... ...
... ... @@ -10,6 +10,8 @@ import (
type DepartmentsUsersQuery struct {
//操作人
Operator domain.Operator `json:"-"`
// 类型0:部门用户列表 1:全部用户列表(不包含部门)
Type int `json:"type"`
}
func (departmentsUsersQuery *DepartmentsUsersQuery) Valid(validation *validation.Validation) {
... ...
... ... @@ -31,7 +31,7 @@ func (srv OrgService) DepartmentsUsers(departmentsUsersQuery *query.DepartmentsU
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
departmentUsersDto := &dto.DepartmentUsersDto{}
if err := departmentUsersDto.LoadDto(orgs, users); err != nil {
if err := departmentUsersDto.LoadDto(departmentsUsersQuery.Type, orgs, users); err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
return departmentUsersDto, nil
... ...
... ... @@ -222,8 +222,8 @@ func (controller *CooperationController) PersonSearchCooperationProject() {
return
}
cmd.Operator = controller.GetOperator()
_, data, err := svr.PersonSearchCooperationProject(cmd)
controller.Response(data, err)
total, data, err := svr.PersonSearchCooperationProject(cmd)
controller.ReturnPageListData(int64(total), data, err, cmd.PageNumber)
}
/***** CompanyCreditAccountService 企业端账期结算 *****/
... ...
... ... @@ -34,6 +34,8 @@ func init() {
web.Router("/v1/app/cooperation-projects/search", &mobile_client.CooperationController{}, "Post:SearchCooperationProject")
web.Router("/v1/app/cooperation-modes/", &web_client.CooperationModeController{}, "Get:ListCooperationMode")
web.Router("/v1/app/cooperation-projects/person/search", &mobile_client.CooperationController{}, "Post:PersonSearchCooperationProject")
/***** CompanyDividends 账期结算 *****/
web.Router("/v1/app/company/credit-accounts/search", &mobile_client.CooperationController{}, "Post:CreditAccountSearch")
web.Router("/v1/app/company/credit-accounts/:creditId", &mobile_client.CooperationController{}, "Get:CreditAccountGet")
... ...