This commit is contained in:
zhangwenjian committed 2020-04-13 00:30:58 +08:00
1 parent f25da5f1ee
commit 1df55e75e5
72 files changed
+1401 -1559

No files matched your search

+7 -7
View File
@@ -2,22 +2,22 @@ package models
import (
"github.com/jinzhu/gorm"
"go-admin/utils"
"go-admin/pkg/utils"
)
type DataPermission struct {
DataScope string
UserId int64
DeptId int64
RoleId int64
UserId int
DeptId int
RoleId int
}
func (e *DataPermission) GetDataScope(tbname string, table *gorm.DB) *gorm.DB {
SysUser := new(SysUser)
SysRole := new(SysRole)
SysUser.Id = e.UserId
SysUser.UserId = e.UserId
user, _ := SysUser.Get()
SysRole.Id = user.RoleId
SysRole.RoleId = user.RoleId
role, _ := SysRole.Get()
if role.DataScope == "2" {
@@ -27,7 +27,7 @@ func (e *DataPermission) GetDataScope(tbname string, table *gorm.DB) *gorm.DB {
table = table.Where(tbname+".create_by in (SELECT user_id from sys_user where dept_id = ? )", user.DeptId)
}
if role.DataScope == "4" {
table = table.Where(tbname+".create_by in (SELECT user_id from sys_user where sys_user.dept_id in(select dept_id from sys_dept where dept_path like ? ))", "%"+utils.Int64ToString(user.DeptId)+"%")
table = table.Where(tbname+".create_by in (SELECT user_id from sys_user where sys_user.dept_id in(select dept_id from sys_dept where dept_path like ? ))", "%"+utils.IntToString(user.DeptId)+"%")
}
if role.DataScope == "5" || role.DataScope == "" {
table = table.Where(tbname+".create_by = ?", e.UserId)