【联赛列表】电竞CSGO界面,在线界面文档importcom.alibaba.fastjson.JSON;importcom.alibaba.fastjson.annotation.JSONField;导入java.nio.charset.StandardCharsets;导入java.nio.file.Files;导入java.nio.file.Paths;导入java.util.List;/***@API:联赛列表*@Website:https://www.feijing88.com*/publicclassCsgoLeague{publicstaticvoidmain(String[]args){try{Stringcontent=getContent();响应rsp=JSON.parseObject(content,Respond.class);System.out.println(rsp.code);System.out.println(rsp.message);rsp.getLeagueList().forEach(System.out::println);}catch(Throwablet){t.printStackTrace();}}/***获取API返回的内容*
*注意:这里为了方便测试,我使用了本地文件,应该换成真正的接口返回内容*/privatestaticStringgetContent(){尝试{StringBuilderbuilder=newStringBuilder();列表行=Files.readAllLines(Paths.get("./src/main/resources/CsgoLeague.json"),StandardCharsets.UTF_8);lines.forEach(builder::append);返回builder.toString();}catch(Throwablet){t.printStackTrace();返回””;}}publicstaticclassRespond{@JSONField(name="code")privateintcode;@JSONField(name="message")私有字符串消息;@JSONField(name="data")privateListleagueList;publicintgetCode(){返回代码;}publicvoidsetCode(intcode){this.code=code;}publicStringgetMessage(){返回消息;}publicvoidsetMessage(Stringmessage){this.message=message;}publicListgetLeagueList(){returnleagueList;}publicvoidsetLeagueList(ListleagueList){this.leagueList=leagueList;}}publicstaticclassLeague{@JSONField(name="league_id")privateintleagueId;@JSONField(name="logo")私有字符串标识;@JSONField(name="name")私有字符串名称;@JSONField(name="country")私人字符串国家;@JSONField(name="location")私有字符串位置;@JSONField(name="start_time")privatelongstartTime;@JSONField(name="end_time")privatelongendTime;@JSONField(name="team_ids")privateListteamIds;@JSONField(name="status")privateint状态;@OverridepublicStringtoString(){return"League{"+"leagueId="+leagueId+",logo='"+logo+'\''+",name='"+name+'\''+",country='"+country+'\''+",location='"+location+'\''+",startTime="+startTime+",endTime="+endTime+",teamIds="+teamIds+",status="+status+'}';}publicintgetLeagueId(){返回leagueId;}publicvoidsetLeagueId(intleagueId){this.leagueId=leagueId;}publicStringgetLogo(){返回标识;}publicvoidsetLogo(Stringlogo){this.logo=logo;}publicStringgetName(){返回名称;}publicvoidsetName(Stringname){this.name=name;}publicStringgetCountry(){返回国家;}publicvoidsetCountry(Stringcountry){this.country=country;}publicStringgetLocation(){返回位置;}publicvoidsetLocation(Stringlocation){this.location=location;}publiclonggetStartTime(){返回开始时间;}publicvoidsetStartTime(longstartTime){this.startTime=startTime;}publiclonggetEndTime(){返回结束时间;}publicvoidsetEndTime(longendTime){this.endTime=endTime;}publicListgetTeamIds(){returnteamIds;}publicvoidsetTeamIds(ListteamIds){this.teamIds=teamIds;}publicintgetStatus(){返回状态;}publicvoidsetStatus(intstatus){this.status=status;}}}API返回数据如下(部分):200成功联赛{leagueId=9866,logo='http://qn.feijing88.com/feijing-home/egame/image/20190514/49cd2c63e3834fa2a92df8f1d02ec390.png',name='DreamHack公开赛villa2019',country='Spain',location='Sevilla,Spain',startTime=1576234800000,endTime=1576407600000,teamIds=[],status=2}League{leagueId=9342,logo='http://qn.feijing88.com/feijing-home/egame/image/20190801/a50756930fbe44b68b35c1e63febfe70.jpg',name='GamersClubMastersIV',country='Brazil',location='Sorocaba,S?oPaulo',startTime=1576148400000,endTime=15770012400,teamIds=[],status=0}League{leagueId=9253,logo='http://qn.feijing88.com/feijing-home/egame/image/20190624/06280d3da7e640708ff86179eee76ffb.jpg',name='ESL职业联赛Season10Finals',country='Denmark',location='Odense,Denmark',startTime=1575630000000,endTime=1575802800000,teamIds=[],status=2}League{leagueId=9868,logo='http://qn.feijing88.com/feijing-home/egame/image/20190514/7190e798f3d84ce2b52902f09dbc2349.png',name='DreamHackOpenWinter2019',country='Sweden',location='J?nk?ping,Sweden',startTime=1575025200000,endTime=8015075,teamIds=[],status=0}League{leagueId=9240,logo='http://qn.feijing88.com/feijing-home/egame/image/20190711/b340bbdf32554914961b4a1e328a3c9b.png',name='CS:GO亚洲锦标赛2019',country='中国',location='中国上海',startTime=1574334000000,endTime=1574593200000,teamIds=[9425,5761,9428],status=2}League{leagueId=9867,logo='http://qn.feijing88.com/feijing-home/egame/image/20190514/04e44a98f9564a4983568ae8b95bc506.png',name='DreamHackOpenAtlanta2019',country='UnitedStates',location='Atlanta,Georgia,USA',startTime=1573815600000,endTime=1573988880000,4000=[],status=0}联赛{leagueId=9246,logo='http://qn.feijing88.com/feijing-home/egame/image/20190713/7a21b891f3fd493c94c19e17d82d543c.jpg',name='极限乐园2019亚洲总决赛',country='中国',location='中国上海',startTime=1573729200000,endTime=1573988400000,teamIds=[],status=2}League{leagueId=9307,logo='http://qn.feijing88.com/飞精-home/egame/image/20190627/2f20036ba3a84bbb90815f1acb8c2dbf.jpg',name='BLASTProSeriesCopenhagen2019',country='Denmark',location='Copenhagen,Denmark',startTime=1572606000000,endTime=1572692400000,teamIds=[1538,2221,9204,9966],status=2}League{leagueId=9348,logo='http://qn.feijing88.com/feijing-home/egame/image/20190801/aad3efd47ed64a1a922ae1b56dbc3996.png',name='ESLLALeagueSeason5Finals',country='巴西',location='圣保罗',startTime=1572084000000,endTime=1572170400000,teamIds=[],status=2}League{leagueId=9275,logo='http://qn.feijing88.com/feijing-home/egame/image/20190521/5860289be57d46dc88eaa30bac90bb45.png',name='LogitechGChallenge2019',country='Mexico',location='MexicoCity,Mexico',startTime=1571997600000,endTime=1571997600000,teamIds=[],状态=2}