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