diff --git a/model/gmodel/fs_cloud_render_log_gen.go b/model/gmodel/fs_cloud_render_log_gen.go index a1d8aeae..2e851c6d 100644 --- a/model/gmodel/fs_cloud_render_log_gen.go +++ b/model/gmodel/fs_cloud_render_log_gen.go @@ -8,6 +8,7 @@ import ( type FsCloudRenderLog struct { Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` // ID UserId *int64 `gorm:"default:0;" json:"user_id"` // 用户id + GuestId *int64 `gorm:"default:0;" json:"guest_id"` // 游客id PostData *string `gorm:"default:'';" json:"post_data"` // PostUrl *string `gorm:"default:'';" json:"post_url"` // Title *string `gorm:"index;default:'';" json:"title"` // diff --git a/model/gmodel/fs_resource_gen.go b/model/gmodel/fs_resource_gen.go index af635081..400dd9e4 100644 --- a/model/gmodel/fs_resource_gen.go +++ b/model/gmodel/fs_resource_gen.go @@ -17,7 +17,7 @@ type FsResource struct { Metadata *string `gorm:"default:'';" json:"metadata"` // 元数据,json格式,存储图像分率 MetaKey1 *string `gorm:"index;default:'';" json:"meta_key1"` // 需要关键信息查询的自定义属性1,可以动态增加 ApiType *int64 `gorm:"default:1;" json:"api_type"` // 调用类型:1=对外,2=对内 - BucketName *string `gorm:"default:'';" json:"bucket_name"` // 存储桶名 + BucketName *string `gorm:"default:'';" json:"bucket_name"` // 存储桶名: 1=持久 2=缓存 } type FsResourceModel struct { db *gorm.DB diff --git a/server/render/consumer/assemble_render_data.go b/server/render/consumer/assemble_render_data.go index 5f15c56d..ae168ede 100644 --- a/server/render/consumer/assemble_render_data.go +++ b/server/render/consumer/assemble_render_data.go @@ -64,11 +64,12 @@ func (m *MqConsumerRenderAssemble) Run(ctx context.Context, data []byte) error { title := "1-组装模板数据" //云渲染日志 err = allmodels.FsCloudRenderLog.Create(ctx, &gmodel.FsCloudRenderLog{ - UserId: &parseInfo.RenderData.UserId, - Title: &title, - Time: &renderLogTime, - Tag: &parseInfo.RenderId, - Ctime: &now, + UserId: &parseInfo.RenderData.UserId, + GuestId: &parseInfo.RenderData.GuestId, + Title: &title, + Time: &renderLogTime, + Tag: &parseInfo.RenderId, + Ctime: &now, }) if err != nil { logx.Error(err) @@ -116,11 +117,12 @@ func (m *MqConsumerRenderAssemble) Run(ctx context.Context, data []byte) error { now = time.Now().Unix() pyRequestTime := time.Now().UnixMilli() - pyapiBeginTime err = allmodels.FsCloudRenderLog.Create(ctx, &gmodel.FsCloudRenderLog{ - UserId: &parseInfo.RenderData.UserId, - Title: &title, - Time: &pyRequestTime, - Tag: &parseInfo.RenderId, - Ctime: &now, + UserId: &parseInfo.RenderData.UserId, + GuestId: &parseInfo.RenderData.GuestId, + Title: &title, + Time: &pyRequestTime, + Tag: &parseInfo.RenderId, + Ctime: &now, }) if err != nil { logx.Error(err) @@ -138,6 +140,7 @@ func (m *MqConsumerRenderAssemble) Run(ctx context.Context, data []byte) error { pyRspStr := string(pyRspBytes) err = allmodels.FsCloudRenderLog.Create(ctx, &gmodel.FsCloudRenderLog{ UserId: &parseInfo.RenderData.UserId, + GuestId: &parseInfo.RenderData.GuestId, PostUrl: &url, PostData: &postData, Result: &pyRspStr, @@ -225,11 +228,12 @@ func (m *MqConsumerRenderAssemble) Run(ctx context.Context, data []byte) error { title = "接收到python刀版图 -> 3-组装MQ渲染任务队列" now = time.Now().Unix() err = allmodels.FsCloudRenderLog.Create(ctx, &gmodel.FsCloudRenderLog{ - UserId: &parseInfo.RenderData.UserId, - Title: &title, - Time: &timePinjie, - Tag: &parseInfo.RenderId, - Ctime: &now, + UserId: &parseInfo.RenderData.UserId, + GuestId: &parseInfo.RenderData.GuestId, + Title: &title, + Time: &timePinjie, + Tag: &parseInfo.RenderId, + Ctime: &now, }) if err != nil { logx.Error(err) diff --git a/server/websocket/internal/logic/datatransferlogic.go b/server/websocket/internal/logic/datatransferlogic.go index a282f726..52f25a61 100644 --- a/server/websocket/internal/logic/datatransferlogic.go +++ b/server/websocket/internal/logic/datatransferlogic.go @@ -65,13 +65,14 @@ var ( type wsConnectItem struct { conn *websocket.Conn //websocket的连接 rabbitMq *initalize.RabbitMqHandle - closeChan chan struct{} //ws连接关闭chan - isClose bool //是否已经关闭 - uniqueId uint64 //ws连接唯一标识 - inChan chan []byte //接受消息缓冲通道 - outChan chan []byte //发送回客户端的消息 - mutex sync.Mutex //互斥锁 - userId int64 + closeChan chan struct{} //ws连接关闭chan + isClose bool //是否已经关闭 + uniqueId uint64 //ws连接唯一标识 + inChan chan []byte //接受消息缓冲通道 + outChan chan []byte //发送回客户端的消息 + mutex sync.Mutex //互斥锁 + userId int64 //用户id + guestId int64 //游客id renderProperty renderProperty //扩展云渲染属性 } @@ -84,7 +85,7 @@ func (l *DataTransferLogic) DataTransfer(svcCtx *svc.ServiceContext, w http.Resp } defer conn.Close() //鉴权不成功10秒后断开 - /*var ( + var ( userInfo *auth.UserInfo isAuth bool ) @@ -101,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{ @@ -114,16 +115,13 @@ func (l *DataTransferLogic) DataTransfer(svcCtx *svc.ServiceContext, w http.Resp closeChan: make(chan struct{}, 1), inChan: make(chan []byte, 1000), outChan: make(chan []byte, 1000), + userId: userInfo.UserId, + guestId: userInfo.GuestId, renderProperty: renderProperty{ renderImageTask: make(map[string]string), renderImageTaskCtlChan: make(chan renderImageControlChanItem, 100), }, } - if userInfo.UserId > 0 { - ws.userId = userInfo.UserId - } else { - ws.userId = userInfo.GuestId - } //保存连接 mapConnPool.Store(uniqueId, ws) defer ws.close() diff --git a/server/websocket/internal/logic/ws_render_image_logic.go b/server/websocket/internal/logic/ws_render_image_logic.go index 2b2e860b..225c63dd 100644 --- a/server/websocket/internal/logic/ws_render_image_logic.go +++ b/server/websocket/internal/logic/ws_render_image_logic.go @@ -30,7 +30,9 @@ func (w *wsConnectItem) renderImage(data []byte) { return } logx.Info("收到请求云渲染图片数据:", renderImageData) + //用户id赋值 renderImageData.RenderData.UserId = w.userId + renderImageData.RenderData.GuestId = w.guestId //把需要渲染的图片任务加进去 taskId := hash.JsonHashKey(renderImageData.RenderData) w.renderProperty.renderImageTaskCtlChan <- renderImageControlChanItem{ diff --git a/utils/websocket_data/render_data.go b/utils/websocket_data/render_data.go index 5ec90785..18d272ed 100644 --- a/utils/websocket_data/render_data.go +++ b/utils/websocket_data/render_data.go @@ -16,6 +16,7 @@ type RenderData struct { ProductId int64 `json:"product_id"` //产品id Data interface{} `json:"data"` //面片数据 UserId int64 `json:"user_id"` //用户id + GuestId int64 `json:"guest_id"` //游客id } // websocket发送渲染完的数据