package storehouse import ( "fmt" "github.com/gin-gonic/gin" "server/global" "server/model/common/request" "server/model/common/response" ) type GoodsApi struct{} func (ga *GoodsApi) QueryAllGoods(c *gin.Context) { goods, err := goodsService.QueryAllGoods() if err != nil { response.FailWithMessage("查询失败", c) global.GVA_LOG.Error("QueryAllGoods ====== " + err.Error()) return } response.OkWithData(goods, c) } func (ga *GoodsApi) QueryGoodsList(c *gin.Context) { var info request.SearchGoods err := c.ShouldBindJSON(&info) if err != nil { response.FailWithMessage("参数错误", c) global.GVA_LOG.Error("QueryGoodsList ====== " + err.Error()) return } fmt.Println(info) list, total, err := goodsService.QueryGoodsList(info) if err != nil { response.FailWithMessage("查询失败", c) global.GVA_LOG.Error("QueryGoodsList ====== " + err.Error()) return } response.OkWithDetailed(response.PageResult{ List: list, Total: total, Page: info.PageInfo.Page, PageSize: info.PageInfo.PageSize, }, "获取成功", c) } func (ga *GoodsApi) GetInventory(c *gin.Context) { var info request.GetInventoryRequest err := c.ShouldBindJSON(&info) if err != nil { response.FailWithMessage("参数错误", c) global.GVA_LOG.Error("QueryGoodsList ====== " + err.Error()) return } inventory := goodsService.GetInventory(info) response.OkWithData(inventory, c) }