- SendFilesToStores
This commit is contained in:
43
controllers/financial.go
Normal file
43
controllers/financial.go
Normal file
@@ -0,0 +1,43 @@
|
||||
package controllers
|
||||
|
||||
import (
|
||||
"io"
|
||||
|
||||
"github.com/astaxie/beego"
|
||||
|
||||
"git.rosy.net.cn/jx-callback/business/jxstore/financial"
|
||||
)
|
||||
|
||||
type FinancialController struct {
|
||||
beego.Controller
|
||||
}
|
||||
|
||||
// @Title 发送文件给门店
|
||||
// @Description 发送文件给门店,调用GET方法得到浏览器端参考的上传HTML实现,userfiles
|
||||
// @Param token header string true "认证token"
|
||||
// @Param isAsync query bool false "是否异步,缺省是同步"
|
||||
// @Success 200 {object} controllers.CallResult
|
||||
// @Failure 200 {object} controllers.CallResult
|
||||
// @router /SendFilesToStores [post,get]
|
||||
func (c *FinancialController) SendFilesToStores() {
|
||||
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/financial/SendFilesToStores" 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.callSendFilesToStores(func(params *tFinancialSendFilesToStoresParams) (retVal interface{}, errCode string, err error) {
|
||||
r := c.Ctx.Request
|
||||
files := r.MultipartForm.File["userfiles"]
|
||||
retVal, err = financial.SendFilesToStores(files, params.IsAsync, "test")
|
||||
return retVal, "", err
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user