fix
This commit is contained in:
parent
7542c35184
commit
35cb2ef1ce
|
@ -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) {
|
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() {
|
if req.TaskId == "" {
|
||||||
return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "invalid param time")
|
|
||||||
}*/
|
|
||||||
if req.Info.TaskId == "" {
|
|
||||||
return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "invalid param task_id")
|
return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "invalid param task_id")
|
||||||
}
|
}
|
||||||
if req.Info.Image == "" {
|
if req.Image == "" {
|
||||||
return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "invalid param 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")
|
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{
|
var upload = file.Upload{
|
||||||
Ctx: l.ctx,
|
Ctx: l.ctx,
|
||||||
|
@ -70,12 +55,12 @@ func (l *RenderNotifyLogic) RenderNotify(req *types.RenderNotifyReq, userinfo *a
|
||||||
AwsSession: l.svcCtx.AwsSession,
|
AwsSession: l.svcCtx.AwsSession,
|
||||||
}
|
}
|
||||||
uploadRes, err := upload.UploadFileByBase64(&file.UploadBaseReq{
|
uploadRes, err := upload.UploadFileByBase64(&file.UploadBaseReq{
|
||||||
FileHash: req.Info.TaskId,
|
FileHash: req.TaskId,
|
||||||
FileData: req.Info.Image,
|
FileData: req.Image,
|
||||||
UploadBucket: 1,
|
UploadBucket: 1,
|
||||||
ApiType: 2,
|
ApiType: 2,
|
||||||
UserId: req.Info.UserId,
|
UserId: req.UserId,
|
||||||
GuestId: req.Info.GuestId,
|
GuestId: req.GuestId,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logx.Error(err)
|
logx.Error(err)
|
||||||
|
@ -83,13 +68,13 @@ func (l *RenderNotifyLogic) RenderNotify(req *types.RenderNotifyReq, userinfo *a
|
||||||
}
|
}
|
||||||
//发送消息到对应的rabbitmq
|
//发送消息到对应的rabbitmq
|
||||||
data := websocket_data.RenderImageNotify{
|
data := websocket_data.RenderImageNotify{
|
||||||
TaskId: req.Info.TaskId,
|
TaskId: req.TaskId,
|
||||||
Image: uploadRes.ResourceUrl,
|
Image: uploadRes.ResourceUrl,
|
||||||
}
|
}
|
||||||
d, _ := json.Marshal(data)
|
d, _ := json.Marshal(data)
|
||||||
if err = l.svcCtx.RabbitMq.SendMsg(constants.RABBIT_MQ_RENDER_RESULT_DATA, d); err != nil {
|
if err = l.svcCtx.RabbitMq.SendMsg(constants.RABBIT_MQ_RENDER_RESULT_DATA, d); err != nil {
|
||||||
logx.Error(err)
|
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")
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,12 +12,6 @@ type RequestReadImages struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type RenderNotifyReq 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
|
TaskId string `json:"task_id"` //任务id
|
||||||
UserId int64 `json:"user_id"`
|
UserId int64 `json:"user_id"`
|
||||||
GuestId int64 `json:"guest_id"`
|
GuestId int64 `json:"guest_id"`
|
||||||
|
|
|
@ -26,11 +26,6 @@ service render {
|
||||||
|
|
||||||
//渲染完了通知接口
|
//渲染完了通知接口
|
||||||
type RenderNotifyReq {
|
type RenderNotifyReq {
|
||||||
Sign string `json:"sign"`
|
|
||||||
RequestTime string `json:"request_time"`
|
|
||||||
Info NotifyInfo `json:"info"`
|
|
||||||
}
|
|
||||||
type NotifyInfo {
|
|
||||||
TaskId string `json:"task_id"` //任务id
|
TaskId string `json:"task_id"` //任务id
|
||||||
UserId int64 `json:"user_id"`
|
UserId int64 `json:"user_id"`
|
||||||
GuestId int64 `json:"guest_id"`
|
GuestId int64 `json:"guest_id"`
|
||||||
|
|
Loading…
Reference in New Issue
Block a user