package manage import ( "Cold_Logistic/internal/pkg/common/codex" "Cold_Logistic/internal/pkg/common/global" "Cold_Logistic/internal/server/application/warehousesrv" "Cold_Logistic/internal/server/infra/dao" "github.com/gin-gonic/gin" "gogs.baozhida.cn/Cold_Logistic_libs/pkg/contrib/core" "gogs.baozhida.cn/Cold_Logistic_libs/pkg/contrib/errors" ) // warehousePage // @Tags 后台-仓库管理 // @Summary 仓库列表 // @Success 200 {object} swagger.PageListResponse "成功响应的结构体" // @Param req body swagger.WarehousePageReqVO true "请求参数" // @Accept application/json // @Router /manage/warehouse/page [post] func (api Api) warehousePage(c *gin.Context) { req := warehousesrv.WarehousePageReqVO{} if err := c.BindJSON(&req); err != nil { core.WriteErrResponse(c, errors.WithCodeOnce(err, codex.ErrBindJSON, "")) return } srv := warehousesrv.NewWarehouseService(dao.NewDataStore(global.CommonConnectRepoInst.StoreDB)) res, err := srv.WarehousePage(c, req) if err != nil { core.WriteErrResponse(c, errors.WithCodeOnce(err, codex.ErrQueryFailed, "")) return } core.WriteResponse(c, nil, res) } // addWarehouse // @Tags 后台-仓库管理 // @Summary 添加仓库 // @Success 200 {object} warehousesrv.WarehouseIdRespVO "成功响应的结构体" // @Param req body warehousesrv.AddWarehouseReqVO true "请求参数" // @Accept application/json // @Router /manage/warehouse/add [post] func (api Api) addWarehouse(c *gin.Context) { req := warehousesrv.AddWarehouseReqVO{} if err := c.BindJSON(&req); err != nil { core.WriteErrResponse(c, errors.WithCodeOnce(err, codex.ErrBindJSON, "")) return } if err := req.Validate(); err != nil { core.WriteErrResponse(c, errors.WithCodeOnce(err, codex.ErrParamValidate, "")) return } srv := warehousesrv.NewWarehouseService(dao.NewDataStore(global.CommonConnectRepoInst.StoreDB)) res, err := srv.AddWarehouse(c, req) if err != nil { core.WriteErrResponse(c, errors.WithCodeOnce(err, codex.ErrSaveFailed, "")) return } core.WriteResponse(c, nil, res) } // updateWarehouse // @Tags 后台-仓库管理 // @Summary 修改仓库 // @Success 200 {object} warehousesrv.WarehouseIdRespVO "成功响应的结构体" // @Param req body warehousesrv.UpdateWarehouseReqVO true "请求参数" // @Accept application/json // @Router /manage/warehouse/update [post] func (api Api) updateWarehouse(c *gin.Context) { req := warehousesrv.UpdateWarehouseReqVO{} if err := c.BindJSON(&req); err != nil { core.WriteErrResponse(c, errors.WithCodeOnce(err, codex.ErrBindJSON, "")) return } if err := req.Validate(); err != nil { core.WriteErrResponse(c, errors.WithCodeOnce(err, codex.ErrParamValidate, "")) return } srv := warehousesrv.NewWarehouseService(dao.NewDataStore(global.CommonConnectRepoInst.StoreDB)) res, err := srv.UpdateWarehouse(c, req) if err != nil { core.WriteErrResponse(c, errors.WithCodeOnce(err, codex.ErrSaveFailed, "")) return } core.WriteResponse(c, nil, res) } // updateWarehouse // @Tags 后台-仓库管理 // @Summary 仓库订单列表 // @Success 200 {object} swagger.PageListResponse "成功响应的结构体" // @Param req body swagger.WarehousePageReqVO true "请求参数" // @Accept application/json // @Router /manage/warehouse/orderPage [post] func (api Api) warehouseOrder(c *gin.Context) { req := warehousesrv.WarehouseOrderReqVO{} if err := c.ShouldBindJSON(&req); err != nil { core.WriteErrResponse(c, errors.WithCodeOnce(err, codex.ErrBindJSON, "")) return } srv := warehousesrv.NewWarehouseService(dao.NewDataStore(global.CommonConnectRepoInst.StoreDB)) res, err := srv.WarehouseOrder(c, req) if err != nil { core.WriteErrResponse(c, errors.WithCodeOnce(err, codex.ErrQueryFailed, "")) return } core.WriteResponse(c, nil, res) }