forked from wenjy/HighWayIot
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
119 lines
3.1 KiB
C#
119 lines
3.1 KiB
C#
using HighWayIot.Log4net;
|
|
using HighWayIot.Repository.domain;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Linq.Expressions;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace HighWayIot.Repository.service
|
|
{
|
|
public class SysUserRoleService
|
|
{
|
|
private static readonly Lazy<SysUserRoleService> lazy = new Lazy<SysUserRoleService>(() => new SysUserRoleService());
|
|
|
|
public static SysUserRoleService Instance
|
|
{
|
|
get
|
|
{
|
|
return lazy.Value;
|
|
}
|
|
}
|
|
|
|
private LogHelper log = LogHelper.Instance;
|
|
Repository<SysRoleEntity> _repository => new Repository<SysRoleEntity>("sqlserver");
|
|
|
|
/// <summary>
|
|
/// 查询所有角色列表
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public List<SysRoleEntity> GetRoleInfos()
|
|
{
|
|
try
|
|
{
|
|
List<SysRoleEntity> entity = _repository.GetList();
|
|
return entity;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
log.Error("用户信息获取异常", ex);
|
|
return null;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 查询所有角色列表
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public List<SysRoleEntity> GetRoleInfos(string roleName)
|
|
{
|
|
try
|
|
{
|
|
List<SysRoleEntity> deviceInfo = _repository.GetList(x => x.RoleName == roleName);
|
|
|
|
return deviceInfo;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
log.Error("用户信息获取异常", ex);
|
|
return null;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 添加角色信息
|
|
/// </summary>
|
|
/// <param name="sysRoleEntity"></param>
|
|
/// <returns></returns>
|
|
public bool InsertRoleInfo(SysRoleEntity sysRoleEntity)
|
|
{
|
|
try
|
|
{
|
|
return _repository.Insert(sysRoleEntity);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
log.Error("用户信息插入异常", ex);
|
|
return false;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 修改角色信息
|
|
/// </summary>
|
|
/// <param name="sysRoleEntity"></param>
|
|
/// <returns></returns>
|
|
public bool UpdateRoleInfo(SysRoleEntity sysRoleEntity)
|
|
{
|
|
try
|
|
{
|
|
return _repository.Update(sysRoleEntity);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
log.Error("用户信息修改异常", ex);
|
|
return false;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 根据ID删除角色信息
|
|
/// </summary>
|
|
/// <param name="id"></param>
|
|
/// <returns></returns>
|
|
public bool DeleteRoleInfoById(int id)
|
|
{
|
|
try
|
|
{
|
|
return _repository.DeleteById(id);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
log.Error("用户信息删除异常", ex);
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
}
|