新增产品详情api
This commit is contained in:
parent
a933f0d763
commit
f7e7e2d85c
106
product.api
106
product.api
@ -7,6 +7,17 @@ info (
|
|||||||
email: ""
|
email: ""
|
||||||
)
|
)
|
||||||
import "basic.api"
|
import "basic.api"
|
||||||
|
|
||||||
|
service product {
|
||||||
|
//获取产品列表
|
||||||
|
@handler GetProductListHandler
|
||||||
|
get /product/list(GetProductListReq) returns (response);
|
||||||
|
//获取产品详情信息
|
||||||
|
@handler GetProductInfoHandler
|
||||||
|
get /product/info(GetProductInfoReq) returns (response);
|
||||||
|
}
|
||||||
|
|
||||||
|
//获取产品列表
|
||||||
type GetProductListReq {
|
type GetProductListReq {
|
||||||
// TODO: add members here and delete this comment
|
// TODO: add members here and delete this comment
|
||||||
Cid int64 `form:"cid"`
|
Cid int64 `form:"cid"`
|
||||||
@ -14,7 +25,6 @@ type GetProductListReq {
|
|||||||
Page uint32 `form:"page"`
|
Page uint32 `form:"page"`
|
||||||
IsDemo uint32 `form:"is_demo" , options=0|1"`
|
IsDemo uint32 `form:"is_demo" , options=0|1"`
|
||||||
}
|
}
|
||||||
//获取产品列表响应体
|
|
||||||
type GetProductListRsp {
|
type GetProductListRsp {
|
||||||
Ob Ob `json:"ob"`
|
Ob Ob `json:"ob"`
|
||||||
TypeName string `json:"typeName"`
|
TypeName string `json:"typeName"`
|
||||||
@ -53,7 +63,95 @@ type Items {
|
|||||||
MiniPrice float64 `json:"miniPrice"`
|
MiniPrice float64 `json:"miniPrice"`
|
||||||
CoverDefault string `json:"coverDefault"`
|
CoverDefault string `json:"coverDefault"`
|
||||||
}
|
}
|
||||||
service product {
|
//获取产品详情
|
||||||
@handler GetProductListHandler
|
type GetProductInfoReq {
|
||||||
get /product/list(GetProductListReq) returns (response);
|
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"`
|
||||||
}
|
}
|
31
product/internal/handler/getproductinfohandler.go
Normal file
31
product/internal/handler/getproductinfohandler.go
Normal file
@ -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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -17,6 +17,11 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
|
|||||||
Path: "/product/list",
|
Path: "/product/list",
|
||||||
Handler: GetProductListHandler(serverCtx),
|
Handler: GetProductListHandler(serverCtx),
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
Method: http.MethodGet,
|
||||||
|
Path: "/product/info",
|
||||||
|
Handler: GetProductInfoHandler(serverCtx),
|
||||||
|
},
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
33
product/internal/logic/getproductinfologic.go
Normal file
33
product/internal/logic/getproductinfologic.go
Normal file
@ -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
|
||||||
|
}
|
@ -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) {
|
func (l *GetProductListLogic) GetProductList(req *types.GetProductListReq, loginInfo auth.UserInfo) (resp *types.Response, err error) {
|
||||||
loginInfo.UserId = 84
|
|
||||||
//校验前台登录情况
|
//校验前台登录情况
|
||||||
if loginInfo.UserId == 0 {
|
if loginInfo.UserId == 0 {
|
||||||
return &types.Response{Code: 402, Message: "please sign in"}, nil
|
return &types.Response{Code: 402, Message: "please sign in"}, nil
|
||||||
|
@ -52,6 +52,108 @@ type Items struct {
|
|||||||
CoverDefault string `json:"coverDefault"`
|
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 {
|
type Response struct {
|
||||||
Code int `json:"code"`
|
Code int `json:"code"`
|
||||||
Message string `json:"msg"`
|
Message string `json:"msg"`
|
||||||
|
Loading…
x
Reference in New Issue
Block a user