From 95df7ccd04dde7561900c1b12e85bed8318880a0 Mon Sep 17 00:00:00 2001
From: laodaming <11058467+laudamine@user.noreply.gitee.com>
Date: Wed, 18 Oct 2023 11:44:47 +0800
Subject: [PATCH 01/17] fix
---
server/websocket/internal/logic/datatransferlogic.go | 1 +
1 file changed, 1 insertion(+)
diff --git a/server/websocket/internal/logic/datatransferlogic.go b/server/websocket/internal/logic/datatransferlogic.go
index 0f65ccbb..86d49b16 100644
--- a/server/websocket/internal/logic/datatransferlogic.go
+++ b/server/websocket/internal/logic/datatransferlogic.go
@@ -167,6 +167,7 @@ func (l *DataTransferLogic) setConnPool(conn *websocket.Conn, userInfo *auth.Use
l.sendGetUniqueIdErrResponse(conn)
return wsConnectItem{}, err
}
+ //传入绑定的wid判断是否可重用
if oldWid != "" {
for i := 0; i < 1; i++ {
//解析传入的wid是不是属于自己的用户的
From e14fd8b28680338357d0e0bf8a41af2aa3dec148 Mon Sep 17 00:00:00 2001
From: momo <1012651275@qq.com>
Date: Wed, 18 Oct 2023 11:48:32 +0800
Subject: [PATCH 02/17] =?UTF-8?q?feat:=E5=90=88=E5=9B=BE=E6=96=B0=E5=A2=9E?=
=?UTF-8?q?debug=E6=A8=A1=E5=9D=97?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
service/repositories/image_handle.go | 31 +++++++++++++++++++---------
utils/auth/user.go | 6 ++++++
2 files changed, 27 insertions(+), 10 deletions(-)
diff --git a/service/repositories/image_handle.go b/service/repositories/image_handle.go
index f5036756..170eeb1c 100644
--- a/service/repositories/image_handle.go
+++ b/service/repositories/image_handle.go
@@ -136,6 +136,7 @@ type (
Metadata *string
DiffTimeLogoCombine int64
DiffTimeUploadFile int64
+ DebugData *auth.DebugData `json:"debug_data"`
}
)
type TemplateTagColor struct {
@@ -144,6 +145,7 @@ type TemplateTagColor struct {
}
func (l *defaultImageHandle) LogoCombine(ctx context.Context, in *LogoCombineReq) (*LogoCombineRes, error) {
+ var resp = &LogoCombineRes{}
logoResourceId := s3url_to_s3id.GetS3ResourceIdFormUrl(in.LogoUrl)
if logoResourceId == "" {
return nil, errors.New("invalid logo url")
@@ -167,10 +169,12 @@ func (l *defaultImageHandle) LogoCombine(ctx context.Context, in *LogoCombineReq
resourceModel := gmodel.NewFsResourceModel(l.MysqlConn)
resourceInfo, err := resourceModel.FindOneById(ctx, resourceId)
if err == nil && resourceInfo.ResourceId != "" {
- return &LogoCombineRes{
- ResourceId: resourceId,
- ResourceUrl: resourceInfo.ResourceUrl,
- }, nil
+ if in.Debug == nil || (in.Debug != nil && in.Debug.IsCache == 1) {
+ return &LogoCombineRes{
+ ResourceId: resourceId,
+ ResourceUrl: resourceInfo.ResourceUrl,
+ }, nil
+ }
} else {
if err != nil {
if !errors.Is(err, gorm.ErrRecordNotFound) {
@@ -308,12 +312,19 @@ func (l *defaultImageHandle) LogoCombine(ctx context.Context, in *LogoCombineReq
return nil, err
}
- return &LogoCombineRes{
- ResourceId: uploadRes.ResourceId,
- ResourceUrl: &uploadRes.ResourceUrl,
- DiffTimeLogoCombine: diffTimeLogoCombine,
- DiffTimeUploadFile: diffTimeUploadFile,
- }, nil
+ resp.ResourceId = uploadRes.ResourceId
+ resp.ResourceUrl = &uploadRes.ResourceUrl
+ resp.DiffTimeLogoCombine = diffTimeLogoCombine
+ resp.DiffTimeUploadFile = diffTimeUploadFile
+
+ if in.Debug != nil {
+ resp.DebugData = &auth.DebugData{
+ DiffTimeLogoCombine: diffTimeLogoCombine,
+ DiffTimeUploadFile: diffTimeUploadFile,
+ }
+ }
+
+ return resp, nil
}
/* logo合图 */
diff --git a/utils/auth/user.go b/utils/auth/user.go
index 8c9e2ca5..b1d43087 100644
--- a/utils/auth/user.go
+++ b/utils/auth/user.go
@@ -24,6 +24,12 @@ const (
IDTYPE_Guest IDTYPE = 2
)
+// DebugData
+type DebugData struct {
+ DiffTimeLogoCombine int64 `json:"diff_time_logo_combine"` // 合图算法时间
+ DiffTimeUploadFile int64 `json:"diff_time_upload_file"` // 合图上传时间
+}
+
// Debug 相关的结构
type Debug struct {
Exp *int64 `json:"exp"`
From 86547b9267e0427e0d1890040e858fd7964cbc32 Mon Sep 17 00:00:00 2001
From: momo <1012651275@qq.com>
Date: Wed, 18 Oct 2023 11:54:58 +0800
Subject: [PATCH 03/17] =?UTF-8?q?feat:=E5=90=88=E5=9B=BE=E6=96=B0=E5=A2=9E?=
=?UTF-8?q?debug=E6=A8=A1=E5=9D=97?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
server/resource/internal/logic/logocombinelogic.go | 11 +++++------
service/repositories/image_handle.go | 13 ++++---------
2 files changed, 9 insertions(+), 15 deletions(-)
diff --git a/server/resource/internal/logic/logocombinelogic.go b/server/resource/internal/logic/logocombinelogic.go
index 609a4316..2a601548 100644
--- a/server/resource/internal/logic/logocombinelogic.go
+++ b/server/resource/internal/logic/logocombinelogic.go
@@ -116,6 +116,7 @@ func (l *LogoCombineLogic) LogoCombine(req *types.LogoCombineReq, userinfo *auth
},
ProductTemplateTagGroups: req.TemplateTagGroups,
ProductTemplateV2Info: productTemplateV2Info,
+ Debug: userinfo.Debug,
})
if err != nil {
@@ -124,10 +125,8 @@ func (l *LogoCombineLogic) LogoCombine(req *types.LogoCombineReq, userinfo *auth
// 返回成功的响应和上传URL
return resp.SetStatus(basic.CodeOK, map[string]interface{}{
- "resource_id": res.ResourceId,
- "resource_url": res.ResourceUrl,
- "resource_metadata": "",
- "diff_time_logo_combine": res.DiffTimeLogoCombine,
- "diff_time_upload_file": res.DiffTimeUploadFile,
- })
+ "resource_id": res.ResourceId,
+ "resource_url": res.ResourceUrl,
+ "resource_metadata": "",
+ }).WithDebug(res.DebugData)
}
diff --git a/service/repositories/image_handle.go b/service/repositories/image_handle.go
index 170eeb1c..bde815fa 100644
--- a/service/repositories/image_handle.go
+++ b/service/repositories/image_handle.go
@@ -131,12 +131,10 @@ type (
Debug *auth.Debug `json:"debug"`
}
LogoCombineRes struct {
- ResourceId string
- ResourceUrl *string
- Metadata *string
- DiffTimeLogoCombine int64
- DiffTimeUploadFile int64
- DebugData *auth.DebugData `json:"debug_data"`
+ ResourceId string
+ ResourceUrl *string
+ Metadata *string
+ DebugData *auth.DebugData `json:"debug_data"`
}
)
type TemplateTagColor struct {
@@ -314,9 +312,6 @@ func (l *defaultImageHandle) LogoCombine(ctx context.Context, in *LogoCombineReq
resp.ResourceId = uploadRes.ResourceId
resp.ResourceUrl = &uploadRes.ResourceUrl
- resp.DiffTimeLogoCombine = diffTimeLogoCombine
- resp.DiffTimeUploadFile = diffTimeUploadFile
-
if in.Debug != nil {
resp.DebugData = &auth.DebugData{
DiffTimeLogoCombine: diffTimeLogoCombine,
From 616fc938cb4f6033ab4b985a5da4e2b83b24a979 Mon Sep 17 00:00:00 2001
From: laodaming <11058467+laudamine@user.noreply.gitee.com>
Date: Wed, 18 Oct 2023 11:57:26 +0800
Subject: [PATCH 04/17] fix
---
server/websocket/internal/logic/ws_render_image.go | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/server/websocket/internal/logic/ws_render_image.go b/server/websocket/internal/logic/ws_render_image.go
index 9cd04c9a..9db76b29 100644
--- a/server/websocket/internal/logic/ws_render_image.go
+++ b/server/websocket/internal/logic/ws_render_image.go
@@ -10,6 +10,7 @@ import (
"fusenapi/constants"
"fusenapi/model/gmodel"
"fusenapi/service/repositories"
+ "fusenapi/utils/auth"
"fusenapi/utils/curl"
"fusenapi/utils/hash"
"fusenapi/utils/websocket_data"
@@ -245,7 +246,7 @@ func (w *wsConnectItem) renderImage(renderImageData websocket_data.RenderImageRe
return
}
//发送合图完毕阶段消息
- w.sendCombineImageStepResponseMessage(renderImageData.RenderId, renderImageData.RequestId, combineImage, productSize.Id, model3dInfo.Id, productTemplate.Id, res.DiffTimeLogoCombine, res.DiffTimeUploadFile)
+ w.sendCombineImageStepResponseMessage(renderImageData.RenderId, renderImageData.RequestId, combineImage, productSize.Id, model3dInfo.Id, productTemplate.Id, res.DebugData)
//获取唯一id
taskId := w.genRenderTaskId(combineImage, renderImageData, model3dInfo, productTemplate, element)
//查询有没有缓存的资源,有就返回
@@ -467,17 +468,17 @@ func (w *wsConnectItem) genRenderTaskId(combineImage string, renderImageData web
// ****************************下面的发送消息的*********************************
// 发送合图完毕阶段通知消息
-func (w *wsConnectItem) sendCombineImageStepResponseMessage(renderId, requestId, combineImage string, sizeId, modelId, templateId, combineTime, uploadTime int64) {
+func (w *wsConnectItem) sendCombineImageStepResponseMessage(renderId, requestId, combineImage string, sizeId, modelId, templateId int64, debugData *auth.DebugData) {
if w.debug == nil {
return
}
combineTakesTime := "cache"
uploadCombineImageTakesTime := "cache"
- if combineTime > 0 {
- combineTakesTime = fmt.Sprintf("%dms", combineTime)
+ if debugData.DiffTimeLogoCombine > 0 {
+ combineTakesTime = fmt.Sprintf("%dms", debugData.DiffTimeLogoCombine)
}
- if uploadTime > 0 {
- uploadCombineImageTakesTime = fmt.Sprintf("%dms", uploadTime)
+ if debugData.DiffTimeUploadFile > 0 {
+ uploadCombineImageTakesTime = fmt.Sprintf("%dms", debugData.DiffTimeUploadFile)
}
w.sendToOutChan(w.respondDataFormat(constants.WEBSOCKET_COMBINE_IMAGE, websocket_data.CombineImageRspMsg{
RenderId: renderId,
From 5a173a491c91ce4b4c909075b75149580a7a3c78 Mon Sep 17 00:00:00 2001
From: laodaming <11058467+laudamine@user.noreply.gitee.com>
Date: Wed, 18 Oct 2023 12:02:04 +0800
Subject: [PATCH 05/17] fix
---
server/websocket/internal/logic/ws_render_image.go | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/server/websocket/internal/logic/ws_render_image.go b/server/websocket/internal/logic/ws_render_image.go
index 9db76b29..98abfa7b 100644
--- a/server/websocket/internal/logic/ws_render_image.go
+++ b/server/websocket/internal/logic/ws_render_image.go
@@ -133,7 +133,7 @@ func (w *wsConnectItem) consumeRenderImageData() {
}()
select {
case <-w.extendRenderProperty.renderCtx.Done():
- panic("=========检测到模板标签/颜色变化,渲染取消旧的任务=======")
+ panic("检测到模板标签/颜色变化,渲染取消旧的任务")
case <-tmpChan:
return
}
From 2ab8a4b21330152054a0c5cd6ac6ba596e6c98e1 Mon Sep 17 00:00:00 2001
From: momo <1012651275@qq.com>
Date: Wed, 18 Oct 2023 12:10:29 +0800
Subject: [PATCH 06/17] =?UTF-8?q?feat:=E5=90=88=E5=9B=BE=E6=96=B0=E5=A2=9E?=
=?UTF-8?q?debug=E6=A8=A1=E5=9D=97?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
constants/invoice_html.go | 17 ++++++++++++-----
service/repositories/order.go | 30 +++++++++++-------------------
2 files changed, 23 insertions(+), 24 deletions(-)
diff --git a/constants/invoice_html.go b/constants/invoice_html.go
index 6e4417a8..6fddf30c 100644
--- a/constants/invoice_html.go
+++ b/constants/invoice_html.go
@@ -196,7 +196,7 @@ const INVOICE_TEMPLATE_01 = `
const INVOICE_TEMPLATE_02 = `
-