Ejemplo n.º 1
0
        public async Task <IActionResult> InitUserAsync(Int32 userId = 0)
        {
            UserDto userDto  = null;
            var     response = new ResponseModel <dynamic>();

            if (userId != 0)
            {
                userDto = await _userServices.GetUserAsync(userId);

                if (userDto == null)
                {
                    response.Message   = "获取用户失败";
                    response.IsSuccess = false;
                }
            }
            var userContext = await GetUserContextAsync();

            var roleDtos = await _securityServices.GetRolesAsync("", 1, 100);

            var uniqueToken = await CreateUniqueTokenAsync(userContext.Id);

            response.Model     = new { roleDtos, userDto, uniqueToken };
            response.IsSuccess = true;
            response.Message   = "创建新账户初始化成功";

            return(Json(response));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> GetRolesAsync(String roleName, Int32 pageIndex, Int32 pageSize)
        {
            Check.IfNullOrZero(roleName, true);
            var result = await _securityServices.GetRolesAsync(roleName, pageIndex, pageSize);

            return(Json(new ResponsePaging <IList <RoleDto> >
            {
                IsSuccess = true,
                Message = "获取角色列表成功",
                Model = result.Models,
                TotalCount = result.TotalCount
            }));
        }