作者 yangfu

共创项目修改

@@ -155,20 +155,17 @@ func (svr AuthService) SignInPassword(account string, password string, loginPlat @@ -155,20 +155,17 @@ func (svr AuthService) SignInPassword(account string, password string, loginPlat
155 if err != nil { 155 if err != nil {
156 return "", application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 156 return "", application.ThrowError(application.TRANSACTION_ERROR, err.Error())
157 } 157 }
158 - ltoken := domain.LoginToken{ 158 + loginToken := domain.LoginToken{
159 UserId: 0, 159 UserId: 0,
160 Account: account, 160 Account: account,
161 Platform: loginPlatform, 161 Platform: loginPlatform,
162 CompanyId: 0, 162 CompanyId: 0,
163 } 163 }
164 - authcode, err := ltoken.GenerateAuthCode() 164 + authCode, err := loginToken.GenerateAuthCode()
165 if err != nil { 165 if err != nil {
166 return "", application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 166 return "", application.ThrowError(application.TRANSACTION_ERROR, err.Error())
167 } 167 }
168 - //result := map[string]string{  
169 - // "authCode": authcode,  
170 - //}  
171 - return authcode, nil 168 + return authCode, nil
172 } 169 }
173 170
174 //SignInCaptcha 使用手机验证码登录 171 //SignInCaptcha 使用手机验证码登录
@@ -178,17 +175,17 @@ func (svr AuthService) SignInCaptcha(phone string, captcha string, loginPlatform @@ -178,17 +175,17 @@ func (svr AuthService) SignInCaptcha(phone string, captcha string, loginPlatform
178 if err != nil { 175 if err != nil {
179 return "", application.ThrowError(application.BUSINESS_ERROR, err.Error()) 176 return "", application.ThrowError(application.BUSINESS_ERROR, err.Error())
180 } 177 }
181 - ltoken := domain.LoginToken{ 178 + loginToken := domain.LoginToken{
182 UserId: 0, 179 UserId: 0,
183 Account: phone, 180 Account: phone,
184 Platform: loginPlatform, 181 Platform: loginPlatform,
185 CompanyId: 0, 182 CompanyId: 0,
186 } 183 }
187 - authcode, err := ltoken.GenerateAuthCode() 184 + authCode, err := loginToken.GenerateAuthCode()
188 if err != nil { 185 if err != nil {
189 return "", application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 186 return "", application.ThrowError(application.TRANSACTION_ERROR, err.Error())
190 } 187 }
191 - return authcode, nil 188 + return authCode, nil
192 } 189 }
193 190
194 //GetAuthAccessToken 获取令牌Token 191 //GetAuthAccessToken 获取令牌Token
@@ -196,13 +193,13 @@ func (svr AuthService) GetAuthAccessToken(accessTokenCommand *command.AccessToke @@ -196,13 +193,13 @@ func (svr AuthService) GetAuthAccessToken(accessTokenCommand *command.AccessToke
196 if err := accessTokenCommand.ValidateCommand(); err != nil { 193 if err := accessTokenCommand.ValidateCommand(); err != nil {
197 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 194 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
198 } 195 }
199 - ltoken := &domain.LoginToken{}  
200 - err := ltoken.ParseToken(accessTokenCommand.AuthCode) 196 + loginToken := &domain.LoginToken{}
  197 + err := loginToken.ParseToken(accessTokenCommand.AuthCode)
201 if err != nil { 198 if err != nil {
202 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 199 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
203 } 200 }
204 - ltoken.Platform = accessTokenCommand.LoginPlatform  
205 - result, err := svr.getToken(*ltoken) 201 + loginToken.Platform = accessTokenCommand.LoginPlatform
  202 + result, err := svr.getToken(*loginToken)
206 return result["token"], err 203 return result["token"], err
207 } 204 }
208 205
@@ -210,12 +207,12 @@ func (svr AuthService) RefreshAuthAccessToken(refreshTokenCommand *command.Refre @@ -210,12 +207,12 @@ func (svr AuthService) RefreshAuthAccessToken(refreshTokenCommand *command.Refre
210 if err := refreshTokenCommand.ValidateCommand(); err != nil { 207 if err := refreshTokenCommand.ValidateCommand(); err != nil {
211 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 208 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
212 } 209 }
213 - ltoken := domain.LoginToken{}  
214 - err := ltoken.ParseToken(refreshTokenCommand.RefreshToken) 210 + loginToken := domain.LoginToken{}
  211 + err := loginToken.ParseToken(refreshTokenCommand.RefreshToken)
215 if err != nil { 212 if err != nil {
216 return nil, application.ThrowError(application.TRANSACTION_ERROR, "refreshToken 不可用,"+err.Error()) 213 return nil, application.ThrowError(application.TRANSACTION_ERROR, "refreshToken 不可用,"+err.Error())
217 } 214 }
218 - token, err := svr.getToken(ltoken) 215 + token, err := svr.getToken(loginToken)
219 return map[string]interface{}{ 216 return map[string]interface{}{
220 "access": token["token"], 217 "access": token["token"],
221 }, err 218 }, err
@@ -281,13 +278,13 @@ func (svr AuthService) OrgSwitch(switchOrgCommand *command.SwitchOrgCommand) (in @@ -281,13 +278,13 @@ func (svr AuthService) OrgSwitch(switchOrgCommand *command.SwitchOrgCommand) (in
281 if err := switchOrgCommand.ValidateCommand(); err != nil { 278 if err := switchOrgCommand.ValidateCommand(); err != nil {
282 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 279 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
283 } 280 }
284 - ltoken := domain.LoginToken{}  
285 - err := ltoken.ParseToken(switchOrgCommand.Operator.Token) 281 + loginToken := domain.LoginToken{}
  282 + err := loginToken.ParseToken(switchOrgCommand.Operator.Token)
286 if err != nil { 283 if err != nil {
287 return nil, application.ThrowError(application.TRANSACTION_ERROR, "accessToken 不可用,"+err.Error()) 284 return nil, application.ThrowError(application.TRANSACTION_ERROR, "accessToken 不可用,"+err.Error())
288 } 285 }
289 - ltoken.OrgId = switchOrgCommand.OrgId  
290 - token, err := svr.getToken(ltoken) 286 + loginToken.OrgId = switchOrgCommand.OrgId
  287 + token, err := svr.getToken(loginToken)
291 if err != nil { 288 if err != nil {
292 return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) 289 return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
293 } 290 }
@@ -394,10 +391,10 @@ func (svr AuthService) getUserInfo(operator domain.Operator) (interface{}, error @@ -394,10 +391,10 @@ func (svr AuthService) getUserInfo(operator domain.Operator) (interface{}, error
394 return user, nil 391 return user, nil
395 } 392 }
396 393
397 -func (svr AuthService) getToken(ltoken domain.LoginToken) (map[string]interface{}, error) { 394 +func (svr AuthService) getToken(loginToken domain.LoginToken) (map[string]interface{}, error) {
398 creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(domain.Operator{}) 395 creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(domain.Operator{})
399 userSearchResult, err := creationUserGateway.UserSearch(allied_creation_user.ReqUserSearch{ 396 userSearchResult, err := creationUserGateway.UserSearch(allied_creation_user.ReqUserSearch{
400 - Phone: ltoken.Account, 397 + Phone: loginToken.Account,
401 }) 398 })
402 if err != nil { 399 if err != nil {
403 return nil, application.ThrowError(application.BUSINESS_ERROR, "用户信息获取失败,"+err.Error()) 400 return nil, application.ThrowError(application.BUSINESS_ERROR, "用户信息获取失败,"+err.Error())
@@ -408,7 +405,7 @@ func (svr AuthService) getToken(ltoken domain.LoginToken) (map[string]interface{ @@ -408,7 +405,7 @@ func (svr AuthService) getToken(ltoken domain.LoginToken) (map[string]interface{
408 loopUser1: 405 loopUser1:
409 for _, v := range userSearchResult.Users { 406 for _, v := range userSearchResult.Users {
410 for _, vv := range v.UserOrg { 407 for _, vv := range v.UserOrg {
411 - if vv.OrgID == int(ltoken.OrgId) { 408 + if vv.OrgID == int(loginToken.OrgId) {
412 currentOrgIsOK = true 409 currentOrgIsOK = true
413 currentUser = v 410 currentUser = v
414 break loopUser1 411 break loopUser1
@@ -419,7 +416,7 @@ loopUser1: @@ -419,7 +416,7 @@ loopUser1:
419 loopUser2: 416 loopUser2:
420 for _, v := range userSearchResult.Users { 417 for _, v := range userSearchResult.Users {
421 for _, vv := range v.UserOrg { 418 for _, vv := range v.UserOrg {
422 - ltoken.OrgId = int64(vv.OrgID) 419 + loginToken.OrgId = int64(vv.OrgID)
423 currentOrgIsOK = true 420 currentOrgIsOK = true
424 currentUser = v 421 currentUser = v
425 break loopUser2 422 break loopUser2
@@ -429,9 +426,9 @@ loopUser1: @@ -429,9 +426,9 @@ loopUser1:
429 if !currentOrgIsOK { 426 if !currentOrgIsOK {
430 return nil, application.ThrowError(application.TRANSACTION_ERROR, "登录的公司组织不可用") 427 return nil, application.ThrowError(application.TRANSACTION_ERROR, "登录的公司组织不可用")
431 } 428 }
432 - ltoken.UserId = int64(currentUser.UserId)  
433 - ltoken.UserBaseId = int64(currentUser.UserBaseId)  
434 - ltoken.CompanyId = int64(currentUser.Company.CompanyId) 429 + loginToken.UserId = int64(currentUser.UserId)
  430 + loginToken.UserBaseId = int64(currentUser.UserBaseId)
  431 + loginToken.CompanyId = int64(currentUser.Company.CompanyId)
435 432
436 // 2. 更新currentAccess信息 433 // 2. 更新currentAccess信息
437 transactionContext, err := factory.CreateTransactionContext(nil) 434 transactionContext, err := factory.CreateTransactionContext(nil)
@@ -451,8 +448,8 @@ loopUser1: @@ -451,8 +448,8 @@ loopUser1:
451 return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) 448 return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
452 } 449 }
453 _, lAccess, err := loginAccessRepository.Find(map[string]interface{}{ 450 _, lAccess, err := loginAccessRepository.Find(map[string]interface{}{
454 - "account": ltoken.Account,  
455 - "platform": ltoken.Platform, 451 + "account": loginToken.Account,
  452 + "platform": loginToken.Platform,
456 }) 453 })
457 if err != nil { 454 if err != nil {
458 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 455 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
@@ -461,26 +458,26 @@ loopUser1: @@ -461,26 +458,26 @@ loopUser1:
461 if len(lAccess) > 0 { 458 if len(lAccess) > 0 {
462 currentAccess = lAccess[0] 459 currentAccess = lAccess[0]
463 } 460 }
464 - currentAccess.UserId = int64(ltoken.UserId)  
465 - currentAccess.UserBaseId = int64(ltoken.UserBaseId)  
466 - currentAccess.Account = ltoken.Account  
467 - currentAccess.Platform = ltoken.Platform  
468 - currentAccess.CompanyId = int64(ltoken.CompanyId)  
469 - currentAccess.OrganizationId = ltoken.OrgId 461 + currentAccess.UserId = int64(loginToken.UserId)
  462 + currentAccess.UserBaseId = int64(loginToken.UserBaseId)
  463 + currentAccess.Account = loginToken.Account
  464 + currentAccess.Platform = loginToken.Platform
  465 + currentAccess.CompanyId = int64(loginToken.CompanyId)
  466 + currentAccess.OrganizationId = loginToken.OrgId
470 currentAccess.UpdatedTime = time.Now() 467 currentAccess.UpdatedTime = time.Now()
471 468
472 - accessTokenStr, err := ltoken.GenerateAccessToken() 469 + accessTokenStr, err := loginToken.GenerateAccessToken()
473 if err != nil { 470 if err != nil {
474 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 471 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
475 } 472 }
476 currentAccess.AccessToken = accessTokenStr 473 currentAccess.AccessToken = accessTokenStr
477 - currentAccess.AccessExpired = ltoken.ExpiresAt  
478 - refreshTokenStr, err := ltoken.GenerateRefreshToken() 474 + currentAccess.AccessExpired = loginToken.ExpiresAt
  475 + refreshTokenStr, err := loginToken.GenerateRefreshToken()
479 if err != nil { 476 if err != nil {
480 return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) 477 return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
481 } 478 }
482 currentAccess.RefreshToken = refreshTokenStr 479 currentAccess.RefreshToken = refreshTokenStr
483 - currentAccess.RefreshExpired = ltoken.ExpiresAt 480 + currentAccess.RefreshExpired = loginToken.ExpiresAt
484 481
485 //存数据库 482 //存数据库
486 _, err = loginAccessRepository.Save(currentAccess) 483 _, err = loginAccessRepository.Save(currentAccess)
@@ -493,8 +490,8 @@ loopUser1: @@ -493,8 +490,8 @@ loopUser1:
493 490
494 //redis缓存 491 //redis缓存
495 tokenCache := cache.LoginTokenCache{} 492 tokenCache := cache.LoginTokenCache{}
496 - tokenCache.RemoveAccessToken(currentAccess.Account, ltoken.Platform)  
497 - tokenCache.RemoveRefreshToken(currentAccess.Account, ltoken.Platform) 493 + tokenCache.RemoveAccessToken(currentAccess.Account, loginToken.Platform)
  494 + tokenCache.RemoveRefreshToken(currentAccess.Account, loginToken.Platform)
498 tokenCache.SaveAccessToken(currentAccess) 495 tokenCache.SaveAccessToken(currentAccess)
499 tokenCache.SaveRefreshToken(currentAccess) 496 tokenCache.SaveRefreshToken(currentAccess)
500 nowTime := time.Now().Unix() 497 nowTime := time.Now().Unix()
@@ -514,7 +511,9 @@ func (svr AuthService) GetCompanyOrgsByUser(queryParam *query.GetCompanyOrgsByUs @@ -514,7 +511,9 @@ func (svr AuthService) GetCompanyOrgsByUser(queryParam *query.GetCompanyOrgsByUs
514 511
515 creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(queryParam.Operator) 512 creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(queryParam.Operator)
516 result, err := creationUserGateway.UserSearch(allied_creation_user.ReqUserSearch{ 513 result, err := creationUserGateway.UserSearch(allied_creation_user.ReqUserSearch{
517 - Phone: queryParam.Phone, 514 + UserBaseId: queryParam.Operator.UserBaseId,
  515 + //Phone: queryParam.Phone,
  516 + UserType: domain.UserTypeEmployee,
518 }) 517 })
519 if err != nil { 518 if err != nil {
520 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 519 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
@@ -590,8 +589,8 @@ func (svr *AuthService) CaptchaInit(request *query.CaptchaInitRequest) (interfac @@ -590,8 +589,8 @@ func (svr *AuthService) CaptchaInit(request *query.CaptchaInitRequest) (interfac
590 var rsp map[string]interface{} 589 var rsp map[string]interface{}
591 var err error 590 var err error
592 591
593 - newGeetest := geetest.NewGeetestLib(captchaID, privateKey, 2*time.Second)  
594 - status, responseBt := newGeetest.PreProcess("", request.UserIp) 592 + lib := geetest.NewGeetestLib(captchaID, privateKey, 2*time.Second)
  593 + status, responseBt := lib.PreProcess("", request.UserIp)
595 var geetestRsp geetest.FailbackRegisterRespnse 594 var geetestRsp geetest.FailbackRegisterRespnse
596 json.Unmarshal(responseBt, &geetestRsp) 595 json.Unmarshal(responseBt, &geetestRsp)
597 rspData := map[string]interface{}{ 596 rspData := map[string]interface{}{
@@ -144,5 +144,5 @@ func (srv CooperationProjectService) PersonSearchCooperationProject(projectQuery @@ -144,5 +144,5 @@ func (srv CooperationProjectService) PersonSearchCooperationProject(projectQuery
144 // item := dto.ToCooperationProjectItem(&result.List[i]) 144 // item := dto.ToCooperationProjectItem(&result.List[i])
145 // dataList = append(dataList, *item) 145 // dataList = append(dataList, *item)
146 //} 146 //}
147 - return int(result.Total), result, nil 147 + return int(result.Total), result.List, nil
148 } 148 }
@@ -3,7 +3,8 @@ package dto @@ -3,7 +3,8 @@ package dto
3 import "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_user" 3 import "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_user"
4 4
5 type DepartmentUsersDto struct { 5 type DepartmentUsersDto struct {
6 - Departments []*Department `json:"departments"` 6 + Departments []*Department `json:"departments,omitempty"`
  7 + Users []interface{} `json:"users,omitempty"`
7 } 8 }
8 9
9 type Department struct { 10 type Department struct {
@@ -16,7 +17,18 @@ type User struct { @@ -16,7 +17,18 @@ type User struct {
16 UserInfo map[string]interface{} `json:"userInfo"` 17 UserInfo map[string]interface{} `json:"userInfo"`
17 } 18 }
18 19
19 -func (dto *DepartmentUsersDto) LoadDto(subDepartment *allied_creation_user.DataOrgGetSubDepartment, userSearch *allied_creation_user.DataUserSearch) error { 20 +func (dto *DepartmentUsersDto) LoadDto(dataType int, subDepartment *allied_creation_user.DataOrgGetSubDepartment, userSearch *allied_creation_user.DataUserSearch) error {
  21 + if dataType == 1 {
  22 + for i := range userSearch.Users {
  23 + user := userSearch.Users[i]
  24 + dto.Users = append(dto.Users, map[string]interface{}{
  25 + "userId": user.UserId,
  26 + "userInfo": user.UserInfo,
  27 + "department": user.Department,
  28 + })
  29 + }
  30 + return nil
  31 + }
20 var mapDepartment = make(map[int64]*Department) 32 var mapDepartment = make(map[int64]*Department)
21 33
22 for i := range subDepartment.Orgs { 34 for i := range subDepartment.Orgs {
@@ -10,6 +10,8 @@ import ( @@ -10,6 +10,8 @@ import (
10 type DepartmentsUsersQuery struct { 10 type DepartmentsUsersQuery struct {
11 //操作人 11 //操作人
12 Operator domain.Operator `json:"-"` 12 Operator domain.Operator `json:"-"`
  13 + // 类型0:部门用户列表 1:全部用户列表(不包含部门)
  14 + Type int `json:"type"`
13 } 15 }
14 16
15 func (departmentsUsersQuery *DepartmentsUsersQuery) Valid(validation *validation.Validation) { 17 func (departmentsUsersQuery *DepartmentsUsersQuery) Valid(validation *validation.Validation) {
@@ -31,7 +31,7 @@ func (srv OrgService) DepartmentsUsers(departmentsUsersQuery *query.DepartmentsU @@ -31,7 +31,7 @@ func (srv OrgService) DepartmentsUsers(departmentsUsersQuery *query.DepartmentsU
31 return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) 31 return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
32 } 32 }
33 departmentUsersDto := &dto.DepartmentUsersDto{} 33 departmentUsersDto := &dto.DepartmentUsersDto{}
34 - if err := departmentUsersDto.LoadDto(orgs, users); err != nil { 34 + if err := departmentUsersDto.LoadDto(departmentsUsersQuery.Type, orgs, users); err != nil {
35 return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) 35 return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
36 } 36 }
37 return departmentUsersDto, nil 37 return departmentUsersDto, nil
@@ -222,8 +222,8 @@ func (controller *CooperationController) PersonSearchCooperationProject() { @@ -222,8 +222,8 @@ func (controller *CooperationController) PersonSearchCooperationProject() {
222 return 222 return
223 } 223 }
224 cmd.Operator = controller.GetOperator() 224 cmd.Operator = controller.GetOperator()
225 - _, data, err := svr.PersonSearchCooperationProject(cmd)  
226 - controller.Response(data, err) 225 + total, data, err := svr.PersonSearchCooperationProject(cmd)
  226 + controller.ReturnPageListData(int64(total), data, err, cmd.PageNumber)
227 } 227 }
228 228
229 /***** CompanyCreditAccountService 企业端账期结算 *****/ 229 /***** CompanyCreditAccountService 企业端账期结算 *****/
@@ -34,6 +34,8 @@ func init() { @@ -34,6 +34,8 @@ func init() {
34 web.Router("/v1/app/cooperation-projects/search", &mobile_client.CooperationController{}, "Post:SearchCooperationProject") 34 web.Router("/v1/app/cooperation-projects/search", &mobile_client.CooperationController{}, "Post:SearchCooperationProject")
35 web.Router("/v1/app/cooperation-modes/", &web_client.CooperationModeController{}, "Get:ListCooperationMode") 35 web.Router("/v1/app/cooperation-modes/", &web_client.CooperationModeController{}, "Get:ListCooperationMode")
36 36
  37 + web.Router("/v1/app/cooperation-projects/person/search", &mobile_client.CooperationController{}, "Post:PersonSearchCooperationProject")
  38 +
37 /***** CompanyDividends 账期结算 *****/ 39 /***** CompanyDividends 账期结算 *****/
38 web.Router("/v1/app/company/credit-accounts/search", &mobile_client.CooperationController{}, "Post:CreditAccountSearch") 40 web.Router("/v1/app/company/credit-accounts/search", &mobile_client.CooperationController{}, "Post:CreditAccountSearch")
39 web.Router("/v1/app/company/credit-accounts/:creditId", &mobile_client.CooperationController{}, "Get:CreditAccountGet") 41 web.Router("/v1/app/company/credit-accounts/:creditId", &mobile_client.CooperationController{}, "Get:CreditAccountGet")