|
|
@ -4,6 +4,7 @@ package om |
|
|
|
|
|
|
|
import ( |
|
|
|
model "LAPP_GAAS_GFrame_BACKEND/models/om" |
|
|
|
"LAPP_GAAS_GFrame_BACKEND/utils" |
|
|
|
"LAPP_GAAS_GFrame_BACKEND/web/middleware/jwts" |
|
|
|
"LAPP_GAAS_GFrame_BACKEND/web/models" |
|
|
|
"LAPP_GAAS_GFrame_BACKEND/web/supports" |
|
|
@ -370,3 +371,80 @@ func RegisterUpdateDemandHead(party router.Party, path string, method func(*mode |
|
|
|
|
|
|
|
RegisterMultiDemandHead(party, "PUT", path, method) |
|
|
|
} |
|
|
|
|
|
|
|
/****************************************************************************** |
|
|
|
* |
|
|
|
* @Function Name : RegisterUploadDemandHeadExcel |
|
|
|
*----------------------------------------------------------------------------- |
|
|
|
* |
|
|
|
* @Description : 为一个插入单条DemandHead的方法注册路由 |
|
|
|
* |
|
|
|
* @Function Parameters : 路由分组 |
|
|
|
* |
|
|
|
* @Function Parameters : 路径 |
|
|
|
* |
|
|
|
* @Function Parameters : 实际处理请求的方法 |
|
|
|
* |
|
|
|
* @Author : 代码生成器创建 |
|
|
|
* |
|
|
|
* @Date : 2021-04-21 10:27:00 |
|
|
|
* |
|
|
|
******************************************************************************/ |
|
|
|
func RegisterUploadDemandHeadExcel(party router.Party, path string, method func(*models.Usertab, string, string) error) { |
|
|
|
|
|
|
|
RegisterUploadExcel(party, "POST", path, method) |
|
|
|
} |
|
|
|
|
|
|
|
/****************************************************************************** |
|
|
|
* |
|
|
|
* @Function Name : RegisterOneDemandHead |
|
|
|
*----------------------------------------------------------------------------- |
|
|
|
* |
|
|
|
* @Description : 为一个处理单条DemandHead的方法注册路由 |
|
|
|
* |
|
|
|
* @Function Parameters : 路由分组 |
|
|
|
* |
|
|
|
* @Function Parameters : HTTP方法 |
|
|
|
* |
|
|
|
* @Function Parameters : 路径 |
|
|
|
* |
|
|
|
* @Function Parameters : 实际处理请求的方法 |
|
|
|
* |
|
|
|
* @Author : 代码生成器创建 |
|
|
|
* |
|
|
|
* @Date : 2021-04-21 10:27:00 |
|
|
|
* |
|
|
|
******************************************************************************/ |
|
|
|
func RegisterUploadExcel(party router.Party, httpMethod string, path string, method func(*models.Usertab, string, string) error) { |
|
|
|
|
|
|
|
party.Handle(httpMethod, path, func(ctx iris.Context) { |
|
|
|
user, ok := jwts.ParseToken(ctx) |
|
|
|
if !ok { |
|
|
|
supports.Error(ctx, iris.StatusBadRequest, supports.ParseParamsFailur, nil) |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
var err error = nil |
|
|
|
//form := ctx.Request().MultipartForm
|
|
|
|
_, info, err := ctx.FormFile("uploadfile") |
|
|
|
if err != nil { |
|
|
|
supports.Error(ctx, iris.StatusBadRequest, "获取上传文件出错,err: " + err.Error() + err.Error(), nil) |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
guid := utils.MakeOrderSn("OM") |
|
|
|
savePath := "web/public/uploadxlsx/" + guid + ".xlsx" |
|
|
|
err = utils.SaveUploadedFile(info, savePath) |
|
|
|
if err != nil { |
|
|
|
supports.Error(ctx, iris.StatusBadRequest, "保存上传文件出错,err: " + err.Error() + err.Error(), nil) |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
err = method(user, savePath, info.Filename) |
|
|
|
if err != nil { |
|
|
|
supports.Error(ctx, iris.StatusBadRequest, err.Error(), nil) |
|
|
|
return |
|
|
|
} |
|
|
|
supports.Ok(ctx, supports.OptionSuccess, nil) |
|
|
|
}) |
|
|
|
} |