complete mobile image upload

This commit is contained in:
2024-12-18 01:08:25 +08:00
parent 58777e4b58
commit 24df28e53f
15 changed files with 526 additions and 136 deletions

View File

@@ -0,0 +1,35 @@
package upscale
import (
"github.com/zeromicro/go-zero/core/logx"
"net/http"
"github.com/zeromicro/go-zero/rest/httpx"
"schisandra-album-cloud-microservices/app/core/api/common/response"
"schisandra-album-cloud-microservices/app/core/api/internal/logic/upscale"
"schisandra-album-cloud-microservices/app/core/api/internal/svc"
"schisandra-album-cloud-microservices/app/core/api/internal/types"
)
func UploadImageHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.UploadRequest
if err := httpx.Parse(r, &req); err != nil {
httpx.ErrorCtx(r.Context(), w, err)
return
}
l := upscale.NewUploadImageLogic(r.Context(), svcCtx)
resp, err := l.UploadImage(r, &req)
if err != nil {
logx.Error(err)
httpx.WriteJsonCtx(
r.Context(),
w,
http.StatusInternalServerError,
response.ErrorWithI18n(r.Context(), "system.error"))
} else {
httpx.OkJsonCtx(r.Context(), w, resp)
}
}
}