fusenapi/server/upload/internal/handler/uploadfilebackendhandler.go
2023-07-21 14:20:21 +08:00

36 lines
763 B
Go

package handler
import (
"net/http"
"github.com/zeromicro/go-zero/rest/httpx"
"fusenapi/utils/basic"
"fusenapi/server/upload/internal/logic"
"fusenapi/server/upload/internal/svc"
"fusenapi/server/upload/internal/types"
)
func UploadFileBackendHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.RequestUploadFileBackend
// 解析upload文件类型
err = basic.RequestFileParse(r, &req)
if err != nil {
httpx.OkJsonCtx(r.Context(), w, &basic.Response{
Code: 510,
Message: err.Error(),
})
return
}
// 创建一个业务逻辑层实例
l := logic.NewUploadFileBackendLogic(r.Context(), svcCtx)
resp := l.UploadFileBackend(&req, userinfo)
}
}