report.go 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. package services
  2. import (
  3. "encoding/json"
  4. "eta/eta_mini_api/models"
  5. "eta/eta_mini_api/utils"
  6. "fmt"
  7. resp2 "eta/eta_mini_api/models/response"
  8. )
  9. // GetReportPdfClassify 获取pdf研报的最小分类
  10. func GetReportPdfClassify(report *models.ReportPdfView) int {
  11. var res int
  12. if report.ClassifyIdFirst != 0 {
  13. res = report.ClassifyIdFirst
  14. }
  15. if report.ClassifyIdSecond != 0 {
  16. res = report.ClassifyIdSecond
  17. }
  18. if report.ClassifyIdThird != 0 {
  19. res = report.ClassifyIdThird
  20. }
  21. return res
  22. }
  23. func GetReportList(chartPermissionId, level, rangeType, classifyId, currentIndex, pageSize int) (resp *resp2.ReportResp[resp2.ReportList], err error) {
  24. url := utils.ETA_MINI_BRIDGE_URL + "/report/list?"
  25. url += fmt.Sprintf("RangeType=%d&ChartPermissionId=%d&Level=%d&PageSize=%d&CurrentIndex=%d&ClassifyId=%d", rangeType, chartPermissionId, level, pageSize, currentIndex, classifyId)
  26. fmt.Println(url)
  27. body, err := HttpGet(url)
  28. if err != nil {
  29. return
  30. }
  31. err = json.Unmarshal(body, &resp)
  32. if err != nil {
  33. return
  34. }
  35. return
  36. }
  37. func GetNoAuthReportList(reportType, chartPermissionId, level, rangeType, classifyId, currentIndex, pageSize int) (resp *resp2.ReportResp[resp2.ReportPushListResp], err error) {
  38. url := utils.ETA_MINI_BRIDGE_URL + "/noAuth/report/list?"
  39. url += fmt.Sprintf("ReportType=%d&RangeType=%d&ChartPermissionId=%d&Level=%d&PageSize=%d&CurrentIndex=%d&ClassifyId=%d", reportType, rangeType, chartPermissionId, level, pageSize, currentIndex, classifyId)
  40. fmt.Println(url)
  41. body, err := HttpGet(url)
  42. if err != nil {
  43. return
  44. }
  45. err = json.Unmarshal(body, &resp)
  46. if err != nil {
  47. return
  48. }
  49. return
  50. }
  51. func GetNoAuthReportDetail(reportId int) (resp *resp2.ReportResp[resp2.ReportDetailResp], err error) {
  52. url := utils.ETA_MINI_BRIDGE_URL + "/noAuth/report/detail?"
  53. url += fmt.Sprintf("ReportId=%d", reportId)
  54. fmt.Println(url)
  55. body, err := HttpGet(url)
  56. if err != nil {
  57. return
  58. }
  59. err = json.Unmarshal(body, &resp)
  60. if err != nil {
  61. return
  62. }
  63. return
  64. }
  65. func GetReportDetail(reportId, userId int) (resp *resp2.ReportResp[resp2.ReportDetailResp], err error) {
  66. url := utils.ETA_MINI_BRIDGE_URL + "/report/detail?"
  67. url += fmt.Sprintf("ReportId=%d&UserId=%d", reportId, userId)
  68. fmt.Println(url)
  69. body, err := HttpGet(url)
  70. if err != nil {
  71. return
  72. }
  73. err = json.Unmarshal(body, &resp)
  74. if err != nil {
  75. return
  76. }
  77. return
  78. }
  79. func GetReportDetailNoUser(reportId int) (resp *resp2.ReportResp[resp2.ReportDetailResp], err error) {
  80. url := utils.ETA_MINI_BRIDGE_URL + "/report/detail/noUser?"
  81. url += fmt.Sprintf("ReportId=%d", reportId)
  82. fmt.Println(url)
  83. body, err := HttpGet(url)
  84. if err != nil {
  85. return
  86. }
  87. err = json.Unmarshal(body, &resp)
  88. if err != nil {
  89. return
  90. }
  91. return
  92. }
  93. func GetReportDailyList() (resp *resp2.ReportResp[resp2.ReportList], err error) {
  94. url := utils.ETA_MINI_BRIDGE_URL + "/report/daily/list"
  95. fmt.Println(url)
  96. body, err := HttpGet(url)
  97. if err != nil {
  98. return
  99. }
  100. err = json.Unmarshal(body, &resp)
  101. if err != nil {
  102. return
  103. }
  104. return
  105. }
  106. func GetReportRecentList(currentIndex, pageSize int) (resp *resp2.ReportResp[resp2.ReportList], err error) {
  107. url := utils.ETA_MINI_BRIDGE_URL + "/report/recent/list?"
  108. url += fmt.Sprintf("PageSize=%d&CurrentIndex=%d", pageSize, currentIndex)
  109. fmt.Println(url)
  110. body, err := HttpGet(url)
  111. if err != nil {
  112. return
  113. }
  114. err = json.Unmarshal(body, &resp)
  115. if err != nil {
  116. return
  117. }
  118. return
  119. }
  120. func SearchReport(keyWord string, currentIndex, pageSize int) (resp *resp2.ReportResp[resp2.ReportSearchResp], err error) {
  121. url := utils.ETA_MINI_BRIDGE_URL + "/report/search?"
  122. url += fmt.Sprintf("KeyWord=%s&PageSize=%d&CurrentIndex=%d", keyWord, pageSize, currentIndex)
  123. fmt.Println(url)
  124. body, err := HttpGet(url)
  125. if err != nil {
  126. return
  127. }
  128. err = json.Unmarshal(body, &resp)
  129. if err != nil {
  130. return
  131. }
  132. return
  133. }
  134. func SearchReportPush(keyWord string, startSize, pageSize int) (items []*models.ReportPushStatus, total int, err error) {
  135. if keyWord == "" {
  136. return
  137. }
  138. var pars []interface{}
  139. condition := `AND title LIKE ?`
  140. pars = append(pars, utils.GetLikeKeywordPars(pars, keyWord, 1))
  141. total, err = models.GetReportPushStatusCountByCondition(condition, pars)
  142. if err != nil {
  143. return
  144. }
  145. items, err = models.GetReportPushStatusByCondition(condition, pars, startSize, pageSize)
  146. if err != nil {
  147. return
  148. }
  149. return
  150. }