From 161ee4304badcefbd0a6560424930e695fe10425 Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Thu, 10 Aug 2023 18:38:31 +0800 Subject: [PATCH 001/151] fix --- server/render/consumer/assemble_render_data.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/server/render/consumer/assemble_render_data.go b/server/render/consumer/assemble_render_data.go index 5334db5b..3c7f1ffa 100644 --- a/server/render/consumer/assemble_render_data.go +++ b/server/render/consumer/assemble_render_data.go @@ -18,6 +18,7 @@ import ( "gorm.io/gorm" "io/ioutil" "strconv" + "time" ) // 这里请求的py接口返回数据 @@ -227,7 +228,7 @@ func getCombineImage(ctx context.Context, svcCtx *svc.ServiceContext, parseInfo /*f, _ := os.Create("a.txt") defer f.Close() f.Write(postData)*/ - httpRsp, err := curl.ApiCall(url, "POST", header, bytes.NewReader(postData), 20) + httpRsp, err := curl.ApiCall(url, "POST", header, bytes.NewReader(postData), time.Second*20) if err != nil { logx.Error("failed to combine logo:", err) return "", err From 83b0b7f5ab5a520edc89fba180edfb0915edcdc6 Mon Sep 17 00:00:00 2001 From: Hiven Date: Thu, 10 Aug 2023 19:08:06 +0800 Subject: [PATCH 002/151] =?UTF-8?q?fix:=E4=BF=AE=E5=A4=8D=E4=B8=8A?= =?UTF-8?q?=E4=BC=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- model/gmodel/fs_cart_logic.go | 20 +++++++ .../gmodel/fs_order_detail_template_logic.go | 4 ++ model/gmodel/fs_order_logic.go | 15 +++++ model/gmodel/fs_pay_logic.go | 29 +++++++++ model/gmodel/fs_product_design_logic.go | 17 ++++++ model/gmodel/fs_refund_reason_logic.go | 20 +++++++ model/gmodel/fs_resource_logic.go | 21 +++++++ .../internal/logic/userordercancellogic.go | 4 +- .../internal/logic/orderpaymentintentlogic.go | 8 +-- .../pay/internal/logic/stripewebhooklogic.go | 23 ++++---- .../internal/handler/uploadlogohandler.go | 2 +- .../internal/logic/uploadcallbacklogic.go | 10 ++-- .../upload/internal/logic/uploadlogologic.go | 59 +++++++++++++++---- server/upload/internal/types/types.go | 9 ++- server_api/upload.api | 9 ++- 15 files changed, 209 insertions(+), 41 deletions(-) diff --git a/model/gmodel/fs_cart_logic.go b/model/gmodel/fs_cart_logic.go index d86b18be..e7ed91b1 100755 --- a/model/gmodel/fs_cart_logic.go +++ b/model/gmodel/fs_cart_logic.go @@ -4,6 +4,7 @@ package gmodel import ( "context" + "gorm.io/gorm" ) type FindOneCartByParamsReq struct { @@ -94,3 +95,22 @@ func (c *FsCartModel) DeleteCartsByIds(ctx context.Context, ids []int64) ( err e } return c.db.Table(c.name).WithContext(ctx).Model(&FsCart{}).Where("`id` in (?)", ids).Update("status", 0).Error } + +func (c *FsCartModel) RBDeleteCartsByIds(rowBuilder *gorm.DB,ids []int64) ( err error) { + if len(ids) == 0 { + return + } + return rowBuilder.Where("`id` in (?)", ids).Update("status", 0).Error +} + +func (c *FsCartModel) BuilderTrans(ctx context.Context,selectData []string) *gorm.DB { + var rowBuilder = c.db.WithContext(ctx) + + if selectData != nil { + rowBuilder = rowBuilder.Select(selectData) + } else { + rowBuilder = rowBuilder.Select("*") + } + return rowBuilder +} + diff --git a/model/gmodel/fs_order_detail_template_logic.go b/model/gmodel/fs_order_detail_template_logic.go index cbdcd360..c0cdf641 100755 --- a/model/gmodel/fs_order_detail_template_logic.go +++ b/model/gmodel/fs_order_detail_template_logic.go @@ -26,6 +26,10 @@ func (dt *FsOrderDetailTemplateModel) FindOne(ctx context.Context, id int64) (re return resp, err } +func (dt *FsOrderDetailTemplateModel) RBCreate(ctx context.Context, data *FsOrderDetailTemplate) error { + return dt.db.WithContext(ctx).Create(&data).Error +} + func (m *FsOrderDetailTemplateModel) TableName() string { return m.name } diff --git a/model/gmodel/fs_order_logic.go b/model/gmodel/fs_order_logic.go index 60ce74d8..c0d27763 100755 --- a/model/gmodel/fs_order_logic.go +++ b/model/gmodel/fs_order_logic.go @@ -28,6 +28,10 @@ func (o *FsOrderModel) Update(ctx context.Context, data *FsOrder) error { return o.db.WithContext(ctx).Model(&FsOrder{}).Where("`id` = ?", data.Id).Updates(&data).Error } +func (o *FsOrderModel) RBUpdate(ctx context.Context, data *FsOrder) error { + return o.db.WithContext(ctx).Where("`id` = ?", data.Id).Updates(&data).Error +} + func (o *FsOrderModel) Create(ctx context.Context, data *FsOrder) error { return o.db.WithContext(ctx).Model(&FsOrder{}).Create(&data).Error } @@ -120,6 +124,17 @@ func (m *FsOrderModel) RowSelectBuilder(selectData []string) *gorm.DB { return rowBuilder } +func (m *FsOrderModel) BuilderTrans(selectData []string) *gorm.DB { + var rowBuilder = m.db + + if selectData != nil { + rowBuilder = rowBuilder.Select(selectData) + } else { + rowBuilder = rowBuilder.Select("*") + } + return rowBuilder +} + func (m *FsOrderModel) FindCount(ctx context.Context, countBuilder *gorm.DB, filterMap map[string]string) (int64, error) { var count int64 diff --git a/model/gmodel/fs_pay_logic.go b/model/gmodel/fs_pay_logic.go index c23f3b36..2ae4ebc9 100644 --- a/model/gmodel/fs_pay_logic.go +++ b/model/gmodel/fs_pay_logic.go @@ -29,6 +29,14 @@ func (p *FsPayModel) GetListByOrderNumberStage(ctx context.Context, sn string, s return resp, nil } +func (p *FsPayModel) RBGetListByOrderNumberStage(ctx context.Context, sn string, stage int64) (resp *FsPay, err error) { + err = p.db.WithContext(ctx).Where("`order_number` = ? ", sn).Where("`pay_stage` = ? ", stage).Take(&resp).Error + if err != nil { + return nil, err + } + return resp, nil +} + func (p *FsPayModel) CreateOrUpdate(ctx context.Context, req *FsPay) (resp *FsPay, err error) { rowBuilder := p.db.Table(p.name).WithContext(ctx) if req.Id > 0 { @@ -39,6 +47,16 @@ func (p *FsPayModel) CreateOrUpdate(ctx context.Context, req *FsPay) (resp *FsPa return req, err } +func (p *FsPayModel) RBCreateOrUpdate(ctx context.Context, req *FsPay) (resp *FsPay, err error) { + rowBuilder := p.db.WithContext(ctx) + if req.Id > 0 { + err = rowBuilder.Save(req).Error + } else { + err = rowBuilder.Create(req).Error + } + return req, err +} + func (m *FsPayModel) RowSelectBuilder(selectData []string) *gorm.DB { var rowBuilder = m.db.Table(m.name) @@ -50,6 +68,17 @@ func (m *FsPayModel) RowSelectBuilder(selectData []string) *gorm.DB { return rowBuilder } +func (m *FsPayModel) BuilderTrans(selectData []string) *gorm.DB { + var rowBuilder = m.db + + if selectData != nil { + rowBuilder = rowBuilder.Select(selectData) + } else { + rowBuilder = rowBuilder.Select("*") + } + return rowBuilder +} + func (m *FsPayModel) FindCount(ctx context.Context, countBuilder *gorm.DB, filterMap map[string]string) (int64, error) { var count int64 diff --git a/model/gmodel/fs_product_design_logic.go b/model/gmodel/fs_product_design_logic.go index 71f26d17..2dfe5dcc 100755 --- a/model/gmodel/fs_product_design_logic.go +++ b/model/gmodel/fs_product_design_logic.go @@ -2,6 +2,8 @@ package gmodel import ( "context" + + "gorm.io/gorm" ) func (d *FsProductDesignModel) FindOneBySn(ctx context.Context, sn string, userId int64) (resp *FsProductDesign, err error) { @@ -39,6 +41,21 @@ func (d *FsProductDesignModel) UpdateByIds(ctx context.Context, ids []int64, dat return d.db.Table(d.name).WithContext(ctx).Model(&FsProductDesign{}).Where("`id` in ?", ids).Updates(&data).Error } +func (d *FsProductDesignModel) RBUpdateByIds(rowBuilder *gorm.DB, ids []int64, data *FsProductDesign) error { + return rowBuilder.Where("`id` in ?", ids).Updates(&data).Error +} + +func (m *FsProductDesignModel) BuilderTrans(ctx context.Context, selectData []string) *gorm.DB { + var rowBuilder = m.db.WithContext(ctx) + + if selectData != nil { + rowBuilder = rowBuilder.Select(selectData) + } else { + rowBuilder = rowBuilder.Select("*") + } + return rowBuilder +} + func (m *FsProductDesignModel) TableName() string { return m.name } diff --git a/model/gmodel/fs_refund_reason_logic.go b/model/gmodel/fs_refund_reason_logic.go index 14acda7a..5a6fce1b 100644 --- a/model/gmodel/fs_refund_reason_logic.go +++ b/model/gmodel/fs_refund_reason_logic.go @@ -36,6 +36,16 @@ func (m *FsRefundReasonModel) CreateOrUpdate(ctx context.Context, req *FsRefundR return req, err } +func (m *FsRefundReasonModel) RBCreateOrUpdate(ctx context.Context, req *FsRefundReason) (resp *FsRefundReason, err error) { + rowBuilder := m.db.WithContext(ctx) + if req.Id > 0 { + err = rowBuilder.Save(req).Error + } else { + err = rowBuilder.Create(req).Error + } + return req, err +} + func (m *FsRefundReasonModel) FindOneByQuery(ctx context.Context, rowBuilder *gorm.DB, filterMap map[string]string) (*FsRefundReason, error) { var resp FsRefundReason @@ -62,6 +72,16 @@ func (m *FsRefundReasonModel) RowSelectBuilder(selectData []string) *gorm.DB { return rowBuilder } +func (m *FsRefundReasonModel) BuilderTrans(selectData []string) *gorm.DB { + var rowBuilder = m.db + if selectData != nil { + rowBuilder = rowBuilder.Select(selectData) + } else { + rowBuilder = rowBuilder.Select("*") + } + return rowBuilder +} + func (m *FsRefundReasonModel) TableName() string { return m.name } diff --git a/model/gmodel/fs_resource_logic.go b/model/gmodel/fs_resource_logic.go index 19e095db..31212da2 100644 --- a/model/gmodel/fs_resource_logic.go +++ b/model/gmodel/fs_resource_logic.go @@ -24,6 +24,16 @@ func (p *FsResourceModel) Update(ctx context.Context, req *FsResource) (resp *Fs return req, err } +func (p *FsResourceModel) BuilderCreate(ctx context.Context, rowBuilder *gorm.DB, req *FsResource) (resp *FsResource, err error) { + err = rowBuilder.WithContext(ctx).Create(req).Error + return req, err +} + +func (p *FsResourceModel) BuilderUpdate(ctx context.Context, rowBuilder *gorm.DB, req *FsResource) (resp *FsResource, err error) { + err = rowBuilder.WithContext(ctx).Where("resource_id =?", req.ResourceId).Save(req).Error + return req, err +} + func (m *FsResourceModel) FindOneByQuery(ctx context.Context, rowBuilder *gorm.DB, filterMap map[string]string) (*FsResource, error) { var resp FsResource @@ -50,6 +60,17 @@ func (m *FsResourceModel) RowSelectBuilder(selectData []string) *gorm.DB { return rowBuilder } +func (m *FsResourceModel) BuilderTrans(selectData []string) *gorm.DB { + var rowBuilder = m.db + + if selectData != nil { + rowBuilder = rowBuilder.Select(selectData) + } else { + rowBuilder = rowBuilder.Select("*") + } + return rowBuilder +} + // 事务 func (m *FsResourceModel) Trans(ctx context.Context, fn func(ctx context.Context, connGorm *gorm.DB) error) error { diff --git a/server/home-user-auth/internal/logic/userordercancellogic.go b/server/home-user-auth/internal/logic/userordercancellogic.go index 13211fcf..6164da9c 100644 --- a/server/home-user-auth/internal/logic/userordercancellogic.go +++ b/server/home-user-auth/internal/logic/userordercancellogic.go @@ -80,14 +80,14 @@ func (l *UserOrderCancelLogic) UserOrderCancel(req *types.UserOrderCancelReq, us err = l.svcCtx.MysqlConn.Transaction(func(tx *gorm.DB) error { // 修改订单信息 orderModelTS := gmodel.NewFsOrderModel(tx) - err = orderModelTS.Update(ctx, orderInfo) + err = orderModelTS.RBUpdate(ctx, orderInfo) if err != nil { return err } // 新增退款记录 var isRefund int64 = 0 refundReasonModelTS := gmodel.NewFsRefundReasonModel(tx) - refundReasonModelTS.CreateOrUpdate(ctx, &gmodel.FsRefundReason{ + refundReasonModelTS.RBCreateOrUpdate(ctx, &gmodel.FsRefundReason{ IsRefund: &isRefund, RefundReasonId: &req.RefundReasonId, RefundReason: &req.RefundReason, diff --git a/server/pay/internal/logic/orderpaymentintentlogic.go b/server/pay/internal/logic/orderpaymentintentlogic.go index fdc608ad..85946f40 100644 --- a/server/pay/internal/logic/orderpaymentintentlogic.go +++ b/server/pay/internal/logic/orderpaymentintentlogic.go @@ -116,7 +116,7 @@ func (l *OrderPaymentIntentLogic) OrderPaymentIntent(req *types.OrderPaymentInte var fspay *gmodel.FsPay newFsPayModel := gmodel.NewFsPayModel(connGorm) if *orderInfo.Status == int64(constants.STATUS_NEW_NOT_PAY) { - fspay, err = newFsPayModel.GetListByOrderNumberStage(ctx, *orderInfo.Sn, 1) + fspay, err = newFsPayModel.RBGetListByOrderNumberStage(ctx, *orderInfo.Sn, 1) if err != nil { if !errors.Is(err, gorm.ErrRecordNotFound) { return err @@ -124,7 +124,7 @@ func (l *OrderPaymentIntentLogic) OrderPaymentIntent(req *types.OrderPaymentInte } payStage = 1 } else { - fspay, err = newFsPayModel.GetListByOrderNumberStage(ctx, *orderInfo.Sn, 2) + fspay, err = newFsPayModel.RBGetListByOrderNumberStage(ctx, *orderInfo.Sn, 2) if err != nil { if !errors.Is(err, gorm.ErrRecordNotFound) { return err @@ -146,7 +146,7 @@ func (l *OrderPaymentIntentLogic) OrderPaymentIntent(req *types.OrderPaymentInte } // 订单信息--修改 - err = gmodel.NewFsOrderModel(connGorm).Update(ctx, orderInfo) + err = gmodel.NewFsOrderModel(connGorm).RBUpdate(ctx, orderInfo) if err != nil { return err } @@ -167,7 +167,7 @@ func (l *OrderPaymentIntentLogic) OrderPaymentIntent(req *types.OrderPaymentInte fspay.OrderSource = &orderSource fspay.PayStatus = &payStatus - _, err = newFsPayModel.CreateOrUpdate(ctx, fspay) + _, err = newFsPayModel.RBCreateOrUpdate(ctx, fspay) if err != nil { return err } diff --git a/server/pay/internal/logic/stripewebhooklogic.go b/server/pay/internal/logic/stripewebhooklogic.go index 5f327ab5..a0fe1dd2 100644 --- a/server/pay/internal/logic/stripewebhooklogic.go +++ b/server/pay/internal/logic/stripewebhooklogic.go @@ -157,7 +157,7 @@ func (l *StripeWebhookLogic) HandleChargeRefunded(chargeRefunded *stripe.Charge) err = l.svcCtx.MysqlConn.Transaction(func(connGorm *gorm.DB) error { // 查询支付记录 payModelT := gmodel.NewFsPayModel(connGorm) - payModelTRSB := payModelT.RowSelectBuilder(nil) + payModelTRSB := payModelT.BuilderTrans(nil) payModelTRSB1 := payModelTRSB.Where("trade_no = ?", chargeRefunded.PaymentIntent.ID).Where("pay_status = ?", constants.PAYSTATUS_SUCCESS).Where("is_refund = ?", 0) payInfo, err := payModelT.FindOneByQuery(ctx, payModelTRSB1, nil) if err != nil { @@ -165,7 +165,7 @@ func (l *StripeWebhookLogic) HandleChargeRefunded(chargeRefunded *stripe.Charge) } // 更新支付记录 *payInfo.IsRefund = 1 - _, err = payModelT.CreateOrUpdate(ctx, payInfo) + _, err = payModelT.RBCreateOrUpdate(ctx, payInfo) if err != nil { return err } @@ -175,7 +175,7 @@ func (l *StripeWebhookLogic) HandleChargeRefunded(chargeRefunded *stripe.Charge) if count == 0 { // 退款完成更新订单状态 orderModelT := gmodel.NewFsOrderModel(connGorm) - orderModelTRSB := orderModelT.RowSelectBuilder(nil).Where("sn =?", payInfo.OrderNumber) + orderModelTRSB := orderModelT.BuilderTrans(nil).Where("sn =?", payInfo.OrderNumber) orderInfoRel, err := orderModelT.FindOneByQuery(ctx, orderModelTRSB, nil) if err != nil { return err @@ -192,13 +192,14 @@ func (l *StripeWebhookLogic) HandleChargeRefunded(chargeRefunded *stripe.Charge) // 记录退款原因 refundReasonModelT := gmodel.NewFsRefundReasonModel(connGorm) - refundReasonModelTRSB := refundReasonModelT.RowSelectBuilder(nil).Where("order_id =?", orderInfoRel.Id) - refundReasonInfo, err := refundReasonModelT.FindOneByQuery(ctx, refundReasonModelTRSB, nil) + refundReasonModelTRSB := refundReasonModelT.BuilderTrans(nil) + refundReasonModelTRSB1 := refundReasonModelTRSB.Where("order_id =?", orderInfoRel.Id) + refundReasonInfo, err := refundReasonModelT.FindOneByQuery(ctx, refundReasonModelTRSB1, nil) if err != nil { return err } *refundReasonInfo.IsRefund = 1 - _, err = refundReasonModelT.CreateOrUpdate(ctx, refundReasonInfo) + _, err = refundReasonModelT.RBCreateOrUpdate(ctx, refundReasonInfo) if err != nil { return err } @@ -304,15 +305,16 @@ func (l *StripeWebhookLogic) HandlePaymentIntentSucceeded(paymentIntent *stripe. *payInfo.CardNo = card *payInfo.Brand = brand *payInfo.TradeNo = paymentIntent.ID - _, err = payModelT.CreateOrUpdate(ctx, payInfo) + _, err = payModelT.RBCreateOrUpdate(ctx, payInfo) if err != nil { return err } // 更新设计数据 productDesignModelT := gmodel.NewFsProductDesignModel(connGorm) + productDesignModelTRSB := productDesignModelT.BuilderTrans(ctx, nil) var isPay int64 = 1 - err = productDesignModelT.UpdateByIds(ctx, designIds, &gmodel.FsProductDesign{IsPay: &isPay}) + err = productDesignModelT.RBUpdateByIds(productDesignModelTRSB, designIds, &gmodel.FsProductDesign{IsPay: &isPay}) if err != nil { return err } @@ -331,7 +333,8 @@ func (l *StripeWebhookLogic) HandlePaymentIntentSucceeded(paymentIntent *stripe. // 删除购物车 cartModelT := gmodel.NewFsCartModel(connGorm) - err = cartModelT.DeleteCartsByIds(ctx, cartIds) + cartModelTRSB := cartModelT.BuilderTrans(ctx, nil) + err = cartModelT.RBDeleteCartsByIds(cartModelTRSB, cartIds) if err != nil { return err } @@ -353,7 +356,7 @@ func (l *StripeWebhookLogic) HandlePaymentIntentSucceeded(paymentIntent *stripe. orderInfo.Ptime = &nowTime orderInfo.PayedAmount = &orderPayedAmount orderModelT := gmodel.NewFsOrderModel(connGorm) - err = orderModelT.Update(ctx, orderInfo) + err = orderModelT.RBUpdate(ctx, orderInfo) if err != nil { return err } diff --git a/server/upload/internal/handler/uploadlogohandler.go b/server/upload/internal/handler/uploadlogohandler.go index 52c58424..6fee9634 100644 --- a/server/upload/internal/handler/uploadlogohandler.go +++ b/server/upload/internal/handler/uploadlogohandler.go @@ -21,7 +21,7 @@ func UploadLogoHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { } // 创建一个业务逻辑层实例 - l := logic.NewUploadLogoLogic(r.Context(), svcCtx) + l := logic.NewUploadLogoLogic(r, svcCtx) rl := reflect.ValueOf(l) basic.BeforeLogic(w, r, rl) diff --git a/server/upload/internal/logic/uploadcallbacklogic.go b/server/upload/internal/logic/uploadcallbacklogic.go index 4c67de50..615052fd 100644 --- a/server/upload/internal/logic/uploadcallbacklogic.go +++ b/server/upload/internal/logic/uploadcallbacklogic.go @@ -66,8 +66,10 @@ func (l *UploadCallbackLogic) UploadCallback(req *types.UploadCallbackReq, useri ctx := l.ctx err := l.svcCtx.MysqlConn.Transaction(func(connGorm *gorm.DB) error { - resourceModelTS := gmodel.NewFsResourceModel(l.svcCtx.MysqlConn) - resourceInfo, err := resourceModelTS.FindOneById(ctx, req.ResourceId) + resourceModelTS := gmodel.NewFsResourceModel(connGorm) + transBuilder := resourceModelTS.BuilderTrans(nil) + transBuilderFind := transBuilder.Where("resource_id =?", req.ResourceId) + resourceInfo, err := resourceModelTS.FindOneByQuery(ctx, transBuilderFind, nil) if err != nil { return err } @@ -84,9 +86,9 @@ func (l *UploadCallbackLogic) UploadCallback(req *types.UploadCallbackReq, useri fsResource.BucketName = bucketName fsResource.Version = &version if resourceInfo.ResourceId == "" { - _, err = resourceModelTS.Create(ctx, fsResource) + _, err = resourceModelTS.BuilderCreate(ctx, transBuilder, fsResource) } else { - _, err = resourceModelTS.Update(ctx, fsResource) + _, err = resourceModelTS.BuilderUpdate(ctx, transBuilder, fsResource) } return err }) diff --git a/server/upload/internal/logic/uploadlogologic.go b/server/upload/internal/logic/uploadlogologic.go index 7bbc20e2..ea98bf45 100644 --- a/server/upload/internal/logic/uploadlogologic.go +++ b/server/upload/internal/logic/uploadlogologic.go @@ -6,7 +6,10 @@ import ( "fusenapi/utils/auth" "fusenapi/utils/basic" "fusenapi/utils/curl" + "fusenapi/utils/file" + "fusenapi/utils/hash" "io" + "net/http" "strings" "time" @@ -22,13 +25,15 @@ type UploadLogoLogic struct { logx.Logger ctx context.Context svcCtx *svc.ServiceContext + r *http.Request } -func NewUploadLogoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UploadLogoLogic { +func NewUploadLogoLogic(r *http.Request, svcCtx *svc.ServiceContext) *UploadLogoLogic { return &UploadLogoLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, + Logger: logx.WithContext(r.Context()), + ctx: r.Context(), svcCtx: svcCtx, + r: r, } } @@ -61,6 +66,43 @@ func (l *UploadLogoLogic) UploadLogo(req *types.UploadLogoReq, userinfo *auth.Us userId = userinfo.UserId } + //设置内存大小 + l.r.ParseMultipartForm(32 << 20) + + fileObject, _, err := l.r.FormFile("file") + if err != nil { + logx.Error(err) + return resp.SetStatus(basic.CodeFileUploadErr, "file upload err,no files") + } + + // 读取数据流 + ioData, err := io.ReadAll(fileObject) + if err != nil { + logx.Error(err) + return resp.SetStatus(basic.CodeFileUploadErr, "file upload err,no files") + } + + // 上传文件 + var upload = file.Upload{ + Ctx: l.ctx, + MysqlConn: l.svcCtx.MysqlConn, + AwsSession: l.svcCtx.AwsSession, + } + var resourceId string = hash.JsonHashKey(req.FileKey) + uploadRes, err := upload.UploadFileByByte(&file.UploadBaseReq{ + FileHash: resourceId, + FileByte: ioData, + UploadBucket: 1, + ApiType: 2, + UserId: userId, + GuestId: guestId, + }) + + if err != nil { + logx.Error(err) + return resp.SetStatus(basic.CodeFileUploadErr, "upload file failed") + } + var logoWidth int64 var logoHeight int64 // 查看sku是否存在 @@ -82,17 +124,14 @@ func (l *UploadLogoLogic) UploadLogo(req *types.UploadLogoReq, userinfo *auth.Us logoHeight = 200 } var resultStr string - var err error var postMap = make(map[string]interface{}, 1) - postMap["logo_url"] = req.ResourceUrl + postMap["logo_url"] = uploadRes.ResourceUrl postMapB, _ := json.Marshal(postMap) - //result, err := http.Post(l.svcCtx.Config.BLMService.ImageProcess.Url, "application/json", strings.NewReader(string(postMapB))) - var headerData = make(map[string]string, 1) headerData["Content-Type"] = "application/json" - result, err := curl.ApiCall(l.svcCtx.Config.BLMService.ImageProcess.Url, "POST", headerData, strings.NewReader(string(postMapB)), 20) + result, err := curl.ApiCall(l.svcCtx.Config.BLMService.ImageProcess.Url, "POST", headerData, strings.NewReader(string(postMapB)), time.Second*20) if err != nil { logx.Error(err) @@ -118,8 +157,8 @@ func (l *UploadLogoLogic) UploadLogo(req *types.UploadLogoReq, userinfo *auth.Us Module: &module, UserId: &userId, GuestId: &guestId, - ResourceId: &req.ResourceId, - ResourceUrl: &req.ResourceUrl, + ResourceId: &uploadRes.ResourceId, + ResourceUrl: &uploadRes.ResourceUrl, Metadata: &resultStr, CreateAt: &nowTime, }) diff --git a/server/upload/internal/types/types.go b/server/upload/internal/types/types.go index b6363f9f..6ac757ae 100644 --- a/server/upload/internal/types/types.go +++ b/server/upload/internal/types/types.go @@ -16,11 +16,10 @@ type UploadFileBaseReq struct { } type UploadLogoReq struct { - ResourceId string `form:"resource_id"` // 资源ID - ResourceUrl string `form:"resource_url"` // 资源URL - IsRemoveBg int64 `form:"is_remove_bg,optional"` // 是否要去掉背景 - Proportion int64 `form:"proportion,default=60"` // 贴图在模型面板上的比例 - SkuId int64 `form:"sku_id,default=0"` // 模板ID + FileKey string `form:"file_key"` // 上传logo唯一标识信息 + IsRemoveBg int64 `form:"is_remove_bg,optional"` // 是否要去掉背景 + Proportion int64 `form:"proportion,default=60"` // 贴图在模型面板上的比例 + SkuId int64 `form:"sku_id,default=0"` // 模板ID } type UploadFileBackendReq struct { diff --git a/server_api/upload.api b/server_api/upload.api index a9581adf..a3c7399f 100644 --- a/server_api/upload.api +++ b/server_api/upload.api @@ -58,11 +58,10 @@ type ( type ( UploadLogoReq { - ResourceId string `form:"resource_id"` // 资源ID - ResourceUrl string `form:"resource_url"` // 资源URL - IsRemoveBg int64 `form:"is_remove_bg,optional"` // 是否要去掉背景 - Proportion int64 `form:"proportion,default=60"` // 贴图在模型面板上的比例 - SkuId int64 `form:"sku_id,default=0"` // 模板ID + FileKey string `form:"file_key"` // 上传logo唯一标识信息 + IsRemoveBg int64 `form:"is_remove_bg,optional"` // 是否要去掉背景 + Proportion int64 `form:"proportion,default=60"` // 贴图在模型面板上的比例 + SkuId int64 `form:"sku_id,default=0"` // 模板ID } ) From d101d241f43bf627b913c5df708cd0108f8b90be Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Thu, 10 Aug 2023 19:12:07 +0800 Subject: [PATCH 003/151] fix --- server/render/consumer/assemble_render_data.go | 6 ++++++ server/websocket/internal/logic/mq_consumer.go | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/server/render/consumer/assemble_render_data.go b/server/render/consumer/assemble_render_data.go index 3c7f1ffa..98184dca 100644 --- a/server/render/consumer/assemble_render_data.go +++ b/server/render/consumer/assemble_render_data.go @@ -33,6 +33,11 @@ type MqConsumerRenderAssemble struct { } func (m *MqConsumerRenderAssemble) Run(ctx context.Context, data []byte) error { + defer func() { + if err := recover(); err != nil { + logx.Error("MqConsumerRenderAssemble panic:", err) + } + }() logx.Info("收到需要组装的消息:", string(data)) var parseInfo websocket_data.AssembleRenderData if err := json.Unmarshal(data, &parseInfo); err != nil { @@ -244,6 +249,7 @@ func getCombineImage(ctx context.Context, svcCtx *svc.ServiceContext, parseInfo logx.Error("failed to parse python api rsp:", err) return "", err } + //fmt.Println("××××××××××××××××××××:", pythonApiInfo) //上传刀版图 var upload = file.Upload{ Ctx: ctx, diff --git a/server/websocket/internal/logic/mq_consumer.go b/server/websocket/internal/logic/mq_consumer.go index 7488e229..410dee3e 100644 --- a/server/websocket/internal/logic/mq_consumer.go +++ b/server/websocket/internal/logic/mq_consumer.go @@ -13,6 +13,11 @@ type MqConsumerRenderResult struct { } func (m *MqConsumerRenderResult) Run(ctx context.Context, data []byte) error { + defer func() { + if err := recover(); err != nil { + logx.Error("MqConsumerRenderResult panic:", err) + } + }() logx.Info("接收到MqConsumerRenderResult数据:", string(data)) var parseInfo websocket_data.RenderImageNotify if err := json.Unmarshal(data, &parseInfo); err != nil { From b085f3dbefd8c84479802468dedaeb4a444504c4 Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Thu, 10 Aug 2023 19:41:25 +0800 Subject: [PATCH 004/151] fix --- .../internal/logic/datatransferlogic.go | 58 ++++++++++++------- 1 file changed, 38 insertions(+), 20 deletions(-) diff --git a/server/websocket/internal/logic/datatransferlogic.go b/server/websocket/internal/logic/datatransferlogic.go index 44dc3e82..cbd1a189 100644 --- a/server/websocket/internal/logic/datatransferlogic.go +++ b/server/websocket/internal/logic/datatransferlogic.go @@ -9,6 +9,7 @@ import ( "fusenapi/utils/auth" "fusenapi/utils/id_generator" "fusenapi/utils/websocket_data" + "github.com/google/uuid" "github.com/gorilla/websocket" "net/http" "sync" @@ -60,6 +61,8 @@ var ( } //websocket连接存储 mapConnPool = sync.Map{} + //公共互斥锁 + publicMutex sync.Mutex ) // 每个连接的连接基本属性 @@ -70,7 +73,7 @@ type wsConnectItem struct { allModels *gmodel.AllModelsGen closeChan chan struct{} //ws连接关闭chan isClose bool //是否已经关闭 - uniqueId uint64 //ws连接唯一标识 + uniqueId string //ws连接唯一标识 inChan chan []byte //接受消息缓冲通道 outChan chan []byte //发送回客户端的消息 mutex sync.Mutex //互斥锁 @@ -94,7 +97,7 @@ func (l *DataTransferLogic) DataTransfer(svcCtx *svc.ServiceContext, w http.Resp ) isAuth, userInfo = l.checkAuth(svcCtx, r) if !isAuth { - time.Sleep(time.Second * 4) //兼容下火狐 + time.Sleep(time.Second * 2) //兼容下火狐 rsp := websocket_data.DataTransferData{ T: constants.WEBSOCKET_UNAUTH, D: nil, @@ -109,8 +112,32 @@ func (l *DataTransferLogic) DataTransfer(svcCtx *svc.ServiceContext, w http.Resp //测试的目前写死 39 var userInfo auth.UserInfo userInfo.UserId = 39 + ws := l.setConnPool(conn, userInfo) + defer ws.close() + go func() { + //把连接成功消息发回去 + time.Sleep(time.Second * 2) //兼容下火狐 + b := ws.respondDataFormat(constants.WEBSOCKET_CONNECT_SUCCESS, uniqueId) + _ = conn.WriteMessage(websocket.TextMessage, b) + }() + //循环读客户端信息 + go ws.readLoop() + //循环把数据发送给客户端 + go ws.writeLoop() + //推消息到云渲染 + go ws.sendLoop() + //操作连接中渲染任务的增加/删除 + go ws.operationRenderTask() + //心跳 + ws.heartbeat() +} + +// 获取唯一id +func (l *DataTransferLogic) setConnPool(conn *websocket.Conn, userInfo auth.UserInfo) wsConnectItem { + publicMutex.Lock() + defer publicMutex.Unlock() //生成连接唯一标识 - uniqueId := websocketIdGenerator.Get() + uniqueId := l.getUniqueId() ws := wsConnectItem{ conn: conn, ctx: l.ctx, @@ -129,23 +156,14 @@ func (l *DataTransferLogic) DataTransfer(svcCtx *svc.ServiceContext, w http.Resp } //保存连接 mapConnPool.Store(uniqueId, ws) - defer ws.close() - go func() { - //把连接成功消息发回去 - time.Sleep(time.Second * 4) //兼容下火狐 - b := ws.respondDataFormat(constants.WEBSOCKET_CONNECT_SUCCESS, uniqueId) - _ = conn.WriteMessage(websocket.TextMessage, b) - }() - //循环读客户端信息 - go ws.readLoop() - //循环把数据发送给客户端 - go ws.writeLoop() - //推消息到云渲染 - go ws.sendLoop() - //操作连接中渲染任务的增加/删除 - go ws.operationRenderTask() - //心跳 - ws.heartbeat() + return ws +} +func (l *DataTransferLogic) getUniqueId() string { + uniqueId := uuid.New().String() + time.Now().Format("20060102150405") + if _, ok := mapConnPool.Load(uniqueId); ok { + uniqueId = l.getUniqueId() + } + return uniqueId } // 鉴权 From df8772812aa1927bb7a180aef0b30dfb9c3c9df1 Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Thu, 10 Aug 2023 19:42:31 +0800 Subject: [PATCH 005/151] fix --- server/websocket/internal/logic/datatransferlogic.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/server/websocket/internal/logic/datatransferlogic.go b/server/websocket/internal/logic/datatransferlogic.go index cbd1a189..825ce08a 100644 --- a/server/websocket/internal/logic/datatransferlogic.go +++ b/server/websocket/internal/logic/datatransferlogic.go @@ -114,12 +114,6 @@ func (l *DataTransferLogic) DataTransfer(svcCtx *svc.ServiceContext, w http.Resp userInfo.UserId = 39 ws := l.setConnPool(conn, userInfo) defer ws.close() - go func() { - //把连接成功消息发回去 - time.Sleep(time.Second * 2) //兼容下火狐 - b := ws.respondDataFormat(constants.WEBSOCKET_CONNECT_SUCCESS, uniqueId) - _ = conn.WriteMessage(websocket.TextMessage, b) - }() //循环读客户端信息 go ws.readLoop() //循环把数据发送给客户端 @@ -156,6 +150,12 @@ func (l *DataTransferLogic) setConnPool(conn *websocket.Conn, userInfo auth.User } //保存连接 mapConnPool.Store(uniqueId, ws) + go func() { + //把连接成功消息发回去 + time.Sleep(time.Second * 2) //兼容下火狐 + b := ws.respondDataFormat(constants.WEBSOCKET_CONNECT_SUCCESS, uniqueId) + _ = conn.WriteMessage(websocket.TextMessage, b) + }() return ws } func (l *DataTransferLogic) getUniqueId() string { From b0e534de8c35f3dbd6725f0c5e19d8356c3c217e Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Fri, 11 Aug 2023 10:12:25 +0800 Subject: [PATCH 006/151] fix --- server/render/consumer/assemble_render_data.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server/render/consumer/assemble_render_data.go b/server/render/consumer/assemble_render_data.go index 98184dca..5b041711 100644 --- a/server/render/consumer/assemble_render_data.go +++ b/server/render/consumer/assemble_render_data.go @@ -25,7 +25,7 @@ import ( type pythonApiRsp struct { Id string `json:"id"` //物料模板的id LogoUrl string `json:"logo_url"` //logo地址 - result string `json:"result"` //图片base64 + Result string `json:"result"` //图片base64 } // 消费渲染需要组装的数据 @@ -258,7 +258,7 @@ func getCombineImage(ctx context.Context, svcCtx *svc.ServiceContext, parseInfo } uploadRes, err := upload.UploadFileByBase64(&file.UploadBaseReq{ FileHash: combineHash, - FileData: pythonApiInfo.result, + FileData: pythonApiInfo.Result, UploadBucket: 1, ApiType: 2, UserId: parseInfo.RenderData.UserId, From 84749f4d14458ca40f2cae2d91dff9706698a7d9 Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Fri, 11 Aug 2023 10:49:29 +0800 Subject: [PATCH 007/151] fix --- constants/websocket.go | 6 +++++ .../internal/logic/datatransferlogic.go | 8 +++++- .../internal/logic/ws_resume_last_connect.go | 27 +++++++++++++++++++ 3 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 server/websocket/internal/logic/ws_resume_last_connect.go diff --git a/constants/websocket.go b/constants/websocket.go index be28eb32..ced0c947 100644 --- a/constants/websocket.go +++ b/constants/websocket.go @@ -8,6 +8,12 @@ const ( WEBSOCKET_UNAUTH = "WEBSOCKET_UNAUTH" //ws连接成功 WEBSOCKET_CONNECT_SUCCESS = "WEBSOCKET_CONNECT_SUCCESS" + //请求恢复为上次连接的标识 + 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/datatransferlogic.go b/server/websocket/internal/logic/datatransferlogic.go index 825ce08a..16f822aa 100644 --- a/server/websocket/internal/logic/datatransferlogic.go +++ b/server/websocket/internal/logic/datatransferlogic.go @@ -112,6 +112,7 @@ func (l *DataTransferLogic) DataTransfer(svcCtx *svc.ServiceContext, w http.Resp //测试的目前写死 39 var userInfo auth.UserInfo userInfo.UserId = 39 + //设置连接 ws := l.setConnPool(conn, userInfo) defer ws.close() //循环读客户端信息 @@ -126,7 +127,7 @@ func (l *DataTransferLogic) DataTransfer(svcCtx *svc.ServiceContext, w http.Resp ws.heartbeat() } -// 获取唯一id +// 设置连接 func (l *DataTransferLogic) setConnPool(conn *websocket.Conn, userInfo auth.UserInfo) wsConnectItem { publicMutex.Lock() defer publicMutex.Unlock() @@ -158,6 +159,8 @@ func (l *DataTransferLogic) setConnPool(conn *websocket.Conn, userInfo auth.User }() return ws } + +// 获取唯一id func (l *DataTransferLogic) getUniqueId() string { uniqueId := uuid.New().String() + time.Now().Format("20060102150405") if _, ok := mapConnPool.Load(uniqueId); ok { @@ -309,6 +312,9 @@ func (w *wsConnectItem) dealwithReciveData(data []byte) { //图片渲染 case constants.WEBSOCKET_RENDER_IMAGE: w.renderImage(d) + //刷新重连请求恢复上次连接的标识 + case constants.WEBSOCKET_REQUEST_RESUME_LAST_CONNECT: + w.resumeLateConnect(d) default: } diff --git a/server/websocket/internal/logic/ws_resume_last_connect.go b/server/websocket/internal/logic/ws_resume_last_connect.go new file mode 100644 index 00000000..39f29414 --- /dev/null +++ b/server/websocket/internal/logic/ws_resume_last_connect.go @@ -0,0 +1,27 @@ +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_REQUEST_RESUME_LAST_CONNECT_SUCCESS, clientId) + w.sendToOutChan(rsp) + return +} From 266ff9075f3d3f041d990a5ec0e0c09170171a2e Mon Sep 17 00:00:00 2001 From: Hiven Date: Fri, 11 Aug 2023 14:27:46 +0800 Subject: [PATCH 008/151] =?UTF-8?q?fix:=E6=9B=B4=E6=96=B0=E6=B5=8B?= =?UTF-8?q?=E8=AF=95=E7=8E=AF=E5=A2=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/resource/etc/resource.yaml | 3 ++- server/upload/etc/upload.yaml | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/server/resource/etc/resource.yaml b/server/resource/etc/resource.yaml index b57c5f1c..8e70bf17 100644 --- a/server/resource/etc/resource.yaml +++ b/server/resource/etc/resource.yaml @@ -16,4 +16,5 @@ AWS: Token: BLMService: LogoCombine: - Url: "http://192.168.1.7:45678/LogoCombine" \ No newline at end of file + #Url: "http://192.168.1.7:45678/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 5a8a5cb6..3e1c96f3 100644 --- a/server/upload/etc/upload.yaml +++ b/server/upload/etc/upload.yaml @@ -15,4 +15,5 @@ AWS: Token: BLMService: ImageProcess: - Url: "http://192.168.1.7:45678/FeatureExtraction" + #Url: "http://192.168.1.7:45678/FeatureExtraction" + Url: "http://18.119.109.254:8999/FeatureExtraction" From 0edcf1e65f16b364c06d840e7303d0140960c9aa Mon Sep 17 00:00:00 2001 From: Hiven Date: Fri, 11 Aug 2023 14:38:57 +0800 Subject: [PATCH 009/151] =?UTF-8?q?fix:=E6=9B=B4=E6=96=B0=E6=B5=8B?= =?UTF-8?q?=E8=AF=95=E7=8E=AF=E5=A2=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/product-template-tag/etc/product-template-tag.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/product-template-tag/etc/product-template-tag.yaml b/server/product-template-tag/etc/product-template-tag.yaml index 253828fb..75f4d2d3 100644 --- a/server/product-template-tag/etc/product-template-tag.yaml +++ b/server/product-template-tag/etc/product-template-tag.yaml @@ -1,6 +1,6 @@ Name: product-template-tag Host: 0.0.0.0 -Port: 9916 +Port: 9917 SourceMysql: fusentest:XErSYmLELKMnf3Dh@tcp(110.41.19.98:3306)/fusentest Auth: AccessSecret: fusen2023 From dbe6e99f2d6f51f351536ab8a2e4eab201fb3fc2 Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Fri, 11 Aug 2023 14:52:16 +0800 Subject: [PATCH 010/151] fix --- model/gmodel/fs_product_template_v2_logic.go | 27 ++++ .../internal/logic/gettemplatebypidlogic.go | 125 +++++------------- server/product/internal/types/types.go | 7 +- server_api/product.api | 10 +- 4 files changed, 74 insertions(+), 95 deletions(-) diff --git a/model/gmodel/fs_product_template_v2_logic.go b/model/gmodel/fs_product_template_v2_logic.go index d760f398..c29c285d 100755 --- a/model/gmodel/fs_product_template_v2_logic.go +++ b/model/gmodel/fs_product_template_v2_logic.go @@ -139,3 +139,30 @@ func (t *FsProductTemplateV2Model) FindAllByModelIdsTemplateTag(ctx context.Cont err = db.Find(&resp).Error return resp, err } + +// 获取产品某个物料下的第一个模板 +func (t *FsProductTemplateV2Model) GetSizeLatestTemplate(ctx context.Context, ids []int64, productId int64) (resp *FsProductTemplateV2, err error) { + err = t.db.WithContext(ctx).Model(&FsProductTemplateV2{}). + Where("id in (?) and product_id = ? and status = ? and is_del = ?", ids, productId, 1, 0). + Order("sort ASC").Take(&resp).Error + return resp, err +} + +// 获取产品第一个物料下的第一个模板 +func (t *FsProductTemplateV2Model) GetProductLatestTemplate(ctx context.Context, ids []int64, productId int64) (resp *FsProductTemplateV2, err error) { + err = t.db.WithContext(ctx).Model(&FsProductTemplateV2{}). + Where("id in (?) and product_id = ? and status = ? and is_del = ?", ids, productId, 1, 0). + Order("sort ASC").Take(&resp).Error + return resp, err +} + +// 获取产品在指定模板标签下的所有模板 +func (t *FsProductTemplateV2Model) GetListByProductAndTemplateTag(ctx context.Context, templateTagId string, productId int64, fields ...string) (resp []FsProductTemplateV2, err error) { + db := t.db.WithContext(ctx).Model(&FsProductTemplateV2{}). + Where("tag = ? and product_id = ? and status = ? and is_del = ?", templateTagId, productId, 1, 0) + if len(fields) > 0 { + db = db.Select(fields[0]) + } + err = db.Find(&resp).Error + return resp, err +} diff --git a/server/product/internal/logic/gettemplatebypidlogic.go b/server/product/internal/logic/gettemplatebypidlogic.go index 18ccb887..876f6274 100644 --- a/server/product/internal/logic/gettemplatebypidlogic.go +++ b/server/product/internal/logic/gettemplatebypidlogic.go @@ -4,12 +4,10 @@ import ( "encoding/json" "errors" "fmt" - "fusenapi/constants" + "fusenapi/model/gmodel" "fusenapi/utils/auth" "fusenapi/utils/basic" - "fusenapi/utils/image" "gorm.io/gorm" - "strconv" "strings" "context" @@ -39,13 +37,11 @@ func (l *GetTemplateByPidLogic) GetTemplateByPid(req *types.GetTemplateByPidReq, if req.Pid == "" { return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "err param:pid is empty") } - if req.Size > 0 { - req.Size = image.GetCurrentSize(req.Size) - } if req.ProductTemplateTagId <= 0 { return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "err param:product_template_tag_id") } - //获取产品信息(只是获取id) + + //获取产品信息(只获取id) productInfo, err := l.svcCtx.AllModels.FsProduct.FindOneBySn(l.ctx, req.Pid, "id") if err != nil { if errors.Is(err, gorm.ErrRecordNotFound) { @@ -54,99 +50,46 @@ func (l *GetTemplateByPidLogic) GetTemplateByPid(req *types.GetTemplateByPidReq, logx.Error(err) return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get product info") } - //获取尺寸ids(只获取id) - sizeList, err := l.svcCtx.AllModels.FsProductSize.GetAllByProductIds(l.ctx, []int64{productInfo.Id}, "id") + //获取该产品该模板标签下的模板列表(只获取id) + templateList, err := l.svcCtx.AllModels.FsProductTemplateV2. + GetListByProductAndTemplateTag(l.ctx, fmt.Sprintf("%d", req.ProductTemplateTagId), productInfo.Id, "id") if err != nil { logx.Error(err) - return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get size list") + return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get templates") } - if len(sizeList) == 0 { - return resp.SetStatusWithMessage(basic.CodeOK, "success:size list is empty") + if len(templateList) == 0 { + return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "templates are not exists") } - sizeIds := make([]int64, 0, len(sizeList)) - for _, v := range sizeList { - sizeIds = append(sizeIds, v.Id) + templateIds := make([]int64, 0, len(templateList)) + for _, v := range templateList { + templateIds = append(templateIds, v.Id) + } + var ( + templateInfo *gmodel.FsProductTemplateV2 + ) + //传了指定物料,则获取该物料的第一个模板 + if req.ProductSizeId > 0 { + templateInfo, err = l.svcCtx.AllModels.FsProductTemplateV2.GetSizeLatestTemplate(l.ctx, templateIds, productInfo.Id) + } else { //没有指定物料则获取第一个物料的第一个模板 + templateInfo, err = l.svcCtx.AllModels.FsProductTemplateV2.GetProductLatestTemplate(l.ctx, templateIds, productInfo.Id) } - //获取模型数据 - modelList, err := l.svcCtx.AllModels.FsProductModel3d.GetAllBySizeIdsTag(l.ctx, sizeIds, constants.TAG_MODEL, "id,size_id") if err != nil { + if errors.Is(err, gorm.ErrRecordNotFound) { + return resp.SetStatusWithMessage(basic.CodeDbRecordNotFoundErr, "template info not found") + } logx.Error(err) - return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get model list") + return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get template info") } - if len(modelList) == 0 { - return resp.SetStatusWithMessage(basic.CodeOK, "success:model list is empty") + if templateInfo.TemplateInfo == nil || *templateInfo.TemplateInfo == "" { + return resp.SetStatusWithMessage(basic.CodeJsonErr, "template info is not set") } - modelIds := make([]int64, 0, len(modelList)) - mapModel := make(map[int64]int) - for k, v := range modelList { - modelIds = append(modelIds, v.Id) - mapModel[v.Id] = k - } - //获取模板数据 - productTemplateList, err := l.svcCtx.AllModels.FsProductTemplateV2.FindAllByModelIdsTemplateTag(l.ctx, modelIds, fmt.Sprintf("%d", req.ProductTemplateTagId), "sort DESC") - if err != nil { + var info interface{} + if err = json.Unmarshal([]byte(*templateInfo.TemplateInfo), &info); err != nil { logx.Error(err) - return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get product templates") + return resp.SetStatusWithMessage(basic.CodeJsonErr, "failed to parse json product template info:", templateInfo.Id) } - if len(productTemplateList) == 0 { - return resp.SetStatusWithMessage(basic.CodeOK, "success:product template list is empty") - } - tagIds := make([]int64, 0, len(productTemplateList)) - for _, v := range productTemplateList { - if *v.Tag == "" { - continue - } - tag, err := strconv.ParseInt(*v.Tag, 10, 64) - if err != nil { - logx.Error(err) - return resp.SetStatusWithMessage(basic.CodeServiceErr, "template tag is not a number:"+*v.Tag) - } - tagIds = append(tagIds, tag) - } - //获取模板标签列表 - templateTagList, err := l.svcCtx.AllModels.FsProductTemplateTags.GetListByIds(l.ctx, tagIds) - if err != nil { - logx.Error(err) - return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get template tag list") - } - mapTemplateTag := make(map[string]int) - for k, v := range templateTagList { - mapTemplateTag[fmt.Sprintf("%d", v.Id)] = k - } - mapRsp := make(map[string][]interface{}) - for _, v := range productTemplateList { - //过滤没有设置详细数据的模板 - if v.TemplateInfo == nil || *v.TemplateInfo == "" { - continue - } - var templateInfo map[string]interface{} - if err = json.Unmarshal([]byte(*v.TemplateInfo), &templateInfo); err != nil { - logx.Error(err) - return resp.SetStatusWithMessage(basic.CodeJsonErr, "failed to parse json:template info") - } - if templateInfo["cover"] != nil && templateInfo["cover"].(string) != "" { - cover := strings.Split(templateInfo["cover"].(string), ".") - if req.Size >= 200 && len(cover) >= 2 { - templateInfo["cover"] = fmt.Sprintf("%s_%d.%s", cover[0], req.Size, cover[1]) - } - } else { - templateInfo["cover"] = "" - } - templateInfo["tag_name"] = "" - if tagIndex, ok := mapTemplateTag[*v.Tag]; ok { - templateInfo["tag_name"] = *templateTagList[tagIndex].Title - } - templateInfo["title"] = *v.Title - modelIndex, ok := mapModel[*v.ModelId] - if !ok { - continue - } - key := fmt.Sprintf("_%d", *modelList[modelIndex].SizeId) - if _, ok = mapRsp[key]; ok { - mapRsp[key] = append(mapRsp[key], templateInfo) - } else { - mapRsp[key] = []interface{}{templateInfo} - } - } - return resp.SetStatusWithMessage(basic.CodeOK, "success", mapRsp) + return resp.SetStatusWithMessage(basic.CodeOK, "success", types.GetTemplateByPidRsp{ + TemplateId: templateInfo.Id, + TemplateInfo: info, + }) } diff --git a/server/product/internal/types/types.go b/server/product/internal/types/types.go index cf94b40b..8e718fb7 100644 --- a/server/product/internal/types/types.go +++ b/server/product/internal/types/types.go @@ -341,8 +341,13 @@ type GetSizeByPidRsp struct { type GetTemplateByPidReq struct { Pid string `form:"pid"` - Size uint32 `form:"size"` ProductTemplateTagId int64 `form:"product_template_tag_id"` + ProductSizeId int64 `form:"product_size_id,optional"` +} + +type GetTemplateByPidRsp struct { + TemplateId int64 `json:"template_id"` //模板id + TemplateInfo interface{} `json:"template_info"` //模板信息 } type GetFittingByPidReq struct { diff --git a/server_api/product.api b/server_api/product.api index b4aca200..28ca4ae7 100644 --- a/server_api/product.api +++ b/server_api/product.api @@ -50,7 +50,7 @@ service product { //获取产品尺寸列表 @handler GetSizeByPidHandler get /api/product/get_size_by_pid(GetSizeByPidReq) returns (response); - //获取产品模板列表 + //获取产品模板 @handler GetTemplateByPidHandler get /api/product/get_template_by_pid(GetTemplateByPidReq) returns (response); //获取产品配件数据 @@ -383,11 +383,15 @@ type GetSizeByPidRsp { IsPopular bool `json:"is_popular"` //是否受欢迎 MinPrice float64 `json:"min_price"` //最小价格 } -//获取产品模板列表 +//获取产品模板 type GetTemplateByPidReq { Pid string `form:"pid"` - Size uint32 `form:"size"` ProductTemplateTagId int64 `form:"product_template_tag_id"` + ProductSizeId int64 `form:"product_size_id,optional"` +} +type GetTemplateByPidRsp { + TemplateId int64 `json:"template_id"` //模板id + TemplateInfo interface{} `json:"template_info"` //模板信息 } //获取产品配件数据 type GetFittingByPidReq { From 94e15c1c19101f41c57220f334d64a09cd6daa48 Mon Sep 17 00:00:00 2001 From: Hiven Date: Fri, 11 Aug 2023 15:28:03 +0800 Subject: [PATCH 011/151] =?UTF-8?q?fix:=E6=9B=B4=E6=96=B0=E6=B5=8B?= =?UTF-8?q?=E8=AF=95=E7=8E=AF=E5=A2=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/resource/etc/resource.yaml | 4 ++-- server/resource/internal/logic/logocombinelogic.go | 11 ++++++++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/server/resource/etc/resource.yaml b/server/resource/etc/resource.yaml index 8e70bf17..cc596ed4 100644 --- a/server/resource/etc/resource.yaml +++ b/server/resource/etc/resource.yaml @@ -16,5 +16,5 @@ AWS: Token: BLMService: LogoCombine: - #Url: "http://192.168.1.7:45678/LogoCombine" - Url: "http://18.119.109.254:8999/LogoCombine" \ No newline at end of file + 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 71fca87d..b392a138 100644 --- a/server/resource/internal/logic/logocombinelogic.go +++ b/server/resource/internal/logic/logocombinelogic.go @@ -2,6 +2,7 @@ package logic import ( "encoding/json" + "errors" "fusenapi/model/gmodel" "fusenapi/utils/auth" "fusenapi/utils/basic" @@ -17,6 +18,7 @@ import ( "fusenapi/server/resource/internal/types" "github.com/zeromicro/go-zero/core/logx" + "gorm.io/gorm" ) type LogoCombineLogic struct { @@ -75,8 +77,10 @@ func (l *LogoCombineLogic) LogoCombine(req *types.LogoCombineReq, userinfo *auth }) } else { if err != nil { - logx.Error(err) - return resp.SetStatus(basic.CodeDbSqlErr, "LogoCombine error") + if !errors.Is(err, gorm.ErrRecordNotFound) { + logx.Error(err) + return resp.SetStatus(basic.CodeDbSqlErr, "LogoCombine error") + } } } @@ -134,8 +138,9 @@ func (l *LogoCombineLogic) LogoCombine(req *types.LogoCombineReq, userinfo *auth logx.Error(err) return resp.SetStatus(basic.CodeFileLogoCombineErr, "service read fail") } + ress := string(b) - if string(b) == "Internal Server Error" { + if ress == "Internal Server Error" { return resp.SetStatus(basic.CodeFileLogoCombineErr, "service read fail") } From a587a19dbfc146fcfe9392afeb0564a6323fe1f6 Mon Sep 17 00:00:00 2001 From: Hiven Date: Fri, 11 Aug 2023 15:30:55 +0800 Subject: [PATCH 012/151] =?UTF-8?q?fix:=E6=9B=B4=E6=96=B0=E6=B5=8B?= =?UTF-8?q?=E8=AF=95=E7=8E=AF=E5=A2=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/resource/etc/resource.yaml | 4 ++-- server/resource/internal/logic/logocombinelogic.go | 9 +++++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/server/resource/etc/resource.yaml b/server/resource/etc/resource.yaml index cc596ed4..befe8caf 100644 --- a/server/resource/etc/resource.yaml +++ b/server/resource/etc/resource.yaml @@ -16,5 +16,5 @@ AWS: Token: BLMService: LogoCombine: - Url: "http://192.168.1.7:8999/LogoCombine" - #Url: "http://18.119.109.254:8999/LogoCombine" \ No newline at end of file + #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 b392a138..86da8d7c 100644 --- a/server/resource/internal/logic/logocombinelogic.go +++ b/server/resource/internal/logic/logocombinelogic.go @@ -6,11 +6,12 @@ import ( "fusenapi/model/gmodel" "fusenapi/utils/auth" "fusenapi/utils/basic" + "fusenapi/utils/curl" "fusenapi/utils/file" "fusenapi/utils/hash" "io" - "net/http" "strings" + "time" "context" @@ -127,7 +128,11 @@ func (l *LogoCombineLogic) LogoCombine(req *types.LogoCombineReq, userinfo *auth postMap["param_data"] = combineParam postMapB, _ := json.Marshal(postMap) - result, err := http.Post(l.svcCtx.Config.BLMService.LogoCombine.Url, "application/json", strings.NewReader(string(postMapB))) + //result, err := http.Post(l.svcCtx.Config.BLMService.LogoCombine.Url, "application/json", strings.NewReader(string(postMapB))) + var headerData = make(map[string]string, 1) + headerData["Content-Type"] = "application/json" + result, err := curl.ApiCall(l.svcCtx.Config.BLMService.LogoCombine.Url, "POST", headerData, strings.NewReader(string(postMapB)), time.Second*20) + if err != nil { logx.Error(err) return resp.SetStatus(basic.CodeFileLogoCombineErr, "service post fail") From 9b0a18fcd8077c05c98418dc1a47ef5b29692b78 Mon Sep 17 00:00:00 2001 From: Hiven Date: Fri, 11 Aug 2023 17:22:14 +0800 Subject: [PATCH 013/151] =?UTF-8?q?fix:=E6=9B=B4=E6=96=B0=E6=B5=8B?= =?UTF-8?q?=E8=AF=95=E7=8E=AF=E5=A2=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/upload/internal/logic/uploadlogologic.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/server/upload/internal/logic/uploadlogologic.go b/server/upload/internal/logic/uploadlogologic.go index ea98bf45..88744393 100644 --- a/server/upload/internal/logic/uploadlogologic.go +++ b/server/upload/internal/logic/uploadlogologic.go @@ -168,5 +168,12 @@ func (l *UploadLogoLogic) UploadLogo(req *types.UploadLogoReq, userinfo *auth.Us return resp.SetStatus(basic.CodeFileUploadLogoErr, "service fail") } - return resp.SetStatus(basic.CodeOK) + // 返回成功的响应和上传URL + return resp.SetStatus(basic.CodeOK, map[string]interface{}{ + "upload_data": UploadUrl{ + Status: 1, + ResourceId: uploadRes.ResourceId, + ResourceUrl: uploadRes.ResourceUrl, + }, + }) } From 48afd3105f5778c9524f2791c352a8a934be015d Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Fri, 11 Aug 2023 18:59:03 +0800 Subject: [PATCH 014/151] fix --- model/gmodel/fs_product_model3d_logic.go | 11 +++ model/gmodel/fs_product_template_v2_gen.go | 1 + model/gmodel/fs_product_template_v2_logic.go | 16 ---- .../internal/logic/gettemplatebypidlogic.go | 91 +++++++++++-------- server_api/product.api | 5 - 5 files changed, 65 insertions(+), 59 deletions(-) diff --git a/model/gmodel/fs_product_model3d_logic.go b/model/gmodel/fs_product_model3d_logic.go index 9cb2fe91..741fdac2 100755 --- a/model/gmodel/fs_product_model3d_logic.go +++ b/model/gmodel/fs_product_model3d_logic.go @@ -101,3 +101,14 @@ func (d *FsProductModel3dModel) FindOneJoinSize(ctx context.Context, productId i Order("s.sort ASC").Take(&resp).Error return resp, err } + +func (d *FsProductModel3dModel) GetOneBySizeIdTag(ctx context.Context, sizeId int64, tag int64, fields ...string) (resp *FsProductModel3d, err error) { + db := d.db.WithContext(ctx).Model(&FsProductModel3d{}). + Where("`size_id` = ? and `tag` = ? and `status` = ?", sizeId, tag, 1). + Order("sort DESC") + if len(fields) != 0 { + db = db.Select(fields[0]) + } + err = db.Take(&resp).Error + return resp, err +} diff --git a/model/gmodel/fs_product_template_v2_gen.go b/model/gmodel/fs_product_template_v2_gen.go index 5e14427f..d72b388a 100644 --- a/model/gmodel/fs_product_template_v2_gen.go +++ b/model/gmodel/fs_product_template_v2_gen.go @@ -22,6 +22,7 @@ type FsProductTemplateV2 struct { Ctime *int64 `gorm:"default:0;" json:"ctime"` // 添加时间 Tag *string `gorm:"default:'';" json:"tag"` // 标签(用户自填) 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"` // } diff --git a/model/gmodel/fs_product_template_v2_logic.go b/model/gmodel/fs_product_template_v2_logic.go index c29c285d..57109ca8 100755 --- a/model/gmodel/fs_product_template_v2_logic.go +++ b/model/gmodel/fs_product_template_v2_logic.go @@ -140,22 +140,6 @@ func (t *FsProductTemplateV2Model) FindAllByModelIdsTemplateTag(ctx context.Cont return resp, err } -// 获取产品某个物料下的第一个模板 -func (t *FsProductTemplateV2Model) GetSizeLatestTemplate(ctx context.Context, ids []int64, productId int64) (resp *FsProductTemplateV2, err error) { - err = t.db.WithContext(ctx).Model(&FsProductTemplateV2{}). - Where("id in (?) and product_id = ? and status = ? and is_del = ?", ids, productId, 1, 0). - Order("sort ASC").Take(&resp).Error - return resp, err -} - -// 获取产品第一个物料下的第一个模板 -func (t *FsProductTemplateV2Model) GetProductLatestTemplate(ctx context.Context, ids []int64, productId int64) (resp *FsProductTemplateV2, err error) { - err = t.db.WithContext(ctx).Model(&FsProductTemplateV2{}). - Where("id in (?) and product_id = ? and status = ? and is_del = ?", ids, productId, 1, 0). - Order("sort ASC").Take(&resp).Error - return resp, err -} - // 获取产品在指定模板标签下的所有模板 func (t *FsProductTemplateV2Model) GetListByProductAndTemplateTag(ctx context.Context, templateTagId string, productId int64, fields ...string) (resp []FsProductTemplateV2, err error) { db := t.db.WithContext(ctx).Model(&FsProductTemplateV2{}). diff --git a/server/product/internal/logic/gettemplatebypidlogic.go b/server/product/internal/logic/gettemplatebypidlogic.go index 876f6274..51432f3d 100644 --- a/server/product/internal/logic/gettemplatebypidlogic.go +++ b/server/product/internal/logic/gettemplatebypidlogic.go @@ -4,7 +4,7 @@ import ( "encoding/json" "errors" "fmt" - "fusenapi/model/gmodel" + "fusenapi/constants" "fusenapi/utils/auth" "fusenapi/utils/basic" "gorm.io/gorm" @@ -40,7 +40,6 @@ func (l *GetTemplateByPidLogic) GetTemplateByPid(req *types.GetTemplateByPidReq, if req.ProductTemplateTagId <= 0 { return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "err param:product_template_tag_id") } - //获取产品信息(只获取id) productInfo, err := l.svcCtx.AllModels.FsProduct.FindOneBySn(l.ctx, req.Pid, "id") if err != nil { @@ -50,46 +49,62 @@ func (l *GetTemplateByPidLogic) GetTemplateByPid(req *types.GetTemplateByPidReq, logx.Error(err) return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get product info") } - //获取该产品该模板标签下的模板列表(只获取id) - templateList, err := l.svcCtx.AllModels.FsProductTemplateV2. - GetListByProductAndTemplateTag(l.ctx, fmt.Sprintf("%d", req.ProductTemplateTagId), productInfo.Id, "id") - if err != nil { - logx.Error(err) - return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get templates") - } - if len(templateList) == 0 { - return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "templates are not exists") - } - templateIds := make([]int64, 0, len(templateList)) - for _, v := range templateList { - templateIds = append(templateIds, v.Id) - } - var ( - templateInfo *gmodel.FsProductTemplateV2 - ) - //传了指定物料,则获取该物料的第一个模板 - if req.ProductSizeId > 0 { - templateInfo, err = l.svcCtx.AllModels.FsProductTemplateV2.GetSizeLatestTemplate(l.ctx, templateIds, productInfo.Id) - } else { //没有指定物料则获取第一个物料的第一个模板 - templateInfo, err = l.svcCtx.AllModels.FsProductTemplateV2.GetProductLatestTemplate(l.ctx, templateIds, productInfo.Id) - } - if err != nil { - if errors.Is(err, gorm.ErrRecordNotFound) { - return resp.SetStatusWithMessage(basic.CodeDbRecordNotFoundErr, "template info not found") + //没有指定物料 + sizeIds := make([]int64, 0, 10) + if req.ProductSizeId <= 0 { + //获取产品所有物料 + sizeList, err := l.svcCtx.AllModels.FsProductSize.GetAllByProductIds(l.ctx, []int64{productInfo.Id}, "id") + if err != nil { + logx.Error(err) + return resp.SetStatusWithMessage(basic.CodeDbRecordNotFoundErr, "failed to get product size list") } + if len(sizeList) == 0 { + return resp.SetStatusWithMessage(basic.CodeDbRecordNotFoundErr, "product size list is empty") + } + for _, v := range sizeList { + sizeIds = append(sizeIds, v.Id) + } + } else { //指定物料 + sizeIds = append(sizeIds, req.ProductSizeId) + } + //根据尺寸id获取模型id + modelList, err := l.svcCtx.AllModels.FsProductModel3d.GetAllBySizeIdsTag(l.ctx, sizeIds, constants.TAG_MODEL, "id") + if err != nil { logx.Error(err) - return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get template info") + return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get model list") } - if templateInfo.TemplateInfo == nil || *templateInfo.TemplateInfo == "" { - return resp.SetStatusWithMessage(basic.CodeJsonErr, "template info is not set") + if len(modelList) == 0 { + return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "model list is empty") } - var info interface{} - if err = json.Unmarshal([]byte(*templateInfo.TemplateInfo), &info); err != nil { + modelIds := make([]int64, 0, len(modelList)) + for _, v := range modelList { + modelIds = append(modelIds, v.Id) + } + //查询模型ids下对应tag标签的模板 + templateList, err := l.svcCtx.AllModels.FsProductTemplateV2.FindAllByModelIdsTemplateTag(l.ctx, modelIds, fmt.Sprintf("%d", req.ProductTemplateTagId), "") + if err != nil { logx.Error(err) - return resp.SetStatusWithMessage(basic.CodeJsonErr, "failed to parse json product template info:", templateInfo.Id) + return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get template list") } - return resp.SetStatusWithMessage(basic.CodeOK, "success", types.GetTemplateByPidRsp{ - TemplateId: templateInfo.Id, - TemplateInfo: info, - }) + rspList := make([]interface{}, 0, len(templateList)) + for _, templateInfo := range templateList { + //没有设置模板据不要 + if templateInfo.TemplateInfo == nil || *templateInfo.TemplateInfo == "" { + continue + } + //基础模板信息 + var info interface{} + if err = json.Unmarshal([]byte(*templateInfo.TemplateInfo), &info); err != nil { + logx.Error(err) + return resp.SetStatusWithMessage(basic.CodeJsonErr, "failed to parse json product template info:", templateInfo.Id) + } + //后台隐藏/显示信息 + var switchInfo interface{} + if templateInfo.SwitchInfo != nil && *templateInfo.SwitchInfo != "" { + _ = json.Unmarshal([]byte(*templateInfo.SwitchInfo), &switchInfo) + } + // todo 继续下周 + rspList = append(rspList, map[string]interface{}{}) + } + return nil } diff --git a/server_api/product.api b/server_api/product.api index 28ca4ae7..e710a978 100644 --- a/server_api/product.api +++ b/server_api/product.api @@ -387,11 +387,6 @@ type GetSizeByPidRsp { type GetTemplateByPidReq { Pid string `form:"pid"` ProductTemplateTagId int64 `form:"product_template_tag_id"` - ProductSizeId int64 `form:"product_size_id,optional"` -} -type GetTemplateByPidRsp { - TemplateId int64 `json:"template_id"` //模板id - TemplateInfo interface{} `json:"template_info"` //模板信息 } //获取产品配件数据 type GetFittingByPidReq { From 538d9ff4cf35c91f53f387bee0a6297d545103ef Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Mon, 14 Aug 2023 10:51:39 +0800 Subject: [PATCH 015/151] fix --- .../internal/logic/gettemplatebypidlogic.go | 33 ++++++++++++++----- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/server/product/internal/logic/gettemplatebypidlogic.go b/server/product/internal/logic/gettemplatebypidlogic.go index 51432f3d..e036fa15 100644 --- a/server/product/internal/logic/gettemplatebypidlogic.go +++ b/server/product/internal/logic/gettemplatebypidlogic.go @@ -67,8 +67,8 @@ func (l *GetTemplateByPidLogic) GetTemplateByPid(req *types.GetTemplateByPidReq, } else { //指定物料 sizeIds = append(sizeIds, req.ProductSizeId) } - //根据尺寸id获取模型id - modelList, err := l.svcCtx.AllModels.FsProductModel3d.GetAllBySizeIdsTag(l.ctx, sizeIds, constants.TAG_MODEL, "id") + //根据尺寸id获取模型 + modelList, err := l.svcCtx.AllModels.FsProductModel3d.GetAllBySizeIdsTag(l.ctx, sizeIds, constants.TAG_MODEL) if err != nil { logx.Error(err) return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get model list") @@ -77,8 +77,10 @@ func (l *GetTemplateByPidLogic) GetTemplateByPid(req *types.GetTemplateByPidReq, return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "model list is empty") } modelIds := make([]int64, 0, len(modelList)) - for _, v := range modelList { + mapModel := make(map[int64]int) + for k, v := range modelList { modelIds = append(modelIds, v.Id) + mapModel[v.Id] = k } //查询模型ids下对应tag标签的模板 templateList, err := l.svcCtx.AllModels.FsProductTemplateV2.FindAllByModelIdsTemplateTag(l.ctx, modelIds, fmt.Sprintf("%d", req.ProductTemplateTagId), "") @@ -86,25 +88,38 @@ func (l *GetTemplateByPidLogic) GetTemplateByPid(req *types.GetTemplateByPidReq, logx.Error(err) return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get template list") } - rspList := make([]interface{}, 0, len(templateList)) + rsp := make(map[string][]interface{}) for _, templateInfo := range templateList { //没有设置模板据不要 if templateInfo.TemplateInfo == nil || *templateInfo.TemplateInfo == "" { continue } + modelIndex, ok := mapModel[*templateInfo.ModelId] + if !ok { + continue + } //基础模板信息 - var info interface{} + var info map[string]map[string]interface{} if err = json.Unmarshal([]byte(*templateInfo.TemplateInfo), &info); err != nil { logx.Error(err) - return resp.SetStatusWithMessage(basic.CodeJsonErr, "failed to parse json product template info:", templateInfo.Id) + return resp.SetStatusWithMessage(basic.CodeJsonErr, fmt.Sprintf("failed to parse json product template info(may be old data):%d", templateInfo.Id)) } //后台隐藏/显示信息 var switchInfo interface{} if templateInfo.SwitchInfo != nil && *templateInfo.SwitchInfo != "" { _ = json.Unmarshal([]byte(*templateInfo.SwitchInfo), &switchInfo) } - // todo 继续下周 - rspList = append(rspList, map[string]interface{}{}) + modelInfo := modelList[modelIndex] + var material interface{} + if info["module_data"] != nil && info["module_data"]["material"] != nil { + material = info["module_data"]["material"] + } + mapKey := fmt.Sprintf("_%d", *modelInfo.SizeId) + rsp[mapKey] = append(rsp[mapKey], map[string]interface{}{ + "id": templateInfo.Id, + "material": material, + "material_data": switchInfo, + }) } - return nil + return resp.SetStatusWithMessage(basic.CodeOK, "success", rsp) } From cfc7b2209069a021500f72b71a264ff49c7ceec7 Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Mon, 14 Aug 2023 11:04:25 +0800 Subject: [PATCH 016/151] fix --- model/gmodel/fs_merchant_category_gen.go | 25 +++++++++++++++++++ model/gmodel/fs_merchant_category_logic.go | 2 ++ model/gmodel/fs_product_recommend_gen.go | 9 ++++--- model/gmodel/fs_product_recommend_logic.go | 10 +++++--- model/gmodel/fs_product_template_v2_gen.go | 16 ++++++------ model/gmodel/var_gen.go | 2 ++ .../homepagerecommendproductlistlogic.go | 7 +++--- server/product/internal/types/types.go | 9 ++----- server_api/product.api | 3 ++- 9 files changed, 57 insertions(+), 26 deletions(-) create mode 100644 model/gmodel/fs_merchant_category_gen.go create mode 100644 model/gmodel/fs_merchant_category_logic.go diff --git a/model/gmodel/fs_merchant_category_gen.go b/model/gmodel/fs_merchant_category_gen.go new file mode 100644 index 00000000..732ec88b --- /dev/null +++ b/model/gmodel/fs_merchant_category_gen.go @@ -0,0 +1,25 @@ +package gmodel + +import ( + "gorm.io/gorm" +) + +// fs_merchant_category 商户类型表 +type FsMerchantCategory struct { + Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` // Id + ZnName *string `gorm:"default:'';" json:"zn_name"` // 中文名 + EnName *string `gorm:"default:'';" json:"en_name"` // 英文名 + Icon *string `gorm:"default:'';" json:"icon"` // 图标 + RecommendProduct *string `gorm:"default:'';" json:"recommend_product"` // 推荐商品 + Sort *int64 `gorm:"default:0;" json:"sort"` // 排序 + Status *int64 `gorm:"default:0;" json:"status"` // 状态 + Ctime *int64 `gorm:"default:0;" json:"ctime"` // 添加时间 +} +type FsMerchantCategoryModel struct { + db *gorm.DB + name string +} + +func NewFsMerchantCategoryModel(db *gorm.DB) *FsMerchantCategoryModel { + return &FsMerchantCategoryModel{db: db, name: "fs_merchant_category"} +} diff --git a/model/gmodel/fs_merchant_category_logic.go b/model/gmodel/fs_merchant_category_logic.go new file mode 100644 index 00000000..e68225aa --- /dev/null +++ b/model/gmodel/fs_merchant_category_logic.go @@ -0,0 +1,2 @@ +package gmodel +// TODO: 使用model的属性做你想做的 \ No newline at end of file diff --git a/model/gmodel/fs_product_recommend_gen.go b/model/gmodel/fs_product_recommend_gen.go index 930a3da8..111494f6 100644 --- a/model/gmodel/fs_product_recommend_gen.go +++ b/model/gmodel/fs_product_recommend_gen.go @@ -6,10 +6,11 @@ import ( // fs_product_recommend 推荐商品表 type FsProductRecommend struct { - Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` // - ProductId *int64 `gorm:"default:0;" json:"product_id"` // 产品ID - Status *int64 `gorm:"default:1;" json:"status"` // 状态 1正常 0不正常 - Ctime *int64 `gorm:"default:0;" json:"ctime"` // 添加时间 + Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` // + ProductId *int64 `gorm:"default:0;" json:"product_id"` // 产品ID + MerchantType *int64 `gorm:"default:0;" json:"merchant_type"` // 商家类型 + Status *int64 `gorm:"default:1;" json:"status"` // 状态 1正常 0不正常 + Ctime *int64 `gorm:"default:0;" json:"ctime"` // 添加时间 } type FsProductRecommendModel struct { db *gorm.DB diff --git a/model/gmodel/fs_product_recommend_logic.go b/model/gmodel/fs_product_recommend_logic.go index 02e33584..0646203d 100644 --- a/model/gmodel/fs_product_recommend_logic.go +++ b/model/gmodel/fs_product_recommend_logic.go @@ -7,9 +7,10 @@ import ( ) type GetRecommendProductListReq struct { - Ctx context.Context - Page int - Limit int + Ctx context.Context + MerchantType int64 + Page int + Limit int } func (r *FsProductRecommendModel) GetRecommendProductList(req GetRecommendProductListReq) (resp []FsProduct, total int64, err error) { @@ -18,6 +19,9 @@ func (r *FsProductRecommendModel) GetRecommendProductList(req GetRecommendProduc Joins("inner join fs_product as p on r.product_id = p.id"). Where("r.status = ? ", 1). Where("p.is_shelf = ? and p.is_del = ? and p.status = ?", 1, 0, 1) + if req.MerchantType > 0 { + db = db.Where("merchant_type = ?", req.MerchantType) + } if err = db.Limit(1).Count(&total).Error; err != nil { return nil, 0, err } diff --git a/model/gmodel/fs_product_template_v2_gen.go b/model/gmodel/fs_product_template_v2_gen.go index d72b388a..07ad37fc 100644 --- a/model/gmodel/fs_product_template_v2_gen.go +++ b/model/gmodel/fs_product_template_v2_gen.go @@ -9,21 +9,21 @@ type FsProductTemplateV2 struct { Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` // ProductId *int64 `gorm:"index;default:0;" json:"product_id"` // 产品ID ModelId *int64 `gorm:"default:0;" json:"model_id"` // 模型ID - Title *string `gorm:"default:'';" json:"title"` // 模板(sku),预留字段 - Name *string `gorm:"default:'';" json:"name"` // 名称 - CoverImg *string `gorm:"default:'';" json:"cover_img"` // 模板背景图 - TemplateInfo *string `gorm:"default:'';" json:"template_info"` // 模板详情 - MaterialImg *string `gorm:"default:'';" json:"material_img"` // 合成好的贴图 + Title *string `gorm:"default:'';" json:"title"` // + Name *string `gorm:"default:'';" json:"name"` // + CoverImg *string `gorm:"default:'';" json:"cover_img"` // + TemplateInfo *string `gorm:"default:'';" json:"template_info"` // + MaterialImg *string `gorm:"default:'';" json:"material_img"` // Sort *int64 `gorm:"default:0;" json:"sort"` // 排序 LogoWidth *int64 `gorm:"default:0;" json:"logo_width"` // logo图最大宽度 LogoHeight *int64 `gorm:"default:0;" json:"logo_height"` // logo图最大高度 IsPublic *int64 `gorm:"default:0;" json:"is_public"` // 是否可公用(1:可以,0:不可以) Status *int64 `gorm:"default:0;" json:"status"` // 状态1正常 2异常 Ctime *int64 `gorm:"default:0;" json:"ctime"` // 添加时间 - Tag *string `gorm:"default:'';" json:"tag"` // 标签(用户自填) + Tag *string `gorm:"default:'';" json:"tag"` // IsDel *int64 `gorm:"default:0;" json:"is_del"` // 是否删除 1删除 - SwitchInfo *string `gorm:"default:'';" json:"switch_info"` // 开关信息 - GroupOptions *string `gorm:"default:'';" json:"group_options"` // 颜色分组 + SwitchInfo *string `gorm:"default:'';" json:"switch_info"` // + GroupOptions *string `gorm:"default:'';" json:"group_options"` // Version *int64 `gorm:"default:0;" json:"version"` // } type FsProductTemplateV2Model struct { diff --git a/model/gmodel/var_gen.go b/model/gmodel/var_gen.go index 46818f31..905e8301 100644 --- a/model/gmodel/var_gen.go +++ b/model/gmodel/var_gen.go @@ -45,6 +45,7 @@ type AllModelsGen struct { FsLog *FsLogModel // fs_log 日志表 FsMapLibrary *FsMapLibraryModel // fs_map_library 贴图库 FsMenu *FsMenuModel // fs_menu 后台菜单 + FsMerchantCategory *FsMerchantCategoryModel // fs_merchant_category 商户类型表 FsMigration *FsMigrationModel // fs_migration 版本库 FsOrder *FsOrderModel // fs_order FsOrderAffiliate *FsOrderAffiliateModel // fs_order_affiliate 订单附属表-流程控制时间等 @@ -140,6 +141,7 @@ func NewAllModels(gdb *gorm.DB) *AllModelsGen { FsLog: NewFsLogModel(gdb), FsMapLibrary: NewFsMapLibraryModel(gdb), FsMenu: NewFsMenuModel(gdb), + FsMerchantCategory: NewFsMerchantCategoryModel(gdb), FsMigration: NewFsMigrationModel(gdb), FsOrder: NewFsOrderModel(gdb), FsOrderAffiliate: NewFsOrderAffiliateModel(gdb), diff --git a/server/product/internal/logic/homepagerecommendproductlistlogic.go b/server/product/internal/logic/homepagerecommendproductlistlogic.go index b41c7dd0..e542aec4 100644 --- a/server/product/internal/logic/homepagerecommendproductlistlogic.go +++ b/server/product/internal/logic/homepagerecommendproductlistlogic.go @@ -54,9 +54,10 @@ func (l *HomePageRecommendProductListLogic) HomePageRecommendProductList(req *ty ) //获取列表推荐产品 recommendProductList, _, err = l.svcCtx.AllModels.FsProductRecommend.GetRecommendProductList(gmodel.GetRecommendProductListReq{ - Ctx: l.ctx, - Page: 1, - Limit: 500, //设置最大500 + Ctx: l.ctx, + MerchantType: req.MerchantType, + Page: 1, + Limit: 500, //设置最大500 }) if len(recommendProductList) == 0 { return resp.SetStatusWithMessage(basic.CodeOK, "success", []interface{}{}) diff --git a/server/product/internal/types/types.go b/server/product/internal/types/types.go index 8e718fb7..5cb5c2d4 100644 --- a/server/product/internal/types/types.go +++ b/server/product/internal/types/types.go @@ -342,12 +342,6 @@ type GetSizeByPidRsp struct { type GetTemplateByPidReq struct { Pid string `form:"pid"` ProductTemplateTagId int64 `form:"product_template_tag_id"` - ProductSizeId int64 `form:"product_size_id,optional"` -} - -type GetTemplateByPidRsp struct { - TemplateId int64 `json:"template_id"` //模板id - TemplateInfo interface{} `json:"template_info"` //模板信息 } type GetFittingByPidReq struct { @@ -395,7 +389,8 @@ type GetLastProductDesignRsp struct { } type HomePageRecommendProductListReq struct { - Size uint32 `form:"size"` + Size uint32 `form:"size"` + MerchantType int64 `form:"merchant_type"` } type HomePageRecommendProductListRsp struct { diff --git a/server_api/product.api b/server_api/product.api index e710a978..1f37a789 100644 --- a/server_api/product.api +++ b/server_api/product.api @@ -432,7 +432,8 @@ type GetLastProductDesignRsp { } //获取列表页推荐产品(返回是这个维度数组) type HomePageRecommendProductListReq { - Size uint32 `form:"size"` + Size uint32 `form:"size"` + MerchantType int64 `form:"merchant_type"` } type HomePageRecommendProductListRsp { Id int64 `json:"id"` From 2bb1c73e4a29c1a75a5070e572861a456101aa0f Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Mon, 14 Aug 2023 11:35:23 +0800 Subject: [PATCH 017/151] fix --- model/gmodel/fs_merchant_category_gen.go | 2 +- model/gmodel/fs_merchant_category_logic.go | 13 +++++- model/gmodel/fs_product_recommend_gen.go | 22 ---------- model/gmodel/fs_product_recommend_logic.go | 43 ------------------- model/gmodel/var_gen.go | 2 - .../homepagerecommendproductlistlogic.go | 34 ++++++++++++--- server/product/internal/types/types.go | 1 + server_api/product.api | 1 + 8 files changed, 43 insertions(+), 75 deletions(-) delete mode 100644 model/gmodel/fs_product_recommend_gen.go delete mode 100644 model/gmodel/fs_product_recommend_logic.go diff --git a/model/gmodel/fs_merchant_category_gen.go b/model/gmodel/fs_merchant_category_gen.go index 732ec88b..37944dce 100644 --- a/model/gmodel/fs_merchant_category_gen.go +++ b/model/gmodel/fs_merchant_category_gen.go @@ -11,7 +11,7 @@ type FsMerchantCategory struct { EnName *string `gorm:"default:'';" json:"en_name"` // 英文名 Icon *string `gorm:"default:'';" json:"icon"` // 图标 RecommendProduct *string `gorm:"default:'';" json:"recommend_product"` // 推荐商品 - Sort *int64 `gorm:"default:0;" json:"sort"` // 排序 + Sort *int64 `gorm:"default:128;" json:"sort"` // 排序 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 e68225aa..66b709d5 100644 --- a/model/gmodel/fs_merchant_category_logic.go +++ b/model/gmodel/fs_merchant_category_logic.go @@ -1,2 +1,13 @@ package gmodel -// TODO: 使用model的属性做你想做的 \ No newline at end of file + +import "context" + +// TODO: 使用model的属性做你想做的 +func (m *FsMerchantCategoryModel) FindOne(ctx context.Context, id int64) (resp *FsMerchantCategory, err error) { + 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 + return resp, err +} diff --git a/model/gmodel/fs_product_recommend_gen.go b/model/gmodel/fs_product_recommend_gen.go deleted file mode 100644 index 111494f6..00000000 --- a/model/gmodel/fs_product_recommend_gen.go +++ /dev/null @@ -1,22 +0,0 @@ -package gmodel - -import ( - "gorm.io/gorm" -) - -// fs_product_recommend 推荐商品表 -type FsProductRecommend struct { - Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` // - ProductId *int64 `gorm:"default:0;" json:"product_id"` // 产品ID - MerchantType *int64 `gorm:"default:0;" json:"merchant_type"` // 商家类型 - Status *int64 `gorm:"default:1;" json:"status"` // 状态 1正常 0不正常 - Ctime *int64 `gorm:"default:0;" json:"ctime"` // 添加时间 -} -type FsProductRecommendModel struct { - db *gorm.DB - name string -} - -func NewFsProductRecommendModel(db *gorm.DB) *FsProductRecommendModel { - return &FsProductRecommendModel{db: db, name: "fs_product_recommend"} -} diff --git a/model/gmodel/fs_product_recommend_logic.go b/model/gmodel/fs_product_recommend_logic.go deleted file mode 100644 index 0646203d..00000000 --- a/model/gmodel/fs_product_recommend_logic.go +++ /dev/null @@ -1,43 +0,0 @@ -package gmodel - -import ( - "context" - "errors" - "gorm.io/gorm" -) - -type GetRecommendProductListReq struct { - Ctx context.Context - MerchantType int64 - Page int - Limit int -} - -func (r *FsProductRecommendModel) GetRecommendProductList(req GetRecommendProductListReq) (resp []FsProduct, total int64, err error) { - db := r.db.WithContext(req.Ctx). - Table("fs_product_recommend as r"). - Joins("inner join fs_product as p on r.product_id = p.id"). - Where("r.status = ? ", 1). - Where("p.is_shelf = ? and p.is_del = ? and p.status = ?", 1, 0, 1) - if req.MerchantType > 0 { - db = db.Where("merchant_type = ?", req.MerchantType) - } - if err = db.Limit(1).Count(&total).Error; err != nil { - return nil, 0, err - } - db = db.Select("p.*") - offset := (req.Page - 1) * req.Limit - err = db.Offset(offset).Limit(req.Limit).Find(&resp).Error - return resp, total, err -} -func (r *FsProductRecommendModel) CreateOrUpdate(ctx context.Context, productId int64, data *FsProductRecommend) error { - var info FsProductRecommend - err := r.db.WithContext(ctx).Model(&FsProductRecommend{}).Where("`product_id` = ?", productId).Take(&info).Error - if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) { - return err - } - if info.Id == 0 { - return r.db.WithContext(ctx).Model(&FsProductRecommend{}).Create(data).Error - } - return r.db.WithContext(ctx).Model(&FsProductRecommend{}).Where("`product_id` = ?", productId).Updates(data).Error -} diff --git a/model/gmodel/var_gen.go b/model/gmodel/var_gen.go index 905e8301..b62e2377 100644 --- a/model/gmodel/var_gen.go +++ b/model/gmodel/var_gen.go @@ -62,7 +62,6 @@ type AllModelsGen struct { FsProductModel3dLight *FsProductModel3dLightModel // fs_product_model3d_light 模型-灯光组表 FsProductOption *FsProductOptionModel // fs_product_option 产品选项表(已废弃) FsProductPrice *FsProductPriceModel // fs_product_price 阶梯价格表 - FsProductRecommend *FsProductRecommendModel // fs_product_recommend 推荐商品表 FsProductRenderDesign *FsProductRenderDesignModel // fs_product_render_design FsProductScene *FsProductSceneModel // fs_product_scene 产品场景表 FsProductSize *FsProductSizeModel // fs_product_size 产品尺寸表 @@ -158,7 +157,6 @@ func NewAllModels(gdb *gorm.DB) *AllModelsGen { FsProductModel3dLight: NewFsProductModel3dLightModel(gdb), FsProductOption: NewFsProductOptionModel(gdb), FsProductPrice: NewFsProductPriceModel(gdb), - FsProductRecommend: NewFsProductRecommendModel(gdb), FsProductRenderDesign: NewFsProductRenderDesignModel(gdb), FsProductScene: NewFsProductSceneModel(gdb), FsProductSize: NewFsProductSizeModel(gdb), diff --git a/server/product/internal/logic/homepagerecommendproductlistlogic.go b/server/product/internal/logic/homepagerecommendproductlistlogic.go index e542aec4..61708dfa 100644 --- a/server/product/internal/logic/homepagerecommendproductlistlogic.go +++ b/server/product/internal/logic/homepagerecommendproductlistlogic.go @@ -42,6 +42,7 @@ func (l *HomePageRecommendProductListLogic) HomePageRecommendProductList(req *ty return resp.SetStatusWithMessage(basic.CodeServiceErr, "get user info err") } var ( + merchantInfo *gmodel.FsMerchantCategory recommendProductList []gmodel.FsProduct //产品列表(select 字段需要看查询的地方) productOptionalPartList []gmodel.GetGroupPartListByProductIdsRsp //产品配件列表 mapProductHaveOptionFitting = make(map[int64]struct{}) @@ -52,13 +53,34 @@ func (l *HomePageRecommendProductListLogic) HomePageRecommendProductList(req *ty mapProductSizeCount = make(map[int64]int64) //产品尺寸数量map mapProductTemplate = make(map[int64]struct{}) //产品模板map ) + //选了商家类型 + 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") + } + logx.Error(err) + return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get merchant type info") + } + if *merchantInfo.RecommendProduct == "" { + return resp.SetStatusWithMessage(basic.CodeOK, "success", []interface{}{}) + } + recommendProductIds, err := format.StrSlicToInt64Slice(strings.Split(*merchantInfo.RecommendProduct, ",")) + if err != nil { + logx.Error(err) + return resp.SetStatusWithMessage(basic.CodeServiceErr, "failed to parse recommend product") + } //获取列表推荐产品 - recommendProductList, _, err = l.svcCtx.AllModels.FsProductRecommend.GetRecommendProductList(gmodel.GetRecommendProductListReq{ - Ctx: l.ctx, - MerchantType: req.MerchantType, - Page: 1, - Limit: 500, //设置最大500 - }) + recommendProductList, err = l.svcCtx.AllModels.FsProduct.GetProductListByIds(l.ctx, recommendProductIds, "sort-desc") + if err != nil { + logx.Error(err) + return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get product list") + } if len(recommendProductList) == 0 { return resp.SetStatusWithMessage(basic.CodeOK, "success", []interface{}{}) } diff --git a/server/product/internal/types/types.go b/server/product/internal/types/types.go index 5cb5c2d4..435229a7 100644 --- a/server/product/internal/types/types.go +++ b/server/product/internal/types/types.go @@ -341,6 +341,7 @@ type GetSizeByPidRsp struct { type GetTemplateByPidReq struct { Pid string `form:"pid"` + ProductSizeId int64 `form:"product_size_id,optional"` ProductTemplateTagId int64 `form:"product_template_tag_id"` } diff --git a/server_api/product.api b/server_api/product.api index 1f37a789..0fd841bf 100644 --- a/server_api/product.api +++ b/server_api/product.api @@ -386,6 +386,7 @@ type GetSizeByPidRsp { //获取产品模板 type GetTemplateByPidReq { Pid string `form:"pid"` + ProductSizeId int64 `form:"product_size_id,optional"` ProductTemplateTagId int64 `form:"product_template_tag_id"` } //获取产品配件数据 From 76b291c02a7373c86a669c885d4b80678b3a356c Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Mon, 14 Aug 2023 11:46:29 +0800 Subject: [PATCH 018/151] fix --- server/product/internal/logic/gettagproductlistlogic.go | 5 +++-- .../internal/logic/homepagerecommendproductlistlogic.go | 6 ++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/server/product/internal/logic/gettagproductlistlogic.go b/server/product/internal/logic/gettagproductlistlogic.go index 8c6f5a3c..480e2bc1 100644 --- a/server/product/internal/logic/gettagproductlistlogic.go +++ b/server/product/internal/logic/gettagproductlistlogic.go @@ -366,12 +366,13 @@ func (l *GetTagProductListLogic) getTagProducts(req getTagProductsReq) (productL MinPrice: minPrice, HaveOptionalFitting: haveOptionalFitting, Recommended: *productInfo.IsRecommend > 0, + Cover: *productInfo.Cover, } if _, ok = req.MapTagProp[productInfo.Id]; ok { item.CoverDefault = req.MapTagProp[productInfo.Id] } //千人千面处理 - r := image.ThousandFaceImageFormatReq{ + /*r := image.ThousandFaceImageFormatReq{ Size: int(req.Size), IsThousandFace: 0, Cover: *productInfo.Cover, @@ -383,7 +384,7 @@ func (l *GetTagProductListLogic) getTagProducts(req getTagProductsReq) (productL r.IsThousandFace = int(*req.User.IsThousandFace) } image.ThousandFaceImageFormat(&r) - item.Cover = r.Cover + item.Cover = r.Cover*/ //加入分类产品切片 productListRsp = append(productListRsp, item) } diff --git a/server/product/internal/logic/homepagerecommendproductlistlogic.go b/server/product/internal/logic/homepagerecommendproductlistlogic.go index 61708dfa..77a24069 100644 --- a/server/product/internal/logic/homepagerecommendproductlistlogic.go +++ b/server/product/internal/logic/homepagerecommendproductlistlogic.go @@ -170,12 +170,14 @@ func (l *HomePageRecommendProductListLogic) HomePageRecommendProductList(req *ty Id: productInfo.Id, Sn: *productInfo.Sn, Title: *productInfo.Title, + Cover: *productInfo.Cover, + CoverDefault: *productInfo.Cover, SizeNum: uint32(sizeNum), MinPrice: minPrice, HaveOptionalFitting: haveOptionalFitting, } //千人千面处理 - r := image.ThousandFaceImageFormatReq{ + /*r := image.ThousandFaceImageFormatReq{ Size: int(req.Size), IsThousandFace: 0, Cover: *productInfo.Cover, @@ -189,7 +191,7 @@ func (l *HomePageRecommendProductListLogic) HomePageRecommendProductList(req *ty } image.ThousandFaceImageFormat(&r) item.Cover = r.Cover - item.CoverDefault = r.CoverDefault + item.CoverDefault = r.CoverDefault*/ //加入分类产品切片 listRsp = append(listRsp, item) } From aa895fda51e756b169f1905d5598b8cda13a3213 Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Mon, 14 Aug 2023 11:49:02 +0800 Subject: [PATCH 019/151] fix --- .../internal/logic/homepagerecommendproductlistlogic.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/server/product/internal/logic/homepagerecommendproductlistlogic.go b/server/product/internal/logic/homepagerecommendproductlistlogic.go index 77a24069..6273a99a 100644 --- a/server/product/internal/logic/homepagerecommendproductlistlogic.go +++ b/server/product/internal/logic/homepagerecommendproductlistlogic.go @@ -7,7 +7,6 @@ import ( "fusenapi/utils/auth" "fusenapi/utils/basic" "fusenapi/utils/format" - "fusenapi/utils/image" "gorm.io/gorm" "sort" "strings" @@ -36,7 +35,7 @@ func NewHomePageRecommendProductListLogic(ctx context.Context, svcCtx *svc.Servi func (l *HomePageRecommendProductListLogic) HomePageRecommendProductList(req *types.HomePageRecommendProductListReq, userinfo *auth.UserInfo) (resp *basic.Response) { //查询用户信息(不用判断存在) - user, err := l.svcCtx.AllModels.FsUser.FindUserById(l.ctx, userinfo.UserId) + _, err := l.svcCtx.AllModels.FsUser.FindUserById(l.ctx, userinfo.UserId) if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) { logx.Error(err) return resp.SetStatusWithMessage(basic.CodeServiceErr, "get user info err") From 06e32e6af9c757605c4190e6f0797ee902d54380 Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Mon, 14 Aug 2023 11:53:16 +0800 Subject: [PATCH 020/151] fix --- .../logic/homepagerecommendproductlistlogic.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/server/product/internal/logic/homepagerecommendproductlistlogic.go b/server/product/internal/logic/homepagerecommendproductlistlogic.go index 6273a99a..3656f78e 100644 --- a/server/product/internal/logic/homepagerecommendproductlistlogic.go +++ b/server/product/internal/logic/homepagerecommendproductlistlogic.go @@ -44,13 +44,13 @@ func (l *HomePageRecommendProductListLogic) HomePageRecommendProductList(req *ty merchantInfo *gmodel.FsMerchantCategory recommendProductList []gmodel.FsProduct //产品列表(select 字段需要看查询的地方) productOptionalPartList []gmodel.GetGroupPartListByProductIdsRsp //产品配件列表 - mapProductHaveOptionFitting = make(map[int64]struct{}) - productPriceList []gmodel.GetPriceListByProductIdsRsp //产品价格列表(select 字段需要看查询的地方) - mapProductMinPrice = make(map[int64]int64) //产品最小价格map - productTemplatesV2 []gmodel.FsProductTemplateV2 //产品模板列表(select 字段需要看查询的地方) - productSizeCountList []gmodel.CountProductSizeByStatusRsp //产品尺寸数量列表(select 字段需要看查询的地方) - mapProductSizeCount = make(map[int64]int64) //产品尺寸数量map - mapProductTemplate = make(map[int64]struct{}) //产品模板map + mapProductHaveOptionFitting = make(map[int64]struct{}) //是否有配件map + productPriceList []gmodel.GetPriceListByProductIdsRsp //产品价格列表(select 字段需要看查询的地方) + mapProductMinPrice = make(map[int64]int64) //产品最小价格map + productTemplatesV2 []gmodel.FsProductTemplateV2 //产品模板列表(select 字段需要看查询的地方) + productSizeCountList []gmodel.CountProductSizeByStatusRsp //产品尺寸数量列表(select 字段需要看查询的地方) + mapProductSizeCount = make(map[int64]int64) //产品尺寸数量map + mapProductTemplate = make(map[int64]struct{}) //产品模板map ) //选了商家类型 if req.MerchantType > 0 { From 5bc6f411bed552831f181774a57365d089bae98c Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Mon, 14 Aug 2023 12:05:22 +0800 Subject: [PATCH 021/151] fix --- server/render/consumer/assemble_render_data.go | 8 ++++---- utils/websocket_data/render_data.go | 4 ++++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/server/render/consumer/assemble_render_data.go b/server/render/consumer/assemble_render_data.go index 5b041711..bf368975 100644 --- a/server/render/consumer/assemble_render_data.go +++ b/server/render/consumer/assemble_render_data.go @@ -183,10 +183,10 @@ func getCombineImage(ctx context.Context, svcCtx *svc.ServiceContext, parseInfo //需要替换的参数 replaceData := map[string]interface{}{ "logo_url": parseInfo.RenderData.Logo, - "website": "", - "slogan": "", - "address": "", - "phone": "", + "website": parseInfo.RenderData.Website, + "slogan": parseInfo.RenderData.Slogan, + "address": parseInfo.RenderData.Address, + "phone": parseInfo.RenderData.Phone, "colors": []string{}, "template_tagid": []string{"b1a"}, "is_crop": false, diff --git a/utils/websocket_data/render_data.go b/utils/websocket_data/render_data.go index 8bde5dbe..fcec9690 100644 --- a/utils/websocket_data/render_data.go +++ b/utils/websocket_data/render_data.go @@ -16,6 +16,10 @@ type RenderData struct { 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连接建立再赋值) } From 35b02302ebf55add154543537fb122228b6e6c44 Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Mon, 14 Aug 2023 12:30:14 +0800 Subject: [PATCH 022/151] fix --- .../logic/getrecommandproductlistlogic.go | 46 +++++++++++++------ .../homepagerecommendproductlistlogic.go | 17 ++++++- server/product/internal/types/types.go | 36 +++++++-------- server_api/product.api | 36 +++++++-------- 4 files changed, 83 insertions(+), 52 deletions(-) diff --git a/server/product/internal/logic/getrecommandproductlistlogic.go b/server/product/internal/logic/getrecommandproductlistlogic.go index f3bf72be..3d4e9734 100644 --- a/server/product/internal/logic/getrecommandproductlistlogic.go +++ b/server/product/internal/logic/getrecommandproductlistlogic.go @@ -113,14 +113,27 @@ func (l *GetRecommandProductListLogic) GetRecommandProductList(req *types.GetRec } } //获取用户信息(不用判断存在) - user, err := l.svcCtx.AllModels.FsUser.FindUserById(l.ctx, userinfo.UserId) + /*user, err := l.svcCtx.AllModels.FsUser.FindUserById(l.ctx, userinfo.UserId) if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) { logx.Error(err) return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get user") + }*/ + //获取产品标签相关属性 + productTagPropList, err := l.svcCtx.AllModels.FsProductTagProp.GetTagPropByProductIdsWithProductTag(l.ctx, productIds) + if err != nil { + logx.Error(err) + return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get product tag property") + } + mapTagProp := make(map[int64][]types.CoverDefaultItem) + for _, v := range productTagPropList { + mapTagProp[*v.ProductId] = append(mapTagProp[*v.ProductId], types.CoverDefaultItem{ + Tag: v.Title, + Cover: *v.Cover, + }) } list := make([]types.GetRecommandProductListRsp, 0, len(recommendProductList)) for _, v := range recommendProductList { - r := image.ThousandFaceImageFormatReq{ + /*r := image.ThousandFaceImageFormatReq{ Size: int(req.Size), IsThousandFace: 0, Cover: *v.Cover, @@ -133,7 +146,7 @@ func (l *GetRecommandProductListLogic) GetRecommandProductList(req *types.GetRec r.IsThousandFace = int(*user.IsThousandFace) } //千人前面处理 - image.ThousandFaceImageFormat(&r) + image.ThousandFaceImageFormat(&r)*/ isRecommend := int64(0) if _, ok := mapRecommend[v.Id]; ok { isRecommend = 1 @@ -142,18 +155,21 @@ func (l *GetRecommandProductListLogic) GetRecommandProductList(req *types.GetRec if minVal, ok := mapProductMinPrice[v.Id]; ok { minPrice = minVal } - list = append(list, types.GetRecommandProductListRsp{ - Id: v.Id, - Sn: *v.Sn, - Title: *v.Title, - TitleCn: *v.TitleCn, - Cover: r.Cover, - CoverImg: r.CoverImg, - CoverDefault: r.CoverDefault, - Intro: *v.Intro, - IsRecommend: isRecommend, - MinPrice: minPrice, - }) + item := types.GetRecommandProductListRsp{ + Id: v.Id, + Sn: *v.Sn, + Title: *v.Title, + TitleCn: *v.TitleCn, + Cover: *productInfo.Cover, + CoverImg: *productInfo.CoverImg, + Intro: *v.Intro, + IsRecommend: isRecommend, + MinPrice: minPrice, + } + if _, ok := mapTagProp[productInfo.Id]; ok { + item.CoverDefault = mapTagProp[productInfo.Id] + } + list = append(list, item) } return resp.SetStatusWithMessage(basic.CodeOK, "success", list) } diff --git a/server/product/internal/logic/homepagerecommendproductlistlogic.go b/server/product/internal/logic/homepagerecommendproductlistlogic.go index 3656f78e..4e5740c9 100644 --- a/server/product/internal/logic/homepagerecommendproductlistlogic.go +++ b/server/product/internal/logic/homepagerecommendproductlistlogic.go @@ -147,6 +147,19 @@ func (l *HomePageRecommendProductListLogic) HomePageRecommendProductList(req *ty for _, v := range productSizeCountList { mapProductSizeCount[v.ProductId] = v.Num } + //获取产品标签相关属性 + productTagPropList, err := l.svcCtx.AllModels.FsProductTagProp.GetTagPropByProductIdsWithProductTag(l.ctx, productIds) + if err != nil { + logx.Error(err) + return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get product tag property") + } + mapTagProp := make(map[int64][]types.CoverDefaultItem) + for _, v := range productTagPropList { + mapTagProp[*v.ProductId] = append(mapTagProp[*v.ProductId], types.CoverDefaultItem{ + Tag: v.Title, + Cover: *v.Cover, + }) + } //组装返回 listRsp := make([]types.HomePageRecommendProductListRsp, 0, len(recommendProductList)) for _, productInfo := range recommendProductList { @@ -170,11 +183,13 @@ func (l *HomePageRecommendProductListLogic) HomePageRecommendProductList(req *ty Sn: *productInfo.Sn, Title: *productInfo.Title, Cover: *productInfo.Cover, - CoverDefault: *productInfo.Cover, SizeNum: uint32(sizeNum), MinPrice: minPrice, HaveOptionalFitting: haveOptionalFitting, } + if _, ok = mapTagProp[productInfo.Id]; ok { + item.CoverDefault = mapTagProp[productInfo.Id] + } //千人千面处理 /*r := image.ThousandFaceImageFormatReq{ Size: int(req.Size), diff --git a/server/product/internal/types/types.go b/server/product/internal/types/types.go index 435229a7..e44a240f 100644 --- a/server/product/internal/types/types.go +++ b/server/product/internal/types/types.go @@ -234,16 +234,16 @@ type GetRecommandProductListReq struct { } type GetRecommandProductListRsp struct { - Id int64 `json:"id"` - Sn string `json:"sn"` - Title string `json:"title"` - TitleCn string `json:"title_cn"` - Cover string `json:"cover"` - CoverImg string `json:"cover_img"` - CoverDefault string `json:"cover_default"` - Intro string `json:"intro"` - IsRecommend int64 `json:"is_recommend"` - MinPrice int64 `json:"min_price"` + Id int64 `json:"id"` + Sn string `json:"sn"` + Title string `json:"title"` + TitleCn string `json:"title_cn"` + Cover string `json:"cover"` + CoverImg string `json:"cover_img"` + CoverDefault []CoverDefaultItem `json:"cover_default"` + Intro string `json:"intro"` + IsRecommend int64 `json:"is_recommend"` + MinPrice int64 `json:"min_price"` } type GetTagProductListReq struct { @@ -395,14 +395,14 @@ type HomePageRecommendProductListReq struct { } type HomePageRecommendProductListRsp struct { - Id int64 `json:"id"` - Sn string `json:"sn"` - Title string `json:"title"` - Cover string `json:"cover"` - SizeNum uint32 `json:"size_num"` - MinPrice int64 `json:"min_price"` - CoverDefault string `json:"cover_default"` - HaveOptionalFitting bool `json:"have_optional_fitting"` + Id int64 `json:"id"` + Sn string `json:"sn"` + Title string `json:"title"` + Cover string `json:"cover"` + SizeNum uint32 `json:"size_num"` + MinPrice int64 `json:"min_price"` + CoverDefault []CoverDefaultItem `json:"cover_default"` + HaveOptionalFitting bool `json:"have_optional_fitting"` } type Request struct { diff --git a/server_api/product.api b/server_api/product.api index 0fd841bf..cbdc734f 100644 --- a/server_api/product.api +++ b/server_api/product.api @@ -286,16 +286,16 @@ type GetRecommandProductListReq { Sn string `form:"sn"` } type GetRecommandProductListRsp { - Id int64 `json:"id"` - Sn string `json:"sn"` - Title string `json:"title"` - TitleCn string `json:"title_cn"` - Cover string `json:"cover"` - CoverImg string `json:"cover_img"` - CoverDefault string `json:"cover_default"` - Intro string `json:"intro"` - IsRecommend int64 `json:"is_recommend"` - MinPrice int64 `json:"min_price"` + Id int64 `json:"id"` + Sn string `json:"sn"` + Title string `json:"title"` + TitleCn string `json:"title_cn"` + Cover string `json:"cover"` + CoverImg string `json:"cover_img"` + CoverDefault []CoverDefaultItem `json:"cover_default"` + Intro string `json:"intro"` + IsRecommend int64 `json:"is_recommend"` + MinPrice int64 `json:"min_price"` } //获取分类产品列表 type GetTagProductListReq { @@ -437,12 +437,12 @@ type HomePageRecommendProductListReq { MerchantType int64 `form:"merchant_type"` } type HomePageRecommendProductListRsp { - Id int64 `json:"id"` - Sn string `json:"sn"` - Title string `json:"title"` - Cover string `json:"cover"` - SizeNum uint32 `json:"size_num"` - MinPrice int64 `json:"min_price"` - CoverDefault string `json:"cover_default"` - HaveOptionalFitting bool `json:"have_optional_fitting"` + Id int64 `json:"id"` + Sn string `json:"sn"` + Title string `json:"title"` + Cover string `json:"cover"` + SizeNum uint32 `json:"size_num"` + MinPrice int64 `json:"min_price"` + CoverDefault []CoverDefaultItem `json:"cover_default"` + HaveOptionalFitting bool `json:"have_optional_fitting"` } \ No newline at end of file From 68441426032f3d7b32bb38d07bb91061da51605a Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Mon, 14 Aug 2023 12:31:49 +0800 Subject: [PATCH 023/151] fix --- .../logic/getrecommandproductlistlogic.go | 19 ++++++++++--------- .../homepagerecommendproductlistlogic.go | 1 + 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/server/product/internal/logic/getrecommandproductlistlogic.go b/server/product/internal/logic/getrecommandproductlistlogic.go index 3d4e9734..018d68a4 100644 --- a/server/product/internal/logic/getrecommandproductlistlogic.go +++ b/server/product/internal/logic/getrecommandproductlistlogic.go @@ -156,15 +156,16 @@ func (l *GetRecommandProductListLogic) GetRecommandProductList(req *types.GetRec minPrice = minVal } item := types.GetRecommandProductListRsp{ - Id: v.Id, - Sn: *v.Sn, - Title: *v.Title, - TitleCn: *v.TitleCn, - Cover: *productInfo.Cover, - CoverImg: *productInfo.CoverImg, - Intro: *v.Intro, - IsRecommend: isRecommend, - MinPrice: minPrice, + Id: v.Id, + Sn: *v.Sn, + Title: *v.Title, + TitleCn: *v.TitleCn, + Cover: *productInfo.Cover, + CoverImg: *productInfo.CoverImg, + CoverDefault: []types.CoverDefaultItem{}, + Intro: *v.Intro, + IsRecommend: isRecommend, + MinPrice: minPrice, } if _, ok := mapTagProp[productInfo.Id]; ok { item.CoverDefault = mapTagProp[productInfo.Id] diff --git a/server/product/internal/logic/homepagerecommendproductlistlogic.go b/server/product/internal/logic/homepagerecommendproductlistlogic.go index 4e5740c9..a8bd03df 100644 --- a/server/product/internal/logic/homepagerecommendproductlistlogic.go +++ b/server/product/internal/logic/homepagerecommendproductlistlogic.go @@ -183,6 +183,7 @@ func (l *HomePageRecommendProductListLogic) HomePageRecommendProductList(req *ty Sn: *productInfo.Sn, Title: *productInfo.Title, Cover: *productInfo.Cover, + CoverDefault: []types.CoverDefaultItem{}, SizeNum: uint32(sizeNum), MinPrice: minPrice, HaveOptionalFitting: haveOptionalFitting, From bdd9a70a2dedef60edda6edea1a6281488d31c16 Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Mon, 14 Aug 2023 14:21:14 +0800 Subject: [PATCH 024/151] fix --- server/product/internal/logic/gettemplatebypidlogic.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/server/product/internal/logic/gettemplatebypidlogic.go b/server/product/internal/logic/gettemplatebypidlogic.go index e036fa15..d13dbd0a 100644 --- a/server/product/internal/logic/gettemplatebypidlogic.go +++ b/server/product/internal/logic/gettemplatebypidlogic.go @@ -88,7 +88,7 @@ func (l *GetTemplateByPidLogic) GetTemplateByPid(req *types.GetTemplateByPidReq, logx.Error(err) return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get template list") } - rsp := make(map[string][]interface{}) + rsp := make(map[string]interface{}) for _, templateInfo := range templateList { //没有设置模板据不要 if templateInfo.TemplateInfo == nil || *templateInfo.TemplateInfo == "" { @@ -115,11 +115,11 @@ func (l *GetTemplateByPidLogic) GetTemplateByPid(req *types.GetTemplateByPidReq, material = info["module_data"]["material"] } mapKey := fmt.Sprintf("_%d", *modelInfo.SizeId) - rsp[mapKey] = append(rsp[mapKey], map[string]interface{}{ + rsp[mapKey] = map[string]interface{}{ "id": templateInfo.Id, "material": material, "material_data": switchInfo, - }) + } } return resp.SetStatusWithMessage(basic.CodeOK, "success", rsp) } From 57e635c26cc08c8c2d179477addcfb2caac5a7f4 Mon Sep 17 00:00:00 2001 From: Hiven Date: Mon, 14 Aug 2023 14:40:50 +0800 Subject: [PATCH 025/151] =?UTF-8?q?feat:=E6=96=B0=E5=A2=9E=E5=95=86?= =?UTF-8?q?=E6=88=B7=E5=88=97=E8=A1=A8/=E4=BF=9D=E5=AD=98=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- model/gmodel/fs_merchant_category_gen.go | 25 +++++ model/gmodel/fs_merchant_category_logic.go | 45 +++++++++ model/gmodel/fs_product_template_v2_gen.go | 15 +-- model/gmodel/fs_user_info_gen.go | 25 +++++ model/gmodel/fs_user_info_logic.go | 42 ++++++++ model/gmodel/var_gen.go | 4 + server/base/base.go | 36 +++++++ server/base/base_test.go | 9 ++ server/base/etc/base.yaml | 10 ++ server/base/internal/config/config.go | 14 +++ .../handler/merchantcategorylisthandler.go | 35 +++++++ server/base/internal/handler/routes.go | 22 +++++ .../logic/merchantcategorylistlogic.go | 53 +++++++++++ server/base/internal/svc/servicecontext.go | 62 ++++++++++++ server/base/internal/types/types.go | 78 +++++++++++++++ .../home-user-auth/internal/handler/routes.go | 5 + .../internal/handler/userinfosethandler.go | 35 +++++++ .../internal/logic/userinfosetlogic.go | 95 +++++++++++++++++++ server/home-user-auth/internal/types/types.go | 5 + server_api/base.api | 20 ++++ server_api/home-user-auth.api | 11 +++ utils/validate/user_info.go | 26 +++++ 22 files changed, 665 insertions(+), 7 deletions(-) create mode 100644 model/gmodel/fs_merchant_category_gen.go create mode 100644 model/gmodel/fs_merchant_category_logic.go create mode 100644 model/gmodel/fs_user_info_gen.go create mode 100644 model/gmodel/fs_user_info_logic.go create mode 100644 server/base/base.go create mode 100644 server/base/base_test.go create mode 100644 server/base/etc/base.yaml create mode 100644 server/base/internal/config/config.go create mode 100644 server/base/internal/handler/merchantcategorylisthandler.go create mode 100644 server/base/internal/handler/routes.go create mode 100644 server/base/internal/logic/merchantcategorylistlogic.go create mode 100644 server/base/internal/svc/servicecontext.go create mode 100644 server/base/internal/types/types.go create mode 100644 server/home-user-auth/internal/handler/userinfosethandler.go create mode 100644 server/home-user-auth/internal/logic/userinfosetlogic.go create mode 100644 server_api/base.api create mode 100644 utils/validate/user_info.go diff --git a/model/gmodel/fs_merchant_category_gen.go b/model/gmodel/fs_merchant_category_gen.go new file mode 100644 index 00000000..37944dce --- /dev/null +++ b/model/gmodel/fs_merchant_category_gen.go @@ -0,0 +1,25 @@ +package gmodel + +import ( + "gorm.io/gorm" +) + +// fs_merchant_category 商户类型表 +type FsMerchantCategory struct { + Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` // Id + ZnName *string `gorm:"default:'';" json:"zn_name"` // 中文名 + EnName *string `gorm:"default:'';" json:"en_name"` // 英文名 + Icon *string `gorm:"default:'';" json:"icon"` // 图标 + RecommendProduct *string `gorm:"default:'';" json:"recommend_product"` // 推荐商品 + Sort *int64 `gorm:"default:128;" json:"sort"` // 排序 + Status *int64 `gorm:"default:0;" json:"status"` // 状态 + Ctime *int64 `gorm:"default:0;" json:"ctime"` // 添加时间 +} +type FsMerchantCategoryModel struct { + db *gorm.DB + name string +} + +func NewFsMerchantCategoryModel(db *gorm.DB) *FsMerchantCategoryModel { + return &FsMerchantCategoryModel{db: db, name: "fs_merchant_category"} +} diff --git a/model/gmodel/fs_merchant_category_logic.go b/model/gmodel/fs_merchant_category_logic.go new file mode 100644 index 00000000..bb6ef130 --- /dev/null +++ b/model/gmodel/fs_merchant_category_logic.go @@ -0,0 +1,45 @@ +package gmodel + +import ( + "context" + "fusenapi/utils/handlers" + "reflect" + + "gorm.io/gorm" +) + +// TODO: 使用model的属性做你想做的 + +func (m *FsMerchantCategoryModel) BuilderDB(ctx context.Context, selectData []string) *gorm.DB { + if selectData != nil { + return m.db.WithContext(ctx).Select(selectData) + } else { + return m.db.WithContext(ctx).Select("*") + } +} + +func (m *FsMerchantCategoryModel) FindAll(gormDB *gorm.DB, filterMap map[string]string, orderBy string) ([]*FsMerchantCategory, error) { + var resp []*FsMerchantCategory + + // 过滤 + if filterMap != nil { + gormDB = gormDB.Scopes(handlers.FilterData(filterMap)) + } + + // 排序 + if orderBy != "" { + var fieldsMap = make(map[string]struct{}) + s := reflect.TypeOf(&FsOrder{}).Elem() //通过反射获取type定义 + for i := 0; i < s.NumField(); i++ { + fieldsMap[s.Field(i).Tag.Get("json")] = struct{}{} + } + gormDB = gormDB.Scopes(handlers.OrderCheck(orderBy, fieldsMap)) + } + + result := gormDB.Find(&resp) + if result.Error != nil { + return nil, result.Error + } else { + return resp, nil + } +} diff --git a/model/gmodel/fs_product_template_v2_gen.go b/model/gmodel/fs_product_template_v2_gen.go index 5e14427f..07ad37fc 100644 --- a/model/gmodel/fs_product_template_v2_gen.go +++ b/model/gmodel/fs_product_template_v2_gen.go @@ -9,20 +9,21 @@ type FsProductTemplateV2 struct { Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` // ProductId *int64 `gorm:"index;default:0;" json:"product_id"` // 产品ID ModelId *int64 `gorm:"default:0;" json:"model_id"` // 模型ID - Title *string `gorm:"default:'';" json:"title"` // 模板(sku),预留字段 - Name *string `gorm:"default:'';" json:"name"` // 名称 - CoverImg *string `gorm:"default:'';" json:"cover_img"` // 模板背景图 - TemplateInfo *string `gorm:"default:'';" json:"template_info"` // 模板详情 - MaterialImg *string `gorm:"default:'';" json:"material_img"` // 合成好的贴图 + Title *string `gorm:"default:'';" json:"title"` // + Name *string `gorm:"default:'';" json:"name"` // + CoverImg *string `gorm:"default:'';" json:"cover_img"` // + TemplateInfo *string `gorm:"default:'';" json:"template_info"` // + MaterialImg *string `gorm:"default:'';" json:"material_img"` // Sort *int64 `gorm:"default:0;" json:"sort"` // 排序 LogoWidth *int64 `gorm:"default:0;" json:"logo_width"` // logo图最大宽度 LogoHeight *int64 `gorm:"default:0;" json:"logo_height"` // logo图最大高度 IsPublic *int64 `gorm:"default:0;" json:"is_public"` // 是否可公用(1:可以,0:不可以) Status *int64 `gorm:"default:0;" json:"status"` // 状态1正常 2异常 Ctime *int64 `gorm:"default:0;" json:"ctime"` // 添加时间 - Tag *string `gorm:"default:'';" json:"tag"` // 标签(用户自填) + Tag *string `gorm:"default:'';" json:"tag"` // IsDel *int64 `gorm:"default:0;" json:"is_del"` // 是否删除 1删除 - GroupOptions *string `gorm:"default:'';" json:"group_options"` // 颜色分组 + SwitchInfo *string `gorm:"default:'';" json:"switch_info"` // + GroupOptions *string `gorm:"default:'';" json:"group_options"` // Version *int64 `gorm:"default:0;" json:"version"` // } type FsProductTemplateV2Model struct { diff --git a/model/gmodel/fs_user_info_gen.go b/model/gmodel/fs_user_info_gen.go new file mode 100644 index 00000000..71b1bd7a --- /dev/null +++ b/model/gmodel/fs_user_info_gen.go @@ -0,0 +1,25 @@ +package gmodel + +import ( + "gorm.io/gorm" +) + +// fs_user_info 用户信息表 +type FsUserInfo struct { + Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` // ID + Module *string `gorm:"default:'';" json:"module"` // 所属模块 + UserId *int64 `gorm:"index;default:0;" json:"user_id"` // 用户 ID + GuestId *int64 `gorm:"index;default:0;" json:"guest_id"` // 访客 ID + Metadata *string `gorm:"default:'';" json:"metadata"` // 元数据,json格式 + MetaKey1 *string `gorm:"default:'';" json:"meta_key1"` // 需要关键信息查询的自定义属性1,可以动态增加 + Ctime *int64 `gorm:"default:0;" json:"ctime"` // + Utime *int64 `gorm:"default:0;" json:"utime"` // +} +type FsUserInfoModel struct { + db *gorm.DB + name string +} + +func NewFsUserInfoModel(db *gorm.DB) *FsUserInfoModel { + return &FsUserInfoModel{db: db, name: "fs_user_info"} +} diff --git a/model/gmodel/fs_user_info_logic.go b/model/gmodel/fs_user_info_logic.go new file mode 100644 index 00000000..3ca2b8d0 --- /dev/null +++ b/model/gmodel/fs_user_info_logic.go @@ -0,0 +1,42 @@ +package gmodel + +import ( + "context" + "fusenapi/utils/handlers" + + "gorm.io/gorm" +) + +// TODO: 使用model的属性做你想做的 + +func (m *FsUserInfoModel) BuilderDB(ctx context.Context, selectData []string) *gorm.DB { + if selectData != nil { + return m.db.WithContext(ctx).Select(selectData) + } else { + return m.db.WithContext(ctx).Select("*") + } +} + +func (m *FsUserInfoModel) FindOne(gormDB *gorm.DB, filterMap map[string]string) (*FsUserInfo, error) { + var resp FsUserInfo + + if filterMap != nil { + gormDB = gormDB.Scopes(handlers.FilterData(filterMap)) + } + + result := gormDB.Limit(1).Find(&resp) + if result.Error != nil { + return nil, result.Error + } else { + return &resp, nil + } +} + +func (p *FsUserInfoModel) CreateOrUpdate(gormDB *gorm.DB, req *FsUserInfo) (resp *FsUserInfo, err error) { + if req.Id > 0 { + err = gormDB.Save(req).Error + } else { + err = gormDB.Create(req).Error + } + return req, err +} diff --git a/model/gmodel/var_gen.go b/model/gmodel/var_gen.go index 46818f31..d8c7fa82 100644 --- a/model/gmodel/var_gen.go +++ b/model/gmodel/var_gen.go @@ -45,6 +45,7 @@ type AllModelsGen struct { FsLog *FsLogModel // fs_log 日志表 FsMapLibrary *FsMapLibraryModel // fs_map_library 贴图库 FsMenu *FsMenuModel // fs_menu 后台菜单 + FsMerchantCategory *FsMerchantCategoryModel // fs_merchant_category 商户类型表 FsMigration *FsMigrationModel // fs_migration 版本库 FsOrder *FsOrderModel // fs_order FsOrderAffiliate *FsOrderAffiliateModel // fs_order_affiliate 订单附属表-流程控制时间等 @@ -91,6 +92,7 @@ type AllModelsGen struct { FsTrade *FsTradeModel // fs_trade FsUser *FsUserModel // fs_user 用户表 FsUserDesign *FsUserDesignModel // fs_user_design 废弃表 + FsUserInfo *FsUserInfoModel // fs_user_info 用户信息表 FsUserMaterial *FsUserMaterialModel // fs_user_material 用户素材表 FsUserStock *FsUserStockModel // fs_user_stock 用户云仓库存 FsWebSet *FsWebSetModel // fs_web_set 网站配置表 @@ -140,6 +142,7 @@ func NewAllModels(gdb *gorm.DB) *AllModelsGen { FsLog: NewFsLogModel(gdb), FsMapLibrary: NewFsMapLibraryModel(gdb), FsMenu: NewFsMenuModel(gdb), + FsMerchantCategory: NewFsMerchantCategoryModel(gdb), FsMigration: NewFsMigrationModel(gdb), FsOrder: NewFsOrderModel(gdb), FsOrderAffiliate: NewFsOrderAffiliateModel(gdb), @@ -186,6 +189,7 @@ func NewAllModels(gdb *gorm.DB) *AllModelsGen { FsTrade: NewFsTradeModel(gdb), FsUser: NewFsUserModel(gdb), FsUserDesign: NewFsUserDesignModel(gdb), + FsUserInfo: NewFsUserInfoModel(gdb), FsUserMaterial: NewFsUserMaterialModel(gdb), FsUserStock: NewFsUserStockModel(gdb), FsWebSet: NewFsWebSetModel(gdb), diff --git a/server/base/base.go b/server/base/base.go new file mode 100644 index 00000000..df2962f3 --- /dev/null +++ b/server/base/base.go @@ -0,0 +1,36 @@ +package main + +import ( + "flag" + "fmt" + "net/http" + "time" + + "fusenapi/utils/auth" + + "fusenapi/server/base/internal/config" + "fusenapi/server/base/internal/handler" + "fusenapi/server/base/internal/svc" + + "github.com/zeromicro/go-zero/core/conf" + "github.com/zeromicro/go-zero/rest" +) + +var configFile = flag.String("f", "etc/base.yaml", "the config file") + +func main() { + flag.Parse() + + 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() + + ctx := svc.NewServiceContext(c) + handler.RegisterHandlers(server, ctx) + + fmt.Printf("Starting server at %s:%d...\n", c.Host, c.Port) + server.Start() +} diff --git a/server/base/base_test.go b/server/base/base_test.go new file mode 100644 index 00000000..80820ef2 --- /dev/null +++ b/server/base/base_test.go @@ -0,0 +1,9 @@ +package main + +import ( + "testing" +) + +func TestMain(t *testing.T) { + main() +} diff --git a/server/base/etc/base.yaml b/server/base/etc/base.yaml new file mode 100644 index 00000000..e201a85b --- /dev/null +++ b/server/base/etc/base.yaml @@ -0,0 +1,10 @@ +Name: base +Host: 0.0.0.0 +Port: 9920 +Timeout: 15000 #服务超时时间(毫秒) +SourceMysql: fusentest:XErSYmLELKMnf3Dh@tcp(110.41.19.98:3306)/fusentest +Auth: + AccessSecret: fusen2023 + AccessExpire: 2592000 + RefreshAfter: 1592000 +SourceRabbitMq: amqp://rabbit001:rabbit001129@110.41.19.98:5672 \ No newline at end of file diff --git a/server/base/internal/config/config.go b/server/base/internal/config/config.go new file mode 100644 index 00000000..be42afd5 --- /dev/null +++ b/server/base/internal/config/config.go @@ -0,0 +1,14 @@ +package config + +import ( + "fusenapi/server/base/internal/types" + + "github.com/zeromicro/go-zero/rest" +) + +type Config struct { + rest.RestConf + SourceMysql string + Auth types.Auth + SourceRabbitMq string +} diff --git a/server/base/internal/handler/merchantcategorylisthandler.go b/server/base/internal/handler/merchantcategorylisthandler.go new file mode 100644 index 00000000..c7b4484a --- /dev/null +++ b/server/base/internal/handler/merchantcategorylisthandler.go @@ -0,0 +1,35 @@ +package handler + +import ( + "net/http" + "reflect" + + "fusenapi/utils/basic" + + "fusenapi/server/base/internal/logic" + "fusenapi/server/base/internal/svc" + "fusenapi/server/base/internal/types" +) + +func MerchantCategoryListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + + var req types.MerchantCategoryListReq + userinfo, err := basic.RequestParse(w, r, svcCtx, &req) + if err != nil { + return + } + + // 创建一个业务逻辑层实例 + l := logic.NewMerchantCategoryListLogic(r.Context(), svcCtx) + + rl := reflect.ValueOf(l) + basic.BeforeLogic(w, r, rl) + + resp := l.MerchantCategoryList(&req, userinfo) + + if !basic.AfterLogic(w, r, rl, resp) { + basic.NormalAfterLogic(w, r, resp) + } + } +} diff --git a/server/base/internal/handler/routes.go b/server/base/internal/handler/routes.go new file mode 100644 index 00000000..4f4764c0 --- /dev/null +++ b/server/base/internal/handler/routes.go @@ -0,0 +1,22 @@ +// Code generated by goctl. DO NOT EDIT. +package handler + +import ( + "net/http" + + "fusenapi/server/base/internal/svc" + + "github.com/zeromicro/go-zero/rest" +) + +func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { + server.AddRoutes( + []rest.Route{ + { + Method: http.MethodGet, + Path: "/api/base/merchant_category_list", + Handler: MerchantCategoryListHandler(serverCtx), + }, + }, + ) +} diff --git a/server/base/internal/logic/merchantcategorylistlogic.go b/server/base/internal/logic/merchantcategorylistlogic.go new file mode 100644 index 00000000..eb9dd3ae --- /dev/null +++ b/server/base/internal/logic/merchantcategorylistlogic.go @@ -0,0 +1,53 @@ +package logic + +import ( + "fusenapi/model/gmodel" + "fusenapi/utils/auth" + "fusenapi/utils/basic" + + "context" + + "fusenapi/server/base/internal/svc" + "fusenapi/server/base/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type MerchantCategoryListLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewMerchantCategoryListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *MerchantCategoryListLogic { + return &MerchantCategoryListLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +// 处理进入前逻辑w,r +// func (l *MerchantCategoryListLogic) BeforeLogic(w http.ResponseWriter, r *http.Request) { +// } + +// 处理逻辑后 w,r 如:重定向, resp 必须重新处理 +// func (l *MerchantCategoryListLogic) AfterLogic(w http.ResponseWriter, r *http.Request, resp *basic.Response) { +// // httpx.OkJsonCtx(r.Context(), w, resp) +// } + +func (l *MerchantCategoryListLogic) MerchantCategoryList(req *types.MerchantCategoryListReq, userinfo *auth.UserInfo) (resp *basic.Response) { + // 返回值必须调用Set重新返回, resp可以空指针调用 resp.SetStatus(basic.CodeOK, data) + // userinfo 传入值时, 一定不为null + fsMerchantCategoryModel := gmodel.NewFsMerchantCategoryModel(l.svcCtx.MysqlConn) + BuilderDB := fsMerchantCategoryModel.BuilderDB(l.ctx, nil).Model(&gmodel.FsMerchantCategory{}) + resourceInfo, err := fsMerchantCategoryModel.FindAll(BuilderDB, nil, "sort desc") + if err != nil { + logx.Error(err) + return resp.SetStatus(basic.CodeDbSqlErr, "MerchantCategoryList error system failed") + } + // 返回成功 + return resp.SetStatus(basic.CodeOK, map[string]interface{}{ + "list": resourceInfo, + }) +} diff --git a/server/base/internal/svc/servicecontext.go b/server/base/internal/svc/servicecontext.go new file mode 100644 index 00000000..335cab29 --- /dev/null +++ b/server/base/internal/svc/servicecontext.go @@ -0,0 +1,62 @@ +package svc + +import ( + "errors" + "fmt" + "fusenapi/server/base/internal/config" + "net/http" + + "fusenapi/initalize" + "fusenapi/model/gmodel" + + "github.com/golang-jwt/jwt" + "gorm.io/gorm" +) + +type ServiceContext struct { + Config config.Config + + MysqlConn *gorm.DB + AllModels *gmodel.AllModelsGen + RabbitMq *initalize.RabbitMqHandle +} + +func NewServiceContext(c config.Config) *ServiceContext { + return &ServiceContext{ + Config: c, + MysqlConn: initalize.InitMysql(c.SourceMysql), + AllModels: gmodel.NewAllModels(initalize.InitMysql(c.SourceMysql)), + RabbitMq: initalize.InitRabbitMq(c.SourceRabbitMq, nil), + } +} + +func (svcCtx *ServiceContext) ParseJwtToken(r *http.Request) (jwt.MapClaims, error) { + AuthKey := r.Header.Get("Authorization") + if AuthKey == "" { + return nil, nil + } + AuthKey = AuthKey[7:] + + if len(AuthKey) <= 50 { + return nil, errors.New(fmt.Sprint("Error parsing token, len:", len(AuthKey))) + } + + token, err := jwt.Parse(AuthKey, func(token *jwt.Token) (interface{}, error) { + // 检查签名方法是否为 HS256 + if _, ok := token.Method.(*jwt.SigningMethodHMAC); !ok { + return nil, fmt.Errorf("unexpected signing method: %v", token.Header["alg"]) + } + // 返回用于验证签名的密钥 + return []byte(svcCtx.Config.Auth.AccessSecret), nil + }) + if err != nil { + return nil, errors.New(fmt.Sprint("Error parsing token:", err)) + } + + // 验证成功返回 + if claims, ok := token.Claims.(jwt.MapClaims); ok && token.Valid { + return claims, nil + } + + return nil, errors.New(fmt.Sprint("Invalid token", err)) +} diff --git a/server/base/internal/types/types.go b/server/base/internal/types/types.go new file mode 100644 index 00000000..afa558e9 --- /dev/null +++ b/server/base/internal/types/types.go @@ -0,0 +1,78 @@ +// Code generated by goctl. DO NOT EDIT. +package types + +import ( + "fusenapi/utils/basic" +) + +type MerchantCategoryListReq struct { +} + +type Request struct { +} + +type Response struct { + Code int `json:"code"` + Message string `json:"msg"` + Data interface{} `json:"data"` +} + +type Auth struct { + AccessSecret string `json:"accessSecret"` + AccessExpire int64 `json:"accessExpire"` + RefreshAfter int64 `json:"refreshAfter"` +} + +type File struct { + Filename string `fsfile:"filename"` + Header map[string][]string `fsfile:"header"` + Size int64 `fsfile:"size"` + Data []byte `fsfile:"data"` +} + +type Meta struct { + TotalCount int64 `json:"totalCount"` + PageCount int64 `json:"pageCount"` + CurrentPage int `json:"currentPage"` + PerPage int `json:"perPage"` +} + +// Set 设置Response的Code和Message值 +func (resp *Response) Set(Code int, Message string) *Response { + return &Response{ + Code: Code, + Message: Message, + } +} + +// Set 设置整个Response +func (resp *Response) SetWithData(Code int, Message string, Data interface{}) *Response { + return &Response{ + Code: Code, + Message: Message, + Data: Data, + } +} + +// SetStatus 设置默认StatusResponse(内部自定义) 默认msg, 可以带data, data只使用一个参数 +func (resp *Response) SetStatus(sr *basic.StatusResponse, data ...interface{}) *Response { + newResp := &Response{ + Code: sr.Code, + } + if len(data) == 1 { + newResp.Data = data[0] + } + return newResp +} + +// SetStatusWithMessage 设置默认StatusResponse(内部自定义) 非默认msg, 可以带data, data只使用一个参数 +func (resp *Response) SetStatusWithMessage(sr *basic.StatusResponse, msg string, data ...interface{}) *Response { + newResp := &Response{ + Code: sr.Code, + Message: msg, + } + if len(data) == 1 { + newResp.Data = data[0] + } + return newResp +} diff --git a/server/home-user-auth/internal/handler/routes.go b/server/home-user-auth/internal/handler/routes.go index 607e6278..c6957627 100644 --- a/server/home-user-auth/internal/handler/routes.go +++ b/server/home-user-auth/internal/handler/routes.go @@ -102,6 +102,11 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { Path: "/api/user/one-more-order", Handler: UserAgainOrderHandler(serverCtx), }, + { + Method: http.MethodPost, + Path: "/api/user/set_user_info", + Handler: UserInfoSetHandler(serverCtx), + }, }, ) } diff --git a/server/home-user-auth/internal/handler/userinfosethandler.go b/server/home-user-auth/internal/handler/userinfosethandler.go new file mode 100644 index 00000000..8593b501 --- /dev/null +++ b/server/home-user-auth/internal/handler/userinfosethandler.go @@ -0,0 +1,35 @@ +package handler + +import ( + "net/http" + "reflect" + + "fusenapi/utils/basic" + + "fusenapi/server/home-user-auth/internal/logic" + "fusenapi/server/home-user-auth/internal/svc" + "fusenapi/server/home-user-auth/internal/types" +) + +func UserInfoSetHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + + var req types.UserInfoSetReq + userinfo, err := basic.RequestParse(w, r, svcCtx, &req) + if err != nil { + return + } + + // 创建一个业务逻辑层实例 + l := logic.NewUserInfoSetLogic(r.Context(), svcCtx) + + rl := reflect.ValueOf(l) + basic.BeforeLogic(w, r, rl) + + resp := l.UserInfoSet(&req, userinfo) + + if !basic.AfterLogic(w, r, rl, resp) { + basic.NormalAfterLogic(w, r, resp) + } + } +} diff --git a/server/home-user-auth/internal/logic/userinfosetlogic.go b/server/home-user-auth/internal/logic/userinfosetlogic.go new file mode 100644 index 00000000..c27836b8 --- /dev/null +++ b/server/home-user-auth/internal/logic/userinfosetlogic.go @@ -0,0 +1,95 @@ +package logic + +import ( + "fusenapi/model/gmodel" + "fusenapi/utils/auth" + "fusenapi/utils/basic" + "fusenapi/utils/validate" + "time" + + "context" + + "fusenapi/server/home-user-auth/internal/svc" + "fusenapi/server/home-user-auth/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type UserInfoSetLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewUserInfoSetLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UserInfoSetLogic { + return &UserInfoSetLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +// 处理进入前逻辑w,r +// func (l *UserInfoSetLogic) BeforeLogic(w http.ResponseWriter, r *http.Request) { +// } + +// 处理逻辑后 w,r 如:重定向, resp 必须重新处理 +// func (l *UserInfoSetLogic) AfterLogic(w http.ResponseWriter, r *http.Request, resp *basic.Response) { +// // httpx.OkJsonCtx(r.Context(), w, resp) +// } + +func (l *UserInfoSetLogic) UserInfoSet(req *types.UserInfoSetReq, userinfo *auth.UserInfo) (resp *basic.Response) { + // 返回值必须调用Set重新返回, resp可以空指针调用 resp.SetStatus(basic.CodeOK, data) + // userinfo 传入值时, 一定不为null + if userinfo.IsOnlooker() { + // 如果是,返回未授权的错误码 + return resp.SetStatus(basic.CodeUnAuth) + } + + var userId int64 + var guestId int64 + + // 检查用户是否是游客 + if userinfo.IsGuest() { + // 如果是,使用游客ID和游客键名格式 + guestId = userinfo.GuestId + } else { + // 否则,使用用户ID和用户键名格式 + userId = userinfo.UserId + } + + _, err := validate.Validate(&req.Module, &req.Metadata) + if err != nil { + logx.Error(err) + return resp.SetStatus(basic.CodeRequestParamsErr, "UserInfoSet error Validate failed") + } + + // 根据模块类型检查数据 + var userInfo = &gmodel.FsUserInfo{} + fsUserInfoModel := gmodel.NewFsUserInfoModel(l.svcCtx.MysqlConn) + BuilderDB := fsUserInfoModel.BuilderDB(l.ctx, nil).Model(&gmodel.FsUserInfo{}) + BuilderDB1 := BuilderDB.Where("module = ?", req.Module).Where("user_id=?", userId).Where("guest_id=?", guestId) + userInfo, err = fsUserInfoModel.FindOne(BuilderDB1, nil) + if err != nil { + logx.Error(err) + return resp.SetStatus(basic.CodeDbSqlErr, "UserInfoSet error system failed") + } + var nowTime = time.Now().Unix() + if userInfo.Id != 0 { + userInfo.Metadata = &req.Metadata + userInfo.Utime = &nowTime + } else { + userInfo.GuestId = &guestId + userInfo.UserId = &userId + userInfo.Module = &req.Module + userInfo.Metadata = &req.Metadata + userInfo.Ctime = &nowTime + } + _, err = fsUserInfoModel.CreateOrUpdate(BuilderDB, userInfo) + if err != nil { + logx.Error(err) + return resp.SetStatus(basic.CodeDbSqlErr, "UserInfoSet error system failed") + } + + return resp.SetStatus(basic.CodeOK) +} diff --git a/server/home-user-auth/internal/types/types.go b/server/home-user-auth/internal/types/types.go index b183ef86..6bbf9f49 100644 --- a/server/home-user-auth/internal/types/types.go +++ b/server/home-user-auth/internal/types/types.go @@ -5,6 +5,11 @@ import ( "fusenapi/utils/basic" ) +type UserInfoSetReq struct { + Module string `form:"module,options=[merchant_category]"` // json格式字符串 + Metadata string `form:"metadata"` // json格式字符串 +} + type UserAgainOrderReq struct { Sn string `form:"sn"` // 订单编号 } diff --git a/server_api/base.api b/server_api/base.api new file mode 100644 index 00000000..3a174324 --- /dev/null +++ b/server_api/base.api @@ -0,0 +1,20 @@ +syntax = "v1" + +info ( + title: // TODO: add title + desc: // TODO: add description + author: "" + email: "" +) + +import "basic.api" + +service base { + @handler MerchantCategoryListHandler + get /api/base/merchant_category_list(MerchantCategoryListReq) returns (response); +} + +type ( + MerchantCategoryListReq { + } +) \ No newline at end of file diff --git a/server_api/home-user-auth.api b/server_api/home-user-auth.api index 3b686163..62ae1f35 100644 --- a/server_api/home-user-auth.api +++ b/server_api/home-user-auth.api @@ -75,8 +75,19 @@ service home-user-auth { // 再来一单 @handler UserAgainOrderHandler get /api/user/one-more-order (UserAgainOrderReq) returns (response); + + // 保存商户信息 + @handler UserInfoSetHandler + post /api/user/set_user_info (UserInfoSetReq) returns (response); } +type ( + UserInfoSetReq { + Module string `form:"module,options=[merchant_category]"` // json格式字符串 + Metadata string `form:"metadata"` // json格式字符串 + } +) + type ( UserAgainOrderReq { Sn string `form:"sn"` // 订单编号 diff --git a/utils/validate/user_info.go b/utils/validate/user_info.go new file mode 100644 index 00000000..9e0342ec --- /dev/null +++ b/utils/validate/user_info.go @@ -0,0 +1,26 @@ +package validate + +import ( + "encoding/json" + "errors" +) + +type MerchantCategory struct { + CategoryId int64 `json:"category_id"` +} + +func Validate(module *string, metadata *string) (interface{}, error) { + if *module == "merchant_category" { + var merchantCategory MerchantCategory + err := json.Unmarshal([]byte(*metadata), &merchantCategory) + if err != nil { + return nil, err + } else { + if merchantCategory.CategoryId == 0 { + return nil, errors.New("merchant_category.category_id is required") + } + return merchantCategory, nil + } + } + return nil, nil +} From b7849935a0f9f70234ca378c58bf2f5c834254a7 Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Mon, 14 Aug 2023 15:06:32 +0800 Subject: [PATCH 026/151] fix --- model/gmodel/fs_product_template_tags_gen.go | 3 ++- model/gmodel/var_gen.go | 2 ++ .../internal/logic/getproducttemplatetagslogic.go | 2 +- server/product/internal/logic/gettemplatebypidlogic.go | 6 +----- 4 files changed, 6 insertions(+), 7 deletions(-) diff --git a/model/gmodel/fs_product_template_tags_gen.go b/model/gmodel/fs_product_template_tags_gen.go index 227af16d..07d86482 100644 --- a/model/gmodel/fs_product_template_tags_gen.go +++ b/model/gmodel/fs_product_template_tags_gen.go @@ -8,9 +8,10 @@ import ( type FsProductTemplateTags struct { Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` // ID Title *string `gorm:"default:'';" json:"title"` // 标题 - CoverImg *string `gorm:"default:'';" json:"cover_img"` // 封面图 + Cover *string `gorm:"default:'';" json:"cover"` // 封面图 Status *int64 `gorm:"default:0;" json:"status"` // 状态 1:可用 CreateAt *int64 `gorm:"default:0;" json:"create_at"` // 创建时间 + Groups *string `gorm:"default:'';" json:"groups"` // 分组信息 } type FsProductTemplateTagsModel struct { db *gorm.DB diff --git a/model/gmodel/var_gen.go b/model/gmodel/var_gen.go index b62e2377..831f79d8 100644 --- a/model/gmodel/var_gen.go +++ b/model/gmodel/var_gen.go @@ -91,6 +91,7 @@ type AllModelsGen struct { FsTrade *FsTradeModel // fs_trade FsUser *FsUserModel // fs_user 用户表 FsUserDesign *FsUserDesignModel // fs_user_design 废弃表 + FsUserInfo *FsUserInfoModel // fs_user_info 用户信息表 FsUserMaterial *FsUserMaterialModel // fs_user_material 用户素材表 FsUserStock *FsUserStockModel // fs_user_stock 用户云仓库存 FsWebSet *FsWebSetModel // fs_web_set 网站配置表 @@ -186,6 +187,7 @@ func NewAllModels(gdb *gorm.DB) *AllModelsGen { FsTrade: NewFsTradeModel(gdb), FsUser: NewFsUserModel(gdb), FsUserDesign: NewFsUserDesignModel(gdb), + FsUserInfo: NewFsUserInfoModel(gdb), FsUserMaterial: NewFsUserMaterialModel(gdb), FsUserStock: NewFsUserStockModel(gdb), FsWebSet: NewFsWebSetModel(gdb), diff --git a/server/product-template-tag/internal/logic/getproducttemplatetagslogic.go b/server/product-template-tag/internal/logic/getproducttemplatetagslogic.go index 815ef07c..cb335505 100644 --- a/server/product-template-tag/internal/logic/getproducttemplatetagslogic.go +++ b/server/product-template-tag/internal/logic/getproducttemplatetagslogic.go @@ -49,7 +49,7 @@ func (l *GetProductTemplateTagsLogic) GetProductTemplateTags(req *types.GetProdu list = append(list, types.GetProductTemplateTagsRsp{ Id: v.Id, Tag: *v.Title, - Cover: *v.CoverImg, + Cover: *v.Cover, }) } return resp.SetStatusWithMessage(basic.CodeOK, "success", list) diff --git a/server/product/internal/logic/gettemplatebypidlogic.go b/server/product/internal/logic/gettemplatebypidlogic.go index d13dbd0a..e14a0c88 100644 --- a/server/product/internal/logic/gettemplatebypidlogic.go +++ b/server/product/internal/logic/gettemplatebypidlogic.go @@ -110,14 +110,10 @@ func (l *GetTemplateByPidLogic) GetTemplateByPid(req *types.GetTemplateByPidReq, _ = json.Unmarshal([]byte(*templateInfo.SwitchInfo), &switchInfo) } modelInfo := modelList[modelIndex] - var material interface{} - if info["module_data"] != nil && info["module_data"]["material"] != nil { - material = info["module_data"]["material"] - } mapKey := fmt.Sprintf("_%d", *modelInfo.SizeId) rsp[mapKey] = map[string]interface{}{ "id": templateInfo.Id, - "material": material, + "material": *templateInfo.MaterialImg, "material_data": switchInfo, } } From 81bfb0dda8dac0980219d862d5c7eda568aed6a3 Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Mon, 14 Aug 2023 15:07:12 +0800 Subject: [PATCH 027/151] fix --- model/gmodel/fs_user_info_gen.go | 25 +++++++++++++++++++++++++ model/gmodel/fs_user_info_logic.go | 2 ++ 2 files changed, 27 insertions(+) create mode 100644 model/gmodel/fs_user_info_gen.go create mode 100644 model/gmodel/fs_user_info_logic.go diff --git a/model/gmodel/fs_user_info_gen.go b/model/gmodel/fs_user_info_gen.go new file mode 100644 index 00000000..71b1bd7a --- /dev/null +++ b/model/gmodel/fs_user_info_gen.go @@ -0,0 +1,25 @@ +package gmodel + +import ( + "gorm.io/gorm" +) + +// fs_user_info 用户信息表 +type FsUserInfo struct { + Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` // ID + Module *string `gorm:"default:'';" json:"module"` // 所属模块 + UserId *int64 `gorm:"index;default:0;" json:"user_id"` // 用户 ID + GuestId *int64 `gorm:"index;default:0;" json:"guest_id"` // 访客 ID + Metadata *string `gorm:"default:'';" json:"metadata"` // 元数据,json格式 + MetaKey1 *string `gorm:"default:'';" json:"meta_key1"` // 需要关键信息查询的自定义属性1,可以动态增加 + Ctime *int64 `gorm:"default:0;" json:"ctime"` // + Utime *int64 `gorm:"default:0;" json:"utime"` // +} +type FsUserInfoModel struct { + db *gorm.DB + name string +} + +func NewFsUserInfoModel(db *gorm.DB) *FsUserInfoModel { + return &FsUserInfoModel{db: db, name: "fs_user_info"} +} diff --git a/model/gmodel/fs_user_info_logic.go b/model/gmodel/fs_user_info_logic.go new file mode 100644 index 00000000..e68225aa --- /dev/null +++ b/model/gmodel/fs_user_info_logic.go @@ -0,0 +1,2 @@ +package gmodel +// TODO: 使用model的属性做你想做的 \ No newline at end of file From 357f402031d8364314240907e557f98606e592ba Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Mon, 14 Aug 2023 15:18:07 +0800 Subject: [PATCH 028/151] fix --- .../render/consumer/assemble_render_data.go | 27 ++++++++++--------- 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/server/render/consumer/assemble_render_data.go b/server/render/consumer/assemble_render_data.go index bf368975..2eaf2831 100644 --- a/server/render/consumer/assemble_render_data.go +++ b/server/render/consumer/assemble_render_data.go @@ -175,13 +175,13 @@ func getCombineImage(ctx context.Context, svcCtx *svc.ServiceContext, parseInfo return "", errors.New("product template info`template_info is empty") } //反序列化替换其中一些参数 - var combineInfo map[string]interface{} - if err = json.Unmarshal([]byte(*productTemplate.TemplateInfo), &combineInfo); err != nil { + var moduleInfo interface{} + if err = json.Unmarshal([]byte(*productTemplate.TemplateInfo), &moduleInfo); err != nil { logx.Error("failed to parse json:template_info:", err) return "", err } //需要替换的参数 - replaceData := map[string]interface{}{ + paramData := map[string]interface{}{ "logo_url": parseInfo.RenderData.Logo, "website": parseInfo.RenderData.Website, "slogan": parseInfo.RenderData.Slogan, @@ -214,17 +214,20 @@ func getCombineImage(ctx context.Context, svcCtx *svc.ServiceContext, parseInfo return "", err } //赋值 - replaceData["colors"] = materialMetaData["colors"] - replaceData["logo_url"] = materialMetaData["logo_url"] - replaceData["shape"] = materialMetaData["shape"] - replaceData["is_crop"] = materialMetaData["is_crop"] - replaceData["ratio"] = materialMetaData["ratio"] - replaceData["line"] = materialMetaData["line"] - replaceData["other"] = materialMetaData["other"] - replaceData["other1"] = materialMetaData["other1"] + paramData["colors"] = materialMetaData["colors"] + paramData["logo_url"] = materialMetaData["logo_url"] + paramData["shape"] = materialMetaData["shape"] + paramData["is_crop"] = materialMetaData["is_crop"] + paramData["ratio"] = materialMetaData["ratio"] + paramData["line"] = materialMetaData["line"] + paramData["other"] = materialMetaData["other"] + paramData["other1"] = materialMetaData["other1"] } } - combineInfo["param_data"] = replaceData + combineInfo := map[string]interface{}{ + "module_data": moduleInfo, + "param_data": paramData, + } postData, _ := json.Marshal(combineInfo) //请求合成图片 url := svcCtx.Config.PythonApi.CombineImageUrl From 50da55d7bb9d60b78c67856f1466ef665b8cb009 Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Mon, 14 Aug 2023 15:46:28 +0800 Subject: [PATCH 029/151] fix --- server/render/consumer/assemble_render_data.go | 9 +++++---- server/render/etc/render.yaml | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/server/render/consumer/assemble_render_data.go b/server/render/consumer/assemble_render_data.go index 2eaf2831..a37a131c 100644 --- a/server/render/consumer/assemble_render_data.go +++ b/server/render/consumer/assemble_render_data.go @@ -17,6 +17,7 @@ import ( "github.com/zeromicro/go-zero/core/logx" "gorm.io/gorm" "io/ioutil" + "os" "strconv" "time" ) @@ -233,9 +234,9 @@ func getCombineImage(ctx context.Context, svcCtx *svc.ServiceContext, parseInfo url := svcCtx.Config.PythonApi.CombineImageUrl header := make(map[string]string) header["content-type"] = "application/json" - /*f, _ := os.Create("a.txt") - defer f.Close() - f.Write(postData)*/ + /* f, _ := os.Create("a.txt") + defer f.Close() + f.Write(postData)*/ httpRsp, err := curl.ApiCall(url, "POST", header, bytes.NewReader(postData), time.Second*20) if err != nil { logx.Error("failed to combine logo:", err) @@ -252,7 +253,6 @@ func getCombineImage(ctx context.Context, svcCtx *svc.ServiceContext, parseInfo logx.Error("failed to parse python api rsp:", err) return "", err } - //fmt.Println("××××××××××××××××××××:", pythonApiInfo) //上传刀版图 var upload = file.Upload{ Ctx: ctx, @@ -271,5 +271,6 @@ func getCombineImage(ctx context.Context, svcCtx *svc.ServiceContext, parseInfo logx.Error("上传刀版图到s3失败:", err) return "", err } + logx.Info("发送渲染组装数据到unity成功") return uploadRes.ResourceUrl, nil } diff --git a/server/render/etc/render.yaml b/server/render/etc/render.yaml index 7081d46b..2be7fc7d 100644 --- a/server/render/etc/render.yaml +++ b/server/render/etc/render.yaml @@ -14,4 +14,4 @@ AWS: Secret: sjCEv0JxATnPCxno2KNLm0X8oDc7srUR+4vkYhvm Token: PythonApi: #python接口 - CombineImageUrl: http://192.168.1.7:45678/LogoCombine #合成刀版图接口 \ No newline at end of file + CombineImageUrl: http://18.119.109.254:8999/LogoCombine #合成刀版图接口 \ No newline at end of file From 1c03e5bb01594cce2ca47d3463c5e04876f15a6b Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Mon, 14 Aug 2023 15:49:24 +0800 Subject: [PATCH 030/151] fix --- server/render/consumer/assemble_render_data.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/server/render/consumer/assemble_render_data.go b/server/render/consumer/assemble_render_data.go index a37a131c..0953d70b 100644 --- a/server/render/consumer/assemble_render_data.go +++ b/server/render/consumer/assemble_render_data.go @@ -17,7 +17,6 @@ import ( "github.com/zeromicro/go-zero/core/logx" "gorm.io/gorm" "io/ioutil" - "os" "strconv" "time" ) @@ -250,7 +249,7 @@ func getCombineImage(ctx context.Context, svcCtx *svc.ServiceContext, parseInfo } var pythonApiInfo pythonApiRsp if err = json.Unmarshal(bytes, &pythonApiInfo); err != nil { - logx.Error("failed to parse python api rsp:", err) + logx.Error("请求python合图失败,err:", err, " 请求数据:", string(postData)) return "", err } //上传刀版图 From 63a7aa0a3de0f419251974825be2b5f1252a4a15 Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Mon, 14 Aug 2023 15:52:10 +0800 Subject: [PATCH 031/151] fix --- server/product/internal/logic/gettemplatebypidlogic.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/product/internal/logic/gettemplatebypidlogic.go b/server/product/internal/logic/gettemplatebypidlogic.go index e14a0c88..9e1b66d1 100644 --- a/server/product/internal/logic/gettemplatebypidlogic.go +++ b/server/product/internal/logic/gettemplatebypidlogic.go @@ -99,7 +99,7 @@ func (l *GetTemplateByPidLogic) GetTemplateByPid(req *types.GetTemplateByPidReq, continue } //基础模板信息 - var info map[string]map[string]interface{} + var info interface{} if err = json.Unmarshal([]byte(*templateInfo.TemplateInfo), &info); err != nil { logx.Error(err) return resp.SetStatusWithMessage(basic.CodeJsonErr, fmt.Sprintf("failed to parse json product template info(may be old data):%d", templateInfo.Id)) From 94a36bd98ed549c4f213186336ed717794ffae2e Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Mon, 14 Aug 2023 15:58:31 +0800 Subject: [PATCH 032/151] fix --- server/render/consumer/assemble_render_data.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/render/consumer/assemble_render_data.go b/server/render/consumer/assemble_render_data.go index 0953d70b..434dbee8 100644 --- a/server/render/consumer/assemble_render_data.go +++ b/server/render/consumer/assemble_render_data.go @@ -55,7 +55,7 @@ func (m *MqConsumerRenderAssemble) Run(ctx context.Context, data []byte) error { return nil //不返回错误就删除消息 } rabbitmq := initalize.RabbitMqHandle{} - //获取模板(产品第一个sku的模板) + //获取模板(模板标签下的对一个物料的的模板) productTemplate, err := svcCtx.AllModels.FsProductTemplateV2.FindOneByProductIdTagIdWithSizeTable(ctx, parseInfo.RenderData.ProductId, fmt.Sprintf("%d", parseInfo.RenderData.TemplateTagId)) if err != nil { if errors.Is(err, gorm.ErrRecordNotFound) { From 24a5bf11a39f5db5db1ac7640a25e7f745bafadb Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Mon, 14 Aug 2023 17:31:57 +0800 Subject: [PATCH 033/151] fix --- .../gmodel/fs_product_template_tags_logic.go | 11 ++ model/gmodel/fs_user_material_logic.go | 14 +- .../logic/getproducttemplatetagslogic.go | 38 ++++- .../render/consumer/assemble_render_data.go | 132 +----------------- utils/websocket_data/render_data.go | 8 +- 5 files changed, 61 insertions(+), 142 deletions(-) diff --git a/model/gmodel/fs_product_template_tags_logic.go b/model/gmodel/fs_product_template_tags_logic.go index 4c26d2fb..5ef7e6ae 100755 --- a/model/gmodel/fs_product_template_tags_logic.go +++ b/model/gmodel/fs_product_template_tags_logic.go @@ -32,3 +32,14 @@ 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 { + return nil, nil + } + db := pt.db.WithContext(ctx).Model(&FsProductTemplateTags{}).Where("`title` in (?) and `status` = ?", titles, 1) + if orderBy != "" { + db = db.Order(orderBy) + } + err = db.Limit(limit).Find(&resp).Error + return resp, err +} diff --git a/model/gmodel/fs_user_material_logic.go b/model/gmodel/fs_user_material_logic.go index 98c0bb08..c500f71e 100644 --- a/model/gmodel/fs_user_material_logic.go +++ b/model/gmodel/fs_user_material_logic.go @@ -61,12 +61,9 @@ func (m *FsUserMaterialModel) FindLatestOne(ctx context.Context, userId int64, g if userId == 0 && guestId == 0 { return FsUserMaterial{}, nil } - db := m.db.WithContext(ctx).Model(&FsUserMaterial{}).Order("id DESC") - if userId != 0 { - db = db.Where("`user_id` = ?", userId) - } else { - db = db.Where("`guest_id` = ?", guestId) - } + db := m.db.WithContext(ctx).Model(&FsUserMaterial{}). + Where("`user_id` = ? and `guest_id` = ?", userId, guestId). + Order("id DESC") err = db.Take(&resp).Error return resp, err } @@ -75,3 +72,8 @@ func (m *FsUserMaterialModel) FindOneById(ctx context.Context, id int64) (resp * err = m.db.WithContext(ctx).Model(&FsUserMaterial{}).Where("id = ?", id).Take(&resp).Error return resp, err } +func (m *FsUserMaterialModel) GetListByUser(ctx context.Context, userId, guestId int64, limit int) (resp *FsUserMaterial, err error) { + err = m.db.WithContext(ctx).Model(&FsUserMaterial{}). + Where("`user_id` = ? and `guest_id` = ?", userId, guestId).Order("id DESC").Limit(limit).Find(&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 cb335505..21953ee1 100644 --- a/server/product-template-tag/internal/logic/getproducttemplatetagslogic.go +++ b/server/product-template-tag/internal/logic/getproducttemplatetagslogic.go @@ -1,8 +1,12 @@ package logic import ( + "encoding/json" + "errors" + "fusenapi/model/gmodel" "fusenapi/utils/auth" "fusenapi/utils/basic" + "gorm.io/gorm" "context" @@ -37,9 +41,39 @@ func NewGetProductTemplateTagsLogic(ctx context.Context, svcCtx *svc.ServiceCont func (l *GetProductTemplateTagsLogic) GetProductTemplateTags(req *types.GetProductTemplateTagsReq, userinfo *auth.UserInfo) (resp *basic.Response) { if req.Limit <= 0 || req.Limit > 100 { - req.Limit = 4 + req.Limit = 5 + } + var ( + productTemplateTags []gmodel.FsProductTemplateTags + ) + //获取用户元数据 + userMaterial, err := l.svcCtx.AllModels.FsUserMaterial.GetListByUser(l.ctx, userinfo.UserId, userinfo.GuestId, req.Limit) + if err != nil { + if !errors.Is(err, gorm.ErrRecordNotFound) { + logx.Error(err) + return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get ai recommend product template tag list") + } + // 返回固定模板标签列表 + productTemplateTags, err = l.svcCtx.AllModels.FsProductTemplateTags.GetList(l.ctx, 1, req.Limit, "`id` DESC") + } else { + //元数据是空的 + if userMaterial.Metadata == nil || *userMaterial.Metadata == "" { + // 返回固定模板标签列表 + productTemplateTags, err = l.svcCtx.AllModels.FsProductTemplateTags.GetList(l.ctx, 1, req.Limit, "`id` DESC") + } else { + //解析元数据 + var metaData map[string]interface{} + if err = json.Unmarshal([]byte(*userMaterial.Metadata), &metaData); err != nil { + 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") + } + productTemplateTags, err = l.svcCtx.AllModels.FsProductTemplateTags.GetListByTitles(l.ctx, templateTagNameList, req.Limit, "id DESC") + } } - productTemplateTags, err := l.svcCtx.AllModels.FsProductTemplateTags.GetList(l.ctx, 1, req.Limit, "`id` DESC") if err != nil { logx.Error(err) return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get template tags") diff --git a/server/render/consumer/assemble_render_data.go b/server/render/consumer/assemble_render_data.go index 434dbee8..06b164ad 100644 --- a/server/render/consumer/assemble_render_data.go +++ b/server/render/consumer/assemble_render_data.go @@ -1,24 +1,17 @@ package consumer import ( - "bytes" "context" "encoding/json" "errors" "fmt" "fusenapi/constants" "fusenapi/initalize" - "fusenapi/model/gmodel" "fusenapi/server/render/internal/svc" - "fusenapi/utils/curl" - "fusenapi/utils/file" - "fusenapi/utils/hash" "fusenapi/utils/websocket_data" "github.com/zeromicro/go-zero/core/logx" "gorm.io/gorm" - "io/ioutil" "strconv" - "time" ) // 这里请求的py接口返回数据 @@ -65,23 +58,8 @@ func (m *MqConsumerRenderAssemble) Run(ctx context.Context, data []byte) error { logx.Error("failed to get template info:", err) return nil //不返回错误就删除消息 } - combineImage := "" //刀版图 - combineHash := hash.JsonHashKey(parseInfo) //区别于云渲染的taskid,这个用获取刀版图缓存 - //获取该hash值下有没有对应的资源 - resource, err := svcCtx.AllModels.FsResource.FindOneById(ctx, combineHash) - if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) { - logx.Error("failed to get resource :", err) - return nil //不返回错误就删除消息 - } - //如果不存在,则请求生成刀版图 - if errors.Is(err, gorm.ErrRecordNotFound) { - combineImage, err = getCombineImage(ctx, svcCtx, parseInfo, productTemplate, combineHash) - if err != nil { - return nil //不返回错误就删除消息 - } - } else { - combineImage = *resource.ResourceUrl - } + //获取刀版图 + combineImage := "" //刀版图 //获取渲染设置信息 element, err := svcCtx.AllModels.FsProductTemplateElement.FindOneByModelId(ctx, *productTemplate.ModelId) if err != nil { @@ -167,109 +145,3 @@ func (m *MqConsumerRenderAssemble) Run(ctx context.Context, data []byte) error { logx.Info("发送渲染组装数据到unity成功") return nil } - -// 获取刀版图 -func getCombineImage(ctx context.Context, svcCtx *svc.ServiceContext, parseInfo websocket_data.AssembleRenderData, productTemplate *gmodel.FsProductTemplateV2, combineHash string) (image string, err error) { - if productTemplate.TemplateInfo == nil || *productTemplate.TemplateInfo == "" { - logx.Error("product template info`template_info is empty") - return "", errors.New("product template info`template_info is empty") - } - //反序列化替换其中一些参数 - var moduleInfo interface{} - if err = json.Unmarshal([]byte(*productTemplate.TemplateInfo), &moduleInfo); err != nil { - logx.Error("failed to parse json:template_info:", err) - return "", err - } - //需要替换的参数 - paramData := map[string]interface{}{ - "logo_url": parseInfo.RenderData.Logo, - "website": parseInfo.RenderData.Website, - "slogan": parseInfo.RenderData.Slogan, - "address": parseInfo.RenderData.Address, - "phone": parseInfo.RenderData.Phone, - "colors": []string{}, - "template_tagid": []string{"b1a"}, - "is_crop": false, - "shape": "", - "ratio": 0, - "line": "", - "other": "", - "other1": "", - } - //获取用户素材信息 - if parseInfo.RenderData.UserMaterialId > 0 { - userMaterial, err := svcCtx.AllModels.FsUserMaterial.FindOneById(ctx, parseInfo.RenderData.UserMaterialId) - if err != nil { - if errors.Is(err, gorm.ErrRecordNotFound) { - logx.Error("user material not exists:", parseInfo.RenderData.UserMaterialId) - return "", errors.New("user material not exists") - } - logx.Error("err failed to get user material info") - } - if userMaterial.Metadata != nil && *userMaterial.Metadata != "" { - //解析元数据 - var materialMetaData map[string]interface{} - if err = json.Unmarshal([]byte(*userMaterial.Metadata), &materialMetaData); err != nil { - logx.Error("failed to parse user material`matadata: ", err) - return "", err - } - //赋值 - paramData["colors"] = materialMetaData["colors"] - paramData["logo_url"] = materialMetaData["logo_url"] - paramData["shape"] = materialMetaData["shape"] - paramData["is_crop"] = materialMetaData["is_crop"] - paramData["ratio"] = materialMetaData["ratio"] - paramData["line"] = materialMetaData["line"] - paramData["other"] = materialMetaData["other"] - paramData["other1"] = materialMetaData["other1"] - } - } - combineInfo := map[string]interface{}{ - "module_data": moduleInfo, - "param_data": paramData, - } - postData, _ := json.Marshal(combineInfo) - //请求合成图片 - url := svcCtx.Config.PythonApi.CombineImageUrl - header := make(map[string]string) - header["content-type"] = "application/json" - /* f, _ := os.Create("a.txt") - defer f.Close() - f.Write(postData)*/ - httpRsp, err := curl.ApiCall(url, "POST", header, bytes.NewReader(postData), time.Second*20) - if err != nil { - logx.Error("failed to combine logo:", err) - return "", err - } - defer httpRsp.Body.Close() - bytes, err := ioutil.ReadAll(httpRsp.Body) - if err != nil { - logx.Error("failed to read python api rsp body:", err) - return "", err - } - var pythonApiInfo pythonApiRsp - if err = json.Unmarshal(bytes, &pythonApiInfo); err != nil { - logx.Error("请求python合图失败,err:", err, " 请求数据:", string(postData)) - return "", err - } - //上传刀版图 - var upload = file.Upload{ - Ctx: ctx, - MysqlConn: svcCtx.MysqlConn, - AwsSession: svcCtx.AwsSession, - } - uploadRes, err := upload.UploadFileByBase64(&file.UploadBaseReq{ - FileHash: combineHash, - FileData: pythonApiInfo.Result, - UploadBucket: 1, - ApiType: 2, - UserId: parseInfo.RenderData.UserId, - GuestId: parseInfo.RenderData.GuestId, - }) - if err != nil { - logx.Error("上传刀版图到s3失败:", err) - return "", err - } - logx.Info("发送渲染组装数据到unity成功") - return uploadRes.ResourceUrl, nil -} diff --git a/utils/websocket_data/render_data.go b/utils/websocket_data/render_data.go index fcec9690..3b004441 100644 --- a/utils/websocket_data/render_data.go +++ b/utils/websocket_data/render_data.go @@ -16,12 +16,12 @@ type RenderData struct { 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 05e385313406d4c5cfef26553b17fadb8f026833 Mon Sep 17 00:00:00 2001 From: Hiven Date: Mon, 14 Aug 2023 17:56:06 +0800 Subject: [PATCH 034/151] =?UTF-8?q?fix:=E9=87=8D=E6=9E=84=E5=90=88?= =?UTF-8?q?=E5=9B=BE=E6=A8=A1=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- constants/blm_service.go | 5 + initalize/service.go | 24 +++ server/resource/etc/resource.yaml | 1 + server/resource/internal/config/config.go | 1 + .../internal/logic/logocombinelogic.go | 132 +------------ .../resource/internal/svc/servicecontext.go | 14 +- service/repositories/image_handle.go | 179 ++++++++++++++++++ 7 files changed, 230 insertions(+), 126 deletions(-) create mode 100644 constants/blm_service.go create mode 100644 initalize/service.go create mode 100644 service/repositories/image_handle.go diff --git a/constants/blm_service.go b/constants/blm_service.go new file mode 100644 index 00000000..d4a36c9e --- /dev/null +++ b/constants/blm_service.go @@ -0,0 +1,5 @@ +package constants + +const ( + BLMServiceUrlLogoCombine string = "/LogoCombine" +) diff --git a/initalize/service.go b/initalize/service.go new file mode 100644 index 00000000..7e486360 --- /dev/null +++ b/initalize/service.go @@ -0,0 +1,24 @@ +package initalize + +import ( + "fusenapi/service/repositories" + + "github.com/aws/aws-sdk-go/aws/session" + "gorm.io/gorm" +) + +type Repositories struct { + ImageHandle repositories.ImageHandle +} + +type NewAllRepositorieData struct { + GormDB *gorm.DB + BLMServiceUrl *string + AwsSession *session.Session +} + +func NewAllRepositories(newData *NewAllRepositorieData) *Repositories { + return &Repositories{ + ImageHandle: repositories.NewImageHandle(newData.GormDB, newData.BLMServiceUrl, newData.AwsSession), + } +} diff --git a/server/resource/etc/resource.yaml b/server/resource/etc/resource.yaml index befe8caf..473ac3f3 100644 --- a/server/resource/etc/resource.yaml +++ b/server/resource/etc/resource.yaml @@ -15,6 +15,7 @@ AWS: Secret: sjCEv0JxATnPCxno2KNLm0X8oDc7srUR+4vkYhvm Token: BLMService: + Url: "http://18.119.109.254: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/config/config.go b/server/resource/internal/config/config.go index 51aad1c7..e8569f26 100644 --- a/server/resource/internal/config/config.go +++ b/server/resource/internal/config/config.go @@ -21,6 +21,7 @@ type Config struct { } } BLMService struct { + Url string LogoCombine struct { Url string } diff --git a/server/resource/internal/logic/logocombinelogic.go b/server/resource/internal/logic/logocombinelogic.go index 86da8d7c..bad59cb9 100644 --- a/server/resource/internal/logic/logocombinelogic.go +++ b/server/resource/internal/logic/logocombinelogic.go @@ -1,17 +1,9 @@ package logic import ( - "encoding/json" - "errors" - "fusenapi/model/gmodel" + "fusenapi/service/repositories" "fusenapi/utils/auth" "fusenapi/utils/basic" - "fusenapi/utils/curl" - "fusenapi/utils/file" - "fusenapi/utils/hash" - "io" - "strings" - "time" "context" @@ -19,7 +11,6 @@ import ( "fusenapi/server/resource/internal/types" "github.com/zeromicro/go-zero/core/logx" - "gorm.io/gorm" ) type LogoCombineLogic struct { @@ -65,125 +56,22 @@ func (l *LogoCombineLogic) LogoCombine(req *types.LogoCombineReq, userinfo *auth // 否则,使用用户ID和用户键名格式 userId = userinfo.UserId } - - // 根据hash 查询数据资源 - var resourceId string = hash.JsonHashKey(req.ResourceKey) - resourceModel := gmodel.NewFsResourceModel(l.svcCtx.MysqlConn) - resourceInfo, err := resourceModel.FindOneById(l.ctx, resourceId) - if err == nil && resourceInfo.ResourceId != "" { - return resp.SetStatus(basic.CodeOK, map[string]interface{}{ - "resource_id": resourceId, - "resource_url": resourceInfo.ResourceUrl, - "resource_metadata": resourceInfo.Metadata, - }) - } else { - if err != nil { - if !errors.Is(err, gorm.ErrRecordNotFound) { - logx.Error(err) - return resp.SetStatus(basic.CodeDbSqlErr, "LogoCombine error") - } - } - } - - // 没有查到,先根据模版id 查询模版数据 请求算法数据 - productTemplateV2Model := gmodel.NewFsProductTemplateV2Model(l.svcCtx.MysqlConn) - productTemplateV2Info, err := productTemplateV2Model.FindOne(l.ctx, req.TemplateId) - - if err != nil { - logx.Error(err) - return resp.SetStatus(basic.CodeDbSqlErr, "LogoCombine error") - } - var groupOptions map[string]interface{} - if productTemplateV2Info.GroupOptions != nil { - err = json.Unmarshal([]byte(*productTemplateV2Info.GroupOptions), &groupOptions) - - if err != nil { - logx.Error(err) - return resp.SetStatus(basic.CodeDbSqlErr, "LogoCombine error Unmarshal groupOptions") - } - } - - var materialList []interface{} - if productTemplateV2Info.TemplateInfo != nil { - var templateInfo map[string]interface{} - err = json.Unmarshal([]byte(*productTemplateV2Info.TemplateInfo), &templateInfo) - - if err != nil { - logx.Error(err) - return resp.SetStatus(basic.CodeDbSqlErr, "LogoCombine error Unmarshal templateInfo") - } - materialList = templateInfo["materialList"].([]interface{}) - } - - var moduleDataMap = make(map[string]interface{}, 4) - moduleDataMap["id"] = productTemplateV2Info.Id - moduleDataMap["material"] = productTemplateV2Info.MaterialImg - moduleDataMap["groupOptions"] = groupOptions - moduleDataMap["materialList"] = materialList - - var combineParam map[string]interface{} - json.Unmarshal([]byte(req.CombineParam), &combineParam) - var postMap = make(map[string]interface{}, 2) - postMap["module_data"] = moduleDataMap - postMap["param_data"] = combineParam - postMapB, _ := json.Marshal(postMap) - - //result, err := http.Post(l.svcCtx.Config.BLMService.LogoCombine.Url, "application/json", strings.NewReader(string(postMapB))) - var headerData = make(map[string]string, 1) - headerData["Content-Type"] = "application/json" - result, err := curl.ApiCall(l.svcCtx.Config.BLMService.LogoCombine.Url, "POST", headerData, strings.NewReader(string(postMapB)), time.Second*20) - - if err != nil { - logx.Error(err) - return resp.SetStatus(basic.CodeFileLogoCombineErr, "service post fail") - } - defer result.Body.Close() - b, err := io.ReadAll(result.Body) - if err != nil { - logx.Error(err) - return resp.SetStatus(basic.CodeFileLogoCombineErr, "service read fail") - } - ress := string(b) - - if ress == "Internal Server Error" { - return resp.SetStatus(basic.CodeFileLogoCombineErr, "service read fail") - } - - var resultData map[string]interface{} - err = json.Unmarshal(b, &resultData) - if err != nil { - logx.Error(err) - return resp.SetStatus(basic.CodeFileLogoCombineErr, "service read fail") - } - // { - // id: "", - // logo_url:"https://s3.amazon.com/xxxx", - // result: "$saa541afaldjaldjasldjsadjsapsaasda" - // } - var fileBase = resultData["result"] - - // 上传文件 - var upload = file.Upload{ - Ctx: l.ctx, - MysqlConn: l.svcCtx.MysqlConn, - AwsSession: l.svcCtx.AwsSession, - } - uploadRes, err := upload.UploadFileByBase64(&file.UploadBaseReq{ - FileHash: resourceId, - FileData: fileBase.(string), - UploadBucket: 1, - ApiType: 2, + res, err := l.svcCtx.Repositories.ImageHandle.LogoCombine(l.ctx, &repositories.LogoCombineReq{ + ResourceKey: req.ResourceKey, + TemplateId: req.TemplateId, + CombineParam: req.CombineParam, UserId: userId, GuestId: guestId, }) + if err != nil { - logx.Error(err) - return resp.SetStatus(basic.CodeFileLogoCombineErr, "LogoCombine error upload file failed") + return resp.SetStatus(basic.CodeServiceErr) } + // 返回成功的响应和上传URL return resp.SetStatus(basic.CodeOK, map[string]interface{}{ - "resource_id": resourceId, - "resource_url": uploadRes.ResourceUrl, + "resource_id": res.ResourceId, + "resource_url": res.ResourceUrl, "resource_metadata": "", }) } diff --git a/server/resource/internal/svc/servicecontext.go b/server/resource/internal/svc/servicecontext.go index a81a0767..e006fbce 100644 --- a/server/resource/internal/svc/servicecontext.go +++ b/server/resource/internal/svc/servicecontext.go @@ -19,10 +19,11 @@ import ( type ServiceContext struct { Config config.Config - MysqlConn *gorm.DB - AllModels *gmodel.AllModelsGen - RabbitMq *initalize.RabbitMqHandle - AwsSession *session.Session + MysqlConn *gorm.DB + AllModels *gmodel.AllModelsGen + RabbitMq *initalize.RabbitMqHandle + AwsSession *session.Session + Repositories *initalize.Repositories } func NewServiceContext(c config.Config) *ServiceContext { @@ -35,6 +36,11 @@ func NewServiceContext(c config.Config) *ServiceContext { AllModels: gmodel.NewAllModels(initalize.InitMysql(c.SourceMysql)), RabbitMq: initalize.InitRabbitMq(c.SourceRabbitMq, nil), AwsSession: session.Must(session.NewSession(&config)), + Repositories: initalize.NewAllRepositories(&initalize.NewAllRepositorieData{ + GormDB: initalize.InitMysql(c.SourceMysql), + BLMServiceUrl: &c.BLMService.Url, + AwsSession: session.Must(session.NewSession(&config)), + }), } } diff --git a/service/repositories/image_handle.go b/service/repositories/image_handle.go new file mode 100644 index 00000000..5e873b3f --- /dev/null +++ b/service/repositories/image_handle.go @@ -0,0 +1,179 @@ +package repositories + +import ( + "context" + "encoding/json" + "errors" + "fusenapi/constants" + "fusenapi/model/gmodel" + "fusenapi/utils/curl" + "fusenapi/utils/file" + "fusenapi/utils/hash" + "io" + "strings" + "time" + + "github.com/aws/aws-sdk-go/aws/session" + "github.com/zeromicro/go-zero/core/logx" + "gorm.io/gorm" +) + +func NewImageHandle(gormDB *gorm.DB, bLMServiceUrl *string, awsSession *session.Session) ImageHandle { + return &defaultImageHandle{ + MysqlConn: gormDB, + BLMServiceUrl: bLMServiceUrl, + AwsSession: awsSession, + } +} + +type ( + defaultImageHandle struct { + MysqlConn *gorm.DB + BLMServiceUrl *string + AwsSession *session.Session + } + + ImageHandle = interface { + + // logo合图 + LogoCombine(ctx context.Context, in *LogoCombineReq) (*LogoCombineRes, error) + } +) + +/* 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"` + } + LogoCombineRes struct { + ResourceId string + ResourceUrl *string + Metadata *string + } +) + +func (l *defaultImageHandle) LogoCombine(ctx context.Context, in *LogoCombineReq) (*LogoCombineRes, error) { + // 根据hash 查询数据资源 + var resourceId string = hash.JsonHashKey(in.ResourceKey) + resourceModel := gmodel.NewFsResourceModel(l.MysqlConn) + resourceInfo, err := resourceModel.FindOneById(ctx, resourceId) + if err == nil && resourceInfo.ResourceId != "" { + return &LogoCombineRes{ + ResourceId: resourceId, + ResourceUrl: resourceInfo.ResourceUrl, + }, nil + } else { + if err != nil { + if !errors.Is(err, gorm.ErrRecordNotFound) { + logx.Error(err) + return nil, err + } + } + } + + // 没有查到,先根据模版id 查询模版数据 请求算法数据 + productTemplateV2Model := gmodel.NewFsProductTemplateV2Model(l.MysqlConn) + productTemplateV2Info, err := productTemplateV2Model.FindOne(ctx, in.TemplateId) + + if err != nil { + logx.Error(err) + return nil, err + } + var groupOptions map[string]interface{} + if productTemplateV2Info.GroupOptions != nil { + err = json.Unmarshal([]byte(*productTemplateV2Info.GroupOptions), &groupOptions) + + if err != nil { + logx.Error(err) + return nil, err + } + } + + var materialList []interface{} + if productTemplateV2Info.TemplateInfo != nil { + var templateInfo map[string]interface{} + err = json.Unmarshal([]byte(*productTemplateV2Info.TemplateInfo), &templateInfo) + + if err != nil { + logx.Error(err) + return nil, err + } + materialList = templateInfo["materialList"].([]interface{}) + } + + var moduleDataMap = make(map[string]interface{}, 4) + moduleDataMap["id"] = productTemplateV2Info.Id + moduleDataMap["material"] = productTemplateV2Info.MaterialImg + moduleDataMap["groupOptions"] = groupOptions + moduleDataMap["materialList"] = materialList + + var combineParam map[string]interface{} + json.Unmarshal([]byte(in.CombineParam), &combineParam) + var postMap = make(map[string]interface{}, 2) + postMap["module_data"] = moduleDataMap + postMap["param_data"] = combineParam + postMapB, _ := json.Marshal(postMap) + + var headerData = make(map[string]string, 1) + headerData["Content-Type"] = "application/json" + result, err := curl.ApiCall(*l.BLMServiceUrl+constants.BLMServiceUrlLogoCombine, "POST", headerData, strings.NewReader(string(postMapB)), time.Second*20) + + if err != nil { + logx.Error(err) + return nil, err + } + defer result.Body.Close() + b, err := io.ReadAll(result.Body) + if err != nil { + logx.Error(err) + return nil, err + } + ress := string(b) + + if ress == "Internal Server Error" { + logx.Error(errors.New("BLMService fail Internal Server Error")) + return nil, err + } + + var resultData map[string]interface{} + err = json.Unmarshal(b, &resultData) + if err != nil { + logx.Error(err) + return nil, err + } + // { + // id: "", + // logo_url:"https://s3.amazon.com/xxxx", + // result: "$saa541afaldjaldjasldjsadjsapsaasda" + // } + var fileBase = resultData["result"] + + // 上传文件 + var upload = file.Upload{ + Ctx: ctx, + MysqlConn: l.MysqlConn, + AwsSession: l.AwsSession, + } + uploadRes, err := upload.UploadFileByBase64(&file.UploadBaseReq{ + FileHash: resourceId, + FileData: fileBase.(string), + UploadBucket: 1, + ApiType: 2, + UserId: in.UserId, + GuestId: in.GuestId, + }) + if err != nil { + logx.Error(err) + return nil, err + } + return &LogoCombineRes{ + ResourceId: uploadRes.ResourceId, + ResourceUrl: &uploadRes.ResourceUrl, + }, nil +} + +/* logo合图 */ From f652a98c0e477eff30564a43073517e9c06cb0a8 Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Mon, 14 Aug 2023 18:40:34 +0800 Subject: [PATCH 035/151] fix --- .../render/consumer/assemble_render_data.go | 40 +++++++++++++++++++ server/render/etc/render.yaml | 7 +++- server/render/internal/config/config.go | 7 +++- server/render/internal/svc/servicecontext.go | 16 +++++--- 4 files changed, 61 insertions(+), 9 deletions(-) diff --git a/server/render/consumer/assemble_render_data.go b/server/render/consumer/assemble_render_data.go index 06b164ad..85a32996 100644 --- a/server/render/consumer/assemble_render_data.go +++ b/server/render/consumer/assemble_render_data.go @@ -8,10 +8,13 @@ import ( "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接口返回数据 @@ -58,8 +61,45 @@ 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, + }) + + if err != nil { + logx.Error("合成刀版图失败:", err) + return nil + } combineImage := "" //刀版图 + if res != nil && res.ResourceUrl != nil { + combineImage = *res.ResourceUrl + } else { + logx.Error("合成刀版图失败,合成的刀版图是空指针:", err) + return nil + } + logx.Info("合成刀版图成功") //获取渲染设置信息 element, err := svcCtx.AllModels.FsProductTemplateElement.FindOneByModelId(ctx, *productTemplate.ModelId) if err != nil { diff --git a/server/render/etc/render.yaml b/server/render/etc/render.yaml index 2be7fc7d..a75711b8 100644 --- a/server/render/etc/render.yaml +++ b/server/render/etc/render.yaml @@ -13,5 +13,8 @@ AWS: AccessKeyID: AKIAZB2JKUXDPNRP4YT2 Secret: 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 Token: -PythonApi: #python接口 - CombineImageUrl: http://18.119.109.254:8999/LogoCombine #合成刀版图接口 \ No newline at end of file +BLMService: + Url: "http://18.119.109.254: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/render/internal/config/config.go b/server/render/internal/config/config.go index 3cc5089e..a180c7da 100644 --- a/server/render/internal/config/config.go +++ b/server/render/internal/config/config.go @@ -19,7 +19,10 @@ type Config struct { } } } - PythonApi struct { - CombineImageUrl string //合图url + BLMService struct { + Url string + LogoCombine struct { + Url string + } } } diff --git a/server/render/internal/svc/servicecontext.go b/server/render/internal/svc/servicecontext.go index 08a78653..a0a334b7 100644 --- a/server/render/internal/svc/servicecontext.go +++ b/server/render/internal/svc/servicecontext.go @@ -17,11 +17,12 @@ import ( ) type ServiceContext struct { - Config config.Config - MysqlConn *gorm.DB - AllModels *gmodel.AllModelsGen - RabbitMq *initalize.RabbitMqHandle - AwsSession *session.Session + Config config.Config + MysqlConn *gorm.DB + AllModels *gmodel.AllModelsGen + RabbitMq *initalize.RabbitMqHandle + AwsSession *session.Session + Repositories *initalize.Repositories } func NewServiceContext(c config.Config) *ServiceContext { @@ -34,6 +35,11 @@ func NewServiceContext(c config.Config) *ServiceContext { AllModels: gmodel.NewAllModels(initalize.InitMysql(c.SourceMysql)), RabbitMq: initalize.InitRabbitMq(c.SourceRabbitMq, nil), AwsSession: session.Must(session.NewSession(&config)), + Repositories: initalize.NewAllRepositories(&initalize.NewAllRepositorieData{ + GormDB: initalize.InitMysql(c.SourceMysql), + BLMServiceUrl: &c.BLMService.Url, + AwsSession: session.Must(session.NewSession(&config)), + }), } } From d1c6f5cdc5a1b41605b57a9d2bf6e2520bba2179 Mon Sep 17 00:00:00 2001 From: Hiven Date: Tue, 15 Aug 2023 10:58:24 +0800 Subject: [PATCH 036/151] =?UTF-8?q?fix:=E9=87=8D=E6=9E=84=E5=90=88?= =?UTF-8?q?=E5=9B=BE=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 037/151] =?UTF-8?q?fix:=E9=87=8D=E6=9E=84=E5=90=88?= =?UTF-8?q?=E5=9B=BE=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 038/151] 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 039/151] =?UTF-8?q?fix:=E9=87=8D=E6=9E=84=E5=90=88?= =?UTF-8?q?=E5=9B=BE=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 040/151] 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 041/151] =?UTF-8?q?fix:=E9=87=8D=E6=9E=84=E5=90=88?= =?UTF-8?q?=E5=9B=BE=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 042/151] 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 043/151] 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 044/151] 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 045/151] 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 046/151] 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 047/151] =?UTF-8?q?fix:=E9=87=8D=E6=9E=84=E5=90=88?= =?UTF-8?q?=E5=9B=BE=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 048/151] 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 049/151] 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 050/151] =?UTF-8?q?fix:=E9=87=8D=E6=9E=84=E5=90=88?= =?UTF-8?q?=E5=9B=BE=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 051/151] =?UTF-8?q?fix:=E9=87=8D=E6=9E=84=E5=90=88?= =?UTF-8?q?=E5=9B=BE=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 052/151] 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 053/151] 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 054/151] =?UTF-8?q?fix:=E9=87=8D=E6=9E=84=E5=90=88?= =?UTF-8?q?=E5=9B=BE=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 055/151] 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 056/151] 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 057/151] 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 058/151] =?UTF-8?q?fix:=E9=87=8D=E6=9E=84=E5=90=88?= =?UTF-8?q?=E5=9B=BE=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 059/151] 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 060/151] 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"` } From b11e76855071301d60d148e27c3d35ad239de63c Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Wed, 16 Aug 2023 10:58:34 +0800 Subject: [PATCH 061/151] fix --- server/render/consumer/assemble_render_data.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/server/render/consumer/assemble_render_data.go b/server/render/consumer/assemble_render_data.go index 96e6a38f..7f228c4d 100644 --- a/server/render/consumer/assemble_render_data.go +++ b/server/render/consumer/assemble_render_data.go @@ -175,5 +175,12 @@ func (m *MqConsumerRenderAssemble) Run(ctx context.Context, data []byte) error { return nil //不返回错误就删除消息 } logx.Info("发送渲染组装数据到unity成功") + //模拟发送回去(unity部署后要去掉) + h := websocket_data.RenderImageNotify{ + TaskId: parseInfo.TaskId, + Image: "https://fusenh5.kayue.cn:8011/storage/test/final_k8TgMUxauc_temp.png", + } + d, _ := json.Marshal(h) + _ = rabbitmq.SendMsg(constants.RABBIT_MQ_RENDER_RESULT_DATA, d) return nil } From a022e5a8d916a250000d67a8d01955c19c47120f Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Wed, 16 Aug 2023 12:16:23 +0800 Subject: [PATCH 062/151] fix --- constants/rabbitmq.go | 17 +- .../render/consumer/assemble_render_data.go | 186 ------------------ server/render/internal/handler/routes.go | 5 - server/render/internal/types/types.go | 13 -- server/render/render.go | 9 - server/websocket/etc/websocket.yaml | 13 +- server/websocket/internal/config/config.go | 15 ++ .../internal/handler/rendernotifyhandler.go | 6 +- server/websocket/internal/handler/routes.go | 5 + .../internal/logic/datatransferlogic.go | 5 +- .../websocket/internal/logic/mq_consumer.go | 58 ------ .../internal/logic/rendernotifylogic.go | 48 +++-- .../internal/logic/ws_render_image_logic.go | 162 +++++++++++++-- .../websocket/internal/svc/servicecontext.go | 28 ++- server/websocket/internal/types/types.go | 7 + server/websocket/websocket.go | 9 - server_api/render.api | 18 -- server_api/websocket.api | 11 ++ utils/websocket_data/render_data.go | 13 -- 19 files changed, 267 insertions(+), 361 deletions(-) delete mode 100644 server/render/consumer/assemble_render_data.go rename server/{render => websocket}/internal/handler/rendernotifyhandler.go (82%) delete mode 100644 server/websocket/internal/logic/mq_consumer.go rename server/{render => websocket}/internal/logic/rendernotifylogic.go (68%) diff --git a/constants/rabbitmq.go b/constants/rabbitmq.go index e9e06ef5..b8e374b3 100644 --- a/constants/rabbitmq.go +++ b/constants/rabbitmq.go @@ -4,17 +4,16 @@ type RABBIT_MQ string // 消息队列队列名 const ( - //组装渲染数据队列 - RABBIT_MQ_ASSEMBLE_RENDER_DATA RABBIT_MQ = "RABBIT_MQ_ASSEMBLE_RENDER_DATA" - //渲染结果数据队列 - RABBIT_MQ_RENDER_RESULT_DATA RABBIT_MQ = "RABBIT_MQ_RENDER_RESULT_DATA" - //原来发送到unity渲染的队列 - RABBIT_MQ_TO_UNITY RABBIT_MQ = "newTaskQueue" +//组装渲染数据队列 +/*RABBIT_MQ_ASSEMBLE_RENDER_DATA RABBIT_MQ = "RABBIT_MQ_ASSEMBLE_RENDER_DATA" +//渲染结果数据队列 +RABBIT_MQ_RENDER_RESULT_DATA RABBIT_MQ = "RABBIT_MQ_RENDER_RESULT_DATA"*/ ) // 队列列表 var MqQueueArr = []RABBIT_MQ{ - RABBIT_MQ_ASSEMBLE_RENDER_DATA, - RABBIT_MQ_RENDER_RESULT_DATA, - RABBIT_MQ_TO_UNITY, + /* + RABBIT_MQ_ASSEMBLE_RENDER_DATA, + RABBIT_MQ_RENDER_RESULT_DATA, + */ } diff --git a/server/render/consumer/assemble_render_data.go b/server/render/consumer/assemble_render_data.go deleted file mode 100644 index 7f228c4d..00000000 --- a/server/render/consumer/assemble_render_data.go +++ /dev/null @@ -1,186 +0,0 @@ -package consumer - -import ( - "context" - "encoding/json" - "errors" - "fmt" - "fusenapi/constants" - "fusenapi/initalize" - "fusenapi/server/render/internal/svc" - "fusenapi/service/repositories" - "fusenapi/utils/websocket_data" - "github.com/zeromicro/go-zero/core/logx" - "gorm.io/gorm" - "strconv" -) - -// 这里请求的py接口返回数据 -type pythonApiRsp struct { - Id string `json:"id"` //物料模板的id - LogoUrl string `json:"logo_url"` //logo地址 - Result string `json:"result"` //图片base64 -} - -// 消费渲染需要组装的数据 -type MqConsumerRenderAssemble struct { -} - -func (m *MqConsumerRenderAssemble) Run(ctx context.Context, data []byte) error { - defer func() { - if err := recover(); err != nil { - logx.Error("MqConsumerRenderAssemble panic:", err) - } - }() - logx.Info("收到需要组装的消息:", string(data)) - var parseInfo websocket_data.AssembleRenderData - if err := json.Unmarshal(data, &parseInfo); err != nil { - logx.Error("MqConsumerRenderAssemble数据格式错误:", err) - return nil //不返回错误就删除消息 - } - val := ctx.Value("svcctx") - if val == nil { - logx.Error("svcctx is nil") - return nil //不返回错误就删除消息 - } - svcCtx, ok := val.(*svc.ServiceContext) - if !ok { - logx.Error("svcctx is nil!!") - 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, fmt.Sprintf("%d", templateTag.Id)) - if err != nil { - if errors.Is(err, gorm.ErrRecordNotFound) { - logx.Error("template info is not found") - return nil //不返回错误就删除消息 - } - logx.Error("failed to get template info:", err) - return nil //不返回错误就删除消息 - } - //获取刀版图 - res, err := svcCtx.Repositories.ImageHandle.LogoCombine(ctx, &repositories.LogoCombineReq{ - 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 - } - combineImage := "" //刀版图 - if res != nil && res.ResourceUrl != nil { - combineImage = *res.ResourceUrl - } else { - logx.Error("合成刀版图失败,合成的刀版图是空指针:", err) - return nil - } - logx.Info("合成刀版图成功:", *res.ResourceUrl) - //获取渲染设置信息 - element, err := svcCtx.AllModels.FsProductTemplateElement.FindOneByModelId(ctx, *productTemplate.ModelId) - if err != nil { - if errors.Is(err, gorm.ErrRecordNotFound) { - logx.Error("element info is not found,model_id = ?", *productTemplate.ModelId) - return nil //不返回错误就删除消息 - } - logx.Error("failed to get element list,", err) - return nil //不返回错误就删除消息 - } - //组装数据 - refletion := -1 - if element.Refletion != nil && *element.Refletion != "" { - refletion, err = strconv.Atoi(*element.Refletion) - } - //组装data数据 - var mode map[string]interface{} - if element.Mode != nil && *element.Mode != "" { - if err = json.Unmarshal([]byte(*element.Mode), &mode); err != nil { - logx.Error("faile to parse element mode json:", err) - return nil //不返回错误就删除消息 - } - } - tempData := make([]map[string]interface{}, 0, 3) - if element.Base != nil && *element.Base != "" { - tempData = append(tempData, map[string]interface{}{ - "name": "model", - "data": "0," + combineImage + "," + *element.Base, - "type": "other", - "layer": "0", - "is_update": 1, - "mode": mode["model"], - }) - } - if element.Shadow != nil && *element.Shadow != "" { - tempData = append(tempData, map[string]interface{}{ - "name": "shadow", - "data": *element.Shadow, - "type": "other", - "layer": "0", - "is_update": 0, - "mode": mode["shadow"], - }) - } - if element.ModelP != nil && *element.ModelP != "" { - tempData = append(tempData, map[string]interface{}{ - "name": "model_P", - "data": "0," + *element.ModelP, - "type": "other", - "layer": "0", - "is_update": 0, - "mode": mode["model_P"], - }) - } - result := []interface{}{ - map[string]interface{}{ - "light": *element.Light, - "refletion": refletion, - "scale": *element.Scale, - "sku_id": parseInfo.RenderData.ProductId, - "tid": *element.Title, - "rotation": *element.Rotation, - "filePath": "", //todo 文件路径,针对千人千面 - "data": tempData, - }, - } - sendData := map[string]interface{}{ - "id": parseInfo.TaskId, - "order_id": 0, - "user_id": parseInfo.RenderData.UserId, - "guest_id": parseInfo.RenderData.GuestId, - "sku_ids": []int64{parseInfo.RenderData.ProductId}, - "tids": []string{*element.Title}, - "data": result, - "is_thousand_face": 0, - "folder": "", //todo 千人千面需要使用 - } - b, _ := json.Marshal(sendData) - if err = rabbitmq.SendMsg(constants.RABBIT_MQ_TO_UNITY, b); err != nil { - logx.Error("发送渲染组装数据到rabbitmq失败:", err) - return nil //不返回错误就删除消息 - } - logx.Info("发送渲染组装数据到unity成功") - //模拟发送回去(unity部署后要去掉) - h := websocket_data.RenderImageNotify{ - TaskId: parseInfo.TaskId, - Image: "https://fusenh5.kayue.cn:8011/storage/test/final_k8TgMUxauc_temp.png", - } - d, _ := json.Marshal(h) - _ = rabbitmq.SendMsg(constants.RABBIT_MQ_RENDER_RESULT_DATA, d) - return nil -} diff --git a/server/render/internal/handler/routes.go b/server/render/internal/handler/routes.go index 26ad8b15..03e1cab2 100644 --- a/server/render/internal/handler/routes.go +++ b/server/render/internal/handler/routes.go @@ -12,11 +12,6 @@ import ( func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { server.AddRoutes( []rest.Route{ - { - Method: http.MethodPost, - Path: "/api/render/render_notify", - Handler: RenderNotifyHandler(serverCtx), - }, { Method: http.MethodPost, Path: "/api/render/get_face_slice", diff --git a/server/render/internal/types/types.go b/server/render/internal/types/types.go index ef9aad74..70ec268a 100644 --- a/server/render/internal/types/types.go +++ b/server/render/internal/types/types.go @@ -5,19 +5,6 @@ import ( "fusenapi/utils/basic" ) -type RequestToUnity struct { -} - -type RequestReadImages struct { -} - -type RenderNotifyReq struct { - TaskId string `json:"task_id"` //任务id - UserId int64 `json:"user_id"` - GuestId int64 `json:"guest_id"` - Image string `json:"image"` -} - type Request struct { } diff --git a/server/render/render.go b/server/render/render.go index 56fc25ee..9790b18a 100644 --- a/server/render/render.go +++ b/server/render/render.go @@ -1,11 +1,8 @@ package main import ( - "context" "flag" "fmt" - "fusenapi/constants" - "fusenapi/server/render/consumer" "net/http" "fusenapi/utils/auth" @@ -30,12 +27,6 @@ func main() { defer server.Stop() ctx := svc.NewServiceContext(c) - //消费渲染前组装数据队列 - ctx1 := context.Background() - ctx2, cancel := context.WithCancel(ctx1) - ctx2 = context.WithValue(ctx2, "svcctx", ctx) - defer cancel() - go ctx.RabbitMq.Consume(ctx2, constants.RABBIT_MQ_ASSEMBLE_RENDER_DATA, &consumer.MqConsumerRenderAssemble{}) handler.RegisterHandlers(server, ctx) fmt.Printf("Starting server at %s:%d...\n", c.Host, c.Port) server.Start() diff --git a/server/websocket/etc/websocket.yaml b/server/websocket/etc/websocket.yaml index d47e1243..63d7dbb4 100644 --- a/server/websocket/etc/websocket.yaml +++ b/server/websocket/etc/websocket.yaml @@ -7,4 +7,15 @@ Auth: AccessSecret: fusen2023 AccessExpire: 2592000 RefreshAfter: 1592000 -SourceRabbitMq: amqp://rabbit001:rabbit001129@110.41.19.98:5672 \ No newline at end of file +SourceRabbitMq: amqp://rabbit001:rabbit001129@110.41.19.98:5672 +AWS: + S3: + Credentials: + AccessKeyID: AKIAZB2JKUXDPNRP4YT2 + Secret: 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 + Token: +BLMService: + Url: "http://18.119.109.254: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/websocket/internal/config/config.go b/server/websocket/internal/config/config.go index ee0f22f7..af191b9b 100644 --- a/server/websocket/internal/config/config.go +++ b/server/websocket/internal/config/config.go @@ -10,4 +10,19 @@ type Config struct { SourceMysql string Auth types.Auth SourceRabbitMq string + AWS struct { + S3 struct { + Credentials struct { + AccessKeyID string + Secret string + Token string + } + } + } + BLMService struct { + Url string + LogoCombine struct { + Url string + } + } } diff --git a/server/render/internal/handler/rendernotifyhandler.go b/server/websocket/internal/handler/rendernotifyhandler.go similarity index 82% rename from server/render/internal/handler/rendernotifyhandler.go rename to server/websocket/internal/handler/rendernotifyhandler.go index a8d01c9c..63a84e1f 100644 --- a/server/render/internal/handler/rendernotifyhandler.go +++ b/server/websocket/internal/handler/rendernotifyhandler.go @@ -6,9 +6,9 @@ import ( "fusenapi/utils/basic" - "fusenapi/server/render/internal/logic" - "fusenapi/server/render/internal/svc" - "fusenapi/server/render/internal/types" + "fusenapi/server/websocket/internal/logic" + "fusenapi/server/websocket/internal/svc" + "fusenapi/server/websocket/internal/types" ) func RenderNotifyHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { diff --git a/server/websocket/internal/handler/routes.go b/server/websocket/internal/handler/routes.go index fd3200e4..859ecc5b 100644 --- a/server/websocket/internal/handler/routes.go +++ b/server/websocket/internal/handler/routes.go @@ -17,6 +17,11 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { Path: "/api/websocket/data_transfer", Handler: DataTransferHandler(serverCtx), }, + { + Method: http.MethodPost, + Path: "/api/websocket/render_notify", + Handler: RenderNotifyHandler(serverCtx), + }, }, ) } diff --git a/server/websocket/internal/logic/datatransferlogic.go b/server/websocket/internal/logic/datatransferlogic.go index 777d20b4..5b576cb9 100644 --- a/server/websocket/internal/logic/datatransferlogic.go +++ b/server/websocket/internal/logic/datatransferlogic.go @@ -6,7 +6,6 @@ import ( "fmt" "fusenapi/constants" "fusenapi/initalize" - "fusenapi/model/gmodel" "fusenapi/utils/auth" "fusenapi/utils/id_generator" "fusenapi/utils/websocket_data" @@ -71,7 +70,7 @@ type wsConnectItem struct { conn *websocket.Conn //websocket的连接 ctx context.Context rabbitMq *initalize.RabbitMqHandle - allModels *gmodel.AllModelsGen + svcCtx *svc.ServiceContext closeChan chan struct{} //ws连接关闭chan isClose bool //是否已经关闭 uniqueId string //ws连接唯一标识 @@ -138,7 +137,7 @@ func (l *DataTransferLogic) setConnPool(conn *websocket.Conn, userInfo auth.User conn: conn, ctx: l.ctx, rabbitMq: l.svcCtx.RabbitMq, - allModels: l.svcCtx.AllModels, + svcCtx: l.svcCtx, uniqueId: uniqueId, closeChan: make(chan struct{}, 1), inChan: make(chan []byte, 1000), diff --git a/server/websocket/internal/logic/mq_consumer.go b/server/websocket/internal/logic/mq_consumer.go deleted file mode 100644 index 410dee3e..00000000 --- a/server/websocket/internal/logic/mq_consumer.go +++ /dev/null @@ -1,58 +0,0 @@ -package logic - -import ( - "context" - "encoding/json" - "fusenapi/constants" - "fusenapi/utils/websocket_data" - "github.com/zeromicro/go-zero/core/logx" -) - -// 消费渲染结果数据 -type MqConsumerRenderResult struct { -} - -func (m *MqConsumerRenderResult) Run(ctx context.Context, data []byte) error { - defer func() { - if err := recover(); err != nil { - logx.Error("MqConsumerRenderResult panic:", err) - } - }() - logx.Info("接收到MqConsumerRenderResult数据:", string(data)) - var parseInfo websocket_data.RenderImageNotify - if err := json.Unmarshal(data, &parseInfo); err != nil { - logx.Error("MqConsumerRenderResult data format err:", err) - return nil //不返回错误则就删掉该消息 - } - //遍历websocket链接把数据传进去 - mapConnPool.Range(func(key, value any) bool { - //断言连接 - ws, ok := value.(wsConnectItem) - if !ok { - return true - } - //关闭标识 - if ws.isClose { - return true - } - //查询有无该渲染任务 - renderId, ok := ws.renderProperty.renderImageTask[parseInfo.TaskId] - if !ok { - return true - } - b := ws.respondDataFormat(constants.WEBSOCKET_RENDER_IMAGE, websocket_data.RenderImageRspMsg{ - RenderId: renderId, - Image: parseInfo.Image, - }) - //删除对应的需要渲染的图片map - ws.renderProperty.renderImageTaskCtlChan <- renderImageControlChanItem{ - Option: 0, //0删除 1添加 - TaskId: parseInfo.TaskId, - RenderId: renderId, - } - //发送数据到out chan - ws.sendToOutChan(b) - return true - }) - return nil -} diff --git a/server/render/internal/logic/rendernotifylogic.go b/server/websocket/internal/logic/rendernotifylogic.go similarity index 68% rename from server/render/internal/logic/rendernotifylogic.go rename to server/websocket/internal/logic/rendernotifylogic.go index c49da008..e8ee60c5 100644 --- a/server/render/internal/logic/rendernotifylogic.go +++ b/server/websocket/internal/logic/rendernotifylogic.go @@ -1,16 +1,16 @@ package logic import ( - "context" - "encoding/json" "fusenapi/constants" "fusenapi/utils/auth" "fusenapi/utils/basic" "fusenapi/utils/file" "fusenapi/utils/websocket_data" - "fusenapi/server/render/internal/svc" - "fusenapi/server/render/internal/types" + "context" + + "fusenapi/server/websocket/internal/svc" + "fusenapi/server/websocket/internal/types" "github.com/zeromicro/go-zero/core/logx" ) @@ -66,15 +66,35 @@ func (l *RenderNotifyLogic) RenderNotify(req *types.RenderNotifyReq, userinfo *a logx.Error(err) return resp.SetStatusWithMessage(basic.CodeFileUploadErr, "failed to upload render resource image") } - //发送消息到对应的rabbitmq - data := websocket_data.RenderImageNotify{ - 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.SetStatusWithMessage(basic.CodeServiceErr, "failed to send data") - } + //遍历websocket链接把数据传进去 + mapConnPool.Range(func(key, value any) bool { + //断言连接 + ws, ok := value.(wsConnectItem) + if !ok { + return true + } + //关闭标识 + if ws.isClose { + return true + } + //查询有无该渲染任务 + renderId, ok := ws.renderProperty.renderImageTask[req.TaskId] + if !ok { + return true + } + b := ws.respondDataFormat(constants.WEBSOCKET_RENDER_IMAGE, websocket_data.RenderImageRspMsg{ + RenderId: renderId, + Image: uploadRes.ResourceUrl, + }) + //删除对应的需要渲染的图片map + ws.renderProperty.renderImageTaskCtlChan <- renderImageControlChanItem{ + Option: 0, //0删除 1添加 + TaskId: req.TaskId, + RenderId: renderId, + } + //发送数据到out chan + ws.sendToOutChan(b) + return true + }) return resp.SetStatusWithMessage(basic.CodeOK, "success") } diff --git a/server/websocket/internal/logic/ws_render_image_logic.go b/server/websocket/internal/logic/ws_render_image_logic.go index 0d23615e..9ef4303b 100644 --- a/server/websocket/internal/logic/ws_render_image_logic.go +++ b/server/websocket/internal/logic/ws_render_image_logic.go @@ -3,11 +3,14 @@ package logic import ( "encoding/json" "errors" + "fmt" "fusenapi/constants" + "fusenapi/service/repositories" "fusenapi/utils/hash" "fusenapi/utils/websocket_data" "github.com/zeromicro/go-zero/core/logx" "gorm.io/gorm" + "strconv" ) // 云渲染属性 @@ -48,7 +51,7 @@ func (w *wsConnectItem) renderImage(data []byte) { return } //获取上传最近的logo - userMaterial, err := w.allModels.FsUserMaterial.FindLatestOne(w.ctx, w.userId, w.guestId) + userMaterial, err := w.svcCtx.AllModels.FsUserMaterial.FindLatestOne(w.ctx, w.userId, w.guestId) if err != nil { if !errors.Is(err, gorm.ErrRecordNotFound) { w.sendToOutChan(w.respondDataFormat(constants.WEBSOCKET_ERR_DATA_FORMAT, "failed to get user logo")) @@ -56,7 +59,7 @@ func (w *wsConnectItem) renderImage(data []byte) { return } //使用默认logo(id=0) - userMaterialDefault, err := w.allModels.FsUserMaterial.FindOneById(w.ctx, 0) + userMaterialDefault, err := w.svcCtx.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")) @@ -77,7 +80,7 @@ func (w *wsConnectItem) renderImage(data []byte) { //生成任务id taskId := hash.JsonHashKey(renderImageData.RenderData) //查询有没有缓存的资源,有就返回###################### - resource, err := w.allModels.FsResource.FindOneById(w.ctx, taskId) + resource, err := w.svcCtx.AllModels.FsResource.FindOneById(w.ctx, taskId) if err != nil { if !errors.Is(err, gorm.ErrRecordNotFound) { logx.Error("failed to find render resource:", err) @@ -100,18 +103,151 @@ func (w *wsConnectItem) renderImage(data []byte) { TaskId: taskId, RenderId: renderImageData.RenderId, } - tmpData := websocket_data.AssembleRenderData{ - TaskId: taskId, - RenderId: renderImageData.RenderId, - RenderData: renderImageData.RenderData, - } - d, _ := json.Marshal(tmpData) - //发送给对应的流水线组装数据 - if err = w.rabbitMq.SendMsg(constants.RABBIT_MQ_ASSEMBLE_RENDER_DATA, d); err != nil { - logx.Error("发送渲染任务数据到MQ失败:", string(d), "err:", err) + //组装数据 + go w.assembleRenderData(taskId, renderImageData) +} + +// 组装数据发送给unity +func (w *wsConnectItem) assembleRenderData(taskId string, info websocket_data.RenderImageReqMsg) { + defer func() { + if err := recover(); err != nil { + logx.Error("MqConsumerRenderAssemble panic:", err) + } + }() + //根据templateTag获取templateTagId(后续模板表的tag改成template_tag后可能就不需要这个步骤了) + templateTag, err := w.svcCtx.AllModels.FsProductTemplateTags.FindOneByTagName(w.ctx, info.RenderData.TemplateTag) + if err != nil { + if errors.Is(err, gorm.ErrRecordNotFound) { + logx.Error("can`t find template tag info by template tag:", info.RenderData.TemplateTag) + return + } + logx.Error("failed to get template tag info") return } - logx.Info("发送渲染数据到rabbitmq成功:", string(d)) + //获取模板(模板标签下的对一个物料的的模板) + productTemplate, err := w.svcCtx.AllModels.FsProductTemplateV2.FindOneByProductIdTagIdWithSizeTable(w.ctx, info.RenderData.ProductId, fmt.Sprintf("%d", templateTag.Id)) + if err != nil { + if errors.Is(err, gorm.ErrRecordNotFound) { + logx.Error("template info is not found") + return + } + logx.Error("failed to get template info:", err) + return + } + //获取刀版图 + res, err := w.svcCtx.Repositories.ImageHandle.LogoCombine(w.ctx, &repositories.LogoCombineReq{ + UserId: info.RenderData.UserId, + GuestId: info.RenderData.GuestId, + TemplateId: productTemplate.Id, + TemplateTag: info.RenderData.TemplateTag, + Website: info.RenderData.Website, + Slogan: info.RenderData.Slogan, + Address: info.RenderData.Address, + Phone: info.RenderData.Phone, + }) + if err != nil { + logx.Error("合成刀版图失败:", err) + return + } + combineImage := "" //刀版图 + if res != nil && res.ResourceUrl != nil { + combineImage = *res.ResourceUrl + } else { + logx.Error("合成刀版图失败,合成的刀版图是空指针:", err) + return + } + logx.Info("合成刀版图成功:", *res.ResourceUrl) + //获取渲染设置信息 + element, err := w.svcCtx.AllModels.FsProductTemplateElement.FindOneByModelId(w.ctx, *productTemplate.ModelId) + if err != nil { + if errors.Is(err, gorm.ErrRecordNotFound) { + logx.Error("element info is not found,model_id = ?", *productTemplate.ModelId) + return + } + logx.Error("failed to get element list,", err) + return + } + //组装数据 + refletion := -1 + if element.Refletion != nil && *element.Refletion != "" { + refletion, err = strconv.Atoi(*element.Refletion) + } + //组装data数据 + var mode map[string]interface{} + if element.Mode != nil && *element.Mode != "" { + if err = json.Unmarshal([]byte(*element.Mode), &mode); err != nil { + logx.Error("faile to parse element mode json:", err) + return + } + } + tempData := make([]map[string]interface{}, 0, 3) + if element.Base != nil && *element.Base != "" { + tempData = append(tempData, map[string]interface{}{ + "name": "model", + "data": "0," + combineImage + "," + *element.Base, + "type": "other", + "layer": "0", + "is_update": 1, + "mode": mode["model"], + }) + } + if element.Shadow != nil && *element.Shadow != "" { + tempData = append(tempData, map[string]interface{}{ + "name": "shadow", + "data": *element.Shadow, + "type": "other", + "layer": "0", + "is_update": 0, + "mode": mode["shadow"], + }) + } + if element.ModelP != nil && *element.ModelP != "" { + tempData = append(tempData, map[string]interface{}{ + "name": "model_P", + "data": "0," + *element.ModelP, + "type": "other", + "layer": "0", + "is_update": 0, + "mode": mode["model_P"], + }) + } + result := []interface{}{ + map[string]interface{}{ + "light": *element.Light, + "refletion": refletion, + "scale": *element.Scale, + "sku_id": info.RenderData.ProductId, + "tid": *element.Title, + "rotation": *element.Rotation, + "filePath": "", //todo 文件路径,针对千人千面 + "data": tempData, + }, + } + sendData := map[string]interface{}{ + "id": taskId, + "order_id": 0, + "user_id": info.RenderData.UserId, + "guest_id": info.RenderData.GuestId, + "sku_ids": []int64{info.RenderData.ProductId}, + "tids": []string{*element.Title}, + "data": result, + "is_thousand_face": 0, + "folder": "", //todo 千人千面需要使用 + } + /*b, _ := json.Marshal(sendData) + if err = rabbitmq.SendMsg(constants.RABBIT_MQ_TO_UNITY, b); err != nil { + logx.Error("发送渲染组装数据到rabbitmq失败:", err) + return nil + } + logx.Info("发送渲染组装数据到unity成功")*/ + // todo 请求unity接口 /api/render/queue/push + logx.Info(sendData["id"]) + //模拟发送回去(unity部署后要去掉) + w.sendToOutChan(w.respondDataFormat(constants.WEBSOCKET_RENDER_IMAGE, websocket_data.RenderImageRspMsg{ + RenderId: info.RenderId, + Image: "https://fusenh5.kayue.cn:8011/storage/test/final_k8TgMUxauc_temp.png", + })) + return } // 操作连接中渲染任务的增加/删除 diff --git a/server/websocket/internal/svc/servicecontext.go b/server/websocket/internal/svc/servicecontext.go index df41e0b3..cff40090 100644 --- a/server/websocket/internal/svc/servicecontext.go +++ b/server/websocket/internal/svc/servicecontext.go @@ -4,6 +4,9 @@ import ( "errors" "fmt" "fusenapi/server/websocket/internal/config" + "github.com/aws/aws-sdk-go/aws" + "github.com/aws/aws-sdk-go/aws/credentials" + "github.com/aws/aws-sdk-go/aws/session" "net/http" "fusenapi/initalize" @@ -16,17 +19,28 @@ import ( type ServiceContext struct { Config config.Config - MysqlConn *gorm.DB - AllModels *gmodel.AllModelsGen - RabbitMq *initalize.RabbitMqHandle + MysqlConn *gorm.DB + AllModels *gmodel.AllModelsGen + RabbitMq *initalize.RabbitMqHandle + AwsSession *session.Session + Repositories *initalize.Repositories } func NewServiceContext(c config.Config) *ServiceContext { + config := aws.Config{ + Credentials: credentials.NewStaticCredentials(c.AWS.S3.Credentials.AccessKeyID, c.AWS.S3.Credentials.Secret, c.AWS.S3.Credentials.Token), + } return &ServiceContext{ - Config: c, - MysqlConn: initalize.InitMysql(c.SourceMysql), - AllModels: gmodel.NewAllModels(initalize.InitMysql(c.SourceMysql)), - RabbitMq: initalize.InitRabbitMq(c.SourceRabbitMq, nil), + Config: c, + MysqlConn: initalize.InitMysql(c.SourceMysql), + AllModels: gmodel.NewAllModels(initalize.InitMysql(c.SourceMysql)), + RabbitMq: initalize.InitRabbitMq(c.SourceRabbitMq, nil), + AwsSession: session.Must(session.NewSession(&config)), + Repositories: initalize.NewAllRepositories(&initalize.NewAllRepositorieData{ + GormDB: initalize.InitMysql(c.SourceMysql), + BLMServiceUrl: &c.BLMService.Url, + AwsSession: session.Must(session.NewSession(&config)), + }), } } diff --git a/server/websocket/internal/types/types.go b/server/websocket/internal/types/types.go index 70ec268a..1cd1f5b4 100644 --- a/server/websocket/internal/types/types.go +++ b/server/websocket/internal/types/types.go @@ -5,6 +5,13 @@ import ( "fusenapi/utils/basic" ) +type RenderNotifyReq struct { + TaskId string `json:"task_id"` //任务id + UserId int64 `json:"user_id"` + GuestId int64 `json:"guest_id"` + Image string `json:"image"` +} + type Request struct { } diff --git a/server/websocket/websocket.go b/server/websocket/websocket.go index cfc775f7..b6c469b6 100644 --- a/server/websocket/websocket.go +++ b/server/websocket/websocket.go @@ -1,11 +1,8 @@ package main import ( - "context" "flag" "fmt" - "fusenapi/constants" - "fusenapi/server/websocket/internal/logic" "net/http" "fusenapi/utils/auth" @@ -30,12 +27,6 @@ func main() { defer server.Stop() ctx := svc.NewServiceContext(c) - //消费渲染结果队列 - ctx1 := context.Background() - ctx2, cancel := context.WithCancel(ctx1) - ctx2 = context.WithValue(ctx2, "allmodels", ctx.AllModels) - defer cancel() - go ctx.RabbitMq.Consume(ctx2, constants.RABBIT_MQ_RENDER_RESULT_DATA, &logic.MqConsumerRenderResult{}) handler.RegisterHandlers(server, ctx) fmt.Printf("Starting server at %s:%d...\n", c.Host, c.Port) server.Start() diff --git a/server_api/render.api b/server_api/render.api index 2a717984..c860476f 100644 --- a/server_api/render.api +++ b/server_api/render.api @@ -8,26 +8,8 @@ info ( ) import "basic.api" - -type RequestToUnity { -} - -type RequestReadImages { -} - service render { - //云渲染完了通知接口 - @handler RenderNotifyHandler - post /api/render/render_notify(RenderNotifyReq) returns (response); //获取面片信息 @handler GetFaceSliceHandler post /api/render/get_face_slice(request) returns (response); -} - -//渲染完了通知接口 -type RenderNotifyReq { - TaskId string `json:"task_id"` //任务id - UserId int64 `json:"user_id"` - GuestId int64 `json:"guest_id"` - Image string `json:"image"` } \ No newline at end of file diff --git a/server_api/websocket.api b/server_api/websocket.api index ef24d79f..b5adb666 100644 --- a/server_api/websocket.api +++ b/server_api/websocket.api @@ -12,4 +12,15 @@ service websocket { //websocket数据交互 @handler DataTransferHandler get /api/websocket/data_transfer(request) returns (response); + //云渲染完了通知接口 + @handler RenderNotifyHandler + post /api/websocket/render_notify(RenderNotifyReq) returns (response); +} + +//渲染完了通知接口 +type RenderNotifyReq { + TaskId string `json:"task_id"` //任务id + UserId int64 `json:"user_id"` + GuestId int64 `json:"guest_id"` + Image string `json:"image"` } \ No newline at end of file diff --git a/utils/websocket_data/render_data.go b/utils/websocket_data/render_data.go index bb4c82eb..0238bcfa 100644 --- a/utils/websocket_data/render_data.go +++ b/utils/websocket_data/render_data.go @@ -28,20 +28,7 @@ type RenderImageRspMsg struct { RenderId string `json:"render_id"` //渲染id Image string `json:"image"` //渲染结果图片 } - -// 渲染服务器回调数据 -type RenderImageNotify struct { - TaskId string `json:"task_id"` - Image string `json:"image"` -} type ThirdPartyLoginRspMsg struct { //websocket三方登录的通知数据 Token string `json:"token"` } - -// 发送到渲染组装的mq数据 -type AssembleRenderData struct { - TaskId string `json:"task_id"` - RenderId string `json:"render_id"` - RenderData RenderData `json:"render_data"` -} From 37b5cc0f30c907f5278a82dbd1a6333f2a526337 Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Wed, 16 Aug 2023 12:33:01 +0800 Subject: [PATCH 063/151] fix --- .../internal/logic/ws_render_image_logic.go | 34 ++++++++++++------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/server/websocket/internal/logic/ws_render_image_logic.go b/server/websocket/internal/logic/ws_render_image_logic.go index 9ef4303b..68f4006d 100644 --- a/server/websocket/internal/logic/ws_render_image_logic.go +++ b/server/websocket/internal/logic/ws_render_image_logic.go @@ -1,16 +1,20 @@ package logic import ( + "bytes" "encoding/json" "errors" "fmt" "fusenapi/constants" "fusenapi/service/repositories" + "fusenapi/utils/curl" "fusenapi/utils/hash" "fusenapi/utils/websocket_data" "github.com/zeromicro/go-zero/core/logx" "gorm.io/gorm" + "os" "strconv" + "time" ) // 云渲染属性 @@ -234,20 +238,24 @@ func (w *wsConnectItem) assembleRenderData(taskId string, info websocket_data.Re "is_thousand_face": 0, "folder": "", //todo 千人千面需要使用 } - /*b, _ := json.Marshal(sendData) - if err = rabbitmq.SendMsg(constants.RABBIT_MQ_TO_UNITY, b); err != nil { - logx.Error("发送渲染组装数据到rabbitmq失败:", err) - return nil - } - logx.Info("发送渲染组装数据到unity成功")*/ // todo 请求unity接口 /api/render/queue/push - logx.Info(sendData["id"]) - //模拟发送回去(unity部署后要去掉) - w.sendToOutChan(w.respondDataFormat(constants.WEBSOCKET_RENDER_IMAGE, websocket_data.RenderImageRspMsg{ - RenderId: info.RenderId, - Image: "https://fusenh5.kayue.cn:8011/storage/test/final_k8TgMUxauc_temp.png", - })) - return + url := "http://api.fusen.3718.cn:4050/api/render/queue/push" + header := make(map[string]string) + header["content-type"] = "application/json" + t := time.Now().UTC() + postData := map[string]interface{}{ + "group": "unity3d", + "source": "home page", + "priority": 1, + "create_at": t, + "render_data": sendData, + } + p, _ := json.Marshal(postData) + _, err = curl.ApiCall(url, "POST", header, bytes.NewReader(p), time.Second*20) + if err != nil { + logx.Error("failed to send data to unity") + return + } } // 操作连接中渲染任务的增加/删除 From 7bdd1f00afe2c0aa056794a053682a498d40e1dd Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Wed, 16 Aug 2023 14:09:03 +0800 Subject: [PATCH 064/151] fix --- server/websocket/etc/websocket.yaml | 4 ++- server/websocket/internal/config/config.go | 3 ++ .../internal/logic/datatransferlogic.go | 29 ++++++++----------- .../internal/logic/ws_render_image_logic.go | 20 ++++++------- 4 files changed, 28 insertions(+), 28 deletions(-) diff --git a/server/websocket/etc/websocket.yaml b/server/websocket/etc/websocket.yaml index 63d7dbb4..f287bbb9 100644 --- a/server/websocket/etc/websocket.yaml +++ b/server/websocket/etc/websocket.yaml @@ -18,4 +18,6 @@ BLMService: Url: "http://18.119.109.254:8999" LogoCombine: #Url: "http://192.168.1.7:8999/LogoCombine" - Url: "http://18.119.109.254:8999/LogoCombine" \ No newline at end of file + Url: "http://18.119.109.254:8999/LogoCombine" +Unity: + Host: http://api.fusen.3718.cn:4050 \ No newline at end of file diff --git a/server/websocket/internal/config/config.go b/server/websocket/internal/config/config.go index af191b9b..6dd60c29 100644 --- a/server/websocket/internal/config/config.go +++ b/server/websocket/internal/config/config.go @@ -25,4 +25,7 @@ type Config struct { Url string } } + Unity struct { + Host string + } } diff --git a/server/websocket/internal/logic/datatransferlogic.go b/server/websocket/internal/logic/datatransferlogic.go index 5b576cb9..2bf05623 100644 --- a/server/websocket/internal/logic/datatransferlogic.go +++ b/server/websocket/internal/logic/datatransferlogic.go @@ -5,7 +5,6 @@ import ( "encoding/json" "fmt" "fusenapi/constants" - "fusenapi/initalize" "fusenapi/utils/auth" "fusenapi/utils/id_generator" "fusenapi/utils/websocket_data" @@ -67,19 +66,17 @@ var ( // 每个连接的连接基本属性 type wsConnectItem struct { - conn *websocket.Conn //websocket的连接 - ctx context.Context - rabbitMq *initalize.RabbitMqHandle - svcCtx *svc.ServiceContext - closeChan chan struct{} //ws连接关闭chan - isClose bool //是否已经关闭 - uniqueId string //ws连接唯一标识 - inChan chan []byte //接受消息缓冲通道 - outChan chan []byte //发送回客户端的消息 - mutex sync.Mutex //互斥锁 - userId int64 //用户id - guestId int64 //游客id - renderProperty renderProperty //扩展云渲染属性 + conn *websocket.Conn //websocket的连接 + logic *DataTransferLogic //logic + closeChan chan struct{} //ws连接关闭chan + isClose bool //是否已经关闭 + uniqueId string //ws连接唯一标识 + inChan chan []byte //接受消息缓冲通道 + outChan chan []byte //发送回客户端的消息 + mutex sync.Mutex //互斥锁 + userId int64 //用户id + guestId int64 //游客id + renderProperty renderProperty //扩展云渲染属性 } func (l *DataTransferLogic) DataTransfer(svcCtx *svc.ServiceContext, w http.ResponseWriter, r *http.Request) { @@ -135,9 +132,7 @@ func (l *DataTransferLogic) setConnPool(conn *websocket.Conn, userInfo auth.User uniqueId := l.getUniqueId(userInfo) ws := wsConnectItem{ conn: conn, - ctx: l.ctx, - rabbitMq: l.svcCtx.RabbitMq, - svcCtx: l.svcCtx, + logic: l, uniqueId: uniqueId, closeChan: make(chan struct{}, 1), inChan: make(chan []byte, 1000), diff --git a/server/websocket/internal/logic/ws_render_image_logic.go b/server/websocket/internal/logic/ws_render_image_logic.go index 68f4006d..e8770a49 100644 --- a/server/websocket/internal/logic/ws_render_image_logic.go +++ b/server/websocket/internal/logic/ws_render_image_logic.go @@ -12,7 +12,6 @@ import ( "fusenapi/utils/websocket_data" "github.com/zeromicro/go-zero/core/logx" "gorm.io/gorm" - "os" "strconv" "time" ) @@ -55,7 +54,7 @@ func (w *wsConnectItem) renderImage(data []byte) { return } //获取上传最近的logo - userMaterial, err := w.svcCtx.AllModels.FsUserMaterial.FindLatestOne(w.ctx, w.userId, w.guestId) + userMaterial, err := w.logic.svcCtx.AllModels.FsUserMaterial.FindLatestOne(w.logic.ctx, w.userId, w.guestId) if err != nil { if !errors.Is(err, gorm.ErrRecordNotFound) { w.sendToOutChan(w.respondDataFormat(constants.WEBSOCKET_ERR_DATA_FORMAT, "failed to get user logo")) @@ -63,7 +62,7 @@ func (w *wsConnectItem) renderImage(data []byte) { return } //使用默认logo(id=0) - userMaterialDefault, err := w.svcCtx.AllModels.FsUserMaterial.FindOneById(w.ctx, 0) + userMaterialDefault, err := w.logic.svcCtx.AllModels.FsUserMaterial.FindOneById(w.logic.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")) @@ -84,7 +83,7 @@ func (w *wsConnectItem) renderImage(data []byte) { //生成任务id taskId := hash.JsonHashKey(renderImageData.RenderData) //查询有没有缓存的资源,有就返回###################### - resource, err := w.svcCtx.AllModels.FsResource.FindOneById(w.ctx, taskId) + resource, err := w.logic.svcCtx.AllModels.FsResource.FindOneById(w.logic.ctx, taskId) if err != nil { if !errors.Is(err, gorm.ErrRecordNotFound) { logx.Error("failed to find render resource:", err) @@ -119,7 +118,7 @@ func (w *wsConnectItem) assembleRenderData(taskId string, info websocket_data.Re } }() //根据templateTag获取templateTagId(后续模板表的tag改成template_tag后可能就不需要这个步骤了) - templateTag, err := w.svcCtx.AllModels.FsProductTemplateTags.FindOneByTagName(w.ctx, info.RenderData.TemplateTag) + templateTag, err := w.logic.svcCtx.AllModels.FsProductTemplateTags.FindOneByTagName(w.logic.ctx, info.RenderData.TemplateTag) if err != nil { if errors.Is(err, gorm.ErrRecordNotFound) { logx.Error("can`t find template tag info by template tag:", info.RenderData.TemplateTag) @@ -129,7 +128,7 @@ func (w *wsConnectItem) assembleRenderData(taskId string, info websocket_data.Re return } //获取模板(模板标签下的对一个物料的的模板) - productTemplate, err := w.svcCtx.AllModels.FsProductTemplateV2.FindOneByProductIdTagIdWithSizeTable(w.ctx, info.RenderData.ProductId, fmt.Sprintf("%d", templateTag.Id)) + productTemplate, err := w.logic.svcCtx.AllModels.FsProductTemplateV2.FindOneByProductIdTagIdWithSizeTable(w.logic.ctx, info.RenderData.ProductId, fmt.Sprintf("%d", templateTag.Id)) if err != nil { if errors.Is(err, gorm.ErrRecordNotFound) { logx.Error("template info is not found") @@ -139,7 +138,7 @@ func (w *wsConnectItem) assembleRenderData(taskId string, info websocket_data.Re return } //获取刀版图 - res, err := w.svcCtx.Repositories.ImageHandle.LogoCombine(w.ctx, &repositories.LogoCombineReq{ + res, err := w.logic.svcCtx.Repositories.ImageHandle.LogoCombine(w.logic.ctx, &repositories.LogoCombineReq{ UserId: info.RenderData.UserId, GuestId: info.RenderData.GuestId, TemplateId: productTemplate.Id, @@ -162,7 +161,7 @@ func (w *wsConnectItem) assembleRenderData(taskId string, info websocket_data.Re } logx.Info("合成刀版图成功:", *res.ResourceUrl) //获取渲染设置信息 - element, err := w.svcCtx.AllModels.FsProductTemplateElement.FindOneByModelId(w.ctx, *productTemplate.ModelId) + element, err := w.logic.svcCtx.AllModels.FsProductTemplateElement.FindOneByModelId(w.logic.ctx, *productTemplate.ModelId) if err != nil { if errors.Is(err, gorm.ErrRecordNotFound) { logx.Error("element info is not found,model_id = ?", *productTemplate.ModelId) @@ -238,7 +237,7 @@ func (w *wsConnectItem) assembleRenderData(taskId string, info websocket_data.Re "is_thousand_face": 0, "folder": "", //todo 千人千面需要使用 } - // todo 请求unity接口 /api/render/queue/push + //请求unity接口 url := "http://api.fusen.3718.cn:4050/api/render/queue/push" header := make(map[string]string) header["content-type"] = "application/json" @@ -251,11 +250,12 @@ func (w *wsConnectItem) assembleRenderData(taskId string, info websocket_data.Re "render_data": sendData, } p, _ := json.Marshal(postData) - _, err = curl.ApiCall(url, "POST", header, bytes.NewReader(p), time.Second*20) + _, err = curl.ApiCall(url, "POST", header, bytes.NewReader(p), time.Second*10) if err != nil { logx.Error("failed to send data to unity") return } + logx.Info("发送到unity成功################") } // 操作连接中渲染任务的增加/删除 From 7d2c2ab02536f66a441ddf41f435f08bf7aa1587 Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Wed, 16 Aug 2023 14:16:33 +0800 Subject: [PATCH 065/151] fix --- server/websocket/internal/handler/datatransferhandler.go | 2 +- server/websocket/internal/logic/datatransferlogic.go | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/server/websocket/internal/handler/datatransferhandler.go b/server/websocket/internal/handler/datatransferhandler.go index 8ef09842..c167b31c 100644 --- a/server/websocket/internal/handler/datatransferhandler.go +++ b/server/websocket/internal/handler/datatransferhandler.go @@ -10,6 +10,6 @@ func DataTransferHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { // 创建一个业务逻辑层实例 l := logic.NewDataTransferLogic(r.Context(), svcCtx) - l.DataTransfer(svcCtx, w, r) + l.DataTransfer(w, r) } } diff --git a/server/websocket/internal/logic/datatransferlogic.go b/server/websocket/internal/logic/datatransferlogic.go index 2bf05623..7288256b 100644 --- a/server/websocket/internal/logic/datatransferlogic.go +++ b/server/websocket/internal/logic/datatransferlogic.go @@ -79,7 +79,7 @@ type wsConnectItem struct { renderProperty renderProperty //扩展云渲染属性 } -func (l *DataTransferLogic) DataTransfer(svcCtx *svc.ServiceContext, w http.ResponseWriter, r *http.Request) { +func (l *DataTransferLogic) DataTransfer(w http.ResponseWriter, r *http.Request) { //升级websocket conn, err := upgrade.Upgrade(w, r, nil) if err != nil { @@ -92,7 +92,7 @@ func (l *DataTransferLogic) DataTransfer(svcCtx *svc.ServiceContext, w http.Resp userInfo *auth.UserInfo isAuth bool ) - isAuth, userInfo = l.checkAuth(svcCtx, r) + isAuth, userInfo = l.checkAuth(r) if !isAuth { time.Sleep(time.Second * 1) //兼容下火狐 rsp := websocket_data.DataTransferData{ @@ -170,9 +170,9 @@ func getUserPart(userId, guestId int64) string { } // 鉴权 -func (l *DataTransferLogic) checkAuth(svcCtx *svc.ServiceContext, r *http.Request) (isAuth bool, userInfo *auth.UserInfo) { +func (l *DataTransferLogic) checkAuth(r *http.Request) (isAuth bool, userInfo *auth.UserInfo) { // 解析JWT token,并对空用户进行判断 - claims, err := svcCtx.ParseJwtToken(r) + claims, err := l.svcCtx.ParseJwtToken(r) // 如果解析JWT token出错,则返回未授权的JSON响应并记录错误消息 if err != nil { return false, nil From 6e78e4f2096b724bf4b5d502664606baf9d664d4 Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Wed, 16 Aug 2023 14:29:25 +0800 Subject: [PATCH 066/151] fix --- server/websocket/internal/logic/ws_render_image_logic.go | 7 ++++++- 1 file changed, 6 insertions(+), 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 e8770a49..f5e592c5 100644 --- a/server/websocket/internal/logic/ws_render_image_logic.go +++ b/server/websocket/internal/logic/ws_render_image_logic.go @@ -31,6 +31,11 @@ type renderImageControlChanItem struct { // 渲染发送到组装数据组装数据 func (w *wsConnectItem) renderImage(data []byte) { + defer func() { + if err := recover(); err != nil { + logx.Error("renderImage panic:", err) + } + }() var renderImageData websocket_data.RenderImageReqMsg if err := json.Unmarshal(data, &renderImageData); err != nil { w.sendToOutChan(w.respondDataFormat(constants.WEBSOCKET_ERR_DATA_FORMAT, "invalid format of websocket render image message:"+string(data))) @@ -114,7 +119,7 @@ func (w *wsConnectItem) renderImage(data []byte) { func (w *wsConnectItem) assembleRenderData(taskId string, info websocket_data.RenderImageReqMsg) { defer func() { if err := recover(); err != nil { - logx.Error("MqConsumerRenderAssemble panic:", err) + logx.Error("assembleRenderData panic:", err) } }() //根据templateTag获取templateTagId(后续模板表的tag改成template_tag后可能就不需要这个步骤了) From dc4c87b3234224600943710a7777073ce8c32697 Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Wed, 16 Aug 2023 15:38:17 +0800 Subject: [PATCH 067/151] fix --- server/websocket/internal/logic/ws_render_image_logic.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/server/websocket/internal/logic/ws_render_image_logic.go b/server/websocket/internal/logic/ws_render_image_logic.go index f5e592c5..44bc15ab 100644 --- a/server/websocket/internal/logic/ws_render_image_logic.go +++ b/server/websocket/internal/logic/ws_render_image_logic.go @@ -123,7 +123,7 @@ func (w *wsConnectItem) assembleRenderData(taskId string, info websocket_data.Re } }() //根据templateTag获取templateTagId(后续模板表的tag改成template_tag后可能就不需要这个步骤了) - templateTag, err := w.logic.svcCtx.AllModels.FsProductTemplateTags.FindOneByTagName(w.logic.ctx, info.RenderData.TemplateTag) + /*templateTag, err := w.logic.svcCtx.AllModels.FsProductTemplateTags.FindOneByTagName(w.logic.ctx, info.RenderData.TemplateTag) if err != nil { if errors.Is(err, gorm.ErrRecordNotFound) { logx.Error("can`t find template tag info by template tag:", info.RenderData.TemplateTag) @@ -131,9 +131,9 @@ func (w *wsConnectItem) assembleRenderData(taskId string, info websocket_data.Re } logx.Error("failed to get template tag info") return - } + }*/ //获取模板(模板标签下的对一个物料的的模板) - productTemplate, err := w.logic.svcCtx.AllModels.FsProductTemplateV2.FindOneByProductIdTagIdWithSizeTable(w.logic.ctx, info.RenderData.ProductId, fmt.Sprintf("%d", templateTag.Id)) + productTemplate, err := w.logic.svcCtx.AllModels.FsProductTemplateV2.FindOneByProductIdTagIdWithSizeTable(w.logic.ctx, info.RenderData.ProductId, "8" /*fmt.Sprintf("%d", templateTag.Id)*/) if err != nil { if errors.Is(err, gorm.ErrRecordNotFound) { logx.Error("template info is not found") From ca1faa7acea41919ddce419d36f1512b31bc7982 Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Wed, 16 Aug 2023 15:39:14 +0800 Subject: [PATCH 068/151] fix --- server/websocket/internal/logic/ws_render_image_logic.go | 1 - 1 file changed, 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 44bc15ab..3589d74b 100644 --- a/server/websocket/internal/logic/ws_render_image_logic.go +++ b/server/websocket/internal/logic/ws_render_image_logic.go @@ -4,7 +4,6 @@ import ( "bytes" "encoding/json" "errors" - "fmt" "fusenapi/constants" "fusenapi/service/repositories" "fusenapi/utils/curl" From 2b05154fc4340c4ba2f4862b89a71a7c4c005ba6 Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Wed, 16 Aug 2023 15:42:46 +0800 Subject: [PATCH 069/151] fix --- .../internal/logic/ws_render_image_logic.go | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/server/websocket/internal/logic/ws_render_image_logic.go b/server/websocket/internal/logic/ws_render_image_logic.go index 3589d74b..244a81d8 100644 --- a/server/websocket/internal/logic/ws_render_image_logic.go +++ b/server/websocket/internal/logic/ws_render_image_logic.go @@ -121,18 +121,8 @@ func (w *wsConnectItem) assembleRenderData(taskId string, info websocket_data.Re logx.Error("assembleRenderData panic:", err) } }() - //根据templateTag获取templateTagId(后续模板表的tag改成template_tag后可能就不需要这个步骤了) - /*templateTag, err := w.logic.svcCtx.AllModels.FsProductTemplateTags.FindOneByTagName(w.logic.ctx, info.RenderData.TemplateTag) - if err != nil { - if errors.Is(err, gorm.ErrRecordNotFound) { - logx.Error("can`t find template tag info by template tag:", info.RenderData.TemplateTag) - return - } - logx.Error("failed to get template tag info") - return - }*/ - //获取模板(模板标签下的对一个物料的的模板) - productTemplate, err := w.logic.svcCtx.AllModels.FsProductTemplateV2.FindOneByProductIdTagIdWithSizeTable(w.logic.ctx, info.RenderData.ProductId, "8" /*fmt.Sprintf("%d", templateTag.Id)*/) + // todo 获取模板(模板标签下的对一个物料的的模板)目前写死参数 + productTemplate, err := w.logic.svcCtx.AllModels.FsProductTemplateV2.FindOneByProductIdTagIdWithSizeTable(w.logic.ctx, 18, "8" /*fmt.Sprintf("%d", templateTag.Id)*/) if err != nil { if errors.Is(err, gorm.ErrRecordNotFound) { logx.Error("template info is not found") From c5dd4866b9a982fed58eff3bafdaa6b468fca3ef Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Wed, 16 Aug 2023 15:46:10 +0800 Subject: [PATCH 070/151] 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 244a81d8..8d658bc6 100644 --- a/server/websocket/internal/logic/ws_render_image_logic.go +++ b/server/websocket/internal/logic/ws_render_image_logic.go @@ -122,7 +122,7 @@ func (w *wsConnectItem) assembleRenderData(taskId string, info websocket_data.Re } }() // todo 获取模板(模板标签下的对一个物料的的模板)目前写死参数 - productTemplate, err := w.logic.svcCtx.AllModels.FsProductTemplateV2.FindOneByProductIdTagIdWithSizeTable(w.logic.ctx, 18, "8" /*fmt.Sprintf("%d", templateTag.Id)*/) + productTemplate, err := w.logic.svcCtx.AllModels.FsProductTemplateV2.FindOneByProductIdTagIdWithSizeTable(w.logic.ctx, 31, "11" /*fmt.Sprintf("%d", templateTag.Id)*/) if err != nil { if errors.Is(err, gorm.ErrRecordNotFound) { logx.Error("template info is not found") From 4a8b245ffda892cc089d11f9d92ceab27607e4da Mon Sep 17 00:00:00 2001 From: Hiven Date: Wed, 16 Aug 2023 16:08:48 +0800 Subject: [PATCH 071/151] =?UTF-8?q?fix:=E9=87=8D=E6=9E=84=E5=90=88?= =?UTF-8?q?=E5=9B=BE=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 | 47 ++++++++++++++-------------- 1 file changed, 24 insertions(+), 23 deletions(-) diff --git a/service/repositories/image_handle.go b/service/repositories/image_handle.go index 861a9f1e..9ef14c26 100644 --- a/service/repositories/image_handle.go +++ b/service/repositories/image_handle.go @@ -46,7 +46,7 @@ type ( UserId int64 `json:"user_id"` GuestId int64 `json:"guest_id"` TemplateId int64 `json:"template_id"` - TemplateTag string `json:"resource_key"` + TemplateTag string `json:"template_tag"` Website string `json:"website"` // 合图参数 Slogan string `json:"slogan"` // 合图参数 Address string `json:"address"` // 合图参数 @@ -61,8 +61,30 @@ type ( ) func (l *defaultImageHandle) LogoCombine(ctx context.Context, in *LogoCombineReq) (*LogoCombineRes, error) { + + // 查询logo最新基础信息 + var metadata *string + userMaterialModel := gmodel.NewFsUserMaterialModel(l.MysqlConn) + userMaterialInfo, err := userMaterialModel.FindLatestOne(ctx, in.UserId, in.GuestId) + + if err != nil { + 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 + } + // 根据hash 查询数据资源 - var resourceId string = hash.JsonHashKey(in) + var resourceId string = hash.JsonHashKey(userMaterialInfo.ResourceUrl) resourceModel := gmodel.NewFsResourceModel(l.MysqlConn) resourceInfo, err := resourceModel.FindOneById(ctx, resourceId) @@ -116,27 +138,6 @@ func (l *defaultImageHandle) LogoCombine(ctx context.Context, in *LogoCombineReq moduleDataMap["groupOptions"] = groupOptions moduleDataMap["materialList"] = materialList - // 查询logo最新基础信息 - var metadata *string - userMaterialModel := gmodel.NewFsUserMaterialModel(l.MysqlConn) - userMaterialInfo, err := userMaterialModel.FindLatestOne(ctx, in.UserId, in.GuestId) - - if err != nil { - 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(*metadata), &combineParam) combineParam["template_tagid"] = in.TemplateTag From d0bd037d7b6e13f93915328482d69a381c8388eb Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Wed, 16 Aug 2023 16:20:16 +0800 Subject: [PATCH 072/151] fix --- .../internal/logic/datatransferlogic.go | 9 ++-- .../internal/logic/ws_render_image_logic.go | 52 +++++++++++++++---- 2 files changed, 47 insertions(+), 14 deletions(-) diff --git a/server/websocket/internal/logic/datatransferlogic.go b/server/websocket/internal/logic/datatransferlogic.go index 7288256b..8d6e2188 100644 --- a/server/websocket/internal/logic/datatransferlogic.go +++ b/server/websocket/internal/logic/datatransferlogic.go @@ -120,6 +120,8 @@ func (l *DataTransferLogic) DataTransfer(w http.ResponseWriter, r *http.Request) go ws.sendLoop() //操作连接中渲染任务的增加/删除 go ws.operationRenderTask() + //消费渲染缓冲队列 + go ws.renderImage() //心跳 ws.heartbeat() } @@ -135,13 +137,14 @@ func (l *DataTransferLogic) setConnPool(conn *websocket.Conn, userInfo auth.User logic: l, uniqueId: uniqueId, closeChan: make(chan struct{}, 1), - inChan: make(chan []byte, 1000), - outChan: make(chan []byte, 1000), + inChan: make(chan []byte, 100), + outChan: make(chan []byte, 100), userId: userInfo.UserId, guestId: userInfo.GuestId, renderProperty: renderProperty{ renderImageTask: make(map[string]string), renderImageTaskCtlChan: make(chan renderImageControlChanItem, 100), + renderChan: make(chan []byte, 100), }, } //保存连接 @@ -313,7 +316,7 @@ func (w *wsConnectItem) dealwithReciveData(data []byte) { switch parseInfo.T { //图片渲染 case constants.WEBSOCKET_RENDER_IMAGE: - w.renderImage(d) + w.sendToRenderChan(d) //刷新重连请求恢复上次连接的标识 case constants.WEBSOCKET_REQUEST_REUSE_LAST_CONNECT: w.reuseLastConnect(d) diff --git a/server/websocket/internal/logic/ws_render_image_logic.go b/server/websocket/internal/logic/ws_render_image_logic.go index 8d658bc6..4743c5ee 100644 --- a/server/websocket/internal/logic/ws_render_image_logic.go +++ b/server/websocket/internal/logic/ws_render_image_logic.go @@ -19,6 +19,7 @@ import ( type renderProperty struct { renderImageTask map[string]string //需要渲染的图片任务 key是taskId val 是renderId renderImageTaskCtlChan chan renderImageControlChanItem //渲染任务新增移除的控制通道 + renderChan chan []byte //渲染的缓冲队列 } // 渲染任务新增移除的控制通道的数据 @@ -28,13 +29,38 @@ type renderImageControlChanItem struct { RenderId string // map的val } +// 发送到渲染缓冲池 +func (w *wsConnectItem) sendToRenderChan(data []byte) { + select { + case <-w.closeChan: //已经关闭 + return + case w.renderProperty.renderChan <- data: + return + case <-time.After(time.Second * 3): + return + } +} + // 渲染发送到组装数据组装数据 -func (w *wsConnectItem) renderImage(data []byte) { +func (w *wsConnectItem) renderImage() { defer func() { if err := recover(); err != nil { logx.Error("renderImage panic:", err) } }() + for { + select { + case <-w.closeChan: //已关闭 + return + case data := <-w.renderProperty.renderChan: + w.consumeRenderCache(data) + } + } + +} + +// 消费渲染缓冲数据 +func (w *wsConnectItem) consumeRenderCache(data []byte) { var renderImageData websocket_data.RenderImageReqMsg if err := json.Unmarshal(data, &renderImageData); err != nil { w.sendToOutChan(w.respondDataFormat(constants.WEBSOCKET_ERR_DATA_FORMAT, "invalid format of websocket render image message:"+string(data))) @@ -111,11 +137,14 @@ func (w *wsConnectItem) renderImage(data []byte) { RenderId: renderImageData.RenderId, } //组装数据 - go w.assembleRenderData(taskId, renderImageData) + if err = w.assembleRenderData(taskId, renderImageData); err != nil { + logx.Error("组装数据失败:", err) + return + } } // 组装数据发送给unity -func (w *wsConnectItem) assembleRenderData(taskId string, info websocket_data.RenderImageReqMsg) { +func (w *wsConnectItem) assembleRenderData(taskId string, info websocket_data.RenderImageReqMsg) error { defer func() { if err := recover(); err != nil { logx.Error("assembleRenderData panic:", err) @@ -126,10 +155,10 @@ func (w *wsConnectItem) assembleRenderData(taskId string, info websocket_data.Re if err != nil { if errors.Is(err, gorm.ErrRecordNotFound) { logx.Error("template info is not found") - return + return err } logx.Error("failed to get template info:", err) - return + return err } //获取刀版图 res, err := w.logic.svcCtx.Repositories.ImageHandle.LogoCombine(w.logic.ctx, &repositories.LogoCombineReq{ @@ -144,14 +173,14 @@ func (w *wsConnectItem) assembleRenderData(taskId string, info websocket_data.Re }) if err != nil { logx.Error("合成刀版图失败:", err) - return + return err } combineImage := "" //刀版图 if res != nil && res.ResourceUrl != nil { combineImage = *res.ResourceUrl } else { logx.Error("合成刀版图失败,合成的刀版图是空指针:", err) - return + return err } logx.Info("合成刀版图成功:", *res.ResourceUrl) //获取渲染设置信息 @@ -159,10 +188,10 @@ func (w *wsConnectItem) assembleRenderData(taskId string, info websocket_data.Re if err != nil { if errors.Is(err, gorm.ErrRecordNotFound) { logx.Error("element info is not found,model_id = ?", *productTemplate.ModelId) - return + return err } logx.Error("failed to get element list,", err) - return + return err } //组装数据 refletion := -1 @@ -174,7 +203,7 @@ func (w *wsConnectItem) assembleRenderData(taskId string, info websocket_data.Re if element.Mode != nil && *element.Mode != "" { if err = json.Unmarshal([]byte(*element.Mode), &mode); err != nil { logx.Error("faile to parse element mode json:", err) - return + return err } } tempData := make([]map[string]interface{}, 0, 3) @@ -247,9 +276,10 @@ func (w *wsConnectItem) assembleRenderData(taskId string, info websocket_data.Re _, err = curl.ApiCall(url, "POST", header, bytes.NewReader(p), time.Second*10) if err != nil { logx.Error("failed to send data to unity") - return + return err } logx.Info("发送到unity成功################") + return nil } // 操作连接中渲染任务的增加/删除 From c8ff11b63312054ef59d5c3bf34f385c789011f4 Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Wed, 16 Aug 2023 16:26:44 +0800 Subject: [PATCH 073/151] fix --- server/websocket/internal/logic/ws_render_image_logic.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/server/websocket/internal/logic/ws_render_image_logic.go b/server/websocket/internal/logic/ws_render_image_logic.go index 4743c5ee..d078e0be 100644 --- a/server/websocket/internal/logic/ws_render_image_logic.go +++ b/server/websocket/internal/logic/ws_render_image_logic.go @@ -110,8 +110,11 @@ func (w *wsConnectItem) consumeRenderCache(data []byte) { renderImageData.RenderData.UserId = w.userId renderImageData.RenderData.GuestId = w.guestId - //生成任务id - taskId := hash.JsonHashKey(renderImageData.RenderData) + //生成任务id(需要把user_id,guest_id设为0) + hashVal := renderImageData.RenderData + hashVal.UserId = 0 + hashVal.GuestId = 0 + taskId := hash.JsonHashKey(hashVal) //查询有没有缓存的资源,有就返回###################### resource, err := w.logic.svcCtx.AllModels.FsResource.FindOneById(w.logic.ctx, taskId) if err != nil { From 1af3399a9d05eb7ab063d081baf6a14a20a10b89 Mon Sep 17 00:00:00 2001 From: Hiven Date: Wed, 16 Aug 2023 16:33:25 +0800 Subject: [PATCH 074/151] =?UTF-8?q?fix:=E9=87=8D=E6=9E=84=E5=90=88?= =?UTF-8?q?=E5=9B=BE=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 | 48 +++++++++++++++------------- 1 file changed, 25 insertions(+), 23 deletions(-) diff --git a/service/repositories/image_handle.go b/service/repositories/image_handle.go index 9ef14c26..d9bdc43e 100644 --- a/service/repositories/image_handle.go +++ b/service/repositories/image_handle.go @@ -61,30 +61,11 @@ type ( ) func (l *defaultImageHandle) LogoCombine(ctx context.Context, in *LogoCombineReq) (*LogoCombineRes, error) { - - // 查询logo最新基础信息 - var metadata *string - userMaterialModel := gmodel.NewFsUserMaterialModel(l.MysqlConn) - userMaterialInfo, err := userMaterialModel.FindLatestOne(ctx, in.UserId, in.GuestId) - - if err != nil { - 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 - } - // 根据hash 查询数据资源 - var resourceId string = hash.JsonHashKey(userMaterialInfo.ResourceUrl) + var hashKeyData = *in + hashKeyData.GuestId = 0 + hashKeyData.UserId = 0 + var resourceId string = hash.JsonHashKey(hashKeyData) resourceModel := gmodel.NewFsResourceModel(l.MysqlConn) resourceInfo, err := resourceModel.FindOneById(ctx, resourceId) @@ -138,6 +119,27 @@ func (l *defaultImageHandle) LogoCombine(ctx context.Context, in *LogoCombineReq moduleDataMap["groupOptions"] = groupOptions moduleDataMap["materialList"] = materialList + // 查询logo最新基础信息 + var metadata *string + userMaterialModel := gmodel.NewFsUserMaterialModel(l.MysqlConn) + userMaterialInfo, err := userMaterialModel.FindLatestOne(ctx, in.UserId, in.GuestId) + + if err != nil { + 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(*metadata), &combineParam) combineParam["template_tagid"] = in.TemplateTag From 4d215beabc3830b2f3d6a91fd6253a9bc4aae93d Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Wed, 16 Aug 2023 16:55:31 +0800 Subject: [PATCH 075/151] 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 d078e0be..47db6b84 100644 --- a/server/websocket/internal/logic/ws_render_image_logic.go +++ b/server/websocket/internal/logic/ws_render_image_logic.go @@ -154,7 +154,7 @@ func (w *wsConnectItem) assembleRenderData(taskId string, info websocket_data.Re } }() // todo 获取模板(模板标签下的对一个物料的的模板)目前写死参数 - productTemplate, err := w.logic.svcCtx.AllModels.FsProductTemplateV2.FindOneByProductIdTagIdWithSizeTable(w.logic.ctx, 31, "11" /*fmt.Sprintf("%d", templateTag.Id)*/) + productTemplate, err := w.logic.svcCtx.AllModels.FsProductTemplateV2.FindOneByProductIdTagIdWithSizeTable(w.logic.ctx, info.RenderData.ProductId, "16") if err != nil { if errors.Is(err, gorm.ErrRecordNotFound) { logx.Error("template info is not found") From c692d74442be3283c54faf9a9c2f3603066e6fbe Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Wed, 16 Aug 2023 17:04:45 +0800 Subject: [PATCH 076/151] fix --- server/websocket/internal/logic/ws_render_image_logic.go | 1 + 1 file changed, 1 insertion(+) diff --git a/server/websocket/internal/logic/ws_render_image_logic.go b/server/websocket/internal/logic/ws_render_image_logic.go index 47db6b84..de44508f 100644 --- a/server/websocket/internal/logic/ws_render_image_logic.go +++ b/server/websocket/internal/logic/ws_render_image_logic.go @@ -61,6 +61,7 @@ func (w *wsConnectItem) renderImage() { // 消费渲染缓冲数据 func (w *wsConnectItem) consumeRenderCache(data []byte) { + logx.Info("消费渲染数据:", string(data)) var renderImageData websocket_data.RenderImageReqMsg if err := json.Unmarshal(data, &renderImageData); err != nil { w.sendToOutChan(w.respondDataFormat(constants.WEBSOCKET_ERR_DATA_FORMAT, "invalid format of websocket render image message:"+string(data))) From 886e765d4b9cd8ecae30c305198e40d3d5fdc89c Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Wed, 16 Aug 2023 17:06:52 +0800 Subject: [PATCH 077/151] 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 de44508f..560cb4d7 100644 --- a/server/websocket/internal/logic/ws_render_image_logic.go +++ b/server/websocket/internal/logic/ws_render_image_logic.go @@ -191,7 +191,7 @@ func (w *wsConnectItem) assembleRenderData(taskId string, info websocket_data.Re element, err := w.logic.svcCtx.AllModels.FsProductTemplateElement.FindOneByModelId(w.logic.ctx, *productTemplate.ModelId) if err != nil { if errors.Is(err, gorm.ErrRecordNotFound) { - logx.Error("element info is not found,model_id = ?", *productTemplate.ModelId) + logx.Error("element info is not found,model_id = ", *productTemplate.ModelId) return err } logx.Error("failed to get element list,", err) From 5bafc6cc432bd65d4b436edf8e137f1670b4eeb2 Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Wed, 16 Aug 2023 17:07:53 +0800 Subject: [PATCH 078/151] 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 560cb4d7..49b7b804 100644 --- a/server/websocket/internal/logic/ws_render_image_logic.go +++ b/server/websocket/internal/logic/ws_render_image_logic.go @@ -155,7 +155,7 @@ func (w *wsConnectItem) assembleRenderData(taskId string, info websocket_data.Re } }() // todo 获取模板(模板标签下的对一个物料的的模板)目前写死参数 - productTemplate, err := w.logic.svcCtx.AllModels.FsProductTemplateV2.FindOneByProductIdTagIdWithSizeTable(w.logic.ctx, info.RenderData.ProductId, "16") + productTemplate, err := w.logic.svcCtx.AllModels.FsProductTemplateV2.FindOneByProductIdTagIdWithSizeTable(w.logic.ctx, info.RenderData.ProductId, "8") if err != nil { if errors.Is(err, gorm.ErrRecordNotFound) { logx.Error("template info is not found") From d3220e2461997384f6bc224e9db35fe05b503fa2 Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Wed, 16 Aug 2023 17:10:22 +0800 Subject: [PATCH 079/151] 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 49b7b804..560cb4d7 100644 --- a/server/websocket/internal/logic/ws_render_image_logic.go +++ b/server/websocket/internal/logic/ws_render_image_logic.go @@ -155,7 +155,7 @@ func (w *wsConnectItem) assembleRenderData(taskId string, info websocket_data.Re } }() // todo 获取模板(模板标签下的对一个物料的的模板)目前写死参数 - productTemplate, err := w.logic.svcCtx.AllModels.FsProductTemplateV2.FindOneByProductIdTagIdWithSizeTable(w.logic.ctx, info.RenderData.ProductId, "8") + productTemplate, err := w.logic.svcCtx.AllModels.FsProductTemplateV2.FindOneByProductIdTagIdWithSizeTable(w.logic.ctx, info.RenderData.ProductId, "16") if err != nil { if errors.Is(err, gorm.ErrRecordNotFound) { logx.Error("template info is not found") From a422979748f677a0db150956581c47fc03331ef6 Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Wed, 16 Aug 2023 17:18:51 +0800 Subject: [PATCH 080/151] fix --- model/gmodel/fs_product_template_element_logic.go | 6 ++++++ server/websocket/internal/logic/ws_render_image_logic.go | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/model/gmodel/fs_product_template_element_logic.go b/model/gmodel/fs_product_template_element_logic.go index 783f5480..f1f2afe4 100644 --- a/model/gmodel/fs_product_template_element_logic.go +++ b/model/gmodel/fs_product_template_element_logic.go @@ -11,3 +11,9 @@ func (e *FsProductTemplateElementModel) FindOneByModelId(ctx context.Context, mo Take(&resp).Error return resp, err } +func (e *FsProductTemplateElementModel) FindRandOne(ctx context.Context) (resp *FsProductTemplateElement, err error) { + err = e.db.WithContext(ctx).Model(&FsProductTemplateElement{}). + Order("RAND()"). + Take(&resp).Error + return resp, err +} diff --git a/server/websocket/internal/logic/ws_render_image_logic.go b/server/websocket/internal/logic/ws_render_image_logic.go index 560cb4d7..338d074b 100644 --- a/server/websocket/internal/logic/ws_render_image_logic.go +++ b/server/websocket/internal/logic/ws_render_image_logic.go @@ -188,7 +188,7 @@ func (w *wsConnectItem) assembleRenderData(taskId string, info websocket_data.Re } logx.Info("合成刀版图成功:", *res.ResourceUrl) //获取渲染设置信息 - element, err := w.logic.svcCtx.AllModels.FsProductTemplateElement.FindOneByModelId(w.logic.ctx, *productTemplate.ModelId) + element, err := w.logic.svcCtx.AllModels.FsProductTemplateElement.FindRandOne(w.logic.ctx /*, *productTemplate.ModelId*/) if err != nil { if errors.Is(err, gorm.ErrRecordNotFound) { logx.Error("element info is not found,model_id = ", *productTemplate.ModelId) From cb3e8d4db682a38f673d11855aade6634afcc0e8 Mon Sep 17 00:00:00 2001 From: Hiven Date: Wed, 16 Aug 2023 17:33:34 +0800 Subject: [PATCH 081/151] =?UTF-8?q?fix:=E9=87=8D=E6=9E=84=E5=90=88?= =?UTF-8?q?=E5=9B=BE=E6=A8=A1=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- model/gmodel/fs_resource_gen.go | 1 + model/gmodel/fs_tags_gen.go | 4 ++-- server/resource/internal/logic/logocombinelogic.go | 3 ++- service/repositories/image_handle.go | 1 + utils/file/upload.go | 3 +++ 5 files changed, 9 insertions(+), 3 deletions(-) diff --git a/model/gmodel/fs_resource_gen.go b/model/gmodel/fs_resource_gen.go index 400dd9e4..0f308faf 100644 --- a/model/gmodel/fs_resource_gen.go +++ b/model/gmodel/fs_resource_gen.go @@ -18,6 +18,7 @@ type FsResource struct { MetaKey1 *string `gorm:"index;default:'';" json:"meta_key1"` // 需要关键信息查询的自定义属性1,可以动态增加 ApiType *int64 `gorm:"default:1;" json:"api_type"` // 调用类型:1=对外,2=对内 BucketName *string `gorm:"default:'';" json:"bucket_name"` // 存储桶名: 1=持久 2=缓存 + Source *string `gorm:"default:'';" json:"source"` // 来源 } type FsResourceModel struct { db *gorm.DB diff --git a/model/gmodel/fs_tags_gen.go b/model/gmodel/fs_tags_gen.go index 5f27544b..1a7d89c9 100644 --- a/model/gmodel/fs_tags_gen.go +++ b/model/gmodel/fs_tags_gen.go @@ -16,8 +16,8 @@ type FsTags struct { Icon *string `gorm:"default:'';" json:"icon"` // 标签图标 Status *int64 `gorm:"default:1;" json:"status"` // 状态 1:可用 Description *string `gorm:"default:'';" json:"description"` // 介绍 Seo - RecommendProduct *string `gorm:"default:'';" json:"recommend_product"` // - RecommendProductSort *string `gorm:"default:'';" json:"recommend_product_sort"` // + RecommendProduct *string `gorm:"default:'';" json:"recommend_product"` // 推荐产品id例如: 1,3,4,5 + RecommendProductSort *string `gorm:"default:'';" json:"recommend_product_sort"` // 推荐排序例如:1324 Category *int64 `gorm:"default:1;" json:"category"` // 分类:1前台用的 2后台用的 } type FsTagsModel struct { diff --git a/server/resource/internal/logic/logocombinelogic.go b/server/resource/internal/logic/logocombinelogic.go index 661228e3..53b02768 100644 --- a/server/resource/internal/logic/logocombinelogic.go +++ b/server/resource/internal/logic/logocombinelogic.go @@ -65,7 +65,8 @@ func (l *LogoCombineLogic) LogoCombine(req *types.LogoCombineReq, userinfo *auth Slogan: req.Slogan, Phone: req.Phone, Address: req.Address, - Qrcode: req.Qrcode, + + Qrcode: req.Qrcode, }) if err != nil { diff --git a/service/repositories/image_handle.go b/service/repositories/image_handle.go index d9bdc43e..8db2eecc 100644 --- a/service/repositories/image_handle.go +++ b/service/repositories/image_handle.go @@ -214,6 +214,7 @@ func (l *defaultImageHandle) LogoCombine(ctx context.Context, in *LogoCombineReq AwsSession: l.AwsSession, } uploadRes, err := upload.UploadFileByBase64(&file.UploadBaseReq{ + Source: "combine-image", FileHash: resourceId, FileData: fileBase.(string), UploadBucket: 1, diff --git a/utils/file/upload.go b/utils/file/upload.go index d19752e7..d561ae28 100644 --- a/utils/file/upload.go +++ b/utils/file/upload.go @@ -22,6 +22,7 @@ type Upload struct { } type UploadBaseReq struct { + Source string FileHash string FileData string Metadata string @@ -119,6 +120,7 @@ func (upload *Upload) UploadFileByBase64(req *UploadBaseReq) (*UploadBaseRes, er Metadata: &req.Metadata, ApiType: &apiType, BucketName: bucketName, + Source: &req.Source, }).Error if err != nil { logx.Errorf("err:%+v,desc:%+v", err, "fail.upload.resourceInfoAdd.mysql") @@ -212,6 +214,7 @@ func (upload *Upload) UploadFileByByte(req *UploadBaseReq) (*UploadBaseRes, erro Metadata: &req.Metadata, ApiType: &apiType, BucketName: bucketName, + Source: &req.Source, }).Error if err != nil { logx.Errorf("err:%+v,desc:%+v", err, "fail.upload.resourceInfoAdd.mysql") From 1a0286a1cba4468028290c0a4049c07ec212494c Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Wed, 16 Aug 2023 17:36:25 +0800 Subject: [PATCH 082/151] fix --- server/websocket/internal/logic/rendernotifylogic.go | 1 + 1 file changed, 1 insertion(+) diff --git a/server/websocket/internal/logic/rendernotifylogic.go b/server/websocket/internal/logic/rendernotifylogic.go index e8ee60c5..ec34190e 100644 --- a/server/websocket/internal/logic/rendernotifylogic.go +++ b/server/websocket/internal/logic/rendernotifylogic.go @@ -96,5 +96,6 @@ func (l *RenderNotifyLogic) RenderNotify(req *types.RenderNotifyReq, userinfo *a ws.sendToOutChan(b) return true }) + logx.Info("渲染回调成功######################") return resp.SetStatusWithMessage(basic.CodeOK, "success") } From 07dbf5eb6d931703e006d12576cec8a7c4ab5e2f Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Wed, 16 Aug 2023 17:48:03 +0800 Subject: [PATCH 083/151] fix --- model/gmodel/fs_product_template_element_logic.go | 6 ------ server/websocket/internal/logic/ws_render_image_logic.go | 2 +- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/model/gmodel/fs_product_template_element_logic.go b/model/gmodel/fs_product_template_element_logic.go index f1f2afe4..783f5480 100644 --- a/model/gmodel/fs_product_template_element_logic.go +++ b/model/gmodel/fs_product_template_element_logic.go @@ -11,9 +11,3 @@ func (e *FsProductTemplateElementModel) FindOneByModelId(ctx context.Context, mo Take(&resp).Error return resp, err } -func (e *FsProductTemplateElementModel) FindRandOne(ctx context.Context) (resp *FsProductTemplateElement, err error) { - err = e.db.WithContext(ctx).Model(&FsProductTemplateElement{}). - Order("RAND()"). - Take(&resp).Error - return resp, err -} diff --git a/server/websocket/internal/logic/ws_render_image_logic.go b/server/websocket/internal/logic/ws_render_image_logic.go index 338d074b..560cb4d7 100644 --- a/server/websocket/internal/logic/ws_render_image_logic.go +++ b/server/websocket/internal/logic/ws_render_image_logic.go @@ -188,7 +188,7 @@ func (w *wsConnectItem) assembleRenderData(taskId string, info websocket_data.Re } logx.Info("合成刀版图成功:", *res.ResourceUrl) //获取渲染设置信息 - element, err := w.logic.svcCtx.AllModels.FsProductTemplateElement.FindRandOne(w.logic.ctx /*, *productTemplate.ModelId*/) + element, err := w.logic.svcCtx.AllModels.FsProductTemplateElement.FindOneByModelId(w.logic.ctx, *productTemplate.ModelId) if err != nil { if errors.Is(err, gorm.ErrRecordNotFound) { logx.Error("element info is not found,model_id = ", *productTemplate.ModelId) From b222579633bcc6e001eb5642cd2f2e31a481c658 Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Thu, 17 Aug 2023 10:39:02 +0800 Subject: [PATCH 084/151] fix --- server/websocket/internal/logic/ws_render_image_logic.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/server/websocket/internal/logic/ws_render_image_logic.go b/server/websocket/internal/logic/ws_render_image_logic.go index 560cb4d7..76133a46 100644 --- a/server/websocket/internal/logic/ws_render_image_logic.go +++ b/server/websocket/internal/logic/ws_render_image_logic.go @@ -191,6 +191,12 @@ func (w *wsConnectItem) assembleRenderData(taskId string, info websocket_data.Re element, err := w.logic.svcCtx.AllModels.FsProductTemplateElement.FindOneByModelId(w.logic.ctx, *productTemplate.ModelId) if err != nil { if errors.Is(err, gorm.ErrRecordNotFound) { + // todo 没有图就给他返回一张默认(后面要删除) + defaultImg := w.respondDataFormat(constants.WEBSOCKET_RENDER_IMAGE, websocket_data.RenderImageRspMsg{ + RenderId: info.RenderId, + Image: "https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/695463af6e9b93c003db39ddf728241f9523efc55b20dc37f30fe5d96ed54fb5", + }) + w.sendToOutChan(defaultImg) logx.Error("element info is not found,model_id = ", *productTemplate.ModelId) return err } From 757a7fb0b4976cfb508dc1535085c7866ae10fd3 Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Thu, 17 Aug 2023 11:09:59 +0800 Subject: [PATCH 085/151] fix --- model/gmodel/fs_product_template_tags_gen.go | 12 ++++++------ model/gmodel/fs_product_template_tags_logic.go | 4 ++-- model/gmodel/fs_product_template_v2_gen.go | 2 +- model/gmodel/fs_product_template_v2_logic.go | 6 +++--- .../product/internal/logic/gettemplatebypidlogic.go | 11 ++++++++++- .../internal/logic/ws_render_image_logic.go | 4 ++-- 6 files changed, 24 insertions(+), 15 deletions(-) diff --git a/model/gmodel/fs_product_template_tags_gen.go b/model/gmodel/fs_product_template_tags_gen.go index a5505bbb..a940bced 100644 --- a/model/gmodel/fs_product_template_tags_gen.go +++ b/model/gmodel/fs_product_template_tags_gen.go @@ -6,12 +6,12 @@ import ( // fs_product_template_tags 模板标签表 type FsProductTemplateTags struct { - Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` // ID - 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"` // 创建时间 - Groups *string `gorm:"default:'';" json:"groups"` // 分组信息 + Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` // ID + TemplateTag *string `gorm:"unique_key;default:'';" json:"template_tag"` // 标题 + Cover *string `gorm:"default:'';" json:"cover"` // 封面图 + Status *int64 `gorm:"default:0;" json:"status"` // 状态 1:可用 + CreateAt *int64 `gorm:"default:0;" json:"create_at"` // 创建时间 + Groups *string `gorm:"default:'';" json:"groups"` // 分组信息 } type FsProductTemplateTagsModel struct { db *gorm.DB diff --git a/model/gmodel/fs_product_template_tags_logic.go b/model/gmodel/fs_product_template_tags_logic.go index 96d4cca2..efa20ad8 100755 --- a/model/gmodel/fs_product_template_tags_logic.go +++ b/model/gmodel/fs_product_template_tags_logic.go @@ -36,7 +36,7 @@ func (pt *FsProductTemplateTagsModel) GetListByTagNames(ctx context.Context, tag if len(tagNames) == 0 { return nil, nil } - db := pt.db.WithContext(ctx).Model(&FsProductTemplateTags{}).Where("`title` in (?) and `status` = ?", tagNames, 1) + db := pt.db.WithContext(ctx).Model(&FsProductTemplateTags{}).Where("`template_tag` in (?) and `status` = ?", tagNames, 1) if orderBy != "" { db = db.Order(orderBy) } @@ -44,6 +44,6 @@ func (pt *FsProductTemplateTagsModel) GetListByTagNames(ctx context.Context, tag 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 + err = pt.db.WithContext(ctx).Model(&FsProductTemplateTags{}).Where("`template_tag` = ? and `status` = ?", tagName, 1).Take(&resp).Error return resp, err } diff --git a/model/gmodel/fs_product_template_v2_gen.go b/model/gmodel/fs_product_template_v2_gen.go index 68c91ed5..e1c1780f 100644 --- a/model/gmodel/fs_product_template_v2_gen.go +++ b/model/gmodel/fs_product_template_v2_gen.go @@ -20,7 +20,7 @@ type FsProductTemplateV2 struct { IsPublic *int64 `gorm:"default:0;" json:"is_public"` // 是否可公用(1:可以,0:不可以) Status *int64 `gorm:"default:0;" json:"status"` // 状态1正常 2异常 Ctime *int64 `gorm:"default:0;" json:"ctime"` // 添加时间 - Tag *string `gorm:"default:'';" json:"tag"` // + TemplateTag *string `gorm:"default:'';" json:"template_tag"` // IsDel *int64 `gorm:"default:0;" json:"is_del"` // 是否删除 1删除 SwitchInfo *string `gorm:"default:'';" json:"switch_info"` // GroupOptions *string `gorm:"default:'';" json:"group_options"` // diff --git a/model/gmodel/fs_product_template_v2_logic.go b/model/gmodel/fs_product_template_v2_logic.go index a4945096..8ae2897d 100755 --- a/model/gmodel/fs_product_template_v2_logic.go +++ b/model/gmodel/fs_product_template_v2_logic.go @@ -115,7 +115,7 @@ func (t *FsProductTemplateV2Model) FindOneByProductIdTagIdWithSizeTable(ctx cont 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, templateTag). + Where("t.product_id = ? and t.template_tag = ? ", productId, templateTag). Where("t.status = ? and t.is_del = ?", 1, 0). Where("s.status = ?", 1). Order("s.sort ASC"). @@ -126,7 +126,7 @@ func (t *FsProductTemplateV2Model) FindAllByModelIdsTemplateTag(ctx context.Cont if len(modelIds) == 0 { return } - db := t.db.WithContext(ctx).Model(&FsProductTemplateV2{}).Where("`model_id` in (?) and `tag` = ? and `is_del` = ? and `status` = ?", modelIds, templateTag, 0, 1) + db := t.db.WithContext(ctx).Model(&FsProductTemplateV2{}).Where("`model_id` in (?) and `template_tag` = ? and `is_del` = ? and `status` = ?", modelIds, templateTag, 0, 1) if len(fields) != 0 { db = db.Select(fields[0]) } @@ -143,7 +143,7 @@ func (t *FsProductTemplateV2Model) FindAllByModelIdsTemplateTag(ctx context.Cont // 获取产品在指定模板标签下的所有模板 func (t *FsProductTemplateV2Model) GetListByProductAndTemplateTag(ctx context.Context, templateTagId string, productId int64, fields ...string) (resp []FsProductTemplateV2, err error) { db := t.db.WithContext(ctx).Model(&FsProductTemplateV2{}). - Where("tag = ? and product_id = ? and status = ? and is_del = ?", templateTagId, productId, 1, 0) + Where("template_tag = ? and product_id = ? and status = ? and is_del = ?", templateTagId, productId, 1, 0) if len(fields) > 0 { db = db.Select(fields[0]) } diff --git a/server/product/internal/logic/gettemplatebypidlogic.go b/server/product/internal/logic/gettemplatebypidlogic.go index 9e1b66d1..7612c61c 100644 --- a/server/product/internal/logic/gettemplatebypidlogic.go +++ b/server/product/internal/logic/gettemplatebypidlogic.go @@ -67,6 +67,15 @@ func (l *GetTemplateByPidLogic) GetTemplateByPid(req *types.GetTemplateByPidReq, } else { //指定物料 sizeIds = append(sizeIds, req.ProductSizeId) } + //获取templatetag信息 + templateTagInfo, err := l.svcCtx.AllModels.FsProductTemplateTags.FindOne(l.ctx, req.ProductTemplateTagId) + if err != nil { + if errors.Is(err, gorm.ErrRecordNotFound) { + return resp.SetStatusWithMessage(basic.CodeDbRecordNotFoundErr, "template tag is not exists") + } + logx.Error(err) + return resp.SetStatusWithMessage(basic.CodeDbRecordNotFoundErr, "failed to get template tag") + } //根据尺寸id获取模型 modelList, err := l.svcCtx.AllModels.FsProductModel3d.GetAllBySizeIdsTag(l.ctx, sizeIds, constants.TAG_MODEL) if err != nil { @@ -83,7 +92,7 @@ func (l *GetTemplateByPidLogic) GetTemplateByPid(req *types.GetTemplateByPidReq, mapModel[v.Id] = k } //查询模型ids下对应tag标签的模板 - templateList, err := l.svcCtx.AllModels.FsProductTemplateV2.FindAllByModelIdsTemplateTag(l.ctx, modelIds, fmt.Sprintf("%d", req.ProductTemplateTagId), "") + templateList, err := l.svcCtx.AllModels.FsProductTemplateV2.FindAllByModelIdsTemplateTag(l.ctx, modelIds, *templateTagInfo.TemplateTag, "") if err != nil { logx.Error(err) return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get template list") diff --git a/server/websocket/internal/logic/ws_render_image_logic.go b/server/websocket/internal/logic/ws_render_image_logic.go index 76133a46..6d8601c1 100644 --- a/server/websocket/internal/logic/ws_render_image_logic.go +++ b/server/websocket/internal/logic/ws_render_image_logic.go @@ -154,8 +154,8 @@ func (w *wsConnectItem) assembleRenderData(taskId string, info websocket_data.Re logx.Error("assembleRenderData panic:", err) } }() - // todo 获取模板(模板标签下的对一个物料的的模板)目前写死参数 - productTemplate, err := w.logic.svcCtx.AllModels.FsProductTemplateV2.FindOneByProductIdTagIdWithSizeTable(w.logic.ctx, info.RenderData.ProductId, "16") + //获取模板 + productTemplate, err := w.logic.svcCtx.AllModels.FsProductTemplateV2.FindOneByProductIdTagIdWithSizeTable(w.logic.ctx, info.RenderData.ProductId, info.RenderData.TemplateTag) if err != nil { if errors.Is(err, gorm.ErrRecordNotFound) { logx.Error("template info is not found") From 748b7e5b66a1af341bd0ac1f8f0af2eb5c041b6b Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Thu, 17 Aug 2023 11:11:58 +0800 Subject: [PATCH 086/151] fix --- server/product/internal/logic/getproductinfologic.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/server/product/internal/logic/getproductinfologic.go b/server/product/internal/logic/getproductinfologic.go index 8047752a..1a768d3c 100644 --- a/server/product/internal/logic/getproductinfologic.go +++ b/server/product/internal/logic/getproductinfologic.go @@ -109,8 +109,8 @@ func (l *GetProductInfoLogic) GetProductInfo(req *types.GetProductInfoReq, useri tagIds := make([]int64, 0, len(productTemplateList)) for _, v := range productTemplateList { mapTemplateModelId[*v.ModelId] = struct{}{} - if v.Tag != nil && *v.Tag != "" { - tagId, err := strconv.ParseInt(*v.Tag, 10, 64) + if v.TemplateTag != nil && *v.TemplateTag != "" { + tagId, err := strconv.ParseInt(*v.TemplateTag, 10, 64) if err != nil { logx.Error(err) return resp.SetStatusWithMessage(basic.CodeServiceErr, "tag is not a number") @@ -296,7 +296,7 @@ func (l *GetProductInfoLogic) GetProductInfo(req *types.GetProductInfoReq, useri partListRsp = append(partListRsp, thisInfo) } tagName := "" - if tagData, ok := mapTag[*tmp.Tag]; ok { + if tagData, ok := mapTag[*tmp.TemplateTag]; ok { tagName = *tagData.Title } //按照材质和尺寸来存放模板信息 From be95ff9d050fbd7f42d3b84f54447d289024457d Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Thu, 17 Aug 2023 11:14:47 +0800 Subject: [PATCH 087/151] fix --- model/gmodel/fs_product_tag_prop_logic.go | 4 ++-- server/product/internal/logic/getrecommandproductlistlogic.go | 2 +- server/product/internal/logic/gettagproductlistlogic.go | 2 +- .../internal/logic/homepagerecommendproductlistlogic.go | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/model/gmodel/fs_product_tag_prop_logic.go b/model/gmodel/fs_product_tag_prop_logic.go index 6612e196..338a61d1 100644 --- a/model/gmodel/fs_product_tag_prop_logic.go +++ b/model/gmodel/fs_product_tag_prop_logic.go @@ -5,7 +5,7 @@ import "context" // TODO: 使用model的属性做你想做的 type GetTagPropByProductIdsWithProductTagRsp struct { FsProductTagProp - Title string `json:"title"` + TemplateTag string `json:"template_tag"` } func (p *FsProductTagPropModel) GetTagPropByProductIdsWithProductTag(ctx context.Context, productIds []int64) (resp []GetTagPropByProductIdsWithProductTagRsp, err error) { @@ -14,7 +14,7 @@ func (p *FsProductTagPropModel) GetTagPropByProductIdsWithProductTag(ctx context } err = p.db.WithContext(ctx).Table(p.name+" as p "). Joins("left join fs_product_template_tags as t on p.template_tag_id = t.id"). - Select("p.*,t.title as title"). + Select("p.*,t.template_tag as template_tag"). Where("p.product_id in (?) and p.status = ? and t.status = ?", productIds, 1, 1). Find(&resp).Error return resp, err diff --git a/server/product/internal/logic/getrecommandproductlistlogic.go b/server/product/internal/logic/getrecommandproductlistlogic.go index d73206c7..7f082fef 100644 --- a/server/product/internal/logic/getrecommandproductlistlogic.go +++ b/server/product/internal/logic/getrecommandproductlistlogic.go @@ -127,7 +127,7 @@ func (l *GetRecommandProductListLogic) GetRecommandProductList(req *types.GetRec mapTagProp := make(map[int64][]types.CoverDefaultItem) for _, v := range productTagPropList { mapTagProp[*v.ProductId] = append(mapTagProp[*v.ProductId], types.CoverDefaultItem{ - Tag: v.Title, + Tag: v.TemplateTag, Cover: *v.Cover, }) } diff --git a/server/product/internal/logic/gettagproductlistlogic.go b/server/product/internal/logic/gettagproductlistlogic.go index 480e2bc1..9b84207e 100644 --- a/server/product/internal/logic/gettagproductlistlogic.go +++ b/server/product/internal/logic/gettagproductlistlogic.go @@ -138,7 +138,7 @@ func (l *GetTagProductListLogic) GetTagProductList(req *types.GetTagProductListR } for _, v := range productTagPropList { mapTagProp[*v.ProductId] = append(mapTagProp[*v.ProductId], types.CoverDefaultItem{ - Tag: v.Title, + Tag: v.TemplateTag, Cover: *v.Cover, }) } diff --git a/server/product/internal/logic/homepagerecommendproductlistlogic.go b/server/product/internal/logic/homepagerecommendproductlistlogic.go index a8bd03df..6d449757 100644 --- a/server/product/internal/logic/homepagerecommendproductlistlogic.go +++ b/server/product/internal/logic/homepagerecommendproductlistlogic.go @@ -156,7 +156,7 @@ func (l *HomePageRecommendProductListLogic) HomePageRecommendProductList(req *ty mapTagProp := make(map[int64][]types.CoverDefaultItem) for _, v := range productTagPropList { mapTagProp[*v.ProductId] = append(mapTagProp[*v.ProductId], types.CoverDefaultItem{ - Tag: v.Title, + Tag: v.TemplateTag, Cover: *v.Cover, }) } From 8de81859d209c9c796456da460fe37c3f9deeb94 Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Thu, 17 Aug 2023 11:15:42 +0800 Subject: [PATCH 088/151] fix --- .../internal/logic/getproducttemplatetagslogic.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/product-template-tag/internal/logic/getproducttemplatetagslogic.go b/server/product-template-tag/internal/logic/getproducttemplatetagslogic.go index d0c8377f..cf89a9b4 100644 --- a/server/product-template-tag/internal/logic/getproducttemplatetagslogic.go +++ b/server/product-template-tag/internal/logic/getproducttemplatetagslogic.go @@ -83,7 +83,7 @@ func (l *GetProductTemplateTagsLogic) GetProductTemplateTags(req *types.GetProdu for _, v := range productTemplateTags { list = append(list, types.GetProductTemplateTagsRsp{ Id: v.Id, - TemplateTag: *v.Title, + TemplateTag: *v.TemplateTag, Cover: *v.Cover, }) } From f84644b406d0046fc7a5bb0d67c99d169f854ce4 Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Thu, 17 Aug 2023 11:28:56 +0800 Subject: [PATCH 089/151] fix --- model/gmodel/fs_product_template_v2_gen.go | 1 - 1 file changed, 1 deletion(-) diff --git a/model/gmodel/fs_product_template_v2_gen.go b/model/gmodel/fs_product_template_v2_gen.go index e1c1780f..cd6a5f51 100644 --- a/model/gmodel/fs_product_template_v2_gen.go +++ b/model/gmodel/fs_product_template_v2_gen.go @@ -23,7 +23,6 @@ type FsProductTemplateV2 struct { TemplateTag *string `gorm:"default:'';" json:"template_tag"` // 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:"index;default:0;" json:"version"` // 默认1 } type FsProductTemplateV2Model struct { From 69030d31deeeca37c2c0d33019c04e341d873926 Mon Sep 17 00:00:00 2001 From: Hiven Date: Thu, 17 Aug 2023 11:29:32 +0800 Subject: [PATCH 090/151] =?UTF-8?q?fix:=E9=87=8D=E6=9E=84=E5=90=88?= =?UTF-8?q?=E5=9B=BE=E6=A8=A1=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/resource/resource_test.go | 3 --- service/repositories/image_handle.go | 10 +--------- 2 files changed, 1 insertion(+), 12 deletions(-) diff --git a/server/resource/resource_test.go b/server/resource/resource_test.go index d035c13a..80820ef2 100644 --- a/server/resource/resource_test.go +++ b/server/resource/resource_test.go @@ -4,9 +4,6 @@ import ( "testing" ) -// var configFile = flag.String("f", "etc/home-user-auth.yaml", "the config file") - func TestMain(t *testing.T) { - // log.Println(model.RawFieldNames[FsCanteenType]()) main() } diff --git a/service/repositories/image_handle.go b/service/repositories/image_handle.go index 8db2eecc..ffacf0d2 100644 --- a/service/repositories/image_handle.go +++ b/service/repositories/image_handle.go @@ -92,15 +92,6 @@ func (l *defaultImageHandle) LogoCombine(ctx context.Context, in *LogoCombineReq return nil, err } var groupOptions map[string]interface{} - if productTemplateV2Info.GroupOptions != nil { - err = json.Unmarshal([]byte(*productTemplateV2Info.GroupOptions), &groupOptions) - - if err != nil { - logx.Error(err) - return nil, err - } - } - var materialList []interface{} if productTemplateV2Info.TemplateInfo != nil { var templateInfo map[string]interface{} @@ -111,6 +102,7 @@ func (l *defaultImageHandle) LogoCombine(ctx context.Context, in *LogoCombineReq return nil, err } materialList = templateInfo["materialList"].([]interface{}) + groupOptions = templateInfo["groupOptions"].(map[string]interface{}) } var moduleDataMap = make(map[string]interface{}, 4) From 3ed2e0e06c29af218b570a71b4bccc0d5989d51e Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Thu, 17 Aug 2023 11:36:41 +0800 Subject: [PATCH 091/151] fix --- server/websocket/internal/logic/rendernotifylogic.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/server/websocket/internal/logic/rendernotifylogic.go b/server/websocket/internal/logic/rendernotifylogic.go index ec34190e..3ad4e9b2 100644 --- a/server/websocket/internal/logic/rendernotifylogic.go +++ b/server/websocket/internal/logic/rendernotifylogic.go @@ -55,12 +55,15 @@ func (l *RenderNotifyLogic) RenderNotify(req *types.RenderNotifyReq, userinfo *a AwsSession: l.svcCtx.AwsSession, } uploadRes, err := upload.UploadFileByBase64(&file.UploadBaseReq{ + Source: "unity cloud render", FileHash: req.TaskId, FileData: req.Image, + Metadata: "", UploadBucket: 1, ApiType: 2, UserId: req.UserId, GuestId: req.GuestId, + FileByte: nil, }) if err != nil { logx.Error(err) From 5b4dd9f360d337940f72706c7941ef8145a19f0d Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Thu, 17 Aug 2023 11:44:18 +0800 Subject: [PATCH 092/151] fix --- server/product/internal/logic/gettagproductlistlogic.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/server/product/internal/logic/gettagproductlistlogic.go b/server/product/internal/logic/gettagproductlistlogic.go index 9b84207e..0ebb5196 100644 --- a/server/product/internal/logic/gettagproductlistlogic.go +++ b/server/product/internal/logic/gettagproductlistlogic.go @@ -312,6 +312,10 @@ func (l *GetTagProductListLogic) organizationLevelRelation(minLevel int, mapTagL //最终值提取最高级别那一层出来 rspList := make([]types.TagItem, 0, len(mapTagLevel)) for prefix, _ := range mapTop { + //大类下没有任何产品则不显示 + if len(mapTagLevel[prefix].TagProductList) == 0 { + continue + } rspList = append(rspList, *mapTagLevel[prefix]) } //排序 From c3cd57b7e5b79689bf9537ff97d1272e9e182283 Mon Sep 17 00:00:00 2001 From: Hiven Date: Thu, 17 Aug 2023 11:46:17 +0800 Subject: [PATCH 093/151] =?UTF-8?q?fix:=E4=B8=8A=E4=BC=A0=E6=A8=A1?= =?UTF-8?q?=E5=9D=97=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/upload/internal/logic/uploadcallbacklogic.go | 2 ++ server/upload/internal/logic/uploadfilebackendlogic.go | 1 + server/upload/internal/logic/uploadfilebaselogic.go | 1 + server/upload/internal/logic/uploadfilesbackendlogic.go | 3 +++ server/upload/internal/logic/uploadlogologic.go | 1 + server/upload/internal/types/types.go | 4 ++++ server_api/upload.api | 4 ++++ 7 files changed, 16 insertions(+) diff --git a/server/upload/internal/logic/uploadcallbacklogic.go b/server/upload/internal/logic/uploadcallbacklogic.go index 615052fd..796016ba 100644 --- a/server/upload/internal/logic/uploadcallbacklogic.go +++ b/server/upload/internal/logic/uploadcallbacklogic.go @@ -83,8 +83,10 @@ func (l *UploadCallbackLogic) UploadCallback(req *types.UploadCallbackReq, useri fsResource.ResourceUrl = &req.ResourceUrl fsResource.Metadata = &req.Metadata fsResource.ApiType = &req.ApiType + fsResource.Source = &req.Source fsResource.BucketName = bucketName fsResource.Version = &version + if resourceInfo.ResourceId == "" { _, err = resourceModelTS.BuilderCreate(ctx, transBuilder, fsResource) } else { diff --git a/server/upload/internal/logic/uploadfilebackendlogic.go b/server/upload/internal/logic/uploadfilebackendlogic.go index 3864c3a4..8e817639 100644 --- a/server/upload/internal/logic/uploadfilebackendlogic.go +++ b/server/upload/internal/logic/uploadfilebackendlogic.go @@ -90,6 +90,7 @@ func (l *UploadFileBackendLogic) UploadFileBackend(req *types.UploadFileBackendR ApiType: req.ApiType, UserId: userId, GuestId: guestId, + Source: req.Source, }) if err != nil { diff --git a/server/upload/internal/logic/uploadfilebaselogic.go b/server/upload/internal/logic/uploadfilebaselogic.go index 0e079884..55326ac1 100644 --- a/server/upload/internal/logic/uploadfilebaselogic.go +++ b/server/upload/internal/logic/uploadfilebaselogic.go @@ -77,6 +77,7 @@ func (l *UploadFileBaseLogic) UploadFileBase(req *types.UploadFileBaseReq, useri ApiType: req.ApiType, UserId: userId, GuestId: guestId, + Source: req.Source, }) if err != nil { diff --git a/server/upload/internal/logic/uploadfilesbackendlogic.go b/server/upload/internal/logic/uploadfilesbackendlogic.go index 6995b0c7..cedbb8de 100644 --- a/server/upload/internal/logic/uploadfilesbackendlogic.go +++ b/server/upload/internal/logic/uploadfilesbackendlogic.go @@ -123,6 +123,7 @@ func (l *UploadFilesBackendLogic) UploadFilesBackend(req *types.UploadFilesReq, ApiType: req.ApiType, Bucket: bucketName, HashKey: hashKey, + Source: req.Source, } } }, func(item interface{}, writer mr.Writer[interface{}], cancel func(error)) { @@ -148,6 +149,7 @@ func (l *UploadFilesBackendLogic) UploadFilesBackend(req *types.UploadFilesReq, ApiType: req.ApiType, UserId: userId, GuestId: guestId, + Source: uploadDataInfo.Source, }) if err == nil { uploadUrl.Status = 1 @@ -201,6 +203,7 @@ type UploadData struct { Bucket *string `json:"bucket"` HashKey string `json:"hash_key"` FileData []byte `fsfile:"data"` + Source string `json:"source"` } type UploadUrl struct { diff --git a/server/upload/internal/logic/uploadlogologic.go b/server/upload/internal/logic/uploadlogologic.go index 1c51eb22..074c3d3f 100644 --- a/server/upload/internal/logic/uploadlogologic.go +++ b/server/upload/internal/logic/uploadlogologic.go @@ -115,6 +115,7 @@ func (l *UploadLogoLogic) UploadLogo(req *types.UploadLogoReq, userinfo *auth.Us ApiType: 2, UserId: userId, GuestId: guestId, + Source: "upload-logo", }) if err != nil { diff --git a/server/upload/internal/types/types.go b/server/upload/internal/types/types.go index 6ac757ae..4a946586 100644 --- a/server/upload/internal/types/types.go +++ b/server/upload/internal/types/types.go @@ -13,6 +13,7 @@ type UploadFileBaseReq struct { UserId int64 `form:"user_id,optional"` // 上传文件额外信息 GuestId int64 `form:"guest_id,optional"` // 上传文件额外信息 UploadBucket int64 `form:"upload_bucket,options=[1,2],default=1"` // 上传桶名:1=缓存,2=持久 + Source string `form:"source"` // 上传来源 } type UploadLogoReq struct { @@ -28,12 +29,14 @@ type UploadFileBackendReq struct { FileKey string `form:"file_key"` // 上传唯一标识信息 FileSize int64 `form:"file_size,optional"` // 上传唯一标识信息 Metadata string `form:"meta_data,optional"` // 上传文件额外信息 + Source string `form:"source"` // 上传来源 } type UploadFilesReq struct { ApiType int64 `form:"api_type,options=[1,2],default=1"` // 调用类型:1=对外,2=对内 UploadBucket int64 `form:"upload_bucket,options=[1,2],default=1"` // 上传桶名:1=缓存,2=持久 UploadInfo string `form:"upload_info"` // 上传信息 json + Source string `form:"source"` // 上传来源 } type UploadCallbackReq struct { @@ -43,6 +46,7 @@ type UploadCallbackReq struct { ResourceUrl string `form:"resource_url"` // 资源URL Metadata string `form:"metadata,optional"` // 元数据,json格式,存储图像分率 ApiType int64 `form:"api_type,options=[1,2],default=1"` // 调用类型:1=对外,2=对内 + Source string `form:"source"` // 上传来源 } type RequestUpFile struct { diff --git a/server_api/upload.api b/server_api/upload.api index a3c7399f..85e85433 100644 --- a/server_api/upload.api +++ b/server_api/upload.api @@ -53,6 +53,7 @@ type ( UserId int64 `form:"user_id,optional"` // 上传文件额外信息 GuestId int64 `form:"guest_id,optional"` // 上传文件额外信息 UploadBucket int64 `form:"upload_bucket,options=[1,2],default=1"` // 上传桶名:1=缓存,2=持久 + Source string `form:"source"` // 上传来源 } ) @@ -72,12 +73,14 @@ type ( FileKey string `form:"file_key"` // 上传唯一标识信息 FileSize int64 `form:"file_size,optional"` // 上传唯一标识信息 Metadata string `form:"meta_data,optional"` // 上传文件额外信息 + Source string `form:"source"` // 上传来源 } UploadFilesReq { ApiType int64 `form:"api_type,options=[1,2],default=1"` // 调用类型:1=对外,2=对内 UploadBucket int64 `form:"upload_bucket,options=[1,2],default=1"` // 上传桶名:1=缓存,2=持久 UploadInfo string `form:"upload_info"` // 上传信息 json + Source string `form:"source"` // 上传来源 } UploadCallbackReq { UploadBucket int64 `form:"upload_bucket,options=[1,2],default=1"` // 上传桶名:1=缓存,2=持久 @@ -86,6 +89,7 @@ type ( ResourceUrl string `form:"resource_url"` // 资源URL Metadata string `form:"metadata,optional"` // 元数据,json格式,存储图像分率 ApiType int64 `form:"api_type,options=[1,2],default=1"` // 调用类型:1=对外,2=对内 + Source string `form:"source"` // 上传来源 } ) From d2c8fa902077b3f048190d3b90453eb6358187e8 Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Thu, 17 Aug 2023 11:49:31 +0800 Subject: [PATCH 094/151] fix --- model/gmodel/fs_product_template_tags_logic.go | 8 ++++++-- .../internal/logic/gettemplatevdetaillogic.go | 11 ++--------- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/model/gmodel/fs_product_template_tags_logic.go b/model/gmodel/fs_product_template_tags_logic.go index efa20ad8..53e76130 100755 --- a/model/gmodel/fs_product_template_tags_logic.go +++ b/model/gmodel/fs_product_template_tags_logic.go @@ -43,7 +43,11 @@ func (pt *FsProductTemplateTagsModel) GetListByTagNames(ctx context.Context, tag 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("`template_tag` = ? and `status` = ?", tagName, 1).Take(&resp).Error +func (pt *FsProductTemplateTagsModel) FindOneByTagName(ctx context.Context, tagName string, fields ...string) (resp *FsProductTemplateTags, err error) { + db := pt.db.WithContext(ctx).Model(&FsProductTemplateTags{}).Where("`template_tag` = ? and `status` = ?", tagName, 1) + if len(fields) != 0 { + db = db.Select(fields[0]) + } + err = db.Take(&resp).Error return resp, err } diff --git a/server/product-template/internal/logic/gettemplatevdetaillogic.go b/server/product-template/internal/logic/gettemplatevdetaillogic.go index 12324f50..7ef73a14 100644 --- a/server/product-template/internal/logic/gettemplatevdetaillogic.go +++ b/server/product-template/internal/logic/gettemplatevdetaillogic.go @@ -8,7 +8,6 @@ import ( "fusenapi/utils/basic" "fusenapi/utils/format" "gorm.io/gorm" - "strconv" "strings" "context" @@ -62,13 +61,7 @@ func (l *GetTemplatevDetailLogic) GetTemplatevDetail(req *types.GetTemplatevDeta return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get product template info") } //获取模板标签 - templateTagModel := gmodel.NewFsProductTemplateTagsModel(l.svcCtx.MysqlConn) - tagId, err := strconv.ParseInt(*templatev2Info.Tag, 10, 64) - if err != nil { - logx.Error(err) - return resp.SetStatusWithMessage(basic.CodeServiceErr, "parse int tag id err") - } - templateTagInfo, err := templateTagModel.FindOne(l.ctx, tagId, "id,title") + templateTagInfo, err := l.svcCtx.AllModels.FsProductTemplateTags.FindOneByTagName(l.ctx, *templatev2Info.TemplateTag, "id,title") if err != nil { if errors.Is(err, gorm.ErrRecordNotFound) { return resp.SetStatusWithMessage(basic.CodeDbRecordNotFoundErr, "template tag info is not exists") @@ -125,7 +118,7 @@ func (l *GetTemplatevDetailLogic) GetTemplatevDetail(req *types.GetTemplatevDeta } templateInfoRsp["tag"] = map[string]interface{}{ "id": templateTagInfo.Id, - "title": *templateTagInfo.Title, + "title": *templateTagInfo.TemplateTag, } response := types.GetTemplatevDetailRsp{ ProductModelInfo: productModelInfoRsp, From 8996424556d82b92095dcc6b9a4766968dd6ad71 Mon Sep 17 00:00:00 2001 From: Hiven Date: Thu, 17 Aug 2023 11:51:05 +0800 Subject: [PATCH 095/151] =?UTF-8?q?fix:=E4=B8=8A=E4=BC=A0=E6=A8=A1?= =?UTF-8?q?=E5=9D=97=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/map-library/internal/logic/getmaplibrarylistlogic.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/map-library/internal/logic/getmaplibrarylistlogic.go b/server/map-library/internal/logic/getmaplibrarylistlogic.go index aa7ec7a8..1ecf5167 100644 --- a/server/map-library/internal/logic/getmaplibrarylistlogic.go +++ b/server/map-library/internal/logic/getmaplibrarylistlogic.go @@ -66,7 +66,7 @@ func (l *GetMapLibraryListLogic) GetMapLibraryList(req *types.Request, userinfo if tagIndex, ok := mapTag[*v.TagId]; ok { data.Tag = &types.MapLibraryListTag{ Id: templateTagList[tagIndex].Id, - Title: *templateTagList[tagIndex].Title, + Title: *templateTagList[tagIndex].TemplateTag, } } //解析info From 82c7fc96f54adf82c27a5ddc6ef3d69ec70363ae Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Thu, 17 Aug 2023 11:56:37 +0800 Subject: [PATCH 096/151] fix --- .../gmodel/fs_product_template_element_gen.go | 40 +++++++++---------- .../fs_product_template_element_logic.go | 2 +- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/model/gmodel/fs_product_template_element_gen.go b/model/gmodel/fs_product_template_element_gen.go index 7dd21864..44f32f14 100644 --- a/model/gmodel/fs_product_template_element_gen.go +++ b/model/gmodel/fs_product_template_element_gen.go @@ -6,26 +6,26 @@ import ( // fs_product_template_element 云渲染配置表 type FsProductTemplateElement struct { - Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` // id - Title *string `gorm:"default:'';" json:"title"` // 产品模板名称 - ProductTemplateId *int64 `gorm:"index;default:0;" json:"product_template_id"` // 产品模板id - Main *string `gorm:"default:'';" json:"main"` // - Second *string `gorm:"default:'';" json:"second"` // - Base *string `gorm:"default:'';" json:"base"` // - Paper *string `gorm:"default:'';" json:"paper"` // - Spoon *string `gorm:"default:'';" json:"spoon"` // - Fork *string `gorm:"default:'';" json:"fork"` // - Toothpick *string `gorm:"default:'';" json:"toothpick"` // - Chopsticks *string `gorm:"default:'';" json:"chopsticks"` // - Shadow *string `gorm:"default:'';" json:"shadow"` // - Cover *string `gorm:"default:'';" json:"cover"` // - Cover1 *string `gorm:"default:'';" json:"cover1"` // - Mode *string `gorm:"default:'';" json:"mode"` // - Light *int64 `gorm:"default:0;" json:"light"` // - Rotation *string `gorm:"default:'';" json:"rotation"` // - Scale *string `gorm:"default:'';" json:"scale"` // - ModelP *string `gorm:"default:'';" json:"model_p"` // 配件对应的云渲染贴图数据 - Refletion *string `gorm:"default:'';" json:"refletion"` // 反射探头组 + Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` // id + Title *string `gorm:"default:'';" json:"title"` // 产品模板名称 + ModelId *int64 `gorm:"index;default:0;" json:"model_id"` // 模型id + Main *string `gorm:"default:'';" json:"main"` // + Second *string `gorm:"default:'';" json:"second"` // + Base *string `gorm:"default:'';" json:"base"` // + Paper *string `gorm:"default:'';" json:"paper"` // + Spoon *string `gorm:"default:'';" json:"spoon"` // + Fork *string `gorm:"default:'';" json:"fork"` // + Toothpick *string `gorm:"default:'';" json:"toothpick"` // + Chopsticks *string `gorm:"default:'';" json:"chopsticks"` // + Shadow *string `gorm:"default:'';" json:"shadow"` // + Cover *string `gorm:"default:'';" json:"cover"` // + Cover1 *string `gorm:"default:'';" json:"cover1"` // + Mode *string `gorm:"default:'';" json:"mode"` // + Light *int64 `gorm:"default:0;" json:"light"` // + Rotation *string `gorm:"default:'';" json:"rotation"` // + Scale *string `gorm:"default:'';" json:"scale"` // + ModelP *string `gorm:"default:'';" json:"model_p"` // 配件对应的云渲染贴图数据 + Refletion *string `gorm:"default:'';" json:"refletion"` // 反射探头组 } type FsProductTemplateElementModel struct { db *gorm.DB diff --git a/model/gmodel/fs_product_template_element_logic.go b/model/gmodel/fs_product_template_element_logic.go index 783f5480..5ace306f 100644 --- a/model/gmodel/fs_product_template_element_logic.go +++ b/model/gmodel/fs_product_template_element_logic.go @@ -7,7 +7,7 @@ import "context" func (e *FsProductTemplateElementModel) FindOneByModelId(ctx context.Context, modelId int64) (resp *FsProductTemplateElement, err error) { err = e.db.WithContext(ctx).Model(&FsProductTemplateElement{}). //以前的神仙员工把表model_id变成product_template_id - Where("`product_template_id` = ?", modelId). + Where("`model_id` = ?", modelId). Take(&resp).Error return resp, err } From c1fddf2a14121e3c80f17708d4209d595e0f6795 Mon Sep 17 00:00:00 2001 From: Hiven Date: Thu, 17 Aug 2023 12:14:19 +0800 Subject: [PATCH 097/151] =?UTF-8?q?fix:=E4=B8=8A=E4=BC=A0=E6=A8=A1?= =?UTF-8?q?=E5=9D=97=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/upload/internal/logic/uploadlogologic.go | 1 + 1 file changed, 1 insertion(+) diff --git a/server/upload/internal/logic/uploadlogologic.go b/server/upload/internal/logic/uploadlogologic.go index 074c3d3f..0019177a 100644 --- a/server/upload/internal/logic/uploadlogologic.go +++ b/server/upload/internal/logic/uploadlogologic.go @@ -88,6 +88,7 @@ func (l *UploadLogoLogic) UploadLogo(req *types.UploadLogoReq, userinfo *auth.Us imageTypes["image/tiff"] = struct{}{} imageTypes["image/webp"] = struct{}{} imageTypes["image/svg+xml"] = struct{}{} + // 判断文件类型是否为图片 _, ok := imageTypes[fileType] if !ok { From d59131af4b0af602e8b02726b3a62b9aec71f7d3 Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Thu, 17 Aug 2023 12:14:38 +0800 Subject: [PATCH 098/151] fix --- .../websocket/internal/logic/rendernotifylogic.go | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/server/websocket/internal/logic/rendernotifylogic.go b/server/websocket/internal/logic/rendernotifylogic.go index 3ad4e9b2..58b9ffeb 100644 --- a/server/websocket/internal/logic/rendernotifylogic.go +++ b/server/websocket/internal/logic/rendernotifylogic.go @@ -6,6 +6,7 @@ import ( "fusenapi/utils/basic" "fusenapi/utils/file" "fusenapi/utils/websocket_data" + "time" "context" @@ -89,14 +90,20 @@ func (l *RenderNotifyLogic) RenderNotify(req *types.RenderNotifyReq, userinfo *a RenderId: renderId, Image: uploadRes.ResourceUrl, }) - //删除对应的需要渲染的图片map - ws.renderProperty.renderImageTaskCtlChan <- renderImageControlChanItem{ + deleteTask := renderImageControlChanItem{ Option: 0, //0删除 1添加 TaskId: req.TaskId, RenderId: renderId, } - //发送数据到out chan - ws.sendToOutChan(b) + select { + case <-ws.closeChan: //关闭了 + return true + case ws.renderProperty.renderImageTaskCtlChan <- deleteTask: //删除对应的需要渲染的图片map + //发送数据到out chan + ws.sendToOutChan(b) + case <-time.After(time.Second * 3): //超时丢弃 + return true + } return true }) logx.Info("渲染回调成功######################") From 3f9ccaeea8aab30f9fdb04b52ae5d5f8606cd59a Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Thu, 17 Aug 2023 14:03:52 +0800 Subject: [PATCH 099/151] fix --- model/gmodel/fs_product_template_v2_logic.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/model/gmodel/fs_product_template_v2_logic.go b/model/gmodel/fs_product_template_v2_logic.go index 8ae2897d..94c99826 100755 --- a/model/gmodel/fs_product_template_v2_logic.go +++ b/model/gmodel/fs_product_template_v2_logic.go @@ -113,7 +113,7 @@ func (t *FsProductTemplateV2Model) GetProductTemplateListByParams(ctx context.Co // 获取第一个尺寸下的模板 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"). + Joins("inner join fs_product_size as s on t.product_id = s.product_id"). Select("t.*"). Where("t.product_id = ? and t.template_tag = ? ", productId, templateTag). Where("t.status = ? and t.is_del = ?", 1, 0). From ddfed4a2ef900038fc333b527d2c35a99e9fd074 Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Thu, 17 Aug 2023 14:11:11 +0800 Subject: [PATCH 100/151] fix --- model/gmodel/fs_product_template_v2_logic.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/model/gmodel/fs_product_template_v2_logic.go b/model/gmodel/fs_product_template_v2_logic.go index 94c99826..388041a0 100755 --- a/model/gmodel/fs_product_template_v2_logic.go +++ b/model/gmodel/fs_product_template_v2_logic.go @@ -118,7 +118,7 @@ func (t *FsProductTemplateV2Model) FindOneByProductIdTagIdWithSizeTable(ctx cont Where("t.product_id = ? and t.template_tag = ? ", productId, templateTag). Where("t.status = ? and t.is_del = ?", 1, 0). Where("s.status = ?", 1). - Order("s.sort ASC"). + Order("t.sort ASC,s.sort ASC"). Take(&resp).Error return resp, err } From 05f61fc8b26881c020efd45b7e92bd2ca24f1c1f Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Thu, 17 Aug 2023 14:48:27 +0800 Subject: [PATCH 101/151] fix --- server/websocket/internal/logic/ws_render_image_logic.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/server/websocket/internal/logic/ws_render_image_logic.go b/server/websocket/internal/logic/ws_render_image_logic.go index 6d8601c1..ca9055c8 100644 --- a/server/websocket/internal/logic/ws_render_image_logic.go +++ b/server/websocket/internal/logic/ws_render_image_logic.go @@ -207,6 +207,9 @@ func (w *wsConnectItem) assembleRenderData(taskId string, info websocket_data.Re refletion := -1 if element.Refletion != nil && *element.Refletion != "" { refletion, err = strconv.Atoi(*element.Refletion) + if err != nil { + logx.Error("err refletion:set default -1") + } } //组装data数据 var mode map[string]interface{} From 666147cfe65420652df87e50a57af95faae4d971 Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Thu, 17 Aug 2023 15:11:32 +0800 Subject: [PATCH 102/151] fix --- .../product/internal/logic/gettagproductlistlogic.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/server/product/internal/logic/gettagproductlistlogic.go b/server/product/internal/logic/gettagproductlistlogic.go index 0ebb5196..253c6e3c 100644 --- a/server/product/internal/logic/gettagproductlistlogic.go +++ b/server/product/internal/logic/gettagproductlistlogic.go @@ -209,9 +209,11 @@ func (l *GetTagProductListLogic) GetTagProductList(req *types.GetTagProductListR logx.Error(err) return resp.SetStatusAddMessage(basic.CodeServiceErr, "failed to deal with tag data") } + //组装等级从属关系 + rspTagList, TotalCategoryProduct := l.organizationLevelRelation(minLevel, mapTagLevel) return resp.SetStatusWithMessage(basic.CodeOK, "success", types.GetTagProductListRsp{ - TotalCategoryProduct: len(productList), - TagList: l.organizationLevelRelation(minLevel, mapTagLevel), //组装等级从属关系 + TotalCategoryProduct: TotalCategoryProduct, + TagList: rspTagList, }) } @@ -274,7 +276,7 @@ func (l *GetTagProductListLogic) dealWithTagMenuData(req dealWithTagMenuDataReq) } // 组织等级从属关系 -func (l *GetTagProductListLogic) organizationLevelRelation(minLevel int, mapTagLevel map[string]*types.TagItem) []types.TagItem { +func (l *GetTagProductListLogic) organizationLevelRelation(minLevel int, mapTagLevel map[string]*types.TagItem) (rspTagList []types.TagItem, productCount int) { mapTop := make(map[string]struct{}) //设置归属关系 for prefix, tagItem := range mapTagLevel { @@ -316,13 +318,14 @@ func (l *GetTagProductListLogic) organizationLevelRelation(minLevel int, mapTagL if len(mapTagLevel[prefix].TagProductList) == 0 { continue } + productCount += len(mapTagLevel[prefix].TagProductList) rspList = append(rspList, *mapTagLevel[prefix]) } //排序 sort.SliceStable(rspList, func(i, j int) bool { return rspList[i].Sort < rspList[j].Sort }) - return rspList + return rspList, productCount } // 获取对应tag的产品列表 From 6fdc784a9d684fc0159ac676a6ca022960b2055d Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Thu, 17 Aug 2023 15:22:09 +0800 Subject: [PATCH 103/151] fix --- server/websocket/internal/logic/datatransferlogic.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/server/websocket/internal/logic/datatransferlogic.go b/server/websocket/internal/logic/datatransferlogic.go index 8d6e2188..a422e928 100644 --- a/server/websocket/internal/logic/datatransferlogic.go +++ b/server/websocket/internal/logic/datatransferlogic.go @@ -106,9 +106,8 @@ func (l *DataTransferLogic) DataTransfer(w http.ResponseWriter, r *http.Request) _ = conn.WriteMessage(websocket.CloseMessage, nil) return }*/ - //测试的目前写死 39 + // todo user信息是没有的 var userInfo auth.UserInfo - userInfo.UserId = 39 //设置连接 ws := l.setConnPool(conn, userInfo) defer ws.close() From 76fecbde7edf8deedd982a3ec0e7c53a47f45ca5 Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Thu, 17 Aug 2023 15:29:54 +0800 Subject: [PATCH 104/151] fix --- server/websocket/internal/logic/ws_render_image_logic.go | 6 ------ 1 file changed, 6 deletions(-) diff --git a/server/websocket/internal/logic/ws_render_image_logic.go b/server/websocket/internal/logic/ws_render_image_logic.go index ca9055c8..e4858c1d 100644 --- a/server/websocket/internal/logic/ws_render_image_logic.go +++ b/server/websocket/internal/logic/ws_render_image_logic.go @@ -191,12 +191,6 @@ func (w *wsConnectItem) assembleRenderData(taskId string, info websocket_data.Re element, err := w.logic.svcCtx.AllModels.FsProductTemplateElement.FindOneByModelId(w.logic.ctx, *productTemplate.ModelId) if err != nil { if errors.Is(err, gorm.ErrRecordNotFound) { - // todo 没有图就给他返回一张默认(后面要删除) - defaultImg := w.respondDataFormat(constants.WEBSOCKET_RENDER_IMAGE, websocket_data.RenderImageRspMsg{ - RenderId: info.RenderId, - Image: "https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/695463af6e9b93c003db39ddf728241f9523efc55b20dc37f30fe5d96ed54fb5", - }) - w.sendToOutChan(defaultImg) logx.Error("element info is not found,model_id = ", *productTemplate.ModelId) return err } From 3b757b0dab96d6642ee07bf6c3f68bcd8dec8cfd Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Thu, 17 Aug 2023 15:35:17 +0800 Subject: [PATCH 105/151] fix --- server/websocket/internal/logic/ws_render_image_logic.go | 3 ++- 1 file changed, 2 insertions(+), 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 e4858c1d..7671c187 100644 --- a/server/websocket/internal/logic/ws_render_image_logic.go +++ b/server/websocket/internal/logic/ws_render_image_logic.go @@ -68,7 +68,6 @@ func (w *wsConnectItem) consumeRenderCache(data []byte) { logx.Error("invalid format of websocket render image message", err) return } - logx.Info("收到请求云渲染图片数据:", renderImageData) if renderImageData.RenderId == "" { 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") @@ -84,6 +83,7 @@ func (w *wsConnectItem) consumeRenderCache(data []byte) { logx.Error("invalid format of websocket render image message:template_tag") return } + logx.Info("##########################begin##############################") //获取上传最近的logo userMaterial, err := w.logic.svcCtx.AllModels.FsUserMaterial.FindLatestOne(w.logic.ctx, w.userId, w.guestId) if err != nil { @@ -107,6 +107,7 @@ func (w *wsConnectItem) consumeRenderCache(data []byte) { } else { renderImageData.RenderData.Logo = *userMaterial.ResourceUrl } + logx.Info("##########################end##############################") //用户id赋值 renderImageData.RenderData.UserId = w.userId renderImageData.RenderData.GuestId = w.guestId From 200680f85fcadf10f0008f5cc02e191ce6132b2f Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Thu, 17 Aug 2023 15:39:37 +0800 Subject: [PATCH 106/151] fix --- server/websocket/internal/logic/ws_render_image_logic.go | 1 + 1 file changed, 1 insertion(+) diff --git a/server/websocket/internal/logic/ws_render_image_logic.go b/server/websocket/internal/logic/ws_render_image_logic.go index 7671c187..b879989e 100644 --- a/server/websocket/internal/logic/ws_render_image_logic.go +++ b/server/websocket/internal/logic/ws_render_image_logic.go @@ -103,6 +103,7 @@ func (w *wsConnectItem) consumeRenderCache(data []byte) { w.sendToOutChan(w.respondDataFormat(constants.WEBSOCKET_ERR_DATA_FORMAT, "failed to get default logo")) return } + logx.Info("素材:", userMaterialDefault.ResourceUrl) renderImageData.RenderData.Logo = *userMaterialDefault.ResourceUrl } else { renderImageData.RenderData.Logo = *userMaterial.ResourceUrl From 5bde276c6ddb6c62bb29a23dd124338554b588bf Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Thu, 17 Aug 2023 15:41:54 +0800 Subject: [PATCH 107/151] 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 b879989e..80b22ab0 100644 --- a/server/websocket/internal/logic/ws_render_image_logic.go +++ b/server/websocket/internal/logic/ws_render_image_logic.go @@ -103,7 +103,7 @@ func (w *wsConnectItem) consumeRenderCache(data []byte) { w.sendToOutChan(w.respondDataFormat(constants.WEBSOCKET_ERR_DATA_FORMAT, "failed to get default logo")) return } - logx.Info("素材:", userMaterialDefault.ResourceUrl) + logx.Info("素材:", userMaterialDefault) renderImageData.RenderData.Logo = *userMaterialDefault.ResourceUrl } else { renderImageData.RenderData.Logo = *userMaterial.ResourceUrl From 784d8f2624c292d60ba4becb89e88e37baa2f0a9 Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Thu, 17 Aug 2023 15:54:03 +0800 Subject: [PATCH 108/151] fix --- model/gmodel/fs_user_material_logic.go | 3 --- server/websocket/internal/logic/ws_render_image_logic.go | 4 +--- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/model/gmodel/fs_user_material_logic.go b/model/gmodel/fs_user_material_logic.go index c500f71e..842a458e 100644 --- a/model/gmodel/fs_user_material_logic.go +++ b/model/gmodel/fs_user_material_logic.go @@ -58,9 +58,6 @@ func (m *FsUserMaterialModel) RowSelectBuilder(selectData []string) *gorm.DB { // 获取最新记录 func (m *FsUserMaterialModel) FindLatestOne(ctx context.Context, userId int64, guestId int64) (resp FsUserMaterial, err error) { - if userId == 0 && guestId == 0 { - return FsUserMaterial{}, nil - } db := m.db.WithContext(ctx).Model(&FsUserMaterial{}). Where("`user_id` = ? and `guest_id` = ?", userId, guestId). Order("id DESC") diff --git a/server/websocket/internal/logic/ws_render_image_logic.go b/server/websocket/internal/logic/ws_render_image_logic.go index 80b22ab0..9b555e9b 100644 --- a/server/websocket/internal/logic/ws_render_image_logic.go +++ b/server/websocket/internal/logic/ws_render_image_logic.go @@ -4,6 +4,7 @@ import ( "bytes" "encoding/json" "errors" + "fmt" "fusenapi/constants" "fusenapi/service/repositories" "fusenapi/utils/curl" @@ -83,7 +84,6 @@ func (w *wsConnectItem) consumeRenderCache(data []byte) { logx.Error("invalid format of websocket render image message:template_tag") return } - logx.Info("##########################begin##############################") //获取上传最近的logo userMaterial, err := w.logic.svcCtx.AllModels.FsUserMaterial.FindLatestOne(w.logic.ctx, w.userId, w.guestId) if err != nil { @@ -103,12 +103,10 @@ func (w *wsConnectItem) consumeRenderCache(data []byte) { w.sendToOutChan(w.respondDataFormat(constants.WEBSOCKET_ERR_DATA_FORMAT, "failed to get default logo")) return } - logx.Info("素材:", userMaterialDefault) renderImageData.RenderData.Logo = *userMaterialDefault.ResourceUrl } else { renderImageData.RenderData.Logo = *userMaterial.ResourceUrl } - logx.Info("##########################end##############################") //用户id赋值 renderImageData.RenderData.UserId = w.userId renderImageData.RenderData.GuestId = w.guestId From 1c2ab8c645fe5c7507534ff41bbf259e371ec9c0 Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Thu, 17 Aug 2023 15:54:21 +0800 Subject: [PATCH 109/151] fix --- server/websocket/internal/logic/ws_render_image_logic.go | 1 - 1 file changed, 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 9b555e9b..9ce08701 100644 --- a/server/websocket/internal/logic/ws_render_image_logic.go +++ b/server/websocket/internal/logic/ws_render_image_logic.go @@ -4,7 +4,6 @@ import ( "bytes" "encoding/json" "errors" - "fmt" "fusenapi/constants" "fusenapi/service/repositories" "fusenapi/utils/curl" From 17556690ed6fcbfdf7efa378c75acb72d9861c9b Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Thu, 17 Aug 2023 16:07:27 +0800 Subject: [PATCH 110/151] 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 9ce08701..62c9d218 100644 --- a/server/websocket/internal/logic/ws_render_image_logic.go +++ b/server/websocket/internal/logic/ws_render_image_logic.go @@ -267,7 +267,7 @@ func (w *wsConnectItem) assembleRenderData(taskId string, info websocket_data.Re "folder": "", //todo 千人千面需要使用 } //请求unity接口 - url := "http://api.fusen.3718.cn:4050/api/render/queue/push" + url := w.logic.svcCtx.Config.Unity.Host + "/api/render/queue/push" header := make(map[string]string) header["content-type"] = "application/json" t := time.Now().UTC() From 6dba8507a7bd3f8899d3f691676fc699ed2d6ce0 Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Thu, 17 Aug 2023 16:11:09 +0800 Subject: [PATCH 111/151] fix --- server/websocket/internal/logic/rendernotifylogic.go | 1 + 1 file changed, 1 insertion(+) diff --git a/server/websocket/internal/logic/rendernotifylogic.go b/server/websocket/internal/logic/rendernotifylogic.go index 58b9ffeb..c05db381 100644 --- a/server/websocket/internal/logic/rendernotifylogic.go +++ b/server/websocket/internal/logic/rendernotifylogic.go @@ -40,6 +40,7 @@ func NewRenderNotifyLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Rend // } func (l *RenderNotifyLogic) RenderNotify(req *types.RenderNotifyReq, userinfo *auth.UserInfo) (resp *basic.Response) { + logx.Info("收到渲染回调数据:", *req) if req.TaskId == "" { return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "invalid param task_id") } From cda5c69f4ff5d589b87a1ca1a873dd66527996b3 Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Thu, 17 Aug 2023 16:16:27 +0800 Subject: [PATCH 112/151] fix --- server/websocket/internal/logic/rendernotifylogic.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/server/websocket/internal/logic/rendernotifylogic.go b/server/websocket/internal/logic/rendernotifylogic.go index c05db381..afa76e64 100644 --- a/server/websocket/internal/logic/rendernotifylogic.go +++ b/server/websocket/internal/logic/rendernotifylogic.go @@ -40,14 +40,16 @@ func NewRenderNotifyLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Rend // } func (l *RenderNotifyLogic) RenderNotify(req *types.RenderNotifyReq, userinfo *auth.UserInfo) (resp *basic.Response) { - logx.Info("收到渲染回调数据:", *req) if req.TaskId == "" { + logx.Error("渲染回调参数错误:invalid param task_id") return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "invalid param task_id") } if req.Image == "" { + logx.Error("渲染回调参数错误:invalid param image") return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "invalid param image") } if req.UserId == 0 && req.GuestId == 0 { + logx.Error("渲染回调参数错误:invalid user_id or guest_id") return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "invalid user_id or guest_id") } // 上传文件 @@ -68,7 +70,7 @@ func (l *RenderNotifyLogic) RenderNotify(req *types.RenderNotifyReq, userinfo *a FileByte: nil, }) if err != nil { - logx.Error(err) + logx.Error("渲染回调上传文件失败:", err) return resp.SetStatusWithMessage(basic.CodeFileUploadErr, "failed to upload render resource image") } //遍历websocket链接把数据传进去 @@ -76,6 +78,7 @@ func (l *RenderNotifyLogic) RenderNotify(req *types.RenderNotifyReq, userinfo *a //断言连接 ws, ok := value.(wsConnectItem) if !ok { + logx.Error("渲染回调断言websocket连接失败") return true } //关闭标识 @@ -102,10 +105,10 @@ func (l *RenderNotifyLogic) RenderNotify(req *types.RenderNotifyReq, userinfo *a case ws.renderProperty.renderImageTaskCtlChan <- deleteTask: //删除对应的需要渲染的图片map //发送数据到out chan ws.sendToOutChan(b) + return true case <-time.After(time.Second * 3): //超时丢弃 return true } - return true }) logx.Info("渲染回调成功######################") return resp.SetStatusWithMessage(basic.CodeOK, "success") From 509e82db6315cfa883e3a5151ba4f59a0f2875c7 Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Thu, 17 Aug 2023 16:17:25 +0800 Subject: [PATCH 113/151] fix --- server/websocket/internal/logic/rendernotifylogic.go | 4 ---- 1 file changed, 4 deletions(-) diff --git a/server/websocket/internal/logic/rendernotifylogic.go b/server/websocket/internal/logic/rendernotifylogic.go index afa76e64..e14983d4 100644 --- a/server/websocket/internal/logic/rendernotifylogic.go +++ b/server/websocket/internal/logic/rendernotifylogic.go @@ -48,10 +48,6 @@ func (l *RenderNotifyLogic) RenderNotify(req *types.RenderNotifyReq, userinfo *a logx.Error("渲染回调参数错误:invalid param image") return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "invalid param image") } - if req.UserId == 0 && req.GuestId == 0 { - logx.Error("渲染回调参数错误:invalid user_id or guest_id") - return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "invalid user_id or guest_id") - } // 上传文件 var upload = file.Upload{ Ctx: l.ctx, From 5ab2bb51e28219669539250a43fba83ce1cf7192 Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Thu, 17 Aug 2023 16:22:26 +0800 Subject: [PATCH 114/151] fix --- server/websocket/internal/logic/datatransferlogic.go | 1 + 1 file changed, 1 insertion(+) diff --git a/server/websocket/internal/logic/datatransferlogic.go b/server/websocket/internal/logic/datatransferlogic.go index a422e928..fada3747 100644 --- a/server/websocket/internal/logic/datatransferlogic.go +++ b/server/websocket/internal/logic/datatransferlogic.go @@ -108,6 +108,7 @@ func (l *DataTransferLogic) DataTransfer(w http.ResponseWriter, r *http.Request) }*/ // todo user信息是没有的 var userInfo auth.UserInfo + userInfo.UserId = 39 //设置连接 ws := l.setConnPool(conn, userInfo) defer ws.close() From 7eea85e49d9161a1816c7fda7402561f93d3404f Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Thu, 17 Aug 2023 16:28:15 +0800 Subject: [PATCH 115/151] 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 62c9d218..69cac32f 100644 --- a/server/websocket/internal/logic/ws_render_image_logic.go +++ b/server/websocket/internal/logic/ws_render_image_logic.go @@ -185,7 +185,7 @@ func (w *wsConnectItem) assembleRenderData(taskId string, info websocket_data.Re logx.Error("合成刀版图失败,合成的刀版图是空指针:", err) return err } - logx.Info("合成刀版图成功:", *res.ResourceUrl) + logx.Info("合成刀版图成功,原logo:", info.RenderData.Logo, "刀版图:", *res.ResourceUrl) //获取渲染设置信息 element, err := w.logic.svcCtx.AllModels.FsProductTemplateElement.FindOneByModelId(w.logic.ctx, *productTemplate.ModelId) if err != nil { From a28fbd2aa6febfb47180fe0a6d18df117c5f74e5 Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Thu, 17 Aug 2023 16:50:44 +0800 Subject: [PATCH 116/151] fix --- server/product/internal/logic/gettagproductlistlogic.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/product/internal/logic/gettagproductlistlogic.go b/server/product/internal/logic/gettagproductlistlogic.go index 253c6e3c..6eed71ac 100644 --- a/server/product/internal/logic/gettagproductlistlogic.go +++ b/server/product/internal/logic/gettagproductlistlogic.go @@ -328,7 +328,7 @@ func (l *GetTagProductListLogic) organizationLevelRelation(minLevel int, mapTagL return rspList, productCount } -// 获取对应tag的产品列表 +// 获取某个tag的直属产品 type getTagProductsReq struct { TagId int64 ProductList []gmodel.FsProduct From 68b125f5a6115dc6453163c8239526d3a0113c5d Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Thu, 17 Aug 2023 17:05:42 +0800 Subject: [PATCH 117/151] fix --- constants/websocket.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/constants/websocket.go b/constants/websocket.go index 8a4a065c..693e7802 100644 --- a/constants/websocket.go +++ b/constants/websocket.go @@ -12,8 +12,6 @@ const ( WEBSOCKET_REQUEST_REUSE_LAST_CONNECT = "WEBSOCKET_REQUEST_REUSE_LAST_CONNECT" //请求恢复为上次连接的标识错误 WEBSOCKET_REQUEST_RESUME_LAST_CONNECT_ERR = "WEBSOCKET_REQUEST_RESUME_LAST_CONNECT_ERR" - //渲染前数据组装 - WEBSOCKET_RENDER_IMAGE_ASSEMBLE = "WEBSOCKET_RENDER_IMAGE_ASSEMBLE" //图片渲染 WEBSOCKET_RENDER_IMAGE = "WEBSOCKET_RENDER_IMAGE" //数据格式错误 From ff6167e7130574cf6d9e8fb8a1a82725453cdf86 Mon Sep 17 00:00:00 2001 From: Hiven Date: Thu, 17 Aug 2023 17:20:43 +0800 Subject: [PATCH 118/151] =?UTF-8?q?fix:=E4=B8=8A=E4=BC=A0=E6=A8=A1?= =?UTF-8?q?=E5=9D=97=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- service/repositories/image_handle.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/service/repositories/image_handle.go b/service/repositories/image_handle.go index ffacf0d2..6ff54137 100644 --- a/service/repositories/image_handle.go +++ b/service/repositories/image_handle.go @@ -197,7 +197,7 @@ func (l *defaultImageHandle) LogoCombine(ctx context.Context, in *LogoCombineReq // logo_url:"https://s3.amazon.com/xxxx", // result: "$saa541afaldjaldjasldjsadjsapsaasda" // } - var fileBase = resultData["result"] + var fileBase = resultData["result"].(string) // 上传文件 var upload = file.Upload{ @@ -208,7 +208,7 @@ func (l *defaultImageHandle) LogoCombine(ctx context.Context, in *LogoCombineReq uploadRes, err := upload.UploadFileByBase64(&file.UploadBaseReq{ Source: "combine-image", FileHash: resourceId, - FileData: fileBase.(string), + FileData: fileBase, UploadBucket: 1, ApiType: 2, UserId: in.UserId, From f892a216d6850fc02e3a8c0537dc7b678f40d2dd Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Thu, 17 Aug 2023 18:19:15 +0800 Subject: [PATCH 119/151] fix --- model/gmodel/fs_product_template_v2_logic.go | 5 ++++- .../product/internal/logic/getproductlistlogic.go | 2 +- .../internal/logic/gettagproductlistlogic.go | 14 ++++++++------ .../logic/homepagerecommendproductlistlogic.go | 2 +- server/product/internal/types/types.go | 1 + server_api/product.api | 1 + 6 files changed, 16 insertions(+), 9 deletions(-) diff --git a/model/gmodel/fs_product_template_v2_logic.go b/model/gmodel/fs_product_template_v2_logic.go index 388041a0..cfae7d32 100755 --- a/model/gmodel/fs_product_template_v2_logic.go +++ b/model/gmodel/fs_product_template_v2_logic.go @@ -4,11 +4,14 @@ import ( "context" ) -func (t *FsProductTemplateV2Model) FindAllByProductIds(ctx context.Context, productIds []int64, fields ...string) (resp []FsProductTemplateV2, err error) { +func (t *FsProductTemplateV2Model) FindAllByProductIds(ctx context.Context, productIds []int64, sort string, fields ...string) (resp []FsProductTemplateV2, err error) { if len(productIds) == 0 { return } db := t.db.WithContext(ctx).Model(&FsProductTemplateV2{}).Where("`product_id` in (?) and `is_del` = ? and `status` = ?", productIds, 0, 1) + if sort != "" { + db = db.Order(sort) + } if len(fields) != 0 { db = db.Select(fields[0]) } diff --git a/server/product/internal/logic/getproductlistlogic.go b/server/product/internal/logic/getproductlistlogic.go index f45b8418..d12bc4dd 100644 --- a/server/product/internal/logic/getproductlistlogic.go +++ b/server/product/internal/logic/getproductlistlogic.go @@ -99,7 +99,7 @@ func (l *GetProductListLogic) GetProductList(req *types.GetProductListReq, useri } //获取模板 productTemplateModel := gmodel.NewFsProductTemplateV2Model(l.svcCtx.MysqlConn) - productTemplatesV2, err := productTemplateModel.FindAllByProductIds(l.ctx, productIds) + productTemplatesV2, err := productTemplateModel.FindAllByProductIds(l.ctx, productIds, "") if err != nil { logx.Error(err) return resp.SetStatusWithMessage(basic.CodeServiceErr, "get product template_v2 err") diff --git a/server/product/internal/logic/gettagproductlistlogic.go b/server/product/internal/logic/gettagproductlistlogic.go index 6eed71ac..18a62e13 100644 --- a/server/product/internal/logic/gettagproductlistlogic.go +++ b/server/product/internal/logic/gettagproductlistlogic.go @@ -90,7 +90,7 @@ func (l *GetTagProductListLogic) GetTagProductList(req *types.GetTagProductListR productTemplatesV2 []gmodel.FsProductTemplateV2 //产品模板列表(select 字段需要看查询的地方) productSizeCountList []gmodel.CountProductSizeByStatusRsp //产品尺寸数量列表(select 字段需要看查询的地方) mapProductSizeCount = make(map[int64]int64) //产品尺寸数量map - mapProductTemplate = make(map[int64]struct{}) //产品模板map + mapProductTemplate = make(map[int64]int64) //产品模板map ) //携带产品 if req.WithProduct { @@ -170,13 +170,14 @@ func (l *GetTagProductListLogic) GetTagProductList(req *types.GetTagProductListR } } //获取模板(只是获取产品product_id) - productTemplatesV2, err = l.svcCtx.AllModels.FsProductTemplateV2.FindAllByProductIds(l.ctx, productIds, "product_id") + productTemplatesV2, err = l.svcCtx.AllModels.FsProductTemplateV2.FindAllByProductIds(l.ctx, productIds, "sort ASC", "product_id") if err != nil { logx.Error(err) return resp.SetStatusWithMessage(basic.CodeServiceErr, "get product template_v2 err") } + //只存第一个 for _, v := range productTemplatesV2 { - mapProductTemplate[*v.ProductId] = struct{}{} + mapProductTemplate[*v.ProductId] = v.Id } //获取产品尺寸数量 productSizeCountList, err = l.svcCtx.AllModels.FsProductSize.GetGroupProductSizeByStatus(l.ctx, productIds, 1) @@ -225,7 +226,7 @@ type dealWithTagMenuDataReq struct { MapTagProp map[int64][]types.CoverDefaultItem ProductTagPropList []gmodel.FsProductTagProp MapProductMinPrice map[int64]int64 - MapProductTemplate map[int64]struct{} + MapProductTemplate map[int64]int64 MapProductSizeCount map[int64]int64 MapTagLevel map[string]*types.TagItem MapProductHaveOptionFitting map[int64]struct{} @@ -334,7 +335,7 @@ type getTagProductsReq struct { ProductList []gmodel.FsProduct MapTagProp map[int64][]types.CoverDefaultItem MapProductMinPrice map[int64]int64 - MapProductTemplate map[int64]struct{} + MapProductTemplate map[int64]int64 MapProductSizeCount map[int64]int64 MapProductHaveOptionFitting map[int64]struct{} Size uint32 @@ -350,7 +351,7 @@ func (l *GetTagProductListLogic) getTagProducts(req getTagProductsReq) (productL continue } minPrice, ok := req.MapProductMinPrice[productInfo.Id] - _, tmpOk := req.MapProductTemplate[productInfo.Id] + templateId, tmpOk := req.MapProductTemplate[productInfo.Id] //无最小价格则不显示 || 没有模板也不显示 if !ok || !tmpOk { continue @@ -370,6 +371,7 @@ func (l *GetTagProductListLogic) getTagProducts(req getTagProductsReq) (productL Title: *productInfo.Title, SizeNum: uint32(sizeNum), CoverDefault: []types.CoverDefaultItem{}, + DefaultTemplateId: templateId, MinPrice: minPrice, HaveOptionalFitting: haveOptionalFitting, Recommended: *productInfo.IsRecommend > 0, diff --git a/server/product/internal/logic/homepagerecommendproductlistlogic.go b/server/product/internal/logic/homepagerecommendproductlistlogic.go index 6d449757..9c70f5ca 100644 --- a/server/product/internal/logic/homepagerecommendproductlistlogic.go +++ b/server/product/internal/logic/homepagerecommendproductlistlogic.go @@ -130,7 +130,7 @@ func (l *HomePageRecommendProductListLogic) HomePageRecommendProductList(req *ty } } //获取模板(只是获取产品product_id) - productTemplatesV2, err = l.svcCtx.AllModels.FsProductTemplateV2.FindAllByProductIds(l.ctx, productIds, "product_id") + productTemplatesV2, err = l.svcCtx.AllModels.FsProductTemplateV2.FindAllByProductIds(l.ctx, productIds, "", "product_id") if err != nil { logx.Error(err) return resp.SetStatusWithMessage(basic.CodeServiceErr, "get product template_v2 err") diff --git a/server/product/internal/types/types.go b/server/product/internal/types/types.go index 6adf44d2..ac643648 100644 --- a/server/product/internal/types/types.go +++ b/server/product/internal/types/types.go @@ -275,6 +275,7 @@ type TagProduct struct { SizeNum uint32 `json:"size_num"` MinPrice int64 `json:"min_price"` CoverDefault []CoverDefaultItem `json:"cover_default"` + DefaultTemplateId int64 `json:"default_template_id"` HaveOptionalFitting bool `json:"have_optional_fitting"` Recommended bool `json:"recommended"` } diff --git a/server_api/product.api b/server_api/product.api index 9e8626c5..abc24c02 100644 --- a/server_api/product.api +++ b/server_api/product.api @@ -325,6 +325,7 @@ type TagProduct { MinPrice int64 `json:"min_price"` //彩膜列表 CoverDefault []CoverDefaultItem `json:"cover_default"` + DefaultTemplateId int64 `json:"default_template_id"` HaveOptionalFitting bool `json:"have_optional_fitting"` Recommended bool `json:"recommended"` } From d760f4e28c448d6d388e0e96f808ee61ec953251 Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Thu, 17 Aug 2023 18:22:00 +0800 Subject: [PATCH 120/151] fix --- server/product/internal/logic/gettagproductlistlogic.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/product/internal/logic/gettagproductlistlogic.go b/server/product/internal/logic/gettagproductlistlogic.go index 18a62e13..e406d72e 100644 --- a/server/product/internal/logic/gettagproductlistlogic.go +++ b/server/product/internal/logic/gettagproductlistlogic.go @@ -170,7 +170,7 @@ func (l *GetTagProductListLogic) GetTagProductList(req *types.GetTagProductListR } } //获取模板(只是获取产品product_id) - productTemplatesV2, err = l.svcCtx.AllModels.FsProductTemplateV2.FindAllByProductIds(l.ctx, productIds, "sort ASC", "product_id") + productTemplatesV2, err = l.svcCtx.AllModels.FsProductTemplateV2.FindAllByProductIds(l.ctx, productIds, "sort ASC", "product_id,id") if err != nil { logx.Error(err) return resp.SetStatusWithMessage(basic.CodeServiceErr, "get product template_v2 err") From 430cd22dc30a3660df329a94757f54fb669e7370 Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Thu, 17 Aug 2023 18:22:09 +0800 Subject: [PATCH 121/151] fix --- server/product/internal/logic/gettagproductlistlogic.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/product/internal/logic/gettagproductlistlogic.go b/server/product/internal/logic/gettagproductlistlogic.go index e406d72e..8d51e6fa 100644 --- a/server/product/internal/logic/gettagproductlistlogic.go +++ b/server/product/internal/logic/gettagproductlistlogic.go @@ -169,7 +169,7 @@ func (l *GetTagProductListLogic) GetTagProductList(req *types.GetTagProductListR mapProductMinPrice[v.ProductId] = int64(priceSlice[0]) } } - //获取模板(只是获取产品product_id) + //获取模板(只是获取产品product_id,id) productTemplatesV2, err = l.svcCtx.AllModels.FsProductTemplateV2.FindAllByProductIds(l.ctx, productIds, "sort ASC", "product_id,id") if err != nil { logx.Error(err) From 37d32a26ab5381adf170eb3a28a16f2c07aa4e9a Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Fri, 18 Aug 2023 10:26:33 +0800 Subject: [PATCH 122/151] fix --- .../internal/logic/gettemplatebypidlogic.go | 15 +++------------ server/product/internal/types/types.go | 6 +++--- server_api/product.api | 6 +++--- 3 files changed, 9 insertions(+), 18 deletions(-) diff --git a/server/product/internal/logic/gettemplatebypidlogic.go b/server/product/internal/logic/gettemplatebypidlogic.go index 7612c61c..e0d46ac3 100644 --- a/server/product/internal/logic/gettemplatebypidlogic.go +++ b/server/product/internal/logic/gettemplatebypidlogic.go @@ -37,8 +37,8 @@ func (l *GetTemplateByPidLogic) GetTemplateByPid(req *types.GetTemplateByPidReq, if req.Pid == "" { return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "err param:pid is empty") } - if req.ProductTemplateTagId <= 0 { - return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "err param:product_template_tag_id") + if req.TemplateTag == "" { + return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "err param:template_tag") } //获取产品信息(只获取id) productInfo, err := l.svcCtx.AllModels.FsProduct.FindOneBySn(l.ctx, req.Pid, "id") @@ -67,15 +67,6 @@ func (l *GetTemplateByPidLogic) GetTemplateByPid(req *types.GetTemplateByPidReq, } else { //指定物料 sizeIds = append(sizeIds, req.ProductSizeId) } - //获取templatetag信息 - templateTagInfo, err := l.svcCtx.AllModels.FsProductTemplateTags.FindOne(l.ctx, req.ProductTemplateTagId) - if err != nil { - if errors.Is(err, gorm.ErrRecordNotFound) { - return resp.SetStatusWithMessage(basic.CodeDbRecordNotFoundErr, "template tag is not exists") - } - logx.Error(err) - return resp.SetStatusWithMessage(basic.CodeDbRecordNotFoundErr, "failed to get template tag") - } //根据尺寸id获取模型 modelList, err := l.svcCtx.AllModels.FsProductModel3d.GetAllBySizeIdsTag(l.ctx, sizeIds, constants.TAG_MODEL) if err != nil { @@ -92,7 +83,7 @@ func (l *GetTemplateByPidLogic) GetTemplateByPid(req *types.GetTemplateByPidReq, mapModel[v.Id] = k } //查询模型ids下对应tag标签的模板 - templateList, err := l.svcCtx.AllModels.FsProductTemplateV2.FindAllByModelIdsTemplateTag(l.ctx, modelIds, *templateTagInfo.TemplateTag, "") + templateList, err := l.svcCtx.AllModels.FsProductTemplateV2.FindAllByModelIdsTemplateTag(l.ctx, modelIds, req.TemplateTag, "") if err != nil { logx.Error(err) return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get template list") diff --git a/server/product/internal/types/types.go b/server/product/internal/types/types.go index ac643648..7d511c6e 100644 --- a/server/product/internal/types/types.go +++ b/server/product/internal/types/types.go @@ -341,9 +341,9 @@ type GetSizeByPidRsp struct { } type GetTemplateByPidReq struct { - Pid string `form:"pid"` - ProductSizeId int64 `form:"product_size_id,optional"` - ProductTemplateTagId int64 `form:"product_template_tag_id"` + Pid string `form:"pid"` + ProductSizeId int64 `form:"product_size_id,optional"` + TemplateTag string `form:"template_tag"` } type GetFittingByPidReq struct { diff --git a/server_api/product.api b/server_api/product.api index abc24c02..8a6fdbf8 100644 --- a/server_api/product.api +++ b/server_api/product.api @@ -386,9 +386,9 @@ type GetSizeByPidRsp { } //获取产品模板 type GetTemplateByPidReq { - Pid string `form:"pid"` - ProductSizeId int64 `form:"product_size_id,optional"` - ProductTemplateTagId int64 `form:"product_template_tag_id"` + Pid string `form:"pid"` + ProductSizeId int64 `form:"product_size_id,optional"` + TemplateTag string `form:"template_tag"` } //获取产品配件数据 type GetFittingByPidReq { From 530d711f750a1481dfbecb0bf64a47a45043bec1 Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Fri, 18 Aug 2023 11:05:18 +0800 Subject: [PATCH 123/151] fix --- .../internal/logic/ws_reuse_last_connect.go | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/server/websocket/internal/logic/ws_reuse_last_connect.go b/server/websocket/internal/logic/ws_reuse_last_connect.go index ea8c75f1..8d591a98 100644 --- a/server/websocket/internal/logic/ws_reuse_last_connect.go +++ b/server/websocket/internal/logic/ws_reuse_last_connect.go @@ -36,10 +36,23 @@ func (w *wsConnectItem) reuseLastConnect(data []byte) { 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 + if v, ok := mapConnPool.Load(clientId); ok { + obj, ok := v.(wsConnectItem) + if !ok { + logx.Error("连接断言失败") + } + //是当前自己占用 + if obj.uniqueId == w.uniqueId { + //重新绑定 + w.uniqueId = clientId + rsp := w.respondDataFormat(constants.WEBSOCKET_CONNECT_SUCCESS, clientId) + w.sendToOutChan(rsp) + return + } else { + rsp := w.respondDataFormat(constants.WEBSOCKET_REQUEST_RESUME_LAST_CONNECT_ERR, "id has bound by other connect ") + w.sendToOutChan(rsp) + return + } } //重新绑定 w.uniqueId = clientId From f519e27719d90da1f3f228e6a58d032e15fa871b Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Fri, 18 Aug 2023 11:41:36 +0800 Subject: [PATCH 124/151] fix --- model/gmodel/fs_auth_item_gen.go | 6 +- model/gmodel/fs_auth_rule_gen.go | 4 +- model/gmodel/fs_canteen_product_gen.go | 18 +- model/gmodel/fs_cart_gen.go | 4 +- model/gmodel/fs_cloud_render_log_gen.go | 1 - model/gmodel/fs_contact_gen.go | 4 +- model/gmodel/fs_contact_service_gen.go | 4 +- model/gmodel/fs_email_template_gen.go | 4 +- model/gmodel/fs_faq_gen.go | 2 +- model/gmodel/fs_gerent_gen.go | 4 +- model/gmodel/fs_logo_cartoon_gen.go | 29 ++ model/gmodel/fs_logo_cartoon_logic.go | 2 + model/gmodel/fs_merchant_category_gen.go | 2 +- model/gmodel/fs_order_detail_gen.go | 2 +- model/gmodel/fs_order_detail_template_gen.go | 2 +- model/gmodel/fs_order_gen.go | 16 +- model/gmodel/fs_product_design_gather_gen.go | 7 +- model/gmodel/fs_product_design_gen.go | 1 + model/gmodel/fs_product_gen.go | 6 +- model/gmodel/fs_product_model3d_gen.go | 2 +- model/gmodel/fs_product_model3d_light_gen.go | 2 +- model/gmodel/fs_product_render_design_gen.go | 7 +- model/gmodel/fs_product_size_gen.go | 8 +- .../fs_product_template_element_0826_gen.go | 35 ++ .../fs_product_template_element_0826_logic.go | 2 + .../fs_product_template_element_22_gen.go | 25 ++ .../fs_product_template_element_22_logic.go | 2 + ...product_template_element_backup1018_gen.go | 37 ++ ...oduct_template_element_backup1018_logic.go | 2 + .../gmodel/fs_product_template_element_gen.go | 40 +- .../fs_product_template_element_kongde_gen.go | 35 ++ ...s_product_template_element_kongde_logic.go | 2 + model/gmodel/fs_product_template_tags_gen.go | 2 +- model/gmodel/fs_product_template_v2_gen.go | 16 +- model/gmodel/fs_qrcode_log_gen.go | 4 +- model/gmodel/fs_quotation_gen.go | 1 - model/gmodel/fs_quotation_price_gen.go | 23 ++ model/gmodel/fs_quotation_price_logic.go | 2 + model/gmodel/fs_quotation_product_gen.go | 31 +- model/gmodel/fs_quotation_size_layout_gen.go | 22 + .../gmodel/fs_quotation_size_layout_logic.go | 2 + model/gmodel/fs_resource_gen.go | 2 +- model/gmodel/fs_trade_gen.go | 8 +- model/gmodel/fs_user_design_gen.go | 4 +- model/gmodel/fs_user_gen.go | 10 +- model/gmodel/var_gen.go | 378 +++++++++--------- .../internal/logic/getfittingbypidlogic.go | 2 +- 47 files changed, 532 insertions(+), 292 deletions(-) create mode 100644 model/gmodel/fs_logo_cartoon_gen.go create mode 100644 model/gmodel/fs_logo_cartoon_logic.go create mode 100644 model/gmodel/fs_product_template_element_0826_gen.go create mode 100644 model/gmodel/fs_product_template_element_0826_logic.go create mode 100644 model/gmodel/fs_product_template_element_22_gen.go create mode 100644 model/gmodel/fs_product_template_element_22_logic.go create mode 100644 model/gmodel/fs_product_template_element_backup1018_gen.go create mode 100644 model/gmodel/fs_product_template_element_backup1018_logic.go create mode 100644 model/gmodel/fs_product_template_element_kongde_gen.go create mode 100644 model/gmodel/fs_product_template_element_kongde_logic.go create mode 100644 model/gmodel/fs_quotation_price_gen.go create mode 100644 model/gmodel/fs_quotation_price_logic.go create mode 100644 model/gmodel/fs_quotation_size_layout_gen.go create mode 100644 model/gmodel/fs_quotation_size_layout_logic.go diff --git a/model/gmodel/fs_auth_item_gen.go b/model/gmodel/fs_auth_item_gen.go index db2acb41..bca33e90 100644 --- a/model/gmodel/fs_auth_item_gen.go +++ b/model/gmodel/fs_auth_item_gen.go @@ -9,10 +9,10 @@ type FsAuthItem struct { Name string `gorm:"primary_key;default:'';" json:"name"` // 角色或权限名称 Type *int64 `gorm:"index;default:0;" json:"type"` // 权限类型:1 表示角色,2 表示权限 Description *string `gorm:"default:'';" json:"description"` // 角色或权限描述 - RuleName *string `gorm:"index;default:'';" json:"rule_name"` // + RuleName *string `gorm:"index;default:'';" json:"rule_name"` // 规则名称 Data *[]byte `gorm:"default:'';" json:"data"` // 角色或权限的额外数据 - CreatedAt *int64 `gorm:"default:0;" json:"created_at"` // - UpdatedAt *int64 `gorm:"default:0;" json:"updated_at"` // + CreatedAt *int64 `gorm:"default:0;" json:"created_at"` // 创建时间 + UpdatedAt *int64 `gorm:"default:0;" json:"updated_at"` // 更新时间 // FsAuthItemIbfk1 foreign `gorm:"" json:"fs_auth_item_ibfk_1"`// } type FsAuthItemModel struct { diff --git a/model/gmodel/fs_auth_rule_gen.go b/model/gmodel/fs_auth_rule_gen.go index c157140f..04808613 100644 --- a/model/gmodel/fs_auth_rule_gen.go +++ b/model/gmodel/fs_auth_rule_gen.go @@ -8,8 +8,8 @@ import ( type FsAuthRule struct { Name string `gorm:"primary_key;default:'';" json:"name"` // 规则名称 Data *[]byte `gorm:"default:'';" json:"data"` // 规则的额外数据 - CreatedAt *int64 `gorm:"default:0;" json:"created_at"` // - UpdatedAt *int64 `gorm:"default:0;" json:"updated_at"` // + CreatedAt *int64 `gorm:"default:0;" json:"created_at"` // 创建时间 + UpdatedAt *int64 `gorm:"default:0;" json:"updated_at"` // 更新时间 } type FsAuthRuleModel struct { db *gorm.DB diff --git a/model/gmodel/fs_canteen_product_gen.go b/model/gmodel/fs_canteen_product_gen.go index 7c43e5b9..a31bbc32 100644 --- a/model/gmodel/fs_canteen_product_gen.go +++ b/model/gmodel/fs_canteen_product_gen.go @@ -6,14 +6,16 @@ import ( // fs_canteen_product 餐厅类别产品对应表 type FsCanteenProduct struct { - Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` // ID - CanteenType *int64 `gorm:"index;default:0;" json:"canteen_type"` // 餐厅类别id - ProductId *int64 `gorm:"default:0;" json:"product_id"` // 产品id - SizeId *int64 `gorm:"default:0;" json:"size_id"` // 尺寸id - Sort *int64 `gorm:"default:0;" json:"sort"` // 排序 - Status *int64 `gorm:"default:0;" json:"status"` // 状态位 1启用0停用 - Ctime *int64 `gorm:"default:0;" json:"ctime"` // 添加时间 - Sid *string `gorm:"default:'';" json:"sid"` // 前端带入的id + Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` // ID + CanteenType *int64 `gorm:"index;default:0;" json:"canteen_type"` // 餐厅类别id + ProductId *int64 `gorm:"default:0;" json:"product_id"` // 产品id + SizeId *int64 `gorm:"default:0;" json:"size_id"` // 尺寸id + Sort *int64 `gorm:"default:0;" json:"sort"` // 排序 + Status *int64 `gorm:"default:0;" json:"status"` // 状态位 1启用0停用 + Ctime *int64 `gorm:"default:0;" json:"ctime"` // 添加时间 + Sid *string `gorm:"default:'';" json:"sid"` // 前端带入的id + ShowSizeTips *int64 `gorm:"default:0;" json:"show_size_tips"` // 是否显示提示 + ShowSizeList *int64 `gorm:"default:0;" json:"show_size_list"` // 是否显示规格列表 } type FsCanteenProductModel struct { db *gorm.DB diff --git a/model/gmodel/fs_cart_gen.go b/model/gmodel/fs_cart_gen.go index 915a837f..1fb12d84 100644 --- a/model/gmodel/fs_cart_gen.go +++ b/model/gmodel/fs_cart_gen.go @@ -8,7 +8,7 @@ import ( // fs_cart 购物车 type FsCart struct { Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` // id - UserId *int64 `gorm:"index;default:0;" json:"user_id"` // + UserId *int64 `gorm:"index;default:0;" json:"user_id"` // 用户ID ProductId *int64 `gorm:"index;default:0;" json:"product_id"` // 产品ID TemplateId *int64 `gorm:"index;default:0;" json:"template_id"` // 模板ID PriceId *int64 `gorm:"index;default:0;" json:"price_id"` // 价格ID @@ -17,7 +17,7 @@ type FsCart struct { BuyNum *int64 `gorm:"default:0;" json:"buy_num"` // 购买数量 Cover *string `gorm:"default:'';" json:"cover"` // 截图 DesignId *int64 `gorm:"index;default:0;" json:"design_id"` // 设计ID - Ctime *int64 `gorm:"default:0;" json:"ctime"` // + Ctime *int64 `gorm:"default:0;" json:"ctime"` // 添加时间 Status *int64 `gorm:"default:0;" json:"status"` // 状态位 OptionalId *int64 `gorm:"index;default:0;" json:"optional_id"` // 选项ID IsCheck *int64 `gorm:"default:0;" json:"is_check"` // 是否选中状态(0:未选中,1:选中) diff --git a/model/gmodel/fs_cloud_render_log_gen.go b/model/gmodel/fs_cloud_render_log_gen.go index 2e851c6d..a1d8aeae 100644 --- a/model/gmodel/fs_cloud_render_log_gen.go +++ b/model/gmodel/fs_cloud_render_log_gen.go @@ -8,7 +8,6 @@ import ( type FsCloudRenderLog struct { Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` // ID UserId *int64 `gorm:"default:0;" json:"user_id"` // 用户id - GuestId *int64 `gorm:"default:0;" json:"guest_id"` // 游客id PostData *string `gorm:"default:'';" json:"post_data"` // PostUrl *string `gorm:"default:'';" json:"post_url"` // Title *string `gorm:"index;default:'';" json:"title"` // diff --git a/model/gmodel/fs_contact_gen.go b/model/gmodel/fs_contact_gen.go index 033c19a9..1e012861 100644 --- a/model/gmodel/fs_contact_gen.go +++ b/model/gmodel/fs_contact_gen.go @@ -11,8 +11,8 @@ type FsContact struct { Email *string `gorm:"index;default:'';" json:"email"` // 邮箱 Subject *int64 `gorm:"default:0;" json:"subject"` // 主题 Message *string `gorm:"default:'';" json:"message"` // 消息 - Ctime *int64 `gorm:"default:0;" json:"ctime"` // - Status *int64 `gorm:"default:0;" json:"status"` // + Ctime *int64 `gorm:"default:0;" json:"ctime"` // 添加时间 + Status *int64 `gorm:"default:0;" json:"status"` // 状态位 是否已处理 Mark *string `gorm:"default:'';" json:"mark"` // 后台订单备注 } type FsContactModel struct { diff --git a/model/gmodel/fs_contact_service_gen.go b/model/gmodel/fs_contact_service_gen.go index 578c1f7e..055ee183 100644 --- a/model/gmodel/fs_contact_service_gen.go +++ b/model/gmodel/fs_contact_service_gen.go @@ -12,10 +12,10 @@ type FsContactService struct { UserId *int64 `gorm:"index;default:0;" json:"user_id"` // 用户id Name *string `gorm:"default:'';" json:"name"` // 联系人姓名 Email *string `gorm:"index;default:'';" json:"email"` // 联系人邮箱 - Phone *string `gorm:"default:'';" json:"phone"` // + Phone *string `gorm:"default:'';" json:"phone"` // 联系人电话 Remark *string `gorm:"default:'';" json:"remark"` // 备注内容 IsHandle *int64 `gorm:"default:0;" json:"is_handle"` // 是否被处理(0:未处理,1:已处理) - Ctime *int64 `gorm:"default:0;" json:"ctime"` // + Ctime *int64 `gorm:"default:0;" json:"ctime"` // 创建时间 HandleRemark *string `gorm:"default:'';" json:"handle_remark"` // 处理备注 HandleUid *int64 `gorm:"default:0;" json:"handle_uid"` // 处理人 HandleTime *int64 `gorm:"default:0;" json:"handle_time"` // 处理时间 diff --git a/model/gmodel/fs_email_template_gen.go b/model/gmodel/fs_email_template_gen.go index 520a8e02..c4a43101 100644 --- a/model/gmodel/fs_email_template_gen.go +++ b/model/gmodel/fs_email_template_gen.go @@ -10,10 +10,10 @@ type FsEmailTemplate struct { Type *int64 `gorm:"default:0;" json:"type"` // 模板类型 Name *string `gorm:"default:'';" json:"name"` // 模板名称 Title *string `gorm:"default:'';" json:"title"` // 模板标题 - ReplaceFields *string `gorm:"default:'';" json:"replace_fields"` // + ReplaceFields *string `gorm:"default:'';" json:"replace_fields"` // 需要替换的字段 Content *string `gorm:"default:'';" json:"content"` // 模板内容 Status *int64 `gorm:"default:0;" json:"status"` // 状态值(0:禁用,1:启用) - Ctime *int64 `gorm:"default:0;" json:"ctime"` // + Ctime *int64 `gorm:"default:0;" json:"ctime"` // 添加时间 } type FsEmailTemplateModel struct { db *gorm.DB diff --git a/model/gmodel/fs_faq_gen.go b/model/gmodel/fs_faq_gen.go index f087a561..63fee257 100644 --- a/model/gmodel/fs_faq_gen.go +++ b/model/gmodel/fs_faq_gen.go @@ -13,7 +13,7 @@ type FsFaq struct { Content *string `gorm:"default:'';" json:"content"` // 内容 Status *int64 `gorm:"default:0;" json:"status"` // 状态(0:禁用,1:启用) Sort *int64 `gorm:"default:1;" json:"sort"` // 排序 - Ctime *int64 `gorm:"default:0;" json:"ctime"` // + Ctime *int64 `gorm:"default:0;" json:"ctime"` // 添加时间 } type FsFaqModel struct { db *gorm.DB diff --git a/model/gmodel/fs_gerent_gen.go b/model/gmodel/fs_gerent_gen.go index 0c6dfd2a..9aff318a 100644 --- a/model/gmodel/fs_gerent_gen.go +++ b/model/gmodel/fs_gerent_gen.go @@ -10,12 +10,12 @@ type FsGerent struct { Username *string `gorm:"unique_key;default:'';" json:"username"` // 用户名 AuthKey *string `gorm:"default:'';" json:"auth_key"` // token PasswordHash *string `gorm:"default:'';" json:"password_hash"` // 加密密码 - PasswordResetToken *string `gorm:"unique_key;default:'';" json:"password_reset_token"` // + PasswordResetToken *string `gorm:"unique_key;default:'';" json:"password_reset_token"` // 加密密码token Email *string `gorm:"unique_key;default:'';" json:"email"` // 邮箱 Status *int64 `gorm:"default:10;" json:"status"` // 状态 CreatedAt *int64 `gorm:"default:0;" json:"created_at"` // 创建时间 UpdatedAt *int64 `gorm:"default:0;" json:"updated_at"` // 更新时间 - Icon *string `gorm:"default:'';" json:"icon"` // + Icon *string `gorm:"default:'';" json:"icon"` // 标签图标 DepartmentId *int64 `gorm:"default:0;" json:"department_id"` // 部门id } type FsGerentModel struct { diff --git a/model/gmodel/fs_logo_cartoon_gen.go b/model/gmodel/fs_logo_cartoon_gen.go new file mode 100644 index 00000000..e4bac34b --- /dev/null +++ b/model/gmodel/fs_logo_cartoon_gen.go @@ -0,0 +1,29 @@ +package gmodel + +import ( + "gorm.io/gorm" + "time" +) + +// fs_logo_cartoon logo底图表 +type FsLogoCartoon struct { + Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` // ID + CategoryId *int64 `gorm:"default:0;" json:"category_id"` // 分类 + Name *string `gorm:"default:'';" json:"name"` // + Url *string `gorm:"default:'';" json:"url"` // + IsDel *int64 `gorm:"default:0;" json:"is_del"` // 是否删除 + 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"` // 删除人 +} +type FsLogoCartoonModel struct { + db *gorm.DB + name string +} + +func NewFsLogoCartoonModel(db *gorm.DB) *FsLogoCartoonModel { + return &FsLogoCartoonModel{db: db, name: "fs_logo_cartoon"} +} diff --git a/model/gmodel/fs_logo_cartoon_logic.go b/model/gmodel/fs_logo_cartoon_logic.go new file mode 100644 index 00000000..e68225aa --- /dev/null +++ b/model/gmodel/fs_logo_cartoon_logic.go @@ -0,0 +1,2 @@ +package gmodel +// TODO: 使用model的属性做你想做的 \ No newline at end of file diff --git a/model/gmodel/fs_merchant_category_gen.go b/model/gmodel/fs_merchant_category_gen.go index 37944dce..732ec88b 100644 --- a/model/gmodel/fs_merchant_category_gen.go +++ b/model/gmodel/fs_merchant_category_gen.go @@ -11,7 +11,7 @@ type FsMerchantCategory struct { EnName *string `gorm:"default:'';" json:"en_name"` // 英文名 Icon *string `gorm:"default:'';" json:"icon"` // 图标 RecommendProduct *string `gorm:"default:'';" json:"recommend_product"` // 推荐商品 - Sort *int64 `gorm:"default:128;" json:"sort"` // 排序 + Sort *int64 `gorm:"default:0;" json:"sort"` // 排序 Status *int64 `gorm:"default:0;" json:"status"` // 状态 Ctime *int64 `gorm:"default:0;" json:"ctime"` // 添加时间 } diff --git a/model/gmodel/fs_order_detail_gen.go b/model/gmodel/fs_order_detail_gen.go index 9a9ad151..01808b2a 100644 --- a/model/gmodel/fs_order_detail_gen.go +++ b/model/gmodel/fs_order_detail_gen.go @@ -9,7 +9,7 @@ type FsOrderDetail struct { Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` // Sn *string `gorm:"unique_key;default:'';" json:"sn"` // 唯一编码 OrderId *int64 `gorm:"index;default:0;" json:"order_id"` // 订单ID - UserId *int64 `gorm:"default:0;" json:"user_id"` // + UserId *int64 `gorm:"default:0;" json:"user_id"` // 用户ID FactoryId *int64 `gorm:"default:0;" json:"factory_id"` // 工厂ID OrderDetailTemplateId *int64 `gorm:"default:0;" json:"order_detail_template_id"` // 详情templateID ProductId *int64 `gorm:"default:0;" json:"product_id"` // 产品ID diff --git a/model/gmodel/fs_order_detail_template_gen.go b/model/gmodel/fs_order_detail_template_gen.go index 698b691c..376137fc 100644 --- a/model/gmodel/fs_order_detail_template_gen.go +++ b/model/gmodel/fs_order_detail_template_gen.go @@ -16,7 +16,7 @@ type FsOrderDetailTemplate struct { EachBoxNum *int64 `gorm:"default:0;" json:"each_box_num"` // 每一箱的个数 EachBoxWeight *float64 `gorm:"default:0.00;" json:"each_box_weight"` // 每一箱的重量 单位KG DesignId *int64 `gorm:"index;default:0;" json:"design_id"` // 设计ID - Ctime *int64 `gorm:"default:0;" json:"ctime"` // + Ctime *int64 `gorm:"default:0;" json:"ctime"` // 添加时间 } type FsOrderDetailTemplateModel struct { db *gorm.DB diff --git a/model/gmodel/fs_order_gen.go b/model/gmodel/fs_order_gen.go index 2ca004bf..ab34b331 100644 --- a/model/gmodel/fs_order_gen.go +++ b/model/gmodel/fs_order_gen.go @@ -9,17 +9,17 @@ import ( type FsOrder struct { Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` // Sn *string `gorm:"unique_key;default:'';" json:"sn"` // 订单编号 FS211224OL2XDKNP - UserId *int64 `gorm:"index;default:0;" json:"user_id"` // - SellerUserId *int64 `gorm:"default:0;" json:"seller_user_id"` // + UserId *int64 `gorm:"index;default:0;" json:"user_id"` // 用户ID + SellerUserId *int64 `gorm:"default:0;" json:"seller_user_id"` // 销售员ID 0:自主下单 TotalAmount *int64 `gorm:"default:0;" json:"total_amount"` // 总价 PayedAmount *int64 `gorm:"default:0;" json:"payed_amount"` // 已支付金额 PayMethod *int64 `gorm:"default:0;" json:"pay_method"` // 支付方式 1paypal 2strip - Ctime *int64 `gorm:"default:0;" json:"ctime"` // - Utime *int64 `gorm:"default:0;" json:"utime"` // - Ptime *int64 `gorm:"default:0;" json:"ptime"` // + Ctime *int64 `gorm:"default:0;" json:"ctime"` // 添加时间 + Utime *int64 `gorm:"default:0;" json:"utime"` // 更新时间 + Ptime *int64 `gorm:"default:0;" json:"ptime"` // 最后一次 支付时间(可能多次支付) AddressId *int64 `gorm:"index;default:0;" json:"address_id"` // 地址ID或者云仓ID DeliveryMethod *int64 `gorm:"default:0;" json:"delivery_method"` // 配送方式 1:直接发货到收获地址 2:云仓 - CustomerMark *string `gorm:"default:'';" json:"customer_mark"` // + CustomerMark *string `gorm:"default:'';" json:"customer_mark"` // 客户备注 Mark *string `gorm:"default:'';" json:"mark"` // 后台订单备注 AddressInfo *string `gorm:"default:'';" json:"address_info"` // 详细地址信息JSON IsSup *int64 `gorm:"default:0;" json:"is_sup"` // 0不是补货 1是补货 @@ -37,8 +37,8 @@ type FsOrder struct { IsRefunding *int64 `gorm:"default:0;" json:"is_refunding"` // 是否退款中(0:否,1:是) IsRefunded *int64 `gorm:"default:0;" json:"is_refunded"` // 是否退款完成(0:否,1:是) IsDeleted *int64 `gorm:"default:0;" json:"is_deleted"` // 是否删除(0:否,1:是) - RefundReasonId *int64 `gorm:"default:0;" json:"refund_reason_id"` // - RefundReason *string `gorm:"default:'';" json:"refund_reason"` // + RefundReasonId *int64 `gorm:"default:0;" json:"refund_reason_id"` // 取消订单原因ID + RefundReason *string `gorm:"default:'';" json:"refund_reason"` // 取消订单原因 TsTime *time.Time `gorm:"default:'0000-00-00 00:00:00';" json:"ts_time"` // IsSure *int64 `gorm:"default:0;" json:"is_sure"` // 是否确认订单 1确认0未确认 DeliverSn *string `gorm:"default:'';" json:"deliver_sn"` // 发货单号 diff --git a/model/gmodel/fs_product_design_gather_gen.go b/model/gmodel/fs_product_design_gather_gen.go index 5e466861..6a434704 100644 --- a/model/gmodel/fs_product_design_gather_gen.go +++ b/model/gmodel/fs_product_design_gather_gen.go @@ -8,18 +8,19 @@ import ( type FsProductDesignGather struct { Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` // Sn *string `gorm:"index;default:'';" json:"sn"` // 唯一标识 - UserId *int64 `gorm:"index;default:0;" json:"user_id"` // + UserId *int64 `gorm:"index;default:0;" json:"user_id"` // 用户ID ProductId *int64 `gorm:"index;default:0;" json:"product_id"` // 产品ID TemplateId *int64 `gorm:"index;default:0;" json:"template_id"` // 模型ID MaterialId *int64 `gorm:"index;default:0;" json:"material_id"` // 材质ID SizeId *int64 `gorm:"index;default:0;" json:"size_id"` // 尺寸ID OptionalId *int64 `gorm:"index;default:0;" json:"optional_id"` // 选项ID - Cover *string `gorm:"default:'';" json:"cover"` // + Cover *string `gorm:"default:'';" json:"cover"` // 封面图 Info *string `gorm:"default:'';" json:"info"` // 保留的设计信息 - Utime *int64 `gorm:"default:0;" json:"utime"` // + Utime *int64 `gorm:"default:0;" json:"utime"` // 更新时间 Status *int64 `gorm:"default:1;" json:"status"` // 状态位(1:显示,0:删除) ClientIp *string `gorm:"default:'';" json:"client_ip"` // 客户端ip ClientNo *string `gorm:"default:'';" json:"client_no"` // 客户端唯一标识 + InfoNew *string `gorm:"default:'';" json:"info_new"` // 设计信息-改版 } type FsProductDesignGatherModel struct { db *gorm.DB diff --git a/model/gmodel/fs_product_design_gen.go b/model/gmodel/fs_product_design_gen.go index 978031f5..eee357fe 100644 --- a/model/gmodel/fs_product_design_gen.go +++ b/model/gmodel/fs_product_design_gen.go @@ -23,6 +23,7 @@ type FsProductDesign struct { IsPay *int64 `gorm:"default:0;" json:"is_pay"` // 是否已有支付 0 未 1 有 LogoColor *string `gorm:"default:'';" json:"logo_color"` // logo图片备选项 PageGuid *string `gorm:"default:'';" json:"page_guid"` // 页面识别id + InfoNew *string `gorm:"default:'';" json:"info_new"` // 设计信息-改版用 } type FsProductDesignModel struct { db *gorm.DB diff --git a/model/gmodel/fs_product_gen.go b/model/gmodel/fs_product_gen.go index 9eccb236..b888f9f2 100644 --- a/model/gmodel/fs_product_gen.go +++ b/model/gmodel/fs_product_gen.go @@ -17,11 +17,11 @@ type FsProduct struct { Intro *string `gorm:"default:'';" json:"intro"` // 简要描述 Sort *int64 `gorm:"default:0;" json:"sort"` // 排序 SelledNum *int64 `gorm:"default:0;" json:"selled_num"` // 已卖数量 - Ctime *int64 `gorm:"default:0;" json:"ctime"` // + Ctime *int64 `gorm:"default:0;" json:"ctime"` // 添加时间 View *int64 `gorm:"default:0;" json:"view"` // 浏览量 - SizeIds *string `gorm:"default:'';" json:"size_ids"` // + SizeIds *string `gorm:"default:'';" json:"size_ids"` // 尺寸 1,2,3,4 MaterialIds *string `gorm:"default:'';" json:"material_ids"` // 材质 1,2,3 - TagIds *string `gorm:"default:'';" json:"tag_ids"` // + TagIds *string `gorm:"default:'';" json:"tag_ids"` // 标签 逗号间隔 Status *int64 `gorm:"default:0;" json:"status"` // 状态位 弃用 ProduceDays *int64 `gorm:"default:0;" json:"produce_days"` // 生产天数 DeliveryDays *int64 `gorm:"default:0;" json:"delivery_days"` // 运送天数 diff --git a/model/gmodel/fs_product_model3d_gen.go b/model/gmodel/fs_product_model3d_gen.go index 6842c3dc..7669602f 100644 --- a/model/gmodel/fs_product_model3d_gen.go +++ b/model/gmodel/fs_product_model3d_gen.go @@ -8,7 +8,6 @@ import ( type FsProductModel3d struct { Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` // ProductId *int64 `gorm:"index;default:0;" json:"product_id"` // 产品ID - IsPopular *int64 `gorm:"default:0;" json:"is_popular"` // 是否热门 0否 1是 Tag *int64 `gorm:"default:1;" json:"tag"` // 类别(1:模型,2:配件,3:场景) Title *string `gorm:"default:'';" json:"title"` // 标题 Name *string `gorm:"default:'';" json:"name"` // 详情页展示名称 @@ -25,6 +24,7 @@ type FsProductModel3d struct { OptionTemplate *int64 `gorm:"default:0;" json:"option_template"` // 配件绑定的公共模板 Price *int64 `gorm:"default:0;" json:"price"` // 仅配件用,配件的价格, 单位:美分 Sku *string `gorm:"default:'';" json:"sku"` // sku + IsHot *int64 `gorm:"default:0;" json:"is_hot"` // 是否热门 } type FsProductModel3dModel struct { db *gorm.DB diff --git a/model/gmodel/fs_product_model3d_light_gen.go b/model/gmodel/fs_product_model3d_light_gen.go index aa93db60..723f62a3 100644 --- a/model/gmodel/fs_product_model3d_light_gen.go +++ b/model/gmodel/fs_product_model3d_light_gen.go @@ -10,7 +10,7 @@ type FsProductModel3dLight struct { Name *string `gorm:"default:'';" json:"name"` // 灯光名称 Info *string `gorm:"default:'';" json:"info"` // 灯光数据(json格式) Status *int64 `gorm:"default:1;" json:"status"` // 状态值(1:显示,0:删除) - Ctime *int64 `gorm:"default:0;" json:"ctime"` // + Ctime *int64 `gorm:"default:0;" json:"ctime"` // 创建时间 } type FsProductModel3dLightModel struct { db *gorm.DB diff --git a/model/gmodel/fs_product_render_design_gen.go b/model/gmodel/fs_product_render_design_gen.go index 460ec90f..16834189 100644 --- a/model/gmodel/fs_product_render_design_gen.go +++ b/model/gmodel/fs_product_render_design_gen.go @@ -8,19 +8,20 @@ import ( type FsProductRenderDesign struct { Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` // Sn *string `gorm:"index;default:'';" json:"sn"` // 唯一标识 - UserId *int64 `gorm:"index;default:0;" json:"user_id"` // + UserId *int64 `gorm:"index;default:0;" json:"user_id"` // 用户ID ProductId *int64 `gorm:"index;default:0;" json:"product_id"` // 产品ID TemplateId *int64 `gorm:"index;default:0;" json:"template_id"` // 模型ID MaterialId *int64 `gorm:"index;default:0;" json:"material_id"` // 材质ID SizeId *int64 `gorm:"index;default:0;" json:"size_id"` // 尺寸ID OptionalId *int64 `gorm:"index;default:0;" json:"optional_id"` // 选项ID - Cover *string `gorm:"default:'';" json:"cover"` // + Cover *string `gorm:"default:'';" json:"cover"` // 封面图 Info *string `gorm:"default:'';" json:"info"` // 保留的设计信息 - Utime *int64 `gorm:"default:0;" json:"utime"` // + Utime *int64 `gorm:"default:0;" json:"utime"` // 更新时间 Status *int64 `gorm:"default:1;" json:"status"` // 状态位(1:显示,0:删除) ClientIp *string `gorm:"default:'';" json:"client_ip"` // 客户端ip ClientNo *string `gorm:"default:'';" json:"client_no"` // 客户端唯一标识 LogoColor *string `gorm:"default:'';" json:"logo_color"` // logo图片备选颜色 + InfoNew *string `gorm:"default:'';" json:"info_new"` // 设计信息-改版用 } type FsProductRenderDesignModel struct { db *gorm.DB diff --git a/model/gmodel/fs_product_size_gen.go b/model/gmodel/fs_product_size_gen.go index 0c3560e3..24cedf8c 100644 --- a/model/gmodel/fs_product_size_gen.go +++ b/model/gmodel/fs_product_size_gen.go @@ -8,15 +8,15 @@ import ( type FsProductSize struct { Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` // ProductId *int64 `gorm:"index;default:0;" json:"product_id"` // 产品ID - IsPopular *int64 `gorm:"default:0;" json:"is_popular"` // 是否受欢迎 0否1是 Title *string `gorm:"default:'';" json:"title"` // 标题 10*10*20 - Cover *string `gorm:"default:'';" json:"cover"` // - CoverImg *string `gorm:"default:'';" json:"cover_img"` // + Cover *string `gorm:"default:'';" json:"cover"` // 封面图 + CoverImg *string `gorm:"default:'';" json:"cover_img"` // 背景图 Capacity *string `gorm:"default:'';" json:"capacity"` // 自己填的尺寸名称 Status *int64 `gorm:"default:0;" json:"status"` // 状态位 显示 删除 Sort *int64 `gorm:"default:50;" json:"sort"` // 排序 - Remark *string `gorm:"default:'';" json:"remark"` // + Remark *string `gorm:"default:'';" json:"remark"` // 备注信息 PartsCanDeleted *int64 `gorm:"default:1;" json:"parts_can_deleted"` // 配件是否可移除 1是0否 + IsHot *int64 `gorm:"default:0;" json:"is_hot"` // 是否热门 } type FsProductSizeModel struct { db *gorm.DB diff --git a/model/gmodel/fs_product_template_element_0826_gen.go b/model/gmodel/fs_product_template_element_0826_gen.go new file mode 100644 index 00000000..03b30c20 --- /dev/null +++ b/model/gmodel/fs_product_template_element_0826_gen.go @@ -0,0 +1,35 @@ +package gmodel + +import ( + "gorm.io/gorm" +) + +// fs_product_template_element_0826 +type FsProductTemplateElement0826 struct { + Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` // + Title *string `gorm:"default:'';" json:"title"` // 产品模板名称 + ProductTemplateId *int64 `gorm:"index;default:0;" json:"product_template_id"` // 产品模板id + Main *string `gorm:"default:'';" json:"main"` // + Second *string `gorm:"default:'';" json:"second"` // + Base *string `gorm:"default:'';" json:"base"` // + Paper *string `gorm:"default:'';" json:"paper"` // + Spoon *string `gorm:"default:'';" json:"spoon"` // + Fork *string `gorm:"default:'';" json:"fork"` // + Toothpick *string `gorm:"default:'';" json:"toothpick"` // + Chopsticks *string `gorm:"default:'';" json:"chopsticks"` // + Shadow *string `gorm:"default:'';" json:"shadow"` // + Cover *string `gorm:"default:'';" json:"cover"` // + Cover1 *string `gorm:"default:'';" json:"cover1"` // + Mode *string `gorm:"default:'';" json:"mode"` // + Light *int64 `gorm:"default:0;" json:"light"` // + Rotation *string `gorm:"default:'';" json:"rotation"` // + Scale *string `gorm:"default:'';" json:"scale"` // +} +type FsProductTemplateElement0826Model struct { + db *gorm.DB + name string +} + +func NewFsProductTemplateElement0826Model(db *gorm.DB) *FsProductTemplateElement0826Model { + return &FsProductTemplateElement0826Model{db: db, name: "fs_product_template_element_0826"} +} diff --git a/model/gmodel/fs_product_template_element_0826_logic.go b/model/gmodel/fs_product_template_element_0826_logic.go new file mode 100644 index 00000000..e68225aa --- /dev/null +++ b/model/gmodel/fs_product_template_element_0826_logic.go @@ -0,0 +1,2 @@ +package gmodel +// TODO: 使用model的属性做你想做的 \ No newline at end of file diff --git a/model/gmodel/fs_product_template_element_22_gen.go b/model/gmodel/fs_product_template_element_22_gen.go new file mode 100644 index 00000000..3c4665b1 --- /dev/null +++ b/model/gmodel/fs_product_template_element_22_gen.go @@ -0,0 +1,25 @@ +package gmodel + +import ( + "gorm.io/gorm" +) + +// fs_product_template_element_22 +type FsProductTemplateElement22 struct { + Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` // + Title *string `gorm:"default:'';" json:"title"` // 产品模板名称 + ProductTemplateId *int64 `gorm:"index;default:0;" json:"product_template_id"` // 产品模板id + Model *string `gorm:"default:'';" json:"model"` // + Mode *string `gorm:"default:'';" json:"mode"` // + Light *int64 `gorm:"default:0;" json:"light"` // + Rotation *string `gorm:"default:'';" json:"rotation"` // + Scale *string `gorm:"default:'';" json:"scale"` // +} +type FsProductTemplateElement22Model struct { + db *gorm.DB + name string +} + +func NewFsProductTemplateElement22Model(db *gorm.DB) *FsProductTemplateElement22Model { + return &FsProductTemplateElement22Model{db: db, name: "fs_product_template_element_22"} +} diff --git a/model/gmodel/fs_product_template_element_22_logic.go b/model/gmodel/fs_product_template_element_22_logic.go new file mode 100644 index 00000000..e68225aa --- /dev/null +++ b/model/gmodel/fs_product_template_element_22_logic.go @@ -0,0 +1,2 @@ +package gmodel +// TODO: 使用model的属性做你想做的 \ No newline at end of file diff --git a/model/gmodel/fs_product_template_element_backup1018_gen.go b/model/gmodel/fs_product_template_element_backup1018_gen.go new file mode 100644 index 00000000..3c62068a --- /dev/null +++ b/model/gmodel/fs_product_template_element_backup1018_gen.go @@ -0,0 +1,37 @@ +package gmodel + +import ( + "gorm.io/gorm" +) + +// fs_product_template_element_backup1018 +type FsProductTemplateElementBackup1018 struct { + Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` // + Title *string `gorm:"default:'';" json:"title"` // 产品模板名称 + ProductTemplateId *int64 `gorm:"index;default:0;" json:"product_template_id"` // 产品模板id + Main *string `gorm:"default:'';" json:"main"` // + Second *string `gorm:"default:'';" json:"second"` // + Base *string `gorm:"default:'';" json:"base"` // + Paper *string `gorm:"default:'';" json:"paper"` // + Spoon *string `gorm:"default:'';" json:"spoon"` // + Fork *string `gorm:"default:'';" json:"fork"` // + Toothpick *string `gorm:"default:'';" json:"toothpick"` // + Chopsticks *string `gorm:"default:'';" json:"chopsticks"` // + Shadow *string `gorm:"default:'';" json:"shadow"` // + Cover *string `gorm:"default:'';" json:"cover"` // + Cover1 *string `gorm:"default:'';" json:"cover1"` // + Mode *string `gorm:"default:'';" json:"mode"` // + Light *int64 `gorm:"default:0;" json:"light"` // + Rotation *string `gorm:"default:'';" json:"rotation"` // + Scale *string `gorm:"default:'';" json:"scale"` // + ModelP *string `gorm:"default:'';" json:"model_p"` // 配件对应的云渲染贴图数据 + Refletion *int64 `gorm:"default:0;" json:"refletion"` // 反射探头 +} +type FsProductTemplateElementBackup1018Model struct { + db *gorm.DB + name string +} + +func NewFsProductTemplateElementBackup1018Model(db *gorm.DB) *FsProductTemplateElementBackup1018Model { + return &FsProductTemplateElementBackup1018Model{db: db, name: "fs_product_template_element_backup1018"} +} diff --git a/model/gmodel/fs_product_template_element_backup1018_logic.go b/model/gmodel/fs_product_template_element_backup1018_logic.go new file mode 100644 index 00000000..e68225aa --- /dev/null +++ b/model/gmodel/fs_product_template_element_backup1018_logic.go @@ -0,0 +1,2 @@ +package gmodel +// TODO: 使用model的属性做你想做的 \ No newline at end of file diff --git a/model/gmodel/fs_product_template_element_gen.go b/model/gmodel/fs_product_template_element_gen.go index 44f32f14..5da26874 100644 --- a/model/gmodel/fs_product_template_element_gen.go +++ b/model/gmodel/fs_product_template_element_gen.go @@ -6,26 +6,26 @@ import ( // fs_product_template_element 云渲染配置表 type FsProductTemplateElement struct { - Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` // id - Title *string `gorm:"default:'';" json:"title"` // 产品模板名称 - ModelId *int64 `gorm:"index;default:0;" json:"model_id"` // 模型id - Main *string `gorm:"default:'';" json:"main"` // - Second *string `gorm:"default:'';" json:"second"` // - Base *string `gorm:"default:'';" json:"base"` // - Paper *string `gorm:"default:'';" json:"paper"` // - Spoon *string `gorm:"default:'';" json:"spoon"` // - Fork *string `gorm:"default:'';" json:"fork"` // - Toothpick *string `gorm:"default:'';" json:"toothpick"` // - Chopsticks *string `gorm:"default:'';" json:"chopsticks"` // - Shadow *string `gorm:"default:'';" json:"shadow"` // - Cover *string `gorm:"default:'';" json:"cover"` // - Cover1 *string `gorm:"default:'';" json:"cover1"` // - Mode *string `gorm:"default:'';" json:"mode"` // - Light *int64 `gorm:"default:0;" json:"light"` // - Rotation *string `gorm:"default:'';" json:"rotation"` // - Scale *string `gorm:"default:'';" json:"scale"` // - ModelP *string `gorm:"default:'';" json:"model_p"` // 配件对应的云渲染贴图数据 - Refletion *string `gorm:"default:'';" json:"refletion"` // 反射探头组 + Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` // id + Title *string `gorm:"default:'';" json:"title"` // 产品模板名称 + ProductTemplateId *int64 `gorm:"index;default:0;" json:"product_template_id"` // 产品模型id + Main *string `gorm:"default:'';" json:"main"` // 废弃 + Second *string `gorm:"default:'';" json:"second"` // 废弃 + Base *string `gorm:"default:'';" json:"base"` // base + Paper *string `gorm:"default:'';" json:"paper"` // 废弃 + Spoon *string `gorm:"default:'';" json:"spoon"` // 废弃 + Fork *string `gorm:"default:'';" json:"fork"` // 废弃 + Toothpick *string `gorm:"default:'';" json:"toothpick"` // 废弃 + Chopsticks *string `gorm:"default:'';" json:"chopsticks"` // 废弃 + Shadow *string `gorm:"default:'';" json:"shadow"` // shadow + Cover *string `gorm:"default:'';" json:"cover"` // 废弃 + Cover1 *string `gorm:"default:'';" json:"cover1"` // 废弃 + Mode *string `gorm:"default:'';" json:"mode"` // 材质类型 + Light *int64 `gorm:"default:0;" json:"light"` // 灯光组 + Rotation *string `gorm:"default:'';" json:"rotation"` // 旋转 + Scale *string `gorm:"default:'';" json:"scale"` // 缩放 + ModelP *string `gorm:"default:'';" json:"model_p"` // 配件对应的云渲染贴图数据 + Refletion *string `gorm:"default:'';" json:"refletion"` // 反射探头组 } type FsProductTemplateElementModel struct { db *gorm.DB diff --git a/model/gmodel/fs_product_template_element_kongde_gen.go b/model/gmodel/fs_product_template_element_kongde_gen.go new file mode 100644 index 00000000..a7d72cb8 --- /dev/null +++ b/model/gmodel/fs_product_template_element_kongde_gen.go @@ -0,0 +1,35 @@ +package gmodel + +import ( + "gorm.io/gorm" +) + +// fs_product_template_element_kongde +type FsProductTemplateElementKongde struct { + Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` // + Title *string `gorm:"default:'';" json:"title"` // 产品模板名称 + ProductTemplateId *int64 `gorm:"index;default:0;" json:"product_template_id"` // 产品模板id + Main *string `gorm:"default:'';" json:"main"` // + Second *string `gorm:"default:'';" json:"second"` // + Base *string `gorm:"default:'';" json:"base"` // + Paper *string `gorm:"default:'';" json:"paper"` // + Spoon *string `gorm:"default:'';" json:"spoon"` // + Fork *string `gorm:"default:'';" json:"fork"` // + Toothpick *string `gorm:"default:'';" json:"toothpick"` // + Chopsticks *string `gorm:"default:'';" json:"chopsticks"` // + Shadow *string `gorm:"default:'';" json:"shadow"` // + Cover *string `gorm:"default:'';" json:"cover"` // + Cover1 *string `gorm:"default:'';" json:"cover1"` // + Mode *string `gorm:"default:'';" json:"mode"` // + Light *int64 `gorm:"default:0;" json:"light"` // + Rotation *string `gorm:"default:'';" json:"rotation"` // + Scale *string `gorm:"default:'';" json:"scale"` // +} +type FsProductTemplateElementKongdeModel struct { + db *gorm.DB + name string +} + +func NewFsProductTemplateElementKongdeModel(db *gorm.DB) *FsProductTemplateElementKongdeModel { + return &FsProductTemplateElementKongdeModel{db: db, name: "fs_product_template_element_kongde"} +} diff --git a/model/gmodel/fs_product_template_element_kongde_logic.go b/model/gmodel/fs_product_template_element_kongde_logic.go new file mode 100644 index 00000000..e68225aa --- /dev/null +++ b/model/gmodel/fs_product_template_element_kongde_logic.go @@ -0,0 +1,2 @@ +package gmodel +// TODO: 使用model的属性做你想做的 \ No newline at end of file diff --git a/model/gmodel/fs_product_template_tags_gen.go b/model/gmodel/fs_product_template_tags_gen.go index a940bced..4cc602cc 100644 --- a/model/gmodel/fs_product_template_tags_gen.go +++ b/model/gmodel/fs_product_template_tags_gen.go @@ -8,7 +8,7 @@ import ( type FsProductTemplateTags struct { Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` // ID TemplateTag *string `gorm:"unique_key;default:'';" json:"template_tag"` // 标题 - Cover *string `gorm:"default:'';" json:"cover"` // 封面图 + Cover *string `gorm:"default:'';" json:"cover"` // 缩略图 Status *int64 `gorm:"default:0;" json:"status"` // 状态 1:可用 CreateAt *int64 `gorm:"default:0;" json:"create_at"` // 创建时间 Groups *string `gorm:"default:'';" json:"groups"` // 分组信息 diff --git a/model/gmodel/fs_product_template_v2_gen.go b/model/gmodel/fs_product_template_v2_gen.go index cd6a5f51..febe3f7c 100644 --- a/model/gmodel/fs_product_template_v2_gen.go +++ b/model/gmodel/fs_product_template_v2_gen.go @@ -9,21 +9,21 @@ type FsProductTemplateV2 struct { Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` // ProductId *int64 `gorm:"index;default:0;" json:"product_id"` // 产品ID ModelId *int64 `gorm:"default:0;" json:"model_id"` // 模型ID - Title *string `gorm:"default:'';" json:"title"` // - Name *string `gorm:"default:'';" json:"name"` // - CoverImg *string `gorm:"default:'';" json:"cover_img"` // - TemplateInfo *string `gorm:"default:'';" json:"template_info"` // - MaterialImg *string `gorm:"default:'';" json:"material_img"` // + Title *string `gorm:"default:'';" json:"title"` // 模板(sku),预留字段 + Name *string `gorm:"default:'';" json:"name"` // 名称 + CoverImg *string `gorm:"default:'';" json:"cover_img"` // 模板背景图 + TemplateInfo *string `gorm:"default:'';" json:"template_info"` // 模板详情 + MaterialImg *string `gorm:"default:'';" json:"material_img"` // 合成好的贴图 Sort *int64 `gorm:"default:0;" json:"sort"` // 排序 LogoWidth *int64 `gorm:"default:0;" json:"logo_width"` // logo图最大宽度 LogoHeight *int64 `gorm:"default:0;" json:"logo_height"` // logo图最大高度 IsPublic *int64 `gorm:"default:0;" json:"is_public"` // 是否可公用(1:可以,0:不可以) Status *int64 `gorm:"default:0;" json:"status"` // 状态1正常 2异常 Ctime *int64 `gorm:"default:0;" json:"ctime"` // 添加时间 - TemplateTag *string `gorm:"default:'';" json:"template_tag"` // + TemplateTag *string `gorm:"default:'';" json:"template_tag"` // 标签(用户自填) IsDel *int64 `gorm:"default:0;" json:"is_del"` // 是否删除 1删除 - SwitchInfo *string `gorm:"default:'';" json:"switch_info"` // - Version *int64 `gorm:"index;default:0;" json:"version"` // 默认1 + SwitchInfo *string `gorm:"default:'';" json:"switch_info"` // 开关信息 + Version *int64 `gorm:"default:0;" json:"version"` // 默认1 } type FsProductTemplateV2Model struct { db *gorm.DB diff --git a/model/gmodel/fs_qrcode_log_gen.go b/model/gmodel/fs_qrcode_log_gen.go index 45b3477d..8d61dac8 100644 --- a/model/gmodel/fs_qrcode_log_gen.go +++ b/model/gmodel/fs_qrcode_log_gen.go @@ -11,8 +11,8 @@ type FsQrcodeLog struct { QrcodeId *int64 `gorm:"default:0;" json:"qrcode_id"` // 二维码ID TagId *int64 `gorm:"default:0;" json:"tag_id"` // 分组ID CreateAt *int64 `gorm:"default:0;" json:"create_at"` // 创建时间 - Platform *string `gorm:"default:'';" json:"platform"` // - UserAgent *string `gorm:"default:'';" json:"user_agent"` // + Platform *string `gorm:"default:'';" json:"platform"` // 系统信息 + UserAgent *string `gorm:"default:'';" json:"user_agent"` // 浏览器 } type FsQrcodeLogModel struct { db *gorm.DB diff --git a/model/gmodel/fs_quotation_gen.go b/model/gmodel/fs_quotation_gen.go index 08b6885f..041bbb84 100644 --- a/model/gmodel/fs_quotation_gen.go +++ b/model/gmodel/fs_quotation_gen.go @@ -19,7 +19,6 @@ type FsQuotation struct { DesignId *int64 `gorm:"default:0;" json:"design_id"` // 设计人员 QuotationId *int64 `gorm:"default:0;" json:"quotation_id"` // 报价人员 IsMark *int64 `gorm:"default:0;" json:"is_mark"` // 星标 - Qid *int64 `gorm:"default:0;" json:"qid"` // } type FsQuotationModel struct { db *gorm.DB diff --git a/model/gmodel/fs_quotation_price_gen.go b/model/gmodel/fs_quotation_price_gen.go new file mode 100644 index 00000000..6f4b8b52 --- /dev/null +++ b/model/gmodel/fs_quotation_price_gen.go @@ -0,0 +1,23 @@ +package gmodel + +import ( + "gorm.io/gorm" +) + +// fs_quotation_price 报价单价格表 +type FsQuotationPrice struct { + Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` // Id + ProductId *int64 `gorm:"default:0;" json:"product_id"` // 产品id + SizeId *int64 `gorm:"default:0;" json:"size_id"` // 尺寸id + PriceInfo *string `gorm:"default:'';" json:"price_info"` // 价格数据 + Status *int64 `gorm:"default:1;" json:"status"` // 状态 1启用0废弃 + Ctime *int64 `gorm:"default:0;" json:"ctime"` // 添加时间 +} +type FsQuotationPriceModel struct { + db *gorm.DB + name string +} + +func NewFsQuotationPriceModel(db *gorm.DB) *FsQuotationPriceModel { + return &FsQuotationPriceModel{db: db, name: "fs_quotation_price"} +} diff --git a/model/gmodel/fs_quotation_price_logic.go b/model/gmodel/fs_quotation_price_logic.go new file mode 100644 index 00000000..e68225aa --- /dev/null +++ b/model/gmodel/fs_quotation_price_logic.go @@ -0,0 +1,2 @@ +package gmodel +// TODO: 使用model的属性做你想做的 \ No newline at end of file diff --git a/model/gmodel/fs_quotation_product_gen.go b/model/gmodel/fs_quotation_product_gen.go index 9f417951..498c311c 100644 --- a/model/gmodel/fs_quotation_product_gen.go +++ b/model/gmodel/fs_quotation_product_gen.go @@ -6,20 +6,23 @@ import ( // fs_quotation_product 报价单产品表 type FsQuotationProduct struct { - Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` // ID - QuotationId *int64 `gorm:"index;default:0;" json:"quotation_id"` // 报价单id - Name *string `gorm:"default:'';" json:"name"` // 产品名 - Size *string `gorm:"default:'';" json:"size"` // 产品规格 - Cycle *int64 `gorm:"default:0;" json:"cycle"` // 交付周期 - IsGift *int64 `gorm:"default:0;" json:"is_gift"` // 是否赠品 - Img *string `gorm:"default:'';" json:"img"` // 效果图 - Status *int64 `gorm:"default:0;" json:"status"` // 状态位 1启用0停用 - Ctime *int64 `gorm:"default:0;" json:"ctime"` // 添加时间 - Sort *int64 `gorm:"default:0;" json:"sort"` // 排序 - Sid *string `gorm:"default:'';" json:"sid"` // 前端sid - PriceInfo *string `gorm:"default:'';" json:"price_info"` // 价格信息 - Remark *string `gorm:"default:'';" json:"remark"` // 备注 - Num *int64 `gorm:"default:0;" json:"num"` // 产品数量 + Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` // ID + QuotationId *int64 `gorm:"index;default:0;" json:"quotation_id"` // 报价单id + Name *string `gorm:"default:'';" json:"name"` // 产品名 + Size *string `gorm:"default:'';" json:"size"` // 产品规格 + Cycle *int64 `gorm:"default:0;" json:"cycle"` // 交付周期 + IsGift *int64 `gorm:"default:0;" json:"is_gift"` // 是否赠品 + Img *string `gorm:"default:'';" json:"img"` // 效果图 + Status *int64 `gorm:"default:0;" json:"status"` // 状态位 1启用0停用 + Ctime *int64 `gorm:"default:0;" json:"ctime"` // 添加时间 + Sort *int64 `gorm:"default:0;" json:"sort"` // 排序 + Sid *string `gorm:"default:'';" json:"sid"` // 前端sid + PriceInfo *string `gorm:"default:'';" json:"price_info"` // 价格信息 + Remark *string `gorm:"default:'';" json:"remark"` // 备注 + Num *int64 `gorm:"default:0;" json:"num"` // 产品数量 + ShowSizeTips *int64 `gorm:"default:0;" json:"show_size_tips"` // 是否显示提示 + ShowSizeList *int64 `gorm:"default:0;" json:"show_size_list"` // 是否显示规格列表 + ProductId *int64 `gorm:"default:0;" json:"product_id"` // 产品id } type FsQuotationProductModel struct { db *gorm.DB diff --git a/model/gmodel/fs_quotation_size_layout_gen.go b/model/gmodel/fs_quotation_size_layout_gen.go new file mode 100644 index 00000000..67d73ac6 --- /dev/null +++ b/model/gmodel/fs_quotation_size_layout_gen.go @@ -0,0 +1,22 @@ +package gmodel + +import ( + "gorm.io/gorm" +) + +// fs_quotation_size_layout 产品尺寸排版表 +type FsQuotationSizeLayout struct { + Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` // + ProductId *int64 `gorm:"unique_key;default:0;" json:"product_id"` // 产品id + SizeHtml *string `gorm:"default:'';" json:"size_html"` // 尺寸排版html + Status *int64 `gorm:"default:1;" json:"status"` // 状态 + Ctime *int64 `gorm:"default:0;" json:"ctime"` // 添加时间 +} +type FsQuotationSizeLayoutModel struct { + db *gorm.DB + name string +} + +func NewFsQuotationSizeLayoutModel(db *gorm.DB) *FsQuotationSizeLayoutModel { + return &FsQuotationSizeLayoutModel{db: db, name: "fs_quotation_size_layout"} +} diff --git a/model/gmodel/fs_quotation_size_layout_logic.go b/model/gmodel/fs_quotation_size_layout_logic.go new file mode 100644 index 00000000..e68225aa --- /dev/null +++ b/model/gmodel/fs_quotation_size_layout_logic.go @@ -0,0 +1,2 @@ +package gmodel +// TODO: 使用model的属性做你想做的 \ No newline at end of file diff --git a/model/gmodel/fs_resource_gen.go b/model/gmodel/fs_resource_gen.go index 0f308faf..a85dc617 100644 --- a/model/gmodel/fs_resource_gen.go +++ b/model/gmodel/fs_resource_gen.go @@ -13,7 +13,7 @@ type FsResource struct { ResourceType *string `gorm:"index;default:'';" json:"resource_type"` // 资源类型 ResourceUrl *string `gorm:"default:'';" json:"resource_url"` // 资源 URL Version *string `gorm:"index;default:'0';" json:"version"` // 版本信息 - UploadedAt *time.Time `gorm:"index;default:'0000-00-00 00:00:00';" json:"uploaded_at"` // 上传时间 + UploadedAt *time.Time `gorm:"index;default:'0000-00-00 00:00:00';" json:"uploaded_at"` // Metadata *string `gorm:"default:'';" json:"metadata"` // 元数据,json格式,存储图像分率 MetaKey1 *string `gorm:"index;default:'';" json:"meta_key1"` // 需要关键信息查询的自定义属性1,可以动态增加 ApiType *int64 `gorm:"default:1;" json:"api_type"` // 调用类型:1=对外,2=对内 diff --git a/model/gmodel/fs_trade_gen.go b/model/gmodel/fs_trade_gen.go index 740f1300..41514e47 100644 --- a/model/gmodel/fs_trade_gen.go +++ b/model/gmodel/fs_trade_gen.go @@ -13,10 +13,10 @@ type FsTrade struct { TradeSn *string `gorm:"unique_key;default:'';" json:"trade_sn"` // 三方交易号 OrderId *int64 `gorm:"index;default:0;" json:"order_id"` // 订单ID Amount *int64 `gorm:"default:0;" json:"amount"` // 支付金额 - Ctime *int64 `gorm:"default:0;" json:"ctime"` // - Utime *int64 `gorm:"default:0;" json:"utime"` // - Desc *string `gorm:"default:'';" json:"desc"` // - Status *int64 `gorm:"default:0;" json:"status"` // + Ctime *int64 `gorm:"default:0;" json:"ctime"` // 添加时间 + Utime *int64 `gorm:"default:0;" json:"utime"` // 更新时间 + Desc *string `gorm:"default:'';" json:"desc"` // 简要描述 + Status *int64 `gorm:"default:0;" json:"status"` // 状态位 是否支付成功 } type FsTradeModel struct { db *gorm.DB diff --git a/model/gmodel/fs_user_design_gen.go b/model/gmodel/fs_user_design_gen.go index 08d76923..8b6abf07 100644 --- a/model/gmodel/fs_user_design_gen.go +++ b/model/gmodel/fs_user_design_gen.go @@ -7,13 +7,13 @@ import ( // fs_user_design 废弃表 type FsUserDesign struct { Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` // - UserId *int64 `gorm:"index;default:0;" json:"user_id"` // + UserId *int64 `gorm:"index;default:0;" json:"user_id"` // 用户ID ProductId *int64 `gorm:"index;default:0;" json:"product_id"` // 产品ID TemplateId *int64 `gorm:"index;default:0;" json:"template_id"` // 模型ID MaterialId *int64 `gorm:"index;default:0;" json:"material_id"` // 材质ID SizeId *int64 `gorm:"index;default:0;" json:"size_id"` // 尺寸ID Info *string `gorm:"default:'';" json:"info"` // 其他设计信息 - Ctime *int64 `gorm:"default:0;" json:"ctime"` // + Ctime *int64 `gorm:"default:0;" json:"ctime"` // 添加时间 } type FsUserDesignModel struct { db *gorm.DB diff --git a/model/gmodel/fs_user_gen.go b/model/gmodel/fs_user_gen.go index 81d0f008..6c56d10a 100644 --- a/model/gmodel/fs_user_gen.go +++ b/model/gmodel/fs_user_gen.go @@ -9,11 +9,11 @@ type FsUser struct { Id int64 `gorm:"primary_key;default:0;auto_increment;" json:"id"` // ID FaceId *int64 `gorm:"default:0;" json:"face_id"` // facebook的userid GoogleId *int64 `gorm:"default:0;" json:"google_id"` // google的sub - FirstName *string `gorm:"default:'';" json:"first_name"` // - LastName *string `gorm:"default:'';" json:"last_name"` // + FirstName *string `gorm:"default:'';" json:"first_name"` // FirstName + LastName *string `gorm:"default:'';" json:"last_name"` // LastName Username *string `gorm:"unique_key;default:'';" json:"username"` // - Company *string `gorm:"default:'';" json:"company"` // - Mobile *string `gorm:"default:'';" json:"mobile"` // + Company *string `gorm:"default:'';" json:"company"` // 公司名称 + Mobile *string `gorm:"default:'';" json:"mobile"` // 手机号码 AuthKey *string `gorm:"default:'';" json:"auth_key"` // PasswordHash *string `gorm:"default:'';" json:"password_hash"` // VerificationToken *string `gorm:"default:'';" json:"verification_token"` // @@ -30,7 +30,7 @@ type FsUser struct { IsPhoneAdvertisement *int64 `gorm:"default:0;" json:"is_phone_advertisement"` // 是否接收短信广告 IsOpenRender *int64 `gorm:"default:0;" json:"is_open_render"` // 是否打开个性化渲染(1:开启,0:关闭) IsThousandFace *int64 `gorm:"default:0;" json:"is_thousand_face"` // 是否已经存在千人千面(1:存在,0:不存在) - IsLowRendering *int64 `gorm:"default:0;" json:"is_low_rendering"` // 是否开启低渲染模型渲染 + IsLowRendering *int64 `gorm:"default:0;" json:"is_low_rendering"` // IsRemoveBg *int64 `gorm:"default:1;" json:"is_remove_bg"` // 用户上传logo是否去除背景 } type FsUserModel struct { diff --git a/model/gmodel/var_gen.go b/model/gmodel/var_gen.go index 831f79d8..57ed36d2 100644 --- a/model/gmodel/var_gen.go +++ b/model/gmodel/var_gen.go @@ -4,193 +4,207 @@ import "gorm.io/gorm" // AllModelsGen 所有Model集合,修改单行,只要不改字段名,不会根据新的内容修改,需要修改的话手动删除 type AllModelsGen struct { - FsAddress *FsAddressModel // fs_address 用户地址表 - FsAuthAssignment *FsAuthAssignmentModel // fs_auth_assignment 用户角色和权限信息 - FsAuthItem *FsAuthItemModel // fs_auth_item 用户角色和权限信息 - FsAuthItemChild *FsAuthItemChildModel // fs_auth_item_child 角色和权限关系表 - FsAuthRule *FsAuthRuleModel // fs_auth_rule 规则表 - FsBackendUser *FsBackendUserModel // fs_backend_user 管理员表 - FsCanteenProduct *FsCanteenProductModel // fs_canteen_product 餐厅类别产品对应表 - FsCanteenType *FsCanteenTypeModel // fs_canteen_type 餐厅类型表 - FsCard *FsCardModel // fs_card 卡号表 - FsCardGroup *FsCardGroupModel // fs_card_group 卡号分组表 - FsCart *FsCartModel // fs_cart 购物车 - FsChangeCode *FsChangeCodeModel // fs_change_code 忘记密码code表 - FsCloud *FsCloudModel // fs_cloud 云仓表 - FsCloudDeliverEveryTmp *FsCloudDeliverEveryTmpModel // fs_cloud_deliver_every_tmp - FsCloudDeliverTmp *FsCloudDeliverTmpModel // fs_cloud_deliver_tmp - FsCloudPickUp *FsCloudPickUpModel // fs_cloud_pick_up 云仓提货单 - FsCloudPickUpDetail *FsCloudPickUpDetailModel // fs_cloud_pick_up_detail 云仓提货单-详情 - FsCloudReceive *FsCloudReceiveModel // fs_cloud_receive 云仓接收工厂总单 - FsCloudReceiveEvery *FsCloudReceiveEveryModel // fs_cloud_receive_every - FsCloudRenderLog *FsCloudRenderLogModel // fs_cloud_render_log 云渲染日志表 - FsCloudUserApplyBack *FsCloudUserApplyBackModel // fs_cloud_user_apply_back 该表废弃 - FsContact *FsContactModel // fs_contact 该表暂未使用 - FsContactService *FsContactServiceModel // fs_contact_service - FsCoupon *FsCouponModel // fs_coupon 代金券(暂未使用) - FsDeliver *FsDeliverModel // fs_deliver 发货表 云仓 直发 通用(已废弃) - FsDeliverEvery *FsDeliverEveryModel // fs_deliver_every 发货详细表(已废弃) - FsDepartment *FsDepartmentModel // fs_department 部门表 - FsEmailLogs *FsEmailLogsModel // fs_email_logs 邮件日志表 - FsEmailTemplate *FsEmailTemplateModel // fs_email_template 邮件模板表(暂未使用) - FsFactory *FsFactoryModel // fs_factory 该表废弃 - FsFactoryDeliver *FsFactoryDeliverModel // fs_factory_deliver 工厂发货主表(废弃) - FsFactoryDeliverEvery *FsFactoryDeliverEveryModel // fs_factory_deliver_every 该表废弃 - FsFactoryProduct *FsFactoryProductModel // fs_factory_product 工厂生产表(废弃) - FsFactoryShipTmp *FsFactoryShipTmpModel // fs_factory_ship_tmp - FsFaq *FsFaqModel // fs_faq 常见问题 - FsFont *FsFontModel // fs_font 字体配置 - FsGerent *FsGerentModel // fs_gerent 管理员表 - FsGuest *FsGuestModel // fs_guest 游客表 - FsLog *FsLogModel // fs_log 日志表 - FsMapLibrary *FsMapLibraryModel // fs_map_library 贴图库 - FsMenu *FsMenuModel // fs_menu 后台菜单 - FsMerchantCategory *FsMerchantCategoryModel // fs_merchant_category 商户类型表 - FsMigration *FsMigrationModel // fs_migration 版本库 - FsOrder *FsOrderModel // fs_order - FsOrderAffiliate *FsOrderAffiliateModel // fs_order_affiliate 订单附属表-流程控制时间等 - FsOrderDetail *FsOrderDetailModel // fs_order_detail 订单详细表 - FsOrderDetailTemplate *FsOrderDetailTemplateModel // fs_order_detail_template 订单模板详细表 - FsOrderRemark *FsOrderRemarkModel // fs_order_remark 订单备注表 - FsPay *FsPayModel // fs_pay 支付记录 - FsPayEvent *FsPayEventModel // fs_pay_event 支付回调事件日志 - FsProduct *FsProductModel // fs_product 产品表 - FsProductCopy1 *FsProductCopy1Model // fs_product_copy1 产品表 - FsProductDesign *FsProductDesignModel // fs_product_design 产品设计表 - FsProductDesignGather *FsProductDesignGatherModel // fs_product_design_gather - FsProductModel3d *FsProductModel3dModel // fs_product_model3d 产品模型表 - FsProductModel3dLight *FsProductModel3dLightModel // fs_product_model3d_light 模型-灯光组表 - FsProductOption *FsProductOptionModel // fs_product_option 产品选项表(已废弃) - FsProductPrice *FsProductPriceModel // fs_product_price 阶梯价格表 - FsProductRenderDesign *FsProductRenderDesignModel // fs_product_render_design - FsProductScene *FsProductSceneModel // fs_product_scene 产品场景表 - FsProductSize *FsProductSizeModel // fs_product_size 产品尺寸表 - FsProductTagProp *FsProductTagPropModel // fs_product_tag_prop 产品标签相关属性表 - FsProductTemplate *FsProductTemplateModel // fs_product_template 产品模板表(已废弃) - FsProductTemplateBasemap *FsProductTemplateBasemapModel // fs_product_template_basemap 模板底图表 - FsProductTemplateElement *FsProductTemplateElementModel // fs_product_template_element 云渲染配置表 - FsProductTemplateTags *FsProductTemplateTagsModel // fs_product_template_tags 模板标签表 - FsProductTemplateV2 *FsProductTemplateV2Model // fs_product_template_v2 产品-模型-模板表 - FsProductV2Tmp *FsProductV2TmpModel // fs_product_v2_tmp 产品表 - FsQrcode *FsQrcodeModel // fs_qrcode - FsQrcodeLog *FsQrcodeLogModel // fs_qrcode_log 二维码扫描日志 - FsQrcodeSet *FsQrcodeSetModel // fs_qrcode_set 二维码边框配置表 - FsQrcodeUser *FsQrcodeUserModel // fs_qrcode_user 二维码-用户名表 - FsQuotation *FsQuotationModel // fs_quotation 报价单信息表 - FsQuotationProduct *FsQuotationProductModel // fs_quotation_product 报价单产品表 - FsQuotationRemarkTemplate *FsQuotationRemarkTemplateModel // fs_quotation_remark_template 报价单备注模板 - FsQuotationSaler *FsQuotationSalerModel // fs_quotation_saler 报价单业务员表 - FsRefundReason *FsRefundReasonModel // fs_refund_reason - FsResource *FsResourceModel // fs_resource 资源表 - FsResources *FsResourcesModel // fs_resources 资源表 - FsStandardLogo *FsStandardLogoModel // fs_standard_logo 标准logo - FsTags *FsTagsModel // fs_tags 产品分类表 - FsToolLogs *FsToolLogsModel // fs_tool_logs 3d设计工具日志表 - FsToolTemplate *FsToolTemplateModel // fs_tool_template 设计工具模板(废弃) - FsToolUser *FsToolUserModel // fs_tool_user 3d设计工具用户表 - FsTrade *FsTradeModel // fs_trade - FsUser *FsUserModel // fs_user 用户表 - FsUserDesign *FsUserDesignModel // fs_user_design 废弃表 - FsUserInfo *FsUserInfoModel // fs_user_info 用户信息表 - FsUserMaterial *FsUserMaterialModel // fs_user_material 用户素材表 - FsUserStock *FsUserStockModel // fs_user_stock 用户云仓库存 - FsWebSet *FsWebSetModel // fs_web_set 网站配置表 + FsAddress *FsAddressModel // fs_address 用户地址表 + FsAuthAssignment *FsAuthAssignmentModel // fs_auth_assignment 用户角色和权限信息 + FsAuthItem *FsAuthItemModel // fs_auth_item 用户角色和权限信息 + FsAuthItemChild *FsAuthItemChildModel // fs_auth_item_child 角色和权限关系表 + FsAuthRule *FsAuthRuleModel // fs_auth_rule 规则表 + FsBackendUser *FsBackendUserModel // fs_backend_user 管理员表 + FsCanteenProduct *FsCanteenProductModel // fs_canteen_product 餐厅类别产品对应表 + FsCanteenType *FsCanteenTypeModel // fs_canteen_type 餐厅类型表 + FsCard *FsCardModel // fs_card 卡号表 + FsCardGroup *FsCardGroupModel // fs_card_group 卡号分组表 + FsCart *FsCartModel // fs_cart 购物车 + FsChangeCode *FsChangeCodeModel // fs_change_code 忘记密码code表 + FsCloud *FsCloudModel // fs_cloud 云仓表 + FsCloudDeliverEveryTmp *FsCloudDeliverEveryTmpModel // fs_cloud_deliver_every_tmp + FsCloudDeliverTmp *FsCloudDeliverTmpModel // fs_cloud_deliver_tmp + FsCloudPickUp *FsCloudPickUpModel // fs_cloud_pick_up 云仓提货单 + FsCloudPickUpDetail *FsCloudPickUpDetailModel // fs_cloud_pick_up_detail 云仓提货单-详情 + FsCloudReceive *FsCloudReceiveModel // fs_cloud_receive 云仓接收工厂总单 + FsCloudReceiveEvery *FsCloudReceiveEveryModel // fs_cloud_receive_every + FsCloudRenderLog *FsCloudRenderLogModel // fs_cloud_render_log 云渲染日志表 + FsCloudUserApplyBack *FsCloudUserApplyBackModel // fs_cloud_user_apply_back 该表废弃 + FsContact *FsContactModel // fs_contact 该表暂未使用 + FsContactService *FsContactServiceModel // fs_contact_service + FsCoupon *FsCouponModel // fs_coupon 代金券(暂未使用) + FsDeliver *FsDeliverModel // fs_deliver 发货表 云仓 直发 通用(已废弃) + FsDeliverEvery *FsDeliverEveryModel // fs_deliver_every 发货详细表(已废弃) + FsDepartment *FsDepartmentModel // fs_department 部门表 + FsEmailLogs *FsEmailLogsModel // fs_email_logs 邮件日志表 + FsEmailTemplate *FsEmailTemplateModel // fs_email_template 邮件模板表(暂未使用) + FsFactory *FsFactoryModel // fs_factory 该表废弃 + FsFactoryDeliver *FsFactoryDeliverModel // fs_factory_deliver 工厂发货主表(废弃) + FsFactoryDeliverEvery *FsFactoryDeliverEveryModel // fs_factory_deliver_every 该表废弃 + FsFactoryProduct *FsFactoryProductModel // fs_factory_product 工厂生产表(废弃) + FsFactoryShipTmp *FsFactoryShipTmpModel // fs_factory_ship_tmp + FsFaq *FsFaqModel // fs_faq 常见问题 + FsFont *FsFontModel // fs_font 字体配置 + FsGerent *FsGerentModel // fs_gerent 管理员表 + FsGuest *FsGuestModel // fs_guest 游客表 + FsLog *FsLogModel // fs_log 日志表 + FsLogoCartoon *FsLogoCartoonModel // fs_logo_cartoon logo底图表 + FsMapLibrary *FsMapLibraryModel // fs_map_library 贴图库 + FsMenu *FsMenuModel // fs_menu 后台菜单 + FsMerchantCategory *FsMerchantCategoryModel // fs_merchant_category 商户类型表 + FsMigration *FsMigrationModel // fs_migration 版本库 + FsOrder *FsOrderModel // fs_order + FsOrderAffiliate *FsOrderAffiliateModel // fs_order_affiliate 订单附属表-流程控制时间等 + FsOrderDetail *FsOrderDetailModel // fs_order_detail 订单详细表 + FsOrderDetailTemplate *FsOrderDetailTemplateModel // fs_order_detail_template 订单模板详细表 + FsOrderRemark *FsOrderRemarkModel // fs_order_remark 订单备注表 + FsPay *FsPayModel // fs_pay 支付记录 + FsPayEvent *FsPayEventModel // fs_pay_event 支付回调事件日志 + FsProduct *FsProductModel // fs_product 产品表 + FsProductCopy1 *FsProductCopy1Model // fs_product_copy1 产品表 + FsProductDesign *FsProductDesignModel // fs_product_design 产品设计表 + FsProductDesignGather *FsProductDesignGatherModel // fs_product_design_gather + FsProductModel3d *FsProductModel3dModel // fs_product_model3d 产品模型表 + FsProductModel3dLight *FsProductModel3dLightModel // fs_product_model3d_light 模型-灯光组表 + FsProductOption *FsProductOptionModel // fs_product_option 产品选项表(已废弃) + FsProductPrice *FsProductPriceModel // fs_product_price 阶梯价格表 + FsProductRenderDesign *FsProductRenderDesignModel // fs_product_render_design + FsProductScene *FsProductSceneModel // fs_product_scene 产品场景表 + FsProductSize *FsProductSizeModel // fs_product_size 产品尺寸表 + FsProductTagProp *FsProductTagPropModel // fs_product_tag_prop 产品标签相关属性表 + FsProductTemplate *FsProductTemplateModel // fs_product_template 产品模板表(已废弃) + FsProductTemplateBasemap *FsProductTemplateBasemapModel // fs_product_template_basemap 模板底图表 + FsProductTemplateElement *FsProductTemplateElementModel // fs_product_template_element 云渲染配置表 + FsProductTemplateElement0826 *FsProductTemplateElement0826Model // fs_product_template_element_0826 + FsProductTemplateElement22 *FsProductTemplateElement22Model // fs_product_template_element_22 + FsProductTemplateElementBackup1018 *FsProductTemplateElementBackup1018Model // fs_product_template_element_backup1018 + FsProductTemplateElementKongde *FsProductTemplateElementKongdeModel // fs_product_template_element_kongde + FsProductTemplateTags *FsProductTemplateTagsModel // fs_product_template_tags 模板标签表 + FsProductTemplateV2 *FsProductTemplateV2Model // fs_product_template_v2 产品-模型-模板表 + FsProductV2Tmp *FsProductV2TmpModel // fs_product_v2_tmp 产品表 + FsQrcode *FsQrcodeModel // fs_qrcode + FsQrcodeLog *FsQrcodeLogModel // fs_qrcode_log 二维码扫描日志 + FsQrcodeSet *FsQrcodeSetModel // fs_qrcode_set 二维码边框配置表 + FsQrcodeUser *FsQrcodeUserModel // fs_qrcode_user 二维码-用户名表 + FsQuotation *FsQuotationModel // fs_quotation 报价单信息表 + FsQuotationPrice *FsQuotationPriceModel // fs_quotation_price 报价单价格表 + FsQuotationProduct *FsQuotationProductModel // fs_quotation_product 报价单产品表 + FsQuotationRemarkTemplate *FsQuotationRemarkTemplateModel // fs_quotation_remark_template 报价单备注模板 + FsQuotationSaler *FsQuotationSalerModel // fs_quotation_saler 报价单业务员表 + FsQuotationSizeLayout *FsQuotationSizeLayoutModel // fs_quotation_size_layout 产品尺寸排版表 + FsRefundReason *FsRefundReasonModel // fs_refund_reason + FsResource *FsResourceModel // fs_resource 资源表 + FsResources *FsResourcesModel // fs_resources 资源表 + FsStandardLogo *FsStandardLogoModel // fs_standard_logo 标准logo + FsTags *FsTagsModel // fs_tags 产品分类表 + FsToolLogs *FsToolLogsModel // fs_tool_logs 3d设计工具日志表 + FsToolTemplate *FsToolTemplateModel // fs_tool_template 设计工具模板(废弃) + FsToolUser *FsToolUserModel // fs_tool_user 3d设计工具用户表 + FsTrade *FsTradeModel // fs_trade + FsUser *FsUserModel // fs_user 用户表 + FsUserDesign *FsUserDesignModel // fs_user_design 废弃表 + FsUserInfo *FsUserInfoModel // fs_user_info 用户信息表 + FsUserMaterial *FsUserMaterialModel // fs_user_material 用户素材表 + FsUserStock *FsUserStockModel // fs_user_stock 用户云仓库存 + FsWebSet *FsWebSetModel // fs_web_set 网站配置表 } func NewAllModels(gdb *gorm.DB) *AllModelsGen { models := &AllModelsGen{ - FsAddress: NewFsAddressModel(gdb), - FsAuthAssignment: NewFsAuthAssignmentModel(gdb), - FsAuthItem: NewFsAuthItemModel(gdb), - FsAuthItemChild: NewFsAuthItemChildModel(gdb), - FsAuthRule: NewFsAuthRuleModel(gdb), - FsBackendUser: NewFsBackendUserModel(gdb), - FsCanteenProduct: NewFsCanteenProductModel(gdb), - FsCanteenType: NewFsCanteenTypeModel(gdb), - FsCard: NewFsCardModel(gdb), - FsCardGroup: NewFsCardGroupModel(gdb), - FsCart: NewFsCartModel(gdb), - FsChangeCode: NewFsChangeCodeModel(gdb), - FsCloud: NewFsCloudModel(gdb), - FsCloudDeliverEveryTmp: NewFsCloudDeliverEveryTmpModel(gdb), - FsCloudDeliverTmp: NewFsCloudDeliverTmpModel(gdb), - FsCloudPickUp: NewFsCloudPickUpModel(gdb), - FsCloudPickUpDetail: NewFsCloudPickUpDetailModel(gdb), - FsCloudReceive: NewFsCloudReceiveModel(gdb), - FsCloudReceiveEvery: NewFsCloudReceiveEveryModel(gdb), - FsCloudRenderLog: NewFsCloudRenderLogModel(gdb), - FsCloudUserApplyBack: NewFsCloudUserApplyBackModel(gdb), - FsContact: NewFsContactModel(gdb), - FsContactService: NewFsContactServiceModel(gdb), - FsCoupon: NewFsCouponModel(gdb), - FsDeliver: NewFsDeliverModel(gdb), - FsDeliverEvery: NewFsDeliverEveryModel(gdb), - FsDepartment: NewFsDepartmentModel(gdb), - FsEmailLogs: NewFsEmailLogsModel(gdb), - FsEmailTemplate: NewFsEmailTemplateModel(gdb), - FsFactory: NewFsFactoryModel(gdb), - FsFactoryDeliver: NewFsFactoryDeliverModel(gdb), - FsFactoryDeliverEvery: NewFsFactoryDeliverEveryModel(gdb), - FsFactoryProduct: NewFsFactoryProductModel(gdb), - FsFactoryShipTmp: NewFsFactoryShipTmpModel(gdb), - FsFaq: NewFsFaqModel(gdb), - FsFont: NewFsFontModel(gdb), - FsGerent: NewFsGerentModel(gdb), - FsGuest: NewFsGuestModel(gdb), - FsLog: NewFsLogModel(gdb), - FsMapLibrary: NewFsMapLibraryModel(gdb), - FsMenu: NewFsMenuModel(gdb), - FsMerchantCategory: NewFsMerchantCategoryModel(gdb), - FsMigration: NewFsMigrationModel(gdb), - FsOrder: NewFsOrderModel(gdb), - FsOrderAffiliate: NewFsOrderAffiliateModel(gdb), - FsOrderDetail: NewFsOrderDetailModel(gdb), - FsOrderDetailTemplate: NewFsOrderDetailTemplateModel(gdb), - FsOrderRemark: NewFsOrderRemarkModel(gdb), - FsPay: NewFsPayModel(gdb), - FsPayEvent: NewFsPayEventModel(gdb), - FsProduct: NewFsProductModel(gdb), - FsProductCopy1: NewFsProductCopy1Model(gdb), - FsProductDesign: NewFsProductDesignModel(gdb), - FsProductDesignGather: NewFsProductDesignGatherModel(gdb), - FsProductModel3d: NewFsProductModel3dModel(gdb), - FsProductModel3dLight: NewFsProductModel3dLightModel(gdb), - FsProductOption: NewFsProductOptionModel(gdb), - FsProductPrice: NewFsProductPriceModel(gdb), - FsProductRenderDesign: NewFsProductRenderDesignModel(gdb), - FsProductScene: NewFsProductSceneModel(gdb), - FsProductSize: NewFsProductSizeModel(gdb), - FsProductTagProp: NewFsProductTagPropModel(gdb), - FsProductTemplate: NewFsProductTemplateModel(gdb), - FsProductTemplateBasemap: NewFsProductTemplateBasemapModel(gdb), - FsProductTemplateElement: NewFsProductTemplateElementModel(gdb), - FsProductTemplateTags: NewFsProductTemplateTagsModel(gdb), - FsProductTemplateV2: NewFsProductTemplateV2Model(gdb), - FsProductV2Tmp: NewFsProductV2TmpModel(gdb), - FsQrcode: NewFsQrcodeModel(gdb), - FsQrcodeLog: NewFsQrcodeLogModel(gdb), - FsQrcodeSet: NewFsQrcodeSetModel(gdb), - FsQrcodeUser: NewFsQrcodeUserModel(gdb), - FsQuotation: NewFsQuotationModel(gdb), - FsQuotationProduct: NewFsQuotationProductModel(gdb), - FsQuotationRemarkTemplate: NewFsQuotationRemarkTemplateModel(gdb), - FsQuotationSaler: NewFsQuotationSalerModel(gdb), - FsRefundReason: NewFsRefundReasonModel(gdb), - FsResource: NewFsResourceModel(gdb), - FsResources: NewFsResourcesModel(gdb), - FsStandardLogo: NewFsStandardLogoModel(gdb), - FsTags: NewFsTagsModel(gdb), - FsToolLogs: NewFsToolLogsModel(gdb), - FsToolTemplate: NewFsToolTemplateModel(gdb), - FsToolUser: NewFsToolUserModel(gdb), - FsTrade: NewFsTradeModel(gdb), - FsUser: NewFsUserModel(gdb), - FsUserDesign: NewFsUserDesignModel(gdb), - FsUserInfo: NewFsUserInfoModel(gdb), - FsUserMaterial: NewFsUserMaterialModel(gdb), - FsUserStock: NewFsUserStockModel(gdb), - FsWebSet: NewFsWebSetModel(gdb), + FsAddress: NewFsAddressModel(gdb), + FsAuthAssignment: NewFsAuthAssignmentModel(gdb), + FsAuthItem: NewFsAuthItemModel(gdb), + FsAuthItemChild: NewFsAuthItemChildModel(gdb), + FsAuthRule: NewFsAuthRuleModel(gdb), + FsBackendUser: NewFsBackendUserModel(gdb), + FsCanteenProduct: NewFsCanteenProductModel(gdb), + FsCanteenType: NewFsCanteenTypeModel(gdb), + FsCard: NewFsCardModel(gdb), + FsCardGroup: NewFsCardGroupModel(gdb), + FsCart: NewFsCartModel(gdb), + FsChangeCode: NewFsChangeCodeModel(gdb), + FsCloud: NewFsCloudModel(gdb), + FsCloudDeliverEveryTmp: NewFsCloudDeliverEveryTmpModel(gdb), + FsCloudDeliverTmp: NewFsCloudDeliverTmpModel(gdb), + FsCloudPickUp: NewFsCloudPickUpModel(gdb), + FsCloudPickUpDetail: NewFsCloudPickUpDetailModel(gdb), + FsCloudReceive: NewFsCloudReceiveModel(gdb), + FsCloudReceiveEvery: NewFsCloudReceiveEveryModel(gdb), + FsCloudRenderLog: NewFsCloudRenderLogModel(gdb), + FsCloudUserApplyBack: NewFsCloudUserApplyBackModel(gdb), + FsContact: NewFsContactModel(gdb), + FsContactService: NewFsContactServiceModel(gdb), + FsCoupon: NewFsCouponModel(gdb), + FsDeliver: NewFsDeliverModel(gdb), + FsDeliverEvery: NewFsDeliverEveryModel(gdb), + FsDepartment: NewFsDepartmentModel(gdb), + FsEmailLogs: NewFsEmailLogsModel(gdb), + FsEmailTemplate: NewFsEmailTemplateModel(gdb), + FsFactory: NewFsFactoryModel(gdb), + FsFactoryDeliver: NewFsFactoryDeliverModel(gdb), + FsFactoryDeliverEvery: NewFsFactoryDeliverEveryModel(gdb), + FsFactoryProduct: NewFsFactoryProductModel(gdb), + FsFactoryShipTmp: NewFsFactoryShipTmpModel(gdb), + FsFaq: NewFsFaqModel(gdb), + FsFont: NewFsFontModel(gdb), + FsGerent: NewFsGerentModel(gdb), + FsGuest: NewFsGuestModel(gdb), + FsLog: NewFsLogModel(gdb), + FsLogoCartoon: NewFsLogoCartoonModel(gdb), + FsMapLibrary: NewFsMapLibraryModel(gdb), + FsMenu: NewFsMenuModel(gdb), + FsMerchantCategory: NewFsMerchantCategoryModel(gdb), + FsMigration: NewFsMigrationModel(gdb), + FsOrder: NewFsOrderModel(gdb), + FsOrderAffiliate: NewFsOrderAffiliateModel(gdb), + FsOrderDetail: NewFsOrderDetailModel(gdb), + FsOrderDetailTemplate: NewFsOrderDetailTemplateModel(gdb), + FsOrderRemark: NewFsOrderRemarkModel(gdb), + FsPay: NewFsPayModel(gdb), + FsPayEvent: NewFsPayEventModel(gdb), + FsProduct: NewFsProductModel(gdb), + FsProductCopy1: NewFsProductCopy1Model(gdb), + FsProductDesign: NewFsProductDesignModel(gdb), + FsProductDesignGather: NewFsProductDesignGatherModel(gdb), + FsProductModel3d: NewFsProductModel3dModel(gdb), + FsProductModel3dLight: NewFsProductModel3dLightModel(gdb), + FsProductOption: NewFsProductOptionModel(gdb), + FsProductPrice: NewFsProductPriceModel(gdb), + FsProductRenderDesign: NewFsProductRenderDesignModel(gdb), + FsProductScene: NewFsProductSceneModel(gdb), + FsProductSize: NewFsProductSizeModel(gdb), + FsProductTagProp: NewFsProductTagPropModel(gdb), + FsProductTemplate: NewFsProductTemplateModel(gdb), + FsProductTemplateBasemap: NewFsProductTemplateBasemapModel(gdb), + FsProductTemplateElement: NewFsProductTemplateElementModel(gdb), + FsProductTemplateElement0826: NewFsProductTemplateElement0826Model(gdb), + FsProductTemplateElement22: NewFsProductTemplateElement22Model(gdb), + FsProductTemplateElementBackup1018: NewFsProductTemplateElementBackup1018Model(gdb), + FsProductTemplateElementKongde: NewFsProductTemplateElementKongdeModel(gdb), + FsProductTemplateTags: NewFsProductTemplateTagsModel(gdb), + FsProductTemplateV2: NewFsProductTemplateV2Model(gdb), + FsProductV2Tmp: NewFsProductV2TmpModel(gdb), + FsQrcode: NewFsQrcodeModel(gdb), + FsQrcodeLog: NewFsQrcodeLogModel(gdb), + FsQrcodeSet: NewFsQrcodeSetModel(gdb), + FsQrcodeUser: NewFsQrcodeUserModel(gdb), + FsQuotation: NewFsQuotationModel(gdb), + FsQuotationPrice: NewFsQuotationPriceModel(gdb), + FsQuotationProduct: NewFsQuotationProductModel(gdb), + FsQuotationRemarkTemplate: NewFsQuotationRemarkTemplateModel(gdb), + FsQuotationSaler: NewFsQuotationSalerModel(gdb), + FsQuotationSizeLayout: NewFsQuotationSizeLayoutModel(gdb), + FsRefundReason: NewFsRefundReasonModel(gdb), + FsResource: NewFsResourceModel(gdb), + FsResources: NewFsResourcesModel(gdb), + FsStandardLogo: NewFsStandardLogoModel(gdb), + FsTags: NewFsTagsModel(gdb), + FsToolLogs: NewFsToolLogsModel(gdb), + FsToolTemplate: NewFsToolTemplateModel(gdb), + FsToolUser: NewFsToolUserModel(gdb), + FsTrade: NewFsTradeModel(gdb), + FsUser: NewFsUserModel(gdb), + FsUserDesign: NewFsUserDesignModel(gdb), + FsUserInfo: NewFsUserInfoModel(gdb), + FsUserMaterial: NewFsUserMaterialModel(gdb), + FsUserStock: NewFsUserStockModel(gdb), + FsWebSet: NewFsWebSetModel(gdb), } return models } diff --git a/server/product/internal/logic/getfittingbypidlogic.go b/server/product/internal/logic/getfittingbypidlogic.go index fb7a6bce..234d52d6 100644 --- a/server/product/internal/logic/getfittingbypidlogic.go +++ b/server/product/internal/logic/getfittingbypidlogic.go @@ -110,7 +110,7 @@ func (l *GetFittingByPidLogic) GetFittingByPid(req *types.GetFittingByPidReq, us Title: *fitting.Title, Price: *fitting.Price, ModelInfo: modelInfo, - IsPopular: *fitting.IsPopular > 0, + IsPopular: *fitting.IsHot > 0, }) } return resp.SetStatusWithMessage(basic.CodeOK, "success", listRsp) From 21db59c507b1060e551d87a238c7eb4ef0bfa18a Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Fri, 18 Aug 2023 11:42:24 +0800 Subject: [PATCH 125/151] fix --- server/product/internal/logic/getfittingbypidlogic.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/product/internal/logic/getfittingbypidlogic.go b/server/product/internal/logic/getfittingbypidlogic.go index 234d52d6..18f76892 100644 --- a/server/product/internal/logic/getfittingbypidlogic.go +++ b/server/product/internal/logic/getfittingbypidlogic.go @@ -73,7 +73,7 @@ func (l *GetFittingByPidLogic) GetFittingByPid(req *types.GetFittingByPidReq, us partIds = append(partIds, *v.PartId) } //获取配件数据 - fittingList, err := l.svcCtx.AllModels.FsProductModel3d.GetAllByIds(l.ctx, partIds, "is_popular DESC,price ASC") + fittingList, err := l.svcCtx.AllModels.FsProductModel3d.GetAllByIds(l.ctx, partIds, "is_hot DESC,price ASC") if err != nil { logx.Error(err) return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get part list") From 6036b23386215e149ae58c6945b700b5b51632e0 Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Fri, 18 Aug 2023 11:43:50 +0800 Subject: [PATCH 126/151] fix --- server/product/internal/logic/getsizebypidlogic.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/product/internal/logic/getsizebypidlogic.go b/server/product/internal/logic/getsizebypidlogic.go index 55a0471c..77d6cbac 100644 --- a/server/product/internal/logic/getsizebypidlogic.go +++ b/server/product/internal/logic/getsizebypidlogic.go @@ -118,7 +118,7 @@ func (l *GetSizeByPidLogic) GetSizeByPid(req *types.GetSizeByPidReq, userinfo *a Cover: *sizeInfo.Cover, PartsCanDeleted: *sizeInfo.PartsCanDeleted > 0, ModelId: modelList[modelIndex].Id, - IsPopular: *sizeInfo.IsPopular > 0, + IsPopular: *sizeInfo.IsHot > 0, MinPrice: float64(minPrice) / 100, }) } From d0692bbf88b7697b2d2024d39effb96830335bd3 Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Fri, 18 Aug 2023 12:06:59 +0800 Subject: [PATCH 127/151] fix --- server/product/internal/logic/getsizebypidlogic.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/product/internal/logic/getsizebypidlogic.go b/server/product/internal/logic/getsizebypidlogic.go index 77d6cbac..3f508762 100644 --- a/server/product/internal/logic/getsizebypidlogic.go +++ b/server/product/internal/logic/getsizebypidlogic.go @@ -48,7 +48,7 @@ func (l *GetSizeByPidLogic) GetSizeByPid(req *types.GetSizeByPidReq, userinfo *a return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get product info") } //获取产品尺寸列表(需要正序排序) - sizeList, err := l.svcCtx.AllModels.FsProductSize.GetAllByProductIds(l.ctx, []int64{productInfo.Id}, "is_popular DESC,sort ASC") + sizeList, err := l.svcCtx.AllModels.FsProductSize.GetAllByProductIds(l.ctx, []int64{productInfo.Id}, "is_hot DESC,sort ASC") if err != nil { logx.Error(err) return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get size list") From 1f36e62727388de4de0d1069d7762bd1bfd6d239 Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Fri, 18 Aug 2023 12:18:56 +0800 Subject: [PATCH 128/151] fix --- model/gmodel/fs_product_template_v2_logic.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/model/gmodel/fs_product_template_v2_logic.go b/model/gmodel/fs_product_template_v2_logic.go index cfae7d32..d5364778 100755 --- a/model/gmodel/fs_product_template_v2_logic.go +++ b/model/gmodel/fs_product_template_v2_logic.go @@ -41,7 +41,7 @@ func (t *FsProductTemplateV2Model) FindAllByIdsWithoutStatus(ctx context.Context } func (t *FsProductTemplateV2Model) FindOne(ctx context.Context, id int64) (resp *FsProductTemplateV2, err error) { - err = t.db.WithContext(ctx).Model(&FsProductTemplateV2{}).Where("`id` = ? ", id).Find(&resp).Error + err = t.db.WithContext(ctx).Model(&FsProductTemplateV2{}).Where("`id` = ? ", id).Take(&resp).Error return resp, err } func (t *FsProductTemplateV2Model) FindByParam(ctx context.Context, id int64, modelId int64, fields ...string) (resp *FsProductTemplateV2, err error) { From f8c86b1f03e2deb21759f1fec3f89b09707b2eaf Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Fri, 18 Aug 2023 12:30:53 +0800 Subject: [PATCH 129/151] fix --- .../internal/logic/gettemplatebypidlogic.go | 36 +++++++++++++++---- 1 file changed, 30 insertions(+), 6 deletions(-) diff --git a/server/product/internal/logic/gettemplatebypidlogic.go b/server/product/internal/logic/gettemplatebypidlogic.go index e0d46ac3..b15b7d3b 100644 --- a/server/product/internal/logic/gettemplatebypidlogic.go +++ b/server/product/internal/logic/gettemplatebypidlogic.go @@ -104,17 +104,41 @@ func (l *GetTemplateByPidLogic) GetTemplateByPid(req *types.GetTemplateByPidReq, logx.Error(err) return resp.SetStatusWithMessage(basic.CodeJsonErr, fmt.Sprintf("failed to parse json product template info(may be old data):%d", templateInfo.Id)) } - //后台隐藏/显示信息 - var switchInfo interface{} + //后台隐藏/显示信息(现在下面是写死了) + /*var switchInfo interface{} if templateInfo.SwitchInfo != nil && *templateInfo.SwitchInfo != "" { _ = json.Unmarshal([]byte(*templateInfo.SwitchInfo), &switchInfo) - } + }*/ modelInfo := modelList[modelIndex] mapKey := fmt.Sprintf("_%d", *modelInfo.SizeId) rsp[mapKey] = map[string]interface{}{ - "id": templateInfo.Id, - "material": *templateInfo.MaterialImg, - "material_data": switchInfo, + "id": templateInfo.Id, + "material": *templateInfo.MaterialImg, + "material_data": map[string]interface{}{ + "QRcode": map[string]interface{}{ + "if_show": true, + "text": "二维码", + "default_val": "默认二维码", + }, + "website": map[string]interface{}{ + "if_show": true, + "text": "网站", + "default_val": "默认网站", + }, + "slogan": map[string]interface{}{ + "if_show": true, + "text": "slogan", + "default_val": "默认slogan", + }, + "phone": map[string]interface{}{ + "if_show": true, + "text": "phone", + "default_val": "默认phone", + }, + "logo": map[string]interface{}{ + "material": "/image/logo/aHnT1_rzubdwax_scale.png", + }, + }, } } return resp.SetStatusWithMessage(basic.CodeOK, "success", rsp) From 868f9a4192f485d1cfb35e15d7ec5e9e6178e775 Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Fri, 18 Aug 2023 14:57:21 +0800 Subject: [PATCH 130/151] fix --- server/product/internal/logic/gettemplatebypidlogic.go | 1 + 1 file changed, 1 insertion(+) diff --git a/server/product/internal/logic/gettemplatebypidlogic.go b/server/product/internal/logic/gettemplatebypidlogic.go index b15b7d3b..a96152e2 100644 --- a/server/product/internal/logic/gettemplatebypidlogic.go +++ b/server/product/internal/logic/gettemplatebypidlogic.go @@ -114,6 +114,7 @@ func (l *GetTemplateByPidLogic) GetTemplateByPid(req *types.GetTemplateByPidReq, rsp[mapKey] = map[string]interface{}{ "id": templateInfo.Id, "material": *templateInfo.MaterialImg, + //写死的数据 "material_data": map[string]interface{}{ "QRcode": map[string]interface{}{ "if_show": true, From 4060b5775bda1a170e67eb5ff618a83d68c70c86 Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Fri, 18 Aug 2023 14:59:23 +0800 Subject: [PATCH 131/151] fix --- 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 fada3747..e216707f 100644 --- a/server/websocket/internal/logic/datatransferlogic.go +++ b/server/websocket/internal/logic/datatransferlogic.go @@ -94,7 +94,7 @@ func (l *DataTransferLogic) DataTransfer(w http.ResponseWriter, r *http.Request) ) isAuth, userInfo = l.checkAuth(r) if !isAuth { - time.Sleep(time.Second * 1) //兼容下火狐 + //time.Sleep(time.Second * 1) //兼容下火狐 rsp := websocket_data.DataTransferData{ T: constants.WEBSOCKET_UNAUTH, D: nil, @@ -151,7 +151,7 @@ func (l *DataTransferLogic) setConnPool(conn *websocket.Conn, userInfo auth.User mapConnPool.Store(uniqueId, ws) go func() { //把连接成功消息发回去 - time.Sleep(time.Second * 1) //兼容下火狐 + //time.Sleep(time.Second * 1) //兼容下火狐 ws.sendToOutChan(ws.respondDataFormat(constants.WEBSOCKET_CONNECT_SUCCESS, uniqueId)) }() return ws From a19d526e727f2ea5153bf84a71902cb97d17699e Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Fri, 18 Aug 2023 15:02:08 +0800 Subject: [PATCH 132/151] fix --- 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 e216707f..fada3747 100644 --- a/server/websocket/internal/logic/datatransferlogic.go +++ b/server/websocket/internal/logic/datatransferlogic.go @@ -94,7 +94,7 @@ func (l *DataTransferLogic) DataTransfer(w http.ResponseWriter, r *http.Request) ) isAuth, userInfo = l.checkAuth(r) if !isAuth { - //time.Sleep(time.Second * 1) //兼容下火狐 + time.Sleep(time.Second * 1) //兼容下火狐 rsp := websocket_data.DataTransferData{ T: constants.WEBSOCKET_UNAUTH, D: nil, @@ -151,7 +151,7 @@ func (l *DataTransferLogic) setConnPool(conn *websocket.Conn, userInfo auth.User mapConnPool.Store(uniqueId, ws) go func() { //把连接成功消息发回去 - //time.Sleep(time.Second * 1) //兼容下火狐 + time.Sleep(time.Second * 1) //兼容下火狐 ws.sendToOutChan(ws.respondDataFormat(constants.WEBSOCKET_CONNECT_SUCCESS, uniqueId)) }() return ws From 04982bae1835903d2c92ce5292370ea2a23536e2 Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Fri, 18 Aug 2023 16:03:29 +0800 Subject: [PATCH 133/151] fix --- .../websocket/internal/logic/datatransferlogic.go | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/server/websocket/internal/logic/datatransferlogic.go b/server/websocket/internal/logic/datatransferlogic.go index fada3747..1999b62e 100644 --- a/server/websocket/internal/logic/datatransferlogic.go +++ b/server/websocket/internal/logic/datatransferlogic.go @@ -80,6 +80,9 @@ type wsConnectItem struct { } func (l *DataTransferLogic) DataTransfer(w http.ResponseWriter, r *http.Request) { + token := r.Header.Get("Sec-Websocket-Protocol") + //设置Sec-Websocket-Protocol + upgrade.Subprotocols = []string{token} //升级websocket conn, err := upgrade.Upgrade(w, r, nil) if err != nil { @@ -88,10 +91,11 @@ func (l *DataTransferLogic) DataTransfer(w http.ResponseWriter, r *http.Request) } defer conn.Close() //鉴权不成功后断开 - /*var ( + var ( userInfo *auth.UserInfo isAuth bool ) + fmt.Println("###################:", r.Header) isAuth, userInfo = l.checkAuth(r) if !isAuth { time.Sleep(time.Second * 1) //兼容下火狐 @@ -105,12 +109,12 @@ func (l *DataTransferLogic) DataTransfer(w http.ResponseWriter, r *http.Request) //发送关闭信息 _ = conn.WriteMessage(websocket.CloseMessage, nil) return - }*/ + } // todo user信息是没有的 - var userInfo auth.UserInfo - userInfo.UserId = 39 + /*var userInfo auth.UserInfo + userInfo.UserId = 39*/ //设置连接 - ws := l.setConnPool(conn, userInfo) + ws := l.setConnPool(conn, *userInfo) defer ws.close() //循环读客户端信息 go ws.readLoop() From b8ca7360b1b7098ef3b83f568a3d1f237c38990d Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Fri, 18 Aug 2023 16:15:44 +0800 Subject: [PATCH 134/151] fix --- server/websocket/internal/logic/datatransferlogic.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/server/websocket/internal/logic/datatransferlogic.go b/server/websocket/internal/logic/datatransferlogic.go index 1999b62e..bbba31df 100644 --- a/server/websocket/internal/logic/datatransferlogic.go +++ b/server/websocket/internal/logic/datatransferlogic.go @@ -80,9 +80,9 @@ type wsConnectItem struct { } func (l *DataTransferLogic) DataTransfer(w http.ResponseWriter, r *http.Request) { - token := r.Header.Get("Sec-Websocket-Protocol") + r.Header.Set("Authorization", "Bearer "+r.Header.Get("Sec-Websocket-Protocol")) //设置Sec-Websocket-Protocol - upgrade.Subprotocols = []string{token} + upgrade.Subprotocols = []string{r.Header.Get("Sec-Websocket-Protocol")} //升级websocket conn, err := upgrade.Upgrade(w, r, nil) if err != nil { @@ -95,7 +95,6 @@ func (l *DataTransferLogic) DataTransfer(w http.ResponseWriter, r *http.Request) userInfo *auth.UserInfo isAuth bool ) - fmt.Println("###################:", r.Header) isAuth, userInfo = l.checkAuth(r) if !isAuth { time.Sleep(time.Second * 1) //兼容下火狐 @@ -182,6 +181,7 @@ func (l *DataTransferLogic) checkAuth(r *http.Request) (isAuth bool, userInfo *a claims, err := l.svcCtx.ParseJwtToken(r) // 如果解析JWT token出错,则返回未授权的JSON响应并记录错误消息 if err != nil { + logx.Error(err) return false, nil } if claims != nil { @@ -189,6 +189,7 @@ func (l *DataTransferLogic) checkAuth(r *http.Request) (isAuth bool, userInfo *a userInfo, err = auth.GetUserInfoFormMapClaims(claims) // 如果获取用户信息出错,则返回未授权的JSON响应并记录错误消息 if err != nil { + logx.Error(err) return false, nil } //不是登录用户也不是游客 From 62afaeda0772b3caba7a721d147f3514241ac0cd Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Fri, 18 Aug 2023 16:20:45 +0800 Subject: [PATCH 135/151] fix --- server/websocket/internal/logic/datatransferlogic.go | 1 + 1 file changed, 1 insertion(+) diff --git a/server/websocket/internal/logic/datatransferlogic.go b/server/websocket/internal/logic/datatransferlogic.go index bbba31df..3cdd02ba 100644 --- a/server/websocket/internal/logic/datatransferlogic.go +++ b/server/websocket/internal/logic/datatransferlogic.go @@ -80,6 +80,7 @@ type wsConnectItem struct { } func (l *DataTransferLogic) DataTransfer(w http.ResponseWriter, r *http.Request) { + //把子协议携带的token设置到标准token头信息中 r.Header.Set("Authorization", "Bearer "+r.Header.Get("Sec-Websocket-Protocol")) //设置Sec-Websocket-Protocol upgrade.Subprotocols = []string{r.Header.Get("Sec-Websocket-Protocol")} From 2d498a06a0ea797fef76fb611987191bfd517934 Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Fri, 18 Aug 2023 16:21:45 +0800 Subject: [PATCH 136/151] fix --- server/websocket/internal/logic/datatransferlogic.go | 1 + 1 file changed, 1 insertion(+) diff --git a/server/websocket/internal/logic/datatransferlogic.go b/server/websocket/internal/logic/datatransferlogic.go index 3cdd02ba..876a789a 100644 --- a/server/websocket/internal/logic/datatransferlogic.go +++ b/server/websocket/internal/logic/datatransferlogic.go @@ -79,6 +79,7 @@ type wsConnectItem struct { renderProperty renderProperty //扩展云渲染属性 } +// 请求建立连接,升级websocket协议 func (l *DataTransferLogic) DataTransfer(w http.ResponseWriter, r *http.Request) { //把子协议携带的token设置到标准token头信息中 r.Header.Set("Authorization", "Bearer "+r.Header.Get("Sec-Websocket-Protocol")) From 1309473d7b2f6de488a9a684ceaec5d9375b5bcf Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Fri, 18 Aug 2023 16:23:04 +0800 Subject: [PATCH 137/151] fix --- server/websocket/internal/logic/datatransferlogic.go | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/server/websocket/internal/logic/datatransferlogic.go b/server/websocket/internal/logic/datatransferlogic.go index 876a789a..d3725a5b 100644 --- a/server/websocket/internal/logic/datatransferlogic.go +++ b/server/websocket/internal/logic/datatransferlogic.go @@ -99,7 +99,7 @@ func (l *DataTransferLogic) DataTransfer(w http.ResponseWriter, r *http.Request) ) isAuth, userInfo = l.checkAuth(r) if !isAuth { - time.Sleep(time.Second * 1) //兼容下火狐 + time.Sleep(time.Second * 1) //兼容下火狐(直接发回去收不到第一条消息:有待研究) rsp := websocket_data.DataTransferData{ T: constants.WEBSOCKET_UNAUTH, D: nil, @@ -111,9 +111,6 @@ func (l *DataTransferLogic) DataTransfer(w http.ResponseWriter, r *http.Request) _ = conn.WriteMessage(websocket.CloseMessage, nil) return } - // todo user信息是没有的 - /*var userInfo auth.UserInfo - userInfo.UserId = 39*/ //设置连接 ws := l.setConnPool(conn, *userInfo) defer ws.close() @@ -156,7 +153,7 @@ func (l *DataTransferLogic) setConnPool(conn *websocket.Conn, userInfo auth.User mapConnPool.Store(uniqueId, ws) go func() { //把连接成功消息发回去 - time.Sleep(time.Second * 1) //兼容下火狐 + time.Sleep(time.Second * 1) //兼容下火狐(直接发回去收不到第一条消息:有待研究) ws.sendToOutChan(ws.respondDataFormat(constants.WEBSOCKET_CONNECT_SUCCESS, uniqueId)) }() return ws From 05137f3fe5f83105ce98cf6b4ef2528c0d6fdb9b Mon Sep 17 00:00:00 2001 From: Hiven Date: Fri, 18 Aug 2023 16:47:22 +0800 Subject: [PATCH 138/151] =?UTF-8?q?fix:=E4=B8=8A=E4=BC=A0=E5=A4=A7?= =?UTF-8?q?=E5=9B=BE=E9=99=90=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/upload/etc/upload.yaml | 2 +- server/upload/internal/handler/routes.go | 5 +++ .../handler/uploadlogostandardhandler.go | 35 +++++++++++++++ .../upload/internal/logic/uploadlogologic.go | 14 +++--- .../internal/logic/uploadlogostandardlogic.go | 43 +++++++++++++++++++ server/upload/internal/types/types.go | 8 ++++ server_api/upload.api | 13 ++++++ service/repositories/image_handle.go | 20 +++++++++ 8 files changed, 132 insertions(+), 8 deletions(-) create mode 100644 server/upload/internal/handler/uploadlogostandardhandler.go create mode 100644 server/upload/internal/logic/uploadlogostandardlogic.go diff --git a/server/upload/etc/upload.yaml b/server/upload/etc/upload.yaml index 12b42062..a2a2cb4b 100644 --- a/server/upload/etc/upload.yaml +++ b/server/upload/etc/upload.yaml @@ -1,7 +1,7 @@ Name: upload Host: 0.0.0.0 Port: 9912 -Timeout: 15000 #服务超时时间 +Timeout: 150000 #服务超时时间 SourceMysql: "fusentest:XErSYmLELKMnf3Dh@tcp(110.41.19.98:3306)/fusentest" Env: "test" Auth: diff --git a/server/upload/internal/handler/routes.go b/server/upload/internal/handler/routes.go index e33dc5a8..03536a1d 100644 --- a/server/upload/internal/handler/routes.go +++ b/server/upload/internal/handler/routes.go @@ -57,6 +57,11 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { Path: "/api/upload/upload-file-base", Handler: UploadFileBaseHandler(serverCtx), }, + { + Method: http.MethodPost, + Path: "/api/upload/up-standard-logo", + Handler: UploadLogoStandardHandler(serverCtx), + }, }, ) } diff --git a/server/upload/internal/handler/uploadlogostandardhandler.go b/server/upload/internal/handler/uploadlogostandardhandler.go new file mode 100644 index 00000000..813f1978 --- /dev/null +++ b/server/upload/internal/handler/uploadlogostandardhandler.go @@ -0,0 +1,35 @@ +package handler + +import ( + "net/http" + "reflect" + + "fusenapi/utils/basic" + + "fusenapi/server/upload/internal/logic" + "fusenapi/server/upload/internal/svc" + "fusenapi/server/upload/internal/types" +) + +func UploadLogoStandardHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + + var req types.UploadLogoStandardReq + userinfo, err := basic.RequestParse(w, r, svcCtx, &req) + if err != nil { + return + } + + // 创建一个业务逻辑层实例 + l := logic.NewUploadLogoStandardLogic(r.Context(), svcCtx) + + rl := reflect.ValueOf(l) + basic.BeforeLogic(w, r, rl) + + resp := l.UploadLogoStandard(&req, userinfo) + + if !basic.AfterLogic(w, r, rl, resp) { + basic.NormalAfterLogic(w, r, resp) + } + } +} diff --git a/server/upload/internal/logic/uploadlogologic.go b/server/upload/internal/logic/uploadlogologic.go index 0019177a..bd495c61 100644 --- a/server/upload/internal/logic/uploadlogologic.go +++ b/server/upload/internal/logic/uploadlogologic.go @@ -152,29 +152,29 @@ func (l *UploadLogoLogic) UploadLogo(req *types.UploadLogoReq, userinfo *auth.Us var headerData = make(map[string]string, 1) headerData["Content-Type"] = "application/json" - result, err := curl.ApiCall(l.svcCtx.Config.BLMService.ImageProcess.Url, "POST", headerData, strings.NewReader(string(postMapB)), time.Second*20) + result, err := curl.ApiCall(l.svcCtx.Config.BLMService.ImageProcess.Url, "POST", headerData, strings.NewReader(string(postMapB)), time.Minute*5) if err != nil { logx.Error(err) - return resp.SetStatus(basic.CodeFileUploadLogoErr, "service fail") + return resp.SetStatus(basic.CodeFileUploadLogoErr, "service fail 01") } defer result.Body.Close() b, err := io.ReadAll(result.Body) if err != nil { logx.Error(err) - return resp.SetStatus(basic.CodeFileUploadLogoErr, "service fail") + return resp.SetStatus(basic.CodeFileUploadLogoErr, "service fail 02") } if string(b) == "Internal Server Error" { err = errors.New("BLMService fail Internal Server Error") logx.Error(err) - return resp.SetStatus(basic.CodeFileUploadLogoErr, "service fail") + return resp.SetStatus(basic.CodeFileUploadLogoErr, "service fail 03") } 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") + return resp.SetStatus(basic.CodeFileUploadLogoErr, "service fail 04") } if resData != nil { @@ -182,11 +182,11 @@ func (l *UploadLogoLogic) UploadLogo(req *types.UploadLogoReq, userinfo *auth.Us resultStr = resData["data"].(string) } else { logx.Error(err) - return resp.SetStatus(basic.CodeFileUploadLogoErrType, "service fail") + return resp.SetStatus(basic.CodeFileUploadLogoErrType, "service fail 05") } } else { logx.Error(err) - return resp.SetStatus(basic.CodeFileUploadLogoErr, "service fail") + return resp.SetStatus(basic.CodeFileUploadLogoErr, "service fail 06") } } diff --git a/server/upload/internal/logic/uploadlogostandardlogic.go b/server/upload/internal/logic/uploadlogostandardlogic.go new file mode 100644 index 00000000..7f2c3a30 --- /dev/null +++ b/server/upload/internal/logic/uploadlogostandardlogic.go @@ -0,0 +1,43 @@ +package logic + +import ( + "fusenapi/utils/auth" + "fusenapi/utils/basic" + + "context" + + "fusenapi/server/upload/internal/svc" + "fusenapi/server/upload/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type UploadLogoStandardLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewUploadLogoStandardLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UploadLogoStandardLogic { + return &UploadLogoStandardLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +// 处理进入前逻辑w,r +// func (l *UploadLogoStandardLogic) BeforeLogic(w http.ResponseWriter, r *http.Request) { +// } + +// 处理逻辑后 w,r 如:重定向, resp 必须重新处理 +// func (l *UploadLogoStandardLogic) AfterLogic(w http.ResponseWriter, r *http.Request, resp *basic.Response) { +// // httpx.OkJsonCtx(r.Context(), w, resp) +// } + +func (l *UploadLogoStandardLogic) UploadLogoStandard(req *types.UploadLogoStandardReq, userinfo *auth.UserInfo) (resp *basic.Response) { + // 返回值必须调用Set重新返回, resp可以空指针调用 resp.SetStatus(basic.CodeOK, data) + // userinfo 传入值时, 一定不为null + + return resp.SetStatus(basic.CodeOK) +} diff --git a/server/upload/internal/types/types.go b/server/upload/internal/types/types.go index 4a946586..8aa84e78 100644 --- a/server/upload/internal/types/types.go +++ b/server/upload/internal/types/types.go @@ -5,6 +5,14 @@ import ( "fusenapi/utils/basic" ) +type UploadLogoStandardReq struct { + IsRemoveBg string `form:"is_remove_bg"` + LogoFile string `form:"logo_file"` + Width string `form:"width"` + Height string `form:"height"` + Proportion int64 `form:"proportion"` +} + type UploadFileBaseReq struct { ApiType int64 `form:"api_type,options=[1,2],default=1"` // 调用类型:1=对外,2=对内 FileKey string `form:"file_key"` // 上传唯一标识信息 diff --git a/server_api/upload.api b/server_api/upload.api index 85e85433..7aaa9ec0 100644 --- a/server_api/upload.api +++ b/server_api/upload.api @@ -42,8 +42,21 @@ service upload { @handler UploadFileBaseHandler post /api/upload/upload-file-base(UploadFileBaseReq) returns (response); + @handler UploadLogoStandardHandler + post /api/upload/up-standard-logo(UploadLogoStandardReq) returns (response); + } +type ( + UploadLogoStandardReq { + IsRemoveBg string `form:"is_remove_bg"` + LogoFile string `form:"logo_file"` + Width string `form:"width"` + Height string `form:"height"` + Proportion int64 `form:"proportion"` + } +) + type ( UploadFileBaseReq { ApiType int64 `form:"api_type,options=[1,2],default=1"` // 调用类型:1=对外,2=对内 diff --git a/service/repositories/image_handle.go b/service/repositories/image_handle.go index 6ff54137..b68c3c98 100644 --- a/service/repositories/image_handle.go +++ b/service/repositories/image_handle.go @@ -37,6 +37,9 @@ type ( // logo合图 LogoCombine(ctx context.Context, in *LogoCombineReq) (*LogoCombineRes, error) + + // logo裁剪 + LogoStandard(ctx context.Context, in *LogoStandardReq) (*LogoStandardRes, error) } ) @@ -225,3 +228,20 @@ func (l *defaultImageHandle) LogoCombine(ctx context.Context, in *LogoCombineReq } /* logo合图 */ +type ( + LogoStandardReq struct { + IsRemoveBg string `json:"is_remove_bg"` + LogoFile string `json:"logo_file"` + Width string `json:"width"` + Height string `json:"height"` + Proportion int64 `json:"proportion"` + } + LogoStandardRes struct{} +) + +/* 图片裁剪 */ +func (l *defaultImageHandle) LogoStandard(ctx context.Context, in *LogoStandardReq) (*LogoStandardRes, error) { + return nil, nil +} + +/* 图片裁剪 */ From 5af797eeaeb31f59077031292c3c7e9c7a827e09 Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Fri, 18 Aug 2023 16:58:30 +0800 Subject: [PATCH 139/151] 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 69cac32f..e0a294ec 100644 --- a/server/websocket/internal/logic/ws_render_image_logic.go +++ b/server/websocket/internal/logic/ws_render_image_logic.go @@ -185,7 +185,7 @@ func (w *wsConnectItem) assembleRenderData(taskId string, info websocket_data.Re logx.Error("合成刀版图失败,合成的刀版图是空指针:", err) return err } - logx.Info("合成刀版图成功,原logo:", info.RenderData.Logo, "刀版图:", *res.ResourceUrl) + logx.Info("合成刀版图成功,模板id:", productTemplate.Id, ",原logo:", info.RenderData.Logo, "刀版图:", *res.ResourceUrl) //获取渲染设置信息 element, err := w.logic.svcCtx.AllModels.FsProductTemplateElement.FindOneByModelId(w.logic.ctx, *productTemplate.ModelId) if err != nil { From 4f1bb51d8f8d3ca2255de9df23d0d9200d5925e8 Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Fri, 18 Aug 2023 17:08:56 +0800 Subject: [PATCH 140/151] fix --- server/websocket/internal/logic/ws_render_image_logic.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/server/websocket/internal/logic/ws_render_image_logic.go b/server/websocket/internal/logic/ws_render_image_logic.go index e0a294ec..f1ef8386 100644 --- a/server/websocket/internal/logic/ws_render_image_logic.go +++ b/server/websocket/internal/logic/ws_render_image_logic.go @@ -164,7 +164,7 @@ func (w *wsConnectItem) assembleRenderData(taskId string, info websocket_data.Re return err } //获取刀版图 - res, err := w.logic.svcCtx.Repositories.ImageHandle.LogoCombine(w.logic.ctx, &repositories.LogoCombineReq{ + combineReq := repositories.LogoCombineReq{ UserId: info.RenderData.UserId, GuestId: info.RenderData.GuestId, TemplateId: productTemplate.Id, @@ -173,7 +173,8 @@ func (w *wsConnectItem) assembleRenderData(taskId string, info websocket_data.Re Slogan: info.RenderData.Slogan, Address: info.RenderData.Address, Phone: info.RenderData.Phone, - }) + } + res, err := w.logic.svcCtx.Repositories.ImageHandle.LogoCombine(w.logic.ctx, &combineReq) if err != nil { logx.Error("合成刀版图失败:", err) return err @@ -185,7 +186,7 @@ func (w *wsConnectItem) assembleRenderData(taskId string, info websocket_data.Re logx.Error("合成刀版图失败,合成的刀版图是空指针:", err) return err } - logx.Info("合成刀版图成功,模板id:", productTemplate.Id, ",原logo:", info.RenderData.Logo, "刀版图:", *res.ResourceUrl) + logx.Info("合成刀版图成功,合成刀版图数据:", combineReq, ",模板id:", productTemplate.Id, ",原logo:", info.RenderData.Logo, "刀版图:", *res.ResourceUrl) //获取渲染设置信息 element, err := w.logic.svcCtx.AllModels.FsProductTemplateElement.FindOneByModelId(w.logic.ctx, *productTemplate.ModelId) if err != nil { From cba012a2b0edc64e95ba5a01581a839cf0957528 Mon Sep 17 00:00:00 2001 From: Hiven Date: Fri, 18 Aug 2023 17:16:49 +0800 Subject: [PATCH 141/151] =?UTF-8?q?fix:=E4=B8=8A=E4=BC=A0=E5=A4=A7?= =?UTF-8?q?=E5=9B=BE=E9=99=90=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- constants/blm_service.go | 3 +- server/resource/etc/resource.yaml | 2 +- service/repositories/image_handle.go | 120 ++++++++++++++++++++------- 3 files changed, 95 insertions(+), 30 deletions(-) diff --git a/constants/blm_service.go b/constants/blm_service.go index d4a36c9e..2e6406e5 100644 --- a/constants/blm_service.go +++ b/constants/blm_service.go @@ -1,5 +1,6 @@ package constants const ( - BLMServiceUrlLogoCombine string = "/LogoCombine" + BLMServiceUrlLogoCombine string = "/LogoCombine" + BLMServiceUrlLogoRemovebg string = "/removebg" ) diff --git a/server/resource/etc/resource.yaml b/server/resource/etc/resource.yaml index 2b9f5737..f2f27737 100644 --- a/server/resource/etc/resource.yaml +++ b/server/resource/etc/resource.yaml @@ -1,7 +1,7 @@ Name: resource Host: 0.0.0.0 Port: 9916 -Timeout: 15000 #服务超时时间(毫秒) +Timeout: 150000 #服务超时时间(毫秒) SourceMysql: fusentest:XErSYmLELKMnf3Dh@tcp(110.41.19.98:3306)/fusentest Auth: AccessSecret: fusen2023 diff --git a/service/repositories/image_handle.go b/service/repositories/image_handle.go index b68c3c98..09eda85f 100644 --- a/service/repositories/image_handle.go +++ b/service/repositories/image_handle.go @@ -4,6 +4,7 @@ import ( "context" "encoding/json" "errors" + "fmt" "fusenapi/constants" "fusenapi/model/gmodel" "fusenapi/utils/curl" @@ -50,11 +51,12 @@ type ( GuestId int64 `json:"guest_id"` TemplateId int64 `json:"template_id"` TemplateTag string `json:"template_tag"` - Website string `json:"website"` // 合图参数 - Slogan string `json:"slogan"` // 合图参数 - Address string `json:"address"` // 合图参数 - Phone string `json:"phone"` // 合图参数 - Qrcode string `json:"qrcode"` // 合图参数 + Website string `json:"website"` // 合图参数 + Slogan string `json:"slogan"` // 合图参数 + Address string `json:"address"` // 合图参数 + Phone string `json:"phone"` // 合图参数 + Qrcode string `json:"qrcode"` // 合图参数 + LogoUrl string `json:"logo_url"` // 合图参数 } LogoCombineRes struct { ResourceId string @@ -64,10 +66,32 @@ type ( ) func (l *defaultImageHandle) LogoCombine(ctx context.Context, in *LogoCombineReq) (*LogoCombineRes, error) { + // 查询logo最新基础信息 + var metadata *string + userMaterialModel := gmodel.NewFsUserMaterialModel(l.MysqlConn) + userMaterialInfo, err := userMaterialModel.FindLatestOne(ctx, in.UserId, in.GuestId) + + if err != nil { + 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 + } + // 根据hash 查询数据资源 var hashKeyData = *in hashKeyData.GuestId = 0 hashKeyData.UserId = 0 + hashKeyData.LogoUrl = *userMaterialInfo.ResourceUrl var resourceId string = hash.JsonHashKey(hashKeyData) resourceModel := gmodel.NewFsResourceModel(l.MysqlConn) @@ -114,27 +138,6 @@ func (l *defaultImageHandle) LogoCombine(ctx context.Context, in *LogoCombineReq moduleDataMap["groupOptions"] = groupOptions moduleDataMap["materialList"] = materialList - // 查询logo最新基础信息 - var metadata *string - userMaterialModel := gmodel.NewFsUserMaterialModel(l.MysqlConn) - userMaterialInfo, err := userMaterialModel.FindLatestOne(ctx, in.UserId, in.GuestId) - - if err != nil { - 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(*metadata), &combineParam) combineParam["template_tagid"] = in.TemplateTag @@ -145,13 +148,14 @@ func (l *defaultImageHandle) LogoCombine(ctx context.Context, in *LogoCombineReq combineParam["qrcode"] = in.Qrcode var postMap = make(map[string]interface{}, 2) + fmt.Println(combineParam) postMap["module_data"] = moduleDataMap postMap["param_data"] = combineParam postMapB, _ := json.Marshal(postMap) var headerData = make(map[string]string, 1) headerData["Content-Type"] = "application/json" - result, err := curl.ApiCall(*l.BLMServiceUrl+constants.BLMServiceUrlLogoCombine, "POST", headerData, strings.NewReader(string(postMapB)), time.Second*20) + result, err := curl.ApiCall(*l.BLMServiceUrl+constants.BLMServiceUrlLogoCombine, "POST", headerData, strings.NewReader(string(postMapB)), time.Minute*5) if err != nil { logx.Error(err) @@ -236,11 +240,71 @@ type ( Height string `json:"height"` Proportion int64 `json:"proportion"` } - LogoStandardRes struct{} + LogoStandardRes struct { + ResourceId string + ResourceUrl string + IsmaxProportion bool + ImgColor []string + } ) /* 图片裁剪 */ func (l *defaultImageHandle) LogoStandard(ctx context.Context, in *LogoStandardReq) (*LogoStandardRes, error) { + var postMap = make(map[string]interface{}, 2) + postMap["is_remove_bg"] = in.IsRemoveBg + postMap["logo_file"] = in.LogoFile + postMap["width"] = in.Width + postMap["height"] = in.Height + postMap["proportion"] = in.Proportion + postMapB, _ := json.Marshal(postMap) + + var headerData = make(map[string]string, 1) + headerData["Content-Type"] = "application/json" + result, err := curl.ApiCall(*l.BLMServiceUrl+constants.BLMServiceUrlLogoRemovebg, "POST", headerData, strings.NewReader(string(postMapB)), time.Minute*5) + if err != nil { + logx.Error(err) + return nil, err + } + defer result.Body.Close() + b, err := io.ReadAll(result.Body) + if err != nil { + logx.Error(err) + return nil, err + } + 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([]byte(resultStr), &resultData) + if err != nil || resultData == nil { + logx.Error(err) + return nil, err + } + //$removeBg ='{"nobg_url": "/test/dIE10gGfXM_scale.png", "thumbnail_url": "/test/dIE10gGfXM_thumbnail.png", "ismax_proportion": true, "img_color": ["#000000", "#EEF5FB", "#6AAFE6", "#9ECDF1", "#298EDC", "#0C7BD1"]}' + return nil, nil } From 8da61f90e4c2719a276c2f8ba315a923fc13c38b Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Fri, 18 Aug 2023 17:33:42 +0800 Subject: [PATCH 142/151] fix --- .../internal/logic/datatransferlogic.go | 36 ++++++++++--------- .../internal/logic/ws_reuse_last_connect.go | 8 ++++- 2 files changed, 26 insertions(+), 18 deletions(-) diff --git a/server/websocket/internal/logic/datatransferlogic.go b/server/websocket/internal/logic/datatransferlogic.go index d3725a5b..6c724f6a 100644 --- a/server/websocket/internal/logic/datatransferlogic.go +++ b/server/websocket/internal/logic/datatransferlogic.go @@ -3,7 +3,6 @@ package logic import ( "bytes" "encoding/json" - "fmt" "fusenapi/constants" "fusenapi/utils/auth" "fusenapi/utils/id_generator" @@ -99,16 +98,8 @@ func (l *DataTransferLogic) DataTransfer(w http.ResponseWriter, r *http.Request) ) isAuth, userInfo = l.checkAuth(r) if !isAuth { - time.Sleep(time.Second * 1) //兼容下火狐(直接发回去收不到第一条消息:有待研究) - rsp := websocket_data.DataTransferData{ - T: constants.WEBSOCKET_UNAUTH, - D: nil, - } - b, _ := json.Marshal(rsp) - //先发一条正常信息 - _ = conn.WriteMessage(websocket.TextMessage, b) - //发送关闭信息 - _ = conn.WriteMessage(websocket.CloseMessage, nil) + //未授权响应消息 + l.unAuthResponse(conn) return } //设置连接 @@ -162,18 +153,13 @@ func (l *DataTransferLogic) setConnPool(conn *websocket.Conn, userInfo auth.User // 获取唯一id func (l *DataTransferLogic) getUniqueId(userInfo auth.UserInfo) string { //后面拼接上用户id - uniqueId := uuid.New().String() + getUserPart(userInfo.UserId, userInfo.GuestId) + uniqueId := uuid.New().String() + getUserJoinPart(userInfo.UserId, userInfo.GuestId) if _, ok := mapConnPool.Load(uniqueId); ok { uniqueId = l.getUniqueId(userInfo) } return uniqueId } -// 获取用户拼接部分 -func getUserPart(userId, guestId int64) string { - return fmt.Sprintf("_%d_%d", userId, guestId) -} - // 鉴权 func (l *DataTransferLogic) checkAuth(r *http.Request) (isAuth bool, userInfo *auth.UserInfo) { // 解析JWT token,并对空用户进行判断 @@ -200,6 +186,22 @@ func (l *DataTransferLogic) checkAuth(r *http.Request) (isAuth bool, userInfo *a return false, nil } +// 鉴权失败通知 +func (l *DataTransferLogic) unAuthResponse(conn *websocket.Conn) { + time.Sleep(time.Second * 1) //兼容下火狐(直接发回去收不到第一条消息:有待研究) + rsp := websocket_data.DataTransferData{ + T: constants.WEBSOCKET_UNAUTH, + D: nil, + } + b, _ := json.Marshal(rsp) + //先发一条正常信息 + _ = conn.WriteMessage(websocket.TextMessage, b) + //发送关闭信息 + _ = conn.WriteMessage(websocket.CloseMessage, nil) + //关闭连接 + conn.Close() +} + // 心跳 func (w *wsConnectItem) heartbeat() { tick := time.Tick(time.Second * 5) diff --git a/server/websocket/internal/logic/ws_reuse_last_connect.go b/server/websocket/internal/logic/ws_reuse_last_connect.go index 8d591a98..b31ee320 100644 --- a/server/websocket/internal/logic/ws_reuse_last_connect.go +++ b/server/websocket/internal/logic/ws_reuse_last_connect.go @@ -2,6 +2,7 @@ package logic import ( "encoding/json" + "fmt" "fusenapi/constants" "github.com/zeromicro/go-zero/core/logx" ) @@ -22,7 +23,7 @@ func (w *wsConnectItem) reuseLastConnect(data []byte) { return } //合成client后缀,不是同个后缀的不能复用 - userPart := getUserPart(w.userId, w.guestId) + userPart := getUserJoinPart(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")) @@ -60,3 +61,8 @@ func (w *wsConnectItem) reuseLastConnect(data []byte) { w.sendToOutChan(rsp) return } + +// 获取用户拼接部分(复用标识用到) +func getUserJoinPart(userId, guestId int64) string { + return fmt.Sprintf("_%d_%d", userId, guestId) +} From fa97e20ae1dc8cc46349b36b5fd5ea1813ffe8eb Mon Sep 17 00:00:00 2001 From: Hiven Date: Fri, 18 Aug 2023 17:38:12 +0800 Subject: [PATCH 143/151] =?UTF-8?q?fix:=E5=9B=BE=E7=89=87=E8=A3=81?= =?UTF-8?q?=E5=89=AA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/resource/etc/resource.yaml | 4 +- .../internal/handler/logoremovebghandler.go | 35 +++++++++++ server/resource/internal/handler/routes.go | 5 ++ .../internal/logic/logoremovebglogic.go | 61 +++++++++++++++++++ server/resource/internal/types/types.go | 8 +++ server_api/resource.api | 13 ++++ service/repositories/image_handle.go | 33 +++++++++- 7 files changed, 156 insertions(+), 3 deletions(-) create mode 100644 server/resource/internal/handler/logoremovebghandler.go create mode 100644 server/resource/internal/logic/logoremovebglogic.go diff --git a/server/resource/etc/resource.yaml b/server/resource/etc/resource.yaml index f2f27737..099a6460 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/resource/internal/handler/logoremovebghandler.go b/server/resource/internal/handler/logoremovebghandler.go new file mode 100644 index 00000000..b68ab38b --- /dev/null +++ b/server/resource/internal/handler/logoremovebghandler.go @@ -0,0 +1,35 @@ +package handler + +import ( + "net/http" + "reflect" + + "fusenapi/utils/basic" + + "fusenapi/server/resource/internal/logic" + "fusenapi/server/resource/internal/svc" + "fusenapi/server/resource/internal/types" +) + +func LogoRemovebgHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + + var req types.LogoRemovebgReq + userinfo, err := basic.RequestParse(w, r, svcCtx, &req) + if err != nil { + return + } + + // 创建一个业务逻辑层实例 + l := logic.NewLogoRemovebgLogic(r.Context(), svcCtx) + + rl := reflect.ValueOf(l) + basic.BeforeLogic(w, r, rl) + + resp := l.LogoRemovebg(&req, userinfo) + + if !basic.AfterLogic(w, r, rl, resp) { + basic.NormalAfterLogic(w, r, resp) + } + } +} diff --git a/server/resource/internal/handler/routes.go b/server/resource/internal/handler/routes.go index 581fdcb1..50884ef8 100644 --- a/server/resource/internal/handler/routes.go +++ b/server/resource/internal/handler/routes.go @@ -17,6 +17,11 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { Path: "/api/resource/logo-combine", Handler: LogoCombineHandler(serverCtx), }, + { + Method: http.MethodPost, + Path: "/api/resource/logo-removebg", + Handler: LogoRemovebgHandler(serverCtx), + }, { Method: http.MethodGet, Path: "/api/resource/info", diff --git a/server/resource/internal/logic/logoremovebglogic.go b/server/resource/internal/logic/logoremovebglogic.go new file mode 100644 index 00000000..6088c9e7 --- /dev/null +++ b/server/resource/internal/logic/logoremovebglogic.go @@ -0,0 +1,61 @@ +package logic + +import ( + "fusenapi/service/repositories" + "fusenapi/utils/auth" + "fusenapi/utils/basic" + + "context" + + "fusenapi/server/resource/internal/svc" + "fusenapi/server/resource/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type LogoRemovebgLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewLogoRemovebgLogic(ctx context.Context, svcCtx *svc.ServiceContext) *LogoRemovebgLogic { + return &LogoRemovebgLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +// 处理进入前逻辑w,r +// func (l *LogoRemovebgLogic) BeforeLogic(w http.ResponseWriter, r *http.Request) { +// } + +// 处理逻辑后 w,r 如:重定向, resp 必须重新处理 +// func (l *LogoRemovebgLogic) AfterLogic(w http.ResponseWriter, r *http.Request, resp *basic.Response) { +// // httpx.OkJsonCtx(r.Context(), w, resp) +// } + +func (l *LogoRemovebgLogic) LogoRemovebg(req *types.LogoRemovebgReq, userinfo *auth.UserInfo) (resp *basic.Response) { + // 返回值必须调用Set重新返回, resp可以空指针调用 resp.SetStatus(basic.CodeOK, data) + // userinfo 传入值时, 一定不为null + res, err := l.svcCtx.Repositories.ImageHandle.LogoStandard(l.ctx, &repositories.LogoStandardReq{ + IsRemoveBg: req.IsRemoveBg, + LogoFile: req.LogoFile, + Width: req.Width, + Height: req.Height, + Proportion: req.Proportion, + }) + + if err != nil { + return resp.SetStatus(basic.CodeServiceErr) + } + + // 返回成功的响应和上传URL + return resp.SetStatus(basic.CodeOK, map[string]interface{}{ + "resource_id": res.ResourceId, + "resource_url": res.ResourceUrl, + "ismax_proportion": res.IsmaxProportion, + "img_color": req.Proportion, + }) +} diff --git a/server/resource/internal/types/types.go b/server/resource/internal/types/types.go index f32c5505..ccf8d112 100644 --- a/server/resource/internal/types/types.go +++ b/server/resource/internal/types/types.go @@ -5,6 +5,14 @@ import ( "fusenapi/utils/basic" ) +type LogoRemovebgReq struct { + IsRemoveBg string `form:"is_remove_bg"` + LogoFile string `form:"logo_file"` + Width string `form:"width"` + Height string `form:"height"` + Proportion int64 `form:"proportion"` +} + type ResourceInfoReq struct { ResourceId string `form:"resource_id,optional"` // 资源ID ResourceKey string `form:"resource_key,optional"` // 资源唯一标识 diff --git a/server_api/resource.api b/server_api/resource.api index 89423498..f78dae89 100644 --- a/server_api/resource.api +++ b/server_api/resource.api @@ -13,10 +13,23 @@ service resource { @handler LogoCombineHandler post /api/resource/logo-combine(LogoCombineReq) returns (response); + @handler LogoRemovebgHandler + post /api/resource/logo-removebg(LogoRemovebgReq) returns (response); + @handler ResourceInfoHandler get /api/resource/info(ResourceInfoReq) returns (response); } +type ( + LogoRemovebgReq { + IsRemoveBg string `form:"is_remove_bg"` + LogoFile string `form:"logo_file"` + Width string `form:"width"` + Height string `form:"height"` + Proportion int64 `form:"proportion"` + } +) + type ( ResourceInfoReq { ResourceId string `form:"resource_id,optional"` // 资源ID diff --git a/service/repositories/image_handle.go b/service/repositories/image_handle.go index 09eda85f..92e20e42 100644 --- a/service/repositories/image_handle.go +++ b/service/repositories/image_handle.go @@ -250,6 +250,7 @@ type ( /* 图片裁剪 */ func (l *defaultImageHandle) LogoStandard(ctx context.Context, in *LogoStandardReq) (*LogoStandardRes, error) { + var resourceId string = hash.JsonHashKey(in) var postMap = make(map[string]interface{}, 2) postMap["is_remove_bg"] = in.IsRemoveBg postMap["logo_file"] = in.LogoFile @@ -305,7 +306,37 @@ func (l *defaultImageHandle) LogoStandard(ctx context.Context, in *LogoStandardR } //$removeBg ='{"nobg_url": "/test/dIE10gGfXM_scale.png", "thumbnail_url": "/test/dIE10gGfXM_thumbnail.png", "ismax_proportion": true, "img_color": ["#000000", "#EEF5FB", "#6AAFE6", "#9ECDF1", "#298EDC", "#0C7BD1"]}' - return nil, nil + var fileBase = resultData["nobg_url"].(string) + var ismaxProportion = resultData["ismax_proportion"].(bool) + + var imgColor []string + for _, v := range resultData["img_color"].([]interface{}) { + imgColor = append(imgColor, v.(string)) + } + + // 上传文件 + var upload = file.Upload{ + Ctx: ctx, + MysqlConn: l.MysqlConn, + AwsSession: l.AwsSession, + } + uploadRes, err := upload.UploadFileByBase64(&file.UploadBaseReq{ + Source: "combine-removebg", + FileHash: resourceId, + FileData: fileBase, + UploadBucket: 1, + ApiType: 2, + }) + if err != nil { + logx.Error(err) + return nil, err + } + return &LogoStandardRes{ + ResourceId: uploadRes.ResourceId, + ResourceUrl: uploadRes.ResourceUrl, + IsmaxProportion: ismaxProportion, + ImgColor: imgColor, + }, nil } /* 图片裁剪 */ From 588b07915b2559fc97f2940b1b34372f22b38155 Mon Sep 17 00:00:00 2001 From: Hiven Date: Fri, 18 Aug 2023 17:41:21 +0800 Subject: [PATCH 144/151] =?UTF-8?q?fix:=E5=9B=BE=E7=89=87=E8=A3=81?= =?UTF-8?q?=E5=89=AA?= 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 099a6460..f2f27737 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 0f576cc3c2c4ad57f8321c9cfcf625ba43c48877 Mon Sep 17 00:00:00 2001 From: Hiven Date: Fri, 18 Aug 2023 17:51:51 +0800 Subject: [PATCH 145/151] =?UTF-8?q?fix:=E5=9B=BE=E7=89=87=E8=A3=81?= =?UTF-8?q?=E5=89=AA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- service/repositories/image_handle.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/service/repositories/image_handle.go b/service/repositories/image_handle.go index 92e20e42..700d89a8 100644 --- a/service/repositories/image_handle.go +++ b/service/repositories/image_handle.go @@ -251,7 +251,7 @@ type ( /* 图片裁剪 */ func (l *defaultImageHandle) LogoStandard(ctx context.Context, in *LogoStandardReq) (*LogoStandardRes, error) { var resourceId string = hash.JsonHashKey(in) - var postMap = make(map[string]interface{}, 2) + var postMap = make(map[string]interface{}, 5) postMap["is_remove_bg"] = in.IsRemoveBg postMap["logo_file"] = in.LogoFile postMap["width"] = in.Width From 5c7d1bb6b0d15999eb5aefcabd67ae78ac292df5 Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Fri, 18 Aug 2023 17:52:19 +0800 Subject: [PATCH 146/151] fix --- server/websocket/internal/logic/datatransferlogic.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/server/websocket/internal/logic/datatransferlogic.go b/server/websocket/internal/logic/datatransferlogic.go index 6c724f6a..b5929a92 100644 --- a/server/websocket/internal/logic/datatransferlogic.go +++ b/server/websocket/internal/logic/datatransferlogic.go @@ -81,9 +81,10 @@ type wsConnectItem struct { // 请求建立连接,升级websocket协议 func (l *DataTransferLogic) DataTransfer(w http.ResponseWriter, r *http.Request) { //把子协议携带的token设置到标准token头信息中 - r.Header.Set("Authorization", "Bearer "+r.Header.Get("Sec-Websocket-Protocol")) + token := r.Header.Get("Sec-Websocket-Protocol") + r.Header.Set("Authorization", "Bearer "+token) //设置Sec-Websocket-Protocol - upgrade.Subprotocols = []string{r.Header.Get("Sec-Websocket-Protocol")} + upgrade.Subprotocols = []string{token} //升级websocket conn, err := upgrade.Upgrade(w, r, nil) if err != nil { From e36f688c03549168ed466938419b01312231671c Mon Sep 17 00:00:00 2001 From: Hiven Date: Fri, 18 Aug 2023 18:27:10 +0800 Subject: [PATCH 147/151] =?UTF-8?q?fix:=E5=9B=BE=E7=89=87=E8=A3=81?= =?UTF-8?q?=E5=89=AA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/resource/internal/logic/logoremovebglogic.go | 2 +- server/upload/etc/upload.yaml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/server/resource/internal/logic/logoremovebglogic.go b/server/resource/internal/logic/logoremovebglogic.go index 6088c9e7..4091c7a0 100644 --- a/server/resource/internal/logic/logoremovebglogic.go +++ b/server/resource/internal/logic/logoremovebglogic.go @@ -56,6 +56,6 @@ func (l *LogoRemovebgLogic) LogoRemovebg(req *types.LogoRemovebgReq, userinfo *a "resource_id": res.ResourceId, "resource_url": res.ResourceUrl, "ismax_proportion": res.IsmaxProportion, - "img_color": req.Proportion, + "img_color": res.ImgColor, }) } diff --git a/server/upload/etc/upload.yaml b/server/upload/etc/upload.yaml index a2a2cb4b..bc7d5b65 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 cefa83e1e2fa7883377ca97d7b8704eae0226d3a Mon Sep 17 00:00:00 2001 From: Hiven Date: Fri, 18 Aug 2023 18:41:51 +0800 Subject: [PATCH 148/151] =?UTF-8?q?fix:=E5=9B=BE=E7=89=87=E8=A3=81?= =?UTF-8?q?=E5=89=AA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- service/repositories/image_handle.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/service/repositories/image_handle.go b/service/repositories/image_handle.go index 700d89a8..2c2af714 100644 --- a/service/repositories/image_handle.go +++ b/service/repositories/image_handle.go @@ -132,6 +132,8 @@ func (l *defaultImageHandle) LogoCombine(ctx context.Context, in *LogoCombineReq groupOptions = templateInfo["groupOptions"].(map[string]interface{}) } + fmt.Println("合图开始时间:", time.Now()) + var moduleDataMap = make(map[string]interface{}, 4) moduleDataMap["id"] = productTemplateV2Info.Id moduleDataMap["material"] = productTemplateV2Info.MaterialImg @@ -199,6 +201,8 @@ func (l *defaultImageHandle) LogoCombine(ctx context.Context, in *LogoCombineReq logx.Error(err) return nil, err } + + fmt.Println("合图结束时间:", time.Now()) // { // id: "", // logo_url:"https://s3.amazon.com/xxxx", From e11d777f18372129856e79b5e43e56f9f167392e Mon Sep 17 00:00:00 2001 From: Hiven Date: Fri, 18 Aug 2023 18:55:56 +0800 Subject: [PATCH 149/151] =?UTF-8?q?fix:=E5=9B=BE=E7=89=87=E8=A3=81?= =?UTF-8?q?=E5=89=AA?= 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 f2f27737..099a6460 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 bc7d5b65..a2a2cb4b 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 eb2012c5d135f542e79072baced53afc6948fc9e Mon Sep 17 00:00:00 2001 From: Hiven Date: Fri, 18 Aug 2023 19:15:34 +0800 Subject: [PATCH 150/151] =?UTF-8?q?fix:=E5=9B=BE=E7=89=87=E8=A3=81?= =?UTF-8?q?=E5=89=AA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- service/repositories/image_handle.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/service/repositories/image_handle.go b/service/repositories/image_handle.go index 2c2af714..d16e8704 100644 --- a/service/repositories/image_handle.go +++ b/service/repositories/image_handle.go @@ -94,6 +94,10 @@ func (l *defaultImageHandle) LogoCombine(ctx context.Context, in *LogoCombineReq hashKeyData.LogoUrl = *userMaterialInfo.ResourceUrl var resourceId string = hash.JsonHashKey(hashKeyData) + fmt.Println("hashKeyData:", hashKeyData) + + fmt.Println("resourceId:", resourceId) + resourceModel := gmodel.NewFsResourceModel(l.MysqlConn) resourceInfo, err := resourceModel.FindOneById(ctx, resourceId) if err == nil && resourceInfo.ResourceId != "" { From 65b2519f5291d02854900d251f64972ecb8390b8 Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Fri, 18 Aug 2023 19:34:18 +0800 Subject: [PATCH 151/151] fix --- server/websocket/internal/logic/ws_render_image_logic.go | 5 ++++- 1 file changed, 4 insertions(+), 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 f1ef8386..5f225038 100644 --- a/server/websocket/internal/logic/ws_render_image_logic.go +++ b/server/websocket/internal/logic/ws_render_image_logic.go @@ -114,7 +114,10 @@ func (w *wsConnectItem) consumeRenderCache(data []byte) { hashVal := renderImageData.RenderData hashVal.UserId = 0 hashVal.GuestId = 0 - taskId := hash.JsonHashKey(hashVal) + hashByte, _ := json.Marshal(hashVal) + var hashData map[string]interface{} + _ = json.Unmarshal(hashByte, &hashData) + taskId := hash.JsonHashKey(hashData) //查询有没有缓存的资源,有就返回###################### resource, err := w.logic.svcCtx.AllModels.FsResource.FindOneById(w.logic.ctx, taskId) if err != nil {