123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152 |
- package controller
- import (
- "cold-delivery/app/admin/model"
- "cold-delivery/app/admin/service"
- "cold-delivery/app/admin/service/dto"
- "cold-delivery/common/nats/nats_server"
- "github.com/gin-gonic/gin"
- "github.com/gin-gonic/gin/binding"
- "gogs.baozhida.cn/zoie/OAuth-core/api"
- _ "gogs.baozhida.cn/zoie/OAuth-core/pkg/response"
- )
- type WaybillTaskController struct {
- api.Api
- }
- // GetPage 获取运单任务列表
- // @Summary 获取运单任务列表
- // @Description 获取运单任务列表
- // @Tags 运单任务
- // @Param waybillNo query string true "运单号"
- // @Success 200 {object} response.Response{data=response.Page{list=[]model.WaybillTask}} "{"code": 200, "data": [...]}"
- // @Router /api/waybill-task [get]
- // @Security Bearer
- func (e WaybillTaskController) GetPage(c *gin.Context) {
- s := service.WaybillTask{}
- req := dto.WaybillTaskGetPageReq{}
- err := e.MakeContext(c).
- MakeOrm().
- Bind(&req, binding.Query).
- MakeService(&s.Service).
- Errors
- if err != nil {
- e.Logger.Error(err)
- e.Error(500, err, err.Error())
- return
- }
- list := make([]model.WaybillTask, 0)
- var count int64
- err = s.GetPage(&req, &list, &count)
- if err != nil {
- e.Error(500, err, err.Error())
- return
- }
- //e.PageOK(list, int(count), req.GetPageIndex(), req.GetPageSize(), "查询成功")
- e.PageOK(list, int(count), 0, 0, "查询成功")
- }
- // GetData 获取温湿度记录
- // @Summary 获取温湿度记录
- // @Description 获取温湿度记录
- // @Tags 运单任务
- // @Accept application/json
- // @Product application/json
- // @Param data body dto.WaybillTaskGetDataPageReq true "body"
- // @Success 200 {object} response.Response{data=response.Page{list=[]model.WaybillTask}} "{"code": 200, "data": [...]}"
- // @Router /api/waybill-task/data [post]
- // @Security Bearer
- func (e WaybillTaskController) GetData(c *gin.Context) {
- s := service.WaybillTask{}
- req := dto.WaybillTaskGetDataPageReq{}
- err := e.MakeContext(c).
- MakeOrm().
- Bind(&req, binding.JSON, nil).
- MakeService(&s.Service).
- Errors
- if err != nil {
- e.Logger.Error(err)
- e.Error(500, err, err.Error())
- return
- }
- list := make([]nats_server.DeviceData_R, 0)
- var count int64
- list, count, err = s.GetDataPage(&req)
- if err != nil {
- e.Error(500, err, err.Error())
- return
- }
- e.PageOK(list, int(count), req.GetPageIndex(), req.GetPageSize(), "查询成功")
- }
- // GetNewestData 获取最新温湿度记录
- // @Summary 获取最新温湿度记录
- // @Description 获取最新温湿度记录
- // @Tags 运单任务
- // @Accept application/json
- // @Product application/json
- // @Param data body dto.WaybillTaskGetNewestDataPageReq true "body"
- // @Success 200 {object} response.Response{data=response.Page{list=[]model.WaybillTask}} "{"code": 200, "data": [...]}"
- // @Router /api/waybill-task/newest-locus [post]
- // @Security Bearer
- func (e WaybillTaskController) GetNewestData(c *gin.Context) {
- s := service.WaybillTask{}
- req := dto.WaybillTaskGetNewestDataPageReq{}
- err := e.MakeContext(c).
- MakeOrm().
- Bind(&req, binding.JSON, nil).
- MakeService(&s.Service).
- Errors
- if err != nil {
- e.Logger.Error(err)
- e.Error(500, err, err.Error())
- return
- }
- data := nats_server.DeviceData_R{}
- data, err = s.GetNewestDataPage(&req)
- if err != nil {
- e.Error(500, err, err.Error())
- return
- }
- e.OK(data, "查询成功")
- }
- // GetLocus 获取轨迹信息
- // @Summary 获取轨迹信息
- // @Description 获取轨迹信息
- // @Tags 运单任务
- // @Accept application/json
- // @Product application/json
- // @Param data body dto.WaybillTaskGetNewestDataPageReq true "body"
- // @Success 200 {object} response.Response{data=response.Page{list=[]model.WaybillTask}} "{"code": 200, "data": [...]}"
- // @Router /api/waybill-task/locus [post]
- // @Security Bearer
- func (e WaybillTaskController) GetLocus(c *gin.Context) {
- s := service.WaybillTask{}
- req := dto.WaybillGetLocusReq{}
- err := e.MakeContext(c).
- MakeOrm().
- Bind(&req, binding.Query).
- MakeService(&s.Service).
- Errors
- if err != nil {
- e.Logger.Error(err)
- e.Error(500, err, err.Error())
- return
- }
- list := make([]nats_server.DeviceData_R2, 0)
- list, err = s.GetLocus(&req)
- if err != nil {
- e.Error(500, err, err.Error())
- return
- }
- e.OK(list, "获取轨迹信息成功")
- }
|