fix:修复上传
This commit is contained in:
parent
d10f404206
commit
83b0b7f5ab
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
})
|
||||
|
|
|
@ -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,
|
||||
})
|
||||
|
|
|
@ -16,8 +16,7 @@ type UploadFileBaseReq struct {
|
|||
}
|
||||
|
||||
type UploadLogoReq struct {
|
||||
ResourceId string `form:"resource_id"` // 资源ID
|
||||
ResourceUrl string `form:"resource_url"` // 资源URL
|
||||
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
|
||||
|
|
|
@ -58,8 +58,7 @@ type (
|
|||
|
||||
type (
|
||||
UploadLogoReq {
|
||||
ResourceId string `form:"resource_id"` // 资源ID
|
||||
ResourceUrl string `form:"resource_url"` // 资源URL
|
||||
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
|
||||
|
|
Loading…
Reference in New Issue
Block a user