package bi_dashboard import ( "eta/eta_api/global" "eta/eta_api/utils" "time" ) type BiDashboardGrant struct { GrantId int `orm:"column(grant_id);pk" gorm:"primaryKey"` // 授权id BiDashboardId int `gorm:"column:bi_dashboard_id" ` // 看板id GrantAdminId int `gorm:"column:grant_admin_id"` // 授权的用户id CreateTime time.Time `gorm:"column:create_time"` // 授权时间 } // tableName func (m *BiDashboardGrant) TableName() string { return "bi_dashboard_grant" } // GrantDashboardReq 分配看板权限 type GrantDashboardReq struct { BiDashboardId int `description:"看板id" ` AdminIdStr string `description:"指定成员id,多个成员用英文,隔开"` } // MultiAddDashboardGrant 批量添加授权记录 func MultiAddDashboardGrant(boardId int, list []*BiDashboardGrant) (err error) { o := global.DbMap[utils.DbNameMaster] to := o.Begin() defer func() { if err != nil { _ = to.Rollback() } else { _ = to.Commit() } }() sql := "DELETE from bi_dashboard_grant where bi_dashboard_id=?" err = to.Exec(sql, boardId).Error if err != nil { return } // 新增授权记录 if len(list) > 0 { tmpErr := to.CreateInBatches(list, utils.MultiAddNum).Error if tmpErr != nil { err = tmpErr return } } return } // PublicDashboardReq 设置公共看板权限 type PublicDashboardReq struct { BiDashboardId int `description:"看板id" ` } // del func DeleteDashboardGrant(biDashboardId int) (err error) { //return global.DEFAULT_DmSQL.Where("bi_dashboard_id=?", biDashboardId).Delete(&BiDashboardGrant{}).Error o := global.DbMap[utils.DbNameMaster] err = o.Exec("DELETE from bi_dashboard_grant where bi_dashboard_id=?", biDashboardId).Error return } // get func GetDashboardGrantInfo(biDashboardId int) (list []*BiDashboardGrant, err error) { //return list, global.DEFAULT_DmSQL.Where("bi_dashboard_id=?", biDashboardId).Find(&list).Error o := global.DbMap[utils.DbNameMaster] err = o.Raw("SELECT * FROM bi_dashboard_grant where bi_dashboard_id=?", biDashboardId).Find(&list).Error return }