public.go 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. package public
  2. import (
  3. "Cold_Logistic/internal/pkg/common/codex"
  4. "Cold_Logistic/internal/pkg/common/global"
  5. "Cold_Logistic/internal/server/application/devicesrv"
  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. // queryExpressOrder
  13. // @Tags 公开接口不登录
  14. // @BasePath /clodLogistic/app/api/v1
  15. // @Summary 查运单
  16. // @Success 200 {object} ordersrv.QueryExpressOrderRespVO
  17. // @Fail 400 {object} swagger.BaseResponse
  18. // @Param req body ordersrv.QueryExpressOrderReqVO true "运单号"
  19. // @Accept application/json
  20. // @Authorization Bearer
  21. // @Router /app/public/queryOrder [post]
  22. func (api Api) queryExpressOrder(c *gin.Context) {
  23. req := ordersrv.QueryExpressOrderReqVO{}
  24. if err := c.BindJSON(&req); err != nil {
  25. core.WriteErrResponse(c, errors.WithCodeOnce(err, codex.ErrBindJSON, ""))
  26. return
  27. }
  28. if err := req.Validate(); err != nil {
  29. core.WriteErrResponse(c, errors.WithCodeOnce(err, codex.ErrParamValidate, "参数验证失败:"))
  30. return
  31. }
  32. srv := ordersrv.NewOrderService(dao.NewDataStore(global.CommonConnectRepoInst.StoreDB))
  33. res, err := srv.QueryExpressOrder(c, req)
  34. if err != nil {
  35. core.WriteErrResponse(c, errors.WithCodeOnce(err, codex.ErrQueryFailed, ""))
  36. return
  37. }
  38. core.WriteResponse(c, nil, res)
  39. }
  40. // logisticDetail
  41. // @Tags 公开接口不登录
  42. // @BasePath /clodLogistic/app/api/v1
  43. // @Summary 物流详情
  44. // @Success 200 {object} ordersrv.OrderLogisticDetailRespVO
  45. // @Param req body ordersrv.OrderLogisticDetailReqVO true "订单id"
  46. // @Accept application/json
  47. // @Router /app/public/logisticDetail [post]
  48. func (api Api) logisticDetail(c *gin.Context) {
  49. req := ordersrv.OrderLogisticDetailReqVO{}
  50. if err := c.BindJSON(&req); err != nil {
  51. core.WriteErrResponse(c, errors.WithCodeOnce(err, codex.ErrBindJSON, ""))
  52. return
  53. }
  54. if err := req.Validate(); err != nil {
  55. core.WriteErrResponse(c, errors.WithCodeOnce(err, codex.ErrParamValidate, "参数验证失败:"))
  56. return
  57. }
  58. srv := ordersrv.NewOrderService(dao.NewDataStore(global.CommonConnectRepoInst.StoreDB))
  59. res, err := srv.OrderLogisticDetail(c, req)
  60. if err != nil {
  61. core.WriteErrResponse(c, errors.WithCodeOnce(err, codex.ErrQueryFailed, ""))
  62. return
  63. }
  64. core.WriteResponse(c, nil, res)
  65. }
  66. // logisticDetail
  67. // @Tags 公开接口不登录
  68. // @BasePath /clodLogistic/app/api/v1
  69. // @Summary 设备探头列表
  70. // @Success 200 {object} devicesrv.DeviceSensorListRespVO
  71. // @Param req body devicesrv.DeviceSensorListReqVO true "SN"
  72. // @Accept application/json
  73. // @Router /app/public/deviceSensorList [post]
  74. func (api Api) deviceSensorList(c *gin.Context) {
  75. req := devicesrv.DeviceSensorListReqVO{}
  76. if err := c.BindJSON(&req); err != nil {
  77. core.WriteErrResponse(c, errors.WithCodeOnce(err, codex.ErrBindJSON, ""))
  78. return
  79. }
  80. if err := req.Validate(); err != nil {
  81. core.WriteErrResponse(c, errors.WithCodeOnce(err, codex.ErrParamValidate, "参数验证失败:"))
  82. return
  83. }
  84. srv := devicesrv.NewDeviceService(dao.NewDataStore(global.CommonConnectRepoInst.StoreDB))
  85. res, err := srv.DeviceSensorList(c, req)
  86. if err != nil {
  87. core.WriteErrResponse(c, errors.WithCodeOnce(err, codex.ErrQueryFailed, ""))
  88. return
  89. }
  90. core.WriteResponse(c, nil, res)
  91. }
  92. // logisticDetail
  93. // @Tags 公开接口不登录
  94. // @Summary 设备数据列表
  95. // @Success 200 {} swagger.PageListResponse
  96. // @Param req body swagger.SnDataListReqVO true "SN数据"
  97. // @Accept application/json
  98. // @Router /app/public/sensorDataList [post]
  99. func (api Api) snDataList(c *gin.Context) {
  100. req := devicesrv.SnDataListReqVO{}
  101. if err := c.BindJSON(&req); err != nil {
  102. core.WriteErrResponse(c, errors.WithCodeOnce(err, codex.ErrBindJSON, ""))
  103. return
  104. }
  105. if err := req.Validate(); err != nil {
  106. core.WriteErrResponse(c, errors.WithCodeOnce(err, codex.ErrParamValidate, "参数验证失败:"))
  107. return
  108. }
  109. srv := devicesrv.NewDeviceService(dao.NewDataStore(global.CommonConnectRepoInst.StoreDB))
  110. res, err := srv.SnDataList(c, req)
  111. if err != nil {
  112. core.WriteErrResponse(c, errors.WithCodeOnce(err, codex.ErrQueryFailed, ""))
  113. return
  114. }
  115. core.WriteResponse(c, nil, res)
  116. }