Merge branch 'develop' of https://gitee.com/fusenpack/fusenapi into feature/auth
This commit is contained in:
@@ -2,7 +2,7 @@ package logic
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fusenapi/constants"
|
||||
"fusenapi/model/gmodel"
|
||||
"fusenapi/utils/auth"
|
||||
"fusenapi/utils/basic"
|
||||
"fusenapi/utils/format"
|
||||
@@ -46,15 +46,23 @@ func (l *GetRecommandProductListLogic) GetRecommandProductList(req *types.GetRec
|
||||
logx.Error(err)
|
||||
return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get detail product info")
|
||||
}
|
||||
//随机取产品列表(不包含详情产品)
|
||||
recommendProductList, err := l.svcCtx.AllModels.FsProductRecommend.GetIgnoreRandomRecommendProductList(l.ctx, int(req.Num), int64(constants.PRODUCT_DETAIL_RECOMMEND_CATEGORY), []int64{productInfo.Id})
|
||||
if err != nil {
|
||||
logx.Error(err)
|
||||
return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get random recommend list")
|
||||
var (
|
||||
recommendProductList []gmodel.FsProduct
|
||||
)
|
||||
if productInfo.RecommendProduct != nil && *productInfo.RecommendProduct != "" {
|
||||
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
|
||||
ignoreProductIds := make([]int64, 0, len(recommendProductList)+1)
|
||||
ignoreProductIds = append(ignoreProductIds, productInfo.Id)
|
||||
ignoreProductIds := make([]int64, 0, len(recommendProductList))
|
||||
productIds := make([]int64, 0, len(recommendProductList))
|
||||
//在合并之前记住推荐的产品
|
||||
mapRecommend := make(map[int64]struct{})
|
||||
|
||||
@@ -363,7 +363,7 @@ func (l *GetTagProductListLogic) getTagProducts(req getTagProductsReq) (productL
|
||||
}
|
||||
image.ThousandFaceImageFormat(&r)
|
||||
item.Cover = r.Cover
|
||||
item.CoverDefault = r.CoverDefault
|
||||
item.CoverDefault = nil
|
||||
//加入分类产品切片
|
||||
productListRsp = append(productListRsp, item)
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ package logic
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"fusenapi/constants"
|
||||
"fusenapi/model/gmodel"
|
||||
"fusenapi/utils/auth"
|
||||
"fusenapi/utils/basic"
|
||||
@@ -55,10 +54,9 @@ func (l *HomePageRecommendProductListLogic) HomePageRecommendProductList(req *ty
|
||||
)
|
||||
//获取列表推荐产品
|
||||
recommendProductList, _, err = l.svcCtx.AllModels.FsProductRecommend.GetRecommendProductList(gmodel.GetRecommendProductListReq{
|
||||
Ctx: l.ctx,
|
||||
Page: 1,
|
||||
Limit: 500, //设置最大500
|
||||
Category: int64(constants.HOME_PAGE_RECOMMEND_CATEGORY),
|
||||
Ctx: l.ctx,
|
||||
Page: 1,
|
||||
Limit: 500, //设置最大500
|
||||
})
|
||||
if len(recommendProductList) == 0 {
|
||||
return resp.SetStatusWithMessage(basic.CodeOK, "success", []interface{}{})
|
||||
|
||||
@@ -268,15 +268,20 @@ type TagItem struct {
|
||||
}
|
||||
|
||||
type TagProduct struct {
|
||||
ProductId int64 `json:"product_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"`
|
||||
Recommended bool `json:"recommended"`
|
||||
ProductId int64 `json:"product_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"`
|
||||
Recommended bool `json:"recommended"`
|
||||
}
|
||||
|
||||
type CoverDefaultItem struct {
|
||||
Tag string `json:"tag"`
|
||||
Cover string `json:"cover"`
|
||||
}
|
||||
|
||||
type GetRenderDesignReq struct {
|
||||
|
||||
@@ -16,4 +16,4 @@ AWS:
|
||||
Token:
|
||||
BLMService:
|
||||
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
|
||||
|
||||
// 检查用户是否是游客
|
||||
if userinfo.IsGuest() {
|
||||
// 如果是,使用游客ID和游客键名格式
|
||||
guestId = userinfo.GuestId
|
||||
} else {
|
||||
// 否则,使用用户ID和用户键名格式
|
||||
userId = userinfo.UserId
|
||||
}
|
||||
if guestId == 0 {
|
||||
guestId = req.GuestId
|
||||
}
|
||||
if userId == 0 {
|
||||
userId = req.UserId
|
||||
if userinfo != nil {
|
||||
if userinfo.IsGuest() {
|
||||
// 如果是,使用游客ID和游客键名格式
|
||||
guestId = userinfo.GuestId
|
||||
} else {
|
||||
// 否则,使用用户ID和用户键名格式
|
||||
userId = userinfo.UserId
|
||||
}
|
||||
if guestId == 0 {
|
||||
guestId = req.GuestId
|
||||
}
|
||||
if userId == 0 {
|
||||
userId = req.UserId
|
||||
}
|
||||
}
|
||||
|
||||
// 定义存储桶名称
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
package logic
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fusenapi/model/gmodel"
|
||||
"fusenapi/utils/auth"
|
||||
"fusenapi/utils/basic"
|
||||
"io"
|
||||
"net/http"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"context"
|
||||
@@ -79,47 +83,23 @@ func (l *UploadLogoLogic) UploadLogo(req *types.UploadLogoReq, userinfo *auth.Us
|
||||
}
|
||||
var resultStr string
|
||||
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
|
||||
// var onlyScale = true
|
||||
// data := url.Values{}
|
||||
// data.Set("imgurl", req.ResourceUrl)
|
||||
// data.Set("layerwidth", strconv.Itoa(int(logoWidth)))
|
||||
// data.Set("layerheight", strconv.Itoa(int(logoHeight)))
|
||||
// data.Set("is_remove_bg", strconv.Itoa(int(req.IsRemoveBg)))
|
||||
// data.Set("proportion", strconv.Itoa(int(req.Proportion)))
|
||||
// data.Set("only_scale", fmt.Sprintf("%v", onlyScale))
|
||||
|
||||
// u, err := url.ParseRequestURI(apiUrl)
|
||||
// if err != nil {
|
||||
// logx.Error(err)
|
||||
// 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)
|
||||
contentType := "application/json"
|
||||
result, err := http.Post(l.svcCtx.Config.BLMService.ImageProcess.Url, contentType, strings.NewReader(string(postMapB)))
|
||||
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 module = "logo"
|
||||
var nowTime = time.Now().Unix()
|
||||
|
||||
@@ -18,7 +18,7 @@ type UploadFileBaseReq struct {
|
||||
type UploadLogoReq struct {
|
||||
ResourceId string `form:"resource_id"` // 资源ID
|
||||
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"` // 贴图在模型面板上的比例
|
||||
SkuId int64 `form:"sku_id,default=0"` // 模板ID
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user