vue版本上线
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
package com.jsh.erp.config;
|
||||
|
||||
import com.gitee.starblues.extension.mybatis.SpringBootMybatisExtension;
|
||||
import com.gitee.starblues.integration.application.AutoPluginApplication;
|
||||
import com.gitee.starblues.integration.application.PluginApplication;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* @Author: jishenghua
|
||||
* @Version: 1.0
|
||||
* @Create Date Time: 2019-05-30 15:53
|
||||
* @Update Date Time:
|
||||
* @see
|
||||
*/
|
||||
@Configuration
|
||||
public class PluginBeanConfig {
|
||||
@Bean
|
||||
public PluginApplication pluginApplication(){
|
||||
PluginApplication pluginApplication = new AutoPluginApplication();
|
||||
pluginApplication.addExtension(new SpringBootMybatisExtension());
|
||||
return pluginApplication;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
package com.jsh.erp.config;
|
||||
|
||||
import com.gitee.starblues.integration.DefaultIntegrationConfiguration;
|
||||
import org.pf4j.RuntimeMode;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
|
||||
/**
|
||||
* @Description:
|
||||
* @Author: jishenghua
|
||||
* @Version: 1.0
|
||||
* @Create Date Time: 2019-05-25 12:36
|
||||
* @Update Date Time:
|
||||
* @see
|
||||
*/
|
||||
@Component
|
||||
@ConfigurationProperties(prefix = "plugin")
|
||||
public class PluginConfiguration extends DefaultIntegrationConfiguration {
|
||||
|
||||
/**
|
||||
* 运行模式
|
||||
* 开发环境: development、dev
|
||||
* 生产/部署 环境: deployment、prod
|
||||
*/
|
||||
@Value("${runMode:dev}")
|
||||
private String runMode;
|
||||
|
||||
@Value("${pluginPath:plugins}")
|
||||
private String pluginPath;
|
||||
|
||||
@Value("${pluginConfigFilePath:pluginConfigs}")
|
||||
private String pluginConfigFilePath;
|
||||
|
||||
@Override
|
||||
public RuntimeMode environment() {
|
||||
return RuntimeMode.byName(runMode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String pluginPath() {
|
||||
return pluginPath;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String pluginConfigFilePath() {
|
||||
return pluginConfigFilePath;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String uploadTempPath() {
|
||||
return "temp";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String backupPath() {
|
||||
return "backupPlugin";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String pluginRestControllerPathPrefix() {
|
||||
return "/api/plugin";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean enablePluginIdRestControllerPathPrefix() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public String getRunMode() {
|
||||
return runMode;
|
||||
}
|
||||
|
||||
public void setRunMode(String runMode) {
|
||||
this.runMode = runMode;
|
||||
}
|
||||
|
||||
|
||||
public String getPluginPath() {
|
||||
return pluginPath;
|
||||
}
|
||||
|
||||
public void setPluginPath(String pluginPath) {
|
||||
this.pluginPath = pluginPath;
|
||||
}
|
||||
|
||||
public String getPluginConfigFilePath() {
|
||||
return pluginConfigFilePath;
|
||||
}
|
||||
|
||||
public void setPluginConfigFilePath(String pluginConfigFilePath) {
|
||||
this.pluginConfigFilePath = pluginConfigFilePath;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "PluginArgConfiguration{" +
|
||||
"runMode='" + runMode + '\'' +
|
||||
", pluginPath='" + pluginPath + '\'' +
|
||||
", pluginConfigFilePath='" + pluginConfigFilePath + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package com.jsh.erp.config;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import springfox.documentation.builders.ApiInfoBuilder;
|
||||
import springfox.documentation.builders.PathSelectors;
|
||||
import springfox.documentation.builders.RequestHandlerSelectors;
|
||||
import springfox.documentation.service.ApiInfo;
|
||||
import springfox.documentation.service.Contact;
|
||||
import springfox.documentation.spi.DocumentationType;
|
||||
import springfox.documentation.spring.web.plugins.Docket;
|
||||
import springfox.documentation.swagger2.annotations.EnableSwagger2;
|
||||
|
||||
/**
|
||||
* 插件集成配置
|
||||
*
|
||||
* @author jishenghua
|
||||
* @version 1.0
|
||||
*/
|
||||
@Configuration
|
||||
@EnableSwagger2
|
||||
public class Swagger2Config {
|
||||
|
||||
@Bean
|
||||
public Docket createRestApi() {
|
||||
return new Docket(DocumentationType.SWAGGER_2)
|
||||
.apiInfo(this.apiInfo())
|
||||
.select()
|
||||
.apis(RequestHandlerSelectors.any())
|
||||
.paths(PathSelectors.any())
|
||||
.build();
|
||||
}
|
||||
|
||||
private ApiInfo apiInfo() {
|
||||
return new ApiInfoBuilder()
|
||||
.title("Mybatis-Plus Plugin Example RESTful APIs")
|
||||
.description("集成Mybatis-Plus模块接口描述")
|
||||
.termsOfServiceUrl("http://127.0.0.1")
|
||||
.contact(new Contact("jishenghua", "", ""))
|
||||
.version("2.1.1")
|
||||
.build();
|
||||
}
|
||||
|
||||
}
|
||||
107
jshERP-boot/src/main/java/com/jsh/erp/config/TenantConfig.java
Normal file
107
jshERP-boot/src/main/java/com/jsh/erp/config/TenantConfig.java
Normal file
@@ -0,0 +1,107 @@
|
||||
package com.jsh.erp.config;
|
||||
|
||||
import com.baomidou.mybatisplus.core.parser.ISqlParser;
|
||||
import com.baomidou.mybatisplus.core.parser.ISqlParserFilter;
|
||||
import com.baomidou.mybatisplus.core.parser.SqlParserHelper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
|
||||
import com.baomidou.mybatisplus.extension.plugins.PerformanceInterceptor;
|
||||
import com.baomidou.mybatisplus.extension.plugins.tenant.TenantHandler;
|
||||
import com.baomidou.mybatisplus.extension.plugins.tenant.TenantSqlParser;
|
||||
import com.jsh.erp.utils.Tools;
|
||||
import net.sf.jsqlparser.expression.Expression;
|
||||
import net.sf.jsqlparser.expression.LongValue;
|
||||
import org.apache.ibatis.mapping.MappedStatement;
|
||||
import org.apache.ibatis.reflection.MetaObject;
|
||||
import org.mybatis.spring.mapper.MapperScannerConfigurer;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class TenantConfig {
|
||||
|
||||
@Bean
|
||||
public PaginationInterceptor paginationInterceptor(HttpServletRequest request) {
|
||||
PaginationInterceptor paginationInterceptor = new PaginationInterceptor();
|
||||
List<ISqlParser> sqlParserList = new ArrayList<>();
|
||||
TenantSqlParser tenantSqlParser = new TenantSqlParser();
|
||||
tenantSqlParser.setTenantHandler(new TenantHandler() {
|
||||
@Override
|
||||
public Expression getTenantId() {
|
||||
String token = request.getHeader("X-Access-Token");
|
||||
Long tenantId = Tools.getTenantIdByToken(token);
|
||||
if (tenantId!=0L) {
|
||||
return new LongValue(tenantId);
|
||||
} else {
|
||||
//超管
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTenantIdColumn() {
|
||||
return "tenant_id";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean doTableFilter(String tableName) {
|
||||
//获取开启状态
|
||||
Boolean res = true;
|
||||
String token = request.getHeader("X-Access-Token");
|
||||
Long tenantId = Tools.getTenantIdByToken(token);
|
||||
if (tenantId!=0L) {
|
||||
// 这里可以判断是否过滤表
|
||||
if ("jsh_material_property".equals(tableName) || "jsh_sequence".equals(tableName)
|
||||
|| "jsh_user_business".equals(tableName) || "jsh_function".equals(tableName)
|
||||
|| "jsh_platform_config".equals(tableName) || "jsh_tenant".equals(tableName)) {
|
||||
res = true;
|
||||
} else {
|
||||
res = false;
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
});
|
||||
|
||||
sqlParserList.add(tenantSqlParser);
|
||||
paginationInterceptor.setSqlParserList(sqlParserList);
|
||||
paginationInterceptor.setSqlParserFilter(new ISqlParserFilter() {
|
||||
@Override
|
||||
public boolean doFilter(MetaObject metaObject) {
|
||||
MappedStatement ms = SqlParserHelper.getMappedStatement(metaObject);
|
||||
// 过滤自定义查询此时无租户信息约束出现
|
||||
if ("com.jsh.erp.datasource.mappers.UserMapperEx.getUserListByUserNameOrLoginName".equals(ms.getId())||
|
||||
"com.jsh.erp.datasource.mappers.DepotItemMapperEx.getStockByParam".equals(ms.getId())) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
return paginationInterceptor;
|
||||
}
|
||||
|
||||
/**
|
||||
* 相当于顶部的:
|
||||
* {@code @MapperScan("com.jsh.erp.datasource.mappers*")}
|
||||
* 这里可以扩展,比如使用配置文件来配置扫描Mapper的路径
|
||||
*/
|
||||
@Bean
|
||||
public MapperScannerConfigurer mapperScannerConfigurer() {
|
||||
MapperScannerConfigurer scannerConfigurer = new MapperScannerConfigurer();
|
||||
scannerConfigurer.setBasePackage("com.jsh.erp.datasource.mappers*");
|
||||
return scannerConfigurer;
|
||||
}
|
||||
|
||||
/**
|
||||
* 性能分析拦截器,不建议生产使用
|
||||
*/
|
||||
@Bean
|
||||
public PerformanceInterceptor performanceInterceptor(){
|
||||
return new PerformanceInterceptor();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user