作者 yangfu

web用户部门列表修改

@@ -18,6 +18,7 @@ type OrgItem struct { @@ -18,6 +18,7 @@ type OrgItem struct {
18 type DepartmentUsersDto struct { 18 type DepartmentUsersDto struct {
19 Departments []*Department `json:"departments,omitempty"` 19 Departments []*Department `json:"departments,omitempty"`
20 Users []interface{} `json:"users,omitempty"` 20 Users []interface{} `json:"users,omitempty"`
  21 + Applicants []interface{} `json:"applicants,omitempty"`
21 } 22 }
22 23
23 type Department struct { 24 type Department struct {
@@ -27,9 +28,10 @@ type Department struct { @@ -27,9 +28,10 @@ type Department struct {
27 } 28 }
28 29
29 type User struct { 30 type User struct {
30 - UserID int `json:"userId,string"`  
31 - UserCode string `json:"userCode"`  
32 - UserInfo map[string]interface{} `json:"userInfo"` 31 + UserID int `json:"userId,string"`
  32 + UserCode string `json:"userCode"`
  33 + UserInfo map[string]interface{} `json:"userInfo"`
  34 + Department interface{} `json:"department,omitempty"`
33 } 35 }
34 36
35 func (dto *DepartmentUsersDto) LoadDto(dataType int, subDepartment *allied_creation_user.DataOrgGetSubDepartment, userSearch *allied_creation_user.DataUserSearch) error { 37 func (dto *DepartmentUsersDto) LoadDto(dataType int, subDepartment *allied_creation_user.DataOrgGetSubDepartment, userSearch *allied_creation_user.DataUserSearch) error {
@@ -12,6 +12,8 @@ type DepartmentsUsersQuery struct { @@ -12,6 +12,8 @@ type DepartmentsUsersQuery struct {
12 Operator domain.Operator `json:"-"` 12 Operator domain.Operator `json:"-"`
13 // 类型0:部门用户列表 1:全部用户列表(不包含部门) 13 // 类型0:部门用户列表 1:全部用户列表(不包含部门)
14 Type int `json:"type"` 14 Type int `json:"type"`
  15 + // 共创项目ID - 获取项目申请人列表
  16 + CooperationProjectId int `json:"cooperationProjectId,string"`
15 } 17 }
16 18
17 func (departmentsUsersQuery *DepartmentsUsersQuery) Valid(validation *validation.Validation) { 19 func (departmentsUsersQuery *DepartmentsUsersQuery) Valid(validation *validation.Validation) {
1 package service 1 package service
2 2
3 import ( 3 import (
  4 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_cooperation"
4 "strconv" 5 "strconv"
5 6
6 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain" 7 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
@@ -174,6 +175,43 @@ func (orgsService OrgsService) DepartmentsUsers(departmentsUsersQuery *query.Dep @@ -174,6 +175,43 @@ func (orgsService OrgsService) DepartmentsUsers(departmentsUsersQuery *query.Dep
174 if err := departmentUsersDto.LoadDto(departmentsUsersQuery.Type, orgs, users); err != nil { 175 if err := departmentUsersDto.LoadDto(departmentsUsersQuery.Type, orgs, users); err != nil {
175 return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) 176 return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
176 } 177 }
  178 +
  179 + // 项目申请人
  180 + if departmentsUsersQuery.CooperationProjectId != 0 {
  181 + creationCooperationGateway := allied_creation_cooperation.NewHttplibAlliedCreationCooperation(departmentsUsersQuery.Operator)
  182 + resultProject, err := creationCooperationGateway.CooperationProjectGet(allied_creation_cooperation.ReqCooperationProjectGet{
  183 + CooperationProjectId: departmentsUsersQuery.CooperationProjectId,
  184 + })
  185 + if err != nil {
  186 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  187 + }
  188 + resultApplication, err := creationCooperationGateway.CooperationApplicationsSearch(allied_creation_cooperation.ReqCooperationApplicationSearch{
  189 + CooperationProjectNumber: resultProject.CooperationProject.CooperationProjectNumber,
  190 + PageNumber: 0,
  191 + PageSize: 1000,
  192 + CompanyId: resultProject.Company.CompanyId,
  193 + OrgId: int64(resultProject.Org.OrgId),
  194 + })
  195 + if err != nil {
  196 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  197 + }
  198 + applications := make([]interface{}, 0)
  199 + for i := range resultApplication.Grid.List {
  200 + item := resultApplication.Grid.List[i]
  201 + user := dto.User{
  202 + UserID: item.CooperationApplicationApplicant.UserID,
  203 + UserCode: item.CooperationApplicationApplicant.UserInfo.UserCode,
  204 + UserInfo: map[string]interface{}{
  205 + "userName": item.CooperationApplicationApplicant.UserInfo.UserName,
  206 + "phone": item.CooperationApplicationApplicant.UserInfo.UserPhone,
  207 + },
  208 + Department: item.CooperationApplicationApplicant.Department,
  209 + }
  210 + applications = append(applications, user)
  211 + }
  212 + departmentUsersDto.Applicants = applications
  213 + }
  214 +
177 return departmentUsersDto, nil 215 return departmentUsersDto, nil
178 } 216 }
179 217