public async Task <ActionResult <List <Team> > > Get() { Console.WriteLine($"查询团队成员消息"); // 1、查询团队 IList <Team> teams = await teamServiceClient.GetTeams(); // 2、查询团队成员 foreach (var team in teams) { IList <Member> members = await memberServiceClient.GetMembers(team.Id); team.Members = members; } _Logger.Info("团队信息添加成功"); return(Ok(teams)); }
public async Task <ActionResult <List <Team> > > Get() { Console.WriteLine($"查询团队成员消息"); _logger.LogDebug("查询团队成员消息"); _logger.LogError("出错啦!!!"); #region 配置中心测试相关 //// 1. 配置获取 //Console.WriteLine($"配置中心配置项:Leo-Test={_configuration["Leo-Test"]}"); //// 2. 动态设置数据连接 //_dbContext.Database.GetDbConnection().ConnectionString = _configuration.GetConnectionString("DefaultConnection"); //// 3. 使用场景,缓存配置开关、服务降级 //var useCache = _configuration["UseCache"]; //if (useCache == "true") //{ // // 使用缓存,dosomething... // return Ok(new List<Team>()); //} //else //{ // // 不使用缓存,dosomething... // // 1、查询团队 // IList<Team> teams = await _teamServiceClient.GetTeams(); // // 2、查询团队成员 // foreach (var team in teams) // { // IList<Member> members = await _memberServiceClient.GetMembersByTeamId(team.Id); // team.Members = members; // } // return Ok(teams); //} #endregion // 1、查询团队 IList <Team> teams = await _teamServiceClient.GetTeams(); // 2、查询团队成员 foreach (var team in teams) { IList <Member> members = await _memberServiceClient.GetMembersByTeamId(team.Id); team.Members = members; } return(Ok(teams)); }
public async Task <ActionResult <List <Team> > > Get() { /*// 1、查询团队 * HttpClient httpClient = _httpClientFactory.CreateClient(); * HttpResponseMessage response = await httpClient.GetAsync("https://localhost:5001/Teams"); * * string json = await response.Content.ReadAsStringAsync(); * IList<Team> teams = JsonConvert.DeserializeObject<List<Team>>(json);*/ /*// 2、查询团队成员 * foreach (var team in teams) * { * HttpResponseMessage response1 = await httpClient.GetAsync($"https://localhost:5002/Members?teamId={team.Id}"); * string json1 = await response1.Content.ReadAsStringAsync(); * * List<Member> members = JsonConvert.DeserializeObject<List<Member>>(json1); * * team.Members = members; * }*/ IList <Team> teams = await teamServiceClient.GetTeams(); return(Ok(teams)); }