driver.go 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. package insider
  2. import (
  3. "Cold_Logistic/internal/pkg/common/codex"
  4. "Cold_Logistic/internal/pkg/common/global"
  5. "Cold_Logistic/internal/server/application/driversrv"
  6. "Cold_Logistic/internal/server/infra/dao"
  7. "github.com/gin-gonic/gin"
  8. "gogs.baozhida.cn/Cold_Logistic_libs/pkg/contrib/core"
  9. "gogs.baozhida.cn/Cold_Logistic_libs/pkg/contrib/errors"
  10. )
  11. // carInfo
  12. // @Tags 司机
  13. // @Summary 车辆信息
  14. // @Success 200 {object} driversrv.DriverCarInfoRespVO "成功响应的结构体"
  15. // @Accept application/json
  16. // @Router /app/driver/carInfo [post]
  17. func (api Api) carInfo(c *gin.Context) {
  18. srv := driversrv.NewDriverService(dao.NewDataStore(global.CommonConnectRepoInst.StoreDB))
  19. res, err := srv.DriverCarInfo(c)
  20. if err != nil {
  21. core.WriteErrResponse(c, errors.WithCodeOnce(err, codex.ErrQueryFailed, ""))
  22. return
  23. }
  24. core.WriteResponse(c, nil, res)
  25. }
  26. // taskPage
  27. // @Tags 司机
  28. // @Summary 司机任务列表
  29. // @Success 200 {object} swagger.PageListResponse "成功响应的结构体"
  30. // @Param req body swagger.TaskPageReqVO true "请求参数"
  31. // @Accept application/json
  32. // @Router /app/driver/taskPage [post]
  33. func (api Api) taskPage(c *gin.Context) {
  34. req := driversrv.TaskPageReqVO{}
  35. if err := c.BindJSON(&req); err != nil {
  36. core.WriteErrResponse(c, errors.WithCodeOnce(err, codex.ErrBindJSON, ""))
  37. return
  38. }
  39. if err := req.Validate(); err != nil {
  40. core.WriteErrResponse(c, errors.WithCodeOnce(err, codex.ErrParamValidate, ""))
  41. return
  42. }
  43. srv := driversrv.NewDriverService(dao.NewDataStore(global.CommonConnectRepoInst.StoreDB))
  44. res, err := srv.TaskPage(c, req)
  45. if err != nil {
  46. core.WriteErrResponse(c, errors.WithCodeOnce(err, codex.ErrQueryFailed, ""))
  47. return
  48. }
  49. core.WriteResponse(c, nil, res)
  50. }
  51. // orderIntoCar
  52. // @Tags 司机
  53. // @Summary 装车
  54. // @Success 200 {object} driversrv.OrderIntoCarRespVO "成功响应的结构体"
  55. // @Param req body driversrv.OrderIntoCarReqVO true "请求参数"
  56. // @Accept application/json
  57. // @Router /app/driver/orderIntoCar [post]
  58. func (api Api) orderIntoCar(c *gin.Context) {
  59. req := driversrv.OrderIntoCarReqVO{}
  60. if err := c.ShouldBindJSON(&req); err != nil {
  61. core.WriteErrResponse(c, errors.WithCodeOnce(err, codex.ErrBindJSON, ""))
  62. return
  63. }
  64. if err := req.Validate(); err != nil {
  65. core.WriteErrResponse(c, errors.WithCodeOnce(err, codex.ErrParamValidate, ""))
  66. return
  67. }
  68. srv := driversrv.NewDriverService(dao.NewDataStore(global.CommonConnectRepoInst.StoreDB))
  69. res, err := srv.OrderIntoCar(c, req)
  70. if err != nil {
  71. core.WriteErrResponse(c, errors.WithCodeOnce(err, codex.ErrQueryFailed, ""))
  72. return
  73. }
  74. core.WriteResponse(c, nil, res)
  75. }
  76. // orderIntoCar
  77. // @Tags 司机
  78. // @Summary 扫码装车
  79. // @Success 200 {object} driversrv.OrderIntoCarRespVO "成功响应的结构体"
  80. // @Param req body driversrv.ScanIntoReqVO true "请求参数"
  81. // @Accept application/json
  82. // @Router /app/driver/scanIntoCar [post]
  83. func (api Api) scanIntoCar(c *gin.Context) {
  84. req := driversrv.ScanIntoReqVO{}
  85. if err := c.ShouldBindJSON(&req); err != nil {
  86. core.WriteErrResponse(c, errors.WithCodeOnce(err, codex.ErrBindJSON, ""))
  87. return
  88. }
  89. if err := req.Validate(); err != nil {
  90. core.WriteErrResponse(c, errors.WithCodeOnce(err, codex.ErrParamValidate, ""))
  91. return
  92. }
  93. srv := driversrv.NewDriverService(dao.NewDataStore(global.CommonConnectRepoInst.StoreDB))
  94. res, err := srv.ScanIntoCar(c, req)
  95. if err != nil {
  96. core.WriteErrResponse(c, errors.WithCodeOnce(err, codex.ErrQueryFailed, ""))
  97. return
  98. }
  99. core.WriteResponse(c, nil, res)
  100. }
  101. // orderIntoCar
  102. // @Tags 司机
  103. // @Summary 签收
  104. // @Success 200 {object} driversrv.SignReceiptRespVO "成功响应的结构体"
  105. // @Param req body driversrv.ScanIntoReqVO true "请求参数"
  106. // @failure 400 {string} codex.ErrBindJSON "error"
  107. // @Accept application/json
  108. // @Router /app/driver/signReceipt [post]
  109. func (api Api) signReceipt(c *gin.Context) {
  110. req := driversrv.ScanIntoReqVO{}
  111. if err := c.ShouldBindJSON(&req); err != nil {
  112. core.WriteErrResponse(c, errors.WithCodeOnce(err, codex.ErrBindJSON, ""))
  113. return
  114. }
  115. if err := req.Validate(); err != nil {
  116. core.WriteErrResponse(c, errors.WithCodeOnce(err, codex.ErrParamValidate, ""))
  117. return
  118. }
  119. srv := driversrv.NewDriverService(dao.NewDataStore(global.CommonConnectRepoInst.StoreDB))
  120. res, err := srv.SignReceipt(c, req)
  121. if err != nil {
  122. core.WriteErrResponse(c, errors.WithCodeOnce(err, codex.ErrQueryFailed, ""))
  123. return
  124. }
  125. core.WriteResponse(c, nil, res)
  126. }