mirror of
https://github.com/jeecgboot/JimuReport.git
synced 2025-10-14 23:00:24 +00:00
🚀 革命性升级!JimuReport 积木报表 v2.1.0 版本震撼发布
This commit is contained in:
@@ -10,6 +10,6 @@ WORKDIR /jimureport
|
|||||||
|
|
||||||
EXPOSE 8085
|
EXPOSE 8085
|
||||||
|
|
||||||
ADD ./target/jimureport-example-2.0.jar ./
|
ADD ./target/jimureport-example-2.1.jar ./
|
||||||
|
|
||||||
CMD java -DMYSQL-HOST=jimureport-mysql -Dfile.encoding=utf-8 -Djava.security.egd=file:/dev/./urandom -jar jimureport-example-2.0.jar
|
CMD java -DMYSQL-HOST=jimureport-mysql -Dfile.encoding=utf-8 -Djava.security.egd=file:/dev/./urandom -jar jimureport-example-2.1.jar
|
@@ -12,7 +12,7 @@
|
|||||||
<name>jimureport-example</name>
|
<name>jimureport-example</name>
|
||||||
<groupId>org.jeecg</groupId>
|
<groupId>org.jeecg</groupId>
|
||||||
<artifactId>jimureport-example</artifactId>
|
<artifactId>jimureport-example</artifactId>
|
||||||
<version>2.0</version>
|
<version>2.1</version>
|
||||||
|
|
||||||
<url>http://www.jimureport.com</url>
|
<url>http://www.jimureport.com</url>
|
||||||
<description>积木报表集成示例</description>
|
<description>积木报表集成示例</description>
|
||||||
|
@@ -11,14 +11,19 @@ import org.springframework.core.env.Environment;
|
|||||||
* 积木报表独立服务启动类
|
* 积木报表独立服务启动类
|
||||||
*/
|
*/
|
||||||
@SpringBootApplication(scanBasePackages = {"org.jeecg", "com.jeecg"})
|
@SpringBootApplication(scanBasePackages = {"org.jeecg", "com.jeecg"})
|
||||||
@EnableAutoConfiguration(exclude = {MongoAutoConfiguration.class})
|
@EnableAutoConfiguration(exclude={MongoAutoConfiguration.class})
|
||||||
public class JimuReportApplication {
|
public class JimuReportApplication {
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
ConfigurableApplicationContext application = SpringApplication.run(JimuReportApplication.class, args);
|
ConfigurableApplicationContext application = SpringApplication.run(JimuReportApplication.class, args);
|
||||||
Environment env = application.getEnvironment();
|
Environment env = application.getEnvironment();
|
||||||
String port = env.getProperty("server.port");
|
String port = env.getProperty("server.port");
|
||||||
String path = env.containsProperty("server.servlet.context-path") ? env.getProperty("server.servlet.context-path") : "";
|
String path = env.containsProperty("server.servlet.context-path")?env.getProperty("server.servlet.context-path"):"";
|
||||||
|
String currentEncoding = System.getProperty("file.encoding", "UTF-8");
|
||||||
|
if(!currentEncoding.equalsIgnoreCase("UTF-8")){
|
||||||
|
// 默认编码不是UTF-8设置为UTF-8
|
||||||
|
System.setProperty("file.encoding", "UTF-8");
|
||||||
|
}
|
||||||
System.out.println("\n----------------------------------------------------------\n\t" +
|
System.out.println("\n----------------------------------------------------------\n\t" +
|
||||||
"JimuReport 积木报表平台 is running! Access URL:\n\t" +
|
"JimuReport 积木报表平台 is running! Access URL:\n\t" +
|
||||||
"报表工作台: \t\thttp://localhost:" + port + path + "/jmreport/list\n\t" +
|
"报表工作台: \t\thttp://localhost:" + port + path + "/jmreport/list\n\t" +
|
||||||
|
@@ -21,9 +21,9 @@ public class ApiSecurityConfigFilter implements Filter {
|
|||||||
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
|
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
|
||||||
HttpServletRequest req = (HttpServletRequest) request;
|
HttpServletRequest req = (HttpServletRequest) request;
|
||||||
String loginFrom = req.getHeader("jm_login_from");
|
String loginFrom = req.getHeader("jm_login_from");
|
||||||
if(OkConvertUtils.isNotEmpty(loginFrom)){
|
if(null != loginFrom && !loginFrom.isEmpty()){
|
||||||
String springSecurityContext = req.getHeader("jm_spring_security_context");
|
String springSecurityContext = req.getHeader("jm_spring_security_context");
|
||||||
if(OkConvertUtils.isNotEmpty(springSecurityContext)){
|
if(null != springSecurityContext && !springSecurityContext.isEmpty()){
|
||||||
SecurityContextImpl securityContext = JSONObject.parseObject(springSecurityContext, SecurityContextImpl.class);
|
SecurityContextImpl securityContext = JSONObject.parseObject(springSecurityContext, SecurityContextImpl.class);
|
||||||
HttpSession session = req.getSession();
|
HttpSession session = req.getSession();
|
||||||
session.setAttribute("loginFrom", loginFrom);
|
session.setAttribute("loginFrom", loginFrom);
|
||||||
|
@@ -1,13 +1,17 @@
|
|||||||
package com.jeecg.modules.jmreport.config;
|
package com.jeecg.modules.jmreport.config;
|
||||||
|
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.security.core.Authentication;
|
import org.springframework.security.core.Authentication;
|
||||||
import org.springframework.security.web.authentication.SavedRequestAwareAuthenticationSuccessHandler;
|
import org.springframework.security.web.authentication.SavedRequestAwareAuthenticationSuccessHandler;
|
||||||
|
import org.springframework.security.web.savedrequest.SavedRequest;
|
||||||
|
|
||||||
import javax.servlet.ServletException;
|
import javax.servlet.ServletException;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import javax.servlet.http.HttpSession;
|
import javax.servlet.http.HttpSession;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.net.URI;
|
||||||
|
import java.net.URISyntaxException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 自定义springsecurity登录成功处理
|
* 自定义springsecurity登录成功处理
|
||||||
@@ -15,6 +19,7 @@ import java.io.IOException;
|
|||||||
* @author chenrui
|
* @author chenrui
|
||||||
* @date 2024/8/2 16:26
|
* @date 2024/8/2 16:26
|
||||||
*/
|
*/
|
||||||
|
@Slf4j
|
||||||
public class CustomLoginSuccessHandler extends SavedRequestAwareAuthenticationSuccessHandler {
|
public class CustomLoginSuccessHandler extends SavedRequestAwareAuthenticationSuccessHandler {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -22,6 +27,27 @@ public class CustomLoginSuccessHandler extends SavedRequestAwareAuthenticationSu
|
|||||||
Authentication authentication) throws IOException, ServletException {
|
Authentication authentication) throws IOException, ServletException {
|
||||||
HttpSession session = request.getSession();
|
HttpSession session = request.getSession();
|
||||||
session.setAttribute("loginFrom", "jimu_example");
|
session.setAttribute("loginFrom", "jimu_example");
|
||||||
super.onAuthenticationSuccess(request, response, authentication);
|
|
||||||
|
SavedRequest savedRequest = (SavedRequest) session.getAttribute("SPRING_SECURITY_SAVED_REQUEST");
|
||||||
|
String redirectUrl = savedRequest != null ? savedRequest.getRedirectUrl() : null;
|
||||||
|
|
||||||
|
if (redirectUrl != null) {
|
||||||
|
try {
|
||||||
|
URI uri = new URI(redirectUrl);
|
||||||
|
String path = uri.getPath(); // 提取路径部分
|
||||||
|
|
||||||
|
if (path != null && path.startsWith("/jmreport")) {
|
||||||
|
// 路径符合要求,执行默认跳转
|
||||||
|
super.onAuthenticationSuccess(request, response, authentication);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} catch (URISyntaxException e) {
|
||||||
|
// URL解析失败,打印日志后继续执行默认跳转
|
||||||
|
log.error(e.getMessage(), e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 不符合 /jmreport 开头,或 redirectUrl 为 null 或异常
|
||||||
|
response.sendRedirect("/");
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -60,6 +60,7 @@ public class SpringSecurityConfig {
|
|||||||
"/jmreport/show",
|
"/jmreport/show",
|
||||||
"/jmreport/form/submit",
|
"/jmreport/form/submit",
|
||||||
"/jmreport/form/repeat/check/**",
|
"/jmreport/form/repeat/check/**",
|
||||||
|
"/jmreport/exportReport",
|
||||||
"/jmreport/addViewCount/**").permitAll()
|
"/jmreport/addViewCount/**").permitAll()
|
||||||
// 仪表盘分享页面
|
// 仪表盘分享页面
|
||||||
.antMatchers("/jimubi/share/view/**",
|
.antMatchers("/jimubi/share/view/**",
|
||||||
|
@@ -21,7 +21,7 @@ public class ViewPageCustomAccess {
|
|||||||
|
|
||||||
public boolean check(HttpServletRequest request, Authentication authentication) {
|
public boolean check(HttpServletRequest request, Authentication authentication) {
|
||||||
Object principal = authentication.getPrincipal();
|
Object principal = authentication.getPrincipal();
|
||||||
if (OkConvertUtils.isEmpty(principal) || "anonymousUser".equalsIgnoreCase(principal.toString())) {
|
if (null == principal || principal.toString().isEmpty() || "anonymousUser".equalsIgnoreCase(principal.toString())) {
|
||||||
// 未登录
|
// 未登录
|
||||||
if (openViewPage) {
|
if (openViewPage) {
|
||||||
// 配置文件设置了开放view页面
|
// 配置文件设置了开放view页面
|
||||||
@@ -30,7 +30,8 @@ public class ViewPageCustomAccess {
|
|||||||
HttpServletRequest httpRequest = (HttpServletRequest) request;
|
HttpServletRequest httpRequest = (HttpServletRequest) request;
|
||||||
String previousPage = httpRequest.getParameter("previousPage");
|
String previousPage = httpRequest.getParameter("previousPage");
|
||||||
String jmLink = httpRequest.getParameter("jmLink");
|
String jmLink = httpRequest.getParameter("jmLink");
|
||||||
if (OkConvertUtils.isNotEmpty(previousPage) && OkConvertUtils.isNotEmpty(jmLink) ) {
|
if (null != previousPage && !previousPage.isEmpty()
|
||||||
|
&& null != jmLink && !jmLink.isEmpty()) {
|
||||||
// 参数中有previousPage和jmLink
|
// 参数中有previousPage和jmLink
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@@ -1,8 +1,12 @@
|
|||||||
package com.jeecg.modules.jmreport.extend;
|
package com.jeecg.modules.jmreport.extend;
|
||||||
|
|
||||||
import org.jeecg.modules.jmreport.api.JmReportTokenServiceI;
|
import org.jeecg.modules.jmreport.api.JmReportTokenServiceI;
|
||||||
|
import org.jeecg.modules.jmreport.common.constant.JmConst;
|
||||||
|
import org.jeecg.modules.jmreport.common.util.JimuSpringContextUtils;
|
||||||
|
import org.jeecg.modules.jmreport.common.util.OkConvertUtils;
|
||||||
import org.springframework.http.HttpHeaders;
|
import org.springframework.http.HttpHeaders;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -20,31 +24,11 @@ public class JimuReportTokenServiceImpl implements JmReportTokenServiceI {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String getToken(HttpServletRequest request) {
|
public String getToken(HttpServletRequest request) {
|
||||||
//System.out.println("---------call---------getToken-----------------------");
|
//System.out.println("---------call---------getToken-----------------------");
|
||||||
//return TokenUtils.getTokenByRequest(request);
|
//return TokenUtils.getTokenByRequest(request);
|
||||||
return "123456";
|
return "123456";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 自定义获取租户
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public String getTenantId() {
|
|
||||||
// String headerTenantId = null;
|
|
||||||
// HttpServletRequest request = JimuSpringContextUtils.getHttpServletRequest();
|
|
||||||
// if (request != null) {
|
|
||||||
// headerTenantId = request.getHeader(JmConst.HEADER_TENANT_ID);
|
|
||||||
// if(OkConvertUtils.isEmpty(headerTenantId)){
|
|
||||||
// headerTenantId = request.getParameter(JmConst.TENANT_ID);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// return headerTenantId;
|
|
||||||
return "1";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通过Token获取登录人用户名
|
* 通过Token获取登录人用户名
|
||||||
* @param token
|
* @param token
|
||||||
@@ -107,4 +91,26 @@ public class JimuReportTokenServiceImpl implements JmReportTokenServiceI {
|
|||||||
header.add("token", "token value 2");
|
header.add("token", "token value 2");
|
||||||
return header;
|
return header;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 自定义获取租户
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public String getTenantId() {
|
||||||
|
String headerTenantId = null;
|
||||||
|
HttpServletRequest request = JimuSpringContextUtils.getHttpServletRequest();
|
||||||
|
if (request != null) {
|
||||||
|
headerTenantId = request.getHeader(JmConst.HEADER_TENANT_KEY);
|
||||||
|
if(OkConvertUtils.isEmpty(headerTenantId)){
|
||||||
|
headerTenantId = request.getHeader(JmConst.HEADER_TENANT_ID);
|
||||||
|
}
|
||||||
|
if(OkConvertUtils.isEmpty(headerTenantId)){
|
||||||
|
headerTenantId = request.getParameter(JmConst.TENANT_ID);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//return headerTenantId;
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
Reference in New Issue
Block a user