package bi_dashboard import ( "eta_gn/eta_api/global" "eta_gn/eta_api/utils" "time" ) type BiDashboardGrant struct { GrantId int `gorm:"primaryKey;autoIncrement;column:grant_id"` // 授权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) { to := global.DEFAULT_DmSQL.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.InsertMulti(len(list), list) tmpErr := to.CreateInBatches(list, utils.MultiAddNum).Error if tmpErr != nil { err = tmpErr return } } return } // PublicDashboardReq 设置公共看板权限 type PublicDashboardReq struct { BiDashboardId int `description:"看板id" ` ClassifyId int `description:"分类id"` } // del func DeleteDashboardGrant(biDashboardId int) (err error) { return global.DEFAULT_DmSQL.Where("bi_dashboard_id=?", biDashboardId).Delete(&BiDashboardGrant{}).Error } // get func GetDashboardGrantInfo(biDashboardId int) (list []*BiDashboardGrant, err error) { return list, global.DEFAULT_DmSQL.Where("bi_dashboard_id=?", biDashboardId).Find(&list).Error }