Merge branch 'develop' of https://gitee.com/fusenpack/fusenapi into feature/auth
This commit is contained in:
		
						commit
						d7345b577c
					
				@ -1,9 +0,0 @@
 | 
				
			|||||||
package constants
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
type recommend_product int64
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
// 产品详情页推荐产品
 | 
					 | 
				
			||||||
const PRODUCT_DETAIL_RECOMMEND_CATEGORY recommend_product = 1
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
// 主页推荐产品
 | 
					 | 
				
			||||||
const HOME_PAGE_RECOMMEND_CATEGORY recommend_product = 2
 | 
					 | 
				
			||||||
@ -9,7 +9,6 @@ type FsProductRecommend struct {
 | 
				
			|||||||
	Id        int64  `gorm:"primary_key;default:0;auto_increment;" json:"id"` //
 | 
						Id        int64  `gorm:"primary_key;default:0;auto_increment;" json:"id"` //
 | 
				
			||||||
	ProductId *int64 `gorm:"default:0;" json:"product_id"`                    // 产品ID
 | 
						ProductId *int64 `gorm:"default:0;" json:"product_id"`                    // 产品ID
 | 
				
			||||||
	Status    *int64 `gorm:"default:1;" json:"status"`                        // 状态 1正常 0不正常
 | 
						Status    *int64 `gorm:"default:1;" json:"status"`                        // 状态 1正常 0不正常
 | 
				
			||||||
	Category  *int64 `gorm:"default:1;" json:"category"`                      // 推荐类别1:详情推荐 2:列表页推荐
 | 
					 | 
				
			||||||
	Ctime     *int64 `gorm:"default:0;" json:"ctime"`                         // 添加时间
 | 
						Ctime     *int64 `gorm:"default:0;" json:"ctime"`                         // 添加时间
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
type FsProductRecommendModel struct {
 | 
					type FsProductRecommendModel struct {
 | 
				
			||||||
 | 
				
			|||||||
@ -7,10 +7,9 @@ import (
 | 
				
			|||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type GetRecommendProductListReq struct {
 | 
					type GetRecommendProductListReq struct {
 | 
				
			||||||
	Ctx      context.Context
 | 
						Ctx   context.Context
 | 
				
			||||||
	Page     int
 | 
						Page  int
 | 
				
			||||||
	Limit    int
 | 
						Limit int
 | 
				
			||||||
	Category int64 // 0是全部
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (r *FsProductRecommendModel) GetRecommendProductList(req GetRecommendProductListReq) (resp []FsProduct, total int64, err error) {
 | 
					func (r *FsProductRecommendModel) GetRecommendProductList(req GetRecommendProductListReq) (resp []FsProduct, total int64, err error) {
 | 
				
			||||||
@ -19,9 +18,6 @@ func (r *FsProductRecommendModel) GetRecommendProductList(req GetRecommendProduc
 | 
				
			|||||||
		Joins("inner join fs_product as p on r.product_id = p.id").
 | 
							Joins("inner join fs_product as p on r.product_id = p.id").
 | 
				
			||||||
		Where("r.status = ? ", 1).
 | 
							Where("r.status = ? ", 1).
 | 
				
			||||||
		Where("p.is_shelf = ? and p.is_del = ? and p.status = ?", 1, 0, 1)
 | 
							Where("p.is_shelf = ? and p.is_del = ? and p.status = ?", 1, 0, 1)
 | 
				
			||||||
	if req.Category != 0 {
 | 
					 | 
				
			||||||
		db = db.Where("r.category = ?", req.Category)
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	if err = db.Limit(1).Count(&total).Error; err != nil {
 | 
						if err = db.Limit(1).Count(&total).Error; err != nil {
 | 
				
			||||||
		return nil, 0, err
 | 
							return nil, 0, err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
@ -30,24 +26,14 @@ func (r *FsProductRecommendModel) GetRecommendProductList(req GetRecommendProduc
 | 
				
			|||||||
	err = db.Offset(offset).Limit(req.Limit).Find(&resp).Error
 | 
						err = db.Offset(offset).Limit(req.Limit).Find(&resp).Error
 | 
				
			||||||
	return resp, total, err
 | 
						return resp, total, err
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
func (r *FsProductRecommendModel) GetIgnoreRandomRecommendProductList(ctx context.Context, limit int, category int64, idNotInt []int64) (resp []FsProduct, err error) {
 | 
					func (r *FsProductRecommendModel) CreateOrUpdate(ctx context.Context, productId int64, data *FsProductRecommend) error {
 | 
				
			||||||
	err = r.db.WithContext(ctx).Debug().Select("p.*").
 | 
					 | 
				
			||||||
		Table("fs_product_recommend as r").
 | 
					 | 
				
			||||||
		Joins("inner join fs_product as p on r.product_id = p.id").
 | 
					 | 
				
			||||||
		Where("r.product_id not in (?)", idNotInt).
 | 
					 | 
				
			||||||
		Where("r.status = ? ", 1).
 | 
					 | 
				
			||||||
		Where("p.is_shelf = ? and p.is_del = ? and p.status = ?", 1, 0, 1).
 | 
					 | 
				
			||||||
		Where("r.category = ?", category).Order("RAND()").Limit(limit).Find(&resp).Error
 | 
					 | 
				
			||||||
	return resp, err
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
func (r *FsProductRecommendModel) CreateOrUpdate(ctx context.Context, productId int64, category int64, data *FsProductRecommend) error {
 | 
					 | 
				
			||||||
	var info FsProductRecommend
 | 
						var info FsProductRecommend
 | 
				
			||||||
	err := r.db.WithContext(ctx).Model(&FsProductRecommend{}).Where("`product_id` = ? and `category` = ?", productId, category).Take(&info).Error
 | 
						err := r.db.WithContext(ctx).Model(&FsProductRecommend{}).Where("`product_id` = ?", productId).Take(&info).Error
 | 
				
			||||||
	if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {
 | 
						if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {
 | 
				
			||||||
		return err
 | 
							return err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	if info.Id == 0 {
 | 
						if info.Id == 0 {
 | 
				
			||||||
		return r.db.WithContext(ctx).Model(&FsProductRecommend{}).Create(data).Error
 | 
							return r.db.WithContext(ctx).Model(&FsProductRecommend{}).Create(data).Error
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	return r.db.WithContext(ctx).Model(&FsProductRecommend{}).Where("`product_id` = ? and `category` = ?", productId, category).Updates(data).Error
 | 
						return r.db.WithContext(ctx).Model(&FsProductRecommend{}).Where("`product_id` = ?", productId).Updates(data).Error
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										23
									
								
								model/gmodel/fs_product_tag_prop_gen.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										23
									
								
								model/gmodel/fs_product_tag_prop_gen.go
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,23 @@
 | 
				
			|||||||
 | 
					package gmodel
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import (
 | 
				
			||||||
 | 
						"gorm.io/gorm"
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// fs_product_tag_prop 产品标签相关属性表
 | 
				
			||||||
 | 
					type FsProductTagProp struct {
 | 
				
			||||||
 | 
						Id        int64   `gorm:"primary_key;default:0;auto_increment;" json:"id"` // id
 | 
				
			||||||
 | 
						ProductId *int64  `gorm:"default:0;" json:"product_id"`                    // 产品id
 | 
				
			||||||
 | 
						TagId     *int64  `gorm:"default:0;" json:"tag_id"`                        // 模板标签id
 | 
				
			||||||
 | 
						Cover     *string `gorm:"default:'';" json:"cover"`                        //
 | 
				
			||||||
 | 
						Status    *int64  `gorm:"default:1;" json:"status"`                        // 状态
 | 
				
			||||||
 | 
						Ctime     *int64  `gorm:"default:0;" json:"ctime"`                         // 创建时间
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					type FsProductTagPropModel struct {
 | 
				
			||||||
 | 
						db   *gorm.DB
 | 
				
			||||||
 | 
						name string
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func NewFsProductTagPropModel(db *gorm.DB) *FsProductTagPropModel {
 | 
				
			||||||
 | 
						return &FsProductTagPropModel{db: db, name: "fs_product_tag_prop"}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										2
									
								
								model/gmodel/fs_product_tag_prop_logic.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								model/gmodel/fs_product_tag_prop_logic.go
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,2 @@
 | 
				
			|||||||
 | 
					package gmodel
 | 
				
			||||||
 | 
					// TODO: 使用model的属性做你想做的
 | 
				
			||||||
@ -65,6 +65,7 @@ type AllModelsGen struct {
 | 
				
			|||||||
	FsProductRenderDesign     *FsProductRenderDesignModel     // fs_product_render_design
 | 
						FsProductRenderDesign     *FsProductRenderDesignModel     // fs_product_render_design
 | 
				
			||||||
	FsProductScene            *FsProductSceneModel            // fs_product_scene 产品场景表
 | 
						FsProductScene            *FsProductSceneModel            // fs_product_scene 产品场景表
 | 
				
			||||||
	FsProductSize             *FsProductSizeModel             // fs_product_size 产品尺寸表
 | 
						FsProductSize             *FsProductSizeModel             // fs_product_size 产品尺寸表
 | 
				
			||||||
 | 
						FsProductTagProp          *FsProductTagPropModel          // fs_product_tag_prop 产品标签相关属性表
 | 
				
			||||||
	FsProductTemplate         *FsProductTemplateModel         // fs_product_template 产品模板表(已废弃)
 | 
						FsProductTemplate         *FsProductTemplateModel         // fs_product_template 产品模板表(已废弃)
 | 
				
			||||||
	FsProductTemplateBasemap  *FsProductTemplateBasemapModel  // fs_product_template_basemap 模板底图表
 | 
						FsProductTemplateBasemap  *FsProductTemplateBasemapModel  // fs_product_template_basemap 模板底图表
 | 
				
			||||||
	FsProductTemplateElement  *FsProductTemplateElementModel  // fs_product_template_element 云渲染配置表
 | 
						FsProductTemplateElement  *FsProductTemplateElementModel  // fs_product_template_element 云渲染配置表
 | 
				
			||||||
@ -158,6 +159,7 @@ func NewAllModels(gdb *gorm.DB) *AllModelsGen {
 | 
				
			|||||||
		FsProductRenderDesign:     NewFsProductRenderDesignModel(gdb),
 | 
							FsProductRenderDesign:     NewFsProductRenderDesignModel(gdb),
 | 
				
			||||||
		FsProductScene:            NewFsProductSceneModel(gdb),
 | 
							FsProductScene:            NewFsProductSceneModel(gdb),
 | 
				
			||||||
		FsProductSize:             NewFsProductSizeModel(gdb),
 | 
							FsProductSize:             NewFsProductSizeModel(gdb),
 | 
				
			||||||
 | 
							FsProductTagProp:          NewFsProductTagPropModel(gdb),
 | 
				
			||||||
		FsProductTemplate:         NewFsProductTemplateModel(gdb),
 | 
							FsProductTemplate:         NewFsProductTemplateModel(gdb),
 | 
				
			||||||
		FsProductTemplateBasemap:  NewFsProductTemplateBasemapModel(gdb),
 | 
							FsProductTemplateBasemap:  NewFsProductTemplateBasemapModel(gdb),
 | 
				
			||||||
		FsProductTemplateElement:  NewFsProductTemplateElementModel(gdb),
 | 
							FsProductTemplateElement:  NewFsProductTemplateElementModel(gdb),
 | 
				
			||||||
 | 
				
			|||||||
@ -2,7 +2,7 @@ package logic
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
import (
 | 
					import (
 | 
				
			||||||
	"errors"
 | 
						"errors"
 | 
				
			||||||
	"fusenapi/constants"
 | 
						"fusenapi/model/gmodel"
 | 
				
			||||||
	"fusenapi/utils/auth"
 | 
						"fusenapi/utils/auth"
 | 
				
			||||||
	"fusenapi/utils/basic"
 | 
						"fusenapi/utils/basic"
 | 
				
			||||||
	"fusenapi/utils/format"
 | 
						"fusenapi/utils/format"
 | 
				
			||||||
@ -46,15 +46,23 @@ func (l *GetRecommandProductListLogic) GetRecommandProductList(req *types.GetRec
 | 
				
			|||||||
		logx.Error(err)
 | 
							logx.Error(err)
 | 
				
			||||||
		return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get detail product info")
 | 
							return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get detail product info")
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	//随机取产品列表(不包含详情产品)
 | 
						var (
 | 
				
			||||||
	recommendProductList, err := l.svcCtx.AllModels.FsProductRecommend.GetIgnoreRandomRecommendProductList(l.ctx, int(req.Num), int64(constants.PRODUCT_DETAIL_RECOMMEND_CATEGORY), []int64{productInfo.Id})
 | 
							recommendProductList []gmodel.FsProduct
 | 
				
			||||||
	if err != nil {
 | 
						)
 | 
				
			||||||
		logx.Error(err)
 | 
						if productInfo.RecommendProduct != nil && *productInfo.RecommendProduct != "" {
 | 
				
			||||||
		return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get random recommend  list")
 | 
							recommendProductIds, err := format.StrSlicToInt64Slice(strings.Split(*productInfo.RecommendProduct, ","))
 | 
				
			||||||
 | 
							if err != nil {
 | 
				
			||||||
 | 
								logx.Error(err)
 | 
				
			||||||
 | 
								return resp.SetStatusWithMessage(basic.CodeServiceErr, "failed to split recommend product ids")
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							recommendProductList, err = l.svcCtx.AllModels.FsProduct.GetProductListByIds(l.ctx, recommendProductIds, "")
 | 
				
			||||||
 | 
							if err != nil {
 | 
				
			||||||
 | 
								logx.Error(err)
 | 
				
			||||||
 | 
								return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get recommend product list")
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	//需要填充时需要忽略的id
 | 
						//需要填充时需要忽略的id
 | 
				
			||||||
	ignoreProductIds := make([]int64, 0, len(recommendProductList)+1)
 | 
						ignoreProductIds := make([]int64, 0, len(recommendProductList))
 | 
				
			||||||
	ignoreProductIds = append(ignoreProductIds, productInfo.Id)
 | 
					 | 
				
			||||||
	productIds := make([]int64, 0, len(recommendProductList))
 | 
						productIds := make([]int64, 0, len(recommendProductList))
 | 
				
			||||||
	//在合并之前记住推荐的产品
 | 
						//在合并之前记住推荐的产品
 | 
				
			||||||
	mapRecommend := make(map[int64]struct{})
 | 
						mapRecommend := make(map[int64]struct{})
 | 
				
			||||||
 | 
				
			|||||||
@ -363,7 +363,7 @@ func (l *GetTagProductListLogic) getTagProducts(req getTagProductsReq) (productL
 | 
				
			|||||||
		}
 | 
							}
 | 
				
			||||||
		image.ThousandFaceImageFormat(&r)
 | 
							image.ThousandFaceImageFormat(&r)
 | 
				
			||||||
		item.Cover = r.Cover
 | 
							item.Cover = r.Cover
 | 
				
			||||||
		item.CoverDefault = r.CoverDefault
 | 
							item.CoverDefault = nil
 | 
				
			||||||
		//加入分类产品切片
 | 
							//加入分类产品切片
 | 
				
			||||||
		productListRsp = append(productListRsp, item)
 | 
							productListRsp = append(productListRsp, item)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
				
			|||||||
@ -3,7 +3,6 @@ package logic
 | 
				
			|||||||
import (
 | 
					import (
 | 
				
			||||||
	"errors"
 | 
						"errors"
 | 
				
			||||||
	"fmt"
 | 
						"fmt"
 | 
				
			||||||
	"fusenapi/constants"
 | 
					 | 
				
			||||||
	"fusenapi/model/gmodel"
 | 
						"fusenapi/model/gmodel"
 | 
				
			||||||
	"fusenapi/utils/auth"
 | 
						"fusenapi/utils/auth"
 | 
				
			||||||
	"fusenapi/utils/basic"
 | 
						"fusenapi/utils/basic"
 | 
				
			||||||
@ -55,10 +54,9 @@ func (l *HomePageRecommendProductListLogic) HomePageRecommendProductList(req *ty
 | 
				
			|||||||
	)
 | 
						)
 | 
				
			||||||
	//获取列表推荐产品
 | 
						//获取列表推荐产品
 | 
				
			||||||
	recommendProductList, _, err = l.svcCtx.AllModels.FsProductRecommend.GetRecommendProductList(gmodel.GetRecommendProductListReq{
 | 
						recommendProductList, _, err = l.svcCtx.AllModels.FsProductRecommend.GetRecommendProductList(gmodel.GetRecommendProductListReq{
 | 
				
			||||||
		Ctx:      l.ctx,
 | 
							Ctx:   l.ctx,
 | 
				
			||||||
		Page:     1,
 | 
							Page:  1,
 | 
				
			||||||
		Limit:    500, //设置最大500
 | 
							Limit: 500, //设置最大500
 | 
				
			||||||
		Category: int64(constants.HOME_PAGE_RECOMMEND_CATEGORY),
 | 
					 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
	if len(recommendProductList) == 0 {
 | 
						if len(recommendProductList) == 0 {
 | 
				
			||||||
		return resp.SetStatusWithMessage(basic.CodeOK, "success", []interface{}{})
 | 
							return resp.SetStatusWithMessage(basic.CodeOK, "success", []interface{}{})
 | 
				
			||||||
 | 
				
			|||||||
@ -268,15 +268,20 @@ type TagItem struct {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type TagProduct struct {
 | 
					type TagProduct struct {
 | 
				
			||||||
	ProductId           int64  `json:"product_id"`
 | 
						ProductId           int64              `json:"product_id"`
 | 
				
			||||||
	Sn                  string `json:"sn"`
 | 
						Sn                  string             `json:"sn"`
 | 
				
			||||||
	Title               string `json:"title"`
 | 
						Title               string             `json:"title"`
 | 
				
			||||||
	Cover               string `json:"cover"`
 | 
						Cover               string             `json:"cover"`
 | 
				
			||||||
	SizeNum             uint32 `json:"size_num"`
 | 
						SizeNum             uint32             `json:"size_num"`
 | 
				
			||||||
	MinPrice            int64  `json:"min_price"`
 | 
						MinPrice            int64              `json:"min_price"`
 | 
				
			||||||
	CoverDefault        string `json:"cover_default"`
 | 
						CoverDefault        []CoverDefaultItem `json:"cover_default"`
 | 
				
			||||||
	HaveOptionalFitting bool   `json:"have_optional_fitting"`
 | 
						HaveOptionalFitting bool               `json:"have_optional_fitting"`
 | 
				
			||||||
	Recommended         bool   `json:"recommended"`
 | 
						Recommended         bool               `json:"recommended"`
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					type CoverDefaultItem struct {
 | 
				
			||||||
 | 
						Tag   string `json:"tag"`
 | 
				
			||||||
 | 
						Cover string `json:"cover"`
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type GetRenderDesignReq struct {
 | 
					type GetRenderDesignReq struct {
 | 
				
			||||||
 | 
				
			|||||||
@ -16,4 +16,4 @@ AWS:
 | 
				
			|||||||
            Token:
 | 
					            Token:
 | 
				
			||||||
BLMService:
 | 
					BLMService:
 | 
				
			||||||
    ImageProcess:
 | 
					    ImageProcess:
 | 
				
			||||||
        Url: "http://110.41.19.98:8868/removebg"
 | 
					        Url: "http://192.168.1.8:45678/FeatureExtraction"
 | 
				
			||||||
 | 
				
			|||||||
@ -50,18 +50,20 @@ func (l *UploadFileBaseLogic) UploadFileBase(req *types.UploadFileBaseReq, useri
 | 
				
			|||||||
	var guestId int64
 | 
						var guestId int64
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// 检查用户是否是游客
 | 
						// 检查用户是否是游客
 | 
				
			||||||
	if userinfo.IsGuest() {
 | 
						if userinfo != nil {
 | 
				
			||||||
		// 如果是,使用游客ID和游客键名格式
 | 
							if userinfo.IsGuest() {
 | 
				
			||||||
		guestId = userinfo.GuestId
 | 
								// 如果是,使用游客ID和游客键名格式
 | 
				
			||||||
	} else {
 | 
								guestId = userinfo.GuestId
 | 
				
			||||||
		// 否则,使用用户ID和用户键名格式
 | 
							} else {
 | 
				
			||||||
		userId = userinfo.UserId
 | 
								// 否则,使用用户ID和用户键名格式
 | 
				
			||||||
	}
 | 
								userId = userinfo.UserId
 | 
				
			||||||
	if guestId == 0 {
 | 
							}
 | 
				
			||||||
		guestId = req.GuestId
 | 
							if guestId == 0 {
 | 
				
			||||||
	}
 | 
								guestId = req.GuestId
 | 
				
			||||||
	if userId == 0 {
 | 
							}
 | 
				
			||||||
		userId = req.UserId
 | 
							if userId == 0 {
 | 
				
			||||||
 | 
								userId = req.UserId
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// 定义存储桶名称
 | 
						// 定义存储桶名称
 | 
				
			||||||
 | 
				
			|||||||
@ -1,9 +1,13 @@
 | 
				
			|||||||
package logic
 | 
					package logic
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import (
 | 
					import (
 | 
				
			||||||
 | 
						"encoding/json"
 | 
				
			||||||
	"fusenapi/model/gmodel"
 | 
						"fusenapi/model/gmodel"
 | 
				
			||||||
	"fusenapi/utils/auth"
 | 
						"fusenapi/utils/auth"
 | 
				
			||||||
	"fusenapi/utils/basic"
 | 
						"fusenapi/utils/basic"
 | 
				
			||||||
 | 
						"io"
 | 
				
			||||||
 | 
						"net/http"
 | 
				
			||||||
 | 
						"strings"
 | 
				
			||||||
	"time"
 | 
						"time"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	"context"
 | 
						"context"
 | 
				
			||||||
@ -79,47 +83,23 @@ func (l *UploadLogoLogic) UploadLogo(req *types.UploadLogoReq, userinfo *auth.Us
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
	var resultStr string
 | 
						var resultStr string
 | 
				
			||||||
	var err error
 | 
						var err error
 | 
				
			||||||
 | 
						var postMap = make(map[string]interface{}, 1)
 | 
				
			||||||
 | 
						postMap["logo_url"] = req.ResourceUrl
 | 
				
			||||||
 | 
						postMapB, _ := json.Marshal(postMap)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// apiUrl := l.svcCtx.Config.BLMService.ImageProcess.Url
 | 
						contentType := "application/json"
 | 
				
			||||||
	// var onlyScale = true
 | 
						result, err := http.Post(l.svcCtx.Config.BLMService.ImageProcess.Url, contentType, strings.NewReader(string(postMapB)))
 | 
				
			||||||
	// data := url.Values{}
 | 
						if err != nil {
 | 
				
			||||||
	// data.Set("imgurl", req.ResourceUrl)
 | 
							logx.Error(err)
 | 
				
			||||||
	// data.Set("layerwidth", strconv.Itoa(int(logoWidth)))
 | 
							return resp.SetStatus(basic.CodeFileUploadLogoErr, "service fail")
 | 
				
			||||||
	// data.Set("layerheight", strconv.Itoa(int(logoHeight)))
 | 
						}
 | 
				
			||||||
	// data.Set("is_remove_bg", strconv.Itoa(int(req.IsRemoveBg)))
 | 
						defer result.Body.Close()
 | 
				
			||||||
	// data.Set("proportion", strconv.Itoa(int(req.Proportion)))
 | 
						b, err := io.ReadAll(result.Body)
 | 
				
			||||||
	// data.Set("only_scale", fmt.Sprintf("%v", onlyScale))
 | 
						if err != nil {
 | 
				
			||||||
 | 
							logx.Error(err)
 | 
				
			||||||
	// u, err := url.ParseRequestURI(apiUrl)
 | 
							return resp.SetStatus(basic.CodeFileUploadLogoErr, "service fail")
 | 
				
			||||||
	// if err != nil {
 | 
						}
 | 
				
			||||||
	// 	logx.Error(err)
 | 
						resultStr = string(b)
 | 
				
			||||||
	// 	return resp.SetStatus(basic.CodeFileUploadLogoErr, "service fail")
 | 
					 | 
				
			||||||
	// }
 | 
					 | 
				
			||||||
	// u.RawQuery = data.Encode() // URL encode
 | 
					 | 
				
			||||||
	// fmt.Println(u.String())
 | 
					 | 
				
			||||||
	// result, err := http.Get(u.String())
 | 
					 | 
				
			||||||
	// if err != nil {
 | 
					 | 
				
			||||||
	// 	logx.Error(err)
 | 
					 | 
				
			||||||
	// 	return resp.SetStatus(basic.CodeFileUploadLogoErr, "service fail")
 | 
					 | 
				
			||||||
	// }
 | 
					 | 
				
			||||||
	// defer result.Body.Close()
 | 
					 | 
				
			||||||
	// b, err := io.ReadAll(result.Body)
 | 
					 | 
				
			||||||
	// if err != nil {
 | 
					 | 
				
			||||||
	// 	logx.Error(err)
 | 
					 | 
				
			||||||
	// 	return resp.SetStatus(basic.CodeFileUploadLogoErr, "service fail")
 | 
					 | 
				
			||||||
	// }
 | 
					 | 
				
			||||||
	// resultStr = string(b)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	// // 上传图片
 | 
					 | 
				
			||||||
	// var reqs types.UploadFileBaseReq
 | 
					 | 
				
			||||||
	// reqs.ApiType = 2
 | 
					 | 
				
			||||||
	// reqs.UploadBucket = 2
 | 
					 | 
				
			||||||
	// reqs.Metadata = ""
 | 
					 | 
				
			||||||
	// reqs.FileData = ""
 | 
					 | 
				
			||||||
	// reqs.FileKey = ""
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	// // 创建一个业务逻辑层实例
 | 
					 | 
				
			||||||
	// resUpload := NewUploadFileBaseLogic(l.ctx, l.svcCtx).UploadFileBase(&reqs, userinfo)
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	var module = "logo"
 | 
						var module = "logo"
 | 
				
			||||||
	var nowTime = time.Now().Unix()
 | 
						var nowTime = time.Now().Unix()
 | 
				
			||||||
 | 
				
			|||||||
@ -18,7 +18,7 @@ type UploadFileBaseReq struct {
 | 
				
			|||||||
type UploadLogoReq struct {
 | 
					type UploadLogoReq struct {
 | 
				
			||||||
	ResourceId  string `form:"resource_id"`           // 资源ID
 | 
						ResourceId  string `form:"resource_id"`           // 资源ID
 | 
				
			||||||
	ResourceUrl string `form:"resource_url"`          // 资源URL
 | 
						ResourceUrl string `form:"resource_url"`          // 资源URL
 | 
				
			||||||
	IsRemoveBg  int64  `form:"is_remove_bg"`          // 是否要去掉背景
 | 
						IsRemoveBg  int64  `form:"is_remove_bg,optional"` // 是否要去掉背景
 | 
				
			||||||
	Proportion  int64  `form:"proportion,default=60"` // 贴图在模型面板上的比例
 | 
						Proportion  int64  `form:"proportion,default=60"` // 贴图在模型面板上的比例
 | 
				
			||||||
	SkuId       int64  `form:"sku_id,default=0"`      // 模板ID
 | 
						SkuId       int64  `form:"sku_id,default=0"`      // 模板ID
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -317,15 +317,20 @@ type TagItem {
 | 
				
			|||||||
	ChildTagList   []*TagItem    `json:"child_tag_list"`
 | 
						ChildTagList   []*TagItem    `json:"child_tag_list"`
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
type TagProduct {
 | 
					type TagProduct {
 | 
				
			||||||
	ProductId           int64  `json:"product_id"`
 | 
						ProductId int64  `json:"product_id"`
 | 
				
			||||||
	Sn                  string `json:"sn"`
 | 
						Sn        string `json:"sn"`
 | 
				
			||||||
	Title               string `json:"title"`
 | 
						Title     string `json:"title"`
 | 
				
			||||||
	Cover               string `json:"cover"`
 | 
						Cover     string `json:"cover"`
 | 
				
			||||||
	SizeNum             uint32 `json:"size_num"`
 | 
						SizeNum   uint32 `json:"size_num"`
 | 
				
			||||||
	MinPrice            int64  `json:"min_price"`
 | 
						MinPrice  int64  `json:"min_price"`
 | 
				
			||||||
	CoverDefault        string `json:"cover_default"`
 | 
						//彩膜列表
 | 
				
			||||||
	HaveOptionalFitting bool   `json:"have_optional_fitting"`
 | 
						CoverDefault        []CoverDefaultItem `json:"cover_default"`
 | 
				
			||||||
	Recommended         bool   `json:"recommended"`
 | 
						HaveOptionalFitting bool               `json:"have_optional_fitting"`
 | 
				
			||||||
 | 
						Recommended         bool               `json:"recommended"`
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					type CoverDefaultItem {
 | 
				
			||||||
 | 
						Tag   string `json:"tag"`
 | 
				
			||||||
 | 
						Cover string `json:"cover"`
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
//获取云渲染设计方案信息
 | 
					//获取云渲染设计方案信息
 | 
				
			||||||
type GetRenderDesignReq {
 | 
					type GetRenderDesignReq {
 | 
				
			||||||
 | 
				
			|||||||
@ -60,7 +60,7 @@ type (
 | 
				
			|||||||
	UploadLogoReq {
 | 
						UploadLogoReq {
 | 
				
			||||||
		ResourceId  string `form:"resource_id"`           // 资源ID
 | 
							ResourceId  string `form:"resource_id"`           // 资源ID
 | 
				
			||||||
		ResourceUrl string `form:"resource_url"`          // 资源URL
 | 
							ResourceUrl string `form:"resource_url"`          // 资源URL
 | 
				
			||||||
		IsRemoveBg  int64  `form:"is_remove_bg"`          // 是否要去掉背景
 | 
							IsRemoveBg  int64  `form:"is_remove_bg,optional"` // 是否要去掉背景
 | 
				
			||||||
		Proportion  int64  `form:"proportion,default=60"` // 贴图在模型面板上的比例
 | 
							Proportion  int64  `form:"proportion,default=60"` // 贴图在模型面板上的比例
 | 
				
			||||||
		SkuId       int64  `form:"sku_id,default=0"`      // 模板ID
 | 
							SkuId       int64  `form:"sku_id,default=0"`      // 模板ID
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user