作者 tangxuhui

数据结构适配改造

1 -{"D:\\workspaceGo\\src\\allied-creation-gateway\\pkg\\port\\beego\\routers":1628060696735619100}  
  1 +{"D:\\workspaceGo\\src\\allied-creation-gateway\\pkg\\port\\beego\\routers":1628574006679578700}
@@ -75,30 +75,13 @@ func ToCooperationProjectInfo(param *allied_creation_cooperation.CooperationProj @@ -75,30 +75,13 @@ func ToCooperationProjectInfo(param *allied_creation_cooperation.CooperationProj
75 75
76 type CooperationApplicationItem struct { 76 type CooperationApplicationItem struct {
77 CooperationApplicationApplicant struct { 77 CooperationApplicationApplicant struct {
78 - Company struct {  
79 - CompanyID int `json:"companyId"`  
80 - CompanyLogo string `json:"companyLogo"`  
81 - CompanyName string `json:"companyName"`  
82 - } `json:"company"`  
83 - Department struct {  
84 - DepartmentID int `json:"departmentId"`  
85 - DepartmentName string `json:"departmentName"`  
86 - DepartmentNumber string `json:"departmentNumber"`  
87 - } `json:"department"`  
88 - Org struct {  
89 - OrgID int `json:"orgId"`  
90 - OrgName string `json:"orgName"`  
91 - } `json:"org"`  
92 - UserBaseID int `json:"userBaseId"`  
93 - UserID int `json:"userId"`  
94 - UserInfo struct {  
95 - UserAccount string `json:"userAccount"`  
96 - UserAvatar string `json:"userAvatar"`  
97 - UserEmail string `json:"userEmail"`  
98 - UserName string `json:"userName"`  
99 - UserPhone string `json:"userPhone"`  
100 - } `json:"userInfo"`  
101 - UserType int `json:"userType"` 78 + Company domain.CompanyData `json:"company"`
  79 + Department domain.Department `json:"department"`
  80 + Org domain.Org `json:"org"`
  81 + UserBaseID int `json:"userBaseId"`
  82 + UserID int `json:"userId"`
  83 + UserInfo domain.UserInfo `json:"userInfo"`
  84 + UserType int `json:"userType"`
102 } `json:"cooperationApplicationApplicant"` //申请人 85 } `json:"cooperationApplicationApplicant"` //申请人
103 CooperationApplicationDescription string `json:"cooperationApplicationDescription"` //描述 86 CooperationApplicationDescription string `json:"cooperationApplicationDescription"` //描述
104 CooperationApplicationID int `json:"cooperationApplicationId"` //申请id 87 CooperationApplicationID int `json:"cooperationApplicationId"` //申请id
@@ -109,12 +92,24 @@ type CooperationApplicationItem struct { @@ -109,12 +92,24 @@ type CooperationApplicationItem struct {
109 92
110 func ToCooperationApplicationItem(param *allied_creation_cooperation.CooperationApplication) *CooperationApplicationItem { 93 func ToCooperationApplicationItem(param *allied_creation_cooperation.CooperationApplication) *CooperationApplicationItem {
111 data := CooperationApplicationItem{ 94 data := CooperationApplicationItem{
112 - CooperationApplicationApplicant: param.CooperationApplicationApplicant,  
113 CooperationApplicationDescription: param.CooperationApplicationDescription, 95 CooperationApplicationDescription: param.CooperationApplicationDescription,
114 CooperationApplicationID: param.CooperationApplicationID, 96 CooperationApplicationID: param.CooperationApplicationID,
115 CooperationApplicationStatus: param.CooperationApplicationStatus, 97 CooperationApplicationStatus: param.CooperationApplicationStatus,
116 CooperationApplyTime: int(param.CooperationApplyTime.Unix()), 98 CooperationApplyTime: int(param.CooperationApplyTime.Unix()),
117 CooperationApplicationAttachment: param.CooperationApplicationAttachment, 99 CooperationApplicationAttachment: param.CooperationApplicationAttachment,
118 } 100 }
  101 + data.CooperationApplicationApplicant.Company.CompanyID = param.CooperationApplicationApplicant.Company.CompanyID
  102 + // data.CooperationApplicationApplicant.Company.CompanyLogo = param.CooperationApplicationApplicant.Company.CompanyLogo
  103 + data.CooperationApplicationApplicant.Company.CompanyName = param.CooperationApplicationApplicant.Company.CompanyName
  104 + data.CooperationApplicationApplicant.Department.DepartmentId = param.CooperationApplicationApplicant.Department.DepartmentID
  105 + data.CooperationApplicationApplicant.Department.DepartmentName = param.CooperationApplicationApplicant.Department.DepartmentName
  106 + data.CooperationApplicationApplicant.Department.DepartmentNumber = param.CooperationApplicationApplicant.Department.DepartmentNumber
  107 + data.CooperationApplicationApplicant.Org.OrgID = param.CooperationApplicationApplicant.Org.OrgID
  108 + data.CooperationApplicationApplicant.Org.OrgName = param.CooperationApplicationApplicant.Org.OrgName
  109 + data.CooperationApplicationApplicant.UserID = param.CooperationApplicationApplicant.UserID
  110 + data.CooperationApplicationApplicant.UserType = param.CooperationApplicationApplicant.UserType
  111 + data.CooperationApplicationApplicant.UserInfo.Phone = param.CooperationApplicationApplicant.UserInfo.UserPhone
  112 + data.CooperationApplicationApplicant.UserInfo.UsersName = param.CooperationApplicationApplicant.UserInfo.UserName
  113 + data.CooperationApplicationApplicant.UserInfo.UsersId = param.CooperationApplicationApplicant.UserID
119 return &data 114 return &data
120 } 115 }
1 package service 1 package service
2 2
3 import ( 3 import (
4 - "strconv"  
5 "time" 4 "time"
6 5
7 "github.com/linmadan/egglib-go/core/application" 6 "github.com/linmadan/egglib-go/core/application"
@@ -80,16 +79,15 @@ func (dividendsOrderService *DividendsOrderService) RemoveDividendsOrder(removeD @@ -80,16 +79,15 @@ func (dividendsOrderService *DividendsOrderService) RemoveDividendsOrder(removeD
80 if err := removeDividendsOrderCommand.ValidateCommand(); err != nil { 79 if err := removeDividendsOrderCommand.ValidateCommand(); err != nil {
81 return nil, application.ThrowError(application.ARG_ERROR, err.Error()) 80 return nil, application.ThrowError(application.ARG_ERROR, err.Error())
82 } 81 }
83 - dividendsOrderId := []int{}  
84 - for _, v := range removeDividendsOrderCommand.DividendsOrderId {  
85 - id, _ := strconv.Atoi(v)  
86 - dividendsOrderId = append(dividendsOrderId, id)  
87 - } 82 +
88 creationCooperationGateway := allied_creation_cooperation.NewHttplibAlliedCreationCooperation(removeDividendsOrderCommand.Operator) 83 creationCooperationGateway := allied_creation_cooperation.NewHttplibAlliedCreationCooperation(removeDividendsOrderCommand.Operator)
89 - creationCooperationGateway.DividendsOrderRemove(allied_creation_cooperation.ReqDividendsOrderRemove{  
90 - DividendsOrderId: 0, ///TODO 改换为批量删除 84 + _, err := creationCooperationGateway.DividendsOrderBatchRemove(allied_creation_cooperation.ReqDividendsOrderBatchRemove{
  85 + DividendsOrderIds: removeDividendsOrderCommand.DividendsOrderId,
91 }) 86 })
92 - return nil, nil 87 + if err != nil {
  88 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  89 + }
  90 + return removeDividendsOrderCommand, nil
93 } 91 }
94 92
95 // 查询分红订单方法 93 // 查询分红订单方法
@@ -9,7 +9,7 @@ const SERVICE_NAME = "allied-creation-gateway" @@ -9,7 +9,7 @@ const SERVICE_NAME = "allied-creation-gateway"
9 9
10 var LOG_LEVEL = "debug" 10 var LOG_LEVEL = "debug"
11 11
12 -var HTTP_PORT int = 8081 12 +var HTTP_PORT int = 8083
13 13
14 //天联共创基础模块 14 //天联共创基础模块
15 var ALLIED_CREATION_BASIC_HOST = "http://localhost:8080" 15 var ALLIED_CREATION_BASIC_HOST = "http://localhost:8080"
  1 +package domain
  2 +
  3 +//组织
  4 +type Org struct {
  5 + OrgID int `json:"orgId"`
  6 + OrgName string `json:"orgName"`
  7 +}
@@ -5,4 +5,5 @@ type UserInfo struct { @@ -5,4 +5,5 @@ type UserInfo struct {
5 UsersName string `json:"usersName"` 5 UsersName string `json:"usersName"`
6 Phone string `json:"phone"` 6 Phone string `json:"phone"`
7 UsersId int `json:"userId,string"` 7 UsersId int `json:"userId,string"`
  8 + UserCode string `json:"userCode"`
8 } 9 }
@@ -226,3 +226,34 @@ func (gateway HttplibAlliedCreationCooperation) DividendsOrderGet(param ReqDivid @@ -226,3 +226,34 @@ func (gateway HttplibAlliedCreationCooperation) DividendsOrderGet(param ReqDivid
226 err = gateway.GetResponseData(result, &data) 226 err = gateway.GetResponseData(result, &data)
227 return &data, err 227 return &data, err
228 } 228 }
  229 +
  230 +// DividendsOrderBatchRemove 批量移除分红订单
  231 +func (gateway HttplibAlliedCreationCooperation) DividendsOrderBatchRemove(param ReqDividendsOrderBatchRemove) (*DataDividendsOrderBatchRemove, error) {
  232 + url := gateway.baseUrL + "/dividends-orders/batch-remove"
  233 + method := "DELETE"
  234 + req := gateway.CreateRequest(url, method)
  235 + log.Logger.Debug("向业务模块请求数据:移除分红订单。", map[string]interface{}{
  236 + "api": method + ":" + url,
  237 + "param": param,
  238 + })
  239 + req, err := req.JSONBody(param)
  240 + if err != nil {
  241 + return nil, fmt.Errorf("请求移除分红订单失败:%w", err)
  242 + }
  243 +
  244 + byteResult, err := req.Bytes()
  245 + if err != nil {
  246 + return nil, fmt.Errorf("获取移除分红订单失败:%w", err)
  247 + }
  248 + log.Logger.Debug("获取业务模块请求数据:移除分红订单。", map[string]interface{}{
  249 + "result": string(byteResult),
  250 + })
  251 + var result service_gateway.GatewayResponse
  252 + err = json.Unmarshal(byteResult, &result)
  253 + if err != nil {
  254 + return nil, fmt.Errorf("解析移除分红订单:%w", err)
  255 + }
  256 + var data DataDividendsOrderBatchRemove
  257 + err = gateway.GetResponseData(result, &data)
  258 + return &data, err
  259 +}
@@ -162,3 +162,13 @@ type ( @@ -162,3 +162,13 @@ type (
162 DividendsOrder 162 DividendsOrder
163 } 163 }
164 ) 164 )
  165 +
  166 +//移除分红订单
  167 +type (
  168 + ReqDividendsOrderBatchRemove struct {
  169 + DividendsOrderIds []string `json:"dividendsOrderIds"`
  170 + }
  171 +
  172 + DataDividendsOrderBatchRemove struct {
  173 + }
  174 +)