|
@@ -6,6 +6,7 @@ import (
|
|
"github.com/lin-jim-leon/kuaishou"
|
|
"github.com/lin-jim-leon/kuaishou"
|
|
"math/rand"
|
|
"math/rand"
|
|
"strconv"
|
|
"strconv"
|
|
|
|
+ "strings"
|
|
"time"
|
|
"time"
|
|
"youngee_b_api/consts"
|
|
"youngee_b_api/consts"
|
|
"youngee_b_api/db"
|
|
"youngee_b_api/db"
|
|
@@ -216,8 +217,16 @@ func (*product) QueryKuaishouProduct(ctx context.Context, newKuaishouProduct htt
|
|
// 5.1. 主图
|
|
// 5.1. 主图
|
|
var currProductMainPhoto *http_model.ProductPhoto
|
|
var currProductMainPhoto *http_model.ProductPhoto
|
|
rand.Seed(time.Now().UnixNano())
|
|
rand.Seed(time.Now().UnixNano())
|
|
|
|
+ currLastIndex := strings.LastIndex(findKuaishouProductData.KuaishouMainPhoto, "/")
|
|
|
|
+ var currDesiredFileName string
|
|
|
|
+ if currLastIndex != -1 {
|
|
|
|
+ currDesiredFileName = findKuaishouProductData.KuaishouMainPhoto[currLastIndex+1:]
|
|
|
|
+ } else {
|
|
|
|
+ currDesiredFileName = "FileNotFound"
|
|
|
|
+ }
|
|
currProductMainPhoto = &http_model.ProductPhoto{
|
|
currProductMainPhoto = &http_model.ProductPhoto{
|
|
PhotoUrl: findKuaishouProductData.KuaishouMainPhoto,
|
|
PhotoUrl: findKuaishouProductData.KuaishouMainPhoto,
|
|
|
|
+ Name: currDesiredFileName,
|
|
PhotoUid: generateRandomString(10),
|
|
PhotoUid: generateRandomString(10),
|
|
Symbol: 1,
|
|
Symbol: 1,
|
|
}
|
|
}
|
|
@@ -227,8 +236,16 @@ func (*product) QueryKuaishouProduct(ctx context.Context, newKuaishouProduct htt
|
|
for _, url := range findKuaishouProductData.KuaishouCarousePhotoList {
|
|
for _, url := range findKuaishouProductData.KuaishouCarousePhotoList {
|
|
var currProductPhoto *http_model.ProductPhoto
|
|
var currProductPhoto *http_model.ProductPhoto
|
|
rand.Seed(time.Now().UnixNano())
|
|
rand.Seed(time.Now().UnixNano())
|
|
|
|
+ lastIndex := strings.LastIndex(url, "/")
|
|
|
|
+ var desiredFileName string
|
|
|
|
+ if lastIndex != -1 {
|
|
|
|
+ desiredFileName = url[lastIndex+1:]
|
|
|
|
+ } else {
|
|
|
|
+ desiredFileName = "FileNotFound"
|
|
|
|
+ }
|
|
currProductPhoto = &http_model.ProductPhoto{
|
|
currProductPhoto = &http_model.ProductPhoto{
|
|
PhotoUrl: url,
|
|
PhotoUrl: url,
|
|
|
|
+ Name: desiredFileName,
|
|
PhotoUid: generateRandomString(10),
|
|
PhotoUid: generateRandomString(10),
|
|
Symbol: 2,
|
|
Symbol: 2,
|
|
}
|
|
}
|
|
@@ -239,8 +256,16 @@ func (*product) QueryKuaishouProduct(ctx context.Context, newKuaishouProduct htt
|
|
for _, url := range findKuaishouProductData.KuaishouDetailPhotoList {
|
|
for _, url := range findKuaishouProductData.KuaishouDetailPhotoList {
|
|
var currProductPhoto *http_model.ProductPhoto
|
|
var currProductPhoto *http_model.ProductPhoto
|
|
rand.Seed(time.Now().UnixNano())
|
|
rand.Seed(time.Now().UnixNano())
|
|
|
|
+ lastIndex := strings.LastIndex(url, "/")
|
|
|
|
+ var desiredFileName string
|
|
|
|
+ if lastIndex != -1 {
|
|
|
|
+ desiredFileName = url[lastIndex+1:]
|
|
|
|
+ } else {
|
|
|
|
+ desiredFileName = "FileNotFound"
|
|
|
|
+ }
|
|
currProductPhoto = &http_model.ProductPhoto{
|
|
currProductPhoto = &http_model.ProductPhoto{
|
|
PhotoUrl: url,
|
|
PhotoUrl: url,
|
|
|
|
+ Name: desiredFileName,
|
|
PhotoUid: generateRandomString(10),
|
|
PhotoUid: generateRandomString(10),
|
|
Symbol: 4,
|
|
Symbol: 4,
|
|
}
|
|
}
|