Merge branch 'develop' of gitee.com:fusenpack/fusenapi into develop
This commit is contained in:
commit
318f92b869
|
@ -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")
|
||||
}
|
||||
|
|
|
@ -12,12 +12,6 @@ type RequestReadImages struct {
|
|||
}
|
||||
|
||||
type RenderNotifyReq struct {
|
||||
Sign string `json:"sign"`
|
||||
Time int64 `json:"time"`
|
||||
Info NotifyInfo `json:"info"`
|
||||
}
|
||||
|
||||
type NotifyInfo struct {
|
||||
TaskId string `json:"task_id"` //任务id
|
||||
UserId int64 `json:"user_id"`
|
||||
GuestId int64 `json:"guest_id"`
|
||||
|
|
|
@ -26,11 +26,6 @@ service render {
|
|||
|
||||
//渲染完了通知接口
|
||||
type RenderNotifyReq {
|
||||
Sign string `json:"sign"`
|
||||
Time int64 `json:"time"`
|
||||
Info NotifyInfo `json:"info"`
|
||||
}
|
||||
type NotifyInfo {
|
||||
TaskId string `json:"task_id"` //任务id
|
||||
UserId int64 `json:"user_id"`
|
||||
GuestId int64 `json:"guest_id"`
|
||||
|
|
Loading…
Reference in New Issue
Block a user