| | |
| | | import cn.hutool.json.JSONArray; |
| | | import cn.hutool.json.JSONObject; |
| | | import cn.hutool.json.JSONUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.mashape.unirest.http.HttpResponse; |
| | | import com.mashape.unirest.http.Unirest; |
| | |
| | | import lombok.RequiredArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.List; |
| | | |
| | | @Slf4j |
| | | @Service |
| | |
| | | if(CollUtil.isNotEmpty(jsonArray)){ |
| | | for(Object list : jsonArray){ |
| | | JSONObject jsonObject = JSONUtil.parseObj(list); |
| | | String code = SoccerResponseUtil.objectToStr(jsonObject.get("code")); |
| | | List<SoccerCountries> soccerCountryList = soccerCountriesMapper.selectList(new QueryWrapper<SoccerCountries>().eq("code", code)); |
| | | if(CollUtil.isNotEmpty(soccerCountryList)){ |
| | | continue; |
| | | } |
| | | SoccerCountries soccerCountries = new SoccerCountries(); |
| | | soccerCountries.setName(SoccerResponseUtil.objectToStr(jsonObject.get("code"))); |
| | | soccerCountries.setCode(SoccerResponseUtil.objectToStr(jsonObject.get("name"))); |
| | |
| | | JSONObject parseObjLeague = JSONUtil.parseObj(leagueObj); |
| | | JSONObject leagueStr = JSONUtil.parseObj(parseObjLeague); |
| | | |
| | | Integer leaguesId = SoccerResponseUtil.objectToInteger(leagueStr.get("id")); |
| | | List<SoccerLeagues> soccerLeaguesList = soccerLeaguesMapper.selectList(new QueryWrapper<SoccerLeagues>().eq("leagues_id", leaguesId)); |
| | | if(CollUtil.isNotEmpty(soccerLeaguesList)){ |
| | | continue; |
| | | } |
| | | SoccerLeagues soccerLeagues = new SoccerLeagues(); |
| | | soccerLeagues.setLeaguesId(SoccerResponseUtil.objectToInteger(leagueStr.get("id"))); |
| | | soccerLeagues.setLeaguesName(SoccerResponseUtil.objectToStr(leagueStr.get("name"))); |
| | |
| | | soccerLeaguesMapper.insert(soccerLeagues); |
| | | } |
| | | } |
| | | System.out.println(jsonArray); |
| | | log.info(String.valueOf(response.getRawBody())); |
| | | return new FebsResponse().success(); |
| | | } |
| | | } |