You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
55 lines
1.5 KiB
55 lines
1.5 KiB
package customer
|
|
|
|
import (
|
|
"shop-api/api/sys"
|
|
"shop-api/global"
|
|
"shop-api/model/request"
|
|
"shop-api/model/response"
|
|
"shop-api/service"
|
|
"shop-api/utils"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
"go.uber.org/zap"
|
|
)
|
|
|
|
// GetTbGoodsDetail
|
|
// @Summary 获取商品详情
|
|
// @Description
|
|
// @Tags goods
|
|
// @Security ApiKeyAuth
|
|
// @Param data query request.Goods false "params"
|
|
// @Success 200 {object} model.TbGoodsDetail "{"code": 200, "data": {}}"
|
|
// @Router /goods/detail [get]
|
|
func GetTbGoodsDetail(c *gin.Context) {
|
|
var info request.Goods
|
|
_ = c.ShouldBindQuery(&info)
|
|
if err, data := service.GetTbGoodsWithMission(sys.GetUserUuid(c), info); err != nil {
|
|
global.MG_LOG.Error("获取失败!", zap.Any("err", err))
|
|
response.FailWithMessage("获取失败", c)
|
|
} else {
|
|
response.OkWithData(data, c)
|
|
}
|
|
}
|
|
|
|
// CollectGoods
|
|
// @Summary 收藏/取消收藏商品 [v1.0]
|
|
// @Description
|
|
// @Tags goods
|
|
// @Security ApiKeyAuth
|
|
// @Param data body request.SpuNo false "params"
|
|
// @Success 200 {string} string "{"code": 200, "data": {}}"
|
|
// @Router /goods/collect [post]
|
|
func CollectGoods(c *gin.Context) {
|
|
var info request.SpuNo
|
|
_ = c.ShouldBindJSON(&info)
|
|
if err := utils.Verify(info, utils.SpuNoVerify); err != nil {
|
|
response.FailWithMessage(err.Error(), c)
|
|
return
|
|
}
|
|
if err, id := service.ChangeCollectionGoods(sys.GetUserUuid(c), info); err != nil {
|
|
global.MG_LOG.Error("操作失败!"+err.Error(), zap.Any("err", err))
|
|
response.FailWithMessage("操作失败!"+err.Error(), c)
|
|
} else {
|
|
response.OkWithDetailed(id, "操作成功", c)
|
|
}
|
|
}
|
|
|