fix
This commit is contained in:
parent
b1abc92b16
commit
e185ae7458
|
@ -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"` //
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -65,6 +65,7 @@ func (m *MqConsumerRenderAssemble) Run(ctx context.Context, data []byte) error {
|
|||
//云渲染日志
|
||||
err = allmodels.FsCloudRenderLog.Create(ctx, &gmodel.FsCloudRenderLog{
|
||||
UserId: &parseInfo.RenderData.UserId,
|
||||
GuestId: &parseInfo.RenderData.GuestId,
|
||||
Title: &title,
|
||||
Time: &renderLogTime,
|
||||
Tag: &parseInfo.RenderId,
|
||||
|
@ -117,6 +118,7 @@ func (m *MqConsumerRenderAssemble) Run(ctx context.Context, data []byte) error {
|
|||
pyRequestTime := time.Now().UnixMilli() - pyapiBeginTime
|
||||
err = allmodels.FsCloudRenderLog.Create(ctx, &gmodel.FsCloudRenderLog{
|
||||
UserId: &parseInfo.RenderData.UserId,
|
||||
GuestId: &parseInfo.RenderData.GuestId,
|
||||
Title: &title,
|
||||
Time: &pyRequestTime,
|
||||
Tag: &parseInfo.RenderId,
|
||||
|
@ -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,
|
||||
|
@ -226,6 +229,7 @@ func (m *MqConsumerRenderAssemble) Run(ctx context.Context, data []byte) error {
|
|||
now = time.Now().Unix()
|
||||
err = allmodels.FsCloudRenderLog.Create(ctx, &gmodel.FsCloudRenderLog{
|
||||
UserId: &parseInfo.RenderData.UserId,
|
||||
GuestId: &parseInfo.RenderData.GuestId,
|
||||
Title: &title,
|
||||
Time: &timePinjie,
|
||||
Tag: &parseInfo.RenderId,
|
||||
|
|
|
@ -71,7 +71,8 @@ type wsConnectItem struct {
|
|||
inChan chan []byte //接受消息缓冲通道
|
||||
outChan chan []byte //发送回客户端的消息
|
||||
mutex sync.Mutex //互斥锁
|
||||
userId int64
|
||||
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()
|
||||
|
|
|
@ -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{
|
||||
|
|
|
@ -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发送渲染完的数据
|
||||
|
|
Loading…
Reference in New Issue
Block a user