diff --git a/app/http/controllers/product/product.go b/app/http/controllers/product/product.go index bb8fa84..202d2c1 100644 --- a/app/http/controllers/product/product.go +++ b/app/http/controllers/product/product.go @@ -31,13 +31,14 @@ func GetById(c *gin.Context) { response = &proEnt.GetListByIdResp{ Id: res.Id, Name: res.Name, - Price: res.Price, + Price: float64(res.Price) / 100, ProductUrl: res.ProductUrl, Status: res.Status, CreatedAt: res.CreatedAt.Format(time.RFC3339), Type: res.Type, ExtendParameter: res.ExtendParameter, QueueNo: res.QueueNo, + Spec: res.Spec, } } @@ -76,13 +77,14 @@ func Search(c *gin.Context) { response = append(response, &proEnt.SearchResp{ Id: item.Id, Name: item.Name, - Price: item.Price, + Price: float64(item.Price) / 100, ProductUrl: item.ProductUrl, Status: item.Status, CreatedAt: item.CreatedAt.Format(time.RFC3339), Type: item.Type, ExtendParameter: item.ExtendParameter, QueueNo: item.QueueNo, + Spec: item.Spec, }) } } @@ -111,12 +113,13 @@ func Create(c *gin.Context) { product := &proMod.Product{ Name: request.Name, - Price: request.Price, + Price: int64(request.Price * 100), ProductUrl: request.ProductUrl, Status: 1, //1.上架 2.下架 Type: request.Type, ExtendParameter: request.ExtendParameter, QueueNo: request.QueueNo, + Spec: request.Spec, } affected, err := proServ.Create(product) @@ -144,10 +147,11 @@ func Update(c *gin.Context) { Id: request.Id, Name: request.Name, ProductUrl: request.ProductUrl, - Price: request.Price, + Price: int64(request.Price * 100), Type: request.Type, ExtendParameter: request.ExtendParameter, QueueNo: request.QueueNo, + Spec: request.Spec, } affected, err := proServ.Update(product) diff --git a/app/http/entities/product/product.go b/app/http/entities/product/product.go index bf5abba..2666336 100644 --- a/app/http/entities/product/product.go +++ b/app/http/entities/product/product.go @@ -5,15 +5,16 @@ type GetListByIdReq struct { } type GetListByIdResp struct { - Id int64 `json:"id" example:"1"` - Name string `json:"name" example:"snow"` - Price int64 `json:"price" example:"100"` - ProductUrl string `json:"product_url" example:"http://www.baidu.com"` - Status int64 `json:"status" example:"1"` - CreatedAt string `json:"created_at" example:"2020-01-01 00:00:00"` - Type int64 `json:"type" example:"1"` - ExtendParameter string `json:"extend_parameter" example:"{}"` - QueueNo int64 `json:"queue_no" example:"1"` + Id int64 `json:"id" example:"1"` + Name string `json:"name" example:"snow"` + Price float64 `json:"price" example:"100"` + ProductUrl string `json:"product_url" example:"http://www.baidu.com"` + Status int64 `json:"status" example:"1"` + CreatedAt string `json:"created_at" example:"2020-01-01 00:00:00"` + Type int64 `json:"type" example:"1"` + ExtendParameter string `json:"extend_parameter" example:"{}"` + QueueNo int64 `json:"queue_no" example:"1"` + Spec string `json:"spec" example:"{}"` } type SearcgReq struct { @@ -25,24 +26,26 @@ type SearcgReq struct { } type SearchResp struct { - Id int64 `json:"id" example:"1"` - Name string `json:"name" example:"snow"` - Price int64 `json:"price" example:"100"` - ProductUrl string `json:"product_url" example:"http://www.baidu.com"` - Status int64 `json:"status" example:"1"` - CreatedAt string `json:"created_at" example:"2020-01-01 00:00:00"` - Type int64 `json:"type" example:"1"` - ExtendParameter string `json:"extend_parameter" example:"{}"` - QueueNo int64 `json:"queue_no" example:"1"` + Id int64 `json:"id" example:"1"` + Name string `json:"name" example:"snow"` + Price float64 `json:"price" example:"100"` + ProductUrl string `json:"product_url" example:"http://www.baidu.com"` + Status int64 `json:"status" example:"1"` + CreatedAt string `json:"created_at" example:"2020-01-01 00:00:00"` + Type int64 `json:"type" example:"1"` + ExtendParameter string `json:"extend_parameter" example:"{}"` + QueueNo int64 `json:"queue_no" example:"1"` + Spec string `json:"spec" example:"{}"` } type CreateReq struct { - Name string `json:"name" validate:"required"` - Price int64 `json:"price" validate:"required"` - ProductUrl string `json:"product_url"` - Type int64 `json:"type" validate:"required"` - ExtendParameter string `json:"extend_parameter"` - QueueNo int64 `json:"queue_no" example:"1"` + Name string `json:"name" validate:"required"` + Price float64 `json:"price" validate:"required"` + ProductUrl string `json:"product_url"` + Type int64 `json:"type" validate:"required"` + ExtendParameter string `json:"extend_parameter"` + QueueNo int64 `json:"queue_no" example:"1"` + Spec string `json:"spec" example:"{}"` } type CreateResp struct { @@ -50,13 +53,14 @@ type CreateResp struct { } type UpdateReq struct { - Id int64 `json:"id" validate:"required"` - Name string `json:"name" ` - Price int64 `json:"price" ` - ProductUrl string `json:"product_url" ` - Type int64 `json:"type" ` - ExtendParameter string `json:"extend_parameter"` - QueueNo int64 `json:"queue_no" example:"1"` + Id int64 `json:"id" validate:"required"` + Name string `json:"name" ` + Price float64 `json:"price" ` + ProductUrl string `json:"product_url" ` + Type int64 `json:"type" ` + ExtendParameter string `json:"extend_parameter"` + QueueNo int64 `json:"queue_no" example:"1"` + Spec string `json:"spec" example:"{}"` } type UpdateResp struct { diff --git a/app/models/product/product.go b/app/models/product/product.go index d391ad5..828f8b8 100644 --- a/app/models/product/product.go +++ b/app/models/product/product.go @@ -26,6 +26,7 @@ type Product struct { Type int64 ExtendParameter string QueueNo int64 + Spec string } /**