house.go 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. package insider
  2. import (
  3. "Cold_Logistic/internal/pkg/common/codex"
  4. "Cold_Logistic/internal/pkg/common/global"
  5. "Cold_Logistic/internal/server/application/warehousesrv"
  6. "Cold_Logistic/internal/server/infra/dao"
  7. "github.com/gin-gonic/gin"
  8. "gogs.baozhida.cn/Cold_Logistic_libs/pkg/contrib/core"
  9. "gogs.baozhida.cn/Cold_Logistic_libs/pkg/contrib/errors"
  10. )
  11. // houseInfo
  12. // @Tags 仓管
  13. // @Summary 仓库信息
  14. // @Success 200 {object} warehousesrv.WarehouseInfoRespVO "成功响应的结构体"
  15. // @Accept application/json
  16. // @Router /app/warehouse/info [post]
  17. func (api Api) houseInfo(c *gin.Context) {
  18. srv := warehousesrv.NewWarehouseService(dao.NewDataStore(global.CommonConnectRepoInst.StoreDB))
  19. res, err := srv.WarehouseInfo(c)
  20. if err != nil {
  21. core.WriteErrResponse(c, errors.WithCodeOnce(err, codex.ErrQueryFailed, ""))
  22. return
  23. }
  24. core.WriteResponse(c, nil, res)
  25. }
  26. // warehouseOrder
  27. // @Tags 仓管
  28. // @Summary 库中订单列表
  29. // @Success 200 {object} swagger.PageListResponse "成功响应的结构体"
  30. // @Param req body swagger.WarehouseOrderReqVO true "请求参数"
  31. // @Accept application/json
  32. // @Router /app/warehouse/orderPage [post]
  33. func (api Api) warehouseOrder(c *gin.Context) {
  34. req := warehousesrv.WarehouseOrderReqVO{}
  35. if err := c.ShouldBindJSON(&req); err != nil {
  36. core.WriteErrResponse(c, errors.WithCodeOnce(err, codex.ErrBindJSON, ""))
  37. return
  38. }
  39. srv := warehousesrv.NewWarehouseService(dao.NewDataStore(global.CommonConnectRepoInst.StoreDB))
  40. res, err := srv.WarehouseOrder(c, req)
  41. if err != nil {
  42. core.WriteErrResponse(c, errors.WithCodeOnce(err, codex.ErrQueryFailed, ""))
  43. return
  44. }
  45. core.WriteResponse(c, nil, res)
  46. }
  47. // orderIntoHouse
  48. // @Tags 仓管
  49. // @Summary 订单入库
  50. // @Success 200 {object} warehousesrv.OrderIntoHouseRespVO "成功响应的结构体"
  51. // @Param req body warehousesrv.OrderIntoHouseReqVO true "请求参数"
  52. // @Accept application/json
  53. // @Router /app/warehouse/orderInto [post]
  54. func (api Api) orderIntoHouse(c *gin.Context) {
  55. req := warehousesrv.OrderIntoHouseReqVO{}
  56. if err := c.ShouldBindJSON(&req); err != nil {
  57. core.WriteErrResponse(c, errors.WithCodeOnce(err, codex.ErrBindJSON, ""))
  58. return
  59. }
  60. if err := req.Validate(); err != nil {
  61. core.WriteErrResponse(c, errors.WithCodeOnce(err, codex.ErrParamValidate, ""))
  62. return
  63. }
  64. srv := warehousesrv.NewWarehouseService(dao.NewDataStore(global.CommonConnectRepoInst.StoreDB))
  65. res, err := srv.OrderIntoHouse(c, req)
  66. if err != nil {
  67. core.WriteErrResponse(c, errors.WithCodeOnce(err, codex.ErrQueryFailed, ""))
  68. return
  69. }
  70. core.WriteResponse(c, nil, res)
  71. }
  72. // orderOutHouse
  73. // @Tags 仓管
  74. // @Summary 订单出库
  75. // @Success 200 {object} warehousesrv.OrderIntoHouseRespVO "成功响应的结构体"
  76. // @Param req body warehousesrv.OrderIntoHouseReqVO true "请求参数"
  77. // @Accept application/json
  78. // @Router /app/warehouse/orderOutHouse [post]
  79. func (api Api) orderOutHouse(c *gin.Context) {
  80. req := warehousesrv.OrderIntoHouseReqVO{}
  81. if err := c.ShouldBindJSON(&req); err != nil {
  82. core.WriteErrResponse(c, errors.WithCodeOnce(err, codex.ErrBindJSON, ""))
  83. return
  84. }
  85. if err := req.Validate(); err != nil {
  86. core.WriteErrResponse(c, errors.WithCodeOnce(err, codex.ErrParamValidate, ""))
  87. return
  88. }
  89. srv := warehousesrv.NewWarehouseService(dao.NewDataStore(global.CommonConnectRepoInst.StoreDB))
  90. res, err := srv.OrderIntoHouse(c, req)
  91. if err != nil {
  92. core.WriteErrResponse(c, errors.WithCodeOnce(err, codex.ErrQueryFailed, ""))
  93. return
  94. }
  95. core.WriteResponse(c, nil, res)
  96. }