32 lines
616 B
Go
32 lines
616 B
Go
package controller
|
|
|
|
import (
|
|
"net/http"
|
|
"yintai-api/app/admin/service"
|
|
err2 "yintai-api/app/common/err"
|
|
"yintai-api/app/common/response"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
type Files struct{}
|
|
|
|
func (f *Files) Upload(ctx *gin.Context) {
|
|
file, err := ctx.FormFile("file")
|
|
if err != nil {
|
|
err2.ParamErr(err)
|
|
}
|
|
|
|
if file == nil {
|
|
err2.ParamErr()
|
|
}
|
|
|
|
res := new(service.Files).Upload(file, ctx)
|
|
ctx.JSON(http.StatusOK, response.NewRsp(res))
|
|
}
|
|
|
|
func (f *Files) UploadToken(ctx *gin.Context) {
|
|
token := new(service.Files).UploadToken()
|
|
ctx.JSON(http.StatusOK, response.NewRsp(map[string]any{"token": token}))
|
|
}
|