bi_dashboard_classify.go 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. package bi_dashboard
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "time"
  5. )
  6. type BiDashboardClassify struct {
  7. BiDashboardClassifyId int `orm:"column(bi_dashboard_classify_id);pk"` // bi看板分类id
  8. BiDashboardClassifyName string `gorm:"column:bi_dashboard_classify_name;size:255;not null" ` // 看板分类名称
  9. Sort int `gorm:"column:sort" ` // 排序字段
  10. CreateTime time.Time `gorm:"column:create_time" ` // 创建时间
  11. ModifyTime time.Time `gorm:"column:modify_time"` // 更新时间
  12. }
  13. type BiDashboardClassifyItem struct {
  14. BiDashboardClassifyId int // bi看板分类id
  15. BiDashboardClassifyName string // 看板分类名称
  16. Sort int // 排序字段
  17. CreateTime string // 创建时间
  18. ModifyTime string // 更新时间
  19. }
  20. // tableName
  21. func (m *BiDashboardClassify) TableName() string {
  22. return "bi_dashboard_classify"
  23. }
  24. // add
  25. func AddBiDashboardClassify(item *BiDashboardClassify) (lastId int64, err error) {
  26. o := orm.NewOrm()
  27. lastId, err = o.Insert(item)
  28. return
  29. }
  30. // update
  31. func EditDashboardClassify(item *BiDashboardClassify) (err error) {
  32. o := orm.NewOrm()
  33. _, err = o.Raw("UPDATE bi_dashboard_classify SET bi_dashboard_classify_name=?,sort=?,modify_time=? WHERE bi_dashboard_classify_id=?", item.BiDashboardClassifyName, item.Sort, item.ModifyTime, item.BiDashboardClassifyId).Exec()
  34. return
  35. }
  36. type RespGroupList struct {
  37. MyList []*BiDashboard
  38. OtherList []*RespOtherGroupListItem
  39. }
  40. type RespMyGroupListItem struct {
  41. GroupId int64 `description:"目录id"`
  42. GroupName string `description:"目录名称"`
  43. AdminId int `description:"目录创建者账号ID"`
  44. DashboardList []*BiDashboard
  45. }
  46. type RespOtherGroupListItem struct {
  47. GroupId int64 `description:"目录id"`
  48. GroupName string `description:"目录名称"`
  49. AdminId int `description:"目录创建者账号ID"`
  50. DashboardList []*BiDashboard
  51. }
  52. type RespGroupDashboardListItem struct {
  53. GroupPptId int64 `description:"目录和ppt绑定序号"`
  54. PptId int64 `description:"ppt ID"`
  55. Title string `description:"标题"`
  56. AdminId int `description:"移动ppt到该目录的系统用户id"`
  57. AdminRealName string `description:"系统用户名称"`
  58. PptVersion int8 `description:"是否ppt的旧版本;1:旧的,2:新的"`
  59. IsSingleShare int8 `description:"是否是单个共享ppt,0未单个共享,1共享"`
  60. PptxUrl string `description:"pptx下载地址"`
  61. ReportId int `description:"关联的报告ID"`
  62. ReportCode string `description:"关联的报告code"`
  63. PptCreateTime string `description:"ppt创建时间"`
  64. PptModifyTime string `description:"ppt修改时间"`
  65. PublishTime string `description:"发布时间"`
  66. PptPage int `description:"PPT总页数"`
  67. IsReceived int8 `description:"是否收到的共享,0:不是,1:是"`
  68. IsGrant int8 `description:"是否分配了权限,0:不是,1:是"`
  69. TitleSetting string `description:"PPT标题设置"`
  70. }
  71. func GetBiDashboardClassifyAllList() (list []*BiDashboardClassify, err error) {
  72. //err = global.DEFAULT_DmSQL.Select("*").Find(&list).Error
  73. o := orm.NewOrm()
  74. _, err = o.Raw("SELECT * FROM bi_dashboard_classify").QueryRows(&list)
  75. return
  76. }
  77. func GetBiDashboardClassifyById(id int) (item *BiDashboardClassify, err error) {
  78. //err = global.DEFAULT_DmSQL.Where("bi_dashboard_classify_id = ?", id).First(&item).Error
  79. o := orm.NewOrm()
  80. err = o.Raw("SELECT * FROM bi_dashboard_classify where bi_dashboard_classify_id=?", id).QueryRow(&item)
  81. return
  82. }
  83. type AddDashboardClassifyReq struct {
  84. ClassifyName string `description:"看板名称"`
  85. }
  86. type EditDashboardClassifyReq struct {
  87. BiDashboardClassifyId int `description:"看板id"`
  88. ClassifyName string `description:"看板名称"`
  89. }
  90. type DelDashboardClassifyReq struct {
  91. BiDashboardClassifyId int `description:"看板id"`
  92. }
  93. // GetBiDashboardClassifyMaxSort 获取看板分类下最大的排序数
  94. func GetBiDashboardClassifyMaxSort() (sort int, err error) {
  95. sql := `SELECT COALESCE(Max(sort), 0) AS sort FROM bi_dashboard_classify `
  96. //err = global.DEFAULT_DmSQL.Raw(sql).First(&sort).Error
  97. o := orm.NewOrm()
  98. err = o.Raw(sql).QueryRow(&sort)
  99. return
  100. }
  101. // del
  102. //func DelBiDashboardClassify(id int) (err error) {
  103. // return global.DEFAULT_DmSQL.Where("bi_dashboard_classify_id = ?", id).Delete(&BiDashboardClassify{}).Error
  104. //}
  105. type RespPublicGroupListItem struct {
  106. GroupId int64 `description:"目录id"`
  107. GroupName string `description:"目录名称"`
  108. AdminId int `description:"目录创建者账号ID"`
  109. DashboardList []*BiDashboard
  110. Children []*RespPublicGroupListItem
  111. }
  112. // getByName
  113. func GetBiDashboardClassifyByName(classifyName string) (count int64, err error) {
  114. //err = global.DEFAULT_DmSQL.Model(&BiDashboardClassify{}).Where("bi_dashboard_classify_name = ?", classifyName).Count(&count).Error
  115. o := orm.NewOrm()
  116. err = o.Raw("SELECT count(1) FROM bi_dashboard_classify where bi_dashboard_classify_name=?", classifyName).QueryRow(&count)
  117. return
  118. }