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 { 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 { back.Fail(c, "未登录") 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, "total": count, }) } type ArgsDel struct { Ids []int `json:"ids" form:"ids"` } // @Title 删除橱柜商品 // @Param Ids []int true "删除橱柜商品id数组" func (cup *Cupboard) Delete(c *gin.Context) { uid := common.GetUserId(c) argsDel := ArgsDel{} if err := tools.ParseParams(&argsDel, c); err != nil { back.Fail(c, err.Error()) return } if len(argsDel.Ids) == 0 { back.Fail(c, "参数不全") return } if (&goods.Cupboard{}).Delete(uid, argsDel.Ids) { back.Suc(c, "操作成功", "") return } else { back.Fail(c, "操作失败") return } }