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 lazy = new Lazy(() => new SysUserRoleService()); public static SysUserRoleService Instance { get { return lazy.Value; } } private LogHelper log = LogHelper.Instance; Repository _repository => new Repository("sqlserver"); /// /// 查询所有角色列表 /// /// public List GetRoleInfos() { try { List deviceInfo = _repository.GetList(); return deviceInfo; } catch (Exception ex) { log.Error("用户信息获取异常", ex); return null; } } /// /// 查询所有角色列表 /// /// public List GetRoleInfos(string roleName) { try { List deviceInfo = _repository.GetList(x => x.RoleName == roleName); return deviceInfo; } catch (Exception ex) { log.Error("用户信息获取异常", ex); return null; } } /// /// 添加角色信息 /// /// /// public bool InsertRoleInfo(SysRoleEntity sysRoleEntity) { try { return _repository.Insert(sysRoleEntity); } catch (Exception ex) { log.Error("用户信息插入异常", ex); return false; } } /// /// 修改角色信息 /// /// /// public bool UpdateRoleInfo(SysRoleEntity sysRoleEntity) { try { return _repository.Update(sysRoleEntity); } catch (Exception ex) { log.Error("用户信息修改异常", ex); return false; } } /// /// 根据ID删除角色信息 /// /// /// public bool DeleteRoleInfoById(int id) { try { return _repository.DeleteById(id); } catch (Exception ex) { log.Error("用户信息删除异常", ex); return false; } } } }