123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113 |
- 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)
- }
|