Esempio n. 1
0
        public void TestMethod1()
        {
            //取得所有模块
            List <StructureDTO> list = _ICommonServices.GetAllStructure();

            Assert.IsNotNull(list);

            //取得所有功能按钮
            List <ButtonDTO> list1 = _ICommonServices.GetAllButton();

            Assert.IsNotNull(list1);

            //取得取得用户权限
            //用户名为系统管理员的权限
            List <CurrentAuthorityDTO> list2 = _ICommonServices.GetUserAuthority(1);

            Assert.IsNotNull(list2);

            //取得角色权限
            //角色为系统管理员的权限
            List <CurrentAuthorityDTO> list3 = _ICommonServices.GetRoleAuthority(new List <int> {
                1
            });

            Assert.IsNotNull(list3);

            //取得角色类型权限
            //类型为系统管理员的权限
            List <CurrentAuthorityDTO> list4 = _ICommonServices.GetRoleTypeAuthority(0);

            Assert.IsNotNull(list4);

            //取得所有管理员信息
            //系统管理员的信息
            AdminSearchDTO dto = new AdminSearchDTO();

            dto.RoleIdList = new List <int>()
            {
                0
            };
            List <AdminDTO> list5 = _ICommonServices.GetAdminInfo(dto);

            Assert.IsNotNull(list5);
        }
Esempio n. 2
0
        public HttpResponseMessage GetAuthority(string strIdlst, int type, int?roletype)
        {
            List <CurrentAuthorityDTO> resultAuthority = null;

            switch (type)
            {
            case 1:
                if (strIdlst != null)
                {
                    resultAuthority = _ICommonServices.GetUserAuthority(int.Parse(strIdlst));
                }
                break;

            case 2:
                if (strIdlst != null)
                {
                    var arrstr = strIdlst.Split('|').ToList();

                    List <int> intIdLst = new List <int>();
                    arrstr.ForEach(g => {
                        if (g != "")
                        {
                            intIdLst.Add(int.Parse(g));
                        }
                    });
                    resultAuthority = _ICommonServices.GetRoleAuthority(intIdLst);
                }
                else if (roletype != null)
                {
                    resultAuthority = _ICommonServices.GetRoleTypeAuthority(roletype.Value);
                }
                break;
            }

            HttpResponseMessage result = new HttpResponseMessage
            {
                Content = new StringContent(JsonConvert.SerializeObject(resultAuthority),
                                            System.Text.Encoding.GetEncoding("UTF-8"),
                                            "application/json")
            };

            return(result);
        }