12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- package models
- import (
- "eta_gn/eta_api/global"
- "eta_gn/eta_api/utils"
- "time"
- )
- type ReportGrant struct {
- GrantId int64 `gorm:"column:grant_id"`
- ReportId int64 `gorm:"column:report_id"`
- DepartmentId int64 `gorm:"column:department_id"`
- GrantAdminId int64 `gorm:"column:grant_admin_id"`
- CreateTime time.Time `gorm:"column:create_time"`
- }
- func GetReportGrantInfo(reportId int) (list []*ReportGrant, err error) {
-
- sql := `SELECT * FROM report_grant WHERE report_id=? `
-
- err = global.DmSQL["rddp"].Raw(sql, reportId).Find(&list).Error
- return
- }
- func MultiAddReportGrant(reportId int, list []*ReportGrant) (err error) {
-
-
- to := global.DmSQL["rddp"].Begin()
- defer func() {
- if err != nil {
- _ = to.Rollback()
- } else {
- _ = to.Commit()
- }
- }()
- sql := "DELETE from report_grant where report_id=?"
-
- err = to.Exec(sql, reportId).Error
- if err != nil {
- return
- }
-
- if len(list) > 0 {
-
- tmpErr := to.CreateInBatches(list, utils.MultiAddNum).Error
- if tmpErr != nil {
- err = tmpErr
- return
- }
- }
- return
- }
- func DeleteReportGrant(reportId int) (err error) {
-
- sql := "DELETE from report_grant where report_id=?"
-
- err = global.DmSQL["rddp"].Exec(sql, reportId).Error
- return
- }
|