平台管理 - 接口插件 - 新增HTTP接口:
/plugin/api/report/refresh
报表列表接口脚本
load("nashorn:mozilla_compat.js");
importPackage(java.lang);
importPackage(org.apache.commons.lang3.time);
importPackage(org.apache.commons.lang3);
importPackage(com.alibaba.fastjson);
var reportService = beanService.getBean("reportServiceImpl");
var reportDao = beanService.getBean("reportDaoImpl");
var userDao = beanService.getBean("userDaoImpl");
var userService = beanService.getBean("userServiceImpl");
try{
var reportId = request.getParameter("reportId");
var report = reportDao.findById(reportId);
if(report == null) {
throw new Exception("没有找到报表");
}
var reportOwner = userDao.findById(report.getAppId());
userService.userLoginWithUser(reportOwner);
reportService.refreshMetadata(reportId);
result.setSuccess(true);
}catch(e){
result.setSuccess(false);
result.setMessage(e.message);
} finally {
var securityService = beanService.getBean("amsSecurityService");
securityService.logout();
}
接口访问地址
http://x.x.x.x:端口/plugin/api/report/refresh.do?reportId=xxxxxx
接口授权
注意: /plugin/** 路径是公开访问路径,因此需要配合token来验证接口调用的合法性
