/* * @Author: deng.yinping deng.yinping@muchinfo.cn * @Date: 2024-12-17 13:04:09 * @LastEditors: deng.yinping deng.yinping@muchinfo.cn * @LastEditTime: 2024-12-17 13:29:44 * @FilePath: \MTP20_IF\controllers\sbyj\goods-inventory.go * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE */ package sbyj import ( "mtp2_if/global/app" "mtp2_if/global/e" "mtp2_if/logger" "mtp2_if/models" "net/http" "github.com/gin-gonic/gin" ) type QueryUserGoodsInventoryReq struct { UserId int `form:"userId" binding:"required"` // 用户ID } // QueryUserGoodsInventory 用户库存查询 // @Summary 用户库存查询 // @Produce json // @Security ApiKeyAuth // @Param userId query int true "用户ID" // @Success 200 {array} models.UserGoodsInventoryRsp // @Failure 500 {object} app.Response // @Router /sbyj/QueryUserGoodsInventory [get] // @Tags 订单系统 func QueryUserGoodsInventory(c *gin.Context) { appG := app.Gin{C: c} // 获取请求参数 var req QueryUserGoodsInventoryReq if err := appG.C.ShouldBindQuery(&req); err != nil { logger.GetLogger().Errorf("QueryUserGoodsInventory failed: %s", err.Error()) appG.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil) return } // 获取数据 rsp, err := models.FindUserGoodsInventory(req.UserId) if err != nil { // 查询失败 logger.GetLogger().Errorf("QueryUserGoodsInventory failed: %s", err.Error()) appG.Response(http.StatusBadRequest, e.ERROR_QUERY_FAIL, nil) return } // 查询成功返回 appG.Response(http.StatusOK, e.SUCCESS, rsp) } type QueryUserGoodsInventoryLogReq struct { UserId int `form:"userId" binding:"required"` // 用户ID GoodsId int `form:"goodsId"` // 商品ID } // QueryUserGoodsInventoryLog 用户出入库流水查询 // @Summary 用户出入库流水查询 // @Produce json // @Security ApiKeyAuth // @Param userId query int true "用户ID" // @Param goodsId query int false "商品ID" // @Success 200 {array} models.UsergoodsinventorylogRsp // @Failure 500 {object} app.Response // @Router /sbyj/QueryUserGoodsInventoryLog [get] // @Tags 订单系统 func QueryUserGoodsInventoryLog(c *gin.Context) { appG := app.Gin{C: c} // 获取请求参数 var req QueryUserGoodsInventoryLogReq if err := appG.C.ShouldBindQuery(&req); err != nil { logger.GetLogger().Errorf("QueryUserGoodsInventoryLog failed: %s", err.Error()) appG.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil) return } // 获取数据 rsp, err := models.FindUserGoodsInventoryLog(req.UserId, req.GoodsId) if err != nil { // 查询失败 logger.GetLogger().Errorf("QueryUserGoodsInventoryLog failed: %s", err.Error()) appG.Response(http.StatusBadRequest, e.ERROR_QUERY_FAIL, nil) return } // 查询成功返回 appG.Response(http.StatusOK, e.SUCCESS, rsp) }