27 lines
675 B
Go
27 lines
675 B
Go
|
|
package upload
|
||
|
|
|
||
|
|
import (
|
||
|
|
"net/http"
|
||
|
|
|
||
|
|
uploadlogic "qnc-server/app/main/api/internal/logic/upload"
|
||
|
|
"qnc-server/app/main/api/internal/svc"
|
||
|
|
"qnc-server/app/main/api/internal/types"
|
||
|
|
"qnc-server/common/result"
|
||
|
|
|
||
|
|
"github.com/zeromicro/go-zero/rest/httpx"
|
||
|
|
)
|
||
|
|
|
||
|
|
func ServeUploadHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||
|
|
return func(w http.ResponseWriter, r *http.Request) {
|
||
|
|
var req types.ServeUploadFileReq
|
||
|
|
if err := httpx.Parse(r, &req); err != nil {
|
||
|
|
result.ParamErrorResult(r, w, err)
|
||
|
|
return
|
||
|
|
}
|
||
|
|
l := uploadlogic.NewServeUploadLogic(r.Context(), svcCtx)
|
||
|
|
if err := l.ServeUpload(req.Name, w); err != nil {
|
||
|
|
result.HttpResult(r, w, nil, err)
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|