Files
jx-callback/controllers/yonghui.go
2019-11-13 09:57:20 +08:00

44 lines
1.3 KiB
Go

package controllers
import (
"io"
"git.rosy.net.cn/jx-callback/business/jxstore/yonghui"
"github.com/astaxie/beego"
)
//读取永辉excelAPI
type YongHuiController struct {
beego.Controller
}
// @Title 读取永辉excel文件
// @Description 读取永辉excel文件
// @Param token header string false "认证token"
// @Param isAsync query bool false "是否异步,缺省是同步"
// @Success 200 {object} controllers.CallResult
// @Failure 200 {object} controllers.CallResult
// @router /LoadExcelByYongHui [post,get]
func (c *YongHuiController) LoadExcelByYongHui() {
if c.Ctx.Input.IsGet() {
w := c.Ctx.ResponseWriter
// 上传页面
w.Header().Add("Content-Type", "text/html")
w.WriteHeader(200)
html := `
<form enctype="multipart/form-data" action="/v2/yonghui/LoadExcelByYongHui" method="POST">
Send this file: <input name="userfiles" multiple accept="*" type="file" />
<input type="submit" value="Send File" />
</form>
`
io.WriteString(w, html)
} else if c.Ctx.Input.IsPost() {
c.callLoadExcelByYongHui(func(params *tYonghuiLoadExcelByYongHuiParams) (retVal interface{}, errCode string, err error) {
r := c.Ctx.Request
files := r.MultipartForm.File["userfiles"]
retVal, err = yonghui.LoadExcelByYongHui(params.Ctx, files, params.IsAsync)
return retVal, "", err
})
}
}