using HxDbContext;
|
using HxModel;
|
using System;
|
using System.Collections.Generic;
|
using System.Linq;
|
using System.Text;
|
using System.Threading.Tasks;
|
|
namespace HxUserManagement.HxDAL
|
{
|
public class RolesDAL
|
{
|
#region 获取信息
|
/// <summary>
|
/// 获取信息
|
/// </summary>
|
/// <param name="id">ID</param>
|
/// <returns></returns>
|
public RolesModel GetInfodById(string id)
|
{
|
var result = new MySqlEF<RolesModel>().GetModel(x => x.Id == id);
|
if (result != null)
|
{
|
return result;
|
}
|
return null;
|
}
|
|
/// <summary>
|
/// 获取所有权限列表
|
/// </summary>
|
/// <returns></returns>
|
public List<RolesModel> GetAllRoles()
|
{
|
var result = new MySqlEF<RolesModel>().GetList(null);
|
foreach(var role in result)
|
{
|
if (role.Type == "0")
|
role.TypeName = Properties.Resources.strLock;
|
else
|
role.TypeName = Properties.Resources.strNormal;
|
}
|
if (result != null)
|
{
|
return result.ToList();
|
}
|
return null;
|
}
|
|
#endregion
|
|
#region 删除
|
/// <summary>
|
/// 删除
|
/// </summary>
|
/// <param name="id"></param>
|
/// <returns></returns>
|
public bool DelById(string id)
|
{
|
var resultDelModel = new MySqlEF<RolesModel>().GetModel(x => x.Id == id);
|
if (resultDelModel != null)
|
{
|
var result = new MySqlEF<RolesModel>().Delete(new RolesModel { Id = id });
|
return result;
|
}
|
return false;
|
}
|
#endregion
|
|
#region 添加
|
/// <summary>
|
/// 添加
|
/// </summary>
|
/// <param name="model"></param>
|
/// <returns></returns>
|
public RolesModel Add(RolesModel model)
|
{
|
try
|
{
|
var result = new MySqlEF<RolesModel>().Add(model);
|
if (result != null)
|
{
|
return model;
|
}
|
|
|
}
|
catch (Exception ex)
|
{
|
}
|
return null;
|
}
|
#endregion
|
|
#region 修改
|
/// <summary>
|
/// 修改
|
/// </summary>
|
/// <param name="model"></param>
|
/// <returns></returns>
|
public RolesModel Update(RolesModel model)
|
{
|
var result = new MySqlEF<RolesModel>().Update(model);
|
|
#region AddLog
|
OperateAuditLogDAL logDAL = new OperateAuditLogDAL();
|
logDAL.Add("修改", "修改权限【" + model.Name + "】");
|
#endregion
|
|
if (result != null)
|
{
|
return result;
|
}
|
|
return null;
|
}
|
#endregion
|
}
|
}
|