From c4dc31493a1ce4e95a8feb0098bad3efa65d8294 Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Tue, 15 Aug 2023 16:50:35 +0800 Subject: [PATCH 1/2] fix --- server/render/internal/types/types.go | 6 +++--- server_api/render.api | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/server/render/internal/types/types.go b/server/render/internal/types/types.go index 959af2ce..76eff7d4 100644 --- a/server/render/internal/types/types.go +++ b/server/render/internal/types/types.go @@ -12,9 +12,9 @@ type RequestReadImages struct { } type RenderNotifyReq struct { - Sign string `json:"sign"` - Time int64 `json:"time"` - Info NotifyInfo `json:"info"` + Sign string `json:"sign"` + RequestTime string `json:"request_time"` + Info NotifyInfo `json:"info"` } type NotifyInfo struct { diff --git a/server_api/render.api b/server_api/render.api index 1fdfa90a..9e2231aa 100644 --- a/server_api/render.api +++ b/server_api/render.api @@ -26,9 +26,9 @@ service render { //渲染完了通知接口 type RenderNotifyReq { - Sign string `json:"sign"` - Time int64 `json:"time"` - Info NotifyInfo `json:"info"` + Sign string `json:"sign"` + RequestTime string `json:"request_time"` + Info NotifyInfo `json:"info"` } type NotifyInfo { TaskId string `json:"task_id"` //任务id From 35cb2ef1ce310a773e4a7a19ca4295361fbfe4f4 Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Tue, 15 Aug 2023 17:10:43 +0800 Subject: [PATCH 2/2] fix --- .../internal/logic/rendernotifylogic.go | 35 ++++++------------- server/render/internal/types/types.go | 6 ---- server_api/render.api | 5 --- 3 files changed, 10 insertions(+), 36 deletions(-) diff --git a/server/render/internal/logic/rendernotifylogic.go b/server/render/internal/logic/rendernotifylogic.go index 6a11f4bf..c49da008 100644 --- a/server/render/internal/logic/rendernotifylogic.go +++ b/server/render/internal/logic/rendernotifylogic.go @@ -39,30 +39,15 @@ func NewRenderNotifyLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Rend // } func (l *RenderNotifyLogic) RenderNotify(req *types.RenderNotifyReq, userinfo *auth.UserInfo) (resp *basic.Response) { - /*if time.Now().Unix()-120 > req.Time || req.Time > time.Now().Unix() { - return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "invalid param time") - }*/ - if req.Info.TaskId == "" { + if req.TaskId == "" { return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "invalid param task_id") } - if req.Info.Image == "" { + if req.Image == "" { return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "invalid param image") } - if req.Info.UserId == 0 && req.Info.GuestId == 0 { + if req.UserId == 0 && req.GuestId == 0 { return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "invalid user_id or guest_id") } - /* if req.Sign == "" { - return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "invalid param sign") - }*/ - //验证签名 sha256 - /*notifyByte, _ := json.Marshal(req.Info) - h := sha256.New() - h.Write([]byte(fmt.Sprintf(constants.RENDER_NOTIFY_SIGN_KEY, string(notifyByte), req.Time))) - signHex := h.Sum(nil) - sign := hex.EncodeToString(signHex) - if req.Sign != sign { - return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "invalid sign") - }*/ // 上传文件 var upload = file.Upload{ Ctx: l.ctx, @@ -70,12 +55,12 @@ func (l *RenderNotifyLogic) RenderNotify(req *types.RenderNotifyReq, userinfo *a AwsSession: l.svcCtx.AwsSession, } uploadRes, err := upload.UploadFileByBase64(&file.UploadBaseReq{ - FileHash: req.Info.TaskId, - FileData: req.Info.Image, + FileHash: req.TaskId, + FileData: req.Image, UploadBucket: 1, ApiType: 2, - UserId: req.Info.UserId, - GuestId: req.Info.GuestId, + UserId: req.UserId, + GuestId: req.GuestId, }) if err != nil { logx.Error(err) @@ -83,13 +68,13 @@ func (l *RenderNotifyLogic) RenderNotify(req *types.RenderNotifyReq, userinfo *a } //发送消息到对应的rabbitmq data := websocket_data.RenderImageNotify{ - TaskId: req.Info.TaskId, + TaskId: req.TaskId, Image: uploadRes.ResourceUrl, } d, _ := json.Marshal(data) if err = l.svcCtx.RabbitMq.SendMsg(constants.RABBIT_MQ_RENDER_RESULT_DATA, d); err != nil { logx.Error(err) - return resp.SetStatus(basic.CodeServiceErr, "failed to send data") + return resp.SetStatusWithMessage(basic.CodeServiceErr, "failed to send data") } - return resp.SetStatus(basic.CodeOK) + return resp.SetStatusWithMessage(basic.CodeOK, "success") } diff --git a/server/render/internal/types/types.go b/server/render/internal/types/types.go index 76eff7d4..ef9aad74 100644 --- a/server/render/internal/types/types.go +++ b/server/render/internal/types/types.go @@ -12,12 +12,6 @@ type RequestReadImages struct { } type RenderNotifyReq struct { - Sign string `json:"sign"` - RequestTime string `json:"request_time"` - Info NotifyInfo `json:"info"` -} - -type NotifyInfo struct { TaskId string `json:"task_id"` //任务id UserId int64 `json:"user_id"` GuestId int64 `json:"guest_id"` diff --git a/server_api/render.api b/server_api/render.api index 9e2231aa..2a717984 100644 --- a/server_api/render.api +++ b/server_api/render.api @@ -26,11 +26,6 @@ service render { //渲染完了通知接口 type RenderNotifyReq { - Sign string `json:"sign"` - RequestTime string `json:"request_time"` - Info NotifyInfo `json:"info"` -} -type NotifyInfo { TaskId string `json:"task_id"` //任务id UserId int64 `json:"user_id"` GuestId int64 `json:"guest_id"`