正在显示
36 个修改的文件
包含
318 行增加
和
110 行删除
@@ -26,7 +26,7 @@ type ListContractUndertakerFeedbackQuery struct { | @@ -26,7 +26,7 @@ type ListContractUndertakerFeedbackQuery struct { | ||
26 | } | 26 | } |
27 | 27 | ||
28 | func (listContractUndertakerFeedbackQuery *ListContractUndertakerFeedbackQuery) Valid(validation *validation.Validation) { | 28 | func (listContractUndertakerFeedbackQuery *ListContractUndertakerFeedbackQuery) Valid(validation *validation.Validation) { |
29 | - validation.SetError("CustomValid", "未实现的自定义认证") | 29 | + //validation.SetError("CustomValid", "未实现的自定义认证") |
30 | } | 30 | } |
31 | 31 | ||
32 | func (listContractUndertakerFeedbackQuery *ListContractUndertakerFeedbackQuery) ValidateQuery() error { | 32 | func (listContractUndertakerFeedbackQuery *ListContractUndertakerFeedbackQuery) ValidateQuery() error { |
@@ -26,7 +26,7 @@ type AgreeCooperationApplicationCommand struct { | @@ -26,7 +26,7 @@ type AgreeCooperationApplicationCommand struct { | ||
26 | } | 26 | } |
27 | 27 | ||
28 | func (agreeCooperationApplicationCommand *AgreeCooperationApplicationCommand) Valid(validation *validation.Validation) { | 28 | func (agreeCooperationApplicationCommand *AgreeCooperationApplicationCommand) Valid(validation *validation.Validation) { |
29 | - validation.SetError("CustomValid", "未实现的自定义认证") | 29 | + //validation.SetError("CustomValid", "未实现的自定义认证") |
30 | } | 30 | } |
31 | 31 | ||
32 | func (agreeCooperationApplicationCommand *AgreeCooperationApplicationCommand) ValidateCommand() error { | 32 | func (agreeCooperationApplicationCommand *AgreeCooperationApplicationCommand) ValidateCommand() error { |
@@ -66,7 +66,7 @@ type ApplyForCooperationCommand struct { | @@ -66,7 +66,7 @@ type ApplyForCooperationCommand struct { | ||
66 | } | 66 | } |
67 | 67 | ||
68 | func (applyForCooperationCommand *ApplyForCooperationCommand) Valid(validation *validation.Validation) { | 68 | func (applyForCooperationCommand *ApplyForCooperationCommand) Valid(validation *validation.Validation) { |
69 | - validation.SetError("CustomValid", "未实现的自定义认证") | 69 | + //validation.SetError("CustomValid", "未实现的自定义认证") |
70 | } | 70 | } |
71 | 71 | ||
72 | func (applyForCooperationCommand *ApplyForCooperationCommand) ValidateCommand() error { | 72 | func (applyForCooperationCommand *ApplyForCooperationCommand) ValidateCommand() error { |
@@ -27,7 +27,7 @@ type BatchApprovalCooperationApplicationCommand struct { | @@ -27,7 +27,7 @@ type BatchApprovalCooperationApplicationCommand struct { | ||
27 | } | 27 | } |
28 | 28 | ||
29 | func (batchApprovalCooperationApplicationCommand *BatchApprovalCooperationApplicationCommand) Valid(validation *validation.Validation) { | 29 | func (batchApprovalCooperationApplicationCommand *BatchApprovalCooperationApplicationCommand) Valid(validation *validation.Validation) { |
30 | - validation.SetError("CustomValid", "未实现的自定义认证") | 30 | + //validation.SetError("CustomValid", "未实现的自定义认证") |
31 | } | 31 | } |
32 | 32 | ||
33 | func (batchApprovalCooperationApplicationCommand *BatchApprovalCooperationApplicationCommand) ValidateCommand() error { | 33 | func (batchApprovalCooperationApplicationCommand *BatchApprovalCooperationApplicationCommand) ValidateCommand() error { |
@@ -29,7 +29,7 @@ type CreateCooperationApplicationCommand struct { | @@ -29,7 +29,7 @@ type CreateCooperationApplicationCommand struct { | ||
29 | } | 29 | } |
30 | 30 | ||
31 | func (createCooperationApplicationCommand *CreateCooperationApplicationCommand) Valid(validation *validation.Validation) { | 31 | func (createCooperationApplicationCommand *CreateCooperationApplicationCommand) Valid(validation *validation.Validation) { |
32 | - validation.SetError("CustomValid", "未实现的自定义认证") | 32 | + //validation.SetError("CustomValid", "未实现的自定义认证") |
33 | } | 33 | } |
34 | 34 | ||
35 | func (createCooperationApplicationCommand *CreateCooperationApplicationCommand) ValidateCommand() error { | 35 | func (createCooperationApplicationCommand *CreateCooperationApplicationCommand) ValidateCommand() error { |
@@ -26,7 +26,7 @@ type RejectCooperationApplicationCommand struct { | @@ -26,7 +26,7 @@ type RejectCooperationApplicationCommand struct { | ||
26 | } | 26 | } |
27 | 27 | ||
28 | func (rejectCooperationApplicationCommand *RejectCooperationApplicationCommand) Valid(validation *validation.Validation) { | 28 | func (rejectCooperationApplicationCommand *RejectCooperationApplicationCommand) Valid(validation *validation.Validation) { |
29 | - validation.SetError("CustomValid", "未实现的自定义认证") | 29 | + //validation.SetError("CustomValid", "未实现的自定义认证") |
30 | } | 30 | } |
31 | 31 | ||
32 | func (rejectCooperationApplicationCommand *RejectCooperationApplicationCommand) ValidateCommand() error { | 32 | func (rejectCooperationApplicationCommand *RejectCooperationApplicationCommand) ValidateCommand() error { |
@@ -22,7 +22,7 @@ type RemoveCooperationApplicationCommand struct { | @@ -22,7 +22,7 @@ type RemoveCooperationApplicationCommand struct { | ||
22 | } | 22 | } |
23 | 23 | ||
24 | func (removeCooperationApplicationCommand *RemoveCooperationApplicationCommand) Valid(validation *validation.Validation) { | 24 | func (removeCooperationApplicationCommand *RemoveCooperationApplicationCommand) Valid(validation *validation.Validation) { |
25 | - validation.SetError("CustomValid", "未实现的自定义认证") | 25 | + //validation.SetError("CustomValid", "未实现的自定义认证") |
26 | } | 26 | } |
27 | 27 | ||
28 | func (removeCooperationApplicationCommand *RemoveCooperationApplicationCommand) ValidateCommand() error { | 28 | func (removeCooperationApplicationCommand *RemoveCooperationApplicationCommand) ValidateCommand() error { |
@@ -31,7 +31,7 @@ type UpdateCooperationApplicationCommand struct { | @@ -31,7 +31,7 @@ type UpdateCooperationApplicationCommand struct { | ||
31 | } | 31 | } |
32 | 32 | ||
33 | func (updateCooperationApplicationCommand *UpdateCooperationApplicationCommand) Valid(validation *validation.Validation) { | 33 | func (updateCooperationApplicationCommand *UpdateCooperationApplicationCommand) Valid(validation *validation.Validation) { |
34 | - validation.SetError("CustomValid", "未实现的自定义认证") | 34 | + //validation.SetError("CustomValid", "未实现的自定义认证") |
35 | } | 35 | } |
36 | 36 | ||
37 | func (updateCooperationApplicationCommand *UpdateCooperationApplicationCommand) ValidateCommand() error { | 37 | func (updateCooperationApplicationCommand *UpdateCooperationApplicationCommand) ValidateCommand() error { |
@@ -22,7 +22,7 @@ type GetCooperationApplicationQuery struct { | @@ -22,7 +22,7 @@ type GetCooperationApplicationQuery struct { | ||
22 | } | 22 | } |
23 | 23 | ||
24 | func (getCooperationApplicationQuery *GetCooperationApplicationQuery) Valid(validation *validation.Validation) { | 24 | func (getCooperationApplicationQuery *GetCooperationApplicationQuery) Valid(validation *validation.Validation) { |
25 | - validation.SetError("CustomValid", "未实现的自定义认证") | 25 | + //validation.SetError("CustomValid", "未实现的自定义认证") |
26 | } | 26 | } |
27 | 27 | ||
28 | func (getCooperationApplicationQuery *GetCooperationApplicationQuery) ValidateQuery() error { | 28 | func (getCooperationApplicationQuery *GetCooperationApplicationQuery) ValidateQuery() error { |
@@ -28,7 +28,7 @@ type ListCooperationApplicationQuery struct { | @@ -28,7 +28,7 @@ type ListCooperationApplicationQuery struct { | ||
28 | } | 28 | } |
29 | 29 | ||
30 | func (listCooperationApplicationQuery *ListCooperationApplicationQuery) Valid(validation *validation.Validation) { | 30 | func (listCooperationApplicationQuery *ListCooperationApplicationQuery) Valid(validation *validation.Validation) { |
31 | - validation.SetError("CustomValid", "未实现的自定义认证") | 31 | + //validation.SetError("CustomValid", "未实现的自定义认证") |
32 | } | 32 | } |
33 | 33 | ||
34 | func (listCooperationApplicationQuery *ListCooperationApplicationQuery) ValidateQuery() error { | 34 | func (listCooperationApplicationQuery *ListCooperationApplicationQuery) ValidateQuery() error { |
@@ -30,7 +30,7 @@ type SearchCooperationApplicationQuery struct { | @@ -30,7 +30,7 @@ type SearchCooperationApplicationQuery struct { | ||
30 | } | 30 | } |
31 | 31 | ||
32 | func (searchCooperationApplicationQuery *SearchCooperationApplicationQuery) Valid(validation *validation.Validation) { | 32 | func (searchCooperationApplicationQuery *SearchCooperationApplicationQuery) Valid(validation *validation.Validation) { |
33 | - validation.SetError("CustomValid", "未实现的自定义认证") | 33 | + //validation.SetError("CustomValid", "未实现的自定义认证") |
34 | } | 34 | } |
35 | 35 | ||
36 | func (searchCooperationApplicationQuery *SearchCooperationApplicationQuery) ValidateQuery() error { | 36 | func (searchCooperationApplicationQuery *SearchCooperationApplicationQuery) ValidateQuery() error { |
@@ -39,7 +39,7 @@ type UpdateDividendsOrderCommand struct { | @@ -39,7 +39,7 @@ type UpdateDividendsOrderCommand struct { | ||
39 | } | 39 | } |
40 | 40 | ||
41 | func (updateDividendsOrderCommand *UpdateDividendsOrderCommand) Valid(validation *validation.Validation) { | 41 | func (updateDividendsOrderCommand *UpdateDividendsOrderCommand) Valid(validation *validation.Validation) { |
42 | - validation.SetError("CustomValid", "未实现的自定义认证") | 42 | + //validation.SetError("CustomValid", "未实现的自定义认证") |
43 | } | 43 | } |
44 | 44 | ||
45 | func (updateDividendsOrderCommand *UpdateDividendsOrderCommand) ValidateCommand() error { | 45 | func (updateDividendsOrderCommand *UpdateDividendsOrderCommand) ValidateCommand() error { |
@@ -22,7 +22,7 @@ type GetDividendsOrderQuery struct { | @@ -22,7 +22,7 @@ type GetDividendsOrderQuery struct { | ||
22 | } | 22 | } |
23 | 23 | ||
24 | func (getDividendsOrderQuery *GetDividendsOrderQuery) Valid(validation *validation.Validation) { | 24 | func (getDividendsOrderQuery *GetDividendsOrderQuery) Valid(validation *validation.Validation) { |
25 | - validation.SetError("CustomValid", "未实现的自定义认证") | 25 | + //validation.SetError("CustomValid", "未实现的自定义认证") |
26 | } | 26 | } |
27 | 27 | ||
28 | func (getDividendsOrderQuery *GetDividendsOrderQuery) ValidateQuery() error { | 28 | func (getDividendsOrderQuery *GetDividendsOrderQuery) ValidateQuery() error { |
@@ -24,7 +24,7 @@ type ListDividendsOrdersQuery struct { | @@ -24,7 +24,7 @@ type ListDividendsOrdersQuery struct { | ||
24 | } | 24 | } |
25 | 25 | ||
26 | func (listDividendsOrdersQuery *ListDividendsOrdersQuery) Valid(validation *validation.Validation) { | 26 | func (listDividendsOrdersQuery *ListDividendsOrdersQuery) Valid(validation *validation.Validation) { |
27 | - validation.SetError("CustomValid", "未实现的自定义认证") | 27 | + //validation.SetError("CustomValid", "未实现的自定义认证") |
28 | } | 28 | } |
29 | 29 | ||
30 | func (listDividendsOrdersQuery *ListDividendsOrdersQuery) ValidateQuery() error { | 30 | func (listDividendsOrdersQuery *ListDividendsOrdersQuery) ValidateQuery() error { |
@@ -28,7 +28,7 @@ type SearchDividendsOrderQuery struct { | @@ -28,7 +28,7 @@ type SearchDividendsOrderQuery struct { | ||
28 | } | 28 | } |
29 | 29 | ||
30 | func (searchDividendsOrderQuery *SearchDividendsOrderQuery) Valid(validation *validation.Validation) { | 30 | func (searchDividendsOrderQuery *SearchDividendsOrderQuery) Valid(validation *validation.Validation) { |
31 | - validation.SetError("CustomValid", "未实现的自定义认证") | 31 | + //validation.SetError("CustomValid", "未实现的自定义认证") |
32 | } | 32 | } |
33 | 33 | ||
34 | func (searchDividendsOrderQuery *SearchDividendsOrderQuery) ValidateQuery() error { | 34 | func (searchDividendsOrderQuery *SearchDividendsOrderQuery) ValidateQuery() error { |
@@ -26,7 +26,7 @@ type SearchDividendsOrderNumberQuery struct { | @@ -26,7 +26,7 @@ type SearchDividendsOrderNumberQuery struct { | ||
26 | } | 26 | } |
27 | 27 | ||
28 | func (searchDividendsOrderNumberQuery *SearchDividendsOrderNumberQuery) Valid(validation *validation.Validation) { | 28 | func (searchDividendsOrderNumberQuery *SearchDividendsOrderNumberQuery) Valid(validation *validation.Validation) { |
29 | - validation.SetError("CustomValid", "未实现的自定义认证") | 29 | + //validation.SetError("CustomValid", "未实现的自定义认证") |
30 | } | 30 | } |
31 | 31 | ||
32 | func (searchDividendsOrderNumberQuery *SearchDividendsOrderNumberQuery) ValidateQuery() error { | 32 | func (searchDividendsOrderNumberQuery *SearchDividendsOrderNumberQuery) ValidateQuery() error { |
@@ -22,7 +22,7 @@ type RemoveDividendsReturnedOrderCommand struct { | @@ -22,7 +22,7 @@ type RemoveDividendsReturnedOrderCommand struct { | ||
22 | } | 22 | } |
23 | 23 | ||
24 | func (removeDividendsReturnedOrderCommand *RemoveDividendsReturnedOrderCommand) Valid(validation *validation.Validation) { | 24 | func (removeDividendsReturnedOrderCommand *RemoveDividendsReturnedOrderCommand) Valid(validation *validation.Validation) { |
25 | - validation.SetError("CustomValid", "未实现的自定义认证") | 25 | + //validation.SetError("CustomValid", "未实现的自定义认证") |
26 | } | 26 | } |
27 | 27 | ||
28 | func (removeDividendsReturnedOrderCommand *RemoveDividendsReturnedOrderCommand) ValidateCommand() error { | 28 | func (removeDividendsReturnedOrderCommand *RemoveDividendsReturnedOrderCommand) ValidateCommand() error { |
@@ -37,7 +37,7 @@ type UpdateDividendsReturnedOrderCommand struct { | @@ -37,7 +37,7 @@ type UpdateDividendsReturnedOrderCommand struct { | ||
37 | } | 37 | } |
38 | 38 | ||
39 | func (updateDividendsReturnedOrderCommand *UpdateDividendsReturnedOrderCommand) Valid(validation *validation.Validation) { | 39 | func (updateDividendsReturnedOrderCommand *UpdateDividendsReturnedOrderCommand) Valid(validation *validation.Validation) { |
40 | - validation.SetError("CustomValid", "未实现的自定义认证") | 40 | + //validation.SetError("CustomValid", "未实现的自定义认证") |
41 | } | 41 | } |
42 | 42 | ||
43 | func (updateDividendsReturnedOrderCommand *UpdateDividendsReturnedOrderCommand) ValidateCommand() error { | 43 | func (updateDividendsReturnedOrderCommand *UpdateDividendsReturnedOrderCommand) ValidateCommand() error { |
@@ -24,7 +24,7 @@ type ListDividendsReturnedOrderQuery struct { | @@ -24,7 +24,7 @@ type ListDividendsReturnedOrderQuery struct { | ||
24 | } | 24 | } |
25 | 25 | ||
26 | func (listDividendsReturnedOrderQuery *ListDividendsReturnedOrderQuery) Valid(validation *validation.Validation) { | 26 | func (listDividendsReturnedOrderQuery *ListDividendsReturnedOrderQuery) Valid(validation *validation.Validation) { |
27 | - validation.SetError("CustomValid", "未实现的自定义认证") | 27 | + //validation.SetError("CustomValid", "未实现的自定义认证") |
28 | } | 28 | } |
29 | 29 | ||
30 | func (listDividendsReturnedOrderQuery *ListDividendsReturnedOrderQuery) ValidateQuery() error { | 30 | func (listDividendsReturnedOrderQuery *ListDividendsReturnedOrderQuery) ValidateQuery() error { |
@@ -28,7 +28,7 @@ type SearchDividendsReturnedOrderQuery struct { | @@ -28,7 +28,7 @@ type SearchDividendsReturnedOrderQuery struct { | ||
28 | } | 28 | } |
29 | 29 | ||
30 | func (searchDividendsReturnedOrderQuery *SearchDividendsReturnedOrderQuery) Valid(validation *validation.Validation) { | 30 | func (searchDividendsReturnedOrderQuery *SearchDividendsReturnedOrderQuery) Valid(validation *validation.Validation) { |
31 | - validation.SetError("CustomValid", "未实现的自定义认证") | 31 | + //validation.SetError("CustomValid", "未实现的自定义认证") |
32 | } | 32 | } |
33 | 33 | ||
34 | func (searchDividendsReturnedOrderQuery *SearchDividendsReturnedOrderQuery) ValidateQuery() error { | 34 | func (searchDividendsReturnedOrderQuery *SearchDividendsReturnedOrderQuery) ValidateQuery() error { |
@@ -61,10 +61,10 @@ func (cooperationContractRelevant *CooperationContractRelevant) Update(data map[ | @@ -61,10 +61,10 @@ func (cooperationContractRelevant *CooperationContractRelevant) Update(data map[ | ||
61 | cooperationContractRelevant.Relevant.Org.Company.CompanyName = companyName.(string) | 61 | cooperationContractRelevant.Relevant.Org.Company.CompanyName = companyName.(string) |
62 | } | 62 | } |
63 | if roleId, ok := data["roleId"]; ok { | 63 | if roleId, ok := data["roleId"]; ok { |
64 | - cooperationContractRelevant.Relevant.Role.RoleId = roleId.(int64) | 64 | + cooperationContractRelevant.Relevant.Roles.RoleId = roleId.(int64) |
65 | } | 65 | } |
66 | if roleName, ok := data["roleName"]; ok { | 66 | if roleName, ok := data["roleName"]; ok { |
67 | - cooperationContractRelevant.Relevant.Role.RoleName = roleName.(string) | 67 | + cooperationContractRelevant.Relevant.Roles.RoleName = roleName.(string) |
68 | } | 68 | } |
69 | if userAvatar, ok := data["userAvatar"]; ok { | 69 | if userAvatar, ok := data["userAvatar"]; ok { |
70 | cooperationContractRelevant.Relevant.UserInfo.UserAvatar = userAvatar.(string) | 70 | cooperationContractRelevant.Relevant.UserInfo.UserAvatar = userAvatar.(string) |
@@ -17,7 +17,7 @@ type Relevant struct { | @@ -17,7 +17,7 @@ type Relevant struct { | ||
17 | // 用户所属的部门 | 17 | // 用户所属的部门 |
18 | Department *Department `json:"department"` | 18 | Department *Department `json:"department"` |
19 | // 用户角色 | 19 | // 用户角色 |
20 | - Role *Role `json:"role"` | 20 | + Roles []*Role `json:"roles"` |
21 | // 冗余字段,jsonb格式,不限制存放内容 | 21 | // 冗余字段,jsonb格式,不限制存放内容 |
22 | UserInfo *UserInfo `json:"userInfo"` | 22 | UserInfo *UserInfo `json:"userInfo"` |
23 | // 用户类型,1员工,2共创用户,3公开 | 23 | // 用户类型,1员工,2共创用户,3公开 |
1 | package domain_service | 1 | package domain_service |
2 | 2 | ||
3 | -import "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain" | 3 | +import ( |
4 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain" | ||
5 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/service_gateway/adaptor" | ||
6 | +) | ||
4 | 7 | ||
5 | type CompanyService struct { | 8 | type CompanyService struct { |
6 | } | 9 | } |
7 | 10 | ||
8 | func (service *CompanyService) CompanyFrom(companyId int64) (*domain.Company, error) { | 11 | func (service *CompanyService) CompanyFrom(companyId int64) (*domain.Company, error) { |
9 | - return nil, nil | 12 | + if companyAdaptor, err := adaptor.NewCompanyAdaptor(); err != nil { |
13 | + return nil, err | ||
14 | + } else { | ||
15 | + if company, err := companyAdaptor.ToCompany(companyId); err != nil { | ||
16 | + return nil, err | ||
17 | + } else { | ||
18 | + return company, nil | ||
19 | + } | ||
20 | + } | ||
10 | } | 21 | } |
11 | 22 | ||
12 | func NewCompanyService() (*CompanyService, error) { | 23 | func NewCompanyService() (*CompanyService, error) { |
1 | package domain_service | 1 | package domain_service |
2 | 2 | ||
3 | -import "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain" | 3 | +import ( |
4 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain" | ||
5 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/service_gateway/adaptor" | ||
6 | +) | ||
4 | 7 | ||
5 | type OrganizationService struct { | 8 | type OrganizationService struct { |
6 | } | 9 | } |
7 | 10 | ||
8 | func (service *OrganizationService) OrgFrom(companyId int64, orgId int64) (*domain.Org, error) { | 11 | func (service *OrganizationService) OrgFrom(companyId int64, orgId int64) (*domain.Org, error) { |
9 | - return nil, nil | 12 | + if organizationAdaptor, err := adaptor.NewOrganizationAdaptor(); err != nil { |
13 | + return nil, err | ||
14 | + } else { | ||
15 | + if organization, err := organizationAdaptor.ToOrganization(companyId, orgId); err != nil { | ||
16 | + return nil, err | ||
17 | + } else { | ||
18 | + return organization, nil | ||
19 | + } | ||
20 | + } | ||
10 | } | 21 | } |
11 | 22 | ||
12 | func NewOrganizationService() (*OrganizationService, error) { | 23 | func NewOrganizationService() (*OrganizationService, error) { |
@@ -60,7 +60,7 @@ func TransformToCooperationContractDomainModelFromPgModels( | @@ -60,7 +60,7 @@ func TransformToCooperationContractDomainModelFromPgModels( | ||
60 | Org: relevant.Org, | 60 | Org: relevant.Org, |
61 | Orgs: relevant.Orgs, | 61 | Orgs: relevant.Orgs, |
62 | Department: relevant.Department, | 62 | Department: relevant.Department, |
63 | - Role: relevant.Role, | 63 | + Roles: relevant.Role, |
64 | UserInfo: relevant.UserInfo, | 64 | UserInfo: relevant.UserInfo, |
65 | UserType: relevant.UserType, | 65 | UserType: relevant.UserType, |
66 | Status: relevant.Status, | 66 | Status: relevant.Status, |
@@ -17,7 +17,7 @@ func TransformToCooperationContractRelevantDomainModelFromPgModels(cooperationCo | @@ -17,7 +17,7 @@ func TransformToCooperationContractRelevantDomainModelFromPgModels(cooperationCo | ||
17 | Org: cooperationContractRelevantModel.Org, | 17 | Org: cooperationContractRelevantModel.Org, |
18 | Orgs: cooperationContractRelevantModel.Orgs, | 18 | Orgs: cooperationContractRelevantModel.Orgs, |
19 | Department: cooperationContractRelevantModel.Department, | 19 | Department: cooperationContractRelevantModel.Department, |
20 | - Role: cooperationContractRelevantModel.Role, | 20 | + Roles: cooperationContractRelevantModel.Role, |
21 | UserInfo: cooperationContractRelevantModel.UserInfo, | 21 | UserInfo: cooperationContractRelevantModel.UserInfo, |
22 | UserType: cooperationContractRelevantModel.UserType, | 22 | UserType: cooperationContractRelevantModel.UserType, |
23 | Status: cooperationContractRelevantModel.Status, | 23 | Status: cooperationContractRelevantModel.Status, |
@@ -64,7 +64,7 @@ func (repository *CooperationContractRelevantRepository) Save(cooperationContrac | @@ -64,7 +64,7 @@ func (repository *CooperationContractRelevantRepository) Save(cooperationContrac | ||
64 | &cooperationContractRelevant.Relevant.Org, | 64 | &cooperationContractRelevant.Relevant.Org, |
65 | &cooperationContractRelevant.Relevant.Orgs, | 65 | &cooperationContractRelevant.Relevant.Orgs, |
66 | &cooperationContractRelevant.Relevant.Department, | 66 | &cooperationContractRelevant.Relevant.Department, |
67 | - &cooperationContractRelevant.Relevant.Role, | 67 | + &cooperationContractRelevant.Relevant.Roles, |
68 | &cooperationContractRelevant.Relevant.UserInfo, | 68 | &cooperationContractRelevant.Relevant.UserInfo, |
69 | &cooperationContractRelevant.Relevant.UserType, | 69 | &cooperationContractRelevant.Relevant.UserType, |
70 | &cooperationContractRelevant.Relevant.Status, | 70 | &cooperationContractRelevant.Relevant.Status, |
@@ -81,7 +81,7 @@ func (repository *CooperationContractRelevantRepository) Save(cooperationContrac | @@ -81,7 +81,7 @@ func (repository *CooperationContractRelevantRepository) Save(cooperationContrac | ||
81 | &cooperationContractRelevant.Relevant.Org, | 81 | &cooperationContractRelevant.Relevant.Org, |
82 | &cooperationContractRelevant.Relevant.Orgs, | 82 | &cooperationContractRelevant.Relevant.Orgs, |
83 | &cooperationContractRelevant.Relevant.Department, | 83 | &cooperationContractRelevant.Relevant.Department, |
84 | - &cooperationContractRelevant.Relevant.Role, | 84 | + &cooperationContractRelevant.Relevant.Roles, |
85 | &cooperationContractRelevant.Relevant.UserInfo, | 85 | &cooperationContractRelevant.Relevant.UserInfo, |
86 | &cooperationContractRelevant.Relevant.UserType, | 86 | &cooperationContractRelevant.Relevant.UserType, |
87 | &cooperationContractRelevant.Relevant.Status, | 87 | &cooperationContractRelevant.Relevant.Status, |
@@ -102,7 +102,7 @@ func (repository *CooperationContractRelevantRepository) Save(cooperationContrac | @@ -102,7 +102,7 @@ func (repository *CooperationContractRelevantRepository) Save(cooperationContrac | ||
102 | &cooperationContractRelevant.Relevant.Org, | 102 | &cooperationContractRelevant.Relevant.Org, |
103 | &cooperationContractRelevant.Relevant.Orgs, | 103 | &cooperationContractRelevant.Relevant.Orgs, |
104 | &cooperationContractRelevant.Relevant.Department, | 104 | &cooperationContractRelevant.Relevant.Department, |
105 | - &cooperationContractRelevant.Relevant.Role, | 105 | + &cooperationContractRelevant.Relevant.Roles, |
106 | &cooperationContractRelevant.Relevant.UserInfo, | 106 | &cooperationContractRelevant.Relevant.UserInfo, |
107 | &cooperationContractRelevant.Relevant.UserType, | 107 | &cooperationContractRelevant.Relevant.UserType, |
108 | &cooperationContractRelevant.Relevant.Status, | 108 | &cooperationContractRelevant.Relevant.Status, |
@@ -119,7 +119,7 @@ func (repository *CooperationContractRelevantRepository) Save(cooperationContrac | @@ -119,7 +119,7 @@ func (repository *CooperationContractRelevantRepository) Save(cooperationContrac | ||
119 | cooperationContractRelevant.Relevant.Org, | 119 | cooperationContractRelevant.Relevant.Org, |
120 | cooperationContractRelevant.Relevant.Orgs, | 120 | cooperationContractRelevant.Relevant.Orgs, |
121 | cooperationContractRelevant.Relevant.Department, | 121 | cooperationContractRelevant.Relevant.Department, |
122 | - cooperationContractRelevant.Relevant.Role, | 122 | + cooperationContractRelevant.Relevant.Roles, |
123 | cooperationContractRelevant.Relevant.UserInfo, | 123 | cooperationContractRelevant.Relevant.UserInfo, |
124 | cooperationContractRelevant.Relevant.UserType, | 124 | cooperationContractRelevant.Relevant.UserType, |
125 | cooperationContractRelevant.Relevant.Status, | 125 | cooperationContractRelevant.Relevant.Status, |
@@ -106,7 +106,7 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai | @@ -106,7 +106,7 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai | ||
106 | Org: relevant.Org, | 106 | Org: relevant.Org, |
107 | Orgs: relevant.Orgs, | 107 | Orgs: relevant.Orgs, |
108 | Department: relevant.Department, | 108 | Department: relevant.Department, |
109 | - Role: relevant.Role, | 109 | + Role: relevant.Roles, |
110 | UserInfo: relevant.UserInfo, | 110 | UserInfo: relevant.UserInfo, |
111 | UserType: relevant.UserType, | 111 | UserType: relevant.UserType, |
112 | Status: relevant.Status, | 112 | Status: relevant.Status, |
@@ -267,7 +267,7 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai | @@ -267,7 +267,7 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai | ||
267 | Org: relevantDomain.Org, | 267 | Org: relevantDomain.Org, |
268 | Orgs: relevantDomain.Orgs, | 268 | Orgs: relevantDomain.Orgs, |
269 | Department: relevantDomain.Department, | 269 | Department: relevantDomain.Department, |
270 | - Role: relevantDomain.Role, | 270 | + Role: relevantDomain.Roles, |
271 | UserInfo: relevantDomain.UserInfo, | 271 | UserInfo: relevantDomain.UserInfo, |
272 | UserType: relevantDomain.UserType, | 272 | UserType: relevantDomain.UserType, |
273 | Status: relevantDomain.Status, | 273 | Status: relevantDomain.Status, |
@@ -24,6 +24,7 @@ func (repository *CooperationProjectRepository) nextIdentify() (int64, error) { | @@ -24,6 +24,7 @@ func (repository *CooperationProjectRepository) nextIdentify() (int64, error) { | ||
24 | id, err := IdWorker.NextId() | 24 | id, err := IdWorker.NextId() |
25 | return id, err | 25 | return id, err |
26 | } | 26 | } |
27 | + | ||
27 | func (repository *CooperationProjectRepository) Save(cooperationProject *domain.CooperationProject) (*domain.CooperationProject, error) { | 28 | func (repository *CooperationProjectRepository) Save(cooperationProject *domain.CooperationProject) (*domain.CooperationProject, error) { |
28 | sqlBuildFields := []string{ | 29 | sqlBuildFields := []string{ |
29 | "cooperation_project_id", | 30 | "cooperation_project_id", |
@@ -144,6 +145,7 @@ func (repository *CooperationProjectRepository) Save(cooperationProject *domain. | @@ -144,6 +145,7 @@ func (repository *CooperationProjectRepository) Save(cooperationProject *domain. | ||
144 | } | 145 | } |
145 | return cooperationProject, nil | 146 | return cooperationProject, nil |
146 | } | 147 | } |
148 | + | ||
147 | func (repository *CooperationProjectRepository) Remove(cooperationProject *domain.CooperationProject) (*domain.CooperationProject, error) { | 149 | func (repository *CooperationProjectRepository) Remove(cooperationProject *domain.CooperationProject) (*domain.CooperationProject, error) { |
148 | tx := repository.transactionContext.PgTx | 150 | tx := repository.transactionContext.PgTx |
149 | cooperationProjectModel := new(models.CooperationProject) | 151 | cooperationProjectModel := new(models.CooperationProject) |
@@ -153,6 +155,7 @@ func (repository *CooperationProjectRepository) Remove(cooperationProject *domai | @@ -153,6 +155,7 @@ func (repository *CooperationProjectRepository) Remove(cooperationProject *domai | ||
153 | } | 155 | } |
154 | return cooperationProject, nil | 156 | return cooperationProject, nil |
155 | } | 157 | } |
158 | + | ||
156 | func (repository *CooperationProjectRepository) FindOne(queryOptions map[string]interface{}) (*domain.CooperationProject, error) { | 159 | func (repository *CooperationProjectRepository) FindOne(queryOptions map[string]interface{}) (*domain.CooperationProject, error) { |
157 | tx := repository.transactionContext.PgTx | 160 | tx := repository.transactionContext.PgTx |
158 | cooperationProjectModel := new(models.CooperationProject) | 161 | cooperationProjectModel := new(models.CooperationProject) |
@@ -171,6 +174,7 @@ func (repository *CooperationProjectRepository) FindOne(queryOptions map[string] | @@ -171,6 +174,7 @@ func (repository *CooperationProjectRepository) FindOne(queryOptions map[string] | ||
171 | return transform.TransformToCooperationProjectDomainModelFromPgModels(cooperationProjectModel) | 174 | return transform.TransformToCooperationProjectDomainModelFromPgModels(cooperationProjectModel) |
172 | } | 175 | } |
173 | } | 176 | } |
177 | + | ||
174 | func (repository *CooperationProjectRepository) Find(queryOptions map[string]interface{}) (int64, []*domain.CooperationProject, error) { | 178 | func (repository *CooperationProjectRepository) Find(queryOptions map[string]interface{}) (int64, []*domain.CooperationProject, error) { |
175 | tx := repository.transactionContext.PgTx | 179 | tx := repository.transactionContext.PgTx |
176 | var cooperationProjectModels []*models.CooperationProject | 180 | var cooperationProjectModels []*models.CooperationProject |
@@ -191,6 +195,7 @@ func (repository *CooperationProjectRepository) Find(queryOptions map[string]int | @@ -191,6 +195,7 @@ func (repository *CooperationProjectRepository) Find(queryOptions map[string]int | ||
191 | return int64(count), cooperationProjects, nil | 195 | return int64(count), cooperationProjects, nil |
192 | } | 196 | } |
193 | } | 197 | } |
198 | + | ||
194 | func NewCooperationProjectRepository(transactionContext *pgTransaction.TransactionContext) (*CooperationProjectRepository, error) { | 199 | func NewCooperationProjectRepository(transactionContext *pgTransaction.TransactionContext) (*CooperationProjectRepository, error) { |
195 | if transactionContext == nil { | 200 | if transactionContext == nil { |
196 | return nil, fmt.Errorf("transactionContext参数不能为nil") | 201 | return nil, fmt.Errorf("transactionContext参数不能为nil") |
@@ -17,45 +17,43 @@ func (adaptor *UserAdaptor) ToParticipator(companyId int64, orgId int64, userId | @@ -17,45 +17,43 @@ func (adaptor *UserAdaptor) ToParticipator(companyId int64, orgId int64, userId | ||
17 | if userTranslator, err := translator.NewUserTranslator(); err != nil { | 17 | if userTranslator, err := translator.NewUserTranslator(); err != nil { |
18 | return map[string]interface{}{}, err | 18 | return map[string]interface{}{}, err |
19 | } else { | 19 | } else { |
20 | - if response["code"] == 200 { | ||
21 | - switch aRoleName { | ||
22 | - case "Relevant": | ||
23 | - relevant, err := userTranslator.ToRelevantFromRepresentation(response) | ||
24 | - if err != nil { | ||
25 | - return map[string]interface{}{}, err | ||
26 | - } | ||
27 | - return relevant, nil | ||
28 | - case "Referrer": | ||
29 | - referrer, err := userTranslator.ToReferrerFromRepresentation(response) | ||
30 | - if err != nil { | ||
31 | - return map[string]interface{}{}, err | ||
32 | - } | ||
33 | - return referrer, nil | ||
34 | - case "Salesman": | ||
35 | - salesman, err := userTranslator.ToSalesmanFromRepresentation(response) | ||
36 | - if err != nil { | ||
37 | - return map[string]interface{}{}, nil | ||
38 | - } | ||
39 | - return salesman, nil | ||
40 | - case "Undertaker": | ||
41 | - undertaker, err := userTranslator.ToUndertakerFromRepresentation(response) | ||
42 | - if err != nil { | ||
43 | - return map[string]interface{}{}, nil | ||
44 | - } | ||
45 | - return undertaker, nil | ||
46 | - case "Operator": | ||
47 | - operator, err := userTranslator.ToOperatorFromRepresentation(response) | ||
48 | - if err != nil { | ||
49 | - return map[string]interface{}{}, nil | ||
50 | - } | ||
51 | - return operator, nil | ||
52 | - case "User": | ||
53 | - user, err := userTranslator.ToUserFromRepresentation(response) | ||
54 | - if err != nil { | ||
55 | - return map[string]interface{}{}, nil | ||
56 | - } | ||
57 | - return user, nil | 20 | + switch aRoleName { |
21 | + case "Relevant": | ||
22 | + relevant, err := userTranslator.ToRelevantFromRepresentation(response) | ||
23 | + if err != nil { | ||
24 | + return map[string]interface{}{}, err | ||
58 | } | 25 | } |
26 | + return relevant, nil | ||
27 | + case "Referrer": | ||
28 | + referrer, err := userTranslator.ToReferrerFromRepresentation(response) | ||
29 | + if err != nil { | ||
30 | + return map[string]interface{}{}, err | ||
31 | + } | ||
32 | + return referrer, nil | ||
33 | + case "Salesman": | ||
34 | + salesman, err := userTranslator.ToSalesmanFromRepresentation(response) | ||
35 | + if err != nil { | ||
36 | + return map[string]interface{}{}, nil | ||
37 | + } | ||
38 | + return salesman, nil | ||
39 | + case "Undertaker": | ||
40 | + undertaker, err := userTranslator.ToUndertakerFromRepresentation(response) | ||
41 | + if err != nil { | ||
42 | + return map[string]interface{}{}, nil | ||
43 | + } | ||
44 | + return undertaker, nil | ||
45 | + case "Operator": | ||
46 | + operator, err := userTranslator.ToOperatorFromRepresentation(response) | ||
47 | + if err != nil { | ||
48 | + return map[string]interface{}{}, nil | ||
49 | + } | ||
50 | + return operator, nil | ||
51 | + case "User": | ||
52 | + user, err := userTranslator.ToUserFromRepresentation(response) | ||
53 | + if err != nil { | ||
54 | + return map[string]interface{}{}, nil | ||
55 | + } | ||
56 | + return user, nil | ||
59 | } | 57 | } |
60 | } | 58 | } |
61 | return map[string]interface{}{}, nil | 59 | return map[string]interface{}{}, nil |
@@ -9,6 +9,18 @@ import ( | @@ -9,6 +9,18 @@ import ( | ||
9 | "time" | 9 | "time" |
10 | ) | 10 | ) |
11 | 11 | ||
12 | +// MessageCode 消息码 | ||
13 | +type MessageCode struct { | ||
14 | + Code int `json:"code"` | ||
15 | + Msg string `json:"msg"` | ||
16 | +} | ||
17 | + | ||
18 | +// GatewayResponse 统一消息返回格式 | ||
19 | +type GatewayResponse struct { | ||
20 | + MessageCode | ||
21 | + Data json.RawMessage `json:"data"` | ||
22 | +} | ||
23 | + | ||
12 | type httplibBaseServiceGateway struct { | 24 | type httplibBaseServiceGateway struct { |
13 | baseURL string | 25 | baseURL string |
14 | connectTimeout time.Duration | 26 | connectTimeout time.Duration |
@@ -59,3 +71,14 @@ func (serviceGateway *httplibBaseServiceGateway) responseHandle(response map[str | @@ -59,3 +71,14 @@ func (serviceGateway *httplibBaseServiceGateway) responseHandle(response map[str | ||
59 | } | 71 | } |
60 | return data, err | 72 | return data, err |
61 | } | 73 | } |
74 | + | ||
75 | +func (serviceGateway *httplibBaseServiceGateway) getResponseData(result GatewayResponse, data interface{}) error { | ||
76 | + if result.Code != 0 { | ||
77 | + return fmt.Errorf(result.Msg) | ||
78 | + } | ||
79 | + err := json.Unmarshal(result.Data, data) | ||
80 | + if err != nil { | ||
81 | + return err | ||
82 | + } | ||
83 | + return nil | ||
84 | +} |
1 | package service_gateway | 1 | package service_gateway |
2 | 2 | ||
3 | import ( | 3 | import ( |
4 | + "encoding/json" | ||
5 | + "fmt" | ||
4 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/constant" | 6 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/constant" |
7 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/service_gateway/translator" | ||
8 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/log" | ||
5 | "strconv" | 9 | "strconv" |
6 | "strings" | 10 | "strings" |
7 | "time" | 11 | "time" |
@@ -12,29 +16,43 @@ type HttplibUserServiceGateway struct { | @@ -12,29 +16,43 @@ type HttplibUserServiceGateway struct { | ||
12 | } | 16 | } |
13 | 17 | ||
14 | // GetUser 获取用户 | 18 | // GetUser 获取用户 |
15 | -func (serviceGateway *HttplibUserServiceGateway) GetUser(companyId int64, orgId int64, uid int64) (map[string]interface{}, error) { | ||
16 | - companyIdStr := strconv.FormatInt(companyId, 10) | ||
17 | - url := strings.Join([]string{serviceGateway.baseURL, "companies/" + companyIdStr + "/users/get-user"}, "/") | 19 | +func (serviceGateway *HttplibUserServiceGateway) GetUser(companyId int64, orgId int64, uid int64) (*translator.UserDetail, error) { |
20 | + uidStr := strconv.FormatInt(uid, 10) | ||
21 | + url := serviceGateway.baseURL + "/user/" + uidStr | ||
18 | request := serviceGateway.createRequest(url, "get") | 22 | request := serviceGateway.createRequest(url, "get") |
19 | options := make(map[string]interface{}) | 23 | options := make(map[string]interface{}) |
20 | - options["uid"] = uid | ||
21 | _, err1 := request.JSONBody(options) | 24 | _, err1 := request.JSONBody(options) |
22 | if err1 != nil { | 25 | if err1 != nil { |
23 | return nil, err1 | 26 | return nil, err1 |
24 | } | 27 | } |
25 | - response := make(map[string]interface{}) | ||
26 | - err2 := request.ToJSON(&response) | ||
27 | - if err2 != nil { | ||
28 | - return nil, err2 | ||
29 | - } | ||
30 | - data, err := serviceGateway.responseHandle(response) | ||
31 | - return data, err | 28 | + //response := make(map[string]interface{}) |
29 | + //err2 := request.ToJSON(&response) | ||
30 | + //if err2 != nil { | ||
31 | + // return nil, err2 | ||
32 | + //} | ||
33 | + //data, err := serviceGateway.responseHandle(response) | ||
34 | + //return data, err | ||
35 | + byteResult, err := request.Bytes() | ||
36 | + if err != nil { | ||
37 | + return nil, fmt.Errorf("获取获取用户失败:%w", err) | ||
38 | + } | ||
39 | + log.Logger.Debug("获取用户模块请求数据:获取用户。", map[string]interface{}{ | ||
40 | + "result": string(byteResult), | ||
41 | + }) | ||
42 | + var result GatewayResponse | ||
43 | + err = json.Unmarshal(byteResult, &result) | ||
44 | + if err != nil { | ||
45 | + return nil, fmt.Errorf("解析获取用户:%w", err) | ||
46 | + } | ||
47 | + var data translator.UserDetail | ||
48 | + err = serviceGateway.getResponseData(result, &data) | ||
49 | + return &data, err | ||
32 | } | 50 | } |
33 | 51 | ||
34 | // GetUsers 获取用户 | 52 | // GetUsers 获取用户 |
35 | func (serviceGateway *HttplibUserServiceGateway) GetUsers(companyId int64, orgId int64, uids []int64) (map[string]interface{}, error) { | 53 | func (serviceGateway *HttplibUserServiceGateway) GetUsers(companyId int64, orgId int64, uids []int64) (map[string]interface{}, error) { |
36 | companyIdStr := strconv.FormatInt(companyId, 10) | 54 | companyIdStr := strconv.FormatInt(companyId, 10) |
37 | - url := strings.Join([]string{serviceGateway.baseURL, "companies/" + companyIdStr + "/users/get-user"}, "/") | 55 | + url := strings.Join([]string{serviceGateway.baseURL, "user/" + companyIdStr + "/users/get-user"}, "/") |
38 | request := serviceGateway.createRequest(url, "get") | 56 | request := serviceGateway.createRequest(url, "get") |
39 | options := make(map[string]interface{}) | 57 | options := make(map[string]interface{}) |
40 | options["uids"] = uids | 58 | options["uids"] = uids |
@@ -54,19 +72,25 @@ func (serviceGateway *HttplibUserServiceGateway) GetUsers(companyId int64, orgId | @@ -54,19 +72,25 @@ func (serviceGateway *HttplibUserServiceGateway) GetUsers(companyId int64, orgId | ||
54 | // GetCompany 获取公司信息 | 72 | // GetCompany 获取公司信息 |
55 | func (serviceGateway *HttplibUserServiceGateway) GetCompany(companyId int64) (map[string]interface{}, error) { | 73 | func (serviceGateway *HttplibUserServiceGateway) GetCompany(companyId int64) (map[string]interface{}, error) { |
56 | companyIdStr := strconv.FormatInt(companyId, 10) | 74 | companyIdStr := strconv.FormatInt(companyId, 10) |
57 | - url := strings.Join([]string{serviceGateway.baseURL, "companies/" + companyIdStr}, "/") | 75 | + url := serviceGateway.baseURL + "/company/" + companyIdStr |
58 | request := serviceGateway.createRequest(url, "get") | 76 | request := serviceGateway.createRequest(url, "get") |
59 | options := make(map[string]interface{}) | 77 | options := make(map[string]interface{}) |
60 | - options["companyId"] = companyId | ||
61 | _, err1 := request.JSONBody(options) | 78 | _, err1 := request.JSONBody(options) |
62 | if err1 != nil { | 79 | if err1 != nil { |
63 | return nil, err1 | 80 | return nil, err1 |
81 | + } else { | ||
82 | + log.Logger.Debug("向用户模块请求数据:返回企业。", map[string]interface{}{ | ||
83 | + "api": "get:" + url, | ||
84 | + "param": options, | ||
85 | + }) | ||
64 | } | 86 | } |
87 | + | ||
65 | response := make(map[string]interface{}) | 88 | response := make(map[string]interface{}) |
66 | err2 := request.ToJSON(&response) | 89 | err2 := request.ToJSON(&response) |
67 | if err2 != nil { | 90 | if err2 != nil { |
68 | return nil, err2 | 91 | return nil, err2 |
69 | } | 92 | } |
93 | + | ||
70 | data, err := serviceGateway.responseHandle(response) | 94 | data, err := serviceGateway.responseHandle(response) |
71 | return data, err | 95 | return data, err |
72 | } | 96 | } |
@@ -93,9 +117,8 @@ func (serviceGateway *HttplibUserServiceGateway) GetDepartment(companyId int64, | @@ -93,9 +117,8 @@ func (serviceGateway *HttplibUserServiceGateway) GetDepartment(companyId int64, | ||
93 | 117 | ||
94 | // GetOrganization 获取组织信息 | 118 | // GetOrganization 获取组织信息 |
95 | func (serviceGateway *HttplibUserServiceGateway) GetOrganization(companyId int64, organizationId int64) (map[string]interface{}, error) { | 119 | func (serviceGateway *HttplibUserServiceGateway) GetOrganization(companyId int64, organizationId int64) (map[string]interface{}, error) { |
96 | - companyIdStr := strconv.FormatInt(companyId, 10) | ||
97 | organizationIdStr := strconv.FormatInt(organizationId, 10) | 120 | organizationIdStr := strconv.FormatInt(organizationId, 10) |
98 | - url := strings.Join([]string{serviceGateway.baseURL, "companies/" + companyIdStr + "/orgs/" + organizationIdStr}, "/") | 121 | + url := serviceGateway.baseURL + "/org/" + organizationIdStr |
99 | request := serviceGateway.createRequest(url, "get") | 122 | request := serviceGateway.createRequest(url, "get") |
100 | options := make(map[string]interface{}) | 123 | options := make(map[string]interface{}) |
101 | options["orgId"] = organizationId | 124 | options["orgId"] = organizationId |
@@ -5,6 +5,7 @@ type UserServiceGateway interface { | @@ -5,6 +5,7 @@ type UserServiceGateway interface { | ||
5 | GetUsers(companyId int64, orgId int64, uids []int64) (map[string]interface{}, error) | 5 | GetUsers(companyId int64, orgId int64, uids []int64) (map[string]interface{}, error) |
6 | GetCompany(companyId int64) (map[string]interface{}, error) | 6 | GetCompany(companyId int64) (map[string]interface{}, error) |
7 | GetOrganization(companyId int64, organizationId int64) (map[string]interface{}, error) | 7 | GetOrganization(companyId int64, organizationId int64) (map[string]interface{}, error) |
8 | + GetDepartment(companyId int64, departmentId int64) (map[string]interface{}, error) | ||
8 | UserInMenu(companyId int64, userId int64, menuCode string) (bool, error) | 9 | UserInMenu(companyId int64, userId int64, menuCode string) (bool, error) |
9 | UserInOrganization(companyId int64, orgId int64, userId int64) (bool, error) | 10 | UserInOrganization(companyId int64, orgId int64, userId int64) (bool, error) |
10 | } | 11 | } |
1 | package translator | 1 | package translator |
2 | 2 | ||
3 | -import "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain" | 3 | +import ( |
4 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain" | ||
5 | + "time" | ||
6 | +) | ||
4 | 7 | ||
5 | type CompanyTranslator struct { | 8 | type CompanyTranslator struct { |
6 | } | 9 | } |
7 | 10 | ||
8 | -func (translator *CompanyTranslator) ToCompanyFromRepresentation(data map[string]interface{}) (*domain.Company, error) { | 11 | +type CompanyDetail struct { |
12 | + CompanyId int64 `json:"companyId"` | ||
13 | + CompanyConfig struct { | ||
14 | + SystemName string `json:"systemName"` | ||
15 | + Theme string `json:"theme"` | ||
16 | + } `json:"companyConfig"` | ||
17 | + CompanyInfo struct { | ||
18 | + CompanyName string `json:"companyName"` | ||
19 | + Scale string `json:"scale"` | ||
20 | + IndustryCategory string `json:"industryCategory"` | ||
21 | + RegisteredTime time.Time `json:"registeredTime"` | ||
22 | + } `json:"companyInfo"` | ||
23 | + Status int `json:"status"` | ||
24 | + CreatedAt time.Time `json:"createdAt"` | ||
25 | + UpdatedAt time.Time `json:"updatedAt"` | ||
26 | +} | ||
27 | + | ||
28 | +func (translator *CompanyTranslator) ToCompanyFromRepresentation(company *CompanyDetail) (*domain.Company, error) { | ||
9 | return &domain.Company{ | 29 | return &domain.Company{ |
10 | - CompanyId: 0, | ||
11 | - CompanyName: "", | 30 | + CompanyId: company.CompanyId, |
31 | + CompanyName: company.CompanyInfo.CompanyName, | ||
12 | }, nil | 32 | }, nil |
13 | } | 33 | } |
14 | 34 |
1 | package translator | 1 | package translator |
2 | 2 | ||
3 | -import "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain" | 3 | +import ( |
4 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain" | ||
5 | + "time" | ||
6 | +) | ||
4 | 7 | ||
5 | type OrganizationTranslator struct { | 8 | type OrganizationTranslator struct { |
6 | } | 9 | } |
7 | 10 | ||
8 | -func (translator *OrganizationTranslator) ToOrganizationFromRepresentation(data map[string]interface{}) (*domain.Org, error) { | 11 | +type OrganizationDetail struct { |
12 | + OrgId int64 `json:"orgId"` | ||
13 | + CompanyId int64 `json:"companyId"` | ||
14 | + CreatedAt time.Time `json:"createdAt"` | ||
15 | + UpdatedAt time.Time `json:"updatedAt"` | ||
16 | + DeletedAt time.Time `json:"deletedAt"` | ||
17 | + OrgCode string `json:"orgCode"` | ||
18 | + OrgName string `json:"orgName"` | ||
19 | + Ext struct { | ||
20 | + } `json:"ext"` | ||
21 | + IsOrg bool `json:"isOrg"` | ||
22 | + OrgStatus int `json:"orgStatus"` | ||
23 | +} | ||
24 | + | ||
25 | +func (translator *OrganizationTranslator) ToOrganizationFromRepresentation(organization *OrganizationDetail) (*domain.Org, error) { | ||
9 | return &domain.Org{ | 26 | return &domain.Org{ |
10 | - OrgId: 0, | ||
11 | - OrgName: "", | ||
12 | - Company: nil, | 27 | + OrgId: organization.OrgId, |
28 | + OrgName: organization.OrgName, | ||
29 | + Company: &domain.Company{ | ||
30 | + CompanyId: organization.CompanyId, | ||
31 | + CompanyLogo: "", | ||
32 | + CompanyName: "", | ||
33 | + }, | ||
13 | }, nil | 34 | }, nil |
14 | } | 35 | } |
15 | 36 |
1 | package translator | 1 | package translator |
2 | 2 | ||
3 | -import "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain" | 3 | +import ( |
4 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain" | ||
5 | + "time" | ||
6 | +) | ||
4 | 7 | ||
5 | type UserTranslator struct { | 8 | type UserTranslator struct { |
6 | } | 9 | } |
7 | 10 | ||
8 | -func (translator *UserTranslator) ToRelevantFromRepresentation(data map[string]interface{}) (*domain.Relevant, error) { | 11 | +type UserDetail struct { |
12 | + UserId int64 `json:"userId"` | ||
13 | + UserBaseId int64 `json:"userBaseId"` | ||
14 | + UserType int32 `json:"userType"` | ||
15 | + UserCode string `json:"userCode"` | ||
16 | + EnableStatus int32 `json:"enableStatus"` | ||
17 | + CooperationInfo struct { | ||
18 | + CooperationCompany string `json:"cooperationCompany"` | ||
19 | + CooperationDeadline time.Time `json:"cooperationDeadline"` | ||
20 | + } `json:"cooperationInfo,omitempty"` | ||
21 | + UserInfo struct { | ||
22 | + Phone string `json:"phone"` | ||
23 | + UserCode string `json:"userCode"` | ||
24 | + Email string `json:"email"` | ||
25 | + UserName string `json:"userName"` | ||
26 | + Avatar string `json:"avatar"` | ||
27 | + } `json:"userInfo,omitempty"` | ||
28 | + Company *struct { | ||
29 | + CompanyId int64 `json:"companyId"` | ||
30 | + CompanyName string `json:"companyName"` | ||
31 | + Scale string `json:"scale"` | ||
32 | + IndustryCategory string `json:"industryCategory"` | ||
33 | + RegisteredTime time.Time `json:"registeredTime"` | ||
34 | + Status int64 `json:"status"` | ||
35 | + } `json:"company,omitempty"` | ||
36 | + Org *struct { | ||
37 | + OrgId int64 `json:"orgId"` | ||
38 | + OrgCode string `json:"orgCode"` | ||
39 | + OrgName string `json:"orgName"` | ||
40 | + } `json:"org,omitempty"` | ||
41 | + Department *struct { | ||
42 | + DepartmentId int64 `json:"departmentId"` | ||
43 | + DepartmentName string `json:"departmentName"` | ||
44 | + } `json:"department,omitempty"` | ||
45 | + UserRole []struct { | ||
46 | + RoleID int64 `json:"roleId"` | ||
47 | + RoleName string `json:"roleName"` | ||
48 | + Ext struct { | ||
49 | + OrgName string `json:"orgName"` | ||
50 | + } `json:"ext,omitempty"` | ||
51 | + } `json:"userRole"` | ||
52 | + UserOrg []struct { | ||
53 | + OrgID int64 `json:"orgId"` | ||
54 | + CreatedAt time.Time `json:"createdAt"` | ||
55 | + UpdatedAt time.Time `json:"updatedAt"` | ||
56 | + DeletedAt time.Time `json:"deletedAt"` | ||
57 | + OrgName string `json:"orgName"` | ||
58 | + } `json:"userOrg"` | ||
59 | +} | ||
60 | + | ||
61 | +func (translator *UserTranslator) ToRelevantFromRepresentation(user *UserDetail) (*domain.Relevant, error) { | ||
62 | + var orgs []*domain.Org | ||
63 | + for _, org := range user.UserOrg { | ||
64 | + orgs = append(orgs, &domain.Org{ | ||
65 | + OrgId: org.OrgID, | ||
66 | + OrgName: org.OrgName, | ||
67 | + Company: &domain.Company{ | ||
68 | + CompanyId: user.Company.CompanyId, | ||
69 | + CompanyLogo: "", | ||
70 | + CompanyName: user.Company.CompanyName, | ||
71 | + }, | ||
72 | + }) | ||
73 | + } | ||
74 | + var roles []*domain.Role | ||
75 | + for _, role := range user.UserRole { | ||
76 | + roles = append(roles, &domain.Role{ | ||
77 | + RoleId: int64(role.RoleID), | ||
78 | + RoleName: role.RoleName, | ||
79 | + }) | ||
80 | + } | ||
9 | return &domain.Relevant{ | 81 | return &domain.Relevant{ |
10 | - UserId: data["userId"].(int64), | ||
11 | - UserBaseId: data["userBaseId"].(int64), | ||
12 | - Org: nil, | ||
13 | - Orgs: nil, | ||
14 | - Department: nil, | ||
15 | - Role: nil, | ||
16 | - UserInfo: nil, | ||
17 | - UserType: 0, | ||
18 | - Status: 0, | ||
19 | - Company: nil, | 82 | + UserId: user.UserId, |
83 | + UserBaseId: user.UserBaseId, | ||
84 | + Org: &domain.Org{ | ||
85 | + OrgId: user.Org.OrgId, | ||
86 | + OrgName: user.Org.OrgName, | ||
87 | + Company: &domain.Company{ | ||
88 | + CompanyId: user.Company.CompanyId, | ||
89 | + CompanyLogo: "", | ||
90 | + CompanyName: user.Company.CompanyName, | ||
91 | + }, | ||
92 | + }, | ||
93 | + Orgs: orgs, | ||
94 | + Department: &domain.Department{ | ||
95 | + DepartmentId: user.Department.DepartmentId, | ||
96 | + DepartmentName: user.Department.DepartmentName, | ||
97 | + DepartmentNumber: "", | ||
98 | + IsOrganization: false, | ||
99 | + }, | ||
100 | + Roles: roles, | ||
101 | + UserInfo: &domain.UserInfo{ | ||
102 | + UserAvatar: user.UserInfo.Avatar, | ||
103 | + UserEmail: user.UserInfo.Email, | ||
104 | + UserName: user.UserInfo.UserName, | ||
105 | + UserPhone: user.UserInfo.Phone, | ||
106 | + UserAccount: "", | ||
107 | + }, | ||
108 | + UserType: user.UserType, | ||
109 | + Status: user.EnableStatus, | ||
110 | + Company: &domain.Company{ | ||
111 | + CompanyId: user.Company.CompanyId, | ||
112 | + CompanyLogo: "", | ||
113 | + CompanyName: user.Company.CompanyName, | ||
114 | + }, | ||
20 | }, nil | 115 | }, nil |
21 | } | 116 | } |
22 | 117 |
-
请 注册 或 登录 后发表评论