From d1c6f5cdc5a1b41605b57a9d2bf6e2520bba2179 Mon Sep 17 00:00:00 2001 From: Hiven Date: Tue, 15 Aug 2023 10:58:24 +0800 Subject: [PATCH 01/25] =?UTF-8?q?fix:=E9=87=8D=E6=9E=84=E5=90=88=E5=9B=BE?= =?UTF-8?q?=E6=A8=A1=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/resource/etc/resource.yaml | 3 +- .../internal/logic/logocombinelogic.go | 13 +++++--- server/resource/internal/types/types.go | 9 +++-- server_api/resource.api | 9 +++-- service/repositories/image_handle.go | 33 +++++++++++++++---- 5 files changed, 48 insertions(+), 19 deletions(-) diff --git a/server/resource/etc/resource.yaml b/server/resource/etc/resource.yaml index 473ac3f3..a279336e 100644 --- a/server/resource/etc/resource.yaml +++ b/server/resource/etc/resource.yaml @@ -15,7 +15,8 @@ AWS: Secret: sjCEv0JxATnPCxno2KNLm0X8oDc7srUR+4vkYhvm Token: BLMService: - Url: "http://18.119.109.254:8999" + # Url: "http://18.119.109.254:8999" + Url: "http://192.168.1.7:8999" LogoCombine: #Url: "http://192.168.1.7:8999/LogoCombine" Url: "http://18.119.109.254:8999/LogoCombine" \ No newline at end of file diff --git a/server/resource/internal/logic/logocombinelogic.go b/server/resource/internal/logic/logocombinelogic.go index bad59cb9..72468f8e 100644 --- a/server/resource/internal/logic/logocombinelogic.go +++ b/server/resource/internal/logic/logocombinelogic.go @@ -57,11 +57,14 @@ func (l *LogoCombineLogic) LogoCombine(req *types.LogoCombineReq, userinfo *auth userId = userinfo.UserId } res, err := l.svcCtx.Repositories.ImageHandle.LogoCombine(l.ctx, &repositories.LogoCombineReq{ - ResourceKey: req.ResourceKey, - TemplateId: req.TemplateId, - CombineParam: req.CombineParam, - UserId: userId, - GuestId: guestId, + UserId: userId, + GuestId: guestId, + TemplateId: req.TemplateId, + TemplateTag: req.TemplateTag, + Website: req.Website, + Slogan: req.Slogan, + Phone: req.Phone, + Address: req.Address, }) if err != nil { diff --git a/server/resource/internal/types/types.go b/server/resource/internal/types/types.go index 47e38155..f397f7b7 100644 --- a/server/resource/internal/types/types.go +++ b/server/resource/internal/types/types.go @@ -11,9 +11,12 @@ type ResourceInfoReq struct { } type LogoCombineReq struct { - ResourceKey string `form:"resource_key"` // 资源唯一标识 - CombineParam string `form:"combine_param"` // 合图参数 - TemplateId int64 `form:"template_id"` // 合图参数 + TemplateId int64 `form:"template_id"` // 合图参数 + TemplateTag string `form:"template_tag"` // 合图参数 + Website string `form:"website,optional"` // 合图参数 + Slogan string `form:"slogan,optional"` // 合图参数 + Address string `form:"address,optional"` // 合图参数 + Phone string `form:"phone,optional"` // 合图参数 } type Request struct { diff --git a/server_api/resource.api b/server_api/resource.api index 0a37f93f..33cf915b 100644 --- a/server_api/resource.api +++ b/server_api/resource.api @@ -26,8 +26,11 @@ type ( type ( LogoCombineReq { - ResourceKey string `form:"resource_key"` // 资源唯一标识 - CombineParam string `form:"combine_param"` // 合图参数 - TemplateId int64 `form:"template_id"` // 合图参数 + TemplateId int64 `form:"template_id"` // 合图参数 + TemplateTag string `form:"template_tag"` // 合图参数 + Website string `form:"website,optional"` // 合图参数 + Slogan string `form:"slogan,optional"` // 合图参数 + Address string `form:"address,optional"` // 合图参数 + Phone string `form:"phone,optional"` // 合图参数 } ) \ No newline at end of file diff --git a/service/repositories/image_handle.go b/service/repositories/image_handle.go index 5e873b3f..574683ac 100644 --- a/service/repositories/image_handle.go +++ b/service/repositories/image_handle.go @@ -43,11 +43,14 @@ type ( /* logo合图 */ type ( LogoCombineReq struct { - ResourceKey string `json:"resource_key"` - TemplateId int64 `json:"template_id"` - CombineParam string `json:"combine_param"` - UserId int64 `json:"user_id"` - GuestId int64 `json:"guest_id"` + UserId int64 `json:"user_id"` + GuestId int64 `json:"guest_id"` + TemplateId int64 `json:"template_id"` + TemplateTag string `json:"resource_key"` + Website string `form:"website,optional"` // 合图参数 + Slogan string `form:"slogan,optional"` // 合图参数 + Address string `form:"address,optional"` // 合图参数 + Phone string `form:"phone,optional"` // 合图参数 } LogoCombineRes struct { ResourceId string @@ -58,7 +61,8 @@ type ( func (l *defaultImageHandle) LogoCombine(ctx context.Context, in *LogoCombineReq) (*LogoCombineRes, error) { // 根据hash 查询数据资源 - var resourceId string = hash.JsonHashKey(in.ResourceKey) + var resourceId string = hash.JsonHashKey(in) + resourceModel := gmodel.NewFsResourceModel(l.MysqlConn) resourceInfo, err := resourceModel.FindOneById(ctx, resourceId) if err == nil && resourceInfo.ResourceId != "" { @@ -111,8 +115,23 @@ func (l *defaultImageHandle) LogoCombine(ctx context.Context, in *LogoCombineReq moduleDataMap["groupOptions"] = groupOptions moduleDataMap["materialList"] = materialList + // 查询logo最新基础信息 + userMaterialModel := gmodel.NewFsUserMaterialModel(l.MysqlConn) + userMaterialInfo, err := userMaterialModel.FindLatestOne(ctx, in.UserId, in.GuestId) + + if err != nil { + logx.Error(err) + return nil, err + } + var combineParam map[string]interface{} - json.Unmarshal([]byte(in.CombineParam), &combineParam) + json.Unmarshal([]byte(*userMaterialInfo.Metadata), &combineParam) + combineParam["template_tagid"] = in.TemplateTag + combineParam["website"] = in.Website + combineParam["slogan"] = in.Slogan + combineParam["phone"] = in.Phone + combineParam["address"] = in.Address + var postMap = make(map[string]interface{}, 2) postMap["module_data"] = moduleDataMap postMap["param_data"] = combineParam From f65f5673f8f60faeea4529205022a476ce0f35ec Mon Sep 17 00:00:00 2001 From: Hiven Date: Tue, 15 Aug 2023 10:58:58 +0800 Subject: [PATCH 02/25] =?UTF-8?q?fix:=E9=87=8D=E6=9E=84=E5=90=88=E5=9B=BE?= =?UTF-8?q?=E6=A8=A1=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/resource/etc/resource.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server/resource/etc/resource.yaml b/server/resource/etc/resource.yaml index a279336e..2b9f5737 100644 --- a/server/resource/etc/resource.yaml +++ b/server/resource/etc/resource.yaml @@ -15,8 +15,8 @@ AWS: Secret: sjCEv0JxATnPCxno2KNLm0X8oDc7srUR+4vkYhvm Token: BLMService: - # Url: "http://18.119.109.254:8999" - Url: "http://192.168.1.7:8999" + Url: "http://18.119.109.254:8999" + # Url: "http://192.168.1.7:8999" LogoCombine: #Url: "http://192.168.1.7:8999/LogoCombine" Url: "http://18.119.109.254:8999/LogoCombine" \ No newline at end of file From c5ef6cfa14ff085f1dee12bc364326fe6df04a60 Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Tue, 15 Aug 2023 11:18:22 +0800 Subject: [PATCH 03/25] fix --- model/gmodel/fs_product_template_tags_gen.go | 2 +- model/gmodel/fs_product_template_v2_gen.go | 2 +- model/gmodel/fs_product_template_v2_logic.go | 4 +- .../logic/getproducttemplatetagslogic.go | 6 +-- .../internal/types/types.go | 6 +-- .../render/consumer/assemble_render_data.go | 37 +++++-------------- .../internal/logic/ws_render_image_logic.go | 6 +-- server_api/product-template-tag.api | 6 +-- utils/websocket_data/render_data.go | 10 ++--- 9 files changed, 30 insertions(+), 49 deletions(-) diff --git a/model/gmodel/fs_product_template_tags_gen.go b/model/gmodel/fs_product_template_tags_gen.go index 07d86482..a5505bbb 100644 --- a/model/gmodel/fs_product_template_tags_gen.go +++ b/model/gmodel/fs_product_template_tags_gen.go @@ -7,7 +7,7 @@ import ( // fs_product_template_tags 模板标签表 type FsProductTemplateTags struct { Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` // ID - Title *string `gorm:"default:'';" json:"title"` // 标题 + Title *string `gorm:"unique_key;default:'';" json:"title"` // 标题 Cover *string `gorm:"default:'';" json:"cover"` // 封面图 Status *int64 `gorm:"default:0;" json:"status"` // 状态 1:可用 CreateAt *int64 `gorm:"default:0;" json:"create_at"` // 创建时间 diff --git a/model/gmodel/fs_product_template_v2_gen.go b/model/gmodel/fs_product_template_v2_gen.go index 07ad37fc..68c91ed5 100644 --- a/model/gmodel/fs_product_template_v2_gen.go +++ b/model/gmodel/fs_product_template_v2_gen.go @@ -24,7 +24,7 @@ type FsProductTemplateV2 struct { IsDel *int64 `gorm:"default:0;" json:"is_del"` // 是否删除 1删除 SwitchInfo *string `gorm:"default:'';" json:"switch_info"` // GroupOptions *string `gorm:"default:'';" json:"group_options"` // - Version *int64 `gorm:"default:0;" json:"version"` // + Version *int64 `gorm:"index;default:0;" json:"version"` // 默认1 } type FsProductTemplateV2Model struct { db *gorm.DB diff --git a/model/gmodel/fs_product_template_v2_logic.go b/model/gmodel/fs_product_template_v2_logic.go index 57109ca8..a4945096 100755 --- a/model/gmodel/fs_product_template_v2_logic.go +++ b/model/gmodel/fs_product_template_v2_logic.go @@ -111,11 +111,11 @@ func (t *FsProductTemplateV2Model) GetProductTemplateListByParams(ctx context.Co } // 获取第一个尺寸下的模板 -func (t *FsProductTemplateV2Model) FindOneByProductIdTagIdWithSizeTable(ctx context.Context, productId int64, tagId string) (resp *FsProductTemplateV2, err error) { +func (t *FsProductTemplateV2Model) FindOneByProductIdTagIdWithSizeTable(ctx context.Context, productId int64, templateTag string) (resp *FsProductTemplateV2, err error) { err = t.db.WithContext(ctx).Table(t.name+" as t"). Joins("left join fs_product_size as s on t.product_id = s.product_id"). Select("t.*"). - Where("t.product_id = ? and t.tag = ? ", productId, tagId). + Where("t.product_id = ? and t.tag = ? ", productId, templateTag). Where("t.status = ? and t.is_del = ?", 1, 0). Where("s.status = ?", 1). Order("s.sort ASC"). diff --git a/server/product-template-tag/internal/logic/getproducttemplatetagslogic.go b/server/product-template-tag/internal/logic/getproducttemplatetagslogic.go index 21953ee1..de9d34da 100644 --- a/server/product-template-tag/internal/logic/getproducttemplatetagslogic.go +++ b/server/product-template-tag/internal/logic/getproducttemplatetagslogic.go @@ -81,9 +81,9 @@ func (l *GetProductTemplateTagsLogic) GetProductTemplateTags(req *types.GetProdu list := make([]types.GetProductTemplateTagsRsp, 0, len(productTemplateTags)) for _, v := range productTemplateTags { list = append(list, types.GetProductTemplateTagsRsp{ - Id: v.Id, - Tag: *v.Title, - Cover: *v.Cover, + Id: v.Id, + TemplateTag: *v.Title, + Cover: *v.Cover, }) } return resp.SetStatusWithMessage(basic.CodeOK, "success", list) diff --git a/server/product-template-tag/internal/types/types.go b/server/product-template-tag/internal/types/types.go index a89ea882..60cb80ca 100644 --- a/server/product-template-tag/internal/types/types.go +++ b/server/product-template-tag/internal/types/types.go @@ -10,9 +10,9 @@ type GetProductTemplateTagsReq struct { } type GetProductTemplateTagsRsp struct { - Id int64 `json:"id"` - Tag string `json:"tag"` - Cover string `json:"cover"` + Id int64 `json:"id"` + TemplateTag string `json:"template_tag"` + Cover string `json:"cover"` } type Request struct { diff --git a/server/render/consumer/assemble_render_data.go b/server/render/consumer/assemble_render_data.go index 85a32996..5fb67298 100644 --- a/server/render/consumer/assemble_render_data.go +++ b/server/render/consumer/assemble_render_data.go @@ -4,17 +4,14 @@ import ( "context" "encoding/json" "errors" - "fmt" "fusenapi/constants" "fusenapi/initalize" "fusenapi/server/render/internal/svc" "fusenapi/service/repositories" - "fusenapi/utils/hash" "fusenapi/utils/websocket_data" "github.com/zeromicro/go-zero/core/logx" "gorm.io/gorm" "strconv" - "time" ) // 这里请求的py接口返回数据 @@ -52,7 +49,7 @@ func (m *MqConsumerRenderAssemble) Run(ctx context.Context, data []byte) error { } rabbitmq := initalize.RabbitMqHandle{} //获取模板(模板标签下的对一个物料的的模板) - productTemplate, err := svcCtx.AllModels.FsProductTemplateV2.FindOneByProductIdTagIdWithSizeTable(ctx, parseInfo.RenderData.ProductId, fmt.Sprintf("%d", parseInfo.RenderData.TemplateTagId)) + productTemplate, err := svcCtx.AllModels.FsProductTemplateV2.FindOneByProductIdTagIdWithSizeTable(ctx, parseInfo.RenderData.ProductId, parseInfo.RenderData.TemplateTag) if err != nil { if errors.Is(err, gorm.ErrRecordNotFound) { logx.Error("template info is not found") @@ -61,33 +58,17 @@ func (m *MqConsumerRenderAssemble) Run(ctx context.Context, data []byte) error { logx.Error("failed to get template info:", err) return nil //不返回错误就删除消息 } - time.Now().UTC() - resourceKey := hash.JsonHashKey(parseInfo) - combineParam := map[string]interface{}{ - "logo_url": parseInfo.RenderData.Logo, - "website": "", - "slogan": "", - "address": "", - "phone": "", - "colors": []string{}, - "template_tagid": "b1a", - "is_crop": false, - "shape": "rectangle", - "ratio": 0, - "line": "", - "other": "", - "other1": "", - } - combineParamBytes, _ := json.Marshal(combineParam) //获取刀版图 res, err := svcCtx.Repositories.ImageHandle.LogoCombine(ctx, &repositories.LogoCombineReq{ - ResourceKey: resourceKey, - TemplateId: productTemplate.Id, - CombineParam: string(combineParamBytes), - UserId: parseInfo.RenderData.UserId, - GuestId: parseInfo.RenderData.GuestId, + UserId: parseInfo.RenderData.UserId, + GuestId: parseInfo.RenderData.GuestId, + TemplateId: productTemplate.Id, + TemplateTag: parseInfo.RenderData.TemplateTag, + Website: parseInfo.RenderData.Website, + Slogan: parseInfo.RenderData.Slogan, + Address: parseInfo.RenderData.Address, + Phone: parseInfo.RenderData.Phone, }) - if err != nil { logx.Error("合成刀版图失败:", err) return nil diff --git a/server/websocket/internal/logic/ws_render_image_logic.go b/server/websocket/internal/logic/ws_render_image_logic.go index 1aadd993..77240ce6 100644 --- a/server/websocket/internal/logic/ws_render_image_logic.go +++ b/server/websocket/internal/logic/ws_render_image_logic.go @@ -42,9 +42,9 @@ func (w *wsConnectItem) renderImage(data []byte) { logx.Error("invalid format of websocket render image message:product_id") return } - if renderImageData.RenderData.TemplateTagId <= 0 { - w.outChan <- w.respondDataFormat(constants.WEBSOCKET_ERR_DATA_FORMAT, "invalid format of websocket render image message:template_tag_id ") - logx.Error("invalid format of websocket render image message:template_tag_id") + if renderImageData.RenderData.TemplateTag == "" { + w.outChan <- w.respondDataFormat(constants.WEBSOCKET_ERR_DATA_FORMAT, "invalid format of websocket render image message:template_tag ") + logx.Error("invalid format of websocket render image message:template_tag") return } //获取上传最近的logo diff --git a/server_api/product-template-tag.api b/server_api/product-template-tag.api index c8b1a2cc..a565ee01 100644 --- a/server_api/product-template-tag.api +++ b/server_api/product-template-tag.api @@ -20,7 +20,7 @@ type GetProductTemplateTagsReq { Limit int `form:"limit"` } type GetProductTemplateTagsRsp { - Id int64 `json:"id"` - Tag string `json:"tag"` - Cover string `json:"cover"` + Id int64 `json:"id"` + TemplateTag string `json:"template_tag"` + Cover string `json:"cover"` } \ No newline at end of file diff --git a/utils/websocket_data/render_data.go b/utils/websocket_data/render_data.go index 3b004441..eaf44eac 100644 --- a/utils/websocket_data/render_data.go +++ b/utils/websocket_data/render_data.go @@ -12,16 +12,16 @@ type RenderImageReqMsg struct { RenderData RenderData `json:"render_data"` } type RenderData struct { - TemplateTagId int64 `json:"template_tag_id"` //模板标签id + TemplateTag string `json:"template_tag"` //模板标签 ProductId int64 `json:"product_id"` //产品id UserMaterialId int64 `json:"user_material_id"` //用户素材id Logo string `json:"logo"` //log资源地址(websocket连接建立再赋值) - /*Website string `json:"website"` //网站 + Website string `json:"website"` //网站 Slogan string `json:"slogan"` //slogan Address string `json:"address"` //地址 - Phone string `json:"phone"` //电话*/ - UserId int64 `json:"user_id"` //用户id(websocket连接建立再赋值) - GuestId int64 `json:"guest_id"` //游客id(websocket连接建立再赋值) + Phone string `json:"phone"` //电话 + UserId int64 `json:"user_id"` //用户id(websocket连接建立再赋值) + GuestId int64 `json:"guest_id"` //游客id(websocket连接建立再赋值) } // websocket发送渲染完的数据 From 90229ca23ef85fd6803ae00791bac81d26d1cdd3 Mon Sep 17 00:00:00 2001 From: Hiven Date: Tue, 15 Aug 2023 11:20:09 +0800 Subject: [PATCH 04/25] =?UTF-8?q?fix:=E9=87=8D=E6=9E=84=E5=90=88=E5=9B=BE?= =?UTF-8?q?=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 | 1 + server/resource/internal/types/types.go | 1 + server_api/resource.api | 1 + service/repositories/image_handle.go | 10 ++++++---- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/server/resource/internal/logic/logocombinelogic.go b/server/resource/internal/logic/logocombinelogic.go index 72468f8e..661228e3 100644 --- a/server/resource/internal/logic/logocombinelogic.go +++ b/server/resource/internal/logic/logocombinelogic.go @@ -65,6 +65,7 @@ func (l *LogoCombineLogic) LogoCombine(req *types.LogoCombineReq, userinfo *auth Slogan: req.Slogan, Phone: req.Phone, Address: req.Address, + Qrcode: req.Qrcode, }) if err != nil { diff --git a/server/resource/internal/types/types.go b/server/resource/internal/types/types.go index f397f7b7..f32c5505 100644 --- a/server/resource/internal/types/types.go +++ b/server/resource/internal/types/types.go @@ -17,6 +17,7 @@ type LogoCombineReq struct { Slogan string `form:"slogan,optional"` // 合图参数 Address string `form:"address,optional"` // 合图参数 Phone string `form:"phone,optional"` // 合图参数 + Qrcode string `form:"qrcode,optional"` // 合图参数 } type Request struct { diff --git a/server_api/resource.api b/server_api/resource.api index 33cf915b..89423498 100644 --- a/server_api/resource.api +++ b/server_api/resource.api @@ -32,5 +32,6 @@ type ( Slogan string `form:"slogan,optional"` // 合图参数 Address string `form:"address,optional"` // 合图参数 Phone string `form:"phone,optional"` // 合图参数 + Qrcode string `form:"qrcode,optional"` // 合图参数 } ) \ No newline at end of file diff --git a/service/repositories/image_handle.go b/service/repositories/image_handle.go index 574683ac..02292984 100644 --- a/service/repositories/image_handle.go +++ b/service/repositories/image_handle.go @@ -47,10 +47,11 @@ type ( GuestId int64 `json:"guest_id"` TemplateId int64 `json:"template_id"` TemplateTag string `json:"resource_key"` - Website string `form:"website,optional"` // 合图参数 - Slogan string `form:"slogan,optional"` // 合图参数 - Address string `form:"address,optional"` // 合图参数 - Phone string `form:"phone,optional"` // 合图参数 + Website string `json:"website"` // 合图参数 + Slogan string `json:"slogan"` // 合图参数 + Address string `json:"address"` // 合图参数 + Phone string `json:"phone"` // 合图参数 + Qrcode string `json:"qrcode"` // 合图参数 } LogoCombineRes struct { ResourceId string @@ -131,6 +132,7 @@ func (l *defaultImageHandle) LogoCombine(ctx context.Context, in *LogoCombineReq combineParam["slogan"] = in.Slogan combineParam["phone"] = in.Phone combineParam["address"] = in.Address + combineParam["qrcode"] = in.Qrcode var postMap = make(map[string]interface{}, 2) postMap["module_data"] = moduleDataMap From 913b529fa14a208ddf38884115049109fc9b786f Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Tue, 15 Aug 2023 11:59:12 +0800 Subject: [PATCH 05/25] fix --- .../internal/logic/getproducttemplatetagslogic.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/server/product-template-tag/internal/logic/getproducttemplatetagslogic.go b/server/product-template-tag/internal/logic/getproducttemplatetagslogic.go index de9d34da..3653614b 100644 --- a/server/product-template-tag/internal/logic/getproducttemplatetagslogic.go +++ b/server/product-template-tag/internal/logic/getproducttemplatetagslogic.go @@ -1,6 +1,7 @@ package logic import ( + "context" "encoding/json" "errors" "fusenapi/model/gmodel" @@ -8,8 +9,6 @@ import ( "fusenapi/utils/basic" "gorm.io/gorm" - "context" - "fusenapi/server/product-template-tag/internal/svc" "fusenapi/server/product-template-tag/internal/types" @@ -67,9 +66,11 @@ func (l *GetProductTemplateTagsLogic) GetProductTemplateTags(req *types.GetProdu logx.Error(err) return resp.SetStatusWithMessage(basic.CodeJsonErr, "failed to parse user metadata") } - templateTagNameList, ok := metaData["template_tagid"].([]string) - if !ok { - return resp.SetStatusWithMessage(basic.CodeJsonErr, "invalid format of metadata`template_tagid") + var templateTagNameList []string + b, _ := json.Marshal(metaData["template_tagid"]) + if err = json.Unmarshal(b, &templateTagNameList); err != nil { + logx.Error(err) + return resp.SetStatusWithMessage(basic.CodeJsonErr, "invalid format of metadata`s template_tagid") } productTemplateTags, err = l.svcCtx.AllModels.FsProductTemplateTags.GetListByTitles(l.ctx, templateTagNameList, req.Limit, "id DESC") } From fa83f6c17f4d1fecd3eab4d07aa229fc6fcd439a Mon Sep 17 00:00:00 2001 From: Hiven Date: Tue, 15 Aug 2023 11:59:35 +0800 Subject: [PATCH 06/25] =?UTF-8?q?fix:=E9=87=8D=E6=9E=84=E5=90=88=E5=9B=BE?= =?UTF-8?q?=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 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/service/repositories/image_handle.go b/service/repositories/image_handle.go index 02292984..f683df49 100644 --- a/service/repositories/image_handle.go +++ b/service/repositories/image_handle.go @@ -156,7 +156,8 @@ func (l *defaultImageHandle) LogoCombine(ctx context.Context, in *LogoCombineReq ress := string(b) if ress == "Internal Server Error" { - logx.Error(errors.New("BLMService fail Internal Server Error")) + err = errors.New("BLMService fail Internal Server Error") + logx.Error(err) return nil, err } From edf89ea3019a562a6f81b29ca8d0c044d921212c Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Tue, 15 Aug 2023 12:34:41 +0800 Subject: [PATCH 07/25] fix --- server/assistant/assistant.go | 1 - server/assistant/etc/assistant.yaml | 1 + server/backend/backend.go | 1 - server/backend/etc/backend.yaml | 1 + server/base/base.go | 2 +- server/canteen/canteen.go | 2 -- server/canteen/etc/canteen.yaml | 1 + server/data-transfer/data-transfer.go | 1 - server/data-transfer/etc/data-transfer.yaml | 1 + server/home-user-auth/etc/home-user-auth.yaml | 1 + server/home-user-auth/home-user-auth.go | 1 - server/inventory/etc/inventory.yaml | 2 +- server/inventory/inventory.go | 1 - server/map-library/etc/map-library.yaml | 1 + server/map-library/map-library.go | 1 - server/orders/etc/orders.yaml | 1 + server/orders/orders.go | 1 - server/pay/etc/pay.yaml | 1 + server/pay/pay.go | 1 - server/product-model/product-model.go | 1 - server/product-template-tag/etc/product-template-tag.yaml | 1 + server/product-template-tag/product-template-tag.go | 1 - server/product-template/etc/product-template.yaml | 1 + server/product-template/product-template.go | 1 - server/product/etc/product.yaml | 1 + server/render/etc/render.yaml | 1 + server/render/render.go | 1 - server/resource/resource.go | 1 - .../etc/shopping-cart-confirmation.yaml | 1 + server/shopping-cart-confirmation/shopping-cart-confirmation.go | 1 - server/upload/etc/upload.yaml | 1 + server/upload/upload.go | 1 - server/webset/etc/webset.yaml | 1 + server/webset/webset.go | 1 - 34 files changed, 17 insertions(+), 20 deletions(-) diff --git a/server/assistant/assistant.go b/server/assistant/assistant.go index 8ae0cf8e..5ffd00da 100644 --- a/server/assistant/assistant.go +++ b/server/assistant/assistant.go @@ -23,7 +23,6 @@ func main() { var c config.Config conf.MustLoad(*configFile, &c) - c.Timeout = int64(time.Second * 15) server := rest.MustNewServer(c.RestConf, rest.WithCustomCors(auth.FsCors, func(w http.ResponseWriter) { })) defer server.Stop() diff --git a/server/assistant/etc/assistant.yaml b/server/assistant/etc/assistant.yaml index 3804fea1..f65d63af 100644 --- a/server/assistant/etc/assistant.yaml +++ b/server/assistant/etc/assistant.yaml @@ -1,6 +1,7 @@ Name: assistant Host: 0.0.0.0 Port: 9950 +Timeout: 15000 #服务超时时间 SourceMysql: fusentest:XErSYmLELKMnf3Dh@tcp(110.41.19.98:3306)/fusentest Auth: AccessSecret: fusen2023 diff --git a/server/backend/backend.go b/server/backend/backend.go index 83ae4af9..f3f1672f 100644 --- a/server/backend/backend.go +++ b/server/backend/backend.go @@ -22,7 +22,6 @@ func main() { var c config.Config conf.MustLoad(*configFile, &c) - c.Timeout = int64(time.Second * 15) server := rest.MustNewServer(c.RestConf, rest.WithCustomCors(auth.FsCors, func(w http.ResponseWriter) { diff --git a/server/backend/etc/backend.yaml b/server/backend/etc/backend.yaml index 18f08394..f0cdc6c8 100644 --- a/server/backend/etc/backend.yaml +++ b/server/backend/etc/backend.yaml @@ -1,6 +1,7 @@ Name: backend Host: 0.0.0.0 Port: 9901 +Timeout: 15000 #服务超时时间 SourceMysql: fusentest:XErSYmLELKMnf3Dh@tcp(110.41.19.98:3306)/fusentest Auth: AccessSecret: fusen_backend_2023 diff --git a/server/base/base.go b/server/base/base.go index df2962f3..c5880c16 100644 --- a/server/base/base.go +++ b/server/base/base.go @@ -23,7 +23,7 @@ func main() { var c config.Config conf.MustLoad(*configFile, &c) - c.Timeout = int64(time.Second * 15) + server := rest.MustNewServer(c.RestConf, rest.WithCustomCors(auth.FsCors, func(w http.ResponseWriter) { })) defer server.Stop() diff --git a/server/canteen/canteen.go b/server/canteen/canteen.go index 993573fb..774de30e 100644 --- a/server/canteen/canteen.go +++ b/server/canteen/canteen.go @@ -23,8 +23,6 @@ func main() { var c config.Config conf.MustLoad(*configFile, &c) - c.Timeout = int64(time.Second * 15) - c.Timeout = int64(time.Second * 15) server := rest.MustNewServer(c.RestConf, rest.WithCustomCors(auth.FsCors, func(w http.ResponseWriter) { diff --git a/server/canteen/etc/canteen.yaml b/server/canteen/etc/canteen.yaml index 4b363db8..16b26a52 100644 --- a/server/canteen/etc/canteen.yaml +++ b/server/canteen/etc/canteen.yaml @@ -1,6 +1,7 @@ Name: canteen Host: 0.0.0.0 Port: 9902 +Timeout: 15000 #服务超时时间 SourceMysql: fusentest:XErSYmLELKMnf3Dh@tcp(110.41.19.98:3306)/fusentest Auth: AccessSecret: fusen2023 diff --git a/server/data-transfer/data-transfer.go b/server/data-transfer/data-transfer.go index af86ccc2..95147a0d 100644 --- a/server/data-transfer/data-transfer.go +++ b/server/data-transfer/data-transfer.go @@ -21,7 +21,6 @@ func main() { var c config2.Config conf.MustLoad(*configFile, &c) - c.Timeout = int64(time.Second * 15) server := rest.MustNewServer(c.RestConf, rest.WithCustomCors(auth.FsCors, func(w http.ResponseWriter) { diff --git a/server/data-transfer/etc/data-transfer.yaml b/server/data-transfer/etc/data-transfer.yaml index 4a3e767d..758542f8 100644 --- a/server/data-transfer/etc/data-transfer.yaml +++ b/server/data-transfer/etc/data-transfer.yaml @@ -1,6 +1,7 @@ Name: data-transfer Host: 0.0.0.0 Port: 9903 +Timeout: 15000 #服务超时时间 SourceMysql: fusentest:XErSYmLELKMnf3Dh@tcp(110.41.19.98:3306)/fusentest Auth: AccessSecret: fusen2023 diff --git a/server/home-user-auth/etc/home-user-auth.yaml b/server/home-user-auth/etc/home-user-auth.yaml index 31722119..e9a7b8c8 100644 --- a/server/home-user-auth/etc/home-user-auth.yaml +++ b/server/home-user-auth/etc/home-user-auth.yaml @@ -1,6 +1,7 @@ Name: home-user-auth Host: 0.0.0.0 Port: 9904 +Timeout: 15000 #服务超时时间 MainAddress: "http://localhost:9900" SourceMysql: fusentest:XErSYmLELKMnf3Dh@tcp(110.41.19.98:3306)/fusentest diff --git a/server/home-user-auth/home-user-auth.go b/server/home-user-auth/home-user-auth.go index 28598d4f..3ff860d2 100644 --- a/server/home-user-auth/home-user-auth.go +++ b/server/home-user-auth/home-user-auth.go @@ -23,7 +23,6 @@ func main() { var c config.Config conf.MustLoad(*configFile, &c) - c.Timeout = int64(time.Second * 15) server := rest.MustNewServer(c.RestConf, rest.WithCustomCors(auth.FsCors, func(w http.ResponseWriter) { diff --git a/server/inventory/etc/inventory.yaml b/server/inventory/etc/inventory.yaml index 3633f1b0..afd8bfa7 100644 --- a/server/inventory/etc/inventory.yaml +++ b/server/inventory/etc/inventory.yaml @@ -1,7 +1,7 @@ Name: inventory Host: 0.0.0.0 Port: 9905 - +Timeout: 15000 #服务超时时间 SourceMysql: fusentest:XErSYmLELKMnf3Dh@tcp(110.41.19.98:3306)/fusentest Auth: AccessSecret: fusen2023 diff --git a/server/inventory/inventory.go b/server/inventory/inventory.go index f623a627..00645519 100644 --- a/server/inventory/inventory.go +++ b/server/inventory/inventory.go @@ -22,7 +22,6 @@ func main() { var c config.Config conf.MustLoad(*configFile, &c) - c.Timeout = int64(time.Second * 15) server := rest.MustNewServer(c.RestConf, rest.WithCustomCors(auth.FsCors, func(w http.ResponseWriter) { diff --git a/server/map-library/etc/map-library.yaml b/server/map-library/etc/map-library.yaml index 0dc22627..2ab101a4 100644 --- a/server/map-library/etc/map-library.yaml +++ b/server/map-library/etc/map-library.yaml @@ -1,6 +1,7 @@ Name: map-library Host: 0.0.0.0 Port: 9906 +Timeout: 15000 #服务超时时间 SourceMysql: fusentest:XErSYmLELKMnf3Dh@tcp(110.41.19.98:3306)/fusentest Auth: AccessSecret: fusen2023 diff --git a/server/map-library/map-library.go b/server/map-library/map-library.go index 54ee66f6..254f2781 100644 --- a/server/map-library/map-library.go +++ b/server/map-library/map-library.go @@ -22,7 +22,6 @@ func main() { var c config.Config conf.MustLoad(*configFile, &c) - c.Timeout = int64(time.Second * 15) server := rest.MustNewServer(c.RestConf, rest.WithCustomCors(auth.FsCors, func(w http.ResponseWriter) { diff --git a/server/orders/etc/orders.yaml b/server/orders/etc/orders.yaml index 77573dcf..b8bc7a88 100644 --- a/server/orders/etc/orders.yaml +++ b/server/orders/etc/orders.yaml @@ -1,6 +1,7 @@ Name: orders Host: 0.0.0.0 Port: 9907 +Timeout: 15000 #服务超时时间 SourceMysql: fusentest:XErSYmLELKMnf3Dh@tcp(110.41.19.98:3306)/fusentest Auth: AccessSecret: fusen2023 diff --git a/server/orders/orders.go b/server/orders/orders.go index a4707bea..3eda600a 100644 --- a/server/orders/orders.go +++ b/server/orders/orders.go @@ -22,7 +22,6 @@ func main() { var c config.Config conf.MustLoad(*configFile, &c) - c.Timeout = int64(time.Second * 15) server := rest.MustNewServer(c.RestConf, rest.WithCustomCors(auth.FsCors, func(w http.ResponseWriter) { diff --git a/server/pay/etc/pay.yaml b/server/pay/etc/pay.yaml index 831292a9..1d2b1f75 100644 --- a/server/pay/etc/pay.yaml +++ b/server/pay/etc/pay.yaml @@ -1,6 +1,7 @@ Name: pay Host: 0.0.0.0 Port: 9915 +Timeout: 15000 #服务超时时间 SourceMysql: fusentest:XErSYmLELKMnf3Dh@tcp(110.41.19.98:3306)/fusentest Auth: AccessSecret: fusen2023 diff --git a/server/pay/pay.go b/server/pay/pay.go index 08c53e12..610b9d63 100644 --- a/server/pay/pay.go +++ b/server/pay/pay.go @@ -23,7 +23,6 @@ func main() { var c config.Config conf.MustLoad(*configFile, &c) - c.Timeout = int64(time.Second * 15) server := rest.MustNewServer(c.RestConf, rest.WithCustomCors(auth.FsCors, func(w http.ResponseWriter) { })) defer server.Stop() diff --git a/server/product-model/product-model.go b/server/product-model/product-model.go index e0cabc28..adb3846e 100644 --- a/server/product-model/product-model.go +++ b/server/product-model/product-model.go @@ -22,7 +22,6 @@ func main() { var c config.Config conf.MustLoad(*configFile, &c) - c.Timeout = int64(time.Second * 15) server := rest.MustNewServer(c.RestConf, rest.WithCustomCors(auth.FsCors, func(w http.ResponseWriter) { diff --git a/server/product-template-tag/etc/product-template-tag.yaml b/server/product-template-tag/etc/product-template-tag.yaml index 75f4d2d3..af29ff0a 100644 --- a/server/product-template-tag/etc/product-template-tag.yaml +++ b/server/product-template-tag/etc/product-template-tag.yaml @@ -1,6 +1,7 @@ Name: product-template-tag Host: 0.0.0.0 Port: 9917 +Timeout: 15000 #服务超时时间 SourceMysql: fusentest:XErSYmLELKMnf3Dh@tcp(110.41.19.98:3306)/fusentest Auth: AccessSecret: fusen2023 diff --git a/server/product-template-tag/product-template-tag.go b/server/product-template-tag/product-template-tag.go index 18898784..ea3066d4 100644 --- a/server/product-template-tag/product-template-tag.go +++ b/server/product-template-tag/product-template-tag.go @@ -23,7 +23,6 @@ func main() { var c config.Config conf.MustLoad(*configFile, &c) - c.Timeout = int64(time.Second * 15) server := rest.MustNewServer(c.RestConf, rest.WithCustomCors(auth.FsCors, func(w http.ResponseWriter) { })) defer server.Stop() diff --git a/server/product-template/etc/product-template.yaml b/server/product-template/etc/product-template.yaml index 287b4a33..e8700c9c 100644 --- a/server/product-template/etc/product-template.yaml +++ b/server/product-template/etc/product-template.yaml @@ -1,6 +1,7 @@ Name: product-template Host: 0.0.0.0 Port: 9910 +Timeout: 15000 #服务超时时间 SourceMysql: fusentest:XErSYmLELKMnf3Dh@tcp(110.41.19.98:3306)/fusentest Auth: AccessSecret: fusen2023 diff --git a/server/product-template/product-template.go b/server/product-template/product-template.go index 522be699..d189133d 100644 --- a/server/product-template/product-template.go +++ b/server/product-template/product-template.go @@ -22,7 +22,6 @@ func main() { var c config.Config conf.MustLoad(*configFile, &c) - c.Timeout = int64(time.Second * 15) server := rest.MustNewServer(c.RestConf, rest.WithCustomCors(auth.FsCors, func(w http.ResponseWriter) { diff --git a/server/product/etc/product.yaml b/server/product/etc/product.yaml index 658e5411..39181b84 100644 --- a/server/product/etc/product.yaml +++ b/server/product/etc/product.yaml @@ -1,6 +1,7 @@ Name: product Host: 0.0.0.0 Port: 9908 +Timeout: 15000 #服务超时时间 SourceMysql: fusentest:XErSYmLELKMnf3Dh@tcp(110.41.19.98:3306)/fusentest Auth: AccessSecret: fusen2023 diff --git a/server/render/etc/render.yaml b/server/render/etc/render.yaml index a75711b8..ccacf731 100644 --- a/server/render/etc/render.yaml +++ b/server/render/etc/render.yaml @@ -1,6 +1,7 @@ Name: render Host: 0.0.0.0 Port: 9919 +Timeout: 15000 #服务超时时间 SourceMysql: fusentest:XErSYmLELKMnf3Dh@tcp(110.41.19.98:3306)/fusentest Auth: AccessSecret: fusen2023 diff --git a/server/render/render.go b/server/render/render.go index f3cdafef..4088d424 100644 --- a/server/render/render.go +++ b/server/render/render.go @@ -26,7 +26,6 @@ func main() { var c config.Config conf.MustLoad(*configFile, &c) - c.Timeout = int64(time.Second * 15) server := rest.MustNewServer(c.RestConf, rest.WithCustomCors(auth.FsCors, func(w http.ResponseWriter) { })) defer server.Stop() diff --git a/server/resource/resource.go b/server/resource/resource.go index 6a09918b..2841e642 100644 --- a/server/resource/resource.go +++ b/server/resource/resource.go @@ -23,7 +23,6 @@ func main() { var c config.Config conf.MustLoad(*configFile, &c) - c.Timeout = int64(time.Second * 15) server := rest.MustNewServer(c.RestConf, rest.WithCustomCors(auth.FsCors, func(w http.ResponseWriter) { })) defer server.Stop() diff --git a/server/shopping-cart-confirmation/etc/shopping-cart-confirmation.yaml b/server/shopping-cart-confirmation/etc/shopping-cart-confirmation.yaml index fa40bb45..58a74824 100644 --- a/server/shopping-cart-confirmation/etc/shopping-cart-confirmation.yaml +++ b/server/shopping-cart-confirmation/etc/shopping-cart-confirmation.yaml @@ -1,6 +1,7 @@ Name: shopping-cart-confirmation Host: 0.0.0.0 Port: 9911 +Timeout: 15000 #服务超时时间 SourceMysql: fusentest:XErSYmLELKMnf3Dh@tcp(110.41.19.98:3306)/fusentest Auth: AccessSecret: fusen2023 diff --git a/server/shopping-cart-confirmation/shopping-cart-confirmation.go b/server/shopping-cart-confirmation/shopping-cart-confirmation.go index 55f29602..b3d9386e 100644 --- a/server/shopping-cart-confirmation/shopping-cart-confirmation.go +++ b/server/shopping-cart-confirmation/shopping-cart-confirmation.go @@ -22,7 +22,6 @@ func main() { var c config.Config conf.MustLoad(*configFile, &c) - c.Timeout = int64(time.Second * 15) server := rest.MustNewServer(c.RestConf, rest.WithCustomCors(auth.FsCors, func(w http.ResponseWriter) { diff --git a/server/upload/etc/upload.yaml b/server/upload/etc/upload.yaml index 3e1c96f3..9d4ff5a2 100644 --- a/server/upload/etc/upload.yaml +++ b/server/upload/etc/upload.yaml @@ -1,6 +1,7 @@ Name: upload Host: 0.0.0.0 Port: 9912 +Timeout: 15000 #服务超时时间 SourceMysql: "fusentest:XErSYmLELKMnf3Dh@tcp(110.41.19.98:3306)/fusentest" Env: "test" Auth: diff --git a/server/upload/upload.go b/server/upload/upload.go index 603fe25a..2f5ef7f3 100644 --- a/server/upload/upload.go +++ b/server/upload/upload.go @@ -22,7 +22,6 @@ func main() { var c config.Config conf.MustLoad(*configFile, &c) - c.Timeout = int64(time.Second * 15) server := rest.MustNewServer(c.RestConf, rest.WithCustomCors(auth.FsCors, func(w http.ResponseWriter) { diff --git a/server/webset/etc/webset.yaml b/server/webset/etc/webset.yaml index 4d7bb858..828b657b 100644 --- a/server/webset/etc/webset.yaml +++ b/server/webset/etc/webset.yaml @@ -1,6 +1,7 @@ Name: webset Host: 0.0.0.0 Port: 9913 +Timeout: 15000 #服务超时时间 SourceMysql: "fusentest:XErSYmLELKMnf3Dh@tcp(110.41.19.98:3306)/fusentest" Auth: AccessSecret: fusen2023 diff --git a/server/webset/webset.go b/server/webset/webset.go index 0b8d0ea7..069a0e07 100644 --- a/server/webset/webset.go +++ b/server/webset/webset.go @@ -22,7 +22,6 @@ func main() { var c config.Config conf.MustLoad(*configFile, &c) - c.Timeout = int64(time.Second * 15) server := rest.MustNewServer(c.RestConf, rest.WithCustomCors(auth.FsCors, func(w http.ResponseWriter) { From 54568173af99f1559fad3e1ff1767e13a907375c Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Tue, 15 Aug 2023 13:35:23 +0800 Subject: [PATCH 08/25] fix --- server/assistant/assistant.go | 1 - server/backend/backend.go | 1 - server/base/base.go | 1 - server/canteen/canteen.go | 1 - server/data-transfer/data-transfer.go | 1 - server/home-user-auth/home-user-auth.go | 1 - server/inventory/inventory.go | 1 - server/map-library/map-library.go | 1 - server/orders/orders.go | 1 - server/pay/pay.go | 1 - server/product-model/product-model.go | 1 - server/product-template-tag/product-template-tag.go | 1 - server/product-template/product-template.go | 1 - server/product/product.go | 2 -- server/render/render.go | 1 - server/resource/resource.go | 1 - server/shopping-cart-confirmation/shopping-cart-confirmation.go | 1 - server/upload/upload.go | 1 - server/webset/webset.go | 1 - 19 files changed, 20 deletions(-) diff --git a/server/assistant/assistant.go b/server/assistant/assistant.go index 5ffd00da..2d1ab230 100644 --- a/server/assistant/assistant.go +++ b/server/assistant/assistant.go @@ -4,7 +4,6 @@ import ( "flag" "fmt" "net/http" - "time" "fusenapi/utils/auth" diff --git a/server/backend/backend.go b/server/backend/backend.go index f3f1672f..099cb974 100644 --- a/server/backend/backend.go +++ b/server/backend/backend.go @@ -4,7 +4,6 @@ import ( "flag" "fmt" "net/http" - "time" "fusenapi/server/backend/internal/config" "fusenapi/server/backend/internal/handler" diff --git a/server/base/base.go b/server/base/base.go index c5880c16..1d3f1af1 100644 --- a/server/base/base.go +++ b/server/base/base.go @@ -4,7 +4,6 @@ import ( "flag" "fmt" "net/http" - "time" "fusenapi/utils/auth" diff --git a/server/canteen/canteen.go b/server/canteen/canteen.go index 774de30e..eb2e1f27 100644 --- a/server/canteen/canteen.go +++ b/server/canteen/canteen.go @@ -4,7 +4,6 @@ import ( "flag" "fmt" "net/http" - "time" "fusenapi/server/canteen/internal/config" "fusenapi/server/canteen/internal/handler" diff --git a/server/data-transfer/data-transfer.go b/server/data-transfer/data-transfer.go index 95147a0d..8ad3fa67 100644 --- a/server/data-transfer/data-transfer.go +++ b/server/data-transfer/data-transfer.go @@ -8,7 +8,6 @@ import ( svc2 "fusenapi/server/data-transfer/internal/svc" "fusenapi/utils/auth" "net/http" - "time" "github.com/zeromicro/go-zero/core/conf" "github.com/zeromicro/go-zero/rest" diff --git a/server/home-user-auth/home-user-auth.go b/server/home-user-auth/home-user-auth.go index 3ff860d2..911ae5de 100644 --- a/server/home-user-auth/home-user-auth.go +++ b/server/home-user-auth/home-user-auth.go @@ -4,7 +4,6 @@ import ( "flag" "fmt" "net/http" - "time" "fusenapi/server/home-user-auth/internal/config" "fusenapi/server/home-user-auth/internal/handler" diff --git a/server/inventory/inventory.go b/server/inventory/inventory.go index 00645519..10661756 100644 --- a/server/inventory/inventory.go +++ b/server/inventory/inventory.go @@ -4,7 +4,6 @@ import ( "flag" "fmt" "net/http" - "time" "fusenapi/server/inventory/internal/config" "fusenapi/server/inventory/internal/handler" diff --git a/server/map-library/map-library.go b/server/map-library/map-library.go index 254f2781..b8f7e38b 100644 --- a/server/map-library/map-library.go +++ b/server/map-library/map-library.go @@ -4,7 +4,6 @@ import ( "flag" "fmt" "net/http" - "time" "fusenapi/server/map-library/internal/config" "fusenapi/server/map-library/internal/handler" diff --git a/server/orders/orders.go b/server/orders/orders.go index 3eda600a..fc951aa8 100644 --- a/server/orders/orders.go +++ b/server/orders/orders.go @@ -4,7 +4,6 @@ import ( "flag" "fmt" "net/http" - "time" "fusenapi/server/orders/internal/config" "fusenapi/server/orders/internal/handler" diff --git a/server/pay/pay.go b/server/pay/pay.go index 610b9d63..ecfedfef 100644 --- a/server/pay/pay.go +++ b/server/pay/pay.go @@ -4,7 +4,6 @@ import ( "flag" "fmt" "net/http" - "time" "fusenapi/utils/auth" diff --git a/server/product-model/product-model.go b/server/product-model/product-model.go index adb3846e..a6374de1 100644 --- a/server/product-model/product-model.go +++ b/server/product-model/product-model.go @@ -4,7 +4,6 @@ import ( "flag" "fmt" "net/http" - "time" "fusenapi/server/product-model/internal/config" "fusenapi/server/product-model/internal/handler" diff --git a/server/product-template-tag/product-template-tag.go b/server/product-template-tag/product-template-tag.go index ea3066d4..5f1bd6cd 100644 --- a/server/product-template-tag/product-template-tag.go +++ b/server/product-template-tag/product-template-tag.go @@ -4,7 +4,6 @@ import ( "flag" "fmt" "net/http" - "time" "fusenapi/utils/auth" diff --git a/server/product-template/product-template.go b/server/product-template/product-template.go index d189133d..3819752a 100644 --- a/server/product-template/product-template.go +++ b/server/product-template/product-template.go @@ -4,7 +4,6 @@ import ( "flag" "fmt" "net/http" - "time" "fusenapi/server/product-template/internal/config" "fusenapi/server/product-template/internal/handler" diff --git a/server/product/product.go b/server/product/product.go index 6b212bba..13fba403 100644 --- a/server/product/product.go +++ b/server/product/product.go @@ -4,7 +4,6 @@ import ( "flag" "fmt" "net/http" - "time" "fusenapi/server/product/internal/config" "fusenapi/server/product/internal/handler" @@ -22,7 +21,6 @@ func main() { var c config.Config conf.MustLoad(*configFile, &c) - c.Timeout = int64(time.Second * 15) server := rest.MustNewServer(c.RestConf, rest.WithCustomCors(auth.FsCors, func(w http.ResponseWriter) { diff --git a/server/render/render.go b/server/render/render.go index 4088d424..56fc25ee 100644 --- a/server/render/render.go +++ b/server/render/render.go @@ -7,7 +7,6 @@ import ( "fusenapi/constants" "fusenapi/server/render/consumer" "net/http" - "time" "fusenapi/utils/auth" diff --git a/server/resource/resource.go b/server/resource/resource.go index 2841e642..29887332 100644 --- a/server/resource/resource.go +++ b/server/resource/resource.go @@ -4,7 +4,6 @@ import ( "flag" "fmt" "net/http" - "time" "fusenapi/utils/auth" diff --git a/server/shopping-cart-confirmation/shopping-cart-confirmation.go b/server/shopping-cart-confirmation/shopping-cart-confirmation.go index b3d9386e..c5f6711c 100644 --- a/server/shopping-cart-confirmation/shopping-cart-confirmation.go +++ b/server/shopping-cart-confirmation/shopping-cart-confirmation.go @@ -4,7 +4,6 @@ import ( "flag" "fmt" "net/http" - "time" "fusenapi/server/shopping-cart-confirmation/internal/config" "fusenapi/server/shopping-cart-confirmation/internal/handler" diff --git a/server/upload/upload.go b/server/upload/upload.go index 2f5ef7f3..bea4af45 100644 --- a/server/upload/upload.go +++ b/server/upload/upload.go @@ -4,7 +4,6 @@ import ( "flag" "fmt" "net/http" - "time" "fusenapi/server/upload/internal/config" "fusenapi/server/upload/internal/handler" diff --git a/server/webset/webset.go b/server/webset/webset.go index 069a0e07..ab154b3b 100644 --- a/server/webset/webset.go +++ b/server/webset/webset.go @@ -4,7 +4,6 @@ import ( "flag" "fmt" "net/http" - "time" "fusenapi/server/webset/internal/config" "fusenapi/server/webset/internal/handler" From f4e3834d957e0b93ba2891a5b88ed5d5eba6c42d Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Tue, 15 Aug 2023 14:04:44 +0800 Subject: [PATCH 09/25] fix --- constants/websocket.go | 2 -- server/websocket/internal/logic/ws_resume_last_connect.go | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/constants/websocket.go b/constants/websocket.go index ced0c947..03bd63bb 100644 --- a/constants/websocket.go +++ b/constants/websocket.go @@ -12,8 +12,6 @@ const ( WEBSOCKET_REQUEST_RESUME_LAST_CONNECT = "WEBSOCKET_REQUEST_RESUME_LAST_CONNECT" //请求恢复为上次连接的标识错误 WEBSOCKET_REQUEST_RESUME_LAST_CONNECT_ERR = "WEBSOCKET_REQUEST_RESUME_LAST_CONNECT_ERR" - //请求恢复为上次连接的标识成功 - WEBSOCKET_REQUEST_RESUME_LAST_CONNECT_SUCCESS = "WEBSOCKET_REQUEST_RESUME_LAST_CONNECT_SUCCESS" //渲染前数据组装 WEBSOCKET_RENDER_IMAGE_ASSEMBLE = "WEBSOCKET_RENDER_IMAGE_ASSEMBLE" //图片渲染 diff --git a/server/websocket/internal/logic/ws_resume_last_connect.go b/server/websocket/internal/logic/ws_resume_last_connect.go index 39f29414..79934c8b 100644 --- a/server/websocket/internal/logic/ws_resume_last_connect.go +++ b/server/websocket/internal/logic/ws_resume_last_connect.go @@ -21,7 +21,7 @@ func (w *wsConnectItem) resumeLateConnect(data []byte) { } //重新绑定 w.uniqueId = clientId - rsp := w.respondDataFormat(constants.WEBSOCKET_REQUEST_RESUME_LAST_CONNECT_SUCCESS, clientId) + rsp := w.respondDataFormat(constants.WEBSOCKET_CONNECT_SUCCESS, clientId) w.sendToOutChan(rsp) return } From 48cd4b2fea31ddc498dcd567db3682378529223e Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Tue, 15 Aug 2023 14:21:32 +0800 Subject: [PATCH 10/25] fix --- .../internal/logic/ws_render_image_logic.go | 1 - utils/websocket_data/render_data.go | 19 +++++++++---------- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/server/websocket/internal/logic/ws_render_image_logic.go b/server/websocket/internal/logic/ws_render_image_logic.go index 77240ce6..ec254ca7 100644 --- a/server/websocket/internal/logic/ws_render_image_logic.go +++ b/server/websocket/internal/logic/ws_render_image_logic.go @@ -59,7 +59,6 @@ func (w *wsConnectItem) renderImage(data []byte) { renderImageData.RenderData.Logo = "https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/f5ccd11365099fa47a6316b1cd639f6dd6064dcd2d37c8d2fcd0a322160b33cc" } else { renderImageData.RenderData.Logo = *userMaterial.ResourceUrl - renderImageData.RenderData.UserMaterialId = userMaterial.Id } //用户id赋值 renderImageData.RenderData.UserId = w.userId diff --git a/utils/websocket_data/render_data.go b/utils/websocket_data/render_data.go index eaf44eac..4cb3bed6 100644 --- a/utils/websocket_data/render_data.go +++ b/utils/websocket_data/render_data.go @@ -12,16 +12,15 @@ type RenderImageReqMsg struct { RenderData RenderData `json:"render_data"` } type RenderData struct { - TemplateTag string `json:"template_tag"` //模板标签 - ProductId int64 `json:"product_id"` //产品id - UserMaterialId int64 `json:"user_material_id"` //用户素材id - Logo string `json:"logo"` //log资源地址(websocket连接建立再赋值) - Website string `json:"website"` //网站 - Slogan string `json:"slogan"` //slogan - Address string `json:"address"` //地址 - Phone string `json:"phone"` //电话 - UserId int64 `json:"user_id"` //用户id(websocket连接建立再赋值) - GuestId int64 `json:"guest_id"` //游客id(websocket连接建立再赋值) + TemplateTag string `json:"template_tag"` //模板标签 + ProductId int64 `json:"product_id"` //产品id + Logo string `json:"logo"` //log资源地址(websocket连接建立再赋值) + Website string `json:"website"` //网站 + Slogan string `json:"slogan"` //slogan + Address string `json:"address"` //地址 + Phone string `json:"phone"` //电话 + UserId int64 `json:"user_id"` //用户id(websocket连接建立再赋值) + GuestId int64 `json:"guest_id"` //游客id(websocket连接建立再赋值) } // websocket发送渲染完的数据 From a58bd967e92f0b3bde316db91177398fa88c0a63 Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Tue, 15 Aug 2023 14:31:51 +0800 Subject: [PATCH 11/25] fix --- utils/websocket_data/render_data.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/utils/websocket_data/render_data.go b/utils/websocket_data/render_data.go index 4cb3bed6..bb4c82eb 100644 --- a/utils/websocket_data/render_data.go +++ b/utils/websocket_data/render_data.go @@ -12,15 +12,15 @@ type RenderImageReqMsg struct { RenderData RenderData `json:"render_data"` } type RenderData struct { - TemplateTag string `json:"template_tag"` //模板标签 - ProductId int64 `json:"product_id"` //产品id - Logo string `json:"logo"` //log资源地址(websocket连接建立再赋值) - Website string `json:"website"` //网站 - Slogan string `json:"slogan"` //slogan - Address string `json:"address"` //地址 - Phone string `json:"phone"` //电话 + TemplateTag string `json:"template_tag"` //模板标签(必须) + ProductId int64 `json:"product_id"` //产品id(必须) + Website string `json:"website"` //网站(可选) + Slogan string `json:"slogan"` //slogan(可选) + Address string `json:"address"` //地址(可选) + Phone string `json:"phone"` //电话(可选) UserId int64 `json:"user_id"` //用户id(websocket连接建立再赋值) GuestId int64 `json:"guest_id"` //游客id(websocket连接建立再赋值) + Logo string `json:"logo"` //log资源地址(websocket连接建立再赋值) } // websocket发送渲染完的数据 From 98b0765363d547eec4c24798fd0c0ba5c5db6125 Mon Sep 17 00:00:00 2001 From: Hiven Date: Tue, 15 Aug 2023 14:51:54 +0800 Subject: [PATCH 12/25] =?UTF-8?q?fix:=E9=87=8D=E6=9E=84=E5=90=88=E5=9B=BE?= =?UTF-8?q?=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 | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/service/repositories/image_handle.go b/service/repositories/image_handle.go index f683df49..d751b8af 100644 --- a/service/repositories/image_handle.go +++ b/service/repositories/image_handle.go @@ -117,16 +117,28 @@ func (l *defaultImageHandle) LogoCombine(ctx context.Context, in *LogoCombineReq moduleDataMap["materialList"] = materialList // 查询logo最新基础信息 + var metadata *string userMaterialModel := gmodel.NewFsUserMaterialModel(l.MysqlConn) userMaterialInfo, err := userMaterialModel.FindLatestOne(ctx, in.UserId, in.GuestId) if err != nil { - logx.Error(err) - return nil, err + if errors.Is(err, gorm.ErrRecordNotFound) { + userMaterialInfoDefault, err := userMaterialModel.FindOneById(ctx, 0) + if err != nil { + logx.Error(err) + return nil, err + } + metadata = userMaterialInfoDefault.Metadata + } else { + logx.Error(err) + return nil, err + } + } else { + metadata = userMaterialInfo.Metadata } var combineParam map[string]interface{} - json.Unmarshal([]byte(*userMaterialInfo.Metadata), &combineParam) + json.Unmarshal([]byte(*metadata), &combineParam) combineParam["template_tagid"] = in.TemplateTag combineParam["website"] = in.Website combineParam["slogan"] = in.Slogan From a3015e9fddcd301c3c79ffb445fb66734e622281 Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Tue, 15 Aug 2023 15:09:53 +0800 Subject: [PATCH 13/25] fix --- .../render/consumer/assemble_render_data.go | 4 ++-- .../internal/logic/datatransferlogic.go | 2 +- .../internal/logic/ws_render_image_logic.go | 24 +++++++++++++------ 3 files changed, 20 insertions(+), 10 deletions(-) diff --git a/server/render/consumer/assemble_render_data.go b/server/render/consumer/assemble_render_data.go index 5fb67298..89fadf6c 100644 --- a/server/render/consumer/assemble_render_data.go +++ b/server/render/consumer/assemble_render_data.go @@ -49,7 +49,7 @@ func (m *MqConsumerRenderAssemble) Run(ctx context.Context, data []byte) error { } rabbitmq := initalize.RabbitMqHandle{} //获取模板(模板标签下的对一个物料的的模板) - productTemplate, err := svcCtx.AllModels.FsProductTemplateV2.FindOneByProductIdTagIdWithSizeTable(ctx, parseInfo.RenderData.ProductId, parseInfo.RenderData.TemplateTag) + productTemplate, err := svcCtx.AllModels.FsProductTemplateV2.FindOneByProductIdTagIdWithSizeTable(ctx, parseInfo.RenderData.ProductId, "8" /*parseInfo.RenderData.TemplateTag*/) if err != nil { if errors.Is(err, gorm.ErrRecordNotFound) { logx.Error("template info is not found") @@ -80,7 +80,7 @@ func (m *MqConsumerRenderAssemble) Run(ctx context.Context, data []byte) error { logx.Error("合成刀版图失败,合成的刀版图是空指针:", err) return nil } - logx.Info("合成刀版图成功") + logx.Info("合成刀版图成功:", *res.ResourceUrl) //获取渲染设置信息 element, err := svcCtx.AllModels.FsProductTemplateElement.FindOneByModelId(ctx, *productTemplate.ModelId) if err != nil { diff --git a/server/websocket/internal/logic/datatransferlogic.go b/server/websocket/internal/logic/datatransferlogic.go index 16f822aa..c4961ac0 100644 --- a/server/websocket/internal/logic/datatransferlogic.go +++ b/server/websocket/internal/logic/datatransferlogic.go @@ -303,7 +303,7 @@ func (w *wsConnectItem) dealwithReciveData(data []byte) { var parseInfo websocket_data.DataTransferData if err := json.Unmarshal(data, &parseInfo); err != nil { logx.Error("invalid format of websocket message") - w.outChan <- w.respondDataFormat(constants.WEBSOCKET_ERR_DATA_FORMAT, "invalid format of websocket message:"+string(data)) + w.sendToOutChan(w.respondDataFormat(constants.WEBSOCKET_ERR_DATA_FORMAT, "invalid format of websocket message:"+string(data))) return } d, _ := json.Marshal(parseInfo.D) diff --git a/server/websocket/internal/logic/ws_render_image_logic.go b/server/websocket/internal/logic/ws_render_image_logic.go index ec254ca7..2bb61fe7 100644 --- a/server/websocket/internal/logic/ws_render_image_logic.go +++ b/server/websocket/internal/logic/ws_render_image_logic.go @@ -27,23 +27,23 @@ type renderImageControlChanItem struct { func (w *wsConnectItem) renderImage(data []byte) { var renderImageData websocket_data.RenderImageReqMsg if err := json.Unmarshal(data, &renderImageData); err != nil { - w.outChan <- w.respondDataFormat(constants.WEBSOCKET_ERR_DATA_FORMAT, "invalid format of websocket render image message:"+string(data)) + w.sendToOutChan(w.respondDataFormat(constants.WEBSOCKET_ERR_DATA_FORMAT, "invalid format of websocket render image message:"+string(data))) logx.Error("invalid format of websocket render image message", err) return } logx.Info("收到请求云渲染图片数据:", renderImageData) if renderImageData.RenderId == "" { - w.outChan <- w.respondDataFormat(constants.WEBSOCKET_ERR_DATA_FORMAT, "invalid format of websocket render image message:render_id is empty") + w.sendToOutChan(w.respondDataFormat(constants.WEBSOCKET_ERR_DATA_FORMAT, "invalid format of websocket render image message:render_id is empty")) logx.Error("invalid format of websocket render image message:render_id is empty") return } if renderImageData.RenderData.ProductId <= 0 { - w.outChan <- w.respondDataFormat(constants.WEBSOCKET_ERR_DATA_FORMAT, "invalid format of websocket render image message:product_id ") + w.sendToOutChan(w.respondDataFormat(constants.WEBSOCKET_ERR_DATA_FORMAT, "invalid format of websocket render image message:product_id ")) logx.Error("invalid format of websocket render image message:product_id") return } if renderImageData.RenderData.TemplateTag == "" { - w.outChan <- w.respondDataFormat(constants.WEBSOCKET_ERR_DATA_FORMAT, "invalid format of websocket render image message:template_tag ") + w.sendToOutChan(w.respondDataFormat(constants.WEBSOCKET_ERR_DATA_FORMAT, "invalid format of websocket render image message:template_tag ")) logx.Error("invalid format of websocket render image message:template_tag") return } @@ -51,12 +51,22 @@ func (w *wsConnectItem) renderImage(data []byte) { userMaterial, err := w.allModels.FsUserMaterial.FindLatestOne(w.ctx, w.userId, w.guestId) if err != nil { if !errors.Is(err, gorm.ErrRecordNotFound) { - w.outChan <- w.respondDataFormat(constants.WEBSOCKET_ERR_DATA_FORMAT, "failed to get user logo") + w.sendToOutChan(w.respondDataFormat(constants.WEBSOCKET_ERR_DATA_FORMAT, "failed to get user logo")) logx.Error("failed to get user logo") return } - //使用默认logo(写死一个默认) - renderImageData.RenderData.Logo = "https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/f5ccd11365099fa47a6316b1cd639f6dd6064dcd2d37c8d2fcd0a322160b33cc" + //使用默认logo(id=0) + userMaterialDefault, err := w.allModels.FsUserMaterial.FindOneById(w.ctx, 0) + if err != nil { + if errors.Is(err, gorm.ErrRecordNotFound) { + w.sendToOutChan(w.respondDataFormat(constants.WEBSOCKET_ERR_DATA_FORMAT, "default logo is not exists")) + return + } + logx.Error("default logo is not exists") + w.sendToOutChan(w.respondDataFormat(constants.WEBSOCKET_ERR_DATA_FORMAT, "failed to get default logo")) + return + } + renderImageData.RenderData.Logo = *userMaterialDefault.ResourceUrl } else { renderImageData.RenderData.Logo = *userMaterial.ResourceUrl } From c9dfec717cbd89a0a73d768bafb5d085de9ae6b8 Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Tue, 15 Aug 2023 15:47:39 +0800 Subject: [PATCH 14/25] fix --- model/gmodel/fs_product_template_tags_logic.go | 10 +++++++--- .../internal/logic/getproducttemplatetagslogic.go | 2 +- server/render/consumer/assemble_render_data.go | 13 ++++++++++++- 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/model/gmodel/fs_product_template_tags_logic.go b/model/gmodel/fs_product_template_tags_logic.go index 5ef7e6ae..96d4cca2 100755 --- a/model/gmodel/fs_product_template_tags_logic.go +++ b/model/gmodel/fs_product_template_tags_logic.go @@ -32,14 +32,18 @@ func (pt *FsProductTemplateTagsModel) GetList(ctx context.Context, page, limit i err = db.Offset(offset).Limit(limit).Find(&resp).Error return resp, err } -func (pt *FsProductTemplateTagsModel) GetListByTitles(ctx context.Context, titles []string, limit int, orderBy string) (resp []FsProductTemplateTags, err error) { - if len(titles) == 0 { +func (pt *FsProductTemplateTagsModel) GetListByTagNames(ctx context.Context, tagNames []string, limit int, orderBy string) (resp []FsProductTemplateTags, err error) { + if len(tagNames) == 0 { return nil, nil } - db := pt.db.WithContext(ctx).Model(&FsProductTemplateTags{}).Where("`title` in (?) and `status` = ?", titles, 1) + db := pt.db.WithContext(ctx).Model(&FsProductTemplateTags{}).Where("`title` in (?) and `status` = ?", tagNames, 1) if orderBy != "" { db = db.Order(orderBy) } err = db.Limit(limit).Find(&resp).Error return resp, err } +func (pt *FsProductTemplateTagsModel) FindOneByTagName(ctx context.Context, tagName string) (resp *FsProductTemplateTags, err error) { + err = pt.db.WithContext(ctx).Model(&FsProductTemplateTags{}).Where("`title` = ? and `status` = ?", tagName, 1).Take(&resp).Error + return resp, err +} diff --git a/server/product-template-tag/internal/logic/getproducttemplatetagslogic.go b/server/product-template-tag/internal/logic/getproducttemplatetagslogic.go index 3653614b..d0c8377f 100644 --- a/server/product-template-tag/internal/logic/getproducttemplatetagslogic.go +++ b/server/product-template-tag/internal/logic/getproducttemplatetagslogic.go @@ -72,7 +72,7 @@ func (l *GetProductTemplateTagsLogic) GetProductTemplateTags(req *types.GetProdu logx.Error(err) return resp.SetStatusWithMessage(basic.CodeJsonErr, "invalid format of metadata`s template_tagid") } - productTemplateTags, err = l.svcCtx.AllModels.FsProductTemplateTags.GetListByTitles(l.ctx, templateTagNameList, req.Limit, "id DESC") + productTemplateTags, err = l.svcCtx.AllModels.FsProductTemplateTags.GetListByTagNames(l.ctx, templateTagNameList, req.Limit, "id DESC") } } if err != nil { diff --git a/server/render/consumer/assemble_render_data.go b/server/render/consumer/assemble_render_data.go index 89fadf6c..96e6a38f 100644 --- a/server/render/consumer/assemble_render_data.go +++ b/server/render/consumer/assemble_render_data.go @@ -4,6 +4,7 @@ import ( "context" "encoding/json" "errors" + "fmt" "fusenapi/constants" "fusenapi/initalize" "fusenapi/server/render/internal/svc" @@ -48,8 +49,18 @@ func (m *MqConsumerRenderAssemble) Run(ctx context.Context, data []byte) error { return nil //不返回错误就删除消息 } rabbitmq := initalize.RabbitMqHandle{} + //根据templateTag获取templateTagId(后续模板表的tag改成template_tag后可能就不需要这个步骤了) + templateTag, err := svcCtx.AllModels.FsProductTemplateTags.FindOneByTagName(ctx, parseInfo.RenderData.TemplateTag) + if err != nil { + if errors.Is(err, gorm.ErrRecordNotFound) { + logx.Error("can`t find template tag info by template tag:", parseInfo.RenderData.TemplateTag) + return nil + } + logx.Error("failed to get template tag info") + return nil + } //获取模板(模板标签下的对一个物料的的模板) - productTemplate, err := svcCtx.AllModels.FsProductTemplateV2.FindOneByProductIdTagIdWithSizeTable(ctx, parseInfo.RenderData.ProductId, "8" /*parseInfo.RenderData.TemplateTag*/) + productTemplate, err := svcCtx.AllModels.FsProductTemplateV2.FindOneByProductIdTagIdWithSizeTable(ctx, parseInfo.RenderData.ProductId, fmt.Sprintf("%d", templateTag.Id)) if err != nil { if errors.Is(err, gorm.ErrRecordNotFound) { logx.Error("template info is not found") From 10b4b6656f0f396c2e9bdba2b0ecd3a38d0fd143 Mon Sep 17 00:00:00 2001 From: Hiven Date: Tue, 15 Aug 2023 16:14:12 +0800 Subject: [PATCH 15/25] =?UTF-8?q?fix:=E9=87=8D=E6=9E=84=E5=90=88=E5=9B=BE?= =?UTF-8?q?=E6=A8=A1=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/resource/etc/resource.yaml | 4 ++-- server/upload/etc/upload.yaml | 4 ++-- .../internal/logic/uploadfilebackendlogic.go | 24 ++++++++----------- 3 files changed, 14 insertions(+), 18 deletions(-) diff --git a/server/resource/etc/resource.yaml b/server/resource/etc/resource.yaml index 2b9f5737..a279336e 100644 --- a/server/resource/etc/resource.yaml +++ b/server/resource/etc/resource.yaml @@ -15,8 +15,8 @@ AWS: Secret: sjCEv0JxATnPCxno2KNLm0X8oDc7srUR+4vkYhvm Token: BLMService: - Url: "http://18.119.109.254:8999" - # Url: "http://192.168.1.7:8999" + # Url: "http://18.119.109.254:8999" + Url: "http://192.168.1.7:8999" LogoCombine: #Url: "http://192.168.1.7:8999/LogoCombine" Url: "http://18.119.109.254:8999/LogoCombine" \ No newline at end of file diff --git a/server/upload/etc/upload.yaml b/server/upload/etc/upload.yaml index 9d4ff5a2..2876ff61 100644 --- a/server/upload/etc/upload.yaml +++ b/server/upload/etc/upload.yaml @@ -16,5 +16,5 @@ AWS: Token: BLMService: ImageProcess: - #Url: "http://192.168.1.7:45678/FeatureExtraction" - Url: "http://18.119.109.254:8999/FeatureExtraction" + Url: "http://192.168.1.7:8999/FeatureExtraction" + # Url: "http://18.119.109.254:8999/FeatureExtraction" diff --git a/server/upload/internal/logic/uploadfilebackendlogic.go b/server/upload/internal/logic/uploadfilebackendlogic.go index 32a577c8..0422de8f 100644 --- a/server/upload/internal/logic/uploadfilebackendlogic.go +++ b/server/upload/internal/logic/uploadfilebackendlogic.go @@ -44,22 +44,18 @@ func NewUploadFileBackendLogic(r *http.Request, svcCtx *svc.ServiceContext) *Upl func (l *UploadFileBackendLogic) UploadFileBackend(req *types.UploadFileBackendReq, userinfo *auth.UserInfo) (resp *basic.Response) { // 返回值必须调用Set重新返回, resp可以空指针调用 resp.SetStatus(basic.CodeOK, data) // userinfo 传入值时, 一定不为null - if userinfo.IsOnlooker() { - // 如果是,返回未授权的错误码 - return resp.SetStatus(basic.CodeUnAuth) - } - - // 定义用户ID和S3键名格式 - var userId int64 - var guestId int64 + var userId int64 = 0 + var guestId int64 = 0 // 检查用户是否是游客 - if userinfo.IsGuest() { - // 如果是,使用游客ID和游客键名格式 - guestId = userinfo.GuestId - } else { - // 否则,使用用户ID和用户键名格式 - userId = userinfo.UserId + if userinfo != nil { + if userinfo.IsGuest() { + // 如果是,使用游客ID和游客键名格式 + guestId = userinfo.GuestId + } else { + // 否则,使用用户ID和用户键名格式 + userId = userinfo.UserId + } } //设置内存大小 From ee92561769e6993f9295f59809cc674503bba29e Mon Sep 17 00:00:00 2001 From: Hiven Date: Tue, 15 Aug 2023 16:14:49 +0800 Subject: [PATCH 16/25] =?UTF-8?q?fix:=E9=87=8D=E6=9E=84=E5=90=88=E5=9B=BE?= =?UTF-8?q?=E6=A8=A1=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/resource/etc/resource.yaml | 4 ++-- server/upload/etc/upload.yaml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/server/resource/etc/resource.yaml b/server/resource/etc/resource.yaml index a279336e..2b9f5737 100644 --- a/server/resource/etc/resource.yaml +++ b/server/resource/etc/resource.yaml @@ -15,8 +15,8 @@ AWS: Secret: sjCEv0JxATnPCxno2KNLm0X8oDc7srUR+4vkYhvm Token: BLMService: - # Url: "http://18.119.109.254:8999" - Url: "http://192.168.1.7:8999" + Url: "http://18.119.109.254:8999" + # Url: "http://192.168.1.7:8999" LogoCombine: #Url: "http://192.168.1.7:8999/LogoCombine" Url: "http://18.119.109.254:8999/LogoCombine" \ No newline at end of file diff --git a/server/upload/etc/upload.yaml b/server/upload/etc/upload.yaml index 2876ff61..12b42062 100644 --- a/server/upload/etc/upload.yaml +++ b/server/upload/etc/upload.yaml @@ -16,5 +16,5 @@ AWS: Token: BLMService: ImageProcess: - Url: "http://192.168.1.7:8999/FeatureExtraction" - # Url: "http://18.119.109.254:8999/FeatureExtraction" + # Url: "http://192.168.1.7:8999/FeatureExtraction" + Url: "http://18.119.109.254:8999/FeatureExtraction" From c4dc31493a1ce4e95a8feb0098bad3efa65d8294 Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Tue, 15 Aug 2023 16:50:35 +0800 Subject: [PATCH 17/25] fix --- server/render/internal/types/types.go | 6 +++--- server_api/render.api | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/server/render/internal/types/types.go b/server/render/internal/types/types.go index 959af2ce..76eff7d4 100644 --- a/server/render/internal/types/types.go +++ b/server/render/internal/types/types.go @@ -12,9 +12,9 @@ type RequestReadImages struct { } type RenderNotifyReq struct { - Sign string `json:"sign"` - Time int64 `json:"time"` - Info NotifyInfo `json:"info"` + Sign string `json:"sign"` + RequestTime string `json:"request_time"` + Info NotifyInfo `json:"info"` } type NotifyInfo struct { diff --git a/server_api/render.api b/server_api/render.api index 1fdfa90a..9e2231aa 100644 --- a/server_api/render.api +++ b/server_api/render.api @@ -26,9 +26,9 @@ service render { //渲染完了通知接口 type RenderNotifyReq { - Sign string `json:"sign"` - Time int64 `json:"time"` - Info NotifyInfo `json:"info"` + Sign string `json:"sign"` + RequestTime string `json:"request_time"` + Info NotifyInfo `json:"info"` } type NotifyInfo { TaskId string `json:"task_id"` //任务id From 35cb2ef1ce310a773e4a7a19ca4295361fbfe4f4 Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Tue, 15 Aug 2023 17:10:43 +0800 Subject: [PATCH 18/25] fix --- .../internal/logic/rendernotifylogic.go | 35 ++++++------------- server/render/internal/types/types.go | 6 ---- server_api/render.api | 5 --- 3 files changed, 10 insertions(+), 36 deletions(-) diff --git a/server/render/internal/logic/rendernotifylogic.go b/server/render/internal/logic/rendernotifylogic.go index 6a11f4bf..c49da008 100644 --- a/server/render/internal/logic/rendernotifylogic.go +++ b/server/render/internal/logic/rendernotifylogic.go @@ -39,30 +39,15 @@ func NewRenderNotifyLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Rend // } func (l *RenderNotifyLogic) RenderNotify(req *types.RenderNotifyReq, userinfo *auth.UserInfo) (resp *basic.Response) { - /*if time.Now().Unix()-120 > req.Time || req.Time > time.Now().Unix() { - return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "invalid param time") - }*/ - if req.Info.TaskId == "" { + if req.TaskId == "" { return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "invalid param task_id") } - if req.Info.Image == "" { + if req.Image == "" { return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "invalid param image") } - if req.Info.UserId == 0 && req.Info.GuestId == 0 { + if req.UserId == 0 && req.GuestId == 0 { return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "invalid user_id or guest_id") } - /* if req.Sign == "" { - return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "invalid param sign") - }*/ - //验证签名 sha256 - /*notifyByte, _ := json.Marshal(req.Info) - h := sha256.New() - h.Write([]byte(fmt.Sprintf(constants.RENDER_NOTIFY_SIGN_KEY, string(notifyByte), req.Time))) - signHex := h.Sum(nil) - sign := hex.EncodeToString(signHex) - if req.Sign != sign { - return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "invalid sign") - }*/ // 上传文件 var upload = file.Upload{ Ctx: l.ctx, @@ -70,12 +55,12 @@ func (l *RenderNotifyLogic) RenderNotify(req *types.RenderNotifyReq, userinfo *a AwsSession: l.svcCtx.AwsSession, } uploadRes, err := upload.UploadFileByBase64(&file.UploadBaseReq{ - FileHash: req.Info.TaskId, - FileData: req.Info.Image, + FileHash: req.TaskId, + FileData: req.Image, UploadBucket: 1, ApiType: 2, - UserId: req.Info.UserId, - GuestId: req.Info.GuestId, + UserId: req.UserId, + GuestId: req.GuestId, }) if err != nil { logx.Error(err) @@ -83,13 +68,13 @@ func (l *RenderNotifyLogic) RenderNotify(req *types.RenderNotifyReq, userinfo *a } //发送消息到对应的rabbitmq data := websocket_data.RenderImageNotify{ - TaskId: req.Info.TaskId, + TaskId: req.TaskId, Image: uploadRes.ResourceUrl, } d, _ := json.Marshal(data) if err = l.svcCtx.RabbitMq.SendMsg(constants.RABBIT_MQ_RENDER_RESULT_DATA, d); err != nil { logx.Error(err) - return resp.SetStatus(basic.CodeServiceErr, "failed to send data") + return resp.SetStatusWithMessage(basic.CodeServiceErr, "failed to send data") } - return resp.SetStatus(basic.CodeOK) + return resp.SetStatusWithMessage(basic.CodeOK, "success") } diff --git a/server/render/internal/types/types.go b/server/render/internal/types/types.go index 76eff7d4..ef9aad74 100644 --- a/server/render/internal/types/types.go +++ b/server/render/internal/types/types.go @@ -12,12 +12,6 @@ type RequestReadImages struct { } type RenderNotifyReq struct { - Sign string `json:"sign"` - RequestTime string `json:"request_time"` - Info NotifyInfo `json:"info"` -} - -type NotifyInfo struct { TaskId string `json:"task_id"` //任务id UserId int64 `json:"user_id"` GuestId int64 `json:"guest_id"` diff --git a/server_api/render.api b/server_api/render.api index 9e2231aa..2a717984 100644 --- a/server_api/render.api +++ b/server_api/render.api @@ -26,11 +26,6 @@ service render { //渲染完了通知接口 type RenderNotifyReq { - Sign string `json:"sign"` - RequestTime string `json:"request_time"` - Info NotifyInfo `json:"info"` -} -type NotifyInfo { TaskId string `json:"task_id"` //任务id UserId int64 `json:"user_id"` GuestId int64 `json:"guest_id"` From cebd92becd048b800927ee1c3e89f2b32957031b Mon Sep 17 00:00:00 2001 From: Hiven Date: Tue, 15 Aug 2023 17:19:05 +0800 Subject: [PATCH 19/25] =?UTF-8?q?fix:=E9=87=8D=E6=9E=84=E5=90=88=E5=9B=BE?= =?UTF-8?q?=E6=A8=A1=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/upload/internal/logic/uploadfilebackendlogic.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/server/upload/internal/logic/uploadfilebackendlogic.go b/server/upload/internal/logic/uploadfilebackendlogic.go index 0422de8f..3864c3a4 100644 --- a/server/upload/internal/logic/uploadfilebackendlogic.go +++ b/server/upload/internal/logic/uploadfilebackendlogic.go @@ -1,6 +1,7 @@ package logic import ( + "fmt" "fusenapi/utils/auth" "fusenapi/utils/basic" "fusenapi/utils/file" @@ -62,6 +63,7 @@ func (l *UploadFileBackendLogic) UploadFileBackend(req *types.UploadFileBackendR l.r.ParseMultipartForm(32 << 20) fileObject, _, err := l.r.FormFile("file") + fmt.Printf("%#v", fileObject) if err != nil { logx.Error(err) return resp.SetStatus(basic.CodeFileUploadErr, "file upload err,no files") From 8d0a675dd908927121102e54ce7ad76357614589 Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Tue, 15 Aug 2023 17:36:17 +0800 Subject: [PATCH 20/25] fix --- server/websocket/internal/logic/ws_render_image_logic.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/websocket/internal/logic/ws_render_image_logic.go b/server/websocket/internal/logic/ws_render_image_logic.go index 2bb61fe7..0d23615e 100644 --- a/server/websocket/internal/logic/ws_render_image_logic.go +++ b/server/websocket/internal/logic/ws_render_image_logic.go @@ -107,7 +107,7 @@ func (w *wsConnectItem) renderImage(data []byte) { } d, _ := json.Marshal(tmpData) //发送给对应的流水线组装数据 - if err := w.rabbitMq.SendMsg(constants.RABBIT_MQ_ASSEMBLE_RENDER_DATA, d); err != nil { + if err = w.rabbitMq.SendMsg(constants.RABBIT_MQ_ASSEMBLE_RENDER_DATA, d); err != nil { logx.Error("发送渲染任务数据到MQ失败:", string(d), "err:", err) return } From 6502f241abb8d6b6c0ab023c40cd082f21ec4536 Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Tue, 15 Aug 2023 17:40:27 +0800 Subject: [PATCH 21/25] fix --- server/websocket/internal/logic/datatransferlogic.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/server/websocket/internal/logic/datatransferlogic.go b/server/websocket/internal/logic/datatransferlogic.go index c4961ac0..5bb6710b 100644 --- a/server/websocket/internal/logic/datatransferlogic.go +++ b/server/websocket/internal/logic/datatransferlogic.go @@ -284,7 +284,9 @@ func (w *wsConnectItem) sendToOutChan(data []byte) { case <-w.closeChan: return case w.outChan <- data: - logx.Info("notify send render result to out chan") + return + case <-time.After(time.Second * 3): //阻塞超过3秒丢弃 + return } } From d603cacd0b9319701a372fca658a44c6f8f716a4 Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Tue, 15 Aug 2023 18:14:44 +0800 Subject: [PATCH 22/25] fix --- constants/websocket.go | 2 +- .../internal/logic/datatransferlogic.go | 9 +++-- .../internal/logic/ws_resume_last_connect.go | 27 -------------- .../internal/logic/ws_reuse_last_connect.go | 36 +++++++++++++++++++ 4 files changed, 41 insertions(+), 33 deletions(-) delete mode 100644 server/websocket/internal/logic/ws_resume_last_connect.go create mode 100644 server/websocket/internal/logic/ws_reuse_last_connect.go diff --git a/constants/websocket.go b/constants/websocket.go index 03bd63bb..8a4a065c 100644 --- a/constants/websocket.go +++ b/constants/websocket.go @@ -9,7 +9,7 @@ const ( //ws连接成功 WEBSOCKET_CONNECT_SUCCESS = "WEBSOCKET_CONNECT_SUCCESS" //请求恢复为上次连接的标识 - WEBSOCKET_REQUEST_RESUME_LAST_CONNECT = "WEBSOCKET_REQUEST_RESUME_LAST_CONNECT" + WEBSOCKET_REQUEST_REUSE_LAST_CONNECT = "WEBSOCKET_REQUEST_REUSE_LAST_CONNECT" //请求恢复为上次连接的标识错误 WEBSOCKET_REQUEST_RESUME_LAST_CONNECT_ERR = "WEBSOCKET_REQUEST_RESUME_LAST_CONNECT_ERR" //渲染前数据组装 diff --git a/server/websocket/internal/logic/datatransferlogic.go b/server/websocket/internal/logic/datatransferlogic.go index 5bb6710b..1c1b05dd 100644 --- a/server/websocket/internal/logic/datatransferlogic.go +++ b/server/websocket/internal/logic/datatransferlogic.go @@ -154,8 +154,7 @@ func (l *DataTransferLogic) setConnPool(conn *websocket.Conn, userInfo auth.User go func() { //把连接成功消息发回去 time.Sleep(time.Second * 2) //兼容下火狐 - b := ws.respondDataFormat(constants.WEBSOCKET_CONNECT_SUCCESS, uniqueId) - _ = conn.WriteMessage(websocket.TextMessage, b) + ws.sendToOutChan(ws.respondDataFormat(constants.WEBSOCKET_CONNECT_SUCCESS, uniqueId)) }() return ws } @@ -304,7 +303,7 @@ func (w *wsConnectItem) respondDataFormat(msgType string, data interface{}) []by func (w *wsConnectItem) dealwithReciveData(data []byte) { var parseInfo websocket_data.DataTransferData if err := json.Unmarshal(data, &parseInfo); err != nil { - logx.Error("invalid format of websocket message") + logx.Error("invalid format of websocket message:", err) w.sendToOutChan(w.respondDataFormat(constants.WEBSOCKET_ERR_DATA_FORMAT, "invalid format of websocket message:"+string(data))) return } @@ -315,8 +314,8 @@ func (w *wsConnectItem) dealwithReciveData(data []byte) { case constants.WEBSOCKET_RENDER_IMAGE: w.renderImage(d) //刷新重连请求恢复上次连接的标识 - case constants.WEBSOCKET_REQUEST_RESUME_LAST_CONNECT: - w.resumeLateConnect(d) + case constants.WEBSOCKET_REQUEST_REUSE_LAST_CONNECT: + w.reuseLastConnect(d) default: } diff --git a/server/websocket/internal/logic/ws_resume_last_connect.go b/server/websocket/internal/logic/ws_resume_last_connect.go deleted file mode 100644 index 79934c8b..00000000 --- a/server/websocket/internal/logic/ws_resume_last_connect.go +++ /dev/null @@ -1,27 +0,0 @@ -package logic - -import "fusenapi/constants" - -// 刷新重连请求恢复上次连接的标识 -func (w *wsConnectItem) resumeLateConnect(data []byte) { - clientId := string(data) - //id长度不对 - if len(clientId) != 50 { - rsp := w.respondDataFormat(constants.WEBSOCKET_REQUEST_RESUME_LAST_CONNECT_ERR, "request id is invalid") - w.sendToOutChan(rsp) - return - } - publicMutex.Lock() - defer publicMutex.Unlock() - //存在是不能给他申请重新绑定 - if _, ok := mapConnPool.Load(clientId); ok { - rsp := w.respondDataFormat(constants.WEBSOCKET_REQUEST_RESUME_LAST_CONNECT_ERR, "id has bound by other connect ") - w.sendToOutChan(rsp) - return - } - //重新绑定 - w.uniqueId = clientId - rsp := w.respondDataFormat(constants.WEBSOCKET_CONNECT_SUCCESS, clientId) - w.sendToOutChan(rsp) - return -} diff --git a/server/websocket/internal/logic/ws_reuse_last_connect.go b/server/websocket/internal/logic/ws_reuse_last_connect.go new file mode 100644 index 00000000..325bb292 --- /dev/null +++ b/server/websocket/internal/logic/ws_reuse_last_connect.go @@ -0,0 +1,36 @@ +package logic + +import ( + "encoding/json" + "fusenapi/constants" + "github.com/zeromicro/go-zero/core/logx" +) + +// 刷新重连请求恢复上次连接的标识 +func (w *wsConnectItem) reuseLastConnect(data []byte) { + logx.Info("收到请求恢复上次连接标识数据:", string(data)) + var clientId string + if err := json.Unmarshal(data, &clientId); err != nil { + logx.Error(" invalid format of client id :", clientId) + w.sendToOutChan(w.respondDataFormat(constants.WEBSOCKET_REQUEST_RESUME_LAST_CONNECT_ERR, "invalid format of client id")) + return + } + //id长度不对 + if len(clientId) > 100 { + w.sendToOutChan(w.respondDataFormat(constants.WEBSOCKET_REQUEST_RESUME_LAST_CONNECT_ERR, "length of client id is to long")) + return + } + publicMutex.Lock() + defer publicMutex.Unlock() + //存在是不能给他申请重新绑定 + if _, ok := mapConnPool.Load(clientId); ok { + rsp := w.respondDataFormat(constants.WEBSOCKET_REQUEST_RESUME_LAST_CONNECT_ERR, "id has bound by other connect ") + w.sendToOutChan(rsp) + return + } + //重新绑定 + w.uniqueId = clientId + rsp := w.respondDataFormat(constants.WEBSOCKET_CONNECT_SUCCESS, clientId) + w.sendToOutChan(rsp) + return +} From 69f08415fce78bce8c977e1510bdcf699c9f5356 Mon Sep 17 00:00:00 2001 From: Hiven Date: Tue, 15 Aug 2023 18:35:16 +0800 Subject: [PATCH 23/25] =?UTF-8?q?fix:=E9=87=8D=E6=9E=84=E5=90=88=E5=9B=BE?= =?UTF-8?q?=E6=A8=A1=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../upload/internal/logic/uploadlogologic.go | 47 +++++++++++++++++-- service/repositories/image_handle.go | 28 +++++++++-- utils/basic/basic.go | 7 +-- 3 files changed, 70 insertions(+), 12 deletions(-) diff --git a/server/upload/internal/logic/uploadlogologic.go b/server/upload/internal/logic/uploadlogologic.go index 88744393..1c51eb22 100644 --- a/server/upload/internal/logic/uploadlogologic.go +++ b/server/upload/internal/logic/uploadlogologic.go @@ -2,6 +2,7 @@ package logic import ( "encoding/json" + "errors" "fusenapi/model/gmodel" "fusenapi/utils/auth" "fusenapi/utils/basic" @@ -69,11 +70,29 @@ func (l *UploadLogoLogic) UploadLogo(req *types.UploadLogoReq, userinfo *auth.Us //设置内存大小 l.r.ParseMultipartForm(32 << 20) - fileObject, _, err := l.r.FormFile("file") + fileObject, fileHeader, err := l.r.FormFile("file") if err != nil { logx.Error(err) return resp.SetStatus(basic.CodeFileUploadErr, "file upload err,no files") } + defer fileObject.Close() + + // 获取文件的MIME类型 + fileType := fileHeader.Header.Get("Content-Type") + var imageTypes = make(map[string]struct{}, 7) + imageTypes["image/jpg"] = struct{}{} + imageTypes["image/jpeg"] = struct{}{} + imageTypes["image/png"] = struct{}{} + imageTypes["image/gif"] = struct{}{} + imageTypes["image/bmp"] = struct{}{} + imageTypes["image/tiff"] = struct{}{} + imageTypes["image/webp"] = struct{}{} + imageTypes["image/svg+xml"] = struct{}{} + // 判断文件类型是否为图片 + _, ok := imageTypes[fileType] + if !ok { + return resp.SetStatus(basic.CodeFileUploadErr, "file upload err,file is not image") + } // 读取数据流 ioData, err := io.ReadAll(fileObject) @@ -143,10 +162,30 @@ func (l *UploadLogoLogic) UploadLogo(req *types.UploadLogoReq, userinfo *auth.Us logx.Error(err) return resp.SetStatus(basic.CodeFileUploadLogoErr, "service fail") } - resultStr = string(b) - if resultStr == "Internal Server Error" { - return resp.SetStatus(basic.CodeFileUploadLogoErr, resultStr) + if string(b) == "Internal Server Error" { + err = errors.New("BLMService fail Internal Server Error") + logx.Error(err) + return resp.SetStatus(basic.CodeFileUploadLogoErr, "service fail") + } else { + var resData map[string]interface{} + err = json.Unmarshal(b, &resData) + if err != nil || resData == nil { + logx.Error(err) + return resp.SetStatus(basic.CodeFileUploadLogoErr, "service fail") + } + + if resData != nil { + if resData["code"].(string) == "200" { + resultStr = resData["data"].(string) + } else { + logx.Error(err) + return resp.SetStatus(basic.CodeFileUploadLogoErrType, "service fail") + } + } else { + logx.Error(err) + return resp.SetStatus(basic.CodeFileUploadLogoErr, "service fail") + } } var module = "logo" diff --git a/service/repositories/image_handle.go b/service/repositories/image_handle.go index d751b8af..861a9f1e 100644 --- a/service/repositories/image_handle.go +++ b/service/repositories/image_handle.go @@ -165,17 +165,35 @@ func (l *defaultImageHandle) LogoCombine(ctx context.Context, in *LogoCombineReq logx.Error(err) return nil, err } - ress := string(b) - - if ress == "Internal Server Error" { + var resultStr string + if string(b) == "Internal Server Error" { err = errors.New("BLMService fail Internal Server Error") logx.Error(err) return nil, err + } else { + var resData map[string]interface{} + err = json.Unmarshal(b, &resData) + if err != nil || resData == nil { + logx.Error(err) + return nil, err + } + + if resData != nil { + if resData["code"].(string) == "200" { + resultStr = resData["data"].(string) + } else { + logx.Error(err) + return nil, err + } + } else { + logx.Error(err) + return nil, err + } } var resultData map[string]interface{} - err = json.Unmarshal(b, &resultData) - if err != nil { + err = json.Unmarshal([]byte(resultStr), &resultData) + if err != nil || resultData == nil { logx.Error(err) return nil, err } diff --git a/utils/basic/basic.go b/utils/basic/basic.go index d5d99288..cb69830e 100644 --- a/utils/basic/basic.go +++ b/utils/basic/basic.go @@ -77,9 +77,10 @@ var ( CodeAesCbcEncryptionErr = &StatusResponse{5106, "encryption data err"} // 加密数据失败 CodeAesCbcDecryptionErr = &StatusResponse{5107, "decryption data err"} // 解密数据失败 - CodeFileUploadErr = &StatusResponse{5110, "file upload err"} // 文件上传失败 - CodeFileUploadLogoErr = &StatusResponse{5111, "logo upload err"} // 用户上传LOGO失败 - CodeFileLogoCombineErr = &StatusResponse{5112, "logo upload err"} // 用户合图失败 + CodeFileUploadErr = &StatusResponse{5110, "file upload err"} // 文件上传失败 + CodeFileUploadLogoErr = &StatusResponse{5111, "logo upload err"} // 用户上传LOGO失败 + CodeFileUploadLogoErrType = &StatusResponse{5111, "logo upload err file is not image"} // 用户上位LOGO失败"} + CodeFileLogoCombineErr = &StatusResponse{5112, "logo upload err"} // 用户合图失败 ) type Response struct { From 68ed14b373b84cfb2de5727c176a6fe221bcf4cb Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Tue, 15 Aug 2023 18:38:33 +0800 Subject: [PATCH 24/25] fix --- .../internal/logic/datatransferlogic.go | 19 +++++++++++++------ .../internal/logic/ws_reuse_last_connect.go | 15 ++++++++++++++- 2 files changed, 27 insertions(+), 7 deletions(-) diff --git a/server/websocket/internal/logic/datatransferlogic.go b/server/websocket/internal/logic/datatransferlogic.go index 1c1b05dd..777d20b4 100644 --- a/server/websocket/internal/logic/datatransferlogic.go +++ b/server/websocket/internal/logic/datatransferlogic.go @@ -3,6 +3,7 @@ package logic import ( "bytes" "encoding/json" + "fmt" "fusenapi/constants" "fusenapi/initalize" "fusenapi/model/gmodel" @@ -97,7 +98,7 @@ func (l *DataTransferLogic) DataTransfer(svcCtx *svc.ServiceContext, w http.Resp ) isAuth, userInfo = l.checkAuth(svcCtx, r) if !isAuth { - time.Sleep(time.Second * 2) //兼容下火狐 + time.Sleep(time.Second * 1) //兼容下火狐 rsp := websocket_data.DataTransferData{ T: constants.WEBSOCKET_UNAUTH, D: nil, @@ -132,7 +133,7 @@ func (l *DataTransferLogic) setConnPool(conn *websocket.Conn, userInfo auth.User publicMutex.Lock() defer publicMutex.Unlock() //生成连接唯一标识 - uniqueId := l.getUniqueId() + uniqueId := l.getUniqueId(userInfo) ws := wsConnectItem{ conn: conn, ctx: l.ctx, @@ -153,21 +154,27 @@ func (l *DataTransferLogic) setConnPool(conn *websocket.Conn, userInfo auth.User mapConnPool.Store(uniqueId, ws) go func() { //把连接成功消息发回去 - time.Sleep(time.Second * 2) //兼容下火狐 + time.Sleep(time.Second * 1) //兼容下火狐 ws.sendToOutChan(ws.respondDataFormat(constants.WEBSOCKET_CONNECT_SUCCESS, uniqueId)) }() return ws } // 获取唯一id -func (l *DataTransferLogic) getUniqueId() string { - uniqueId := uuid.New().String() + time.Now().Format("20060102150405") +func (l *DataTransferLogic) getUniqueId(userInfo auth.UserInfo) string { + //后面拼接上用户id + uniqueId := uuid.New().String() + getUserPart(userInfo.UserId, userInfo.GuestId) if _, ok := mapConnPool.Load(uniqueId); ok { - uniqueId = l.getUniqueId() + uniqueId = l.getUniqueId(userInfo) } return uniqueId } +// 获取用户拼接部分 +func getUserPart(userId, guestId int64) string { + return fmt.Sprintf("_%d_%d", userId, guestId) +} + // 鉴权 func (l *DataTransferLogic) checkAuth(svcCtx *svc.ServiceContext, r *http.Request) (isAuth bool, userInfo *auth.UserInfo) { // 解析JWT token,并对空用户进行判断 diff --git a/server/websocket/internal/logic/ws_reuse_last_connect.go b/server/websocket/internal/logic/ws_reuse_last_connect.go index 325bb292..ea8c75f1 100644 --- a/server/websocket/internal/logic/ws_reuse_last_connect.go +++ b/server/websocket/internal/logic/ws_reuse_last_connect.go @@ -15,11 +15,24 @@ func (w *wsConnectItem) reuseLastConnect(data []byte) { w.sendToOutChan(w.respondDataFormat(constants.WEBSOCKET_REQUEST_RESUME_LAST_CONNECT_ERR, "invalid format of client id")) return } + lenClientId := len(clientId) //id长度不对 - if len(clientId) > 100 { + if lenClientId > 100 { w.sendToOutChan(w.respondDataFormat(constants.WEBSOCKET_REQUEST_RESUME_LAST_CONNECT_ERR, "length of client id is to long")) return } + //合成client后缀,不是同个后缀的不能复用 + userPart := getUserPart(w.userId, w.guestId) + lenUserPart := len(userPart) + if lenClientId <= lenUserPart { + w.sendToOutChan(w.respondDataFormat(constants.WEBSOCKET_REQUEST_RESUME_LAST_CONNECT_ERR, "length of client id is to short")) + return + } + //尾部不同不能复用 + if clientId[lenClientId-lenUserPart:] != userPart { + w.sendToOutChan(w.respondDataFormat(constants.WEBSOCKET_REQUEST_RESUME_LAST_CONNECT_ERR, "the client id is not belong you before")) + return + } publicMutex.Lock() defer publicMutex.Unlock() //存在是不能给他申请重新绑定 From ac1800bb26ce44fba8be8271c7be2b8403c7d7f5 Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Tue, 15 Aug 2023 19:43:50 +0800 Subject: [PATCH 25/25] fix --- server/product/internal/logic/getrecommandproductlistlogic.go | 2 +- server/product/internal/types/types.go | 2 +- server_api/product.api | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/server/product/internal/logic/getrecommandproductlistlogic.go b/server/product/internal/logic/getrecommandproductlistlogic.go index 018d68a4..d73206c7 100644 --- a/server/product/internal/logic/getrecommandproductlistlogic.go +++ b/server/product/internal/logic/getrecommandproductlistlogic.go @@ -36,7 +36,7 @@ func NewGetRecommandProductListLogic(ctx context.Context, svcCtx *svc.ServiceCon func (l *GetRecommandProductListLogic) GetRecommandProductList(req *types.GetRecommandProductListReq, userinfo *auth.UserInfo) (resp *basic.Response) { req.Num = 4 //写死4个 if req.Size > 0 { - req.Size = image.GetCurrentSize(req.Size) + req.Size = int32(image.GetCurrentSize(uint32(req.Size))) } productInfo, err := l.svcCtx.AllModels.FsProduct.FindOneBySn(l.ctx, req.Sn) if err != nil { diff --git a/server/product/internal/types/types.go b/server/product/internal/types/types.go index e44a240f..6adf44d2 100644 --- a/server/product/internal/types/types.go +++ b/server/product/internal/types/types.go @@ -228,7 +228,7 @@ type OtherProductListRsp struct { } type GetRecommandProductListReq struct { - Size uint32 `form:"size,optional"` + Size int32 `form:"size,optional"` Num int64 `form:"num,optional"` Sn string `form:"sn"` } diff --git a/server_api/product.api b/server_api/product.api index cbdc734f..9e8626c5 100644 --- a/server_api/product.api +++ b/server_api/product.api @@ -281,7 +281,7 @@ type OtherProductListRsp { } //获取详情页推荐产品列表 type GetRecommandProductListReq { - Size uint32 `form:"size,optional"` + Size int32 `form:"size,optional"` Num int64 `form:"num,optional"` Sn string `form:"sn"` }