diff --git a/QMPlusServer/model/sysModel/sys_authority.go b/QMPlusServer/model/sysModel/sys_authority.go index fc720dc22a898d2cb96ddece4d394dac2d404b34..bc5e4726fa9b101490a736e0500269957a14fb97 100644 --- a/QMPlusServer/model/sysModel/sys_authority.go +++ b/QMPlusServer/model/sysModel/sys_authority.go @@ -10,7 +10,7 @@ import ( type SysAuthority struct { gorm.Model - AuthorityId string `json:"authorityId" gorm:"not null;unique"` + AuthorityId string `json:"authorityId" gorm:"not null;unique"` AuthorityName string `json:"authorityName"` } @@ -24,16 +24,14 @@ func (a *SysAuthority) CreateAuthority() (err error, authority *SysAuthority) { func (a *SysAuthority) DeleteAuthority() (err error) { err = qmsql.DEFAULTDB.Where("authority_id = ?", a.AuthorityId).Find(&SysUser{}).Error if err != nil { - err = qmsql.DEFAULTDB.Where("authority_id = ?", a.AuthorityId).First(a).Delete(a).Error - new(CasbinModel).clearCasbin(0,a.AuthorityId) + err = qmsql.DEFAULTDB.Where("authority_id = ?", a.AuthorityId).First(a).Unscoped().Delete(a).Error + new(CasbinModel).clearCasbin(0, a.AuthorityId) } else { err = errors.New("此角色有用户正在使用禁止删除") } return err } - - // 分页获取数据 需要分页实现这个接口即可 func (a *SysAuthority) GetInfoList(info modelInterface.PageInfo) (err error, list interface{}, total int) { // 封装分页方法 调用即可 传入 当前的结构体和分页信息 @@ -45,4 +43,4 @@ func (a *SysAuthority) GetInfoList(info modelInterface.PageInfo) (err error, lis err = db.Find(&authority).Error return err, authority, total } -} \ No newline at end of file +}