waybill_task.go 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. package controller
  2. import (
  3. "cold-logistics/app/admin/model"
  4. "cold-logistics/app/admin/service"
  5. "cold-logistics/app/admin/service/dto"
  6. "cold-logistics/common/nats/nats_server"
  7. "github.com/gin-gonic/gin"
  8. "github.com/gin-gonic/gin/binding"
  9. "gogs.baozhida.cn/zoie/OAuth-core/api"
  10. _ "gogs.baozhida.cn/zoie/OAuth-core/pkg/response"
  11. )
  12. type WaybillTaskController struct {
  13. api.Api
  14. }
  15. // GetPage 获取运单任务列表
  16. // @Summary 获取运单任务列表
  17. // @Description 获取运单任务列表
  18. // @Tags 运单任务
  19. // @Param no query string true "运单号"
  20. // @Success 200 {object} response.Response{data=response.Page{list=[]model.WaybillTask}} "{"code": 200, "data": [...]}"
  21. // @Router /api/waybill-task [get]
  22. // @Security Bearer
  23. func (e WaybillTaskController) GetPage(c *gin.Context) {
  24. s := service.WaybillTask{}
  25. req := dto.WaybillTaskGetPageReq{}
  26. err := e.MakeContext(c).
  27. MakeOrm().
  28. Bind(&req, binding.Query).
  29. MakeService(&s.Service).
  30. Errors
  31. if err != nil {
  32. e.Logger.Error(err)
  33. e.Error(500, err, err.Error())
  34. return
  35. }
  36. list := make([]model.WaybillTask, 0)
  37. var count int64
  38. err = s.GetPage(&req, &list, &count)
  39. if err != nil {
  40. e.Error(500, err, err.Error())
  41. return
  42. }
  43. //e.PageOK(list, int(count), req.GetPageIndex(), req.GetPageSize(), "查询成功")
  44. e.PageOK(list, int(count), 0, 0, "查询成功")
  45. }
  46. // GetData 获取温湿度记录
  47. // @Summary 获取传感器列表
  48. // @Description 获取传感器列表
  49. // @Tags 运单任务
  50. // @Accept application/json
  51. // @Product application/json
  52. // @Param data body dto.WaybillTaskGetDataPageReq true "body"
  53. // @Success 200 {object} response.Response{data=response.Page{list=[]model.WaybillTask}} "{"code": 200, "data": [...]}"
  54. // @Router /api/waybill-task/data [post]
  55. // @Security Bearer
  56. func (e WaybillTaskController) GetData(c *gin.Context) {
  57. s := service.WaybillTask{}
  58. req := dto.WaybillTaskGetDataPageReq{}
  59. err := e.MakeContext(c).
  60. MakeOrm().
  61. Bind(&req, binding.JSON, nil).
  62. MakeService(&s.Service).
  63. Errors
  64. if err != nil {
  65. e.Logger.Error(err)
  66. e.Error(500, err, err.Error())
  67. return
  68. }
  69. list := make([]nats_server.DeviceData_R, 0)
  70. var count int64
  71. list, count, err = s.GetDataPage(&req)
  72. if err != nil {
  73. e.Error(500, err, err.Error())
  74. return
  75. }
  76. e.PageOK(list, int(count), req.GetPageIndex(), req.GetPageSize(), "查询成功")
  77. }
  78. func (e WaybillTaskController) GetLocus(c *gin.Context) {
  79. s := service.WaybillTask{}
  80. req := dto.WaybillGetLocusReq{}
  81. err := e.MakeContext(c).
  82. MakeOrm().
  83. Bind(&req, binding.Query).
  84. MakeService(&s.Service).
  85. Errors
  86. if err != nil {
  87. e.Logger.Error(err)
  88. e.Error(500, err, err.Error())
  89. return
  90. }
  91. list := make([]nats_server.DeviceData_R2, 0)
  92. list, err = s.GetLocus(&req)
  93. if err != nil {
  94. e.Error(500, err, err.Error())
  95. return
  96. }
  97. e.OK(list, "获取轨迹信息成功")
  98. }