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.
67 lines
1.3 KiB
67 lines
1.3 KiB
5 years ago
|
package goods
|
||
|
|
||
|
import (
|
||
|
"github.com/gin-gonic/gin"
|
||
|
"live/app/common"
|
||
|
"live/app/lib"
|
||
|
"live/app/lib/back"
|
||
|
"live/app/lib/tools"
|
||
|
"live/app/logic/goods"
|
||
|
)
|
||
|
|
||
|
type Cupboard struct {
|
||
|
}
|
||
|
|
||
|
// 橱柜列表请求参数
|
||
|
type ListArgs struct {
|
||
|
Keyword uint `json:"keyword"` // 检索关键字
|
||
|
lib.Page
|
||
|
}
|
||
|
|
||
|
// @Title 获取橱柜列表
|
||
|
// @Param keyword string false "检索关键字"
|
||
|
// @Param page int false "页数 默认1"
|
||
|
// @Param limit int false "分页大小"
|
||
|
func (cup *Cupboard) List(c *gin.Context) {
|
||
|
uid := common.GetUserId(c)
|
||
|
if uid == 0 {
|
||
|
return
|
||
|
}
|
||
|
args := ListArgs{}
|
||
|
if err := tools.ParseParams(&args, c); err != nil {
|
||
|
back.Fail(c, err.Error())
|
||
|
return
|
||
|
}
|
||
|
list, count := (&goods.Cupboard{}).GetList(uid, args.Page)
|
||
|
|
||
|
back.Suc(c, "操作成功", gin.H{
|
||
|
"list": list,
|
||
|
"count": count,
|
||
|
})
|
||
|
}
|
||
|
|
||
|
type ArgsDel struct {
|
||
|
Ids []int `json:"ids"`
|
||
|
}
|
||
|
|
||
|
// @Title 删除橱柜商品
|
||
|
// @Param Ids []int true "删除橱柜商品id数组"
|
||
|
func (cup *Cupboard) Delete(c *gin.Context) {
|
||
|
uid := common.GetUserId(c)
|
||
|
if uid == 0 {
|
||
|
return
|
||
|
}
|
||
|
argsDel := ArgsDel{}
|
||
|
if err := tools.ParseParams(&argsDel, c); err != nil {
|
||
|
back.Fail(c, err.Error())
|
||
|
return
|
||
|
}
|
||
|
if (&goods.Cupboard{}).Delete(uid, argsDel.Ids) {
|
||
|
back.Suc(c, "操作成功", "")
|
||
|
return
|
||
|
} else {
|
||
|
back.Fail(c, "操作失败")
|
||
|
return
|
||
|
}
|
||
|
}
|