syntax = "v1"

info (
	title: // TODO: add title
	desc: // TODO: add description
	author: ""
	email: ""
)

import "basic.api"

service product {
	//获取产品列表
	@handler GetProductListHandler
	get /product/list(GetProductListReq) returns (response);
	//获取成功后的推荐产品
	@handler GetSuccessRecommandHandler
	get /product/success-recommand (GetSuccessRecommandReq) returns (response);
	//获取分类下的产品以及尺寸
	@handler GetSizeByProductHandler
	get /product/get-size-by-product  returns (response);
	//获取保存的设计信息
	@handler GetProductDesignHandler
	get /product/design(GetProductDesignReq)  returns (response);
	//产品设计数据采集
	@handler DesignGatherHandler
	post /product/design-gather  (DesignGatherReq)  returns (response);
	//获取产品信息
	@handler GetProductInfoHandler
	get /product/info(GetProductInfoReq) returns (response);
	//保存设计信息
	@handler SaveDesignHandler
	post /product/save-design(SaveDesignReq) returns (response);
}

//获取产品列表
type GetProductListReq {
	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"`
	Meta  Meta    `json:"_meta"`
}
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        int64   `json:"isEnv"`
	IsMicro      int64   `json:"isMicro"`
	SizeNum      uint32  `json:"sizeNum"`
	MiniPrice    float64 `json:"miniPrice"`
	CoverDefault string  `json:"coverDefault"`
}
//获取成功后的推荐产品
type GetSuccessRecommandReq {
	Num  uint32 `form:"num"`
	Size uint32 `form:"size"`
	Sn   string `form:"sn"`
}
type GetSuccessRecommandRsp {
	Title        string `json:"title"`
	Cover        string `json:"cover"`
	CoverImg     string `json:"coverImg"`
	Sn           string `json:"sn"`
	Id           int64  `json:"id"`
	SkuId        int64  `json:"skuId"`
	CoverDefault string `json:"coverDefault"`
}

//获取分类下的产品以及尺寸
type GetSizeByProductRsp {
	Id       int64      `json:"id"`
	Name     string     `json:"name"`
	Children []Children `json:"children"`
}
type Children {
	Id           int64         `json:"id"`
	Name         string        `json:"name"`
	Cycle        int           `json:"cycle"`
	ChildrenList []ChildrenObj `json:"children"`
}
type ChildrenObj {
	Id        int64      `json:"id"`
	Name      string     `json:"name"`
	PriceList []PriceObj `json:"price_list"`
}
type PriceObj {
	Num   int     `json:"num"`
	Price float64 `json:"price"`
}
//获取保存的设计信息
type GetProductDesignReq {
	Sn string `form:"sn"`
}
type GetProductDesignRsp {
	ProductId  int64 `json:"product_id"`
	TemplateId int64 `json:"template_id"`
	//MaterialId int64  `json:"material_id"`
	SizeId     int64  `json:"size_id"`
	OptionalId int64  `json:"optional_id"`
	Cover      string `json:"cover"`
	Info       string `json:"info"`
}
//产品设计数据采集
type DesignGatherReq {
	Data string `json:"data"`
}
type DesignGatherRsp {
	Sn string `json:"sn"`
}
//获取产品信息
type GetProductInfoReq {
	Pid                string `form:"pid"`
	Size               uint32 `form:"size"`
	ClientNo           string `form:"client_no"`
	HaveCloudRendering bool   `form:"haveCloudRendering,optional"`
}
type GetProductInfoRsp {
	Id             int64          `json:"id"`
	Type           int64          `json:"type"`
	Title          string         `json:"title"`
	IsEnv          int64          `json:"isEnv"`
	IsMicro        int64          `json:"isMicro"`
	TypeName       string         `json:"typeName"`
	IsLowRendering bool           `json:"is_low_rendering"`
	IsRemoveBg     bool           `json:"is_remove_bg"`
	Materials      []MaterialItem `json:"materials"`
	Sizes          []SizeItem     `json:"sizes"`
	Templates      interface{}    `json:"templates"`
	Price          interface{}    `json:"price"`
	LastDesign     interface{}    `json:"last_design"`
	RenderDesign   interface{}    `json:"render_design"`
	Colors         interface{}    `json:"colors"`
}
type SizeItem {
	Id              int64     `json:"id"`
	Title           SizeTitle `json:"title"`
	Capacity        string    `json:"capacity"`
	Cover           string    `json:"cover"`
	Sort            int64     `json:"sort"`
	PartsCanDeleted bool      `json:"parts_can_deleted"`
}
type SizeTitle {
	Cm   string `json:"cm"`
	Inch string `json:"inch"`
}
type MaterialItem {
	Id    int64  `json:"id"`
	Title string `json:"title"`
}
//保存设计信息
type SaveDesignReq {
	Data string `json:"data"` //加密信息
}
type SaveDesignRsp {
	Sn string `json:"sn"`
}
//保存设计信息(解密结构体)
type SaveDesignReqRealStruct {
	ProductId  int64      `json:"product_id"`
	SizeId     int64      `json:"size_id"`
	OptionalId int64      `json:"optional_id"`
	TemplateId int64      `json:"template_id"`
	Sn         string     `json:"sn"`
	Data       DesignData `json:"data"`
	Cover      string     `json:"cover"`
	PageGuid   string     `json:"pageGuid"`
}

type DesignData {
	MainColor      ColorFill     `json:"MainColor"`
	SecondaryColor ColorFill     `json:"SecondaryColor"`
	Logo           DesignLogo    `json:"Logo"`
	Slogan         DesignSlogan  `json:"Slogan"`
	QRcode         DesignQRcode  `json:"QRcode"`
	Website        DesignWebsite `json:"Website"`
	Phone          DesignPhone   `json:"Phone"`
	Address        DesignAddress `json:"Address"`
}
type DesignAddress {
	Text   string `json:"text"`
	IfShow bool   `json:"ifShow"`
}
type DesignPhone {
	Text   string `json:"text"`
	IfShow bool   `json:"ifShow"`
}
type DesignWebsite {
	Text   string `json:"text"`
	IfShow bool   `json:"ifShow"`
}
type DesignQRcode {
	Text    string `json:"text"`
	SvgPath string `json:"svgPath"`
	IfShow  bool   `json:"ifShow"`
}
type DesignSlogan {
	Text   string `json:"text"`
	IfShow bool   `json:"ifShow"`
}
type DesignLogo {
	Material     string   `json:"material"`
	MaterialName string   `json:"materialName"`
	MaterialTime string   `json:"materialTime"`
	Fill         string   `json:"fill"`
	FillName     string   `json:"fill_name"`
	Colors       []string `json:"colors"`
}
type ColorFill {
	Fill string `json:"fill"`
}