正在显示
5 个修改的文件
包含
54 行增加
和
18 行删除
@@ -138,6 +138,7 @@ func (dividendsEstimateService *DividendsEstimateService) ListMoneyIncentivesEst | @@ -138,6 +138,7 @@ func (dividendsEstimateService *DividendsEstimateService) ListMoneyIncentivesEst | ||
138 | if count, cooperationContracts, err := cooperationContractRepository.Find(tool_funs.SimpleStructToMap(listMoneyIncentivesEstimateQuery)); err != nil { | 138 | if count, cooperationContracts, err := cooperationContractRepository.Find(tool_funs.SimpleStructToMap(listMoneyIncentivesEstimateQuery)); err != nil { |
139 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 139 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
140 | } else { | 140 | } else { |
141 | + // TODO 判断承接人是否已分红 | ||
141 | var moneyIncentivesEstimateDtos []*dto.MoneyIncentivesEstimateDto | 142 | var moneyIncentivesEstimateDtos []*dto.MoneyIncentivesEstimateDto |
142 | for _, cooperationContract := range cooperationContracts { | 143 | for _, cooperationContract := range cooperationContracts { |
143 | moneyIncentivesEstimateDto := &dto.MoneyIncentivesEstimateDto{} | 144 | moneyIncentivesEstimateDto := &dto.MoneyIncentivesEstimateDto{} |
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 DepartmentService struct { | 8 | type DepartmentService struct { |
6 | } | 9 | } |
7 | 10 | ||
8 | func (service *DepartmentService) DepartmentFrom(companyId int64, departmentId int64) (*domain.Department, error) { | 11 | func (service *DepartmentService) DepartmentFrom(companyId int64, departmentId int64) (*domain.Department, error) { |
9 | - return nil, nil | 12 | + if departmentAdaptor, err := adaptor.NewDepartmentAdaptor(); err != nil { |
13 | + return nil, err | ||
14 | + } else { | ||
15 | + if department, err := departmentAdaptor.ToDepartment(companyId, departmentId); err != nil { | ||
16 | + return nil, err | ||
17 | + } else { | ||
18 | + return department, nil | ||
19 | + } | ||
20 | + } | ||
10 | } | 21 | } |
11 | 22 | ||
12 | func NewDepartmentService() (*DepartmentService, error) { | 23 | func NewDepartmentService() (*DepartmentService, error) { |
@@ -95,23 +95,30 @@ func (serviceGateway *HttplibUserServiceGateway) GetCompany(companyId int64) (*t | @@ -95,23 +95,30 @@ func (serviceGateway *HttplibUserServiceGateway) GetCompany(companyId int64) (*t | ||
95 | } | 95 | } |
96 | 96 | ||
97 | // GetDepartment 获取部门信息 | 97 | // GetDepartment 获取部门信息 |
98 | -func (serviceGateway *HttplibUserServiceGateway) GetDepartment(companyId int64, departmentId int64) (map[string]interface{}, error) { | ||
99 | - companyIdStr := strconv.FormatInt(companyId, 10) | ||
100 | - url := strings.Join([]string{serviceGateway.baseURL, "companies/" + companyIdStr}, "/") | 98 | +func (serviceGateway *HttplibUserServiceGateway) GetDepartment(companyId int64, departmentId int64) (*translator.DepartmentDetail, error) { |
99 | + departmentIdStr := strconv.FormatInt(departmentId, 10) | ||
100 | + url := serviceGateway.baseURL + "/org/" + departmentIdStr | ||
101 | request := serviceGateway.createRequest(url, "get") | 101 | request := serviceGateway.createRequest(url, "get") |
102 | options := make(map[string]interface{}) | 102 | options := make(map[string]interface{}) |
103 | - options["departmentId"] = departmentId | ||
104 | _, err1 := request.JSONBody(options) | 103 | _, err1 := request.JSONBody(options) |
105 | if err1 != nil { | 104 | if err1 != nil { |
106 | return nil, err1 | 105 | return nil, err1 |
107 | } | 106 | } |
108 | - response := make(map[string]interface{}) | ||
109 | - err2 := request.ToJSON(&response) | ||
110 | - if err2 != nil { | ||
111 | - return nil, err2 | 107 | + byteResult, err := request.Bytes() |
108 | + if err != nil { | ||
109 | + return nil, fmt.Errorf("获取返回组织失败:%w", err) | ||
112 | } | 110 | } |
113 | - data, err := serviceGateway.responseHandle(response) | ||
114 | - return data, err | 111 | + log.Logger.Debug("获取用户模块请求数据:返回部门。", map[string]interface{}{ |
112 | + "result": string(byteResult), | ||
113 | + }) | ||
114 | + var result GatewayResponse | ||
115 | + err = json.Unmarshal(byteResult, &result) | ||
116 | + if err != nil { | ||
117 | + return nil, fmt.Errorf("解析返回组织:%w", err) | ||
118 | + } | ||
119 | + var data translator.DepartmentDetail | ||
120 | + err = serviceGateway.getResponseData(result, &data) | ||
121 | + return &data, err | ||
115 | } | 122 | } |
116 | 123 | ||
117 | // GetOrganization 获取组织信息 | 124 | // GetOrganization 获取组织信息 |
@@ -7,7 +7,7 @@ type UserServiceGateway interface { | @@ -7,7 +7,7 @@ type UserServiceGateway interface { | ||
7 | GetUsers(companyId int64, orgId int64, uids []int64) (map[string]interface{}, error) | 7 | GetUsers(companyId int64, orgId int64, uids []int64) (map[string]interface{}, error) |
8 | GetCompany(companyId int64) (*translator.CompanyDetail, error) | 8 | GetCompany(companyId int64) (*translator.CompanyDetail, error) |
9 | GetOrganization(companyId int64, organizationId int64) (*translator.OrganizationDetail, error) | 9 | GetOrganization(companyId int64, organizationId int64) (*translator.OrganizationDetail, error) |
10 | - GetDepartment(companyId int64, departmentId int64) (map[string]interface{}, error) | 10 | + GetDepartment(companyId int64, departmentId int64) (*translator.DepartmentDetail, error) |
11 | UserInMenu(companyId int64, userId int64, menuCode string) (bool, error) | 11 | UserInMenu(companyId int64, userId int64, menuCode string) (bool, error) |
12 | UserInOrganization(companyId int64, orgId int64, userId int64) (bool, error) | 12 | UserInOrganization(companyId int64, orgId int64, userId int64) (bool, error) |
13 | } | 13 | } |
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 DepartmentTranslator struct { | 8 | type DepartmentTranslator struct { |
6 | } | 9 | } |
7 | 10 | ||
8 | -func (translator *DepartmentTranslator) ToDepartmentFromRepresentation(data map[string]interface{}) (*domain.Department, error) { | 11 | +type DepartmentDetail 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 int `json:"isOrg"` | ||
22 | + OrgStatus int `json:"orgStatus"` | ||
23 | +} | ||
24 | + | ||
25 | +func (translator *DepartmentTranslator) ToDepartmentFromRepresentation(department *DepartmentDetail) (*domain.Department, error) { | ||
9 | return &domain.Department{ | 26 | return &domain.Department{ |
10 | - DepartmentId: 0, | ||
11 | - DepartmentName: "", | ||
12 | - DepartmentNumber: "", | 27 | + DepartmentId: department.OrgId, |
28 | + DepartmentName: department.OrgName, | ||
29 | + DepartmentNumber: department.OrgCode, | ||
13 | IsOrganization: false, | 30 | IsOrganization: false, |
14 | }, nil | 31 | }, nil |
15 | } | 32 | } |
-
请 注册 或 登录 后发表评论