mirror of
https://github.com/jeecgboot/JeecgBoot.git
synced 2026-02-04 01:25:34 +08:00
后台目录结构大调整,让结构更清晰
This commit is contained in:
@ -0,0 +1,50 @@
|
||||
package org.jeecg.config.init;
|
||||
|
||||
import com.alibaba.druid.filter.config.ConfigTools;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.jeecgframework.codegenerate.database.CodegenDatasourceConfig;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* @Description: 代码生成器,自定义DB配置
|
||||
* 【加了此类,则online模式DB连接,使用平台的配置,jeecg_database.properties配置无效;
|
||||
* 但是使用GUI模式代码生成,还是走jeecg_database.properties配置】
|
||||
* 提醒: 达梦数据库需要修改下面的参数${spring.datasource.dynamic.datasource.master.url:}配置
|
||||
* @author: scott
|
||||
* @date: 2021年02月18日 16:30
|
||||
*/
|
||||
@Slf4j
|
||||
@Configuration
|
||||
public class CodeGenerateDbConfig {
|
||||
@Value("${spring.datasource.dynamic.datasource.master.url:}")
|
||||
private String url;
|
||||
@Value("${spring.datasource.dynamic.datasource.master.username:}")
|
||||
private String username;
|
||||
@Value("${spring.datasource.dynamic.datasource.master.password:}")
|
||||
private String password;
|
||||
@Value("${spring.datasource.dynamic.datasource.master.driver-class-name:}")
|
||||
private String driverClassName;
|
||||
@Value("${spring.datasource.dynamic.datasource.master.druid.public-key:}")
|
||||
private String publicKey;
|
||||
|
||||
|
||||
@Bean
|
||||
public CodeGenerateDbConfig initCodeGenerateDbConfig() {
|
||||
if(StringUtils.isNotBlank(url)){
|
||||
if(StringUtils.isNotBlank(publicKey)){
|
||||
try {
|
||||
password = ConfigTools.decrypt(publicKey, password);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
log.error(" 代码生成器数据库连接,数据库密码解密失败!");
|
||||
}
|
||||
}
|
||||
CodegenDatasourceConfig.initDbConfig(driverClassName,url, username, password);
|
||||
log.info(" Init CodeGenerate Config [ Get Db Config From application.yml ] ");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,42 @@
|
||||
package org.jeecg.config.init;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.jeecg.common.constant.CacheConstant;
|
||||
import org.jeecg.config.JeecgCloudCondition;
|
||||
import org.jeecg.modules.system.service.ISysGatewayRouteService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.context.event.ApplicationReadyEvent;
|
||||
import org.springframework.context.ApplicationListener;
|
||||
import org.springframework.context.annotation.Conditional;
|
||||
import org.springframework.core.Ordered;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* @desc: 启动程序,初始化路由配置
|
||||
* @author: flyme
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
@Conditional(JeecgCloudCondition.class)
|
||||
public class SystemInitListener implements ApplicationListener<ApplicationReadyEvent>, Ordered {
|
||||
|
||||
|
||||
@Autowired
|
||||
private ISysGatewayRouteService sysGatewayRouteService;
|
||||
|
||||
@Override
|
||||
public void onApplicationEvent(ApplicationReadyEvent applicationReadyEvent) {
|
||||
|
||||
log.info(" 服务已启动,初始化路由配置 ###################");
|
||||
String context = "AnnotationConfigServletWebServerApplicationContext";
|
||||
if (applicationReadyEvent.getApplicationContext().getDisplayName().indexOf(context) > -1) {
|
||||
sysGatewayRouteService.addRoute2Redis(CacheConstant.GATEWAY_ROUTES);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getOrder() {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,33 @@
|
||||
package org.jeecg.config.init;
|
||||
|
||||
import org.apache.catalina.Context;
|
||||
import org.apache.tomcat.util.scan.StandardJarScanner;
|
||||
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* @Description: TomcatFactoryConfig
|
||||
* @author: scott
|
||||
* @date: 2021年01月25日 11:40
|
||||
*/
|
||||
@Configuration
|
||||
public class TomcatFactoryConfig {
|
||||
/**
|
||||
* tomcat-embed-jasper引用后提示jar找不到的问题
|
||||
*/
|
||||
@Bean
|
||||
public TomcatServletWebServerFactory tomcatFactory() {
|
||||
TomcatServletWebServerFactory factory = new TomcatServletWebServerFactory() {
|
||||
@Override
|
||||
protected void postProcessContext(Context context) {
|
||||
((StandardJarScanner) context.getJarScanner()).setScanManifest(false);
|
||||
}
|
||||
};
|
||||
factory.addConnectorCustomizers(connector -> {
|
||||
connector.setProperty("relaxedPathChars", "[]{}");
|
||||
connector.setProperty("relaxedQueryChars", "[]{}");
|
||||
});
|
||||
return factory;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,69 @@
|
||||
package org.jeecg.config.jimureport;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.jeecg.common.system.util.JwtUtil;
|
||||
import org.jeecg.common.system.vo.SysUserCacheInfo;
|
||||
import org.jeecg.common.util.RedisUtil;
|
||||
import org.jeecg.common.util.TokenUtils;
|
||||
import org.jeecg.modules.jmreport.api.JmReportTokenServiceI;
|
||||
import org.jeecg.modules.system.service.impl.SysBaseApiImpl;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 自定义积木报表鉴权(如果不进行自定义,则所有请求不做权限控制)
|
||||
* * 1.自定义获取登录token
|
||||
* * 2.自定义获取登录用户
|
||||
* @author: jeecg-boot
|
||||
*/
|
||||
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class JimuReportTokenService implements JmReportTokenServiceI {
|
||||
@Autowired
|
||||
private SysBaseApiImpl sysBaseApi;
|
||||
@Autowired
|
||||
@Lazy
|
||||
private RedisUtil redisUtil;
|
||||
|
||||
@Override
|
||||
public String getToken(HttpServletRequest request) {
|
||||
return TokenUtils.getTokenByRequest(request);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUsername(String token) {
|
||||
return JwtUtil.getUsername(token);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean verifyToken(String token) {
|
||||
return TokenUtils.verifyToken(token, sysBaseApi, redisUtil);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getUserInfo(String token) {
|
||||
Map<String, Object> map = new HashMap(5);
|
||||
String username = JwtUtil.getUsername(token);
|
||||
//此处通过token只能拿到一个信息 用户账号 后面的就是根据账号获取其他信息 查询数据或是走redis 用户根据自身业务可自定义
|
||||
SysUserCacheInfo userInfo = null;
|
||||
try {
|
||||
userInfo = sysBaseApi.getCacheUser(username);
|
||||
} catch (Exception e) {
|
||||
log.error("获取用户信息异常:"+ e.getMessage());
|
||||
return map;
|
||||
}
|
||||
//设置账号名
|
||||
map.put(SYS_USER_CODE, userInfo.getSysUserCode());
|
||||
//设置部门编码
|
||||
map.put(SYS_ORG_CODE, userInfo.getSysOrgCode());
|
||||
// 将所有信息存放至map 解析sql/api会根据map的键值解析
|
||||
return map;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user