|
@@ -1,6 +1,8 @@
|
|
|
package com.ruoyi.web.controller.visual;
|
|
|
|
|
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import com.ruoyi.system.domain.*;
|
|
|
import com.ruoyi.common.core.domain.Result;
|
|
|
import com.ruoyi.system.dto.VisitingWebsiteRankingDTO;
|
|
@@ -8,12 +10,21 @@ import com.ruoyi.system.dto.WebSiteTenDaysHitsDTO;
|
|
|
import com.ruoyi.system.service.*;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.http.HttpEntity;
|
|
|
+import org.springframework.http.HttpHeaders;
|
|
|
+import org.springframework.http.MediaType;
|
|
|
+import org.springframework.http.ResponseEntity;
|
|
|
+import org.springframework.scheduling.annotation.Scheduled;
|
|
|
+import org.springframework.stereotype.Component;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
+import org.springframework.http.*;
|
|
|
+import org.springframework.web.client.RestTemplate;
|
|
|
+
|
|
|
|
|
|
import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
|
|
|
@Slf4j
|
|
|
+@Component
|
|
|
@RestController
|
|
|
@RequestMapping("/api/webSite/")
|
|
|
public class VisualController {
|
|
@@ -54,15 +65,20 @@ public class VisualController {
|
|
|
private IAreaInteractiveColumnsService areaInteractiveColumnsService;
|
|
|
@Autowired
|
|
|
private ICountyInteractiveColumnsService countyInteractiveColumnsService;
|
|
|
-
|
|
|
+ @Autowired
|
|
|
+ private RestTemplate restTemplate;
|
|
|
+ private final String postUrl = "http://175.22.1.26:8080";
|
|
|
+ private final String authorization = "Bearer ";
|
|
|
|
|
|
/**
|
|
|
* 网站可用性实时监测-数据推送接口
|
|
|
*/
|
|
|
- @PostMapping("putWebsiteAvailabilityMonitor")
|
|
|
- @ResponseBody
|
|
|
- public Result<?> insertBatchWebsiteAvailabilityMonitor(@RequestBody List<WebsiteAvailabilityMonitor> list) {
|
|
|
- log.info("网站可用性实时监测:{}",list);
|
|
|
+ @Scheduled(cron = "0/10 * * * * ?")
|
|
|
+ public Result<?> insertBatchWebsiteAvailabilityMonitor() {
|
|
|
+ log.info("网站可用性实时监测执行,时间:" + System.currentTimeMillis());
|
|
|
+ String token = getToken();
|
|
|
+ JSONObject jsonObject = getDatasource("/api/webSite/putWebsiteAvailabilityMonitor", token);
|
|
|
+ List<WebsiteAvailabilityMonitor> list = JSON.parseArray(jsonObject.get("data").toString(), WebsiteAvailabilityMonitor.class);
|
|
|
websiteAvailabilityMonitorService.insertBatch(list);
|
|
|
return Result.ok();
|
|
|
}
|
|
@@ -70,10 +86,12 @@ public class VisualController {
|
|
|
/**
|
|
|
* 本日无法访问网站列表-数据推送接口
|
|
|
*/
|
|
|
- @PostMapping("putUnableToAccessWebsiteListToday")
|
|
|
- @ResponseBody
|
|
|
- public Result<?> insertBatchUnableToAccessWebsiteListToday(@RequestBody List<UnableToAccessWebsiteListToday> list) {
|
|
|
- log.info("本日无法访问网站列表:{}",list);
|
|
|
+ @Scheduled(cron = "0/10 * * * * ?")
|
|
|
+ public Result<?> insertBatchUnableToAccessWebsiteListToday() {
|
|
|
+ log.info("本日无法访问网站列表,时间:" + System.currentTimeMillis());
|
|
|
+ String token = getToken();
|
|
|
+ JSONObject jsonObject = getDatasource("/api/webSite/putUnableToAccessWebsiteListToday", token);
|
|
|
+ List<UnableToAccessWebsiteListToday> list = JSON.parseArray(jsonObject.get("data").toString(), UnableToAccessWebsiteListToday.class);
|
|
|
unableToAccessWebsiteListTodayService.insertBatch(list);
|
|
|
return Result.ok();
|
|
|
}
|
|
@@ -81,32 +99,38 @@ public class VisualController {
|
|
|
/**
|
|
|
* 市政府网站十日内点击量-数据推送接口
|
|
|
*/
|
|
|
- @PostMapping("putWebSiteTenDaysHits")
|
|
|
- @ResponseBody
|
|
|
- public Result<?> insertBatchWebSiteTenDaysHits(@RequestBody WebSiteTenDaysHitsDTO dto) {
|
|
|
- log.info("市政府网站十日内点击量:{}",dto);
|
|
|
- webSiteTenDaysHitsService.insertBatch(dto);
|
|
|
+ @Scheduled(cron = "0/10 * * * * ?")
|
|
|
+ public Result<?> insertBatchWebSiteTenDaysHits() {
|
|
|
+ log.info("市政府网站十日内点击量:" + System.currentTimeMillis());
|
|
|
+ String token = getToken();
|
|
|
+ JSONObject jsonObject = getDatasource("/api/webSite/putWebSiteTenDaysHits", token);
|
|
|
+ List<WebSiteTenDaysHitsDTO> list = JSON.parseArray(jsonObject.get("data").toString(), WebSiteTenDaysHitsDTO.class);
|
|
|
+ webSiteTenDaysHitsService.insertBatch(list.get(0));
|
|
|
return Result.ok();
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 市政府门户网站访问情况监测-全国各省访问吉林市政府网站排名-数据推送接口
|
|
|
*/
|
|
|
- @PostMapping("putVisitingWebsiteRanking")
|
|
|
- @ResponseBody
|
|
|
- public Result<?> insertBatchVisitingWebsiteRanking(@RequestBody VisitingWebsiteRankingDTO dto) {
|
|
|
- log.info("全国各省访问吉林市政府网站排名:{}",dto);
|
|
|
- visitingWebsiteRankingService.insertBatch(dto);
|
|
|
+ @Scheduled(cron = "0/10 * * * * ?")
|
|
|
+ public Result<?> insertBatchVisitingWebsiteRanking() {
|
|
|
+ log.info("全国各省访问吉林市政府网站排名:" + System.currentTimeMillis());
|
|
|
+ String token = getToken();
|
|
|
+ JSONObject jsonObject = getDatasource("/api/webSite/putVisitingWebsiteRanking", token);
|
|
|
+ List<VisitingWebsiteRankingDTO> list = JSON.parseArray(jsonObject.get("data").toString(), VisitingWebsiteRankingDTO.class);
|
|
|
+ visitingWebsiteRankingService.insertBatch(list.get(0));
|
|
|
return Result.ok();
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 市政府门户网站访问情况监测-门户网站栏目浏览量排名-数据推送接口
|
|
|
*/
|
|
|
- @PostMapping("putColumnPageView")
|
|
|
- @ResponseBody
|
|
|
- public Result<?> insertColumnPageView(@RequestBody List<ColumnPageView> list) {
|
|
|
- log.info("门户网站栏目浏览量排名:{}",list);
|
|
|
+ @Scheduled(cron = "0/10 * * * * ?")
|
|
|
+ public Result<?> insertColumnPageView() {
|
|
|
+ log.info("门户网站栏目浏览量排名:" + System.currentTimeMillis());
|
|
|
+ String token = getToken();
|
|
|
+ JSONObject jsonObject = getDatasource("/api/webSite/putColumnPageView", token);
|
|
|
+ List<ColumnPageView> list = JSON.parseArray(jsonObject.get("data").toString(), ColumnPageView.class);
|
|
|
columnPageViewService.insertBatch(list);
|
|
|
return Result.ok();
|
|
|
}
|
|
@@ -114,10 +138,12 @@ public class VisualController {
|
|
|
/**
|
|
|
* 市政府门户网站访问情况监测-每日最受欢迎信息排名-数据推送接口
|
|
|
*/
|
|
|
- @PostMapping("putPopularInformation")
|
|
|
- @ResponseBody
|
|
|
- public Result<?> insertPopularInformation(@RequestBody List<PopularInformation> list) {
|
|
|
- log.info("每日最受欢迎信息排名:{}",list);
|
|
|
+ @Scheduled(cron = "0/10 * * * * ?")
|
|
|
+ public Result<?> insertPopularInformation() {
|
|
|
+ log.info("每日最受欢迎信息排名:" + System.currentTimeMillis());
|
|
|
+ String token = getToken();
|
|
|
+ JSONObject jsonObject = getDatasource("/api/webSite/putPopularInformation", token);
|
|
|
+ List<PopularInformation> list = JSON.parseArray(jsonObject.get("data").toString(), PopularInformation.class);
|
|
|
popularInformationService.insertBatch(list);
|
|
|
return Result.ok();
|
|
|
}
|
|
@@ -125,10 +151,12 @@ public class VisualController {
|
|
|
/**
|
|
|
* 市政府门户网站错别字监测-市政府工作部门-数据推送接口
|
|
|
*/
|
|
|
- @PostMapping("putMunicipalMisprint")
|
|
|
- @ResponseBody
|
|
|
- public Result<?> insertMunicipalMisprint(@RequestBody List<MunicipalMisprint> list) {
|
|
|
- log.info("市政府门户网站错别字监测-市政府工作部门:{}",list);
|
|
|
+ @Scheduled(cron = "0/10 * * * * ?")
|
|
|
+ public Result<?> insertMunicipalMisprint() {
|
|
|
+ log.info("市政府门户网站错别字监测-市政府工作部门:" + System.currentTimeMillis());
|
|
|
+ String token = getToken();
|
|
|
+ JSONObject jsonObject = getDatasource("/api/webSite/putMunicipalMisprint", token);
|
|
|
+ List<MunicipalMisprint> list = JSON.parseArray(jsonObject.get("data").toString(), MunicipalMisprint.class);
|
|
|
municipalMisprintService.insertBatch(list);
|
|
|
return Result.ok();
|
|
|
}
|
|
@@ -136,10 +164,12 @@ public class VisualController {
|
|
|
/**
|
|
|
* 市政府门户网站错别字监测-县(市)区政府-数据推送接口
|
|
|
*/
|
|
|
- @PostMapping("putCountyAndDistrictMisprint")
|
|
|
- @ResponseBody
|
|
|
- public Result<?> insertCountyAndDistrictMisprint(@RequestBody List<CountyAndDistrictMisprint> list) {
|
|
|
- log.info("市政府门户网站错别字监测-县(市)区政府:{}",list);
|
|
|
+ @Scheduled(cron = "0/10 * * * * ?")
|
|
|
+ public Result<?> insertCountyAndDistrictMisprint() {
|
|
|
+ log.info("市政府门户网站错别字监测-县(市)区政府:" + System.currentTimeMillis());
|
|
|
+ String token = getToken();
|
|
|
+ JSONObject jsonObject = getDatasource("/api/webSite/putCountyAndDistrictMisprint", token);
|
|
|
+ List<CountyAndDistrictMisprint> list = JSON.parseArray(jsonObject.get("data").toString(), CountyAndDistrictMisprint.class);
|
|
|
countyAndDistrictMisprintService.insertBatch(list);
|
|
|
return Result.ok();
|
|
|
}
|
|
@@ -147,10 +177,12 @@ public class VisualController {
|
|
|
/**
|
|
|
* 市政府门户网站错误链接监测-市政府门户网站错误链接监测-数据推送接口
|
|
|
*/
|
|
|
- @PostMapping("putMunicipalErrorLinkMonitor")
|
|
|
- @ResponseBody
|
|
|
- public Result<?> insertMunicipalErrorLinkMonitor(@RequestBody List<MunicipalErrorLinkMonitor> list) {
|
|
|
- log.info("市政府门户网站错误链接监测-市政府门户网站错误链接监测:{}",list);
|
|
|
+ @Scheduled(cron = "0/10 * * * * ?")
|
|
|
+ public Result<?> insertMunicipalErrorLinkMonitor() {
|
|
|
+ log.info("市政府门户网站错误链接监测-市政府门户网站错误链接监测:" + System.currentTimeMillis());
|
|
|
+ String token = getToken();
|
|
|
+ JSONObject jsonObject = getDatasource("/api/webSite/putMunicipalErrorLinkMonitor", token);
|
|
|
+ List<MunicipalErrorLinkMonitor> list = JSON.parseArray(jsonObject.get("data").toString(), MunicipalErrorLinkMonitor.class);
|
|
|
municipalErrorLinkMonitorService.insertBatch(list);
|
|
|
return Result.ok();
|
|
|
}
|
|
@@ -158,10 +190,12 @@ public class VisualController {
|
|
|
/**
|
|
|
* 网站普查指标监测-网站普查要素-数据推送接口
|
|
|
*/
|
|
|
- @PostMapping("putCensusElements")
|
|
|
- @ResponseBody
|
|
|
- public Result<?> insertCensusElements(@RequestBody List<CensusElements> list) {
|
|
|
- log.info("网站普查指标监测-网站普查要素:{}",list);
|
|
|
+ @Scheduled(cron = "0/10 * * * * ?")
|
|
|
+ public Result<?> insertCensusElements() {
|
|
|
+ log.info("网站普查指标监测-网站普查要素:" + System.currentTimeMillis());
|
|
|
+ String token = getToken();
|
|
|
+ JSONObject jsonObject = getDatasource("/api/webSite/putCensusElements", token);
|
|
|
+ List<CensusElements> list = JSON.parseArray(jsonObject.get("data").toString(), CensusElements.class);
|
|
|
censusElementsService.insertBatch(list);
|
|
|
return Result.ok();
|
|
|
}
|
|
@@ -169,10 +203,12 @@ public class VisualController {
|
|
|
/**
|
|
|
* 网站普查指标监测-网站普查单项否信息-数据推送接口
|
|
|
*/
|
|
|
- @PostMapping("putCensusItemNegativeInformation")
|
|
|
- @ResponseBody
|
|
|
- public Result<?> insertCensusItemNegativeInformation(@RequestBody List<CensusItemNegativeInformation> list) {
|
|
|
- log.info("网站普查指标监测-网站普查单项否信息:{}",list);
|
|
|
+ @Scheduled(cron = "0/10 * * * * ?")
|
|
|
+ public Result<?> insertCensusItemNegativeInformation() {
|
|
|
+ log.info("网站普查指标监测-网站普查单项否信息:" + System.currentTimeMillis());
|
|
|
+ String token = getToken();
|
|
|
+ JSONObject jsonObject = getDatasource("/api/webSite/putCensusItemNegativeInformation", token);
|
|
|
+ List<CensusItemNegativeInformation> list = JSON.parseArray(jsonObject.get("data").toString(), CensusItemNegativeInformation.class);
|
|
|
censusItemNegativeInformationService.insertBatch(list);
|
|
|
return Result.ok();
|
|
|
}
|
|
@@ -180,10 +216,12 @@ public class VisualController {
|
|
|
/**
|
|
|
* 市直部门日更新访问量排名-市直部门日访问量排名-数据推送接口
|
|
|
*/
|
|
|
- @PostMapping("putDailyTrafficRanking")
|
|
|
- @ResponseBody
|
|
|
- public Result<?> insertDailyTrafficRanking(@RequestBody List<DailyTrafficRanking> list) {
|
|
|
- log.info("市直部门日更新访问量排名-市直部门日访问量排名:{}",list);
|
|
|
+ @Scheduled(cron = "0/10 * * * * ?")
|
|
|
+ public Result<?> insertDailyTrafficRanking() {
|
|
|
+ log.info("市直部门日更新访问量排名-市直部门日访问量排名:" + System.currentTimeMillis());
|
|
|
+ String token = getToken();
|
|
|
+ JSONObject jsonObject = getDatasource("/api/webSite/putDailyTrafficRanking", token);
|
|
|
+ List<DailyTrafficRanking> list = JSON.parseArray(jsonObject.get("data").toString(), DailyTrafficRanking.class);
|
|
|
dailyTrafficRankingService.insertBatch(list);
|
|
|
return Result.ok();
|
|
|
}
|
|
@@ -191,10 +229,12 @@ public class VisualController {
|
|
|
/**
|
|
|
* 市直部门日更新访问量排名-市直部门日更新量排名-数据推送接口
|
|
|
*/
|
|
|
- @PostMapping("putDailyUpdateRanking")
|
|
|
- @ResponseBody
|
|
|
- public Result<?> insertDailyUpdateRanking(@RequestBody List<DailyUpdateRanking> list) {
|
|
|
- log.info("市直部门日更新访问量排名-市直部门日更新量排名:{}",list);
|
|
|
+ @Scheduled(cron = "0/10 * * * * ?")
|
|
|
+ public Result<?> insertDailyUpdateRanking() {
|
|
|
+ log.info("市直部门日更新访问量排名-市直部门日更新量排名:" + System.currentTimeMillis());
|
|
|
+ String token = getToken();
|
|
|
+ JSONObject jsonObject = getDatasource("/api/webSite/putDailyUpdateRanking", token);
|
|
|
+ List<DailyUpdateRanking> list = JSON.parseArray(jsonObject.get("data").toString(), DailyUpdateRanking.class);
|
|
|
dailyUpdateRankingService.insertBatch(list);
|
|
|
return Result.ok();
|
|
|
}
|
|
@@ -202,10 +242,12 @@ public class VisualController {
|
|
|
/**
|
|
|
* 县(市)区政府日更新访问量排名-县(市)区政府日访问量排名-数据推送接口
|
|
|
*/
|
|
|
- @PostMapping("putCountyDailyTrafficRanking")
|
|
|
- @ResponseBody
|
|
|
- public Result<?> insertCountyDailyTrafficRanking(@RequestBody List<CountyDailyTrafficRanking> list) {
|
|
|
- log.info("县(市)区政府日更新访问量排名-县(市)区政府日访问量排名:{}",list);
|
|
|
+ @Scheduled(cron = "0/10 * * * * ?")
|
|
|
+ public Result<?> insertCountyDailyTrafficRanking() {
|
|
|
+ log.info("县(市)区政府日更新访问量排名-县(市)区政府日访问量排名:" + System.currentTimeMillis());
|
|
|
+ String token = getToken();
|
|
|
+ JSONObject jsonObject = getDatasource("/api/webSite/putCountyDailyTrafficRanking", token);
|
|
|
+ List<CountyDailyTrafficRanking> list = JSON.parseArray(jsonObject.get("data").toString(), CountyDailyTrafficRanking.class);
|
|
|
countyDailyTrafficRankingService.insertBatch(list);
|
|
|
return Result.ok();
|
|
|
}
|
|
@@ -213,10 +255,12 @@ public class VisualController {
|
|
|
/**
|
|
|
* 县(市)区政府日更新访问量排名 - 县(市)区政府日更新量排名-数据推送接口
|
|
|
*/
|
|
|
- @PostMapping("putCountyDailyUpdateRanking")
|
|
|
- @ResponseBody
|
|
|
- public Result<?> insertCountyDailyUpdateRanking(@RequestBody List<CountyDailyUpdateRanking> list) {
|
|
|
- log.info("县(市)区政府日更新访问量排名 - 县(市)区政府日更新量排名:{}",list);
|
|
|
+ @Scheduled(cron = "0/10 * * * * ?")
|
|
|
+ public Result<?> insertCountyDailyUpdateRanking() {
|
|
|
+ log.info("县(市)区政府日更新访问量排名 - 县(市)区政府日更新量排名:" + System.currentTimeMillis());
|
|
|
+ String token = getToken();
|
|
|
+ JSONObject jsonObject = getDatasource("/api/webSite/putCountyDailyUpdateRanking", token);
|
|
|
+ List<CountyDailyUpdateRanking> list = JSON.parseArray(jsonObject.get("data").toString(), CountyDailyUpdateRanking.class);
|
|
|
countyDailyUpdateRankingService.insertBatch(list);
|
|
|
return Result.ok();
|
|
|
}
|
|
@@ -224,10 +268,12 @@ public class VisualController {
|
|
|
/**
|
|
|
* 市政府网站群互动类栏目更新情况-市直部门-数据推送接口
|
|
|
*/
|
|
|
- @PostMapping("putMunicipalInteractiveColumns")
|
|
|
- @ResponseBody
|
|
|
- public Result<?> insertMunicipalInteractiveColumns(@RequestBody List<MunicipalInteractiveColumns> list) {
|
|
|
- log.info("市政府网站群互动类栏目更新情况-市直部门:{}",list);
|
|
|
+ @Scheduled(cron = "0/5 * * * * ?")
|
|
|
+ public Result<?> insertMunicipalInteractiveColumns() {
|
|
|
+ log.info("市政府网站群互动类栏目更新情况-市直部门:" + System.currentTimeMillis());
|
|
|
+ String token = getToken();
|
|
|
+ JSONObject jsonObject = getDatasource("/api/webSite/putMunicipalInteractiveColumns", token);
|
|
|
+ List<MunicipalInteractiveColumns> list = JSON.parseArray(jsonObject.get("data").toString(), MunicipalInteractiveColumns.class);
|
|
|
municipalInteractiveColumnsService.insertBatch(list);
|
|
|
return Result.ok();
|
|
|
}
|
|
@@ -235,10 +281,12 @@ public class VisualController {
|
|
|
/**
|
|
|
* 市政府网站群互动类栏目更新情况-区、开发区-数据推送接口
|
|
|
*/
|
|
|
- @PostMapping("putAreaInteractiveColumns")
|
|
|
- @ResponseBody
|
|
|
- public Result<?> insertAreaInteractiveColumns(@RequestBody List<AreaInteractiveColumns> list) {
|
|
|
- log.info("市政府网站群互动类栏目更新情况-区、开发区:{}",list);
|
|
|
+ @Scheduled(cron = "0/10 * * * * ?")
|
|
|
+ public Result<?> insertAreaInteractiveColumns() {
|
|
|
+ log.info("市政府网站群互动类栏目更新情况-区、开发区:" + System.currentTimeMillis());
|
|
|
+ String token = getToken();
|
|
|
+ JSONObject jsonObject = getDatasource("/api/webSite/putAreaInteractiveColumns", token);
|
|
|
+ List<AreaInteractiveColumns> list = JSON.parseArray(jsonObject.get("data").toString(), AreaInteractiveColumns.class);
|
|
|
areaInteractiveColumnsService.insertBatch(list);
|
|
|
return Result.ok();
|
|
|
}
|
|
@@ -246,13 +294,77 @@ public class VisualController {
|
|
|
/**
|
|
|
* 市政府网站群互动类栏目更新情况告警展示-县(市)-数据推送接口
|
|
|
*/
|
|
|
- @PostMapping("putCountyInteractiveColumns")
|
|
|
- @ResponseBody
|
|
|
- public Result<?> insertCountyInteractiveColumns(@RequestBody List<CountyInteractiveColumns> list) {
|
|
|
- log.info("市政府网站群互动类栏目更新情况告警展示-县(市):{}",list);
|
|
|
+ @Scheduled(cron = "0/15 * * * * ?")
|
|
|
+ public Result<?> insertCountyInteractiveColumns() {
|
|
|
+ log.info("市政府网站群互动类栏目更新情况告警展示-县(市):" + System.currentTimeMillis());
|
|
|
+ String token = getToken();
|
|
|
+ JSONObject jsonObject = getDatasource("/api/webSite/putCountyInteractiveColumns", token);
|
|
|
+ List<CountyInteractiveColumns> list = JSON.parseArray(jsonObject.get("data").toString(), CountyInteractiveColumns.class);
|
|
|
countyInteractiveColumnsService.insertBatch(list);
|
|
|
return Result.ok();
|
|
|
}
|
|
|
|
|
|
|
|
|
+ // 获取 Token
|
|
|
+ public String getToken() {
|
|
|
+ // 请求 URL
|
|
|
+ String url = postUrl + "/auth/getToken";
|
|
|
+ // 请求头
|
|
|
+ HttpHeaders headers = new HttpHeaders();
|
|
|
+ headers.set("Accept", "*/*");
|
|
|
+ headers.set("Accept-Encoding", "gzip, deflate, br");
|
|
|
+ headers.set("User-Agent", "PostmanRuntime-ApipostRuntime/1.1.0");
|
|
|
+ headers.set("Connection", "keep-alive");
|
|
|
+ headers.setContentType(MediaType.APPLICATION_JSON);
|
|
|
+ // 请求体(JSON)
|
|
|
+ String requestBody = "{\"username\": \"admin\", \"password\": \"admin\"}";
|
|
|
+ // 封装请求实体
|
|
|
+ HttpEntity<String> requestEntity = new HttpEntity<>(requestBody, headers);
|
|
|
+ try {
|
|
|
+ // 发送 POST 请求
|
|
|
+ ResponseEntity<String> response = restTemplate.exchange(
|
|
|
+ url,
|
|
|
+ HttpMethod.POST,
|
|
|
+ requestEntity,
|
|
|
+ String.class
|
|
|
+ );
|
|
|
+ JSONObject json = JSONObject.parseObject(response.getBody());
|
|
|
+ return json.get("data").toString();
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("获取 Token 失败: {}", e.getMessage());
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ // 获取 Token
|
|
|
+ public JSONObject getDatasource(String getUrl,String token) {
|
|
|
+ // 请求 URL
|
|
|
+ String url = postUrl + getUrl;
|
|
|
+ // 请求头
|
|
|
+ HttpHeaders headers = new HttpHeaders();
|
|
|
+ headers.set("Accept", "*/*");
|
|
|
+ headers.set("Accept-Encoding", "gzip, deflate, br");
|
|
|
+ headers.set("User-Agent", "PostmanRuntime-ApipostRuntime/1.1.0");
|
|
|
+ headers.set("Connection", "keep-alive");
|
|
|
+ headers.set("Authori-Zation",authorization + token);
|
|
|
+ // 封装请求实体
|
|
|
+ HttpEntity<String> requestEntity = new HttpEntity<>(null, headers);
|
|
|
+ try {
|
|
|
+ // 发送 POST 请求
|
|
|
+ ResponseEntity<String> response = restTemplate.exchange(
|
|
|
+ url,
|
|
|
+ HttpMethod.POST,
|
|
|
+ requestEntity,
|
|
|
+ String.class
|
|
|
+ );
|
|
|
+ return JSONObject.parseObject(response.getBody());
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("请求这个接口 " + getUrl + " 失败: {}", e.getMessage());
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|