fix
This commit is contained in:
parent
5bc6f411be
commit
35b02302eb
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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),
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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"`
|
||||
}
|
Loading…
Reference in New Issue
Block a user