12345678910111213141516171819202122232425262728293031323334 |
- package product
- import (
- "eta/eta_mini_ht_api/common/exception"
- "eta/eta_mini_ht_api/controllers"
- productService "eta/eta_mini_ht_api/service/product"
- )
- type ProductController struct {
- controllers.BaseController
- }
- // GetProductInfo 获取商品信息
- // @Summary 获取商品信息
- // @Description 获取商品信息
- // @Success 200 {object} controllers.BaseResponse
- // @router /getProductInfo [get]
- func (p *ProductController) GetProductInfo(productId int) {
- controllers.Wrap(&p.BaseController, func() (result *controllers.WrapData, err error) {
- result = p.InitWrapData("获取商品详情失败")
- if productId <= 0 {
- err = exception.New(exception.IllegalProductId)
- p.FailedResult("获取商品详情失败", result)
- return
- }
- productInfo, err := productService.GetProductInfoById(productId)
- if err != nil {
- p.FailedResult("获取商品详情失败", result)
- return
- }
- p.SuccessResult("获取商品详情成功", productInfo, result)
- return
- })
- }
|