正在显示
1 个修改的文件
包含
16 行增加
和
5 行删除
@@ -11,6 +11,7 @@ import ( | @@ -11,6 +11,7 @@ import ( | ||
11 | 11 | ||
12 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/constant" | 12 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/constant" |
13 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/port/beego/controllers" | 13 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/port/beego/controllers" |
14 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/port/beego/middleware" | ||
14 | 15 | ||
15 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain" | 16 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain" |
16 | 17 | ||
@@ -202,11 +203,21 @@ func (controller *ExcelDataController) FileImport() { | @@ -202,11 +203,21 @@ func (controller *ExcelDataController) FileImport() { | ||
202 | formWriter.Close() | 203 | formWriter.Close() |
203 | target, _ := url.Parse(constant.ALLIED_CREATION_MANUFACTURE_HOST) | 204 | target, _ := url.Parse(constant.ALLIED_CREATION_MANUFACTURE_HOST) |
204 | targetPath := strings.Replace(controller.Ctx.Request.URL.Path, "/v1/web", "", 1) | 205 | targetPath := strings.Replace(controller.Ctx.Request.URL.Path, "/v1/web", "", 1) |
205 | - resp, err := http.Post( | ||
206 | - target.String()+targetPath, | ||
207 | - formWriter.FormDataContentType(), | ||
208 | - bodyBuf, | ||
209 | - ) | 206 | + newReq, _ := http.NewRequest(http.MethodPost, target.String()+targetPath, bodyBuf) |
207 | + // 传递当前登录信息(可配置) | ||
208 | + loginToken, ok := middleware.FormCtxLoginToken(controller.Ctx) | ||
209 | + if ok && loginToken.CompanyId > 0 && loginToken.OrgId > 0 { | ||
210 | + newReq.Header.Set("companyId", fmt.Sprintf("%v", loginToken.CompanyId)) | ||
211 | + newReq.Header.Set("orgId", fmt.Sprintf("%v", loginToken.OrgId)) | ||
212 | + newReq.Header.Set("userId", fmt.Sprintf("%v", loginToken.UserId)) | ||
213 | + orgIdList := make([]string, 0) | ||
214 | + for i := range loginToken.OrgIds { | ||
215 | + orgIdList = append(orgIdList, fmt.Sprintf("%d", loginToken.OrgIds[i])) | ||
216 | + } | ||
217 | + newReq.Header.Add("orgIds", fmt.Sprintf("%v", strings.Join(orgIdList, ","))) | ||
218 | + } | ||
219 | + newReq.Header.Set("Content-Type", formWriter.FormDataContentType()) | ||
220 | + resp, err := http.DefaultClient.Do(newReq) | ||
210 | if err != nil { | 221 | if err != nil { |
211 | e := application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 222 | e := application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
212 | controller.Response(nil, e) | 223 | controller.Response(nil, e) |
-
请 注册 或 登录 后发表评论