diff --git a/product.api b/product.api index 98787a3d..d5bc11c8 100644 --- a/product.api +++ b/product.api @@ -7,6 +7,17 @@ info ( email: "" ) import "basic.api" + +service product { + //获取产品列表 + @handler GetProductListHandler + get /product/list(GetProductListReq) returns (response); + //获取产品详情信息 + @handler GetProductInfoHandler + get /product/info(GetProductInfoReq) returns (response); +} + +//获取产品列表 type GetProductListReq { // TODO: add members here and delete this comment Cid int64 `form:"cid"` @@ -14,7 +25,6 @@ type GetProductListReq { Page uint32 `form:"page"` IsDemo uint32 `form:"is_demo" , options=0|1"` } -//获取产品列表响应体 type GetProductListRsp { Ob Ob `json:"ob"` TypeName string `json:"typeName"` @@ -53,7 +63,95 @@ type Items { MiniPrice float64 `json:"miniPrice"` CoverDefault string `json:"coverDefault"` } -service product { - @handler GetProductListHandler - get /product/list(GetProductListReq) returns (response); +//获取产品详情 +type GetProductInfoReq { + Pid string `json:"pid"` //sn + Size uint32 `json:"size"` //图片尺寸 + ClientNo string `json:"clientNo"` //页面标识 + HaveCloudRendering bool `json:"haveCloudRendering"` //是否显示云渲染开关 +} +type GetProductInfoRsp { + Id int64 `json:"id"` + Type int32 `json:"type"` + Title string `json:"title"` + IsEnv uint32 `json:"isEnv"` + IsMicro uint32 `json:"isMicro"` + Materials []Materials `json:"materials"` + Sizes []Sizes `json:"sizes"` + TypeName string `json:"typeName"` + Templates Templates `json:"templates"` +} + +type Materials { + Id int64 `json:"id"` + Title string `json:"title"` +} +type Sizes { + Id int64 `json:"id"` + Title SizeTitle `json:"title"` + Capacity string `json:"capacity"` + Cover string `json:"cover"` +} +type SizeTitle { + Cm string `json:"cm"` + Inth string `json:"inth"` +} +type Templates { + Ob484 []Ob484 `json:"4_84"` +} +type Ob484 { + Id int64 `json:"id"` + Title string `json:"title"` + TemplateData TemplateData `json:"templateData"` +} +type TemplateData { + Id int64 `json:"id"` + Cover string `json:"cover"` + Material string `json:"material"` + MaterialList []Material `json:"materialList"` +} +type Material { + Id int64 `json:"id"` + Tag string `json:"tag"` + Title string `json:"title"` + Type string `json:"type"` + Text string `json:"text"` + Fill string `json:"fill"` + FontSize int `json:"fontSize"` + FontFamily string `json:"fontFamily"` + IfBr bool `json:"ifBr"` + IfShow bool `json:"ifShow"` + IfGroup bool `json:"ifGroup"` + MaxNum int `json:"maxNum"` + Rotation int `json:"rotation"` + Align string `json:"align"` + VerticalAlign string `json:"verticalAlign"` + Material string `json:"material"` + QRcodeType string `json:"qRcodeType"` + Width int `json:"width"` + Height int `json:"height"` + X int `json:"x"` + Y int `json:"y"` + Opacity int `json:"opacity"` + OptionalColor []OptionalColor `json:"optionalColor"` + ZIndex int `json:"zIndex"` + SvgPath string `json:"svgPath"` + Follow Follow `json:"follow"` + Group []string `json:"group"` + CameraStand CameraStand `json:"cameraStand"` +} +type CameraStand { + X int `json:"x"` + Y int `json:"y"` + Z int `json:"z"` +} +type Follow { + Fill string `json:"fill"` + IfShow string `json:"ifShow"` + Content string `json:"content"` +} +type OptionalColor { + Color string `json:"color"` + Name string `json:"name"` + Default string `json:"default"` } \ No newline at end of file diff --git a/product/internal/handler/getproductinfohandler.go b/product/internal/handler/getproductinfohandler.go new file mode 100644 index 00000000..5bcbae0a --- /dev/null +++ b/product/internal/handler/getproductinfohandler.go @@ -0,0 +1,31 @@ +package handler + +import ( + "fusenapi/utils/auth" + "net/http" + + "fusenapi/product/internal/logic" + "fusenapi/product/internal/svc" + "fusenapi/product/internal/types" + "github.com/zeromicro/go-zero/rest/httpx" +) + +func GetProductInfoHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + //检测登录权限 + userInfo := auth.CheckAuth(r) + var req types.GetProductInfoReq + if err := httpx.Parse(r, &req); err != nil { + httpx.ErrorCtx(r.Context(), w, err) + return + } + + l := logic.NewGetProductInfoLogic(r.Context(), svcCtx) + resp, err := l.GetProductInfo(&req, userInfo) + if err != nil { + httpx.ErrorCtx(r.Context(), w, err) + } else { + httpx.OkJsonCtx(r.Context(), w, resp) + } + } +} diff --git a/product/internal/handler/routes.go b/product/internal/handler/routes.go index 18f67cbc..278cd1ef 100644 --- a/product/internal/handler/routes.go +++ b/product/internal/handler/routes.go @@ -17,6 +17,11 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { Path: "/product/list", Handler: GetProductListHandler(serverCtx), }, + { + Method: http.MethodGet, + Path: "/product/info", + Handler: GetProductInfoHandler(serverCtx), + }, }, ) } diff --git a/product/internal/logic/getproductinfologic.go b/product/internal/logic/getproductinfologic.go new file mode 100644 index 00000000..ef8a4c67 --- /dev/null +++ b/product/internal/logic/getproductinfologic.go @@ -0,0 +1,33 @@ +package logic + +import ( + "context" + "fusenapi/utils/auth" + + "fusenapi/product/internal/svc" + "fusenapi/product/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +type GetProductInfoLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewGetProductInfoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetProductInfoLogic { + return &GetProductInfoLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *GetProductInfoLogic) GetProductInfo(req *types.GetProductInfoReq, loginInfo auth.UserInfo) (resp *types.Response, err error) { + //校验前台登录情况 + if loginInfo.UserId == 0 { + return &types.Response{Code: 402, Message: "please sign in"}, nil + } + return +} diff --git a/product/internal/logic/getproductlistlogic.go b/product/internal/logic/getproductlistlogic.go index 83f81ce0..9bb2081d 100644 --- a/product/internal/logic/getproductlistlogic.go +++ b/product/internal/logic/getproductlistlogic.go @@ -36,7 +36,6 @@ 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 diff --git a/product/internal/types/types.go b/product/internal/types/types.go index 8ec91a11..6a7d556f 100644 --- a/product/internal/types/types.go +++ b/product/internal/types/types.go @@ -52,6 +52,108 @@ type Items struct { CoverDefault string `json:"coverDefault"` } +type GetProductInfoReq struct { + Pid string `json:"pid"` //sn + Size uint32 `json:"size"` //图片尺寸 + ClientNo string `json:"clientNo"` //页面标识 + HaveCloudRendering bool `json:"haveCloudRendering"` //是否显示云渲染开关 +} + +type GetProductInfoRsp struct { + Id int64 `json:"id"` + Type int32 `json:"type"` + Title string `json:"title"` + IsEnv uint32 `json:"isEnv"` + IsMicro uint32 `json:"isMicro"` + Materials []Materials `json:"materials"` + Sizes []Sizes `json:"sizes"` + TypeName string `json:"typeName"` + Templates Templates `json:"templates"` +} + +type Materials struct { + Id int64 `json:"id"` + Title string `json:"title"` +} + +type Sizes struct { + Id int64 `json:"id"` + Title SizeTitle `json:"title"` + Capacity string `json:"capacity"` + Cover string `json:"cover"` +} + +type SizeTitle struct { + Cm string `json:"cm"` + Inth string `json:"inth"` +} + +type Templates struct { + Ob484 []Ob484 `json:"4_84"` +} + +type Ob484 struct { + Id int64 `json:"id"` + Title string `json:"title"` + TemplateData TemplateData `json:"templateData"` +} + +type TemplateData struct { + Id int64 `json:"id"` + Cover string `json:"cover"` + Material string `json:"material"` + MaterialList []Material `json:"materialList"` +} + +type Material struct { + Id int64 `json:"id"` + Tag string `json:"tag"` + Title string `json:"title"` + Type string `json:"type"` + Text string `json:"text"` + Fill string `json:"fill"` + FontSize int `json:"fontSize"` + FontFamily string `json:"fontFamily"` + IfBr bool `json:"ifBr"` + IfShow bool `json:"ifShow"` + IfGroup bool `json:"ifGroup"` + MaxNum int `json:"maxNum"` + Rotation int `json:"rotation"` + Align string `json:"align"` + VerticalAlign string `json:"verticalAlign"` + Material string `json:"material"` + QRcodeType string `json:"qRcodeType"` + Width int `json:"width"` + Height int `json:"height"` + X int `json:"x"` + Y int `json:"y"` + Opacity int `json:"opacity"` + OptionalColor []OptionalColor `json:"optionalColor"` + ZIndex int `json:"zIndex"` + SvgPath string `json:"svgPath"` + Follow Follow `json:"follow"` + Group []string `json:"group"` + CameraStand CameraStand `json:"cameraStand"` +} + +type CameraStand struct { + X int `json:"x"` + Y int `json:"y"` + Z int `json:"z"` +} + +type Follow struct { + Fill string `json:"fill"` + IfShow string `json:"ifShow"` + Content string `json:"content"` +} + +type OptionalColor struct { + Color string `json:"color"` + Name string `json:"name"` + Default string `json:"default"` +} + type Response struct { Code int `json:"code"` Message string `json:"msg"`