fix
This commit is contained in:
parent
6c717ce30e
commit
92b29d8006
7
constants/domain_render_img.go
Normal file
7
constants/domain_render_img.go
Normal file
|
@ -0,0 +1,7 @@
|
|||
package constants
|
||||
|
||||
// 千人千面windows访问图片的地址
|
||||
const DOMAIN_RENDER_IMG_NAME = "https://fusenrenderimg.kayue.cn"
|
||||
|
||||
// 云渲染域名和访问地址
|
||||
const DOMAIN_NAME = "https://fusenapi.kayue.cn:8010/"
|
22
ddl/fs_product_price.sql
Normal file
22
ddl/fs_product_price.sql
Normal file
|
@ -0,0 +1,22 @@
|
|||
-- fusentest.fs_product_price definition
|
||||
|
||||
CREATE TABLE `fs_product_price` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`sn` char(8) NOT NULL COMMENT '唯一编码',
|
||||
`title` varchar(255) NOT NULL COMMENT '标题描述',
|
||||
`product_id` int(11) NOT NULL COMMENT '产品ID',
|
||||
`material_id` int(11) NOT NULL COMMENT '材质ID',
|
||||
`size_id` int(11) NOT NULL COMMENT '尺寸ID',
|
||||
`each_box_num` int(11) NOT NULL COMMENT '每一箱的个数',
|
||||
`each_box_weight` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '每一箱的重量 单位KG',
|
||||
`min_buy_num` int(11) NOT NULL COMMENT '最少购买量',
|
||||
`step_num` varchar(255) NOT NULL COMMENT '数量阶梯 eg:10,20,30',
|
||||
`step_price` varchar(255) NOT NULL COMMENT '价格阶梯 eg:100,50,25',
|
||||
`status` int(11) DEFAULT '1' COMMENT '是否可用',
|
||||
`is_default` tinyint(1) NOT NULL DEFAULT '0' COMMENT '是否默认',
|
||||
PRIMARY KEY (`id`) USING BTREE,
|
||||
UNIQUE KEY `fields_index` (`product_id`,`material_id`,`size_id`) USING BTREE,
|
||||
KEY `product_id` (`product_id`) USING BTREE,
|
||||
KEY `material_id` (`material_id`) USING BTREE,
|
||||
KEY `size_id` (`size_id`) USING BTREE
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=103 DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT COMMENT='阶梯价格表';
|
22
ddl/fs_product_template_v2.sql
Normal file
22
ddl/fs_product_template_v2.sql
Normal file
|
@ -0,0 +1,22 @@
|
|||
-- fusentest.fs_product_template_v2 definition
|
||||
|
||||
CREATE TABLE `fs_product_template_v2` (
|
||||
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`product_id` int(10) unsigned NOT NULL COMMENT '产品ID',
|
||||
`model_id` int(11) NOT NULL COMMENT '模型ID',
|
||||
`title` varchar(255) NOT NULL DEFAULT '' COMMENT '模板(sku),预留字段',
|
||||
`name` varchar(255) NOT NULL DEFAULT '' COMMENT '名称',
|
||||
`cover_img` varchar(255) DEFAULT NULL COMMENT '模板背景图',
|
||||
`template_info` text NOT NULL COMMENT '模板详情',
|
||||
`material_img` varchar(255) DEFAULT NULL COMMENT '合成好的贴图',
|
||||
`sort` smallint(5) unsigned NOT NULL DEFAULT '0' COMMENT '排序',
|
||||
`logo_width` int(10) NOT NULL DEFAULT '0' COMMENT 'logo图最大宽度',
|
||||
`logo_height` int(10) NOT NULL DEFAULT '0' COMMENT 'logo图最大高度',
|
||||
`is_public` tinyint(1) NOT NULL DEFAULT '0' COMMENT '是否可公用(1:可以,0:不可以)',
|
||||
`status` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '状态1正常 2异常',
|
||||
`ctime` int(10) unsigned NOT NULL COMMENT '添加时间',
|
||||
`tag` varchar(255) NOT NULL COMMENT '标签(用户自填)',
|
||||
`is_del` tinyint(1) NOT NULL DEFAULT '0' COMMENT '是否删除 1删除',
|
||||
PRIMARY KEY (`id`) USING BTREE,
|
||||
KEY `product_id` (`product_id`) USING BTREE
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=463 DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT COMMENT='产品-模型-模板表';
|
16
ddl/fs_tags.sql
Normal file
16
ddl/fs_tags.sql
Normal file
|
@ -0,0 +1,16 @@
|
|||
-- fusentest.fs_tags definition
|
||||
|
||||
CREATE TABLE `fs_tags` (
|
||||
`id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID',
|
||||
`title` varchar(32) NOT NULL COMMENT '标题',
|
||||
`level` int(10) unsigned NOT NULL COMMENT '层级、分类 1 => 二维码分类',
|
||||
`click_num` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '点击次数',
|
||||
`sort` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '排序(从大到小)',
|
||||
`create_at` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '创建时间',
|
||||
`icon` varchar(200) DEFAULT NULL COMMENT '标签图标',
|
||||
`status` tinyint(3) unsigned NOT NULL DEFAULT '1' COMMENT '状态 1:可用',
|
||||
`description` varchar(255) NOT NULL DEFAULT '' COMMENT '介绍 Seo',
|
||||
`recommend_product` varchar(255) DEFAULT NULL COMMENT '推荐产品id例如: 1,3,4,5',
|
||||
`recommend_product_sort` varchar(255) DEFAULT NULL COMMENT '推荐排序例如:1324',
|
||||
PRIMARY KEY (`id`) USING BTREE
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=40 DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT COMMENT='产品分类表';
|
|
@ -28,6 +28,7 @@ type (
|
|||
FindOneBySn(ctx context.Context, sn string) (*FsProduct, error)
|
||||
Update(ctx context.Context, data *FsProduct) error
|
||||
Delete(ctx context.Context, id int64) error
|
||||
GetProductListByConditions(ctx context.Context, productType int, isDel int, isShelf int, sort string) ([]FsProduct, error)
|
||||
}
|
||||
|
||||
defaultFsProductModel struct {
|
||||
|
@ -121,6 +122,24 @@ func (m *defaultFsProductModel) Update(ctx context.Context, newData *FsProduct)
|
|||
return err
|
||||
}
|
||||
|
||||
func (m *defaultFsProductModel) GetProductListByConditions(ctx context.Context, productType int, isDel int, isShelf int, sort string) (resp []FsProduct, err error) {
|
||||
query := fmt.Sprintf("select %s from %s where `type` = ? and `is_del` =? and `is_shelf` = ?",
|
||||
fsProductRows, m.table)
|
||||
switch sort {
|
||||
case "sort-asc":
|
||||
query = fmt.Sprintf("%s order by sort ASC", query)
|
||||
case "sort-desc":
|
||||
query = fmt.Sprintf("%s order by sort DESC", query)
|
||||
default:
|
||||
query = fmt.Sprintf("%s order by sort DESC", query)
|
||||
}
|
||||
err = m.conn.QueryRowsCtx(ctx, &resp, query, productType, isDel, isShelf)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (m *defaultFsProductModel) tableName() string {
|
||||
return m.table
|
||||
}
|
||||
|
|
42
product.api
42
product.api
|
@ -9,12 +9,50 @@ info (
|
|||
import "basic.api"
|
||||
type GetProductListReq {
|
||||
// TODO: add members here and delete this comment
|
||||
Cid uint32 `form:"cid"`
|
||||
Cid int64 `form:"cid"`
|
||||
Size uint32 `form:"size"`
|
||||
Page uint32 `form:"page"`
|
||||
IsDemo uint32 `form:"is_demo" , options=0|1"`
|
||||
}
|
||||
|
||||
//获取产品列表响应体
|
||||
type GetProductListRsp {
|
||||
Ob Ob `json:"ob"`
|
||||
TypeName string `json:"typeName"`
|
||||
Description string `json:"description"`
|
||||
}
|
||||
type Ob {
|
||||
Items []Items `json:"items"`
|
||||
Links Links `json:"_links"`
|
||||
Meta Meta `json:"_meta"`
|
||||
}
|
||||
type Meta {
|
||||
TotalCount int32 `json:"totalCount"`
|
||||
PageCount int32 `json:"pageCount"`
|
||||
CurrentPage int32 `json:"currentPage"`
|
||||
PerPage int32 `json:"perPage"`
|
||||
}
|
||||
type Links {
|
||||
Self HrefUrl `json:"self"`
|
||||
First HrefUrl `json:"first"`
|
||||
Last HrefUrl `json:"last"`
|
||||
Next HrefUrl `json:"next"`
|
||||
}
|
||||
type HrefUrl {
|
||||
Href string `json:"href"`
|
||||
}
|
||||
type Items {
|
||||
Id int64 `json:"id"`
|
||||
Sn string `json:"sn"`
|
||||
Title string `json:"title"`
|
||||
Cover string `json:"cover"`
|
||||
Intro string `json:"intro"`
|
||||
CoverImg string `json:"cover_img"`
|
||||
IsEnv uint32 `json:"isEnv"`
|
||||
IsMicro uint32 `json:"isMicro"`
|
||||
SizeNum uint32 `json:"sizeNum"`
|
||||
MiniPrice float64 `json:"miniPrice"`
|
||||
CoverDefault string `json:"coverDefault"`
|
||||
}
|
||||
service product {
|
||||
@handler GetProductListHandler
|
||||
get /product/list(GetProductListReq) returns (response);
|
||||
|
|
|
@ -16,13 +16,13 @@ func GetProductListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
|||
userInfo := auth.CheckAuth(r)
|
||||
var req types.GetProductListReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
httpx.ErrorCtx(r.Context(), w, err)
|
||||
httpx.OkJsonCtx(r.Context(), w, types.Response{Code: 500, Message: err.Error()})
|
||||
return
|
||||
}
|
||||
l := logic.NewGetProductListLogic(r.Context(), svcCtx)
|
||||
resp, err := l.GetProductList(&req, userInfo)
|
||||
if err != nil {
|
||||
httpx.ErrorCtx(r.Context(), w, err)
|
||||
httpx.OkJsonCtx(r.Context(), w, types.Response{Code: 500, Message: err.Error()})
|
||||
} else {
|
||||
httpx.OkJsonCtx(r.Context(), w, resp)
|
||||
}
|
||||
|
|
|
@ -2,11 +2,21 @@ package logic
|
|||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"fusenapi/constants"
|
||||
"fusenapi/model"
|
||||
"fusenapi/product/internal/svc"
|
||||
"fusenapi/product/internal/types"
|
||||
"fusenapi/utils/auth"
|
||||
"fusenapi/utils/format"
|
||||
"fusenapi/utils/image"
|
||||
"github.com/zeromicro/go-zero/core/stores/sqlx"
|
||||
"sort"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
@ -27,22 +37,418 @@ func NewGetProductListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Ge
|
|||
|
||||
// 获取产品列表
|
||||
func (l *GetProductListLogic) GetProductList(req *types.GetProductListReq, loginInfo auth.UserInfo) (resp *types.Response, err error) {
|
||||
loginInfo.UserId = 84
|
||||
//校验前台登录情况
|
||||
if loginInfo.UserId == 0 {
|
||||
return &types.Response{Code: 402, Message: "please sign in"}, nil
|
||||
}
|
||||
//如果是demo
|
||||
if req.IsDemo == 1 {
|
||||
var demo types.GetProductListRsp
|
||||
if err = json.Unmarshal([]byte(l.DemoProductList()), &demo); err != nil {
|
||||
logx.Error(err)
|
||||
return &types.Response{Code: 510, Message: "demo data format err"}, nil
|
||||
}
|
||||
return &types.Response{Code: 200, Message: "success", Data: demo}, nil
|
||||
}
|
||||
if req.Page <= 0 {
|
||||
req.Page = 1
|
||||
}
|
||||
//获取合适尺寸
|
||||
if req.Size > 0 {
|
||||
req.Size = image.GetCurrentSize(req.Size)
|
||||
}
|
||||
//获取是否存在千人千面
|
||||
//查询用户信息
|
||||
userModel := model.NewFsUserModel(l.svcCtx.MysqlConn)
|
||||
userInfo, err := userModel.FindOne(l.ctx, loginInfo.UserId)
|
||||
if err != nil && !errors.Is(err, sqlx.ErrNotFound) {
|
||||
logx.Error(err)
|
||||
return &types.Response{Code: 510, Message: "get user info err"}, nil
|
||||
}
|
||||
if userInfo == nil {
|
||||
return &types.Response{Code: 402, Message: "user not exists"}, nil
|
||||
}
|
||||
//查询符合的产品列表
|
||||
productModel := model.NewFsProductModel(l.svcCtx.MysqlConn)
|
||||
productList, err := productModel.GetProductListByConditions(l.ctx, int(req.Cid), 0, 1, "sort-desc")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
logx.Error(err)
|
||||
return &types.Response{Code: 510, Message: "failed to get product list"}, nil
|
||||
}
|
||||
if userInfo.Id == 0 {
|
||||
return &types.Response{Code: 402, Message: "please sign in"}, nil
|
||||
fmt.Println(len(productList))
|
||||
productLen := len(productList)
|
||||
if productLen == 0 {
|
||||
return &types.Response{Code: 200, Message: "success"}, nil
|
||||
}
|
||||
//提取产品ids
|
||||
productIds := make([]string, 0, productLen)
|
||||
for _, v := range productList {
|
||||
productIds = append(productIds, fmt.Sprintf("%d", v.Id))
|
||||
}
|
||||
productPriceModel := model.NewFsProductPriceModel(l.svcCtx.MysqlConn)
|
||||
productPriceList, err := productPriceModel.GetPriceList(l.ctx, productIds)
|
||||
if err != nil {
|
||||
logx.Error(err)
|
||||
return &types.Response{Code: 510, Message: "failed to get product min price list"}, nil
|
||||
}
|
||||
//存储产品最小价格
|
||||
mapProductMinPrice := make(map[int64]int64)
|
||||
for _, v := range productPriceList {
|
||||
priceSlic := strings.Split(v.Price, ",")
|
||||
sort.Strings(priceSlic)
|
||||
min, err := strconv.ParseInt(priceSlic[0], 10, 64)
|
||||
if err != nil {
|
||||
logx.Error(err)
|
||||
return &types.Response{Code: 510, Message: "parse min product price err"}, nil
|
||||
}
|
||||
mapProductMinPrice[v.ProductId] = min
|
||||
}
|
||||
//获取模板
|
||||
productTemplateModel := model.NewFsProductTemplateV2Model(l.svcCtx.MysqlConn)
|
||||
productTemplatesV2, err := productTemplateModel.FindAllByCondition(l.ctx, productIds, 0, 1)
|
||||
if err != nil {
|
||||
logx.Error(err)
|
||||
return &types.Response{Code: 510, Message: "get product template_v2 err"}, nil
|
||||
}
|
||||
mapProductTemplate := make(map[int64]struct{})
|
||||
for _, v := range productTemplatesV2 {
|
||||
mapProductTemplate[v.ProductId] = struct{}{}
|
||||
}
|
||||
//获取分类
|
||||
tagsModel := model.NewFsTagsModel(l.svcCtx.MysqlConn)
|
||||
tagInfo, err := tagsModel.FindOne(l.ctx, req.Cid)
|
||||
if err != nil && !errors.Is(err, sqlx.ErrNotFound) {
|
||||
logx.Error(err)
|
||||
return &types.Response{Code: 510, Message: "get classification err "}, nil
|
||||
}
|
||||
if tagInfo == nil {
|
||||
return &types.Response{Code: 510, Message: "classification not exists "}, nil
|
||||
}
|
||||
//拼接返回
|
||||
itemList := make([]types.Items, 0, productLen)
|
||||
for _, v := range productList {
|
||||
minPrice, ok := mapProductMinPrice[v.Id]
|
||||
//无最小价格则不显示
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
_, ok = mapProductTemplate[v.Id]
|
||||
//没有模板也不显示
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
item := types.Items{
|
||||
Id: v.Id,
|
||||
Sn: v.Sn,
|
||||
Title: v.Title,
|
||||
Cover: v.Cover,
|
||||
Intro: v.Intro.String,
|
||||
CoverImg: v.CoverImg,
|
||||
IsEnv: 1,
|
||||
IsMicro: 1,
|
||||
SizeNum: 1,
|
||||
MiniPrice: format.FentoDollar(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 {
|
||||
v.Cover = ""
|
||||
item.CoverDefault = item.CoverImg
|
||||
if req.Size >= 200 {
|
||||
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())
|
||||
item.CoverDefault = fmt.Sprintf("%s_%d.%s", coverImgSlice[0], req.Size, coverImgSlice[1])
|
||||
}
|
||||
}
|
||||
}
|
||||
itemList = append(itemList, item)
|
||||
}
|
||||
return &types.Response{
|
||||
Code: 200,
|
||||
Message: "success",
|
||||
Data: types.GetProductListRsp{
|
||||
Ob: types.Ob{
|
||||
Items: itemList,
|
||||
},
|
||||
TypeName: tagInfo.Title,
|
||||
Description: tagInfo.Description,
|
||||
}}, nil
|
||||
return
|
||||
}
|
||||
|
||||
// 样本产品列表
|
||||
func (l *GetProductListLogic) DemoProductList() string {
|
||||
return `{
|
||||
"ob": {
|
||||
"items": [
|
||||
{
|
||||
"id": 25,
|
||||
"sn": "P1ELZGHU",
|
||||
"title": "Packing box",
|
||||
"cover": "/icon/icon_25_800.png",
|
||||
"intro": "打包盒卡纸",
|
||||
"cover_img": "/uploads/ognhdc6q_800.png",
|
||||
"isEnv": 1,
|
||||
"isMicro": 1,
|
||||
"sizeNum": 5,
|
||||
"miniPrice": 2
|
||||
},
|
||||
{
|
||||
"id": 28,
|
||||
"sn": "P9KVYAUS",
|
||||
"title": "Pizza box",
|
||||
"cover": "/icon/9dmom0g7_800.png",
|
||||
"intro": "披萨盒 瓦楞纸",
|
||||
"cover_img": "/uploads/9xf1olkl_800.png",
|
||||
"isEnv": 1,
|
||||
"isMicro": 1,
|
||||
"sizeNum": 1,
|
||||
"miniPrice": 2
|
||||
},
|
||||
{
|
||||
"id": 30,
|
||||
"sn": "PZWDSROX",
|
||||
"title": "Paper bag with handle",
|
||||
"cover": "/icon/iz44vraw_800.png",
|
||||
"intro": "有提手纸袋牛皮纸",
|
||||
"cover_img": "/uploads/rpwntxcq_800.png",
|
||||
"isEnv": 1,
|
||||
"isMicro": 1,
|
||||
"sizeNum": 4,
|
||||
"miniPrice": 2
|
||||
},
|
||||
{
|
||||
"id": 20,
|
||||
"sn": "PNACHNUK",
|
||||
"title": "Four cups of milk tea cup",
|
||||
"cover": "/icon/plz43wpo_800.png",
|
||||
"intro": "卡纸",
|
||||
"cover_img": "/uploads/9tqgsjqi_800.png",
|
||||
"isEnv": 1,
|
||||
"isMicro": 1,
|
||||
"sizeNum": 2,
|
||||
"miniPrice": 2
|
||||
},
|
||||
{
|
||||
"id": 19,
|
||||
"sn": "PHHVEXRW",
|
||||
"title": "Milk tea cup holder double cup",
|
||||
"cover": "/icon/ipohmmcj_800.png",
|
||||
"intro": "奶茶杯托奶茶杯托两杯袋",
|
||||
"cover_img": "/uploads/57ogzeq5_800.png",
|
||||
"isEnv": 1,
|
||||
"isMicro": 1,
|
||||
"sizeNum": 5,
|
||||
"miniPrice": 2
|
||||
},
|
||||
{
|
||||
"id": 11,
|
||||
"sn": "P7N4D0MK",
|
||||
"title": "Cup double layer",
|
||||
"cover": "/icon/nrmzz4du_800.png",
|
||||
"intro": "牛皮纸双层",
|
||||
"cover_img": "/uploads/oqjm5own_800.png",
|
||||
"isEnv": 1,
|
||||
"isMicro": 1,
|
||||
"sizeNum": 5,
|
||||
"miniPrice": 2
|
||||
},
|
||||
{
|
||||
"id": 33,
|
||||
"sn": "P0NFP19Y",
|
||||
"title": "High paper bowl",
|
||||
"cover": "/icon/cla4k6om_800.png",
|
||||
"intro": "牛皮纸",
|
||||
"cover_img": "/uploads/dt1qjkzg_800.png",
|
||||
"isEnv": 1,
|
||||
"isMicro": 1,
|
||||
"sizeNum": 4,
|
||||
"miniPrice": 2
|
||||
},
|
||||
{
|
||||
"id": 32,
|
||||
"sn": "PDZ3HIUL",
|
||||
"title": "Flat paper bowl",
|
||||
"cover": "/icon/jy14adqz_800.png",
|
||||
"intro": "牛皮纸",
|
||||
"cover_img": "/uploads/bzwbxduc_800.png",
|
||||
"isEnv": 1,
|
||||
"isMicro": 1,
|
||||
"sizeNum": 3,
|
||||
"miniPrice": 2
|
||||
},
|
||||
{
|
||||
"id": 31,
|
||||
"sn": "PEVSMU7I",
|
||||
"title": "Paper bag without handle",
|
||||
"cover": "/icon/osdsegor_800.png",
|
||||
"intro": "牛皮纸",
|
||||
"cover_img": "/uploads/ouvayny7_800.png",
|
||||
"isEnv": 1,
|
||||
"isMicro": 1,
|
||||
"sizeNum": 2,
|
||||
"miniPrice": 2
|
||||
},
|
||||
{
|
||||
"id": 29,
|
||||
"sn": "P58ZZOTI",
|
||||
"title": "plastic bag",
|
||||
"cover": "/icon/dvsvddks_800.png",
|
||||
"intro": "塑料袋",
|
||||
"cover_img": "/uploads/qvvuzkzx_800.png",
|
||||
"isEnv": 1,
|
||||
"isMicro": 1,
|
||||
"sizeNum": 1,
|
||||
"miniPrice": 2
|
||||
},
|
||||
{
|
||||
"id": 24,
|
||||
"sn": "PG7XIXII",
|
||||
"title": "Hamburger box",
|
||||
"cover": "/icon/icon_24_800.png",
|
||||
"intro": "汉堡盒 卡纸",
|
||||
"cover_img": "/uploads/fm1itgge_800.png",
|
||||
"isEnv": 1,
|
||||
"isMicro": 1,
|
||||
"sizeNum": 4,
|
||||
"miniPrice": 2
|
||||
},
|
||||
{
|
||||
"id": 23,
|
||||
"sn": "PIJ2OVUE",
|
||||
"title": "Milk tea ring portable double cup",
|
||||
"cover": "/icon/nxb6hjln_800.png",
|
||||
"intro": "卡纸",
|
||||
"cover_img": "/uploads/52fash1n_800.png",
|
||||
"isEnv": 1,
|
||||
"isMicro": 1,
|
||||
"sizeNum": 4,
|
||||
"miniPrice": 2
|
||||
},
|
||||
{
|
||||
"id": 21,
|
||||
"sn": "PMHXGUL6",
|
||||
"title": "Milk tea ring portable single cup",
|
||||
"cover": "/icon/qoaf5mtp_800.png",
|
||||
"intro": "卡纸",
|
||||
"cover_img": "/uploads/epvkzvyf_800.png",
|
||||
"isEnv": 1,
|
||||
"isMicro": 1,
|
||||
"sizeNum": 5,
|
||||
"miniPrice": 2
|
||||
},
|
||||
{
|
||||
"id": 18,
|
||||
"sn": "PFCM8KNF",
|
||||
"title": "Tableware set chopsticks",
|
||||
"cover": "/icon/tcspod4b_800.png",
|
||||
"intro": "餐具套装筷子厚牛皮纸包装",
|
||||
"cover_img": "/uploads/5jgrgzvh_800.png",
|
||||
"isEnv": 1,
|
||||
"isMicro": 1,
|
||||
"sizeNum": 3,
|
||||
"miniPrice": 2
|
||||
},
|
||||
{
|
||||
"id": 17,
|
||||
"sn": "PQKIQMIK",
|
||||
"title": "Tableware set four piece set",
|
||||
"cover": "/icon/mdo0vu1u_800.png",
|
||||
"intro": "牛皮纸包装",
|
||||
"cover_img": "/uploads/szsekvbw_800.png",
|
||||
"isEnv": 1,
|
||||
"isMicro": 1,
|
||||
"sizeNum": 4,
|
||||
"miniPrice": 2
|
||||
},
|
||||
{
|
||||
"id": 16,
|
||||
"sn": "PBFOIOFH",
|
||||
"title": "Tableware set four piece set",
|
||||
"cover": "/icon/dzrf59cp_800.png",
|
||||
"intro": "餐具套装",
|
||||
"cover_img": "/uploads/svfoebf1_800.png",
|
||||
"isEnv": 1,
|
||||
"isMicro": 1,
|
||||
"sizeNum": 1,
|
||||
"miniPrice": 2
|
||||
},
|
||||
{
|
||||
"id": 15,
|
||||
"sn": "P02V10AB",
|
||||
"title": " Hot drink cup holder",
|
||||
"cover": "/icon/icon_15_800.png",
|
||||
"intro": "杯托、瓦楞纸",
|
||||
"cover_img": "/uploads/4qbdid7i_800.png",
|
||||
"isEnv": 1,
|
||||
"isMicro": 1,
|
||||
"sizeNum": 5,
|
||||
"miniPrice": 2
|
||||
},
|
||||
{
|
||||
"id": 13,
|
||||
"sn": "PER6WLAV",
|
||||
"title": " Cup pet",
|
||||
"cover": "/icon/icon_13_800.png",
|
||||
"intro": "pet",
|
||||
"cover_img": "/uploads/kfxehwjd_800.png",
|
||||
"isEnv": 1,
|
||||
"isMicro": 1,
|
||||
"sizeNum": 1,
|
||||
"miniPrice": 2
|
||||
},
|
||||
{
|
||||
"id": 12,
|
||||
"sn": "PGFWRMAU",
|
||||
"title": " Cup PP",
|
||||
"cover": "/icon/icon_12_800.png",
|
||||
"intro": "pp",
|
||||
"cover_img": "/uploads/azp8uwhz_800.png",
|
||||
"isEnv": 1,
|
||||
"isMicro": 1,
|
||||
"sizeNum": 2,
|
||||
"miniPrice": 2
|
||||
},
|
||||
{
|
||||
"id": 10,
|
||||
"sn": "P4ZXDVHS",
|
||||
"title": "Cup monolayer",
|
||||
"cover": "/icon/icon_10_800.png",
|
||||
"intro": "牛皮纸单层",
|
||||
"cover_img": "/uploads/onuzax6l_800.png",
|
||||
"isEnv": 1,
|
||||
"isMicro": 1,
|
||||
"sizeNum": 1,
|
||||
"miniPrice": 2
|
||||
}
|
||||
],
|
||||
"_links": {
|
||||
"self": {
|
||||
"href": "https://fusenapi.kayue.cn:8010/product/list?cid=13&size=620&page=1&is_demo=1"
|
||||
},
|
||||
"first": {
|
||||
"href": "https://fusenapi.kayue.cn:8010/product/list?cid=13&size=620&page=1&is_demo=1"
|
||||
},
|
||||
"last": {
|
||||
"href": "https://fusenapi.kayue.cn:8010/product/list?cid=13&size=620&page=2&is_demo=1"
|
||||
},
|
||||
"next": {
|
||||
"href": "https://fusenapi.kayue.cn:8010/product/list?cid=13&size=620&page=2&is_demo=1"
|
||||
}
|
||||
},
|
||||
"_meta": {
|
||||
"totalCount": 21,
|
||||
"pageCount": 2,
|
||||
"currentPage": 1,
|
||||
"perPage": 20
|
||||
}
|
||||
},
|
||||
"typeName": "Boxes",
|
||||
"description": ""
|
||||
}`
|
||||
}
|
||||
|
|
|
@ -2,14 +2,63 @@
|
|||
package types
|
||||
|
||||
type GetProductListReq struct {
|
||||
Cid uint32 `form:"cid"`
|
||||
Cid int64 `form:"cid"`
|
||||
Size uint32 `form:"size"`
|
||||
Page uint32 `form:"page"`
|
||||
IsDemo uint32 `form:"is_demo" , options=0|1"`
|
||||
}
|
||||
|
||||
type GetProductListRsp struct {
|
||||
Ob Ob `json:"ob"`
|
||||
TypeName string `json:"typeName"`
|
||||
Description string `json:"description"`
|
||||
}
|
||||
|
||||
type Ob struct {
|
||||
Items []Items `json:"items"`
|
||||
Links Links `json:"_links"`
|
||||
Meta Meta `json:"_meta"`
|
||||
}
|
||||
|
||||
type Meta struct {
|
||||
TotalCount int32 `json:"totalCount"`
|
||||
PageCount int32 `json:"pageCount"`
|
||||
CurrentPage int32 `json:"currentPage"`
|
||||
PerPage int32 `json:"perPage"`
|
||||
}
|
||||
|
||||
type Links struct {
|
||||
Self HrefUrl `json:"self"`
|
||||
First HrefUrl `json:"first"`
|
||||
Last HrefUrl `json:"last"`
|
||||
Next HrefUrl `json:"next"`
|
||||
}
|
||||
|
||||
type HrefUrl struct {
|
||||
Href string `json:"href"`
|
||||
}
|
||||
|
||||
type Items struct {
|
||||
Id int64 `json:"id"`
|
||||
Sn string `json:"sn"`
|
||||
Title string `json:"title"`
|
||||
Cover string `json:"cover"`
|
||||
Intro string `json:"intro"`
|
||||
CoverImg string `json:"cover_img"`
|
||||
IsEnv uint32 `json:"isEnv"`
|
||||
IsMicro uint32 `json:"isMicro"`
|
||||
SizeNum uint32 `json:"sizeNum"`
|
||||
MiniPrice float64 `json:"miniPrice"`
|
||||
CoverDefault string `json:"coverDefault"`
|
||||
}
|
||||
|
||||
type Response struct {
|
||||
Code int `json:"code"`
|
||||
Message string `json:"msg"`
|
||||
Data interface{} `json:"data"`
|
||||
}
|
||||
|
||||
type Auth struct {
|
||||
AccessSecret string `json:"AccessSecret"`
|
||||
AccessExpire int `json:"AccessExpire"`
|
||||
}
|
||||
|
|
|
@ -58,13 +58,13 @@ func CheckAuth(r *http.Request) UserInfo {
|
|||
token = r.Header.Get("Auth-Key")
|
||||
}
|
||||
if token == "" {
|
||||
logx.Debug("token is empty")
|
||||
logx.Error("token is empty")
|
||||
return UserInfo{}
|
||||
}
|
||||
//解析token
|
||||
userInfo, err := ParseJwtToken(token)
|
||||
if err != nil {
|
||||
logx.Debug(err)
|
||||
logx.Error(err)
|
||||
return UserInfo{}
|
||||
}
|
||||
return userInfo
|
||||
|
|
13
utils/format/price.go
Normal file
13
utils/format/price.go
Normal file
|
@ -0,0 +1,13 @@
|
|||
package format
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
// 美分转美元
|
||||
func FentoDollar(price int64) float64 {
|
||||
str := fmt.Sprintf("%.2f", float64(price)/float64(100))
|
||||
dollar, _ := strconv.ParseFloat(str, 64)
|
||||
return dollar
|
||||
}
|
Loading…
Reference in New Issue
Block a user