fix
This commit is contained in:
parent
21b22a3409
commit
0915e98700
@ -12,12 +12,10 @@ import (
|
|||||||
"fusenapi/utils/auth"
|
"fusenapi/utils/auth"
|
||||||
"fusenapi/utils/format"
|
"fusenapi/utils/format"
|
||||||
"fusenapi/utils/image"
|
"fusenapi/utils/image"
|
||||||
|
"github.com/zeromicro/go-zero/core/logx"
|
||||||
"github.com/zeromicro/go-zero/core/stores/sqlc"
|
"github.com/zeromicro/go-zero/core/stores/sqlc"
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/zeromicro/go-zero/core/logx"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type GetProductListLogic struct {
|
type GetProductListLogic struct {
|
||||||
@ -37,6 +35,7 @@ func NewGetProductListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Ge
|
|||||||
// 获取产品列表
|
// 获取产品列表
|
||||||
func (l *GetProductListLogic) GetProductList(req *types.GetProductListReq, loginInfo auth.UserInfo) (resp *types.Response) {
|
func (l *GetProductListLogic) GetProductList(req *types.GetProductListReq, loginInfo auth.UserInfo) (resp *types.Response) {
|
||||||
resp = &types.Response{}
|
resp = &types.Response{}
|
||||||
|
loginInfo.UserId = 83
|
||||||
//校验前台登录情况
|
//校验前台登录情况
|
||||||
if loginInfo.UserId == 0 {
|
if loginInfo.UserId == 0 {
|
||||||
resp.Set(constants.CODE_UNAUTH, "please sign in")
|
resp.Set(constants.CODE_UNAUTH, "please sign in")
|
||||||
@ -160,31 +159,26 @@ func (l *GetProductListLogic) GetProductList(req *types.GetProductListReq, login
|
|||||||
Id: v.Id,
|
Id: v.Id,
|
||||||
Sn: v.Sn,
|
Sn: v.Sn,
|
||||||
Title: v.Title,
|
Title: v.Title,
|
||||||
Cover: v.Cover,
|
|
||||||
Intro: v.Intro.String,
|
Intro: v.Intro.String,
|
||||||
CoverImg: v.CoverImg,
|
|
||||||
IsEnv: v.IsProtection,
|
IsEnv: v.IsProtection,
|
||||||
IsMicro: v.IsMicrowave,
|
IsMicro: v.IsMicrowave,
|
||||||
SizeNum: uint32(productSizeCount),
|
SizeNum: uint32(productSizeCount),
|
||||||
MiniPrice: format.CentoDollar(minPrice),
|
MiniPrice: format.CentoDollar(minPrice),
|
||||||
}
|
}
|
||||||
if req.Size > 0 {
|
|
||||||
coverSlice := strings.Split(v.Cover, ".")
|
|
||||||
coverImgSlice := strings.Split(v.CoverImg, ".")
|
|
||||||
if req.Size >= 200 {
|
|
||||||
item.Cover = fmt.Sprintf("%s_%d.%s", coverSlice[0], req.Size, coverSlice[1])
|
|
||||||
item.CoverImg = fmt.Sprintf("%s_%d.%s", coverImgSlice[0], req.Size, coverImgSlice[1])
|
|
||||||
}
|
|
||||||
//千人千面处理
|
//千人千面处理
|
||||||
if userInfo.IsThousandFace == 1 {
|
thousandFaceImageFormatReq := image.ThousandFaceImageFormatReq{
|
||||||
v.Cover = ""
|
Size: int(req.Size),
|
||||||
item.CoverDefault = item.CoverImg
|
IsThousandFace: int(userInfo.IsThousandFace),
|
||||||
if req.Size >= 200 {
|
Cover: v.Cover,
|
||||||
item.CoverImg = fmt.Sprintf("%s/test/%d/%d_%d.png?%d", constants.DOMAIN_RENDER_IMG_NAME, userInfo.Id, userInfo.Id, v.Id, time.Now().Unix())
|
CoverImg: v.CoverImg,
|
||||||
item.CoverDefault = fmt.Sprintf("%s_%d.%s", coverImgSlice[0], req.Size, coverImgSlice[1])
|
CoverDefault: v.CoverImg,
|
||||||
}
|
ProductId: v.Id,
|
||||||
}
|
UserInfo: *userInfo,
|
||||||
}
|
}
|
||||||
|
image.ThousandFaceImageFormat(&thousandFaceImageFormatReq)
|
||||||
|
item.Cover = thousandFaceImageFormatReq.Cover
|
||||||
|
item.CoverImg = thousandFaceImageFormatReq.CoverImg
|
||||||
|
item.CoverDefault = thousandFaceImageFormatReq.CoverDefault
|
||||||
itemList = append(itemList, item)
|
itemList = append(itemList, item)
|
||||||
}
|
}
|
||||||
resp.SetWithData(constants.CODE_OK, "success", types.GetProductListRsp{
|
resp.SetWithData(constants.CODE_OK, "success", types.GetProductListRsp{
|
||||||
|
@ -3,7 +3,6 @@ package logic
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
|
||||||
"fusenapi/constants"
|
"fusenapi/constants"
|
||||||
"fusenapi/model"
|
"fusenapi/model"
|
||||||
"fusenapi/product/internal/svc"
|
"fusenapi/product/internal/svc"
|
||||||
@ -12,8 +11,6 @@ import (
|
|||||||
"fusenapi/utils/image"
|
"fusenapi/utils/image"
|
||||||
"github.com/zeromicro/go-zero/core/logx"
|
"github.com/zeromicro/go-zero/core/logx"
|
||||||
"github.com/zeromicro/go-zero/core/stores/sqlx"
|
"github.com/zeromicro/go-zero/core/stores/sqlx"
|
||||||
"strings"
|
|
||||||
"time"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type GetSuccessRecommandLogic struct {
|
type GetSuccessRecommandLogic struct {
|
||||||
@ -74,29 +71,24 @@ func (l *GetSuccessRecommandLogic) GetSuccessRecommand(req *types.GetSuccessReco
|
|||||||
for _, v := range productList {
|
for _, v := range productList {
|
||||||
data := types.GetSuccessRecommandRsp{
|
data := types.GetSuccessRecommandRsp{
|
||||||
Title: v.Title,
|
Title: v.Title,
|
||||||
Cover: v.Cover,
|
|
||||||
CoverImg: v.CoverImg,
|
|
||||||
Sn: v.Sn,
|
Sn: v.Sn,
|
||||||
Id: v.Id,
|
Id: v.Id,
|
||||||
SkuId: 0, //???????
|
SkuId: 0, //???????
|
||||||
|
}
|
||||||
|
//千人千面处理
|
||||||
|
thousandFaceImageFormatReq := image.ThousandFaceImageFormatReq{
|
||||||
|
Size: int(req.Size),
|
||||||
|
IsThousandFace: int(userInfo.IsThousandFace),
|
||||||
|
Cover: v.Cover,
|
||||||
|
CoverImg: v.CoverImg,
|
||||||
CoverDefault: v.CoverImg,
|
CoverDefault: v.CoverImg,
|
||||||
|
ProductId: v.Id,
|
||||||
|
UserInfo: *userInfo,
|
||||||
}
|
}
|
||||||
if req.Size > 0 {
|
image.ThousandFaceImageFormat(&thousandFaceImageFormatReq)
|
||||||
coverImgSlice := strings.Split(v.CoverImg, ".")
|
data.Cover = thousandFaceImageFormatReq.Cover
|
||||||
coverSlice := strings.Split(v.Cover, ".")
|
data.CoverImg = thousandFaceImageFormatReq.CoverImg
|
||||||
if req.Size > 200 {
|
data.CoverDefault = thousandFaceImageFormatReq.CoverDefault
|
||||||
data.Cover = fmt.Sprintf("%s_%d.%s", coverSlice[0], req.Size, coverSlice[1])
|
|
||||||
data.CoverImg = fmt.Sprintf("%s_%d.%s", coverImgSlice[0], req.Size, coverImgSlice[1])
|
|
||||||
}
|
|
||||||
//千人千面
|
|
||||||
if userInfo.IsThousandFace == 1 {
|
|
||||||
data.Cover = ""
|
|
||||||
data.CoverImg = fmt.Sprintf("%s/test/%d/%d_%d.png?%d", constants.DOMAIN_RENDER_IMG_NAME, userInfo.Id, userInfo.Id, v.Id, time.Now().Unix())
|
|
||||||
if req.Size > 200 {
|
|
||||||
data.CoverDefault = fmt.Sprintf("%s_%d.%s", coverImgSlice[0], req.Size, coverImgSlice[1])
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
list = append(list, data)
|
list = append(list, data)
|
||||||
}
|
}
|
||||||
resp.SetWithData(constants.CODE_OK, "success", list)
|
resp.SetWithData(constants.CODE_OK, "success", list)
|
||||||
|
@ -1,11 +1,20 @@
|
|||||||
package image
|
package image
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"fusenapi/constants"
|
||||||
|
"fusenapi/model"
|
||||||
|
"strings"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
// 定义尺寸规则
|
// 定义尺寸规则
|
||||||
var sizeArray = []uint32{1200, 1000, 750, 500, 128}
|
var sizeArray = []uint32{1200, 1000, 750, 500, 128}
|
||||||
|
|
||||||
// 裁剪尺寸阶梯
|
// 裁剪尺寸阶梯
|
||||||
var newSizeArray = []uint32{200, 400, 600, 800}
|
var newSizeArray = []uint32{200, 400, 600, 800}
|
||||||
|
|
||||||
|
// 获取合适尺寸
|
||||||
func GetCurrentSize(clientSize uint32) uint32 {
|
func GetCurrentSize(clientSize uint32) uint32 {
|
||||||
lenNewSize := len(newSizeArray)
|
lenNewSize := len(newSizeArray)
|
||||||
//大于最大尺寸则返回规则最大尺寸
|
//大于最大尺寸则返回规则最大尺寸
|
||||||
@ -23,3 +32,34 @@ func GetCurrentSize(clientSize uint32) uint32 {
|
|||||||
}
|
}
|
||||||
return clientSize
|
return clientSize
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 千人前面图像拼接
|
||||||
|
type ThousandFaceImageFormatReq struct {
|
||||||
|
Size int
|
||||||
|
IsThousandFace int
|
||||||
|
Cover string
|
||||||
|
CoverImg string
|
||||||
|
CoverDefault string
|
||||||
|
ProductId int64
|
||||||
|
UserInfo model.FsUser
|
||||||
|
}
|
||||||
|
|
||||||
|
func ThousandFaceImageFormat(req *ThousandFaceImageFormatReq) {
|
||||||
|
if req.Size > 0 {
|
||||||
|
coverSlice := strings.Split(req.Cover, ".")
|
||||||
|
coverImgSlice := strings.Split(req.CoverImg, ".")
|
||||||
|
if req.Size >= 200 && len(coverSlice) == 2 && len(coverImgSlice) == 2 {
|
||||||
|
req.Cover = fmt.Sprintf("%s_%d.%s", coverSlice[0], req.Size, coverSlice[1])
|
||||||
|
req.CoverImg = fmt.Sprintf("%s_%d.%s", coverImgSlice[0], req.Size, coverImgSlice[1])
|
||||||
|
}
|
||||||
|
//千人千面处理
|
||||||
|
if req.IsThousandFace == 1 {
|
||||||
|
req.Cover = ""
|
||||||
|
req.CoverDefault = req.CoverImg
|
||||||
|
if req.Size >= 200 && len(coverSlice) == 2 && len(coverImgSlice) == 2 {
|
||||||
|
req.CoverImg = fmt.Sprintf("%s/test/%d/%d_%d.png?%d", constants.DOMAIN_RENDER_IMG_NAME, req.UserInfo.Id, req.UserInfo.Id, req.ProductId, time.Now().Unix())
|
||||||
|
req.CoverDefault = fmt.Sprintf("%s_%d.%s", coverImgSlice[0], req.Size, coverImgSlice[1])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user