作者 yangfu

共创申请修改

@@ -72,11 +72,11 @@ func (cooperationApplicationService *CooperationApplicationService) ListCooperat @@ -72,11 +72,11 @@ func (cooperationApplicationService *CooperationApplicationService) ListCooperat
72 return 0, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 72 return 0, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
73 } 73 }
74 var dataList []dto.CooperationApplicationItem 74 var dataList []dto.CooperationApplicationItem
75 - for i := range result.Gride.List {  
76 - item := dto.ToCooperationApplicationItem(&result.Gride.List[i]) 75 + for i := range result.Grid.List {
  76 + item := dto.ToCooperationApplicationItem(&result.Grid.List[i])
77 dataList = append(dataList, *item) 77 dataList = append(dataList, *item)
78 } 78 }
79 - return int64(result.Gride.Total), dataList, nil 79 + return int64(result.Grid.Total), dataList, nil
80 } 80 }
81 81
82 func NewCooperationApplicationService(options map[string]interface{}) *CooperationApplicationService { 82 func NewCooperationApplicationService(options map[string]interface{}) *CooperationApplicationService {
@@ -30,7 +30,7 @@ type CooperationProjectInfo struct { @@ -30,7 +30,7 @@ type CooperationProjectInfo struct {
30 CooperationProjectPublishTime time.Time `json:"cooperationProjectPublishTime"` 30 CooperationProjectPublishTime time.Time `json:"cooperationProjectPublishTime"`
31 CreatedAt time.Time `json:"createdAt"` 31 CreatedAt time.Time `json:"createdAt"`
32 CooperationProjectSponsor struct { 32 CooperationProjectSponsor struct {
33 - UsersId int `json:"userId"` 33 + UserId int `json:"userId,string"`
34 UsersName string `json:"userName"` 34 UsersName string `json:"userName"`
35 UsersCode string `json:"userCode"` 35 UsersCode string `json:"userCode"`
36 UserInfo struct { 36 UserInfo struct {
@@ -68,7 +68,7 @@ func ToCooperationProjectInfo(param *allied_creation_cooperation.CooperationProj @@ -68,7 +68,7 @@ func ToCooperationProjectInfo(param *allied_creation_cooperation.CooperationProj
68 68
69 data.CooperationProjectSponsor.UsersCode = param.CooperationProjectSponsor.UserInfo.UsersCode 69 data.CooperationProjectSponsor.UsersCode = param.CooperationProjectSponsor.UserInfo.UsersCode
70 data.CooperationProjectSponsor.UsersName = param.CooperationProjectSponsor.UserInfo.UsersName 70 data.CooperationProjectSponsor.UsersName = param.CooperationProjectSponsor.UserInfo.UsersName
71 - data.CooperationProjectSponsor.UsersId = param.CooperationProjectSponsor.UsersId 71 + data.CooperationProjectSponsor.UserId = param.CooperationProjectSponsor.UsersId
72 data.CooperationProjectSponsor.UserInfo = param.CooperationProjectSponsor.UserInfo 72 data.CooperationProjectSponsor.UserInfo = param.CooperationProjectSponsor.UserInfo
73 return &data 73 return &data
74 } 74 }
@@ -89,8 +89,8 @@ func (cooperationProjectService *CooperationProjectService) GetCooperationProjec @@ -89,8 +89,8 @@ func (cooperationProjectService *CooperationProjectService) GetCooperationProjec
89 var ( 89 var (
90 applications []dto.CooperationApplicationItem 90 applications []dto.CooperationApplicationItem
91 ) 91 )
92 - for i := range resultApplication.Gride.List {  
93 - item := dto.ToCooperationApplicationItem(&resultApplication.Gride.List[i]) 92 + for i := range resultApplication.Grid.List {
  93 + item := dto.ToCooperationApplicationItem(&resultApplication.Grid.List[i])
94 applications = append(applications, *item) 94 applications = append(applications, *item)
95 } 95 }
96 data := map[string]interface{}{ 96 data := map[string]interface{}{
  1 +package dto
  2 +
  3 +import "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_user"
  4 +
  5 +type DepartmentUsersDto struct {
  6 + Departments []*Department `json:"departments"`
  7 +}
  8 +
  9 +type Department struct {
  10 + DepartmentID int64 `json:"departmentId,string"`
  11 + DepartmentName string `json:"departmentName"`
  12 + Users []User `json:"users"`
  13 +}
  14 +type User struct {
  15 + UserID int `json:"userId,string"`
  16 + UserInfo map[string]interface{} `json:"userInfo"`
  17 +}
  18 +
  19 +func (dto *DepartmentUsersDto) LoadDto(subDepartment *allied_creation_user.DataOrgGetSubDepartment, userSearch *allied_creation_user.DataUserSearch) error {
  20 + var mapDepartment = make(map[int64]*Department)
  21 +
  22 + for i := range subDepartment.Orgs {
  23 + org := subDepartment.Orgs[i]
  24 + dep := &Department{
  25 + DepartmentID: int64(org.OrgID),
  26 + DepartmentName: org.OrgName,
  27 + Users: make([]User, 0),
  28 + }
  29 + dto.Departments = append(dto.Departments, dep)
  30 + mapDepartment[dep.DepartmentID] = dep
  31 + }
  32 +
  33 + for i := range userSearch.Users {
  34 + user := userSearch.Users[i]
  35 + if user.Department == nil {
  36 + continue
  37 + }
  38 + if v, ok := mapDepartment[int64(user.Department.DepartmentId)]; ok {
  39 + v.Users = append(v.Users, User{
  40 + UserID: user.UserId,
  41 + UserInfo: map[string]interface{}{
  42 + "userName": user.UserInfo.UserName,
  43 + },
  44 + })
  45 + }
  46 + }
  47 + return nil
  48 +}
  1 +package query
  2 +
  3 +import (
  4 + "fmt"
  5 + "github.com/beego/beego/v2/core/validation"
  6 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
  7 +)
  8 +
  9 +//获取自定义菜单列表
  10 +type DepartmentsUsersQuery struct {
  11 + //操作人
  12 + Operator domain.Operator `json:"-"`
  13 +}
  14 +
  15 +func (departmentsUsersQuery *DepartmentsUsersQuery) Valid(validation *validation.Validation) {
  16 +
  17 +}
  18 +
  19 +func (departmentsUsersQuery *DepartmentsUsersQuery) ValidateQuery() error {
  20 + valid := validation.Validation{}
  21 + b, err := valid.Valid(departmentsUsersQuery)
  22 + if err != nil {
  23 + return err
  24 + }
  25 + if !b {
  26 + for _, validErr := range valid.Errors {
  27 + return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
  28 + }
  29 + }
  30 + return nil
  31 +}
@@ -147,6 +147,33 @@ func (orgsService *OrgsService) OrgGetSubDepartment(orgGetQuery *query.OrgGetSub @@ -147,6 +147,33 @@ func (orgsService *OrgsService) OrgGetSubDepartment(orgGetQuery *query.OrgGetSub
147 }, nil 147 }, nil
148 } 148 }
149 149
  150 +//DepartmentsUsers 部门用户列表
  151 +func (orgsService OrgsService) DepartmentsUsers(departmentsUsersQuery *query.DepartmentsUsersQuery) (interface{}, error) {
  152 + creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(
  153 + departmentsUsersQuery.Operator)
  154 + orgs, err := creationUserGateway.OrgGetSubDepartment(allied_creation_user.ReqOrgGetSubDepartment{
  155 + OrgId: departmentsUsersQuery.Operator.OrgId,
  156 + })
  157 + if err != nil {
  158 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  159 + }
  160 +
  161 + users, err := creationUserGateway.UserSearch(allied_creation_user.ReqUserSearch{
  162 + //Offset: 0,
  163 + //Limit: 999,
  164 + CompanyId: departmentsUsersQuery.Operator.CompanyId,
  165 + OrganizationId: departmentsUsersQuery.Operator.OrgId,
  166 + })
  167 + if err != nil {
  168 + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
  169 + }
  170 + departmentUsersDto := &dto.DepartmentUsersDto{}
  171 + if err := departmentUsersDto.LoadDto(orgs, users); err != nil {
  172 + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
  173 + }
  174 + return departmentUsersDto, nil
  175 +}
  176 +
150 func NewOrgsService(options map[string]interface{}) *OrgsService { 177 func NewOrgsService(options map[string]interface{}) *OrgsService {
151 newOrgsService := &OrgsService{} 178 newOrgsService := &OrgsService{}
152 return newOrgsService 179 return newOrgsService
@@ -227,10 +227,10 @@ type ( @@ -227,10 +227,10 @@ type (
227 } 227 }
228 228
229 DataCooperationApplicationSearch struct { 229 DataCooperationApplicationSearch struct {
230 - Gride struct { 230 + Grid struct {
231 Total int `json:"total"` 231 Total int `json:"total"`
232 List []CooperationApplication `json:"list"` 232 List []CooperationApplication `json:"list"`
233 - } `json:"gride"` 233 + } `json:"grid"`
234 } 234 }
235 ) 235 )
236 236
@@ -52,7 +52,7 @@ type CooperationProject struct { @@ -52,7 +52,7 @@ type CooperationProject struct {
52 UsersId int `json:"userId,string"` 52 UsersId int `json:"userId,string"`
53 } `json:"userInfo"` 53 } `json:"userInfo"`
54 } `json:"cooperationProjectSponsor"` //项目发起人 54 } `json:"cooperationProjectSponsor"` //项目发起人
55 - CooperationProjectUndertakerType []int `json:"cooperationProjectUndertakerType"` //共创合约承接对象,1员工,2共创用户,3公开 55 + CooperationProjectUndertakerType []int `json:"cooperationProjectUndertakerTypes"` //共创合约承接对象,1员工,2共创用户,3公开
56 Department struct { 56 Department struct {
57 DepartmentNumber string `json:"departmentNumber"` 57 DepartmentNumber string `json:"departmentNumber"`
58 DepartmentId int `json:"departmentId,string,"` 58 DepartmentId int `json:"departmentId,string,"`
@@ -95,7 +95,7 @@ type ( @@ -95,7 +95,7 @@ type (
95 } 95 }
96 96
97 DataCooperationProjectGet struct { 97 DataCooperationProjectGet struct {
98 - CooperationProject CooperationProject `json:"cooperationProject"` 98 + CooperationProject
99 } 99 }
100 ) 100 )
101 101
@@ -108,7 +108,7 @@ type ( @@ -108,7 +108,7 @@ type (
108 CooperationProjectName string `json:"cooperationProjectName"` 108 CooperationProjectName string `json:"cooperationProjectName"`
109 CooperationModeNumber string `json:"cooperationModeNumber"` 109 CooperationModeNumber string `json:"cooperationModeNumber"`
110 // 承接对象,1员工,2共创用户,3公开,可以多选 110 // 承接对象,1员工,2共创用户,3公开,可以多选
111 - CooperationProjectUndertakerType []int32 `json:"cooperationProjectUndertakerType"` 111 + CooperationProjectUndertakerType []int32 `json:"cooperationProjectUndertakerTypes"`
112 // 共创项目发起人uid 112 // 共创项目发起人uid
113 SponsorUid string `json:"sponsorUid"` 113 SponsorUid string `json:"sponsorUid"`
114 // 共创项目发布人uid 114 // 共创项目发布人uid
@@ -82,3 +82,16 @@ func (controller *OrgsController) OrgGetSubDepartment() { @@ -82,3 +82,16 @@ func (controller *OrgsController) OrgGetSubDepartment() {
82 data, err := orgsService.OrgGetSubDepartment(orgGetSubDepartmentQuery) 82 data, err := orgsService.OrgGetSubDepartment(orgGetSubDepartmentQuery)
83 controller.Response(data, err) 83 controller.Response(data, err)
84 } 84 }
  85 +
  86 +func (controller *OrgsController) DepartmentUsers() {
  87 + orgService := service.OrgsService{}
  88 + departmentsUsersQuery := &query.DepartmentsUsersQuery{}
  89 + err := controller.Unmarshal(departmentsUsersQuery)
  90 + if err != nil {
  91 + controller.Response(nil, err)
  92 + return
  93 + }
  94 + departmentsUsersQuery.Operator = controller.GetOperator()
  95 + data, err := orgService.DepartmentsUsers(departmentsUsersQuery)
  96 + controller.Response(data, err)
  97 +}
@@ -2,7 +2,6 @@ package routers @@ -2,7 +2,6 @@ package routers
2 2
3 import ( 3 import (
4 "github.com/beego/beego/v2/server/web" 4 "github.com/beego/beego/v2/server/web"
5 - "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/port/beego/controllers/mobile_client"  
6 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/port/beego/controllers/web_client" 5 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/port/beego/controllers/web_client"
7 ) 6 )
8 7
@@ -13,5 +12,5 @@ func init() { @@ -13,5 +12,5 @@ func init() {
13 web.Router("/v1/web/orgs/:orgId", &web_client.OrgsController{}, "Get:OrgGet") 12 web.Router("/v1/web/orgs/:orgId", &web_client.OrgsController{}, "Get:OrgGet")
14 web.Router("/v1/web/orgs/enable", &web_client.OrgsController{}, "Post:OrgEnable") 13 web.Router("/v1/web/orgs/enable", &web_client.OrgsController{}, "Post:OrgEnable")
15 web.Router("/v1/web/orgs/departments", &web_client.OrgsController{}, "Post:OrgGetSubDepartment") 14 web.Router("/v1/web/orgs/departments", &web_client.OrgsController{}, "Post:OrgGetSubDepartment")
16 - web.Router("/v1/web/orgs/department-users", &mobile_client.OrgController{}, "Post:DepartmentUsers") 15 + web.Router("/v1/web/orgs/department-users", &web_client.OrgsController{}, "Post:DepartmentUsers")
17 } 16 }