|
@ -10,7 +10,7 @@ import ( |
|
|
|
|
|
|
|
|
type SysAuthority struct { |
|
|
type SysAuthority struct { |
|
|
gorm.Model |
|
|
gorm.Model |
|
|
AuthorityId string `json:"authorityId" gorm:"not null;unique"` |
|
|
|
|
|
|
|
|
AuthorityId string `json:"authorityId" gorm:"not null;unique"` |
|
|
AuthorityName string `json:"authorityName"` |
|
|
AuthorityName string `json:"authorityName"` |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -24,16 +24,14 @@ func (a *SysAuthority) CreateAuthority() (err error, authority *SysAuthority) { |
|
|
func (a *SysAuthority) DeleteAuthority() (err error) { |
|
|
func (a *SysAuthority) DeleteAuthority() (err error) { |
|
|
err = qmsql.DEFAULTDB.Where("authority_id = ?", a.AuthorityId).Find(&SysUser{}).Error |
|
|
err = qmsql.DEFAULTDB.Where("authority_id = ?", a.AuthorityId).Find(&SysUser{}).Error |
|
|
if err != nil { |
|
|
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 { |
|
|
} else { |
|
|
err = errors.New("此角色有用户正在使用禁止删除") |
|
|
err = errors.New("此角色有用户正在使用禁止删除") |
|
|
} |
|
|
} |
|
|
return err |
|
|
return err |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 分页获取数据 需要分页实现这个接口即可
|
|
|
// 分页获取数据 需要分页实现这个接口即可
|
|
|
func (a *SysAuthority) GetInfoList(info modelInterface.PageInfo) (err error, list interface{}, total int) { |
|
|
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 |
|
|
err = db.Find(&authority).Error |
|
|
return err, authority, total |
|
|
return err, authority, total |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
} |