This commit is contained in:
duyu 2024-09-10 15:55:43 +08:00
parent 977a64bd55
commit 7da6f5ba09
3 changed files with 44 additions and 35 deletions

View File

@ -31,13 +31,14 @@ func GetById(c *gin.Context) {
response = &proEnt.GetListByIdResp{ response = &proEnt.GetListByIdResp{
Id: res.Id, Id: res.Id,
Name: res.Name, Name: res.Name,
Price: res.Price, Price: float64(res.Price) / 100,
ProductUrl: res.ProductUrl, ProductUrl: res.ProductUrl,
Status: res.Status, Status: res.Status,
CreatedAt: res.CreatedAt.Format(time.RFC3339), CreatedAt: res.CreatedAt.Format(time.RFC3339),
Type: res.Type, Type: res.Type,
ExtendParameter: res.ExtendParameter, ExtendParameter: res.ExtendParameter,
QueueNo: res.QueueNo, QueueNo: res.QueueNo,
Spec: res.Spec,
} }
} }
@ -76,13 +77,14 @@ func Search(c *gin.Context) {
response = append(response, &proEnt.SearchResp{ response = append(response, &proEnt.SearchResp{
Id: item.Id, Id: item.Id,
Name: item.Name, Name: item.Name,
Price: item.Price, Price: float64(item.Price) / 100,
ProductUrl: item.ProductUrl, ProductUrl: item.ProductUrl,
Status: item.Status, Status: item.Status,
CreatedAt: item.CreatedAt.Format(time.RFC3339), CreatedAt: item.CreatedAt.Format(time.RFC3339),
Type: item.Type, Type: item.Type,
ExtendParameter: item.ExtendParameter, ExtendParameter: item.ExtendParameter,
QueueNo: item.QueueNo, QueueNo: item.QueueNo,
Spec: item.Spec,
}) })
} }
} }
@ -111,12 +113,13 @@ func Create(c *gin.Context) {
product := &proMod.Product{ product := &proMod.Product{
Name: request.Name, Name: request.Name,
Price: request.Price, Price: int64(request.Price * 100),
ProductUrl: request.ProductUrl, ProductUrl: request.ProductUrl,
Status: 1, //1.上架 2.下架 Status: 1, //1.上架 2.下架
Type: request.Type, Type: request.Type,
ExtendParameter: request.ExtendParameter, ExtendParameter: request.ExtendParameter,
QueueNo: request.QueueNo, QueueNo: request.QueueNo,
Spec: request.Spec,
} }
affected, err := proServ.Create(product) affected, err := proServ.Create(product)
@ -144,10 +147,11 @@ func Update(c *gin.Context) {
Id: request.Id, Id: request.Id,
Name: request.Name, Name: request.Name,
ProductUrl: request.ProductUrl, ProductUrl: request.ProductUrl,
Price: request.Price, Price: int64(request.Price * 100),
Type: request.Type, Type: request.Type,
ExtendParameter: request.ExtendParameter, ExtendParameter: request.ExtendParameter,
QueueNo: request.QueueNo, QueueNo: request.QueueNo,
Spec: request.Spec,
} }
affected, err := proServ.Update(product) affected, err := proServ.Update(product)

View File

@ -7,13 +7,14 @@ type GetListByIdReq struct {
type GetListByIdResp struct { type GetListByIdResp struct {
Id int64 `json:"id" example:"1"` Id int64 `json:"id" example:"1"`
Name string `json:"name" example:"snow"` Name string `json:"name" example:"snow"`
Price int64 `json:"price" example:"100"` Price float64 `json:"price" example:"100"`
ProductUrl string `json:"product_url" example:"http://www.baidu.com"` ProductUrl string `json:"product_url" example:"http://www.baidu.com"`
Status int64 `json:"status" example:"1"` Status int64 `json:"status" example:"1"`
CreatedAt string `json:"created_at" example:"2020-01-01 00:00:00"` CreatedAt string `json:"created_at" example:"2020-01-01 00:00:00"`
Type int64 `json:"type" example:"1"` Type int64 `json:"type" example:"1"`
ExtendParameter string `json:"extend_parameter" example:"{}"` ExtendParameter string `json:"extend_parameter" example:"{}"`
QueueNo int64 `json:"queue_no" example:"1"` QueueNo int64 `json:"queue_no" example:"1"`
Spec string `json:"spec" example:"{}"`
} }
type SearcgReq struct { type SearcgReq struct {
@ -27,22 +28,24 @@ type SearcgReq struct {
type SearchResp struct { type SearchResp struct {
Id int64 `json:"id" example:"1"` Id int64 `json:"id" example:"1"`
Name string `json:"name" example:"snow"` Name string `json:"name" example:"snow"`
Price int64 `json:"price" example:"100"` Price float64 `json:"price" example:"100"`
ProductUrl string `json:"product_url" example:"http://www.baidu.com"` ProductUrl string `json:"product_url" example:"http://www.baidu.com"`
Status int64 `json:"status" example:"1"` Status int64 `json:"status" example:"1"`
CreatedAt string `json:"created_at" example:"2020-01-01 00:00:00"` CreatedAt string `json:"created_at" example:"2020-01-01 00:00:00"`
Type int64 `json:"type" example:"1"` Type int64 `json:"type" example:"1"`
ExtendParameter string `json:"extend_parameter" example:"{}"` ExtendParameter string `json:"extend_parameter" example:"{}"`
QueueNo int64 `json:"queue_no" example:"1"` QueueNo int64 `json:"queue_no" example:"1"`
Spec string `json:"spec" example:"{}"`
} }
type CreateReq struct { type CreateReq struct {
Name string `json:"name" validate:"required"` Name string `json:"name" validate:"required"`
Price int64 `json:"price" validate:"required"` Price float64 `json:"price" validate:"required"`
ProductUrl string `json:"product_url"` ProductUrl string `json:"product_url"`
Type int64 `json:"type" validate:"required"` Type int64 `json:"type" validate:"required"`
ExtendParameter string `json:"extend_parameter"` ExtendParameter string `json:"extend_parameter"`
QueueNo int64 `json:"queue_no" example:"1"` QueueNo int64 `json:"queue_no" example:"1"`
Spec string `json:"spec" example:"{}"`
} }
type CreateResp struct { type CreateResp struct {
@ -52,11 +55,12 @@ type CreateResp struct {
type UpdateReq struct { type UpdateReq struct {
Id int64 `json:"id" validate:"required"` Id int64 `json:"id" validate:"required"`
Name string `json:"name" ` Name string `json:"name" `
Price int64 `json:"price" ` Price float64 `json:"price" `
ProductUrl string `json:"product_url" ` ProductUrl string `json:"product_url" `
Type int64 `json:"type" ` Type int64 `json:"type" `
ExtendParameter string `json:"extend_parameter"` ExtendParameter string `json:"extend_parameter"`
QueueNo int64 `json:"queue_no" example:"1"` QueueNo int64 `json:"queue_no" example:"1"`
Spec string `json:"spec" example:"{}"`
} }
type UpdateResp struct { type UpdateResp struct {

View File

@ -26,6 +26,7 @@ type Product struct {
Type int64 Type int64
ExtendParameter string ExtendParameter string
QueueNo int64 QueueNo int64
Spec string
} }
/** /**