Exemple #1
0
 public List<FullRoleInfo> QueryFullRole(RoleQueryForm form)
 {
     form.IsDeleted = 0;
     return bll.QueryFullRole(form);
 }
Exemple #2
0
        /// <summary>
        /// 查询角色
        /// </summary>
        /// <param name="form"></param>
        /// <returns></returns>
        public List<FullRoleInfo> QueryFullRole(RoleQueryForm form)
        {
            ISqlMapper mapper = MapperHelper.GetMapper();
            RoleDao dao = new RoleDao(mapper);
            Role_Module_ActionDao rmadao = new Role_Module_ActionDao(mapper);
            Menu_RoleDao mrdao = new Menu_RoleDao(mapper);
            MenuDao menudao = new MenuDao(mapper);
            List<FullRoleInfo> result = new List<FullRoleInfo>();
            form.IsDeleted = 0;
            var roles = dao.Query(form);
            var roleids = (from r in roles select r.ID).ToList();
            var rmas = rmadao.Query(new Role_Module_ActionQueryForm { RoleIDs = roleids });
            var mrs = mrdao.Query(new Menu_RoleQueryForm { RoleIDs = roleids });
            var menuids = (from mr in mrs select mr.MenuID).Distinct().ToList();
            var menus = menudao.Query(new MenuQueryForm { IDs = menuids, Enabled = 1 });
            AuthorityMapping mapping = XMLHelper.DeserializeFromFile<AuthorityMapping>(Common.AuthorityMappingFile);
            foreach (var role in roles)
            {
                var data = role.ConvertTo<FullRoleInfo>();
                var parentrole = roles.Find(t => t.ID == role.ParentID);
                if (parentrole != null) data.ParentRoleName = parentrole.Name;
                #region 查询权限
                var role_rmas = rmas.FindAll(t => t.RoleID.Equals(role.ID));
                data.Authority = new List<AuthorityNodeForCheck>();
                foreach (var auth in mapping.AuthNode)
                {
                    auth.Checked = (from au in auth.Item
                                    from r in role_rmas
                                    where au.ModuleID == r.ModuleID && au.ActionID == r.ActionID
                                    select au).Count() == auth.Item.Count;
                    data.Authority.Add(new AuthorityNodeForCheck { ID = auth.ID, Checked = auth.Checked, Name = auth.Name });
                }
                #endregion

                #region 查询菜单
                data.Menus = (from mr in mrs join m in menus on mr.MenuID equals m.ID where mr.RoleID.Equals(role.ID) select m).ToList();
                #endregion
                result.Add(data);
            }
            return result;
        }
Exemple #3
0
 public List<Role> Query(RoleQueryForm form)
 {
     form.IsDeleted = 0;
     return bll.Query(form);
 }
Exemple #4
0
 public List<Role> Query(RoleQueryForm form)
 {
     ISqlMapper mapper = MapperHelper.GetMapper();
     RoleDao dao = new RoleDao(mapper);
     return dao.Query(form);
 }