|
|
|
@ -7,6 +7,7 @@ import (
|
|
|
|
|
"recook/internal/dbc"
|
|
|
|
|
"recook/internal/model/goods"
|
|
|
|
|
"recook/tools"
|
|
|
|
|
"strconv"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
type ArgsList struct {
|
|
|
|
@ -17,6 +18,12 @@ type ArgsList struct {
|
|
|
|
|
|
|
|
|
|
// 获取商品列表
|
|
|
|
|
func List(c *gin.Context) {
|
|
|
|
|
id, err := strconv.Atoi(c.Request.Header.Get("X-Recook-ID"))
|
|
|
|
|
if id <= 0 || err != nil {
|
|
|
|
|
back.Fail(c, "游客无法使用该功能,请登录")
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
argsList := ArgsList{}
|
|
|
|
|
if err := tools.ParseParams(&argsList, c); err != nil {
|
|
|
|
|
back.Fail(c, err.Error())
|
|
|
|
@ -54,7 +61,7 @@ func List(c *gin.Context) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
back.Suc(c, "", gin.H{
|
|
|
|
|
"list": goods2.GetListByLive(goodsList),
|
|
|
|
|
"list": goods2.GetListByLive(goodsList, uint(id)),
|
|
|
|
|
"total": total,
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
@ -65,6 +72,12 @@ type ArgsListIds struct {
|
|
|
|
|
|
|
|
|
|
// 根据商品id获取列表
|
|
|
|
|
func Infos(c *gin.Context) {
|
|
|
|
|
id, err := strconv.Atoi(c.Request.Header.Get("X-Recook-ID"))
|
|
|
|
|
if id <= 0 || err != nil {
|
|
|
|
|
back.Fail(c, "游客无法使用该功能,请登录")
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
argsListIds := ArgsListIds{}
|
|
|
|
|
if err := tools.ParseParams(&argsListIds, c); err != nil {
|
|
|
|
|
back.Fail(c, err.Error())
|
|
|
|
@ -81,7 +94,7 @@ func Infos(c *gin.Context) {
|
|
|
|
|
Where("id in (?)", argsListIds.Ids).
|
|
|
|
|
Find(&goodsList)
|
|
|
|
|
|
|
|
|
|
back.Suc(c, "", goods2.GetListByLive(goodsList))
|
|
|
|
|
back.Suc(c, "", goods2.GetListByLive(goodsList, uint(id)))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type ArgsBrand struct {
|
|
|
|
|