新增打包脚本,新增商品基础逻辑
This commit is contained in:
parent
b75547f739
commit
3e9263324b
|
|
@ -144,7 +144,7 @@ func DataInit() {
|
||||||
database.Instance().Model(&models.PetGoods{}).Find(&petGoodsList)
|
database.Instance().Model(&models.PetGoods{}).Find(&petGoodsList)
|
||||||
PetGoodsMap = make(map[string][]models.PetGoods)
|
PetGoodsMap = make(map[string][]models.PetGoods)
|
||||||
for _, value := range petGoodsList {
|
for _, value := range petGoodsList {
|
||||||
key := strconv.Itoa(value.Assortment) + strconv.Itoa(value.PetType) + strconv.Itoa(value.Weight)
|
key := strconv.Itoa(value.Assortment) + strconv.Itoa(value.PetType) + strconv.Itoa(value.Weight) + strconv.Itoa(value.Hair)
|
||||||
if _, ok := PetGoodsMap[key]; ok {
|
if _, ok := PetGoodsMap[key]; ok {
|
||||||
PetGoodsMap[key] = append(PetGoodsMap[key], value)
|
PetGoodsMap[key] = append(PetGoodsMap[key], value)
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -4,8 +4,10 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"github.com/kataras/iris/v12"
|
"github.com/kataras/iris/v12"
|
||||||
"github.com/kataras/iris/v12/context"
|
"github.com/kataras/iris/v12/context"
|
||||||
|
"go.uber.org/zap"
|
||||||
"io"
|
"io"
|
||||||
"pet-house.com/core/server/web/web_iris"
|
"pet-house.com/core/server/web/web_iris"
|
||||||
|
"pet-house.com/core/server/zap_server"
|
||||||
"strconv"
|
"strconv"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -44,11 +46,40 @@ func (p DefParty) goodsList() web_iris.Party {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
//先取默认的商品
|
//先取默认的商品
|
||||||
key := "0" + strconv.Itoa(userPetInfo.PetBaseInfo.PetType) + strconv.Itoa(userPetInfo.PetBaseInfo.Size)
|
key := "0" + strconv.Itoa(userPetInfo.PetBaseInfo.PetType) + "0" + "0"
|
||||||
goodsList := getPetGoodsList(key)
|
goodsList := getPetGoodsList(key)
|
||||||
key1 := strconv.Itoa(userPetInfo.PetBaseInfo.Id) + strconv.Itoa(userPetInfo.PetBaseInfo.PetType) + strconv.Itoa(userPetInfo.PetInfo.Weight)
|
key1 := strconv.Itoa(userPetInfo.PetBaseInfo.Id) + strconv.Itoa(userPetInfo.PetBaseInfo.PetType) + strconv.Itoa(userPetInfo.PetInfo.Weight) + "0"
|
||||||
goodsList = append(goodsList, getPetGoodsList(key1)...)
|
goodsList = append(goodsList, getPetGoodsList(key1)...)
|
||||||
Success(ctx, goodsListRequest, GoodsListResponse{goodsList})
|
key2 := strconv.Itoa(userPetInfo.PetBaseInfo.Id) + strconv.Itoa(userPetInfo.PetBaseInfo.PetType) + strconv.Itoa(userPetInfo.PetInfo.Weight) + strconv.Itoa(userPetInfo.PetBaseInfo.Hair)
|
||||||
|
goodsList = append(goodsList, getPetGoodsList(key2)...)
|
||||||
|
key3 := "0" + strconv.Itoa(userPetInfo.PetBaseInfo.PetType) + strconv.Itoa(userPetInfo.PetInfo.Weight) + strconv.Itoa(userPetInfo.PetBaseInfo.Hair)
|
||||||
|
goodsList = append(goodsList, getPetGoodsList(key3)...)
|
||||||
|
key4 := "0" + strconv.Itoa(userPetInfo.PetBaseInfo.PetType) + strconv.Itoa(userPetInfo.PetInfo.Weight) + "0"
|
||||||
|
goodsList = append(goodsList, getPetGoodsList(key4)...)
|
||||||
|
var goodsT1 []GoodsDetail
|
||||||
|
var goodsT2 []GoodsDetail
|
||||||
|
var goodsT3 []GoodsDetail
|
||||||
|
for _, value := range goodsList {
|
||||||
|
if value.GoodsType == 3 {
|
||||||
|
goodsT3 = append(goodsT3, value)
|
||||||
|
}
|
||||||
|
if value.GoodsType == 2 {
|
||||||
|
goodsT2 = append(goodsT2, value)
|
||||||
|
}
|
||||||
|
if value.GoodsType == 1 {
|
||||||
|
goodsT1 = append(goodsT1, value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for index, t2 := range goodsT2 {
|
||||||
|
t2.GoodsSubList = goodsT3
|
||||||
|
goodsT2[index] = t2
|
||||||
|
}
|
||||||
|
for index, t1 := range goodsT1 {
|
||||||
|
t1.GoodsSubList = goodsT2
|
||||||
|
goodsT1[index] = t1
|
||||||
|
}
|
||||||
|
zap_server.ZAPLOG.Info("key", zap.Any("key1", key), zap.Any("key2", key1), zap.Any("key3", key2), zap.Any("key4", key3), zap.Any("key5", key4))
|
||||||
|
Success(ctx, goodsListRequest, GoodsListResponse{goodsT1})
|
||||||
})
|
})
|
||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ var CatWeightMap = map[int]string{
|
||||||
2: "1.5-3kg",
|
2: "1.5-3kg",
|
||||||
3: "3-5kg",
|
3: "3-5kg",
|
||||||
4: "5-8kg",
|
4: "5-8kg",
|
||||||
5: "8kg以上",
|
//5: "8kg以上",
|
||||||
}
|
}
|
||||||
var DogWeightMap = map[int]string{
|
var DogWeightMap = map[int]string{
|
||||||
1: "0-3kg",
|
1: "0-3kg",
|
||||||
|
|
@ -23,8 +23,8 @@ var DogWeightMap = map[int]string{
|
||||||
3: "6-9kg",
|
3: "6-9kg",
|
||||||
4: "9-13kg",
|
4: "9-13kg",
|
||||||
5: "13-18kg",
|
5: "13-18kg",
|
||||||
6: "18-22kg",
|
//6: "18-22kg",
|
||||||
7: "22-30kg",
|
//7: "22-30kg",
|
||||||
}
|
}
|
||||||
|
|
||||||
type UserPetInfo struct {
|
type UserPetInfo struct {
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,10 @@
|
||||||
|
#!/bin/bash
|
||||||
|
app_name="petHouseApp"
|
||||||
|
if [ -f "$app_name" ]; then
|
||||||
|
rm "$app_name"
|
||||||
|
fi
|
||||||
|
export GOOS=linux
|
||||||
|
export GOARCH=amd64
|
||||||
|
go clean -cache
|
||||||
|
go build -trimpath -o petHouseApp main.go
|
||||||
|
echo "编译完成"
|
||||||
|
|
@ -45,6 +45,7 @@ type PetBaseInfo struct {
|
||||||
PetType int `gorm:"not null" json:"petType"` //类型 1猫 2狗
|
PetType int `gorm:"not null" json:"petType"` //类型 1猫 2狗
|
||||||
Assortment string `gorm:"not null" json:"assortment"` //品种
|
Assortment string `gorm:"not null" json:"assortment"` //品种
|
||||||
Size int `gorm:"not null" json:"size"` //大小 1大 2中 3小
|
Size int `gorm:"not null" json:"size"` //大小 1大 2中 3小
|
||||||
|
Hair int `gorm:"not null" json:"hair"` //毛发 0未知 1长毛 2短毛
|
||||||
CreateTime time.Time `gorm:"type:timestamp;default:CURRENT_TIMESTAMP" json:"-"` //创建时间
|
CreateTime time.Time `gorm:"type:timestamp;default:CURRENT_TIMESTAMP" json:"-"` //创建时间
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -92,6 +93,7 @@ type PetGoods struct {
|
||||||
PetType int `gorm:"not null" json:"petType"` //类型 1猫 2狗
|
PetType int `gorm:"not null" json:"petType"` //类型 1猫 2狗
|
||||||
Size int `gorm:"not null" json:"size"` //大小 1大 2中 3小
|
Size int `gorm:"not null" json:"size"` //大小 1大 2中 3小
|
||||||
Weight int `gorm:"not null" json:"weight"` //体重
|
Weight int `gorm:"not null" json:"weight"` //体重
|
||||||
|
Hair int `gorm:"not null" json:"hair"` //毛发 0未知 1长毛 2短毛
|
||||||
GoodsId int64 `gorm:"not null" json:"goodsId"` //商品ID
|
GoodsId int64 `gorm:"not null" json:"goodsId"` //商品ID
|
||||||
Sort int `gorm:"not null" json:"sort"` //排序
|
Sort int `gorm:"not null" json:"sort"` //排序
|
||||||
CreateTime time.Time `gorm:"type:timestamp;default:CURRENT_TIMESTAMP" json:"-"` //创建时间
|
CreateTime time.Time `gorm:"type:timestamp;default:CURRENT_TIMESTAMP" json:"-"` //创建时间
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue