waybill_logistics.go 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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/actions"
  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/jwtauth/user"
  11. _ "gogs.baozhida.cn/zoie/OAuth-core/pkg/response"
  12. )
  13. type WaybillLogisticsController struct {
  14. api.Api
  15. }
  16. // GetPage 获取运单物流信息列表
  17. // @Summary 获取运单物流信息列表
  18. // @Description 获取运单物流信息列表
  19. // @Tags 运单物流信息
  20. // @Param waybillNo query string false "运单号"
  21. // @Param status query int false "状态"
  22. // @Param pageSize query int false "页条数"
  23. // @Param page query int false "页码"
  24. // @Success 200 {object} response.Response{data=response.Page{list=[]model.WaybillLogistics}} "{"code": 200, "data": [...]}"
  25. // @Router /api/waybill-logistics [get]
  26. // @Security Bearer
  27. func (e WaybillLogisticsController) GetPage(c *gin.Context) {
  28. s := service.WaybillLogistics{}
  29. req := dto.WaybillLogisticsGetPageReq{}
  30. err := e.MakeContext(c).
  31. MakeOrm().
  32. Bind(&req, binding.Query).
  33. MakeService(&s.Service).
  34. Errors
  35. if err != nil {
  36. e.Logger.Error(err)
  37. e.Error(500, err, err.Error())
  38. return
  39. }
  40. list := make([]model.WaybillLogistics, 0)
  41. var count int64
  42. err = s.GetPage(&req, &list, &count)
  43. if err != nil {
  44. e.Error(500, err, err.Error())
  45. return
  46. }
  47. //e.PageOK(list, int(count), req.GetPageIndex(), req.GetPageSize(), "查询成功")
  48. e.PageOK(list, int(count), 0, 0, "查询成功")
  49. }
  50. // Update 修改运单物流
  51. // @Summary 修改运单物流
  52. // @Description 修改运单物流
  53. // @Tags 运单物流信息
  54. // @Accept application/json
  55. // @Product application/json
  56. // @Param data body dto.WaybillLogisticsUpdateReq true "body"
  57. // @Success 200 {string} string "{"code": 200, "message": "修改成功"}"
  58. // @Success 200 {string} string "{"code": -1, "message": "修改失败"}"
  59. // @Router /api/waybill [put]
  60. // @Security Bearer
  61. func (e WaybillLogisticsController) Update(c *gin.Context) {
  62. s := service.WaybillLogistics{}
  63. req := dto.WaybillLogisticsUpdateReq{}
  64. err := e.MakeContext(c).
  65. MakeOrm().
  66. Bind(&req).
  67. MakeService(&s.Service).
  68. Errors
  69. if err != nil {
  70. e.Logger.Error(err)
  71. e.Error(500, err, err.Error())
  72. return
  73. }
  74. p := actions.GetPermissionFromContext(c)
  75. req.SetUpdateBy(user.GetUserId(c))
  76. err = s.Update(&req, p)
  77. if err != nil {
  78. e.Error(500, err, err.Error())
  79. return
  80. }
  81. e.OK(nil, "修改成功")
  82. }