update: used gormv2 to handle permission process
This commit is contained in:
1 parent
d53ba4ed7a
commit
671291d024
10 files changed
+64
-55
No files matched your search
+8
-8
@@ -215,16 +215,16 @@ func (e *SysUser) GetPage(pageSize int, pageIndex int) ([]SysUserPage, int, erro
|
||||
table = table.Where("sys_user.dept_id in (select dept_id from sys_dept where dept_path like ? )", "%"+tools.IntToString(e.DeptId)+"%")
|
||||
}
|
||||
|
||||
// 数据权限控制
|
||||
dataPermission := new(DataPermission)
|
||||
dataPermission.UserId, _ = tools.StringToInt(e.DataScope)
|
||||
table, err := dataPermission.GetDataScope("sys_user", table)
|
||||
if err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
userid, _ := tools.StringToInt(e.DataScope)
|
||||
//dataPermission.UserId = userid
|
||||
//table, err := dataPermission.GetDataScope(e.TableName(), table)
|
||||
//if err != nil {
|
||||
// return 0, err
|
||||
//}
|
||||
|
||||
var count int64
|
||||
|
||||
if err := table.Offset((pageIndex - 1) * pageSize).Limit(pageSize).Find(&doc).Offset(-1).Limit(-1).Count(&count).Error; err != nil {
|
||||
if err := table.Scopes(DataScopes(e.TableName(),userid)).Offset((pageIndex - 1) * pageSize).Limit(pageSize).Find(&doc).Offset(-1).Limit(-1).Count(&count).Error; err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
//table.Where("sys_user.deleted_at IS NULL").Count(&count)
|
||||
|
||||
Reference in new issue
Block a user