chart.go 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. package chart_collect
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "github.com/rdlucklib/rdluck_tools/paging"
  5. "time"
  6. )
  7. type ChartCollect struct {
  8. ChartCollectId int `orm:"column(chart_collect_id);pk"`
  9. UserId int `orm:"column(user_id)" description:"用户ID"`
  10. BusinessCode string `orm:"column(business_code)" description:"客户编码"`
  11. RealName string `orm:"column(real_name)" description:"用户姓名"`
  12. CollectTime time.Time `orm:"column(collect_time)" description:"收藏时间"`
  13. ChartInfoId int `orm:"column(chart_info_id)" description:"图表ID"`
  14. CollectClassifyId int `orm:"column(collect_classify_id)" description:"收藏的分类ID"`
  15. ChartSource int `orm:"column(chart_source)" description:"图表来源"`
  16. CreateTime time.Time `orm:"column(create_time)" description:"创建时间"`
  17. ModifyTime time.Time `orm:"column(modify_time)" description:"修改时间"`
  18. }
  19. type ChartCollectAddReq struct {
  20. ChartInfoId int `description:"图表id"`
  21. CollectClassifyId int `description:"收藏分类id"`
  22. }
  23. type ChartCollectView struct {
  24. ChartCollectId int `orm:"column(chart_collect_id);pk"`
  25. ChartInfoId int `description:"图表id"`
  26. UserId int `description:"用户id"`
  27. CreateTime time.Time `description:"创建时间"`
  28. CollectTime string `description:"收藏时间"`
  29. CollectClassifyId int
  30. ChartName string `description:"来源名称"`
  31. ChartNameEn string `description:"英文图表名称"`
  32. ChartImage string `description:"图表图片"`
  33. UniqueCode string `description:"图表唯一编码"`
  34. }
  35. type ChartCollectListResp struct {
  36. Paging *paging.PagingItem
  37. List []*ChartCollectView
  38. }
  39. type ChartCollectEditReq struct {
  40. ChartCollectId int `description:"我的图表主键"`
  41. CurrentClassifyId int `description:"当前分类ID"`
  42. ClassifyId []int `description:"分类id,数组形式"`
  43. }
  44. func GetChartCollectPageByCondition(condition string, pars []interface{}, currentIndex, pageSize int) (item []*ChartCollectView, err error) {
  45. o := orm.NewOrm()
  46. //sql := ` SELECT * FROM chart_collect WHERE 1=1 `
  47. sql := `SELECT a.*,b.chart_name_en,b.chart_name, b.unique_code, b.chart_image FROM chart_collect AS a
  48. INNER JOIN chart_info AS b ON a.chart_info_id=b.chart_info_id
  49. WHERE 1=1
  50. `
  51. if condition != "" {
  52. sql += condition
  53. }
  54. sql += ` GROUP BY a.chart_info_id order by a.chart_collect_id desc limit ?,?`
  55. _, err = o.Raw(sql, pars, currentIndex, pageSize).QueryRows(&item)
  56. return
  57. }
  58. func GetChartCollectDetailByCondition(condition string, pars []interface{}) (item []*ChartCollectView, err error) {
  59. o := orm.NewOrm()
  60. //sql := ` SELECT * FROM chart_collect WHERE 1=1 `
  61. sql := `SELECT a.*,b.chart_name_en,b.chart_name, b.unique_code, b.chart_image FROM chart_collect AS a
  62. INNER JOIN chart_info AS b ON a.chart_info_id=b.chart_info_id
  63. WHERE 1=1
  64. `
  65. if condition != "" {
  66. sql += condition
  67. }
  68. sql += ` GROUP BY a.chart_info_id`
  69. _, err = o.Raw(sql, pars).QueryRows(&item)
  70. return
  71. }
  72. func GetChartCollectCountByCondition(condition string, pars []interface{}) (total int64, err error) {
  73. o := orm.NewOrm()
  74. sql := `SELECT a.chart_info_id FROM chart_collect AS a INNER JOIN chart_info AS b ON a.chart_info_id=b.chart_info_id
  75. WHERE 1=1
  76. `
  77. if condition != "" {
  78. sql += condition
  79. }
  80. sql += ` GROUP BY a.chart_info_id`
  81. totalSql := `select count(1) as total from (` + sql + `) as t`
  82. err = o.Raw(totalSql, pars).QueryRow(&total)
  83. return
  84. }
  85. // ModifyChartClassifyPublicReq 修改我的图库分类是否可见
  86. type ModifyChartClassifyPublicReq struct {
  87. ClassifyId int `description:"分类id"`
  88. IsPublic int `description:"是否所有人可见,0:仅自己可见,1:所有人可见"`
  89. }
  90. // CopyChartClassifyReq 复制我的图库分类
  91. type CopyChartClassifyReq struct {
  92. ClassifyId int `description:"分类id"`
  93. }
  94. // ChartCollectClassifyItem 我的图表分类信息
  95. type ChartCollectClassifyItem struct {
  96. CollectClassifyId int `description:"分类ID"`
  97. ClassifyName string `description:"分类名称"`
  98. UserId int `description:"创建人id"`
  99. /*IsPublic int `description:"是否公共分类"`
  100. IsCompanyPublic int `description:"是否为用户公共分类"`*/
  101. ChartNum int `description:"分类下的图表数量"`
  102. }
  103. // ClassifyIdAndNum 我的图表-分类ID及图表数
  104. type ClassifyIdAndNum struct {
  105. ClassifyId int `description:"分类ID"`
  106. ChartNum int `description:"分类下的图表数量"`
  107. }
  108. type ChartCollectAddResp struct {
  109. CollectMsg string `description:"提示信息"`
  110. }
  111. func GetChartCollectByUserIdChartInfoId(userId, chartInfoId int) (item *ChartCollect, err error) {
  112. o := orm.NewOrm()
  113. sql := ` SELECT * FROM chart_collect WHERE user_id=? AND chart_info_id=? `
  114. err = o.Raw(sql, userId, chartInfoId).QueryRow(&item)
  115. return
  116. }