fill_data.go 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. package controller
  2. import (
  3. "gas-cylinder-api/app/admin/model"
  4. "gas-cylinder-api/app/admin/service"
  5. "gas-cylinder-api/app/admin/service/dto"
  6. "gas-cylinder-api/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/response"
  11. )
  12. type FillDataController struct {
  13. api.Api
  14. }
  15. // GetPage 获取上报实时充装数据
  16. // @Summary 获取上报实时充装数据
  17. // @Description 获取上报实时充装数据
  18. // @Tags 上报实时充装数据
  19. // @Param deptName query string false "上报实时充装数据名称"
  20. // @Success 200 {object} response.Response{data=response.Page{list=[]model.FillData}} "{"code": 200, "data": [...]}"
  21. // @Router /api/goods [get]
  22. // @Security Bearer
  23. func (e FillDataController) GetPage(c *gin.Context) {
  24. s := service.FillData{}
  25. req := dto.FillDataGetPageReq{}
  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. //数据权限检查
  37. p := actions.GetPermissionFromContext(c)
  38. list := make([]model.FillData, 0)
  39. var count int64
  40. err = s.GetPage(&req, &list, &count, p)
  41. if err != nil {
  42. e.Error(500, err, err.Error())
  43. return
  44. }
  45. e.PageOK(list, int(count), req.GetPageIndex(), req.GetPageSize(), "查询成功")
  46. }
  47. // Insert 添加上报实时充装数据
  48. // @Summary 添加上报实时充装数据
  49. // @Description 添加上报实时充装数据
  50. // @Tags 上报实时充装数据
  51. // @Accept application/json
  52. // @Product application/json
  53. // @Param data body dto.FillDataInsertReq true "data"
  54. // @Success 200 {string} string "{"code": 200, "message": "添加成功"}"
  55. // @Success 200 {string} string "{"code": -1, "message": "添加失败"}"
  56. // @Router /api/goods [post]
  57. // @Security Bearer
  58. func (e FillDataController) Insert(c *gin.Context) {
  59. s := service.FillData{}
  60. fillGunSvc := service.FillGun{}
  61. req := dto.FillDataInsertReq{}
  62. err := e.MakeContext(c).
  63. MakeOrm().
  64. Bind(&req, binding.JSON).
  65. MakeService(&s.Service).
  66. MakeService(&fillGunSvc.Service).
  67. Errors
  68. if err != nil {
  69. e.Logger.Error(err)
  70. e.Error(500, err, err.Error())
  71. return
  72. }
  73. // 设置创建人
  74. //p := actions.GetPermissionFromContext(c)
  75. //req.SetCreateBy(user.GetUserId(c))
  76. //req.SetDeptId(p.DeptId)
  77. // 获取充装枪信息
  78. var fillGun model.FillGun
  79. err = fillGunSvc.GetByCode(req.ScanGunCode, &fillGun)
  80. if err != nil {
  81. e.Error(500, err, err.Error())
  82. return
  83. }
  84. err = s.Insert(&req, fillGun)
  85. if err != nil {
  86. e.Error(500, err, err.Error())
  87. return
  88. }
  89. e.OK(req.GetId(), "创建成功")
  90. }
  91. // StationList 搜索-气站列表
  92. // @Summary 搜索-气站列表
  93. // @Description 搜索-气站列表
  94. // @Tags 上报实时充装数据
  95. // @Param deptName query string false "操作记录名称"
  96. // @Success 200 {object} response.Response{data=response.Page{list=[]model.OperationLog}} "{"code": 200, "data": [...]}"
  97. // @Router /api/operation-log [get]
  98. // @Security Bearer
  99. func (e FillDataController) StationList(c *gin.Context) {
  100. s := service.FillData{}
  101. err := e.MakeContext(c).
  102. MakeOrm().
  103. MakeService(&s.Service).
  104. Errors
  105. if err != nil {
  106. e.Logger.Error(err)
  107. e.Error(500, err, err.Error())
  108. return
  109. }
  110. //数据权限检查
  111. p := actions.GetPermissionFromContext(c)
  112. list := make([]model.FillDataDistinctStation, 0)
  113. var count int64
  114. err = s.GetStationList(&list, &count, p)
  115. if err != nil {
  116. e.Error(500, err, err.Error())
  117. return
  118. }
  119. e.PageOK(list, int(count), 0, 0, "查询成功")
  120. }
  121. // UserList 搜索-送气员列表
  122. // @Summary 搜索-送气员列表
  123. // @Description 搜索-送气员列表
  124. // @Tags 上报实时充装数据
  125. // @Param deptName query string false "操作记录名称"
  126. // @Success 200 {object} response.Response{data=response.Page{list=[]model.OperationLog}} "{"code": 200, "data": [...]}"
  127. // @Router /api/operation-log [get]
  128. // @Security Bearer
  129. func (e FillDataController) UserList(c *gin.Context) {
  130. s := service.FillData{}
  131. err := e.MakeContext(c).
  132. MakeOrm().
  133. MakeService(&s.Service).
  134. Errors
  135. if err != nil {
  136. e.Logger.Error(err)
  137. e.Error(500, err, err.Error())
  138. return
  139. }
  140. //数据权限检查
  141. p := actions.GetPermissionFromContext(c)
  142. list := make([]model.FillDataDistinctUser, 0)
  143. var count int64
  144. err = s.GetUserList(&list, &count, p)
  145. if err != nil {
  146. e.Error(500, err, err.Error())
  147. return
  148. }
  149. e.PageOK(list, int(count), 0, 0, "查询成功")
  150. }