chart_permission.go 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. package cygx
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. )
  5. type ChartPermission struct {
  6. ChartPermissionId int `description:"权限id"`
  7. PermissionName string `description:"权限名称"`
  8. IcoLink string `description:"图标链接"`
  9. List []*CygxIndustrialManagementNumCheckName
  10. }
  11. type ChartPermissionRepMore struct {
  12. PermissionName string `description:"名称"`
  13. }
  14. type ChartPermissionResp struct {
  15. List []*ChartPermission
  16. }
  17. type ChartPermissionRepMoreList struct {
  18. List []*ChartPermissionRepMore
  19. }
  20. func GetChartPermissionAll() (items []*ChartPermission, err error) {
  21. o := orm.NewOrm()
  22. sql := `SELECT * FROM chart_permission WHERE product_id=2 AND is_report=1 AND is_other = 0 AND permission_type != 2 ORDER BY sort ASC `
  23. _, err = o.Raw(sql).QueryRows(&items)
  24. return
  25. }
  26. // 获取带有ICo的产业
  27. func GetChartPermissionIco(condition string) (items []*ChartPermission, err error) {
  28. o := orm.NewOrm()
  29. sql := `SELECT * FROM chart_permission WHERE parent_id>0 `
  30. if condition != "" {
  31. sql += condition
  32. }
  33. sql += ` ORDER BY sort ASC `
  34. _, err = o.Raw(sql).QueryRows(&items)
  35. return
  36. }
  37. // 获取带有ICo的产业
  38. func GetChartPermissionIcoNew(condition string) (items []*CygxRSlChartPermissionIcoTmp, err error) {
  39. o := orm.NewOrm()
  40. sql := `SELECT chart_permission_id ,chart_permission_name,image_url as ico_link FROM chart_permission WHERE parent_id>0 `
  41. if condition != "" {
  42. sql += condition
  43. }
  44. sql += ` ORDER BY sort ASC `
  45. _, err = o.Raw(sql).QueryRows(&items)
  46. return
  47. }
  48. // 获取带有ICo的产业
  49. func GetChartPermissionIcoDetail(condition string) (items []*CygxRSlChartPermissionIco, err error) {
  50. o := orm.NewOrm()
  51. sql := `SELECT chart_permission_id ,chart_permission_name,image_url as ico_link FROM chart_permission WHERE parent_id>0 `
  52. if condition != "" {
  53. sql += condition
  54. }
  55. sql += ` ORDER BY sort ASC `
  56. _, err = o.Raw(sql).QueryRows(&items)
  57. return
  58. }
  59. // 获取带有ICo的产业
  60. func GetChartPermissionDetail(condition string) (items []*CygxReportSelectionChart, err error) {
  61. o := orm.NewOrm()
  62. sql := `SELECT chart_permission_id ,chart_permission_name,image_url as ico_link FROM chart_permission WHERE parent_id>0 `
  63. if condition != "" {
  64. sql += condition
  65. }
  66. sql += ` ORDER BY sort ASC `
  67. _, err = o.Raw(sql).QueryRows(&items)
  68. return
  69. }
  70. // 没有策略的顶级分类
  71. func GetChartPermissionAllNoTactics() (items []*ChartPermission, err error) {
  72. o := orm.NewOrm()
  73. sql := `SELECT * FROM chart_permission WHERE product_id=2 AND show_type=1 AND is_report=1 AND chart_permission_id != 23 AND is_other = 0 AND permission_type != 2 AND parent_id>0 ORDER BY sort ASC `
  74. _, err = o.Raw(sql).QueryRows(&items)
  75. return
  76. }
  77. func GetChartPermissionOtherAll() (items []*ChartPermission, err error) {
  78. o := orm.NewOrm()
  79. sql := `SELECT * FROM chart_permission WHERE product_id=2 AND show_type=1 AND is_report=1 AND permission_type != 2 OR is_other = 1 AND parent_id>0 ORDER BY sort ASC`
  80. _, err = o.Raw(sql).QueryRows(&items)
  81. return
  82. }
  83. // 获取产业数量
  84. func GetChartPermissionCount(condition string, pars []interface{}) (count int, err error) {
  85. sqlCount := ` SELECT COUNT(1) AS count FROM chart_permission WHERE parent_id>0 `
  86. if condition != "" {
  87. sqlCount += condition
  88. }
  89. o := orm.NewOrm()
  90. err = o.Raw(sqlCount, pars).QueryRow(&count)
  91. return
  92. }
  93. // 通过ID获取分类详情
  94. func GetCategoryInfoById(chartPermissionId int) (item *ChartPermission, err error) {
  95. o := orm.NewOrm()
  96. sql := `SELECT * FROM chart_permission WHERE chart_permission_id=?`
  97. err = o.Raw(sql, chartPermissionId).QueryRow(&item)
  98. return
  99. }
  100. // 通过名称获取分类详情
  101. func GetCategoryInfoByName(name string) (item *ChartPermission, err error) {
  102. //if name == "宏观" {
  103. // name = "宏观经济"
  104. //}
  105. o := orm.NewOrm()
  106. sql := `SELECT * FROM chart_permission WHERE permission_name=? AND parent_id>0`
  107. err = o.Raw(sql, name).QueryRow(&item)
  108. return
  109. }
  110. // 报告分类映射类型
  111. type ReportMapping struct {
  112. CategoryId int `description:"匹配ID"`
  113. MatchTypeName string `description:"匹配类型"`
  114. SubCategoryName string `description:"二级分类"`
  115. ChartPermissionId int `description:"权限id"`
  116. }
  117. func GetReportMapping() (item []*ReportMapping, err error) {
  118. o := orm.NewOrmUsingDB("hz_cygx")
  119. sql := ` SELECT * FROM cygx_report_mapping WHERE match_type_name != '' `
  120. _, err = o.Raw(sql).QueryRows(&item)
  121. return
  122. }
  123. func GetReportMappingDetail(condition string, pars []interface{}) (item *ReportMapping, err error) {
  124. o := orm.NewOrmUsingDB("hz_cygx")
  125. sql := ` SELECT * FROM cygx_report_mapping WHERE 1=1 ` + condition + ` LIMIT 1 `
  126. err = o.Raw(sql, pars).QueryRow(&item)
  127. return
  128. }