From 3698705975988066c270778199c624658c1a578b Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Mon, 28 Aug 2023 14:44:46 +0800 Subject: [PATCH 01/14] 1 --- .../internal/logic/rendernotifylogic.go | 16 +-- .../internal/logic/ws_render_image.go | 106 +++++++++--------- 2 files changed, 61 insertions(+), 61 deletions(-) diff --git a/server/websocket/internal/logic/rendernotifylogic.go b/server/websocket/internal/logic/rendernotifylogic.go index 9c8dedf4..975bd22a 100644 --- a/server/websocket/internal/logic/rendernotifylogic.go +++ b/server/websocket/internal/logic/rendernotifylogic.go @@ -82,18 +82,18 @@ func (l *RenderNotifyLogic) RenderNotify(req *types.RenderNotifyReq, userinfo *a } //记录收到unity渲染结果时间以及上传渲染图耗时时间 ws.modifyRenderTaskTimeConsuming(renderImageControlChanItem{ - Option: 2, - TaskId: req.TaskId, - TaskProperty: renderTask{ - UnityRenderEndTime: unityRenderEndTime, - UploadUnityRenderImageTakesTime: uploadUnityRenderImageTakesTime, + option: 2, + taskId: req.TaskId, + taskProperty: renderTask{ + unityRenderEndTime: unityRenderEndTime, + uploadUnityRenderImageTakesTime: uploadUnityRenderImageTakesTime, }, }) //发送处理并删除任务 ws.deleteRenderTask(renderImageControlChanItem{ - Option: 0, //0删除 1添加 2修改耗时属性 - TaskId: req.TaskId, - RenderNotifyImageUrl: uploadRes.ResourceUrl, + option: 0, //0删除 1添加 2修改耗时属性 + taskId: req.TaskId, + renderNotifyImageUrl: uploadRes.ResourceUrl, }) return true }) diff --git a/server/websocket/internal/logic/ws_render_image.go b/server/websocket/internal/logic/ws_render_image.go index aeb2419b..b2ac63b7 100644 --- a/server/websocket/internal/logic/ws_render_image.go +++ b/server/websocket/internal/logic/ws_render_image.go @@ -27,21 +27,21 @@ type extendRenderProperty struct { // 渲染任务新增移除的控制通道的数据 type renderImageControlChanItem struct { - Option int // 0删除 1添加 - TaskId string //map的key - RenderId string // map的val(增加任务时候传) - RenderNotifyImageUrl string //渲染回调数据(删除任务时候传) - TaskProperty renderTask //渲染任务的属性 + option int // 0删除 1添加 + taskId string //map的key + renderId string // map的val(增加任务时候传) + renderNotifyImageUrl string //渲染回调数据(删除任务时候传) + taskProperty renderTask //渲染任务的属性 } // 渲染任务属性 type renderTask struct { - RenderId string //渲染id(前端传的) - CombineTakesTime int64 //合刀版图耗时 - UploadCombineImageTakesTime int64 //上传刀版图耗时 - UnityRenderBeginTime int64 //发送给unity时间 - UnityRenderEndTime int64 //unity回调结果时间 - UploadUnityRenderImageTakesTime int64 //上传unity渲染结果图时间 + renderId string //渲染id(前端传的) + combineTakesTime int64 //合刀版图耗时 + uploadCombineImageTakesTime int64 //上传刀版图耗时 + unityRenderBeginTime int64 //发送给unity时间 + unityRenderEndTime int64 //unity回调结果时间 + uploadUnityRenderImageTakesTime int64 //上传unity渲染结果图时间 } // 发送到渲染缓冲池 @@ -181,9 +181,9 @@ func (w *wsConnectItem) consumeRenderCache(data []byte) { //########################################### //把需要渲染的图片任务加进去 w.createRenderTask(renderImageControlChanItem{ - Option: 1, //0删除 1添加 2修改耗时属性 - TaskId: taskId, - RenderId: renderImageData.RenderId, + option: 1, //0删除 1添加 2修改耗时属性 + taskId: taskId, + renderId: renderImageData.RenderId, }) //组装数据 if err = w.assembleRenderData(taskId, renderImageData, productTemplate, model3dInfo, element, productFirstSize); err != nil { @@ -247,11 +247,11 @@ func (w *wsConnectItem) assembleRenderData(taskId string, info websocket_data.Re } //记录刀版图合成消耗时间跟上传刀版图时间 w.modifyRenderTaskTimeConsuming(renderImageControlChanItem{ - Option: 2, - TaskId: taskId, - TaskProperty: renderTask{ - CombineTakesTime: res.DiffTimeLogoCombine, - UploadCombineImageTakesTime: res.DiffTimeUploadFile, + option: 2, + taskId: taskId, + taskProperty: renderTask{ + combineTakesTime: res.DiffTimeLogoCombine, + uploadCombineImageTakesTime: res.DiffTimeUploadFile, }, }) logx.Info("合成刀版图成功,合成刀版图数据:", combineReq, ",logo图片:", info.RenderData.Logo, " 刀版图:", *res.ResourceUrl) @@ -349,10 +349,10 @@ func (w *wsConnectItem) assembleRenderData(taskId string, info websocket_data.Re } //记录发送到unity时间 w.modifyRenderTaskTimeConsuming(renderImageControlChanItem{ - Option: 2, - TaskId: taskId, - TaskProperty: renderTask{ - UnityRenderBeginTime: unityRenderBeginTime, + option: 2, + taskId: taskId, + taskProperty: renderTask{ + unityRenderBeginTime: unityRenderBeginTime, }, }) logx.Info("发送到unity成功,刀版图:", combineImage, " 请求unity的数据:", string(postDataBytes)) @@ -362,7 +362,7 @@ func (w *wsConnectItem) assembleRenderData(taskId string, info websocket_data.Re // 增加渲染任务 func (w *wsConnectItem) createRenderTask(data renderImageControlChanItem) { //强制设为增加 - data.Option = 1 + data.option = 1 select { case <-w.closeChan: //关闭 return @@ -376,7 +376,7 @@ func (w *wsConnectItem) createRenderTask(data renderImageControlChanItem) { // 渲染回调处理并删除渲染任务 func (w *wsConnectItem) deleteRenderTask(data renderImageControlChanItem) { //强制设为删除 - data.Option = 0 + data.option = 0 select { case <-w.closeChan: //关闭 return @@ -389,12 +389,12 @@ func (w *wsConnectItem) deleteRenderTask(data renderImageControlChanItem) { // 修改耗时属性(只有耗时属性可以更新) func (w *wsConnectItem) modifyRenderTaskTimeConsuming(data renderImageControlChanItem) { - if data.TaskId == "" { + if data.taskId == "" { logx.Error("设置耗时属性需要的task_id不能为空") return } //强制设为修改耗时属性 - data.Option = 2 + data.option = 2 select { case <-w.closeChan: //关闭 return @@ -417,34 +417,34 @@ func (w *wsConnectItem) operationRenderTask() { case <-w.closeChan: return case data := <-w.extendRenderProperty.renderImageTaskCtlChan: - switch data.Option { + switch data.option { case 0: //渲染结果回调,删除任务 //存在任务,则发送渲染结果给前端 - if taskData, ok := w.extendRenderProperty.renderImageTask[data.TaskId]; ok { + if taskData, ok := w.extendRenderProperty.renderImageTask[data.taskId]; ok { CombineTakesTime := "0ms" UnityRenderTakesTime := "0ms" uploadCombineImageTakesTime := "0ms" uploadUnityRenderImageTakesTime := "0ms" //合图时间 - if taskData.CombineTakesTime > 0 { - CombineTakesTime = fmt.Sprintf("%dms", taskData.CombineTakesTime) + if taskData.combineTakesTime > 0 { + CombineTakesTime = fmt.Sprintf("%dms", taskData.combineTakesTime) } //上传刀版图时间 - if taskData.UploadCombineImageTakesTime > 0 { - uploadCombineImageTakesTime = fmt.Sprintf("%dms", taskData.UploadCombineImageTakesTime) + if taskData.uploadCombineImageTakesTime > 0 { + uploadCombineImageTakesTime = fmt.Sprintf("%dms", taskData.uploadCombineImageTakesTime) } //unity渲染时间 - if taskData.UnityRenderBeginTime > 0 && taskData.UnityRenderEndTime > 0 { - UnityRenderTakesTime = fmt.Sprintf("%dms", taskData.UnityRenderEndTime-taskData.UnityRenderBeginTime) + if taskData.unityRenderBeginTime > 0 && taskData.unityRenderEndTime > 0 { + UnityRenderTakesTime = fmt.Sprintf("%dms", taskData.unityRenderEndTime-taskData.unityRenderBeginTime) } //上传unity渲染图耗时 - if taskData.UploadUnityRenderImageTakesTime > 0 { - uploadUnityRenderImageTakesTime = fmt.Sprintf("%dms", taskData.UploadUnityRenderImageTakesTime) + if taskData.uploadUnityRenderImageTakesTime > 0 { + uploadUnityRenderImageTakesTime = fmt.Sprintf("%dms", taskData.uploadUnityRenderImageTakesTime) } //发送到出口 w.sendToOutChan(w.respondDataFormat(constants.WEBSOCKET_RENDER_IMAGE, websocket_data.RenderImageRspMsg{ - RenderId: taskData.RenderId, - Image: data.RenderNotifyImageUrl, + RenderId: taskData.renderId, + Image: data.renderNotifyImageUrl, RenderProcessTime: websocket_data.RenderProcessTime{ CombineTakesTime: CombineTakesTime, UnityRenderTakesTime: UnityRenderTakesTime, @@ -454,32 +454,32 @@ func (w *wsConnectItem) operationRenderTask() { })) } //删除任务 - delete(w.extendRenderProperty.renderImageTask, data.TaskId) + delete(w.extendRenderProperty.renderImageTask, data.taskId) case 1: //新增任务 - w.extendRenderProperty.renderImageTask[data.TaskId] = &renderTask{ - RenderId: data.RenderId, + w.extendRenderProperty.renderImageTask[data.taskId] = &renderTask{ + renderId: data.renderId, } case 2: //修改(耗时)属性 - if taskData, ok := w.extendRenderProperty.renderImageTask[data.TaskId]; ok { + if taskData, ok := w.extendRenderProperty.renderImageTask[data.taskId]; ok { //合图耗时 - if data.TaskProperty.CombineTakesTime != 0 { - taskData.CombineTakesTime = data.TaskProperty.CombineTakesTime + if data.taskProperty.combineTakesTime != 0 { + taskData.combineTakesTime = data.taskProperty.combineTakesTime } //上传合图耗时 - if data.TaskProperty.UploadCombineImageTakesTime != 0 { - taskData.UploadCombineImageTakesTime = data.TaskProperty.UploadCombineImageTakesTime + if data.taskProperty.uploadCombineImageTakesTime != 0 { + taskData.uploadCombineImageTakesTime = data.taskProperty.uploadCombineImageTakesTime } //上传渲染结果图耗时 - if data.TaskProperty.UploadUnityRenderImageTakesTime != 0 { - taskData.UploadUnityRenderImageTakesTime = data.TaskProperty.UploadUnityRenderImageTakesTime + if data.taskProperty.uploadUnityRenderImageTakesTime != 0 { + taskData.uploadUnityRenderImageTakesTime = data.taskProperty.uploadUnityRenderImageTakesTime } //发送unity时间 - if data.TaskProperty.UnityRenderBeginTime != 0 { - taskData.UnityRenderBeginTime = data.TaskProperty.UnityRenderBeginTime + if data.taskProperty.unityRenderBeginTime != 0 { + taskData.unityRenderBeginTime = data.taskProperty.unityRenderBeginTime } //收到unity返回的时间 - if data.TaskProperty.UnityRenderEndTime != 0 { - taskData.UnityRenderEndTime = data.TaskProperty.UnityRenderEndTime + if data.taskProperty.unityRenderEndTime != 0 { + taskData.unityRenderEndTime = data.taskProperty.unityRenderEndTime } } } From 7af3d2b2aa4659efc96ea0a14b6e0c661f542f03 Mon Sep 17 00:00:00 2001 From: momo <1012651275@qq.com> Date: Mon, 28 Aug 2023 14:51:58 +0800 Subject: [PATCH 02/14] =?UTF-8?q?fix:=E4=BF=AE=E5=A4=8D=E6=97=A5=E5=BF=97?= =?UTF-8?q?=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- go.mod | 4 ++-- server/auth/etc/auth.yaml | 4 +++- server/backend/etc/backend.yaml | 4 +++- server/base/etc/base.yaml | 4 +++- server/canteen/etc/canteen.yaml | 4 +++- server/data-transfer/etc/data-transfer.yaml | 4 +++- server/home-user-auth/etc/home-user-auth.yaml | 4 +++- server/inventory/etc/inventory.yaml | 4 +++- server/map-library/etc/map-library.yaml | 4 +++- server/orders/etc/orders.yaml | 4 +++- server/pay/etc/pay.yaml | 4 +++- server/product-model/etc/product-model.yaml | 4 +++- server/product-template-tag/etc/product-template-tag.yaml | 4 +++- server/product-template/etc/product-template.yaml | 4 +++- server/product/etc/product.yaml | 4 +++- server/render/etc/render.yaml | 4 +++- server/resource/etc/resource.yaml | 4 +++- .../etc/shopping-cart-confirmation.yaml | 4 +++- server/upload/etc/upload.yaml | 2 ++ server/websocket/etc/websocket.yaml | 4 +++- 20 files changed, 58 insertions(+), 20 deletions(-) diff --git a/go.mod b/go.mod index 62244004..187d7e92 100644 --- a/go.mod +++ b/go.mod @@ -102,7 +102,7 @@ require ( github.com/prometheus/common v0.42.0 // indirect github.com/prometheus/procfs v0.10.1 // indirect github.com/spaolacci/murmur3 v1.1.0 // indirect - go.opentelemetry.io/otel v1.14.0 // indirect + go.opentelemetry.io/otel v1.14.0 go.opentelemetry.io/otel/exporters/jaeger v1.14.0 // indirect go.opentelemetry.io/otel/exporters/otlp/internal/retry v1.14.0 // indirect go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.14.0 // indirect @@ -110,7 +110,7 @@ require ( go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.14.0 // indirect go.opentelemetry.io/otel/exporters/zipkin v1.14.0 // indirect go.opentelemetry.io/otel/sdk v1.14.0 // indirect - go.opentelemetry.io/otel/trace v1.14.0 // indirect + go.opentelemetry.io/otel/trace v1.14.0 go.opentelemetry.io/proto/otlp v0.19.0 // indirect go.uber.org/automaxprocs v1.5.2 // indirect golang.org/x/net v0.12.0 // indirect diff --git a/server/auth/etc/auth.yaml b/server/auth/etc/auth.yaml index 59b8aeed..1caaa656 100644 --- a/server/auth/etc/auth.yaml +++ b/server/auth/etc/auth.yaml @@ -3,7 +3,9 @@ Host: localhost Port: 9980 ReplicaId: 10 MainAddress: "https://server.fusen.3718.cn:9900" -SourceMysql: fsreaderwriter:XErSYmLELKMnf3Dh@tcp(fusen.cdmigcvz3rle.us-east-2.rds.amazonaws.com:3306)/fusen +SourceMysql: "fsreaderwriter:XErSYmLELKMnf3Dh@tcp(fusen.cdmigcvz3rle.us-east-2.rds.amazonaws.com:3306)/fusen" +Log: + Stat: false Auth: AccessSecret: fusen2023 AccessExpire: 2592000 diff --git a/server/backend/etc/backend.yaml b/server/backend/etc/backend.yaml index 2e32fa19..b9a69dfe 100644 --- a/server/backend/etc/backend.yaml +++ b/server/backend/etc/backend.yaml @@ -2,7 +2,9 @@ Name: backend Host: localhost Port: 9901 Timeout: 15000 #服务超时时间 -SourceMysql: fsreaderwriter:XErSYmLELKMnf3Dh@tcp(fusen.cdmigcvz3rle.us-east-2.rds.amazonaws.com:3306)/fusen +SourceMysql: "fsreaderwriter:XErSYmLELKMnf3Dh@tcp(fusen.cdmigcvz3rle.us-east-2.rds.amazonaws.com:3306)/fusen" +Log: + Stat: false Auth: AccessSecret: fusen_backend_2023 AccessExpire: 2592000 diff --git a/server/base/etc/base.yaml b/server/base/etc/base.yaml index 8afc7a6b..519c2fe8 100644 --- a/server/base/etc/base.yaml +++ b/server/base/etc/base.yaml @@ -3,7 +3,9 @@ Host: 0.0.0.0 Port: 9920 ReplicaId: 15 Timeout: 15000 #服务超时时间(毫秒) -SourceMysql: fsreaderwriter:XErSYmLELKMnf3Dh@tcp(fusen.cdmigcvz3rle.us-east-2.rds.amazonaws.com:3306)/fusen +SourceMysql: "fsreaderwriter:XErSYmLELKMnf3Dh@tcp(fusen.cdmigcvz3rle.us-east-2.rds.amazonaws.com:3306)/fusen" +Log: + Stat: false Auth: AccessSecret: fusen2023 AccessExpire: 2592000 diff --git a/server/canteen/etc/canteen.yaml b/server/canteen/etc/canteen.yaml index 6131ae44..480df570 100644 --- a/server/canteen/etc/canteen.yaml +++ b/server/canteen/etc/canteen.yaml @@ -3,7 +3,9 @@ Host: localhost Port: 9902 ReplicaId: 20 Timeout: 15000 #服务超时时间 -SourceMysql: fsreaderwriter:XErSYmLELKMnf3Dh@tcp(fusen.cdmigcvz3rle.us-east-2.rds.amazonaws.com:3306)/fusen +SourceMysql: "fsreaderwriter:XErSYmLELKMnf3Dh@tcp(fusen.cdmigcvz3rle.us-east-2.rds.amazonaws.com:3306)/fusen" +Log: + Stat: false Auth: AccessSecret: fusen2023 AccessExpire: 2592000 diff --git a/server/data-transfer/etc/data-transfer.yaml b/server/data-transfer/etc/data-transfer.yaml index 63d3c8c2..43106c78 100644 --- a/server/data-transfer/etc/data-transfer.yaml +++ b/server/data-transfer/etc/data-transfer.yaml @@ -3,7 +3,9 @@ Host: localhost Port: 9903 ReplicaId: 25 Timeout: 15000 #服务超时时间 -SourceMysql: fsreaderwriter:XErSYmLELKMnf3Dh@tcp(fusen.cdmigcvz3rle.us-east-2.rds.amazonaws.com:3306)/fusen +SourceMysql: "fsreaderwriter:XErSYmLELKMnf3Dh@tcp(fusen.cdmigcvz3rle.us-east-2.rds.amazonaws.com:3306)/fusen" +Log: + Stat: false Auth: AccessSecret: fusen2023 AccessExpire: 2592000 diff --git a/server/home-user-auth/etc/home-user-auth.yaml b/server/home-user-auth/etc/home-user-auth.yaml index 09e3373b..dea74873 100644 --- a/server/home-user-auth/etc/home-user-auth.yaml +++ b/server/home-user-auth/etc/home-user-auth.yaml @@ -4,7 +4,9 @@ Port: 9904 ReplicaId: 30 Timeout: 15000 #服务超时时间 MainAddress: "http://localhost:9900" -SourceMysql: fsreaderwriter:XErSYmLELKMnf3Dh@tcp(fusen.cdmigcvz3rle.us-east-2.rds.amazonaws.com:3306)/fusen +SourceMysql: "fsreaderwriter:XErSYmLELKMnf3Dh@tcp(fusen.cdmigcvz3rle.us-east-2.rds.amazonaws.com:3306)/fusen" +Log: + Stat: false Auth: AccessSecret: fusen2023 diff --git a/server/inventory/etc/inventory.yaml b/server/inventory/etc/inventory.yaml index 4fee8639..9accf4ab 100644 --- a/server/inventory/etc/inventory.yaml +++ b/server/inventory/etc/inventory.yaml @@ -3,7 +3,9 @@ Host: localhost Port: 9905 ReplicaId: 35 Timeout: 15000 #服务超时时间 -SourceMysql: fsreaderwriter:XErSYmLELKMnf3Dh@tcp(fusen.cdmigcvz3rle.us-east-2.rds.amazonaws.com:3306)/fusen +SourceMysql: "fsreaderwriter:XErSYmLELKMnf3Dh@tcp(fusen.cdmigcvz3rle.us-east-2.rds.amazonaws.com:3306)/fusen" +Log: + Stat: false Auth: AccessSecret: fusen2023 AccessExpire: 2592000 diff --git a/server/map-library/etc/map-library.yaml b/server/map-library/etc/map-library.yaml index a81bccbe..37de2dc3 100644 --- a/server/map-library/etc/map-library.yaml +++ b/server/map-library/etc/map-library.yaml @@ -3,7 +3,9 @@ Host: localhost Port: 9906 ReplicaId: 40 Timeout: 15000 #服务超时时间 -SourceMysql: fsreaderwriter:XErSYmLELKMnf3Dh@tcp(fusen.cdmigcvz3rle.us-east-2.rds.amazonaws.com:3306)/fusen +SourceMysql: "fsreaderwriter:XErSYmLELKMnf3Dh@tcp(fusen.cdmigcvz3rle.us-east-2.rds.amazonaws.com:3306)/fusen" +Log: + Stat: false Auth: AccessSecret: fusen2023 AccessExpire: 2592000 diff --git a/server/orders/etc/orders.yaml b/server/orders/etc/orders.yaml index 65821d8a..d8f419d6 100644 --- a/server/orders/etc/orders.yaml +++ b/server/orders/etc/orders.yaml @@ -3,7 +3,9 @@ Host: localhost Port: 9907 ReplicaId: 45 Timeout: 15000 #服务超时时间 -SourceMysql: fsreaderwriter:XErSYmLELKMnf3Dh@tcp(fusen.cdmigcvz3rle.us-east-2.rds.amazonaws.com:3306)/fusen +SourceMysql: "fsreaderwriter:XErSYmLELKMnf3Dh@tcp(fusen.cdmigcvz3rle.us-east-2.rds.amazonaws.com:3306)/fusen" +Log: + Stat: false Auth: AccessSecret: fusen2023 AccessExpire: 2592000 diff --git a/server/pay/etc/pay.yaml b/server/pay/etc/pay.yaml index 02605ab0..7bba3a0d 100644 --- a/server/pay/etc/pay.yaml +++ b/server/pay/etc/pay.yaml @@ -3,7 +3,9 @@ Host: 0.0.0.0 Port: 9915 ReplicaId: 50 Timeout: 15000 #服务超时时间 -SourceMysql: fsreaderwriter:XErSYmLELKMnf3Dh@tcp(fusen.cdmigcvz3rle.us-east-2.rds.amazonaws.com:3306)/fusen +SourceMysql: "fsreaderwriter:XErSYmLELKMnf3Dh@tcp(fusen.cdmigcvz3rle.us-east-2.rds.amazonaws.com:3306)/fusen" +Log: + Stat: false Auth: AccessSecret: fusen2023 AccessExpire: 2592000 diff --git a/server/product-model/etc/product-model.yaml b/server/product-model/etc/product-model.yaml index f498b3b5..04fe469c 100644 --- a/server/product-model/etc/product-model.yaml +++ b/server/product-model/etc/product-model.yaml @@ -1,7 +1,9 @@ Name: product-model Host: localhost Port: 9909 -SourceMysql: fsreaderwriter:XErSYmLELKMnf3Dh@tcp(fusen.cdmigcvz3rle.us-east-2.rds.amazonaws.com:3306)/fusen +SourceMysql: "fsreaderwriter:XErSYmLELKMnf3Dh@tcp(fusen.cdmigcvz3rle.us-east-2.rds.amazonaws.com:3306)/fusen" +Log: + Stat: false Auth: AccessSecret: fusen2023 AccessExpire: 2592000 diff --git a/server/product-template-tag/etc/product-template-tag.yaml b/server/product-template-tag/etc/product-template-tag.yaml index f955fea2..e6ff087d 100644 --- a/server/product-template-tag/etc/product-template-tag.yaml +++ b/server/product-template-tag/etc/product-template-tag.yaml @@ -3,7 +3,9 @@ Host: 0.0.0.0 ReplicaId: 65 Port: 9917 Timeout: 15000 #服务超时时间 -SourceMysql: fsreaderwriter:XErSYmLELKMnf3Dh@tcp(fusen.cdmigcvz3rle.us-east-2.rds.amazonaws.com:3306)/fusen +SourceMysql: "fsreaderwriter:XErSYmLELKMnf3Dh@tcp(fusen.cdmigcvz3rle.us-east-2.rds.amazonaws.com:3306)/fusen" +Log: + Stat: false Auth: AccessSecret: fusen2023 AccessExpire: 2592000 diff --git a/server/product-template/etc/product-template.yaml b/server/product-template/etc/product-template.yaml index 218699d9..e25583c3 100644 --- a/server/product-template/etc/product-template.yaml +++ b/server/product-template/etc/product-template.yaml @@ -3,7 +3,9 @@ Host: localhost Port: 9910 ReplicaId: 60 Timeout: 15000 #服务超时时间 -SourceMysql: fsreaderwriter:XErSYmLELKMnf3Dh@tcp(fusen.cdmigcvz3rle.us-east-2.rds.amazonaws.com:3306)/fusen +SourceMysql: "fsreaderwriter:XErSYmLELKMnf3Dh@tcp(fusen.cdmigcvz3rle.us-east-2.rds.amazonaws.com:3306)/fusen" +Log: + Stat: false Auth: AccessSecret: fusen2023 AccessExpire: 2592000 diff --git a/server/product/etc/product.yaml b/server/product/etc/product.yaml index 08f89d66..c43bfa02 100644 --- a/server/product/etc/product.yaml +++ b/server/product/etc/product.yaml @@ -3,7 +3,9 @@ Host: localhost Port: 9908 ReplicaId: 55 Timeout: 15000 #服务超时时间 -SourceMysql: fsreaderwriter:XErSYmLELKMnf3Dh@tcp(fusen.cdmigcvz3rle.us-east-2.rds.amazonaws.com:3306)/fusen +SourceMysql: "fsreaderwriter:XErSYmLELKMnf3Dh@tcp(fusen.cdmigcvz3rle.us-east-2.rds.amazonaws.com:3306)/fusen" +Log: + Stat: false Auth: AccessSecret: fusen2023 AccessExpire: 2592000 diff --git a/server/render/etc/render.yaml b/server/render/etc/render.yaml index 42d115fb..9b88124e 100644 --- a/server/render/etc/render.yaml +++ b/server/render/etc/render.yaml @@ -3,7 +3,9 @@ Host: 0.0.0.0 Port: 9919 ReplicaId: 70 Timeout: 15000 #服务超时时间 -SourceMysql: fsreaderwriter:XErSYmLELKMnf3Dh@tcp(fusen.cdmigcvz3rle.us-east-2.rds.amazonaws.com:3306)/fusen +SourceMysql: "fsreaderwriter:XErSYmLELKMnf3Dh@tcp(fusen.cdmigcvz3rle.us-east-2.rds.amazonaws.com:3306)/fusen" +Log: + Stat: false Auth: AccessSecret: fusen2023 AccessExpire: 2592000 diff --git a/server/resource/etc/resource.yaml b/server/resource/etc/resource.yaml index 2b80b38e..986c09fc 100644 --- a/server/resource/etc/resource.yaml +++ b/server/resource/etc/resource.yaml @@ -3,7 +3,9 @@ Host: 0.0.0.0 Port: 9916 ReplicaId: 75 Timeout: 150000 #服务超时时间(毫秒) -SourceMysql: fsreaderwriter:XErSYmLELKMnf3Dh@tcp(fusen.cdmigcvz3rle.us-east-2.rds.amazonaws.com:3306)/fusen +SourceMysql: "fsreaderwriter:XErSYmLELKMnf3Dh@tcp(fusen.cdmigcvz3rle.us-east-2.rds.amazonaws.com:3306)/fusen" +Log: + Stat: false Auth: AccessSecret: fusen2023 AccessExpire: 2592000 diff --git a/server/shopping-cart-confirmation/etc/shopping-cart-confirmation.yaml b/server/shopping-cart-confirmation/etc/shopping-cart-confirmation.yaml index 18f3d37f..ba427c8f 100644 --- a/server/shopping-cart-confirmation/etc/shopping-cart-confirmation.yaml +++ b/server/shopping-cart-confirmation/etc/shopping-cart-confirmation.yaml @@ -3,7 +3,9 @@ Host: localhost Port: 9911 ReplicaId: 80 Timeout: 15000 #服务超时时间 -SourceMysql: fsreaderwriter:XErSYmLELKMnf3Dh@tcp(fusen.cdmigcvz3rle.us-east-2.rds.amazonaws.com:3306)/fusen +SourceMysql: "fsreaderwriter:XErSYmLELKMnf3Dh@tcp(fusen.cdmigcvz3rle.us-east-2.rds.amazonaws.com:3306)/fusen" +Log: + Stat: false Auth: AccessSecret: fusen2023 AccessExpire: 2592000 diff --git a/server/upload/etc/upload.yaml b/server/upload/etc/upload.yaml index 27a5b2c5..b8596b53 100644 --- a/server/upload/etc/upload.yaml +++ b/server/upload/etc/upload.yaml @@ -5,6 +5,8 @@ ReplicaId: 85 Timeout: 150000 #服务超时时间 MaxBytes: 104857600 #传输字节大小 SourceMysql: "fsreaderwriter:XErSYmLELKMnf3Dh@tcp(fusen.cdmigcvz3rle.us-east-2.rds.amazonaws.com:3306)/fusen" +Log: + Stat: false Env: "test" Auth: AccessSecret: fusen2023 diff --git a/server/websocket/etc/websocket.yaml b/server/websocket/etc/websocket.yaml index e5724a80..270bd48f 100644 --- a/server/websocket/etc/websocket.yaml +++ b/server/websocket/etc/websocket.yaml @@ -3,7 +3,9 @@ Host: 0.0.0.0 Port: 9914 ReplicaId: 95 Timeout: 15000 #服务超时时间 -SourceMysql: fsreaderwriter:XErSYmLELKMnf3Dh@tcp(fusen.cdmigcvz3rle.us-east-2.rds.amazonaws.com:3306)/fusen +SourceMysql: "fsreaderwriter:XErSYmLELKMnf3Dh@tcp(fusen.cdmigcvz3rle.us-east-2.rds.amazonaws.com:3306)/fusen" +Log: + Stat: false Auth: AccessSecret: fusen2023 AccessExpire: 2592000 From f9de30a838a3d9be09e4c1b84c8f47f9169d8634 Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Mon, 28 Aug 2023 14:56:01 +0800 Subject: [PATCH 03/14] 1 --- model/gmodel/fs_merchant_category_gen.go | 1 + model/gmodel/fs_merchant_category_logic.go | 6 +++-- model/gmodel/var_gen.go | 8 ++++++ .../homepagerecommendproductlistlogic.go | 25 ++++++++++++------- 4 files changed, 29 insertions(+), 11 deletions(-) diff --git a/model/gmodel/fs_merchant_category_gen.go b/model/gmodel/fs_merchant_category_gen.go index 732ec88b..b0c42cae 100644 --- a/model/gmodel/fs_merchant_category_gen.go +++ b/model/gmodel/fs_merchant_category_gen.go @@ -12,6 +12,7 @@ type FsMerchantCategory struct { Icon *string `gorm:"default:'';" json:"icon"` // 图标 RecommendProduct *string `gorm:"default:'';" json:"recommend_product"` // 推荐商品 Sort *int64 `gorm:"default:0;" json:"sort"` // 排序 + IsDefault *int64 `gorm:"default:0;" json:"is_default"` // 是否是默认商家类型0非1是 Status *int64 `gorm:"default:0;" json:"status"` // 状态 Ctime *int64 `gorm:"default:0;" json:"ctime"` // 添加时间 } diff --git a/model/gmodel/fs_merchant_category_logic.go b/model/gmodel/fs_merchant_category_logic.go index cbf8c138..e7061476 100644 --- a/model/gmodel/fs_merchant_category_logic.go +++ b/model/gmodel/fs_merchant_category_logic.go @@ -14,8 +14,10 @@ func (m *FsMerchantCategoryModel) FindOne(ctx context.Context, id int64) (resp * err = m.db.WithContext(ctx).Model(&FsMerchantCategory{}).Where("id = ? and status = ?", id, 1).Take(&resp).Error return resp, err } -func (m *FsMerchantCategoryModel) FindRandOne(ctx context.Context) (resp *FsMerchantCategory, err error) { - err = m.db.WithContext(ctx).Model(&FsMerchantCategory{}).Where("status = ?", 1).Order("RAND()").Take(&resp).Error + +// 获取默认那个 +func (m *FsMerchantCategoryModel) FindDefualtOne(ctx context.Context) (resp *FsMerchantCategory, err error) { + err = m.db.WithContext(ctx).Model(&FsMerchantCategory{}).Where("status = ? and is_default = ?", 1, 1).Take(&resp).Error return resp, err } diff --git a/model/gmodel/var_gen.go b/model/gmodel/var_gen.go index c7e2a11b..ad4f5db9 100644 --- a/model/gmodel/var_gen.go +++ b/model/gmodel/var_gen.go @@ -4,7 +4,11 @@ import "gorm.io/gorm" // AllModelsGen 所有Model集合,修改单行,只要不改字段名,不会根据新的内容修改,需要修改的话手动删除 type AllModelsGen struct { + CasbinRule *CasbinRuleModel // casbin_rule FsAddress *FsAddressModel // fs_address 用户地址表 + FsAdminAuthRole *FsAdminAuthRoleModel // fs_admin_auth_role 后台--角色表 + FsAdminDepartment *FsAdminDepartmentModel // fs_admin_department 后台--部门表 + FsAdminMenu *FsAdminMenuModel // fs_admin_menu 后台--菜单表 FsAuthAssignment *FsAuthAssignmentModel // fs_auth_assignment 用户角色和权限信息 FsAuthItem *FsAuthItemModel // fs_auth_item 用户角色和权限信息 FsAuthItemChild *FsAuthItemChildModel // fs_auth_item_child 角色和权限关系表 @@ -103,7 +107,11 @@ type AllModelsGen struct { func NewAllModels(gdb *gorm.DB) *AllModelsGen { models := &AllModelsGen{ + CasbinRule: NewCasbinRuleModel(gdb), FsAddress: NewFsAddressModel(gdb), + FsAdminAuthRole: NewFsAdminAuthRoleModel(gdb), + FsAdminDepartment: NewFsAdminDepartmentModel(gdb), + FsAdminMenu: NewFsAdminMenuModel(gdb), FsAuthAssignment: NewFsAuthAssignmentModel(gdb), FsAuthItem: NewFsAuthItemModel(gdb), FsAuthItemChild: NewFsAuthItemChildModel(gdb), diff --git a/server/product/internal/logic/homepagerecommendproductlistlogic.go b/server/product/internal/logic/homepagerecommendproductlistlogic.go index e9d4694f..389a01e0 100644 --- a/server/product/internal/logic/homepagerecommendproductlistlogic.go +++ b/server/product/internal/logic/homepagerecommendproductlistlogic.go @@ -54,16 +54,23 @@ func (l *HomePageRecommendProductListLogic) HomePageRecommendProductList(req *ty //选了商家类型 if req.MerchantType > 0 { merchantInfo, err = l.svcCtx.AllModels.FsMerchantCategory.FindOne(l.ctx, req.MerchantType) - } else { - //随机获取一个商家类型 - merchantInfo, err = l.svcCtx.AllModels.FsMerchantCategory.FindRandOne(l.ctx) - } - if err != nil { - if errors.Is(err, gorm.ErrRecordNotFound) { - return resp.SetStatusWithMessage(basic.CodeDbRecordNotFoundErr, "none of merchant type found") + if err != nil { + if errors.Is(err, gorm.ErrRecordNotFound) { + return resp.SetStatusWithMessage(basic.CodeDbRecordNotFoundErr, "the merchant category is not exists") + } + logx.Error(err) + return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get merchant category") + } + } else { + //获取默认的那个 + merchantInfo, err = l.svcCtx.AllModels.FsMerchantCategory.FindDefualtOne(l.ctx) + if err != nil { + if errors.Is(err, gorm.ErrRecordNotFound) { + return resp.SetStatusWithMessage(basic.CodeDbRecordNotFoundErr, "the default merchant category is not exists") + } + logx.Error(err) + return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get default merchant category") } - logx.Error(err) - return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get merchant type info") } if *merchantInfo.RecommendProduct == "" { return resp.SetStatusWithMessage(basic.CodeOK, "success", []interface{}{}) From a3f8e0e250d9157936736aeec29477863c7dcac4 Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Mon, 28 Aug 2023 14:57:01 +0800 Subject: [PATCH 04/14] 1 --- model/gmodel/casbin_rule_gen.go | 24 ++++++++++++++++ model/gmodel/casbin_rule_logic.go | 2 ++ model/gmodel/fs_admin_auth_role_gen.go | 33 +++++++++++++++++++++ model/gmodel/fs_admin_auth_role_logic.go | 2 ++ model/gmodel/fs_admin_department_gen.go | 35 +++++++++++++++++++++++ model/gmodel/fs_admin_department_logic.go | 2 ++ model/gmodel/fs_admin_menu_gen.go | 33 +++++++++++++++++++++ model/gmodel/fs_admin_menu_logic.go | 2 ++ 8 files changed, 133 insertions(+) create mode 100644 model/gmodel/casbin_rule_gen.go create mode 100644 model/gmodel/casbin_rule_logic.go create mode 100644 model/gmodel/fs_admin_auth_role_gen.go create mode 100644 model/gmodel/fs_admin_auth_role_logic.go create mode 100644 model/gmodel/fs_admin_department_gen.go create mode 100644 model/gmodel/fs_admin_department_logic.go create mode 100644 model/gmodel/fs_admin_menu_gen.go create mode 100644 model/gmodel/fs_admin_menu_logic.go diff --git a/model/gmodel/casbin_rule_gen.go b/model/gmodel/casbin_rule_gen.go new file mode 100644 index 00000000..57bd8599 --- /dev/null +++ b/model/gmodel/casbin_rule_gen.go @@ -0,0 +1,24 @@ +package gmodel + +import ( + "gorm.io/gorm" +) + +// casbin_rule +type CasbinRule struct { + PType *string `gorm:"default:'';" json:"p_type"` // + V0 *string `gorm:"default:'';" json:"v0"` // + V1 *string `gorm:"default:'';" json:"v1"` // + V2 *string `gorm:"default:'';" json:"v2"` // + V3 *string `gorm:"default:'';" json:"v3"` // + V4 *string `gorm:"default:'';" json:"v4"` // + V5 *string `gorm:"default:'';" json:"v5"` // +} +type CasbinRuleModel struct { + db *gorm.DB + name string +} + +func NewCasbinRuleModel(db *gorm.DB) *CasbinRuleModel { + return &CasbinRuleModel{db: db, name: "casbin_rule"} +} diff --git a/model/gmodel/casbin_rule_logic.go b/model/gmodel/casbin_rule_logic.go new file mode 100644 index 00000000..e68225aa --- /dev/null +++ b/model/gmodel/casbin_rule_logic.go @@ -0,0 +1,2 @@ +package gmodel +// TODO: 使用model的属性做你想做的 \ No newline at end of file diff --git a/model/gmodel/fs_admin_auth_role_gen.go b/model/gmodel/fs_admin_auth_role_gen.go new file mode 100644 index 00000000..f9075654 --- /dev/null +++ b/model/gmodel/fs_admin_auth_role_gen.go @@ -0,0 +1,33 @@ +package gmodel + +import ( + "gorm.io/gorm" + "time" +) + +// fs_admin_auth_role 后台--角色表 +type FsAdminAuthRole struct { + Id int64 `gorm:"primary_key;default:0;" json:"id"` // 序号 + RolePid *int64 `gorm:"default:0;" json:"role_pid"` // 上级角色 + RoleName *string `gorm:"default:'';" json:"role_name"` // + DataAuthType *int64 `gorm:"default:1;" json:"data_auth_type"` // 数据权限类型 + DataAuth *string `gorm:"default:'';" json:"data_auth"` // + Status *int64 `gorm:"default:2;" json:"status"` // 状态:1=启用,2=停用 + Remark *string `gorm:"default:'';" json:"remark"` // + Sort *int64 `gorm:"default:0;" json:"sort"` // 排序权重 + CreateTime *time.Time `gorm:"default:'0000-00-00 00:00:00';" json:"create_time"` // + UpdateTime *time.Time `gorm:"default:'0000-00-00 00:00:00';" json:"update_time"` // + DeleteTime *time.Time `gorm:"default:'0000-00-00 00:00:00';" json:"delete_time"` // + CreateUid *int64 `gorm:"default:0;" json:"create_uid"` // 创建人 + UpdateUid *int64 `gorm:"default:0;" json:"update_uid"` // 更新人 + DeleteUid *int64 `gorm:"default:0;" json:"delete_uid"` // 删除人 + IsDel *int64 `gorm:"default:0;" json:"is_del"` // 是否删除:1=是 0=否 +} +type FsAdminAuthRoleModel struct { + db *gorm.DB + name string +} + +func NewFsAdminAuthRoleModel(db *gorm.DB) *FsAdminAuthRoleModel { + return &FsAdminAuthRoleModel{db: db, name: "fs_admin_auth_role"} +} diff --git a/model/gmodel/fs_admin_auth_role_logic.go b/model/gmodel/fs_admin_auth_role_logic.go new file mode 100644 index 00000000..e68225aa --- /dev/null +++ b/model/gmodel/fs_admin_auth_role_logic.go @@ -0,0 +1,2 @@ +package gmodel +// TODO: 使用model的属性做你想做的 \ No newline at end of file diff --git a/model/gmodel/fs_admin_department_gen.go b/model/gmodel/fs_admin_department_gen.go new file mode 100644 index 00000000..25349b64 --- /dev/null +++ b/model/gmodel/fs_admin_department_gen.go @@ -0,0 +1,35 @@ +package gmodel + +import ( + "gorm.io/gorm" + "time" +) + +// fs_admin_department 后台--部门表 +type FsAdminDepartment struct { + Id int64 `gorm:"primary_key;default:0;" json:"id"` // 序号 + DeptPid *int64 `gorm:"default:0;" json:"dept_pid"` // 上级部门 + DeptNo *string `gorm:"default:'';" json:"dept_no"` // + DeptName *string `gorm:"default:'';" json:"dept_name"` // + ShortName *string `gorm:"default:'';" json:"short_name"` // + UserId *int64 `gorm:"default:0;" json:"user_id"` // 部门负责人 + Phone *string `gorm:"default:'';" json:"phone"` // + Status *int64 `gorm:"default:2;" json:"status"` // 状态:1=启用,2=停用 + Remark *string `gorm:"default:'';" json:"remark"` // + Sort *int64 `gorm:"default:0;" json:"sort"` // 排序权重 + CreateTime *time.Time `gorm:"default:'0000-00-00 00:00:00';" json:"create_time"` // + UpdateTime *time.Time `gorm:"default:'0000-00-00 00:00:00';" json:"update_time"` // + DeleteTime *time.Time `gorm:"default:'0000-00-00 00:00:00';" json:"delete_time"` // + CreateUid *int64 `gorm:"default:0;" json:"create_uid"` // 创建人 + UpdateUid *int64 `gorm:"default:0;" json:"update_uid"` // 更新人 + DeleteUid *int64 `gorm:"default:0;" json:"delete_uid"` // 删除人 + IsDel *int64 `gorm:"default:0;" json:"is_del"` // 是否删除:1=是 0=否 +} +type FsAdminDepartmentModel struct { + db *gorm.DB + name string +} + +func NewFsAdminDepartmentModel(db *gorm.DB) *FsAdminDepartmentModel { + return &FsAdminDepartmentModel{db: db, name: "fs_admin_department"} +} diff --git a/model/gmodel/fs_admin_department_logic.go b/model/gmodel/fs_admin_department_logic.go new file mode 100644 index 00000000..e68225aa --- /dev/null +++ b/model/gmodel/fs_admin_department_logic.go @@ -0,0 +1,2 @@ +package gmodel +// TODO: 使用model的属性做你想做的 \ No newline at end of file diff --git a/model/gmodel/fs_admin_menu_gen.go b/model/gmodel/fs_admin_menu_gen.go new file mode 100644 index 00000000..230ea1b4 --- /dev/null +++ b/model/gmodel/fs_admin_menu_gen.go @@ -0,0 +1,33 @@ +package gmodel + +import ( + "gorm.io/gorm" + "time" +) + +// fs_admin_menu 后台--菜单表 +type FsAdminMenu struct { + Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` // 序号 + Pid *int64 `gorm:"default:0;" json:"pid"` // 上级菜单 + Name *string `gorm:"default:'';" json:"name"` // + Path *string `gorm:"default:'';" json:"path"` // + Hide *string `gorm:"default:'';" json:"hide"` // + Metadata *[]byte `gorm:"default:'';" json:"metadata"` // 元数据,json格式 + Remark *string `gorm:"default:'';" json:"remark"` // + Sort *int64 `gorm:"default:0;" json:"sort"` // 排序权重 + CreateTime *time.Time `gorm:"default:'0000-00-00 00:00:00';" json:"create_time"` // + UpdateTime *time.Time `gorm:"default:'0000-00-00 00:00:00';" json:"update_time"` // + DeleteTime *time.Time `gorm:"default:'0000-00-00 00:00:00';" json:"delete_time"` // + CreateUid *int64 `gorm:"default:0;" json:"create_uid"` // 创建人 + UpdateUid *int64 `gorm:"default:0;" json:"update_uid"` // 更新人 + DeleteUid *int64 `gorm:"default:0;" json:"delete_uid"` // 删除人 + IsDel *int64 `gorm:"default:0;" json:"is_del"` // 是否删除:1=是 0=否 +} +type FsAdminMenuModel struct { + db *gorm.DB + name string +} + +func NewFsAdminMenuModel(db *gorm.DB) *FsAdminMenuModel { + return &FsAdminMenuModel{db: db, name: "fs_admin_menu"} +} diff --git a/model/gmodel/fs_admin_menu_logic.go b/model/gmodel/fs_admin_menu_logic.go new file mode 100644 index 00000000..e68225aa --- /dev/null +++ b/model/gmodel/fs_admin_menu_logic.go @@ -0,0 +1,2 @@ +package gmodel +// TODO: 使用model的属性做你想做的 \ No newline at end of file From 3cf129537321b558be5f58bf8db57a3dcef52e72 Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Mon, 28 Aug 2023 15:09:01 +0800 Subject: [PATCH 05/14] 1 --- initalize/mysql.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/initalize/mysql.go b/initalize/mysql.go index 75db586f..520c519f 100644 --- a/initalize/mysql.go +++ b/initalize/mysql.go @@ -37,7 +37,7 @@ func InitMysql(sourceMysql string) *gorm.DB { sqlDB.SetMaxIdleConns(4) // SetMaxOpenConns 设置打开数据库连接的最大数量。 - sqlDB.SetMaxOpenConns(10) + sqlDB.SetMaxOpenConns(25) // SetConnMaxLifetime 设置了连接可复用的最大时间。 sqlDB.SetConnMaxLifetime(time.Minute * 20) From c3286e41fa42f444db17d217d86e8038d0442662 Mon Sep 17 00:00:00 2001 From: momo <1012651275@qq.com> Date: Mon, 28 Aug 2023 15:17:36 +0800 Subject: [PATCH 06/14] =?UTF-8?q?fix:=E8=B0=83=E6=95=B4=E4=B8=8A=E4=BC=A0?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- utils/file/upload.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/utils/file/upload.go b/utils/file/upload.go index 9991abaa..5108daea 100644 --- a/utils/file/upload.go +++ b/utils/file/upload.go @@ -102,8 +102,9 @@ func (upload *Upload) UploadFileByBase64(req *UploadBaseReq) (*UploadBaseRes, er // 创建S3对象存储请求 s3req, _ = svc.PutObjectRequest( &s3.PutObjectInput{ - Bucket: bucketName, - Key: &resourceId, + Bucket: bucketName, + Key: &resourceId, + CacheControl: aws.String("no-cache, must-revalidate"), }, ) @@ -226,8 +227,9 @@ func (upload *Upload) UploadFileByByte(req *UploadBaseReq) (*UploadBaseRes, erro // 创建S3对象存储请求 s3req, _ = svc.PutObjectRequest( &s3.PutObjectInput{ - Bucket: bucketName, - Key: &resourceId, + Bucket: bucketName, + Key: &resourceId, + CacheControl: aws.String("no-cache, must-revalidate"), }, ) From 7dc95e3cbacffebbcbb8d5fdeb9cb1544604d89b Mon Sep 17 00:00:00 2001 From: momo <1012651275@qq.com> Date: Mon, 28 Aug 2023 15:20:46 +0800 Subject: [PATCH 07/14] =?UTF-8?q?fix:=E6=96=B0=E7=9A=84=E8=A7=A3=E6=9E=90j?= =?UTF-8?q?wtToken=E8=BF=94=E5=9B=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- utils/basic/request_parse.go | 1 + 1 file changed, 1 insertion(+) diff --git a/utils/basic/request_parse.go b/utils/basic/request_parse.go index 42879699..1c0afdf1 100644 --- a/utils/basic/request_parse.go +++ b/utils/basic/request_parse.go @@ -129,6 +129,7 @@ func RequestParse(w http.ResponseWriter, r *http.Request, svcCtx any, LogicReque Code: 510, Message: err.Error(), }) + return nil, err } // 如果端点有请求结构体,则使用httpx.Parse方法从HTTP请求体中解析请求数据 From fed40e2aa87e2b8be7e30d9657268f563cf9cac4 Mon Sep 17 00:00:00 2001 From: momo <1012651275@qq.com> Date: Mon, 28 Aug 2023 15:25:29 +0800 Subject: [PATCH 08/14] =?UTF-8?q?fix:=E6=96=B0=E7=9A=84=E8=A7=A3=E6=9E=90j?= =?UTF-8?q?wtToken=E8=BF=94=E5=9B=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- utils/file/upload.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/utils/file/upload.go b/utils/file/upload.go index 5108daea..af459ae1 100644 --- a/utils/file/upload.go +++ b/utils/file/upload.go @@ -102,9 +102,9 @@ func (upload *Upload) UploadFileByBase64(req *UploadBaseReq) (*UploadBaseRes, er // 创建S3对象存储请求 s3req, _ = svc.PutObjectRequest( &s3.PutObjectInput{ - Bucket: bucketName, - Key: &resourceId, - CacheControl: aws.String("no-cache, must-revalidate"), + Bucket: bucketName, + Key: &resourceId, + // CacheControl: aws.String("no-cache, must-revalidate"), }, ) @@ -227,9 +227,9 @@ func (upload *Upload) UploadFileByByte(req *UploadBaseReq) (*UploadBaseRes, erro // 创建S3对象存储请求 s3req, _ = svc.PutObjectRequest( &s3.PutObjectInput{ - Bucket: bucketName, - Key: &resourceId, - CacheControl: aws.String("no-cache, must-revalidate"), + Bucket: bucketName, + Key: &resourceId, + // CacheControl: aws.String("no-cache, must-revalidate"), }, ) From 083781737ae701a8bdb18b1a43e386968d0504a8 Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Mon, 28 Aug 2023 15:34:30 +0800 Subject: [PATCH 09/14] 1 --- server/websocket/internal/logic/datatransferlogic.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/server/websocket/internal/logic/datatransferlogic.go b/server/websocket/internal/logic/datatransferlogic.go index b62f4dca..c315a036 100644 --- a/server/websocket/internal/logic/datatransferlogic.go +++ b/server/websocket/internal/logic/datatransferlogic.go @@ -300,7 +300,7 @@ func (w *wsConnectItem) readLoop() { select { case <-w.closeChan: //如果关闭了 return - default: + default: //收取消息 msgType, data, err := w.conn.ReadMessage() if err != nil { logx.Error("接受信息错误:", err) @@ -310,8 +310,12 @@ func (w *wsConnectItem) readLoop() { } //ping的消息不处理 if msgType != websocket.PingMessage { - //消息传入缓冲通道 - w.inChan <- data + select { + case w.inChan <- data: //消息传入缓冲通道 + continue + case <-time.After(time.Second * 3): //3秒放不进去就丢弃 + continue + } } } } From d4b6ef5d7c8412dbc812aac991886e762d4f1660 Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Mon, 28 Aug 2023 15:37:45 +0800 Subject: [PATCH 10/14] 1 --- server/websocket/internal/logic/datatransferlogic.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server/websocket/internal/logic/datatransferlogic.go b/server/websocket/internal/logic/datatransferlogic.go index c315a036..1563ee42 100644 --- a/server/websocket/internal/logic/datatransferlogic.go +++ b/server/websocket/internal/logic/datatransferlogic.go @@ -308,8 +308,8 @@ func (w *wsConnectItem) readLoop() { w.close() return } - //ping的消息不处理 - if msgType != websocket.PingMessage { + //ping/pong/close的消息不处理 + if msgType != websocket.PingMessage && msgType != websocket.PongMessage && msgType != websocket.CloseMessage { select { case w.inChan <- data: //消息传入缓冲通道 continue From b03f87c91904cebc6f63b81156ae778b85a87fad Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Mon, 28 Aug 2023 15:40:56 +0800 Subject: [PATCH 11/14] 1 --- .../internal/logic/homepagerecommendproductlistlogic.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server/product/internal/logic/homepagerecommendproductlistlogic.go b/server/product/internal/logic/homepagerecommendproductlistlogic.go index 389a01e0..2b5f27fa 100644 --- a/server/product/internal/logic/homepagerecommendproductlistlogic.go +++ b/server/product/internal/logic/homepagerecommendproductlistlogic.go @@ -56,7 +56,7 @@ func (l *HomePageRecommendProductListLogic) HomePageRecommendProductList(req *ty merchantInfo, err = l.svcCtx.AllModels.FsMerchantCategory.FindOne(l.ctx, req.MerchantType) if err != nil { if errors.Is(err, gorm.ErrRecordNotFound) { - return resp.SetStatusWithMessage(basic.CodeDbRecordNotFoundErr, "the merchant category is not exists") + return resp.SetStatusWithMessage(basic.CodeOK, "the merchant category is not exists", []interface{}{}) } logx.Error(err) return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get merchant category") @@ -66,7 +66,7 @@ func (l *HomePageRecommendProductListLogic) HomePageRecommendProductList(req *ty merchantInfo, err = l.svcCtx.AllModels.FsMerchantCategory.FindDefualtOne(l.ctx) if err != nil { if errors.Is(err, gorm.ErrRecordNotFound) { - return resp.SetStatusWithMessage(basic.CodeDbRecordNotFoundErr, "the default merchant category is not exists") + return resp.SetStatusWithMessage(basic.CodeOK, "the default merchant category is not exists", []interface{}{}) } logx.Error(err) return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get default merchant category") From bb8c80d7f7bd0289515a8b6f991d52c3cf8dd25c Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Mon, 28 Aug 2023 15:47:25 +0800 Subject: [PATCH 12/14] 1 --- .../internal/logic/datatransferlogic.go | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/server/websocket/internal/logic/datatransferlogic.go b/server/websocket/internal/logic/datatransferlogic.go index 1563ee42..c61507af 100644 --- a/server/websocket/internal/logic/datatransferlogic.go +++ b/server/websocket/internal/logic/datatransferlogic.go @@ -310,12 +310,7 @@ func (w *wsConnectItem) readLoop() { } //ping/pong/close的消息不处理 if msgType != websocket.PingMessage && msgType != websocket.PongMessage && msgType != websocket.CloseMessage { - select { - case w.inChan <- data: //消息传入缓冲通道 - continue - case <-time.After(time.Second * 3): //3秒放不进去就丢弃 - continue - } + w.sendToInChan(data) } } } @@ -350,6 +345,18 @@ func (w *wsConnectItem) sendToOutChan(data []byte) { } } +// 发送接受到的消息到入口缓冲队列中 +func (w *wsConnectItem) sendToInChan(data []byte) { + select { + case <-w.closeChan: //关闭了 + return + case w.inChan <- data: + return + case <-time.After(time.Second * 3): //3秒超时丢弃 + return + } +} + // 格式化为websocket标准返回格式 func (w *wsConnectItem) respondDataFormat(msgType constants.Websocket, data interface{}) []byte { d := websocket_data.DataTransferData{ From 22e62e1e0506f2c396480730365e8221412948b0 Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Mon, 28 Aug 2023 15:50:18 +0800 Subject: [PATCH 13/14] 1 --- .../websocket/internal/logic/datatransferlogic.go | 14 +++++++------- server/websocket/internal/logic/ws_render_image.go | 8 ++++---- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/server/websocket/internal/logic/datatransferlogic.go b/server/websocket/internal/logic/datatransferlogic.go index c61507af..7c97ec08 100644 --- a/server/websocket/internal/logic/datatransferlogic.go +++ b/server/websocket/internal/logic/datatransferlogic.go @@ -59,7 +59,7 @@ var ( CheckOrigin: func(r *http.Request) bool { return true }, - //写的缓存池 + //写的缓冲队列 WriteBufferPool: &buffPool, //是否支持压缩 EnableCompression: false, @@ -75,8 +75,8 @@ type wsConnectItem struct { closeChan chan struct{} //ws连接关闭chan(基本属性) isClose bool //是否已经关闭(基本属性) uniqueId string //ws连接唯一标识(基本属性) - inChan chan []byte //接受消息缓冲池(基本属性) - outChan chan []byte //要发送回客户端的消息缓冲池(基本属性) + inChan chan []byte //接受消息缓冲队列(基本属性) + outChan chan []byte //要发送回客户端的消息缓冲队列(基本属性) mutex sync.Mutex //互斥锁(基本属性) userId int64 //用户id(基本属性) guestId int64 //游客id(基本属性) @@ -268,7 +268,7 @@ func (w *wsConnectItem) close() { logx.Info("###websocket:", w.uniqueId, " uid:", w.userId, " gid:", w.guestId, " is closed") } -// 读取出口缓冲池数据输出返回给浏览器端 +// 读取出口缓冲队列数据输出返回给浏览器端 func (w *wsConnectItem) writeLoop() { defer func() { if err := recover(); err != nil { @@ -289,7 +289,7 @@ func (w *wsConnectItem) writeLoop() { } } -// 接受客户端发来的消息并写入入口缓冲池 +// 接受客户端发来的消息并写入入口缓冲队列 func (w *wsConnectItem) readLoop() { defer func() { if err := recover(); err != nil { @@ -333,7 +333,7 @@ func (w *wsConnectItem) sendLoop() { } } -// 把要传递给客户端的数据放入出口缓冲池 +// 把要传递给客户端的数据放入出口缓冲队列 func (w *wsConnectItem) sendToOutChan(data []byte) { select { case <-w.closeChan: @@ -367,7 +367,7 @@ func (w *wsConnectItem) respondDataFormat(msgType constants.Websocket, data inte return b } -// 处理入口缓冲池中不同类型的数据(分发处理) +// 处理入口缓冲队列中不同类型的数据(分发处理) func (w *wsConnectItem) dealwithReciveData(data []byte) { var parseInfo websocket_data.DataTransferData if err := json.Unmarshal(data, &parseInfo); err != nil { diff --git a/server/websocket/internal/logic/ws_render_image.go b/server/websocket/internal/logic/ws_render_image.go index b2ac63b7..123545ff 100644 --- a/server/websocket/internal/logic/ws_render_image.go +++ b/server/websocket/internal/logic/ws_render_image.go @@ -44,19 +44,19 @@ type renderTask struct { uploadUnityRenderImageTakesTime int64 //上传unity渲染结果图时间 } -// 发送到渲染缓冲池 +// 发送到渲染缓冲队列 func (w *wsConnectItem) sendToRenderChan(data []byte) { select { case <-w.closeChan: //已经关闭 return - case w.extendRenderProperty.renderChan <- data: //发入到缓冲池 + case w.extendRenderProperty.renderChan <- data: //发入到缓冲队列 return - case <-time.After(time.Second * 3): //三秒没进入缓冲池就丢弃 + case <-time.After(time.Second * 3): //三秒没进入缓冲队列就丢弃 return } } -// 渲染发送到组装数据组装数据(缓冲池) +// 渲染发送到组装数据组装数据(缓冲队列) func (w *wsConnectItem) renderImage() { for { select { From 02090f640135f3625a8ca99fc74b50151f8926fa Mon Sep 17 00:00:00 2001 From: momo <1012651275@qq.com> Date: Mon, 28 Aug 2023 16:11:54 +0800 Subject: [PATCH 14/14] =?UTF-8?q?fix:=E6=96=B0=E7=9A=84=E8=A7=A3=E6=9E=90j?= =?UTF-8?q?wtToken=E8=BF=94=E5=9B=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- utils/file/upload.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/utils/file/upload.go b/utils/file/upload.go index af459ae1..5108daea 100644 --- a/utils/file/upload.go +++ b/utils/file/upload.go @@ -102,9 +102,9 @@ func (upload *Upload) UploadFileByBase64(req *UploadBaseReq) (*UploadBaseRes, er // 创建S3对象存储请求 s3req, _ = svc.PutObjectRequest( &s3.PutObjectInput{ - Bucket: bucketName, - Key: &resourceId, - // CacheControl: aws.String("no-cache, must-revalidate"), + Bucket: bucketName, + Key: &resourceId, + CacheControl: aws.String("no-cache, must-revalidate"), }, ) @@ -227,9 +227,9 @@ func (upload *Upload) UploadFileByByte(req *UploadBaseReq) (*UploadBaseRes, erro // 创建S3对象存储请求 s3req, _ = svc.PutObjectRequest( &s3.PutObjectInput{ - Bucket: bucketName, - Key: &resourceId, - // CacheControl: aws.String("no-cache, must-revalidate"), + Bucket: bucketName, + Key: &resourceId, + CacheControl: aws.String("no-cache, must-revalidate"), }, )