From eeabaabf95fa0378199268ed2a1c5b7f58462dbe Mon Sep 17 00:00:00 2001 From: pixel <303176530@qq.com> Date: Thu, 12 Dec 2019 17:32:19 +0800 Subject: [PATCH] =?UTF-8?q?=E5=89=8D=E7=AB=AF=E9=A1=B5=E9=9D=A2=E5=B8=83?= =?UTF-8?q?=E5=B1=80=E4=BF=AE=E6=94=B9,=E5=90=8E=E5=8F=B0=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E5=BA=93=E7=BB=93=E6=9E=84=E5=8F=98=E5=8C=96=EF=BC=8C?= =?UTF-8?q?=E9=9C=80=E8=A6=81=E9=87=8D=E6=96=B0=E5=AF=BC=E5=85=A5=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E5=BA=93=E6=89=8D=E5=8F=AF=E4=BD=BF=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- QMPlusServer/model/sysModel/sys_authority.go | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/QMPlusServer/model/sysModel/sys_authority.go b/QMPlusServer/model/sysModel/sys_authority.go index fc720dc2..bc5e4726 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 +}