作者 yangfu

web用户部门列表修改

... ... @@ -18,6 +18,7 @@ type OrgItem struct {
type DepartmentUsersDto struct {
Departments []*Department `json:"departments,omitempty"`
Users []interface{} `json:"users,omitempty"`
Applicants []interface{} `json:"applicants,omitempty"`
}
type Department struct {
... ... @@ -30,6 +31,7 @@ type User struct {
UserID int `json:"userId,string"`
UserCode string `json:"userCode"`
UserInfo map[string]interface{} `json:"userInfo"`
Department interface{} `json:"department,omitempty"`
}
func (dto *DepartmentUsersDto) LoadDto(dataType int, subDepartment *allied_creation_user.DataOrgGetSubDepartment, userSearch *allied_creation_user.DataUserSearch) error {
... ...
... ... @@ -12,6 +12,8 @@ type DepartmentsUsersQuery struct {
Operator domain.Operator `json:"-"`
// 类型0:部门用户列表 1:全部用户列表(不包含部门)
Type int `json:"type"`
// 共创项目ID - 获取项目申请人列表
CooperationProjectId int `json:"cooperationProjectId,string"`
}
func (departmentsUsersQuery *DepartmentsUsersQuery) Valid(validation *validation.Validation) {
... ...
package service
import (
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_cooperation"
"strconv"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
... ... @@ -174,6 +175,43 @@ func (orgsService OrgsService) DepartmentsUsers(departmentsUsersQuery *query.Dep
if err := departmentUsersDto.LoadDto(departmentsUsersQuery.Type, orgs, users); err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
// 项目申请人
if departmentsUsersQuery.CooperationProjectId != 0 {
creationCooperationGateway := allied_creation_cooperation.NewHttplibAlliedCreationCooperation(departmentsUsersQuery.Operator)
resultProject, err := creationCooperationGateway.CooperationProjectGet(allied_creation_cooperation.ReqCooperationProjectGet{
CooperationProjectId: departmentsUsersQuery.CooperationProjectId,
})
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
resultApplication, err := creationCooperationGateway.CooperationApplicationsSearch(allied_creation_cooperation.ReqCooperationApplicationSearch{
CooperationProjectNumber: resultProject.CooperationProject.CooperationProjectNumber,
PageNumber: 0,
PageSize: 1000,
CompanyId: resultProject.Company.CompanyId,
OrgId: int64(resultProject.Org.OrgId),
})
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
applications := make([]interface{}, 0)
for i := range resultApplication.Grid.List {
item := resultApplication.Grid.List[i]
user := dto.User{
UserID: item.CooperationApplicationApplicant.UserID,
UserCode: item.CooperationApplicationApplicant.UserInfo.UserCode,
UserInfo: map[string]interface{}{
"userName": item.CooperationApplicationApplicant.UserInfo.UserName,
"phone": item.CooperationApplicationApplicant.UserInfo.UserPhone,
},
Department: item.CooperationApplicationApplicant.Department,
}
applications = append(applications, user)
}
departmentUsersDto.Applicants = applications
}
return departmentUsersDto, nil
}
... ...