package router

import (
	"demo/data/dao"
	"github.com/gin-gonic/gin"
	"strconv"
)

func DetailRouter(engine *gin.RouterGroup) {
	user := engine.Group("/detail")
	{
		user.GET("/:id", GetDetailData)
	}
}

func GetDetailData(c *gin.Context) {
	id, err2 := strconv.Atoi(c.Param("id"))
	if err2 != nil {
		c.JSON(200, CreateResultError(400, "param 参数错误"))
		return
	}

	vo, err := dao.SelectGoodsDetailById(id)
	if err != nil {
		c.JSON(200, CreateResultError(400, "查询失败"))
		return
	}
	c.JSON(200, CreateResultData(vo))
}
