fix
This commit is contained in:
parent
2d0d410c40
commit
fcf7c909a3
|
@ -2,7 +2,6 @@ package gmodel
|
|||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fusenapi/utils/handlers"
|
||||
|
||||
"gorm.io/gorm"
|
||||
|
@ -10,16 +9,9 @@ import (
|
|||
|
||||
// TODO: 使用model的属性做你想做的
|
||||
|
||||
func (p *FsResourceModel) FindOneById(ctx context.Context, resourceId string) (*FsResource, error) {
|
||||
var resp FsResource
|
||||
result := p.db.Table(p.name).WithContext(ctx).Where("resource_id =?", resourceId).Take(&resp)
|
||||
if result.Error != nil {
|
||||
// 检查 ErrRecordNotFound 错误
|
||||
if !errors.Is(result.Error, gorm.ErrRecordNotFound) {
|
||||
return nil, result.Error
|
||||
}
|
||||
}
|
||||
return &resp, nil
|
||||
func (p *FsResourceModel) FindOneById(ctx context.Context, resourceId string) (resp *FsResource, err error) {
|
||||
err = p.db.Table(p.name).WithContext(ctx).Where("resource_id =?", resourceId).Take(&resp).Error
|
||||
return resp, err
|
||||
}
|
||||
|
||||
func (p *FsResourceModel) Create(ctx context.Context, req *FsResource) (resp *FsResource, err error) {
|
||||
|
|
|
@ -48,6 +48,27 @@ func (m *MqConsumerRenderAssemble) Run(ctx context.Context, data []byte) error {
|
|||
if !ok {
|
||||
return errors.New("allmodels is nil!!")
|
||||
}
|
||||
rabbitmq := initalize.RabbitMqHandle{}
|
||||
//查询有没有缓存的资源
|
||||
resource, err := allmodels.FsResource.FindOneById(ctx, parseInfo.TaskId)
|
||||
if err != nil {
|
||||
if !errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
logx.Error("failed to find render resource:", err)
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
//有数据则直接返回
|
||||
cacheData := websocket_data.RenderImageNotify{
|
||||
TaskId: parseInfo.TaskId,
|
||||
Image: *resource.ResourceUrl,
|
||||
}
|
||||
d, _ := json.Marshal(cacheData)
|
||||
if err = rabbitmq.SendMsg(constants.RABBIT_MQ_RENDER_RESULT_DATA, d); err != nil {
|
||||
logx.Error("failed to send cache render resource to queue:RABBIT_MQ_RENDER_RESULT_DATA")
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
timeSearchBegin := time.Now().UnixMilli()
|
||||
//获取模板
|
||||
templateInfo, err := allmodels.FsProductTemplateV2.FindOneByProductIdTagIdWithSizeTable(ctx, parseInfo.RenderData.ProductId, fmt.Sprintf("%d", parseInfo.RenderData.TemplateTagId))
|
||||
|
@ -250,7 +271,6 @@ func (m *MqConsumerRenderAssemble) Run(ctx context.Context, data []byte) error {
|
|||
"folder": "", //todo 千人千面需要使用
|
||||
}
|
||||
b, _ := json.Marshal(sendData)
|
||||
rabbitmq := initalize.RabbitMqHandle{}
|
||||
if err = rabbitmq.SendMsg(constants.RABBIT_MQ_TO_UNITY, b); err != nil {
|
||||
logx.Error("发送渲染组装数据到rabbitmq失败:", err)
|
||||
return err
|
||||
|
|
|
@ -85,7 +85,7 @@ func (l *DataTransferLogic) DataTransfer(svcCtx *svc.ServiceContext, w http.Resp
|
|||
}
|
||||
defer conn.Close()
|
||||
//鉴权不成功10秒后断开
|
||||
var (
|
||||
/*var (
|
||||
userInfo *auth.UserInfo
|
||||
isAuth bool
|
||||
)
|
||||
|
@ -102,10 +102,10 @@ func (l *DataTransferLogic) DataTransfer(svcCtx *svc.ServiceContext, w http.Resp
|
|||
//发送关闭信息
|
||||
_ = conn.WriteMessage(websocket.CloseMessage, nil)
|
||||
return
|
||||
}
|
||||
}*/
|
||||
//测试的目前写死 39
|
||||
/*var userInfo auth.UserInfo
|
||||
userInfo.UserId = 39*/
|
||||
var userInfo auth.UserInfo
|
||||
userInfo.UserId = 39
|
||||
//生成连接唯一标识
|
||||
uniqueId := websocketIdGenerator.Get()
|
||||
ws := wsConnectItem{
|
||||
|
|
Loading…
Reference in New Issue
Block a user