package myself import ( "Cold_Logistic/internal/pkg/common/codex" "Cold_Logistic/internal/pkg/common/global" "Cold_Logistic/internal/server/application/myselfsrv" "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" ) // logisticPage // @Tags 用户-我的 // @BasePath /clodLogistic/app/api/v1 // @Summary 物流公司列表 // @Success 200 {object} swagger.PageListResponse "成功响应的结构体" // @Param req body swagger.LogisticPageReqVO true "请求参数" // @Accept application/json // @Authorization // @Router /app/myself/logisticCompany/page [post] func (api Api) logisticPage(c *gin.Context) { req := myselfsrv.LogisticPageReqVO{} if err := c.BindJSON(&req); err != nil { core.WriteErrResponse(c, errors.WithCodeOnce(err, codex.ErrBindJSON, "")) return } srv := myselfsrv.NewMyselfService(dao.NewDataStore(global.CommonConnectRepoInst.StoreDB)) res, err := srv.LogisticPage(c, req) if err != nil { core.WriteErrResponse(c, errors.WithCodeOnce(err, codex.ErrQueryFailed, "")) return } core.WriteResponse(c, nil, res) } // addLogistic // @Tags 用户-我的 // @BasePath /clodLogistic/app/api/v1 // @Summary 物流公司添加 // @Success 200 {object} myselfsrv.LogisticIdRespVO "成功响应的结构体" // @Param req body myselfsrv.AddLogisticReqVO true "请求参数" // @Accept application/json // @Authorization // @Router /app/myself/logisticCompany/add [post] func (api Api) addLogistic(c *gin.Context) { req := myselfsrv.AddLogisticReqVO{} 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 := myselfsrv.NewMyselfService(dao.NewDataStore(global.CommonConnectRepoInst.StoreDB)) res, err := srv.AddLogistic(c, req) if err != nil { core.WriteErrResponse(c, errors.WithCodeOnce(err, codex.ErrSaveFailed, "")) return } core.WriteResponse(c, nil, res) } // deleteLogistic // @Tags 用户-我的 // @BasePath /clodLogistic/app/api/v1 // @Summary 物流公司删除 // @Success 200 {object} swagger.BaseResponse "成功响应的结构体" // @Param req body myselfsrv.DeleteLogisticReqVO true "请求参数" // @Accept application/json // @Authorization // @Router /app/myself/logisticCompany/delete [post] func (api Api) deleteLogistic(c *gin.Context) { req := myselfsrv.DeleteLogisticReqVO{} 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 := myselfsrv.NewMyselfService(dao.NewDataStore(global.CommonConnectRepoInst.StoreDB)) err := srv.DeleteLogistic(c, req) if err != nil { core.WriteErrResponse(c, errors.WithCodeOnce(err, codex.ErrDeletedFailed, "")) return } core.WriteResponse(c, nil, nil) }