using LeaRun.Application.Busines.BaseManage;
using LeaRun.Application.Code;
using LeaRun.Application.Entity.AuthorizeManage;
using LeaRun.Application.Entity.BaseManage;
using LeaRun.Application.IService.AuthorizeManage;
using LeaRun.Application.Service.BaseManage;
using LeaRun.Util;
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
namespace LeaRun.Application.Busines.AuthorizeManage
{
///
/// 版 本
/// Copyright (c) 2013-2016 上海力软信息技术有限公司
/// 创建人:佘赐雄
/// 日 期:2015.11.5 22:35
/// 描 述:权限配置管理(角色、岗位、职位、用户组、用户)
///
public class PermissionBLL
{
private IPermissionService service = new PermissionService();
private UserBLL userBLL = new UserBLL();
#region 获取数据
///
/// 获取成员列表
///
/// 对象Id
///
public IEnumerable GetMemberList(string objectId)
{
return service.GetMemberList(objectId);
}
///
/// 获取对象列表
///
///
///
public IEnumerable GetObjectList(string userId)
{
return service.GetObjectList(userId);
}
///
/// 获取对象列表
///
///
///
public string GetObjectStr(string userId)
{
StringBuilder sbId = new StringBuilder();
List list = service.GetObjectList(userId).ToList();
if (list.Count > 0)
{
foreach (UserRelationEntity item in list)
{
sbId.Append(item.ObjectId + ",");
}
sbId.Append(userId);
}
else
{
sbId.Append(userId + ",");
}
return sbId.ToString();
}
///
/// 获取功能列表
///
/// 对象Id
///
public IEnumerable GetModuleList(string objectId)
{
return service.GetModuleList(objectId);
}
///
/// 获取功能列表
///
/// 对象Id
///
public IEnumerable GetModuleListN(string objectId)
{
return service.GetModuleListN(objectId);
}
///
/// 获取按钮列表
///
/// 对象Id
///
public IEnumerable GetModuleButtonList(string objectId)
{
return service.GetModuleButtonList(objectId);
}
///
/// 获取视图列表
///
/// 对象Id
///
public IEnumerable GetModuleColumnList(string objectId)
{
return service.GetModuleColumnList(objectId);
}
///
/// 获取数据权限列表
///
/// 对象Id
///
public IEnumerable GetAuthorizeDataList(string objectId)
{
return service.GetAuthorizeDataList(objectId);
}
#endregion
#region 提交数据
///
/// 添加成员
///
/// 权限分类
/// 对象Id
/// 成员Id:1,2,3,4
public void SaveMember(AuthorizeTypeEnum authorizeType, string objectId, string userIds)
{
try
{
string[] arrayUserId = userIds.Split(',');
service.SaveMember(authorizeType, objectId, arrayUserId);
}
catch (Exception)
{
throw;
}
}
///
/// 保存授权
///
/// 权限分类
/// 对象Id
/// 功能Id
/// 按钮Id
/// 视图Id
/// 数据权限
///
public void SaveAuthorize(AuthorizeTypeEnum authorizeType, string objectId, string moduleIds, string moduleButtonIds, string moduleColumnIds, string authorizeDataJson)
{
try
{
string[] arrayModuleId = moduleIds.Split(',');
string[] arrayModuleButtonId = moduleButtonIds.Split(',');
string[] arrayModuleColumnId = moduleColumnIds.Split(',');
IEnumerable authorizeDataList = authorizeDataJson.ToList();
service.SaveAuthorize(authorizeType, objectId, arrayModuleId, arrayModuleButtonId, arrayModuleColumnId, authorizeDataList);
}
catch (Exception)
{
throw;
}
}
#endregion
}
}