order.go 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. package myself
  2. import (
  3. "Cold_Logistic/internal/pkg/common/codex"
  4. "Cold_Logistic/internal/pkg/common/global"
  5. "Cold_Logistic/internal/server/application/myselfsrv"
  6. "Cold_Logistic/internal/server/application/ordersrv"
  7. "Cold_Logistic/internal/server/infra/dao"
  8. "github.com/gin-gonic/gin"
  9. "gogs.baozhida.cn/Cold_Logistic_libs/pkg/contrib/core"
  10. "gogs.baozhida.cn/Cold_Logistic_libs/pkg/contrib/errors"
  11. )
  12. // orderPage
  13. // @Tags 用户-我的
  14. // @BasePath /clodLogistic/app/api/v1
  15. // @Summary 订单列表
  16. // @Success 200 {object} swagger.PageListResponse "成功响应的结构体"
  17. // @Param req body swagger.OrderPageReqVO true "请求参数"
  18. // @Accept application/json
  19. // @Authorization
  20. // @Router /app/myself/orderPage [post]
  21. func (api Api) orderPage(c *gin.Context) {
  22. req := myselfsrv.OrderPageReqVO{}
  23. if err := c.BindJSON(&req); err != nil {
  24. core.WriteErrResponse(c, errors.WithCodeOnce(err, codex.ErrBindJSON, ""))
  25. return
  26. }
  27. srv := myselfsrv.NewMyselfService(dao.NewDataStore(global.CommonConnectRepoInst.StoreDB))
  28. res, err := srv.OrderPage(c, req)
  29. if err != nil {
  30. core.WriteErrResponse(c, errors.WithCodeOnce(err, codex.ErrQueryFailed, ""))
  31. return
  32. }
  33. core.WriteResponse(c, nil, res)
  34. }
  35. // orderSubNo
  36. // @Tags 用户-我的
  37. // @BasePath /clodLogistic/app/api/v1
  38. // @Summary 订单揽件码
  39. // @Success 200 {object} myselfsrv.OrderSubNoRespVO "成功响应的结构体"
  40. // @Param req body myselfsrv.OrderSubNoReqVO true "请求参数"
  41. // @Accept application/json
  42. // @Authorization
  43. // @Router /app/myself/orderSubNo [post]
  44. func (api Api) orderSubNo(c *gin.Context) {
  45. req := myselfsrv.OrderSubNoReqVO{}
  46. if err := c.BindJSON(&req); err != nil {
  47. core.WriteErrResponse(c, errors.WithCodeOnce(err, codex.ErrBindJSON, ""))
  48. return
  49. }
  50. srv := myselfsrv.NewMyselfService(dao.NewDataStore(global.CommonConnectRepoInst.StoreDB))
  51. res, err := srv.OrderSubNo(c, req)
  52. if err != nil {
  53. core.WriteErrResponse(c, errors.WithCodeOnce(err, codex.ErrQueryFailed, ""))
  54. return
  55. }
  56. core.WriteResponse(c, nil, res)
  57. }
  58. // placeOrder
  59. // @Tags 用户-我的
  60. // @BasePath /clodLogistic/app/api/v1
  61. // @Summary 下单
  62. // @Success 200 {object} ordersrv.PlaceOrderRespVO "成功响应的结构体"
  63. // @Param req body ordersrv.PlaceOrderReqVO true "请求参数"
  64. // @Accept application/json
  65. // @Authorization
  66. // @Router /app/myself/placeOrder [post]
  67. func (api Api) placeOrder(c *gin.Context) {
  68. req := ordersrv.PlaceOrderReqVO{}
  69. if err := c.BindJSON(&req); err != nil {
  70. core.WriteErrResponse(c, errors.WithCodeOnce(err, codex.ErrBindJSON, ""))
  71. return
  72. }
  73. if err := req.Validate(); err != nil {
  74. core.WriteErrResponse(c, errors.WithCodeOnce(err, codex.ErrParamValidate, "参数验证失败:"))
  75. return
  76. }
  77. srv := ordersrv.NewOrderService(dao.NewDataStore(global.CommonConnectRepoInst.StoreDB))
  78. res, err := srv.PlaceOrder(c, req)
  79. if err != nil {
  80. core.WriteErrResponse(c, errors.WithCodeOnce(err, codex.ErrPlaceOrderFailed, ""))
  81. return
  82. }
  83. core.WriteResponse(c, nil, res)
  84. }
  85. // placeOrder
  86. // @Tags 用户-我的
  87. // @BasePath /clodLogistic/app/api/v1
  88. // @Summary 订单详情
  89. // @Success 200 {object} ordersrv.OrderDetailRespVO "成功响应的结构体"
  90. // @Param req body ordersrv.OrderDetailReqVO true "请求参数"
  91. // @Accept application/json
  92. // @Authorization
  93. // @Router /app/myself/orderDetail [post]
  94. func (api Api) orderDetail(c *gin.Context) {
  95. req := ordersrv.OrderDetailReqVO{}
  96. if err := c.BindJSON(&req); err != nil {
  97. core.WriteErrResponse(c, errors.WithCodeOnce(err, codex.ErrBindJSON, ""))
  98. return
  99. }
  100. srv := ordersrv.NewOrderService(dao.NewDataStore(global.CommonConnectRepoInst.StoreDB))
  101. res, err := srv.OrderDetail(c, req)
  102. if err != nil {
  103. core.WriteErrResponse(c, errors.WithCodeOnce(err, codex.ErrQueryFailed, ""))
  104. return
  105. }
  106. core.WriteResponse(c, nil, res)
  107. }