| | |
| | | import cc.mrbird.febs.common.entity.FebsResponse; |
| | | import cc.mrbird.febs.dapp.dto.*; |
| | | import cc.mrbird.febs.dapp.entity.DappMemberEntity; |
| | | import cc.mrbird.febs.dapp.entity.MallNewsInfo; |
| | | import cc.mrbird.febs.dapp.service.DappMemberService; |
| | | 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.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.date.DateUtil; |
| | | import cn.hutool.core.util.ObjectUtil; |
| | | import com.mashape.unirest.http.HttpResponse; |
| | | import com.mashape.unirest.http.Unirest; |
| | | import com.mashape.unirest.http.exceptions.UnirestException; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import io.swagger.annotations.ApiResponse; |
| | | import io.swagger.annotations.ApiResponses; |
| | | import lombok.RequiredArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.jline.utils.Log; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | |
| | | public class ApiCommonController { |
| | | |
| | | private final DappMemberService dappMemberService; |
| | | private final IMallNewsInfoService newsService; |
| | | |
| | | @ApiOperation(value = "地址是否存在", notes = "地址是否存在") |
| | | @GetMapping(value = "/exist/{address}") |
| | |
| | | public FebsResponse connect(@RequestBody ConnectDto connectDto) { |
| | | dappMemberService.connect(connectDto); |
| | | return new FebsResponse().success(); |
| | | } |
| | | |
| | | @ApiOperation(value = "首页轮播图", notes = "首页轮播图") |
| | | @GetMapping(value = "/bannerList") |
| | | public FebsResponse findPlatformBannerList() { |
| | | return dappMemberService.findAllBanner(); |
| | | } |
| | | |
| | | @ApiOperation(value = "商品列表", notes = "商品列表") |
| | |
| | | return new FebsResponse().success().data(dappMemberService.findGoodsDetailsById(id)); |
| | | } |
| | | |
| | | @ApiOperation(value = "新闻分类", notes = "新闻分类") |
| | | @GetMapping(value = "/findNewsInfoCategory") |
| | | public FebsResponse findNewsInfoCategory() { |
| | | return new FebsResponse().success().data(newsService.findNewsCategoryList()); |
| | | } |
| | | |
| | | @ApiOperation(value ="获取新闻列表-分页", notes = "获取新闻列表") |
| | | @ApiResponses({ |
| | | @ApiResponse(code = 200, message = "success", response = NewsListVo.class) |
| | | }) |
| | | @PostMapping(value = "/findNewsInPage") |
| | | public FebsResponse findNewsInPage(@RequestBody NewsListDto newsListDto) { |
| | | return new FebsResponse().success().data(newsService.findNewsInPage(newsListDto)); |
| | | } |
| | | |
| | | @ApiOperation(value = "新闻列表", notes = "新闻列表") |
| | | @ApiResponses({ |
| | | @ApiResponse(code = 200, message = "success", response = NewsListVo.class) |
| | | }) |
| | | @GetMapping(value = "/findNews") |
| | | public FebsResponse findNews() { |
| | | return new FebsResponse().success().data(newsService.findTopNews()); |
| | | } |
| | | |
| | | @ApiOperation(value = "新闻详情", notes = "新闻详情") |
| | | @GetMapping(value = "/newsDetails/{id}") |
| | | public FebsResponse newsDetails(@PathVariable("id") Long id) { |
| | | MallNewsInfo news = newsService.getById(id); |
| | | if (news == null) { |
| | | return new FebsResponse().fail().message("新闻不存在"); |
| | | } |
| | | return new FebsResponse().success().data(news); |
| | | } |
| | | |
| | | @ApiOperation(value = "获取国家", notes = "获取国家") |
| | | @GetMapping(value = "/testApi") |
| | | public FebsResponse testApi() { |
| | | HttpResponse<String> response = null; |
| | | try { |
| | | response = Unirest.get("http://v3.football.api-sports.io/countries") |
| | | .header("x-rapidapi-key", "87f8d87d629d1704ba49622cb978eb81") |
| | | .header("x-rapidapi-host", "v3.football.api-sports.io").asString(); |
| | | } catch (UnirestException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | 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()); |
| | | log.info(String.valueOf(response.getRawBody())); |
| | | return new FebsResponse().success(); |
| | | } |
| | | |
| | | |
| | | // @ApiOperation(value = "头部数据", notes = "头部数据") |
| | | // @GetMapping(value = "/totalIncome") |