/// <summary> /// 添加角色 /// </summary> /// <param name="entity"></param> public int AddRole(SysRoleEntity entity) { entity.IncludeAll(); int line = this.SysRole.Add(entity); if (line > 0) { CacheHelper.Remove(CacheKey.JOOSHOW_SYSROLE_CACHE); } return(line); }
/// <summary> /// 添加角色 /// </summary> /// <param name="entity"></param> public int AddRole(SysRoleEntity entity) { string key = string.Format(CacheKey.JOOSHOW_SYSROLE_CACHE, this.CompanyID); entity.SnNum = entity.SnNum.IsEmpty() ? ConvertHelper.NewGuid() : entity.SnNum; entity.RoleNum = entity.RoleNum.IsEmpty()? new TNumProvider(this.CompanyID).GetSwiftNum(typeof(SysRoleEntity), 5):entity.RoleNum; entity.IncludeAll(); int line = this.SysRole.Add(entity); if (line > 0) { CacheHelper.Remove(key); } return(line); }
/// <summary> /// 获得所有角色信息 /// </summary> /// <returns></returns> public List <SysRoleEntity> GetList() { List <SysRoleEntity> list = CacheHelper.Get(CacheKey.JOOSHOW_SYSROLE_CACHE) as List <SysRoleEntity>; if (!list.IsNullOrEmpty()) { return(list); } SysRoleEntity sysRole = new SysRoleEntity(); sysRole.IncludeAll(); int isDelete = (int)EIsDelete.NotDelete; sysRole.Where(a => a.IsDelete == isDelete); list = this.SysRole.GetList(sysRole); if (!list.IsNullOrEmpty()) { CacheHelper.Insert(CacheKey.JOOSHOW_SYSROLE_CACHE, list); } return(list); }
/// <summary> /// 获得所有角色信息 /// </summary> /// <returns></returns> public List <SysRoleEntity> GetList() { string key = string.Format(CacheKey.JOOSHOW_SYSROLE_CACHE, this.CompanyID); string AdminRoleNum = ResourceManager.GetSettingEntity("Super_AdminRole").Value; List <SysRoleEntity> list = CacheHelper.Get(key) as List <SysRoleEntity>; if (!list.IsNullOrEmpty()) { return(list.Where(item => item.RoleNum != AdminRoleNum).ToList()); } SysRoleEntity sysRole = new SysRoleEntity(); sysRole.IncludeAll(); sysRole.Where <SysRoleEntity>(a => a.IsDelete == (int)EIsDelete.NotDelete) .And <SysRoleEntity>(a => a.CompanyID == this.CompanyID); sysRole.OrderBy(a => a.ID, EOrderBy.DESC); list = this.SysRole.GetList(sysRole); if (!list.IsNullOrEmpty()) { CacheHelper.Insert(key, list); } return(list.Where(item => item.RoleNum != AdminRoleNum).ToList()); }