report_grant.go 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. package models
  2. import (
  3. "time"
  4. )
  5. // ReportGrant Ppt授权表
  6. type ReportGrant struct {
  7. GrantId int64 `gorm:"column:grant_id;primaryKey;autoIncrement" description:"自增序号"`
  8. ReportId int64 `description:"report ID"`
  9. DepartmentId int64 `description:"授权部门id"`
  10. GrantAdminId int64 `description:"授权部门id"`
  11. CreateTime time.Time `orm:"auto_now_add;type(datetime)" description:"创建时间"`
  12. }
  13. // GetReportGrantInfo 获取已经有权限的report列表
  14. //func GetReportGrantInfo(reportId int) (list []*ReportGrant, err error) {
  15. // o := orm.NewOrmUsingDB("rddp")
  16. // sql := `SELECT * FROM report_grant WHERE report_id=? `
  17. // _, err = o.Raw(sql, reportId).QueryRows(&list)
  18. // return
  19. //}
  20. // MultiAddReportGrant 批量添加授权记录
  21. //func MultiAddReportGrant(reportId int, list []*ReportGrant) (err error) {
  22. // o := orm.NewOrmUsingDB("rddp")
  23. // to, err := o.Begin()
  24. // if err != nil {
  25. // return
  26. // }
  27. // defer func() {
  28. // if err != nil {
  29. // _ = to.Rollback()
  30. // } else {
  31. // _ = to.Commit()
  32. // }
  33. // }()
  34. //
  35. // sql := "DELETE from report_grant where report_id=?"
  36. // _, err = to.Raw(sql, reportId).Exec()
  37. // if err != nil {
  38. // return
  39. // }
  40. //
  41. // // 新增授权记录
  42. // if len(list) > 0 {
  43. // _, tmpErr := to.InsertMulti(len(list), list)
  44. // if tmpErr != nil {
  45. // err = tmpErr
  46. // return
  47. // }
  48. // }
  49. //
  50. // return
  51. //}
  52. // DeleteReportGrant 移除授权记录
  53. //func DeleteReportGrant(reportId int) (err error) {
  54. // o := orm.NewOrmUsingDB("rddp")
  55. // sql := "DELETE from report_grant where report_id=?"
  56. // _, err = o.Raw(sql, reportId).Exec()
  57. //
  58. // return
  59. //}