Exemple #1
0
        /// <summary>
        /// 获取角色的权限集合
        /// </summary>
        /// <param name="RoleId">角色Id</param>
        /// <param name="authorityType">权限类型</param>
        /// <returns></returns>
        public MessageModel GetRoleAuthoritieList(string RoleId, SysEnum.Enum_AuthorityType authorityType)
        {
            var RoleList = sysRoleBLL.GetModels(t => t.RoleId.Equals(RoleId));

            return(new MessageModel
            {
                Data = sysAuthorityDAL.GetSysAuthorities(false, RoleList, authorityType)
            });
        }
Exemple #2
0
        /// <summary>
        /// 获取角色的权限集合
        /// </summary>
        /// <param name="RoleId">角色Id</param>
        /// <param name="authorityType">权限类型</param>
        /// <returns></returns>
        public HandleResult <List <SysAuthority> > GetRoleAuthoritieList(string RoleId, AuthorityType authorityType)
        {
            var RoleList = sysRoleBLL.GetModels(t => t.RoleId.Equals(RoleId));

            return(new HandleResult <List <SysAuthority> >
            {
                Data = sysAuthorityDAL.GetSysAuthorities(false, RoleList, authorityType)
            });
        }
Exemple #3
0
        /// <summary>
        /// 根据查询条件获取记录
        /// </summary>
        /// <param name="sWhere">查询条件;多条件是目前只支持 and;表达式 System.Linq.Dynamic的形式</param>
        /// <returns>符合查询条件的List</returns>
        public List <SysRole> GetSysRoles(string sWhere)
        {
            Expression <Func <SysRole, bool> > whereLamda = SerializerHelper.ConvertParamWhereToLinq <SysRole>(sWhere);

            using (ISysRoleBLL SysRoleBLL = BLLContainer.Resolve <ISysRoleBLL>())
            {
                List <SysRole> models = SysRoleBLL.GetModels(whereLamda);
                return(models);
            }
        }
Exemple #4
0
        /// <summary>
        /// 添加/修改角色
        /// </summary>
        /// <param name="userGroupDto"></param>
        /// <param name="objCheckMenus">角色的菜单权限</param>
        /// <returns></returns>
        public IActionResult AddorEditRole(SysRoleDto roleDto, List <SysMenuDto> objCheckMenus)
        {
            bool   bResult  = true;
            string sMessage = "保存成功";
            var    role     = AutoMapper.Mapper.Map <SysRole>(roleDto);

            if (_sysRoleBLL.GetCount(t => t.RoleName.Equals(role.RoleName) && !t.RoleId.Equals(role.RoleId) && t.DeleteSign.Equals((int)DeleteSign.Sing_Deleted)) > 0)
            {
                sMessage = "角色名称不能重复";
                bResult  = !bResult;
            }
            else
            {
                //添加
                if (string.IsNullOrEmpty(role.RoleId))
                {
                    role.DeleteSign   = (Int32)DeleteSign.Sing_Deleted;
                    role.CreateUserId = _userAccount.GetUserInfo().UserId;
                    role.CreateTime   = DateTime.Now;
                    bResult           = _sysRoleBLL.Add(role);
                    bResult           = _sysRoleBLL.AddRoleMenu(role.RoleId, objCheckMenus).Result;
                }
                else//修改
                {
                    var userRole_Edit = _sysRoleBLL.GetModels(t => t.RoleId.Equals(role.RoleId)).SingleOrDefault();
                    userRole_Edit.RoleName = role.RoleName;
                    userRole_Edit.EditTime = DateTime.Now;
                    userRole_Edit.Note     = role.Note;
                    bResult = _sysRoleBLL.Update(userRole_Edit);
                    bResult = _sysRoleBLL.AddRoleMenu(userRole_Edit.RoleId, objCheckMenus).Result;
                }
            }
            return(Ok(new ResponseModel
            {
                RetCode = bResult ? StatesCode.success : StatesCode.failure,
                RetMsg = sMessage
            }));
        }