| | |
| | | import cc.mrbird.febs.dapp.service.DappSimulateDataService; |
| | | import cc.mrbird.febs.dapp.service.DappSystemService; |
| | | import cc.mrbird.febs.dapp.service.IMallNewsInfoService; |
| | | import cc.mrbird.febs.dapp.soccer.dto.LeaguesApiDto; |
| | | import cc.mrbird.febs.dapp.soccer.entity.SoccerLeagues; |
| | | import cc.mrbird.febs.dapp.soccer.mapper.SoccerLeaguesMapper; |
| | | import cc.mrbird.febs.dapp.vo.MallGoodsListVo; |
| | | import cc.mrbird.febs.dapp.vo.NewsListVo; |
| | | import cc.mrbird.febs.dapp.vo.SimulateDataVo; |
| | | import cc.mrbird.febs.rabbit.producer.ChainProducer; |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.hutool.core.date.DateUtil; |
| | | import cn.hutool.core.util.ObjectUtil; |
| | | import cn.hutool.json.JSONArray; |
| | | import cn.hutool.json.JSONObject; |
| | | import cn.hutool.json.JSONUtil; |
| | | import com.mashape.unirest.http.HttpResponse; |
| | | import com.mashape.unirest.http.Unirest; |
| | | import com.mashape.unirest.http.exceptions.UnirestException; |
| | |
| | | |
| | | private final DappMemberService dappMemberService; |
| | | private final IMallNewsInfoService newsService; |
| | | private final SoccerLeaguesMapper soccerLeaguesMapper; |
| | | |
| | | @ApiOperation(value = "地址是否存在", notes = "地址是否存在") |
| | | @GetMapping(value = "/exist/{address}") |
| | |
| | | return new FebsResponse().success().data(news); |
| | | } |
| | | |
| | | @ApiOperation(value = "testApi", notes = "testApi") |
| | | @ApiOperation(value = "获取国家", notes = "获取国家") |
| | | @GetMapping(value = "/testApi") |
| | | public FebsResponse testApi() { |
| | | HttpResponse<String> response = null; |
| | |
| | | } catch (UnirestException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | Log.info(response); |
| | | Log.info(response.getBody()); |
| | | Log.info(response.getRawBody()); |
| | | log.info(String.valueOf(response)); |
| | | log.info(response.getBody()); |
| | | log.info(String.valueOf(response.getRawBody())); |
| | | return new FebsResponse().success(); |
| | | } |
| | | |
| | | @ApiOperation(value = "获取联赛", notes = "获取联赛") |
| | | @PostMapping(value = "/leaguesApi") |
| | | public FebsResponse leaguesApi(LeaguesApiDto leaguesApiDto) { |
| | | HttpResponse<String> response = null; |
| | | int season = ObjectUtil.isEmpty(leaguesApiDto.getSeason()) ? DateUtil.date().year() : leaguesApiDto.getSeason(); |
| | | String current = ObjectUtil.isEmpty(leaguesApiDto.getCurrent()) ? "true" : leaguesApiDto.getCurrent(); |
| | | try { |
| | | /** |
| | | * https://v3.football.api-sports.io/leagues?season=2023¤t=true |
| | | */ |
| | | response = Unirest.get(" https://v3.football.api-sports.io/leagues") |
| | | .header("x-rapidapi-key", "87f8d87d629d1704ba49622cb978eb81") |
| | | .header("x-rapidapi-host", "v3.football.api-sports.io") |
| | | .queryString("season",season) |
| | | .queryString("current",current) |
| | | .asString(); |
| | | } catch (UnirestException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | log.info(String.valueOf(response)); |
| | | log.info(response.getBody()); |
| | | JSONObject parseObj = JSONUtil.parseObj(response.getBody()); |
| | | Object responseStr = parseObj.get("response"); |
| | | JSONArray jsonArray = JSONUtil.parseArray(responseStr); |
| | | if(CollUtil.isNotEmpty(jsonArray)){ |
| | | for(Object list : jsonArray){ |
| | | cn.hutool.json.JSONObject parseObj1 = JSONUtil.parseObj(list); |
| | | Object leagueObj = parseObj1.get("league"); |
| | | cn.hutool.json.JSONObject parseObjLeague = JSONUtil.parseObj(leagueObj); |
| | | JSONObject leagueStr = JSONUtil.parseObj(parseObjLeague); |
| | | System.out.println(leagueStr); |
| | | int id = (int)leagueStr.get("id"); |
| | | String type = (String)leagueStr.get("type"); |
| | | String name = (String)leagueStr.get("name"); |
| | | String logo = (String)leagueStr.get("logo"); |
| | | System.out.println(id); |
| | | System.out.println(type); |
| | | System.out.println(name); |
| | | System.out.println(logo); |
| | | |
| | | SoccerLeagues soccerLeagues = new SoccerLeagues(); |
| | | soccerLeagues.setLeaguesId(id); |
| | | soccerLeagues.setLeaguesName(name); |
| | | soccerLeagues.setLeaguesType(type); |
| | | soccerLeagues.setLeaguesLogo(logo); |
| | | soccerLeaguesMapper.insert(soccerLeagues); |
| | | } |
| | | } |
| | | System.out.println(jsonArray); |
| | | log.info(String.valueOf(response.getRawBody())); |
| | | return new FebsResponse().success(); |
| | | } |
| | | |
| | | public static void main(String[] args) { |
| | | String json = "{\n" + |
| | | " \"get\": \"leagues\",\n" + |
| | | " \"parameters\": {\n" + |
| | | " \"id\": \"53\",\n" + |
| | | " \"season\": \"2023\",\n" + |
| | | " \"current\": \"true\"\n" + |
| | | " },\n" + |
| | | " \"errors\": [],\n" + |
| | | " \"results\": 1,\n" + |
| | | " \"paging\": {\n" + |
| | | " \"current\": 1,\n" + |
| | | " \"total\": 1\n" + |
| | | " },\n" + |
| | | " \"response\": [\n" + |
| | | " {\n" + |
| | | " \"league\": {\n" + |
| | | " \"id\": 53,\n" + |
| | | " \"name\": \"Non League Div One - Isthmian South Central\",\n" + |
| | | " \"type\": \"League\",\n" + |
| | | " \"logo\": \"https://media-4.api-sports.io/football/leagues/53.png\"\n" + |
| | | " },\n" + |
| | | " \"country\": {\n" + |
| | | " \"name\": \"England\",\n" + |
| | | " \"code\": \"GB\",\n" + |
| | | " \"flag\": \"https://media-4.api-sports.io/flags/gb.svg\"\n" + |
| | | " },\n" + |
| | | " \"seasons\": [\n" + |
| | | " {\n" + |
| | | " \"year\": 2023,\n" + |
| | | " \"start\": \"2023-08-12\",\n" + |
| | | " \"end\": \"2024-04-27\",\n" + |
| | | " \"current\": true,\n" + |
| | | " \"coverage\": {\n" + |
| | | " \"fixtures\": {\n" + |
| | | " \"events\": false,\n" + |
| | | " \"lineups\": false,\n" + |
| | | " \"statistics_fixtures\": false,\n" + |
| | | " \"statistics_players\": false\n" + |
| | | " },\n" + |
| | | " \"standings\": true,\n" + |
| | | " \"players\": true,\n" + |
| | | " \"top_scorers\": true,\n" + |
| | | " \"top_assists\": true,\n" + |
| | | " \"top_cards\": true,\n" + |
| | | " \"injuries\": false,\n" + |
| | | " \"predictions\": true,\n" + |
| | | " \"odds\": false\n" + |
| | | " }\n" + |
| | | " }\n" + |
| | | " ]\n" + |
| | | " }\n" + |
| | | " ]\n" + |
| | | "}\n"; |
| | | |
| | | JSONObject parseObj = JSONUtil.parseObj(json); |
| | | Object response = parseObj.get("response"); |
| | | JSONArray jsonArray = JSONUtil.parseArray(response); |
| | | if(CollUtil.isNotEmpty(jsonArray)){ |
| | | for(Object list : jsonArray){ |
| | | JSONObject parseObj1 = JSONUtil.parseObj(list); |
| | | Object leagueObj = parseObj1.get("league"); |
| | | JSONObject parseObjLeague = JSONUtil.parseObj(leagueObj); |
| | | JSONObject leagueStr = JSONUtil.parseObj(parseObjLeague); |
| | | System.out.println(leagueStr); |
| | | int id = (int)leagueStr.get("id"); |
| | | String type = (String)leagueStr.get("type"); |
| | | String name = (String)leagueStr.get("name"); |
| | | String logo = (String)leagueStr.get("logo"); |
| | | System.out.println(id); |
| | | System.out.println(type); |
| | | System.out.println(name); |
| | | System.out.println(logo); |
| | | |
| | | |
| | | } |
| | | } |
| | | System.out.println(jsonArray); |
| | | } |
| | | |
| | | |
| | | // @ApiOperation(value = "头部数据", notes = "头部数据") |
| | | // @GetMapping(value = "/totalIncome") |