添加项目文件。
This commit is contained in:
159
SamplePre.ProcessBll/ConfigManagerBLL/RolesBll.cs
Normal file
159
SamplePre.ProcessBll/ConfigManagerBLL/RolesBll.cs
Normal file
@@ -0,0 +1,159 @@
|
||||
using DataDAL;
|
||||
using Models.Const;
|
||||
using Models.Ext;
|
||||
using Models.Models;
|
||||
using SamplePre.Common;
|
||||
using SamplePre.Common.Helper;
|
||||
using SamplePre.DAL;
|
||||
using SamplePre.DAL.DBContext;
|
||||
using SamplePre.Models;
|
||||
using SamplePre.Models.Ext;
|
||||
using SamplePre.Models.Tables;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Data.Common;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using static System.Collections.Specialized.BitVector32;
|
||||
|
||||
namespace SamplePre.ProcessBll.BLL
|
||||
{
|
||||
public class RolesBll
|
||||
{
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 删除角色
|
||||
/// </summary>
|
||||
/// <param name="user"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
public int DeleteRole(config_role role)
|
||||
{
|
||||
|
||||
var _db = DBFactory.Instance;
|
||||
|
||||
try
|
||||
{
|
||||
_db.BeginTran();
|
||||
var val = _db.Deleteable<config_role>(role)
|
||||
.Where(p => p.id == role.id)
|
||||
.ExecuteCommand();
|
||||
|
||||
|
||||
////
|
||||
//删除角色权限
|
||||
_db.Deleteable<config_role_permisson>().Where(p => p.role_id == role.id).ExecuteCommand();
|
||||
|
||||
|
||||
_db.CommitTran();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_db.RollbackTran();
|
||||
LoggerHelper.Logger.Error(ex.Message);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 1;
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取功能树
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
public List<config_function_ext> GetFuncDataTree()
|
||||
{
|
||||
List<config_function> funcList = DBFactory.Instance.Queryable<config_function>().ToList();
|
||||
List<config_function_ext> funcList2 = new List<config_function_ext>();
|
||||
|
||||
foreach(var item in funcList)
|
||||
{
|
||||
config_function_ext ext = new config_function_ext();
|
||||
ext.code = item.code;
|
||||
ext.id = item.id;
|
||||
ext.name = item.name;
|
||||
ext.description = item.description;
|
||||
ext.IsChecked = false;
|
||||
ext.parent_id = item.parent_id;
|
||||
|
||||
funcList2.Add(ext);
|
||||
}
|
||||
|
||||
return funcList2;
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取角色的权限id集合
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
public List<int> GetPermission(string id)
|
||||
{
|
||||
var list = DBFactory.Instance.Queryable<config_role_permisson>()
|
||||
.Where(p => p.role_id == id)
|
||||
.Select(p => p.function_id)
|
||||
.ToList();
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
public List<config_role> GetRoles()
|
||||
{
|
||||
List<config_role> roles = DBFactory.Instance.Queryable<config_role>().ToList();
|
||||
|
||||
return roles;
|
||||
}
|
||||
|
||||
public int SavePermission(List<config_role_permisson> rolePermissonList)
|
||||
{
|
||||
var _db = DBFactory.Instance;
|
||||
|
||||
try
|
||||
{
|
||||
_db.BeginTran();
|
||||
|
||||
//先删除
|
||||
var val = _db.Deleteable<config_role_permisson>()
|
||||
.Where(p => p.role_id == rolePermissonList[0].role_id)
|
||||
.ExecuteCommand();
|
||||
|
||||
|
||||
///保存权限
|
||||
DBFactory.Instance.Insertable<config_role_permisson>(rolePermissonList).ExecuteCommand();
|
||||
|
||||
_db.CommitTran();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_db.RollbackTran();
|
||||
LoggerHelper.Logger.Error(ex.Message);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 1;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public int SaveRoleData(config_role configRole)
|
||||
{
|
||||
var val = DBFactory.Instance.Insertable<config_role>(configRole).ExecuteCommand();
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
public int UpdateRoleData(config_role configRole)
|
||||
{
|
||||
var val = DBFactory.Instance.Updateable<config_role>(configRole).ExecuteCommand();
|
||||
|
||||
return val;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user