fix
This commit is contained in:
parent
7fd80315b2
commit
52df088b8c
@ -27,6 +27,11 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
|
|||||||
Path: "/upload/qrcode",
|
Path: "/upload/qrcode",
|
||||||
Handler: UploadQrcodeHandler(serverCtx),
|
Handler: UploadQrcodeHandler(serverCtx),
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
Method: http.MethodPost,
|
||||||
|
Path: "/upload/up-logo",
|
||||||
|
Handler: UploadLogoHandler(serverCtx),
|
||||||
|
},
|
||||||
},
|
},
|
||||||
rest.WithJwt(serverCtx.Config.Auth.AccessSecret),
|
rest.WithJwt(serverCtx.Config.Auth.AccessSecret),
|
||||||
)
|
)
|
||||||
|
37
server/data-transfer/internal/handler/uploadlogohandler.go
Normal file
37
server/data-transfer/internal/handler/uploadlogohandler.go
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
package handler
|
||||||
|
|
||||||
|
import (
|
||||||
|
"errors"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"github.com/zeromicro/go-zero/core/logx"
|
||||||
|
"github.com/zeromicro/go-zero/rest/httpx"
|
||||||
|
|
||||||
|
"fusenapi/server/data-transfer/internal/logic"
|
||||||
|
"fusenapi/server/data-transfer/internal/svc"
|
||||||
|
"fusenapi/server/data-transfer/internal/types"
|
||||||
|
)
|
||||||
|
|
||||||
|
func UploadLogoHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||||
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
var req types.UploadLogoReq
|
||||||
|
if err := httpx.Parse(r, &req); err != nil {
|
||||||
|
httpx.OkJsonCtx(r.Context(), w, &types.Response{
|
||||||
|
Code: 510,
|
||||||
|
Message: "parameter error",
|
||||||
|
})
|
||||||
|
logx.Info(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
l := logic.NewUploadLogoLogic(r.Context(), svcCtx)
|
||||||
|
resp := l.UploadLogo(&req)
|
||||||
|
if resp != nil {
|
||||||
|
httpx.OkJsonCtx(r.Context(), w, resp)
|
||||||
|
} else {
|
||||||
|
err := errors.New("server logic is error, resp must not be nil")
|
||||||
|
httpx.ErrorCtx(r.Context(), w, err)
|
||||||
|
logx.Error(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
30
server/data-transfer/internal/logic/uploadlogologic.go
Normal file
30
server/data-transfer/internal/logic/uploadlogologic.go
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
package logic
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"fusenapi/server/data-transfer/internal/svc"
|
||||||
|
"fusenapi/server/data-transfer/internal/types"
|
||||||
|
|
||||||
|
"github.com/zeromicro/go-zero/core/logx"
|
||||||
|
)
|
||||||
|
|
||||||
|
type UploadLogoLogic struct {
|
||||||
|
logx.Logger
|
||||||
|
ctx context.Context
|
||||||
|
svcCtx *svc.ServiceContext
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewUploadLogoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UploadLogoLogic {
|
||||||
|
return &UploadLogoLogic{
|
||||||
|
Logger: logx.WithContext(ctx),
|
||||||
|
ctx: ctx,
|
||||||
|
svcCtx: svcCtx,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (l *UploadLogoLogic) UploadLogo(req *types.UploadLogoReq) (resp *types.Response) {
|
||||||
|
// 返回值必须调用Set重新返回, resp可以空指针调用 resp.SetStatus(basic.CodeOK, data)
|
||||||
|
|
||||||
|
return resp.SetStatus(basic.CodeOK)
|
||||||
|
}
|
@ -26,6 +26,19 @@ type UploadQrcodeRsp struct {
|
|||||||
Data string `json:"d"`
|
Data string `json:"d"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type UploadLogoReq struct {
|
||||||
|
SkuId int64 `json:"skuId"`
|
||||||
|
IsRemoveBg bool `json:"is_remove_bg"`
|
||||||
|
Proportion int64 `json:"proportion"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type UploadLogoRsp struct {
|
||||||
|
NobgUrl string `json:"nobg_url"`
|
||||||
|
ThumbnailUrl string `json:"thumbnail_url"`
|
||||||
|
IsmaxProportion bool `json:"ismax_proportion"`
|
||||||
|
ImgColor []string `json:"img_color"`
|
||||||
|
}
|
||||||
|
|
||||||
type Response struct {
|
type Response struct {
|
||||||
Code int `json:"code"`
|
Code int `json:"code"`
|
||||||
Message string `json:"msg"`
|
Message string `json:"msg"`
|
||||||
|
@ -22,6 +22,9 @@ service data-transfer {
|
|||||||
//生成二维码
|
//生成二维码
|
||||||
@handler UploadQrcodeHandler
|
@handler UploadQrcodeHandler
|
||||||
post /upload/qrcode (UploadQrcodeReq) returns (response);
|
post /upload/qrcode (UploadQrcodeReq) returns (response);
|
||||||
|
//上传logo
|
||||||
|
@handler UploadLogoHandler
|
||||||
|
post /upload/up-logo (UploadLogoReq) returns (response);
|
||||||
}
|
}
|
||||||
|
|
||||||
//获取标准logo列表
|
//获取标准logo列表
|
||||||
@ -43,4 +46,17 @@ type UploadQrcodeReq {
|
|||||||
type UploadQrcodeRsp {
|
type UploadQrcodeRsp {
|
||||||
Link string `json:"link"`
|
Link string `json:"link"`
|
||||||
Data string `json:"d"`
|
Data string `json:"d"`
|
||||||
|
}
|
||||||
|
|
||||||
|
//上传logo
|
||||||
|
type UploadLogoReq {
|
||||||
|
SkuId int64 `json:"skuId"`
|
||||||
|
IsRemoveBg bool `json:"is_remove_bg"`
|
||||||
|
Proportion int64 `json:"proportion"`
|
||||||
|
}
|
||||||
|
type UploadLogoRsp {
|
||||||
|
NobgUrl string `json:"nobg_url"`
|
||||||
|
ThumbnailUrl string `json:"thumbnail_url"`
|
||||||
|
IsmaxProportion bool `json:"ismax_proportion"`
|
||||||
|
ImgColor []string `json:"img_color"`
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user