处理代码生成多租户支持

minio上传文件拼接字符bug
This commit is contained in:
zer0Black
2022-02-28 10:01:00 +08:00
parent 45fbbaa997
commit f221b8e265
5 changed files with 38 additions and 4 deletions
@@ -111,4 +111,13 @@ public interface DataBaseConstant {
*/ */
public static final String BPM_STATUS_TABLE = "bpm_status"; public static final String BPM_STATUS_TABLE = "bpm_status";
//*********系统建表标准字段**************************************** //*********系统建表标准字段****************************************
/**
* 租户ID 实体字段名
*/
String TENANT_ID = "tenantId";
/**
* 租户ID 数据库字段名
*/
String TENANT_ID_TABLE = "tenant_id";
} }
@@ -11,6 +11,7 @@ import java.util.Date;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession; import javax.servlet.http.HttpSession;
import com.jero.common.constant.CommonConstant;
import org.apache.shiro.SecurityUtils; import org.apache.shiro.SecurityUtils;
import com.jero.common.constant.DataBaseConstant; import com.jero.common.constant.DataBaseConstant;
import com.jero.common.exception.JeroBootException; import com.jero.common.exception.JeroBootException;
@@ -197,6 +198,14 @@ public class JwtUtil {
else if (key.equals(DataBaseConstant.BPM_STATUS)|| key.toLowerCase().equals(DataBaseConstant.BPM_STATUS_TABLE)) { else if (key.equals(DataBaseConstant.BPM_STATUS)|| key.toLowerCase().equals(DataBaseConstant.BPM_STATUS_TABLE)) {
returnValue = "1"; returnValue = "1";
} }
//update-begin-author:taoyan date:20210330 for:多租户ID作为系统变量
else if (key.equals(DataBaseConstant.TENANT_ID) || key.toLowerCase().equals(DataBaseConstant.TENANT_ID_TABLE)){
returnValue = sysUser.getRelTenantIds();
if(oConvertUtils.isEmpty(returnValue) || (returnValue!=null && returnValue.indexOf(",")>0)){
returnValue = SpringContextUtils.getHttpServletRequest().getHeader(CommonConstant.TENANT_ID);
}
}
//update-end-author:taoyan date:20210330 for:多租户ID作为系统变量
if(returnValue!=null){returnValue = returnValue + moshi;} if(returnValue!=null){returnValue = returnValue + moshi;}
return returnValue; return returnValue;
} }
@@ -76,7 +76,7 @@ public class MinioUtil {
orgName=file.getName(); orgName=file.getName();
} }
orgName = CommonUtils.getFileName(orgName); orgName = CommonUtils.getFileName(orgName);
String objectName = bizPath+"/"+orgName.substring(0, orgName.lastIndexOf(".")) + "_" + System.currentTimeMillis() + orgName.substring(orgName.indexOf(".")); String objectName = bizPath+"/"+orgName.substring(0, orgName.lastIndexOf(".")) + "_" + System.currentTimeMillis() + orgName.substring(orgName.lastIndexOf("."));
// 使用putObject上传一个本地文件到存储桶中。 // 使用putObject上传一个本地文件到存储桶中。
if(objectName.startsWith("/")){ if(objectName.startsWith("/")){
@@ -111,7 +111,7 @@ public class OssBootUtil {
orgName=file.getName(); orgName=file.getName();
} }
orgName = CommonUtils.getFileName(orgName); orgName = CommonUtils.getFileName(orgName);
String fileName = orgName.substring(0, orgName.lastIndexOf(".")) + "_" + System.currentTimeMillis() + orgName.substring(orgName.indexOf(".")); String fileName = orgName.substring(0, orgName.lastIndexOf(".")) + "_" + System.currentTimeMillis() + orgName.substring(orgName.lastIndexOf("."));
if (!fileDir.endsWith("/")) { if (!fileDir.endsWith("/")) {
fileDir = fileDir.concat("/"); fileDir = fileDir.concat("/");
} }
@@ -36,6 +36,10 @@ public class GatewayRoutersConfiguration {
public static String ROUTE_GROUP; public static String ROUTE_GROUP;
public static String USERNAME;
public static String PASSWORD;
/** /**
* 路由配置文件数据获取方式yml,nacos,database * 路由配置文件数据获取方式yml,nacos,database
*/ */
@@ -62,8 +66,15 @@ public class GatewayRoutersConfiguration {
} }
@Value("${jero.route.config.data-type}") @Value("${jero.route.config.data-type}")
public void setDataType(String dataType) { public void setDataType(String dataType) { DATA_TYPE = dataType; }
DATA_TYPE = dataType;
@Value("${spring.cloud.nacos.config.username}")
public void setUsername(String username) {
USERNAME = username;
}
@Value("${spring.cloud.nacos.config.password}")
public void setPassword(String password) {
PASSWORD = password;
} }
@@ -78,6 +89,11 @@ public class GatewayRoutersConfiguration {
} }
/**
* 映射接口文档默认地址(通过9999端口直接访问)
* @param indexHtml
* @return
*/
@Bean @Bean
public RouterFunction<ServerResponse> indexRouter(@Value("classpath:/META-INF/resources/doc.html") final org.springframework.core.io.Resource indexHtml) { public RouterFunction<ServerResponse> indexRouter(@Value("classpath:/META-INF/resources/doc.html") final org.springframework.core.io.Resource indexHtml) {
return route(GET("/"), request -> ok().contentType(MediaType.TEXT_HTML).syncBody(indexHtml)); return route(GET("/"), request -> ok().contentType(MediaType.TEXT_HTML).syncBody(indexHtml));