作者 tangxuhui
1 package service 1 package service
2 2
3 import ( 3 import (
4 - "errors"  
5 "time" 4 "time"
6 5
7 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/log" 6 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/log"
@@ -30,7 +29,7 @@ func (srv AuthService) AuthLogin(loginCommand *command.LoginCommand) (interface{ @@ -30,7 +29,7 @@ func (srv AuthService) AuthLogin(loginCommand *command.LoginCommand) (interface{
30 Phone: loginCommand.Phone, 29 Phone: loginCommand.Phone,
31 }) 30 })
32 if err != nil { 31 if err != nil {
33 - return nil, application.ThrowError(application.TRANSACTION_ERROR, "系统错误") 32 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
34 } 33 }
35 switch loginCommand.GrantType { 34 switch loginCommand.GrantType {
36 case "signInPassword": 35 case "signInPassword":
@@ -38,7 +37,7 @@ func (srv AuthService) AuthLogin(loginCommand *command.LoginCommand) (interface{ @@ -38,7 +37,7 @@ func (srv AuthService) AuthLogin(loginCommand *command.LoginCommand) (interface{
38 case "signInCaptcha": 37 case "signInCaptcha":
39 result, err = srv.SignInCaptcha(loginCommand.Phone, loginCommand.Captcha) 38 result, err = srv.SignInCaptcha(loginCommand.Phone, loginCommand.Captcha)
40 default: 39 default:
41 - err = errors.New("登录方式无法解析") 40 + err = application.ThrowError(application.TRANSACTION_ERROR, "登录方式无法解析")
42 } 41 }
43 return result, err 42 return result, err
44 } 43 }
@@ -17,7 +17,7 @@ type CreateCooperationProjectCommand struct { @@ -17,7 +17,7 @@ type CreateCooperationProjectCommand struct {
17 // 共创项目名称 17 // 共创项目名称
18 CooperationProjectName string `json:"cooperationProjectName" valid:"Required"` 18 CooperationProjectName string `json:"cooperationProjectName" valid:"Required"`
19 // 共创发起人id 19 // 共创发起人id
20 - CooperationProjectSponsor int `json:"cooperationProjectSponsor,string,"` 20 + CooperationProjectSponsor int `json:"cooperationProjectSponsor"`
21 // 项目承接对象 21 // 项目承接对象
22 CooperationProjectUndertakerType []int `json:"cooperationProjectUndertakerType"` 22 CooperationProjectUndertakerType []int `json:"cooperationProjectUndertakerType"`
23 // 共创项目描述 23 // 共创项目描述
@@ -13,9 +13,9 @@ type UpdateCooperationProjectCommand struct { @@ -13,9 +13,9 @@ type UpdateCooperationProjectCommand struct {
13 // 共创项目ID 13 // 共创项目ID
14 CooperationProjectId string `json:"cooperationProjectId,string" valid:"Required"` 14 CooperationProjectId string `json:"cooperationProjectId,string" valid:"Required"`
15 // 模式编码,唯一确定 15 // 模式编码,唯一确定
16 - CooperationModeNumber string `json:"cooperationModeNumber" valid:"Required"` 16 + //CooperationModeNumber string `json:"cooperationModeNumber" valid:"Required"`
17 // 组织ID 17 // 组织ID
18 - OrgId string `json:"orgId" valid:"Required"` 18 + OrgId int64 `json:"departmentId,string" valid:"Required"`
19 // 共创项目名称 19 // 共创项目名称
20 CooperationProjectName string `json:"cooperationProjectName" valid:"Required"` 20 CooperationProjectName string `json:"cooperationProjectName" valid:"Required"`
21 // 共创发起人id 21 // 共创发起人id
@@ -28,6 +28,7 @@ func (srv CooperationProjectService) CreateCooperationProject(createCooperationP @@ -28,6 +28,7 @@ func (srv CooperationProjectService) CreateCooperationProject(createCooperationP
28 } 28 }
29 result, err := creationCooperationGateway.CooperationProjectAdd(allied_creation_cooperation.ReqCooperationProjectAdd{ 29 result, err := creationCooperationGateway.CooperationProjectAdd(allied_creation_cooperation.ReqCooperationProjectAdd{
30 CooperationProjectDescription: createCooperationProjectCommand.CooperationProjectDescription, 30 CooperationProjectDescription: createCooperationProjectCommand.CooperationProjectDescription,
  31 + CooperationModeNumber: createCooperationProjectCommand.CooperationModeNumber,
31 CooperationProjectName: createCooperationProjectCommand.CooperationProjectName, 32 CooperationProjectName: createCooperationProjectCommand.CooperationProjectName,
32 PublisherUid: int(createCooperationProjectCommand.Operator.UserId), 33 PublisherUid: int(createCooperationProjectCommand.Operator.UserId),
33 SponsorUid: createCooperationProjectCommand.CooperationProjectSponsor, 34 SponsorUid: createCooperationProjectCommand.CooperationProjectSponsor,
@@ -72,14 +73,15 @@ func (srv CooperationProjectService) UpdateCooperationProject(updateCooperationP @@ -72,14 +73,15 @@ func (srv CooperationProjectService) UpdateCooperationProject(updateCooperationP
72 }) 73 })
73 } 74 }
74 _, err := creationCooperationGateway.CooperationProjectUpdate(allied_creation_cooperation.ReqCooperationProjectUpdate{ 75 _, err := creationCooperationGateway.CooperationProjectUpdate(allied_creation_cooperation.ReqCooperationProjectUpdate{
75 - CooperationProjectId: updateCooperationProjectCommand.CooperationProjectId,  
76 - CooperationProjectName: updateCooperationProjectCommand.CooperationProjectName,  
77 - CooperationModeNumber: updateCooperationProjectCommand.CooperationModeNumber, 76 + CooperationProjectId: updateCooperationProjectCommand.CooperationProjectId,
  77 + CooperationProjectName: updateCooperationProjectCommand.CooperationProjectName,
  78 + //CooperationModeNumber: updateCooperationProjectCommand.CooperationModeNumber,
78 CooperationProjectUndertakerType: updateCooperationProjectCommand.CooperationProjectUndertakerType, 79 CooperationProjectUndertakerType: updateCooperationProjectCommand.CooperationProjectUndertakerType,
79 SponsorUid: updateCooperationProjectCommand.CooperationProjectSponsor, 80 SponsorUid: updateCooperationProjectCommand.CooperationProjectSponsor,
80 PublisherUid: strconv.Itoa(int(updateCooperationProjectCommand.Operator.UserId)), 81 PublisherUid: strconv.Itoa(int(updateCooperationProjectCommand.Operator.UserId)),
81 CooperationProjectDescription: updateCooperationProjectCommand.CooperationProjectDescription, 82 CooperationProjectDescription: updateCooperationProjectCommand.CooperationProjectDescription,
82 Attachment: images, 83 Attachment: images,
  84 + OrgId: updateCooperationProjectCommand.OrgId,
83 }) 85 })
84 if err != nil { 86 if err != nil {
85 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 87 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
@@ -116,12 +118,12 @@ func (srv CooperationProjectService) SearchCooperationProject(projectQuery *comm @@ -116,12 +118,12 @@ func (srv CooperationProjectService) SearchCooperationProject(projectQuery *comm
116 if err != nil { 118 if err != nil {
117 return 0, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 119 return 0, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
118 } 120 }
119 - var dataList []dto.CooperationProjectItem  
120 - for i := range result.List {  
121 - item := dto.ToCooperationProjectItem(&result.List[i])  
122 - dataList = append(dataList, *item)  
123 - }  
124 - return int(result.Total), dataList, nil 121 + //var dataList []dto.CooperationProjectItem
  122 + //for i := range result.List {
  123 + // item := dto.ToCooperationProjectItem(&result.List[i])
  124 + // dataList = append(dataList, *item)
  125 + //}
  126 + return int(result.Total), result.List, nil
125 } 127 }
126 128
127 // PersonSearchCooperationProject 共创用户获取共创项目列表 129 // PersonSearchCooperationProject 共创用户获取共创项目列表
@@ -137,10 +139,10 @@ func (srv CooperationProjectService) PersonSearchCooperationProject(projectQuery @@ -137,10 +139,10 @@ func (srv CooperationProjectService) PersonSearchCooperationProject(projectQuery
137 if err != nil { 139 if err != nil {
138 return 0, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 140 return 0, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
139 } 141 }
140 - var dataList []dto.CooperationProjectItem  
141 - for i := range result.List {  
142 - item := dto.ToCooperationProjectItem(&result.List[i])  
143 - dataList = append(dataList, *item)  
144 - }  
145 - return int(result.Total), dataList, nil 142 + //var dataList []dto.CooperationProjectItem
  143 + //for i := range result.List {
  144 + // item := dto.ToCooperationProjectItem(&result.List[i])
  145 + // dataList = append(dataList, *item)
  146 + //}
  147 + return int(result.Total), result, nil
146 } 148 }
@@ -42,7 +42,7 @@ func (srv AuthService) SignInPassword(account string, password string) (interfac @@ -42,7 +42,7 @@ func (srv AuthService) SignInPassword(account string, password string) (interfac
42 Phone: account, 42 Phone: account,
43 }) 43 })
44 if err != nil { 44 if err != nil {
45 - return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 45 + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
46 } 46 }
47 ltoken := domain.LoginToken{ 47 ltoken := domain.LoginToken{
48 UserId: 0, 48 UserId: 0,
@@ -52,7 +52,7 @@ func (srv AuthService) SignInPassword(account string, password string) (interfac @@ -52,7 +52,7 @@ func (srv AuthService) SignInPassword(account string, password string) (interfac
52 } 52 }
53 authcode, err := ltoken.GenerateAuthCode() 53 authcode, err := ltoken.GenerateAuthCode()
54 if err != nil { 54 if err != nil {
55 - return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 55 + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
56 } 56 }
57 result := map[string]string{ 57 result := map[string]string{
58 "authCode": authcode, 58 "authCode": authcode,
@@ -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 {
@@ -11,11 +11,11 @@ type UpdateCooperationProjectCommand struct { @@ -11,11 +11,11 @@ type UpdateCooperationProjectCommand struct {
11 //操作人 11 //操作人
12 Operator domain.Operator `json:"-"` 12 Operator domain.Operator `json:"-"`
13 // 共创项目ID 13 // 共创项目ID
14 - CooperationProjectId string `json:"cooperationProjectId,string" valid:"Required"` 14 + CooperationProjectId string `json:"cooperationProjectId" valid:"Required"`
15 // 模式编码,唯一确定 15 // 模式编码,唯一确定
16 CooperationModeNumber string `json:"cooperationModeNumber" valid:"Required"` 16 CooperationModeNumber string `json:"cooperationModeNumber" valid:"Required"`
17 // 组织ID 17 // 组织ID
18 - OrgId string `json:"orgId" valid:"Required"` 18 + OrgId int64 `json:"departmentId,string" valid:"Required"`
19 // 共创项目名称 19 // 共创项目名称
20 CooperationProjectName string `json:"cooperationProjectName" valid:"Required"` 20 CooperationProjectName string `json:"cooperationProjectName" valid:"Required"`
21 // 共创发起人id 21 // 共创发起人id
@@ -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{}{
@@ -117,15 +117,15 @@ func (cooperationProjectService *CooperationProjectService) ListCooperationProje @@ -117,15 +117,15 @@ func (cooperationProjectService *CooperationProjectService) ListCooperationProje
117 if err != nil { 117 if err != nil {
118 return 0, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 118 return 0, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
119 } 119 }
120 -  
121 - var (  
122 - dataList = []dto.CooperationProjectInfo{}  
123 - )  
124 - for i := range result.List {  
125 - item := dto.ToCooperationProjectInfo(&result.List[i])  
126 - dataList = append(dataList, *item)  
127 - }  
128 - return result.Total, dataList, nil 120 + //
  121 + //var (
  122 + // dataList = []dto.CooperationProjectInfo{}
  123 + //)
  124 + //for i := range result.List {
  125 + // item := dto.ToCooperationProjectInfo(&result.List[i])
  126 + // dataList = append(dataList, *item)
  127 + //}
  128 + return int64(result.Total), result.List, nil
129 } 129 }
130 130
131 // 更新共创项目管理 131 // 更新共创项目管理
@@ -149,6 +149,9 @@ func (cooperationProjectService *CooperationProjectService) UpdateCooperationPro @@ -149,6 +149,9 @@ func (cooperationProjectService *CooperationProjectService) UpdateCooperationPro
149 PublisherUid: strconv.Itoa(int(updateCooperationProjectCommand.Operator.UserId)), 149 PublisherUid: strconv.Itoa(int(updateCooperationProjectCommand.Operator.UserId)),
150 CooperationProjectDescription: updateCooperationProjectCommand.CooperationProjectDescription, 150 CooperationProjectDescription: updateCooperationProjectCommand.CooperationProjectDescription,
151 Attachment: images, 151 Attachment: images,
  152 + UserId: updateCooperationProjectCommand.Operator.UserId,
  153 + UserBaseId: updateCooperationProjectCommand.Operator.UserBaseId,
  154 + OrgId: updateCooperationProjectCommand.OrgId,
152 }) 155 })
153 if err != nil { 156 if err != nil {
154 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 157 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  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
@@ -104,7 +104,7 @@ func (gateway HttplibAlliedCreationCooperation) CooperationProjectGet(param ReqC @@ -104,7 +104,7 @@ func (gateway HttplibAlliedCreationCooperation) CooperationProjectGet(param ReqC
104 104
105 // CooperationProjectUpdate 更新共创项目 105 // CooperationProjectUpdate 更新共创项目
106 func (gateway HttplibAlliedCreationCooperation) CooperationProjectUpdate(param ReqCooperationProjectUpdate) (*DataCooperationProjectUpdate, error) { 106 func (gateway HttplibAlliedCreationCooperation) CooperationProjectUpdate(param ReqCooperationProjectUpdate) (*DataCooperationProjectUpdate, error) {
107 - url := gateway.baseUrL + "/cooperation-projects/{cooperationProjectId}" 107 + url := gateway.baseUrL + "/cooperation-projects/" + param.CooperationProjectId
108 method := "PUT" 108 method := "PUT"
109 req := gateway.CreateRequest(url, method) 109 req := gateway.CreateRequest(url, method)
110 log.Logger.Debug("向业务模块请求数据:更新共创项目。", map[string]interface{}{ 110 log.Logger.Debug("向业务模块请求数据:更新共创项目。", map[string]interface{}{
@@ -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
@@ -2,6 +2,7 @@ package allied_creation_cooperation @@ -2,6 +2,7 @@ package allied_creation_cooperation
2 2
3 import ( 3 import (
4 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain" 4 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
  5 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/util/jtime"
5 "time" 6 "time"
6 ) 7 )
7 8
@@ -51,7 +52,7 @@ type CooperationProject struct { @@ -51,7 +52,7 @@ type CooperationProject struct {
51 UsersId int `json:"userId,string"` 52 UsersId int `json:"userId,string"`
52 } `json:"userInfo"` 53 } `json:"userInfo"`
53 } `json:"cooperationProjectSponsor"` //项目发起人 54 } `json:"cooperationProjectSponsor"` //项目发起人
54 - CooperationProjectUndertakerType []int `json:"cooperationProjectUndertakerType"` //共创合约承接对象,1员工,2共创用户,3公开 55 + CooperationProjectUndertakerType []int `json:"cooperationProjectUndertakerTypes"` //共创合约承接对象,1员工,2共创用户,3公开
55 Department struct { 56 Department struct {
56 DepartmentNumber string `json:"departmentNumber"` 57 DepartmentNumber string `json:"departmentNumber"`
57 DepartmentId int `json:"departmentId,string,"` 58 DepartmentId int `json:"departmentId,string,"`
@@ -94,7 +95,7 @@ type ( @@ -94,7 +95,7 @@ type (
94 } 95 }
95 96
96 DataCooperationProjectGet struct { 97 DataCooperationProjectGet struct {
97 - CooperationProject CooperationProject `json:"cooperationProject"` 98 + CooperationProject
98 } 99 }
99 ) 100 )
100 101
@@ -115,6 +116,12 @@ type ( @@ -115,6 +116,12 @@ type (
115 // 共创项目描述 116 // 共创项目描述
116 CooperationProjectDescription string `json:"cooperationProjectDescription"` 117 CooperationProjectDescription string `json:"cooperationProjectDescription"`
117 Attachment []domain.Attachment `json:"attachment"` 118 Attachment []domain.Attachment `json:"attachment"`
  119 + // 组织机构ID
  120 + OrgId int64 `cname:"组织机构ID" json:"orgId,string" valid:"Required"`
  121 + // 用户ID,通过集成REST上下文获取,可翻译成发起人、承接人、推荐人、业务员
  122 + UserId int64 `cname:"用户ID" json:"userId,string" valid:"Required"`
  123 + // 用户基础数据id
  124 + UserBaseId int64 `cname:"用户基础数据ID" json:"userBaseId,string" valid:"Required"`
118 } 125 }
119 126
120 DataCooperationProjectUpdate struct { 127 DataCooperationProjectUpdate struct {
@@ -157,8 +164,86 @@ type ( @@ -157,8 +164,86 @@ type (
157 } 164 }
158 165
159 DataCooperationProjectSearch struct { 166 DataCooperationProjectSearch struct {
160 - Total int64 `json:"total"`  
161 - List []CooperationProject `json:"cooperationProjects"` 167 + //Total int64 `json:"total"`
  168 + //List []CooperationProject `json:"cooperationProjects"`
  169 + List []struct {
  170 + CooperationProjectID string `json:"cooperationProjectId"`
  171 + CooperationProjectNumber string `json:"cooperationProjectNumber"`
  172 + CooperationProjectDescription string `json:"cooperationProjectDescription"`
  173 + CooperationProjectName string `json:"cooperationProjectName"`
  174 + CooperationProjectPublishTime jtime.TimeToUnixMsec `json:"cooperationProjectPublishTime"`
  175 + CooperationProjectPublisher struct {
  176 + UserID string `json:"userId"`
  177 + UserBaseID string `json:"userBaseId"`
  178 + Department interface{} `json:"department"`
  179 + UserInfo struct {
  180 + UserAvatar string `json:"userAvatar"`
  181 + UserEmail string `json:"userEmail"`
  182 + UserName string `json:"userName"`
  183 + UserPhone string `json:"userPhone"`
  184 + UserAccount string `json:"userAccount"`
  185 + } `json:"userInfo"`
  186 + //UserType int `json:"userType"`
  187 + //UserName string `json:"userName"`
  188 + //UserPhone string `json:"userPhone"`
  189 + //Status int `json:"status"`
  190 + } `json:"cooperationProjectPublisher"`
  191 + CooperationProjectSponsor struct {
  192 + UserID string `json:"userId"`
  193 + UserBaseID string `json:"userBaseId"`
  194 + Department interface{} `json:"department"`
  195 + UserInfo struct {
  196 + UserAvatar string `json:"userAvatar"`
  197 + UserEmail string `json:"userEmail"`
  198 + UserName string `json:"userName"`
  199 + UserPhone string `json:"userPhone"`
  200 + UserAccount string `json:"userAccount"`
  201 + } `json:"userInfo"`
  202 + //UserType int `json:"userType"`
  203 + //UserName string `json:"userName"`
  204 + //UserPhone string `json:"userPhone"`
  205 + //Status int `json:"status"`
  206 + } `json:"cooperationProjectSponsor"`
  207 + Department struct {
  208 + DepartmentID string `json:"departmentId"`
  209 + DepartmentName string `json:"departmentName"`
  210 + DepartmentNumber string `json:"departmentNumber"`
  211 + //IsOrganization bool `json:"isOrganization"`
  212 + } `json:"department"`
  213 + CooperationProjectUndertakerTypes []int `json:"cooperationProjectUndertakerTypes"`
  214 + Org struct {
  215 + OrgID string `json:"orgId"`
  216 + OrgName string `json:"orgName"`
  217 + } `json:"org"`
  218 + Attachment interface{} `json:"attachment"`
  219 + Company struct {
  220 + CompanyID string `json:"companyId"`
  221 + CompanyLogo string `json:"companyLogo"`
  222 + CompanyName string `json:"companyName"`
  223 + } `json:"company"`
  224 + Operator struct {
  225 + UserID string `json:"userId"`
  226 + UserBaseID string `json:"userBaseId"`
  227 + Department interface{} `json:"department"`
  228 + UserInfo struct {
  229 + UserAvatar string `json:"userAvatar"`
  230 + UserEmail string `json:"userEmail"`
  231 + UserName string `json:"userName"`
  232 + UserPhone string `json:"userPhone"`
  233 + UserAccount string `json:"userAccount"`
  234 + } `json:"userInfo"`
  235 + //UserType int `json:"userType"`
  236 + //UserName string `json:"userName"`
  237 + //UserPhone string `json:"userPhone"`
  238 + //Status int `json:"status"`
  239 + } `json:"operator"`
  240 + //OperateTime time.Time `json:"operateTime"`
  241 + Status int `json:"status"`
  242 + //UpdatedAt time.Time `json:"updatedAt"`
  243 + //DeletedAt time.Time `json:"deletedAt"`
  244 + //CreatedAt time.Time `json:"createdAt"`
  245 + } `json:"list"`
  246 + Total int `json:"total"`
162 } 247 }
163 ) 248 )
164 249
@@ -22,6 +22,15 @@ func (controller *baseController) returnPageListData(count int64, data interface @@ -22,6 +22,15 @@ func (controller *baseController) returnPageListData(count int64, data interface
22 controller.Response(dataMap, err) 22 controller.Response(dataMap, err)
23 } 23 }
24 24
  25 +func (controller *baseController) returnListData(count int64, data interface{}, err error) {
  26 + dataMap := map[string]interface{}{
  27 + "total": count,
  28 + //"pageNumber": pageNumber,
  29 + "list": data,
  30 + }
  31 + controller.Response(dataMap, err)
  32 +}
  33 +
25 func (controller *baseController) GetUserId() int64 { 34 func (controller *baseController) GetUserId() int64 {
26 return 1 35 return 1
27 } 36 }
@@ -207,8 +207,8 @@ func (controller *CooperationController) SearchCooperationProject() { @@ -207,8 +207,8 @@ func (controller *CooperationController) SearchCooperationProject() {
207 return 207 return
208 } 208 }
209 cmd.Operator = controller.GetOperator() 209 cmd.Operator = controller.GetOperator()
210 - _, data, err := svr.SearchCooperationProject(cmd)  
211 - controller.Response(data, err) 210 + total, data, err := svr.SearchCooperationProject(cmd)
  211 + controller.returnPageListData(int64(total), data, err, cmd.PageNumber)
212 } 212 }
213 213
214 func (controller *CooperationController) PersonSearchCooperationProject() { 214 func (controller *CooperationController) PersonSearchCooperationProject() {
@@ -20,6 +20,14 @@ func (controller *baseController) returnPageListData(count int64, data interface @@ -20,6 +20,14 @@ func (controller *baseController) returnPageListData(count int64, data interface
20 controller.Response(dataMap, err) 20 controller.Response(dataMap, err)
21 } 21 }
22 22
  23 +func (controller *baseController) returnListData(count int64, data interface{}, err error) {
  24 + dataMap := map[string]interface{}{
  25 + "total": count,
  26 + "list": data,
  27 + }
  28 + controller.Response(dataMap, err)
  29 +}
  30 +
23 func (controller *baseController) GetOperator() domain.Operator { 31 func (controller *baseController) GetOperator() domain.Operator {
24 token := controller.Ctx.Input.Header("X-Mmm-Accesstoken") 32 token := controller.Ctx.Input.Header("X-Mmm-Accesstoken")
25 loginToken := &domain.LoginToken{} 33 loginToken := &domain.LoginToken{}
@@ -82,8 +82,8 @@ func (controller *CooperationModeController) ListCooperationMode() { @@ -82,8 +82,8 @@ func (controller *CooperationModeController) ListCooperationMode() {
82 listCooperationModeQuery.Operator = controller.GetOperator() 82 listCooperationModeQuery.Operator = controller.GetOperator()
83 listCooperationModeQuery.PageNumber = 1 83 listCooperationModeQuery.PageNumber = 1
84 listCooperationModeQuery.PageSize = 999 84 listCooperationModeQuery.PageSize = 999
85 - _, data, err := cooperationModeService.ListCooperationMode(listCooperationModeQuery)  
86 - controller.Response(data, err) 85 + cnt, data, err := cooperationModeService.ListCooperationMode(listCooperationModeQuery)
  86 + controller.returnListData(cnt, data, err)
87 } 87 }
88 88
89 func (controller *CooperationModeController) EnableCooperationMode() { 89 func (controller *CooperationModeController) EnableCooperationMode() {
@@ -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 }
@@ -24,3 +24,26 @@ func (t UnixTimeSecond) UnmarshalJSON(v []byte) error { @@ -24,3 +24,26 @@ func (t UnixTimeSecond) UnmarshalJSON(v []byte) error {
24 t = UnixTimeSecond(time.Unix(int64(number), 0)) 24 t = UnixTimeSecond(time.Unix(int64(number), 0))
25 return nil 25 return nil
26 } 26 }
  27 +
  28 +type TimeToUnixMsec int64
  29 +
  30 +// MarshalJSON implements json.Marshaler.
  31 +func (t TimeToUnixMsec) MarshalJSON() ([]byte, error) {
  32 + stamp := fmt.Sprintf("%d", t)
  33 + return []byte(stamp), nil
  34 +}
  35 +
  36 +// MarshalJSON implements json.Unmarshaler.
  37 +func (t *TimeToUnixMsec) UnmarshalJSON(v []byte) error {
  38 + if len(v) < 2 {
  39 + *t = 0
  40 + return nil
  41 + }
  42 + str := string(v[1 : len(v)-1])
  43 + number, err := time.Parse(time.RFC3339, str)
  44 + if err != nil {
  45 + return fmt.Errorf("时间类型需要使用时间戳传参:%w", err)
  46 + }
  47 + *t = TimeToUnixMsec(number.Unix() * 1000)
  48 + return nil
  49 +}