def GetColumns(userInfo, tableCode, permissionCode = "Column.Access"): """ 获取用户的列权限 Args: tableCode (string): 表名称 permissionCode (string): 操作权限 Returns: returnValue (): 数据表 """ if permissionCode == "Column.Deney" or permissionCode == "Column.Edit": #按数据权限来过滤数据 returnValue = PermissionScopeService.GetResourceScopeIds(None, userInfo.Id, tableCode, permissionCode) elif permissionCode == "Column.Access": #1: 用户有权限的列名 returnValue = PermissionScopeService.GetResourceScopeIds(None, userInfo.Id, tableCode, permissionCode) #2: 先获取公开的列名 publicIds = Citablecolumns.objects.filter(Q(tablecode=tableCode) & Q(ispublic=1)).values_list('columncode', flat=True) returnValue = returnValue.union(publicIds) return returnValue
def GetDT(userInfo): """ 获取列表 Args: Returns: returnValue (CiItems): """ if userInfo.IsAdministrator: dataTable = Ciitems.objects.filter(Q(deletemark=0)).order_by('sortcode') else: ids = PermissionScopeService.GetResourceScopeIds(None, userInfo.Id, 'ciitems', "Resource.ManagePermission") dataTable = Ciitems.objects.filter(Q(deletemark=0) & Q(id__in=ids)).order_by('sortcode') return dataTable
def GetIDsByUser(self, userId): """ 获取用户有权限访问的模块主键 Args: userId (string): 用户主键 Returns: returnValue (string[]): 主键列表 """ #公开的模块谁都可以访问 openModuleIds = Pimodule.objects.filter(Q(ispublic=1) & Q(enabled=1) & Q(deletemark=0)).values_list('id', flat=True) #非公开的模块 if userId: #模块访问,连同用户本身的,还有角色的,全部获取出来 permissionItemCode = 'Resource.AccessPermission' otherModuleIds = PermissionScopeService.GetResourceScopeIds(self, userId, 'PIMODULE', permissionItemCode) #returnValue = openModuleIds.union(otherModuleIds) returnValue = chain(openModuleIds, otherModuleIds) return returnValue