chart_permission.go 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. package advisory
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. )
  5. type ChartPermission struct {
  6. ChartPermissionId int `description:"权限id"`
  7. ClassifyName string `description:"分类名称"`
  8. PermissionName string `description:"名称"`
  9. ImageUrl string `description:"图片地址"`
  10. IsHaveNoRead bool `description:"是否存在未阅读的文章"`
  11. ChildPermission []*ChartPermission
  12. }
  13. type ChartPermissionResp struct {
  14. List []*ChartPermission
  15. }
  16. // 用户关注的分类
  17. type ChartPermissionListResp struct {
  18. ChartPermissionId int `description:"权限id"`
  19. ChartPermissionName string `description:"名称"`
  20. PermissionName string `description:"名称"`
  21. ClassifyName string `description:"分类名称"`
  22. ImageUrl string `description:"图片地址"`
  23. IsFllow bool `description:"是否关注过分类"`
  24. }
  25. type GetChartPermissionAllByChartIdResp struct {
  26. ChartPermissionId int `description:"权限id"`
  27. }
  28. // 用户关注的分类
  29. type MyChartPermission struct {
  30. ChartPermissionId int `description:"权限id"`
  31. ClassifyName string `description:"分类名称"`
  32. PermissionName string `description:"名称"`
  33. ChartPermissionName string `description:"名称"`
  34. ImageUrl string `description:"图片地址"`
  35. }
  36. type MyChartPermissionResp struct {
  37. List []*MyChartPermission
  38. }
  39. type AdminInfoResp struct {
  40. AdminName string `description:"系统用户名称"`
  41. CreatedTime string `description:"注册时间"`
  42. Headimgurl string `description:"头像"`
  43. Mobile string `description:"手机号"`
  44. ArticleNum int `description:"文章数量"`
  45. IsFllow bool `description:"是否关注过分类"`
  46. List []*MyChartPermission
  47. }
  48. type NoAdminInfoResp struct {
  49. List []*MyChartPermission
  50. }
  51. func GetCategoryInfoById(chartPermissionId int) (item *ChartPermission, err error) {
  52. o := orm.NewOrm()
  53. //o.Using("rddp")
  54. sql := `SELECT * FROM chart_permission WHERE chart_permission_id=? AND product_id = 1 AND product_name = 'ficc' `
  55. err = o.Raw(sql, chartPermissionId).QueryRow(&item)
  56. return
  57. }
  58. // 获取分类列表
  59. func GetChartPermissionList() (items []*MyChartPermission, err error) {
  60. o := orm.NewOrm()
  61. sql := `SELECT * FROM chart_permission as ch WHERE product_id = 1 AND product_name = 'ficc' and parent_id > 0 ORDER BY sort ASC; `
  62. _, err = o.Raw(sql).QueryRows(&items)
  63. return
  64. }
  65. type GetBuChartPermissionResp struct {
  66. ChartPermissionId int `description:"权限id"`
  67. PermissionName string `description:"分类名称"`
  68. ImageUrl string `description:"图片链接"`
  69. }
  70. type GetBuChartPermissionRespLIst struct {
  71. List []*GetBuChartPermissionResp
  72. }
  73. // 获取用户购买的分类信息
  74. func GetBuChartPermission(CompanyId int, pars []interface{}) (items []*GetBuChartPermissionResp, err error) {
  75. o := orm.NewOrm()
  76. sql := `SELECT ch.chart_permission_id , ch.permission_name ,ch.image_url FROM chart_permission as ch INNER JOIN company_report_permission as co ON co.chart_permission_id = ch.chart_permission_id WHERE co.company_id = ? `
  77. _, err = o.Raw(sql, CompanyId, pars).QueryRows(&items)
  78. return
  79. }
  80. // 获取分类列表
  81. func GetPermissionList(condition string, pars []interface{}, startSize, pageSize int) (items []*ChartPermission, err error) {
  82. sql := ` SELECT * FROM chart_permission WHERE 1=1 `
  83. if condition != "" {
  84. sql += condition
  85. }
  86. sql += ` ORDER BY sort ASC LIMIT ?,? `
  87. o := orm.NewOrm()
  88. _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
  89. return
  90. }
  91. // 获取用户权限的一级分类名称
  92. func GetFirstChartPermissionAllByUser(Ids string) (items []*ChartPermission, err error) {
  93. o := orm.NewOrm()
  94. sql := `SELECT * FROM chart_permission as ch WHERE product_id = 1 AND product_name = 'ficc' AND chart_permission_id IN (` + Ids + `)` + ` GROUP BY ch.classify_name ORDER BY sort ASC; `
  95. _, err = o.Raw(sql).QueryRows(&items)
  96. return
  97. }
  98. // 获取用户权限的二级分类名称
  99. func GetChartToClassifyNameByUser(ClassifyName, Ids string) (items []*ChartPermission, err error) {
  100. o := orm.NewOrm()
  101. sql := `SELECT * FROM chart_permission WHERE product_id = 1 AND product_name = 'ficc' AND classify_name = ? AND chart_permission_id IN (` + Ids + `)`
  102. _, err = o.Raw(sql, ClassifyName).QueryRows(&items)
  103. return
  104. }
  105. func GetChartPermissionAllByChartId(chartPermissionId int) (items []*GetChartPermissionAllByChartIdResp, err error) {
  106. o := orm.NewOrm()
  107. sql := `SELECT chart_permission_id FROM chart_permission WHERE classify_name = (SELECT classify_name FROM chart_permission WHERE chart_permission_id = ?)`
  108. _, err = o.Raw(sql, chartPermissionId).QueryRows(&items)
  109. return
  110. }