Browse Source
# Conflicts: # blade-ops/blade-resource/src/main/java/org/springblade/resource/builder/OssBuilder.java # blade-ops/blade-resource/src/main/resources/application.yml # blade-service/blade-system/src/main/java/org/springblade/system/service/impl/TenantServiceImpl.javapull/1/head
82 changed files with 1698 additions and 381 deletions
@ -0,0 +1,64 @@
|
||||
/* |
||||
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without |
||||
* modification, are permitted provided that the following conditions are met: |
||||
* |
||||
* Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* Redistributions in binary form must reproduce the above copyright |
||||
* notice, this list of conditions and the following disclaimer in the |
||||
* documentation and/or other materials provided with the distribution. |
||||
* Neither the name of the dreamlu.net developer nor the names of its |
||||
* contributors may be used to endorse or promote products derived from |
||||
* this software without specific prior written permission. |
||||
* Author: Chill 庄骞 (smallchill@163.com) |
||||
*/ |
||||
package org.springblade.resource.rule.context; |
||||
|
||||
import lombok.Data; |
||||
import org.springblade.core.oss.OssTemplate; |
||||
import org.springblade.core.oss.props.OssProperties; |
||||
import org.springblade.core.oss.rule.OssRule; |
||||
import org.springblade.resource.entity.Oss; |
||||
|
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* Oss上下文 |
||||
* |
||||
* @author Chill |
||||
*/ |
||||
@Data |
||||
public class OssContext { |
||||
/** |
||||
* 是否有缓存 |
||||
*/ |
||||
private Boolean isCached; |
||||
/** |
||||
* oss数据 |
||||
*/ |
||||
private Oss oss; |
||||
/** |
||||
* oss规则 |
||||
*/ |
||||
private OssRule ossRule; |
||||
/** |
||||
* oss接口 |
||||
*/ |
||||
private OssTemplate ossTemplate; |
||||
/** |
||||
* oss配置 |
||||
*/ |
||||
private OssProperties ossProperties; |
||||
/** |
||||
* OssTemplate配置缓存池 |
||||
*/ |
||||
private Map<String, OssTemplate> templatePool; |
||||
/** |
||||
* oss配置缓存池 |
||||
*/ |
||||
private Map<String, Oss> ossPool; |
||||
|
||||
|
||||
} |
@ -0,0 +1,64 @@
|
||||
/* |
||||
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without |
||||
* modification, are permitted provided that the following conditions are met: |
||||
* |
||||
* Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* Redistributions in binary form must reproduce the above copyright |
||||
* notice, this list of conditions and the following disclaimer in the |
||||
* documentation and/or other materials provided with the distribution. |
||||
* Neither the name of the dreamlu.net developer nor the names of its |
||||
* contributors may be used to endorse or promote products derived from |
||||
* this software without specific prior written permission. |
||||
* Author: Chill 庄骞 (smallchill@163.com) |
||||
*/ |
||||
package org.springblade.resource.rule.context; |
||||
|
||||
import lombok.Data; |
||||
import org.springblade.core.redis.cache.BladeRedis; |
||||
import org.springblade.core.sms.SmsTemplate; |
||||
import org.springblade.core.sms.props.SmsProperties; |
||||
import org.springblade.resource.entity.Sms; |
||||
|
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* Sms上下文 |
||||
* |
||||
* @author Chill |
||||
*/ |
||||
@Data |
||||
public class SmsContext { |
||||
/** |
||||
* 是否有缓存 |
||||
*/ |
||||
private Boolean isCached; |
||||
/** |
||||
* sms数据 |
||||
*/ |
||||
private Sms sms; |
||||
/** |
||||
* sms接口 |
||||
*/ |
||||
private SmsTemplate smsTemplate; |
||||
/** |
||||
* sms配置 |
||||
*/ |
||||
private SmsProperties smsProperties; |
||||
/** |
||||
* redis工具 |
||||
*/ |
||||
private BladeRedis bladeRedis; |
||||
/** |
||||
* SmsTemplate配置缓存池 |
||||
*/ |
||||
private Map<String, SmsTemplate> templatePool; |
||||
/** |
||||
* sms配置缓存池 |
||||
*/ |
||||
private Map<String, Sms> smsPool; |
||||
|
||||
|
||||
} |
@ -0,0 +1,58 @@
|
||||
/* |
||||
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without |
||||
* modification, are permitted provided that the following conditions are met: |
||||
* |
||||
* Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* Redistributions in binary form must reproduce the above copyright |
||||
* notice, this list of conditions and the following disclaimer in the |
||||
* documentation and/or other materials provided with the distribution. |
||||
* Neither the name of the dreamlu.net developer nor the names of its |
||||
* contributors may be used to endorse or promote products derived from |
||||
* this software without specific prior written permission. |
||||
* Author: Chill 庄骞 (smallchill@163.com) |
||||
*/ |
||||
package org.springblade.resource.rule.oss; |
||||
|
||||
import com.yomahub.liteflow.annotation.LiteflowComponent; |
||||
import com.yomahub.liteflow.core.NodeComponent; |
||||
import org.springblade.core.log.exception.ServiceException; |
||||
import org.springblade.core.oss.OssTemplate; |
||||
import org.springblade.core.tool.utils.Func; |
||||
import org.springblade.resource.entity.Oss; |
||||
import org.springblade.resource.rule.context.OssContext; |
||||
|
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* Oss后置处理 |
||||
* |
||||
* @author Chill |
||||
*/ |
||||
@LiteflowComponent(id = "finallyOssRule", name = "OSS构建后置处理") |
||||
public class FinallyOssRule extends NodeComponent { |
||||
@Override |
||||
public void process() throws Exception { |
||||
String tenantId = this.getRequestData(); |
||||
OssContext contextBean = this.getContextBean(OssContext.class); |
||||
Map<String, Oss> ossPool = contextBean.getOssPool(); |
||||
Map<String, OssTemplate> templatePool = contextBean.getTemplatePool(); |
||||
|
||||
if (contextBean.getIsCached()) { |
||||
OssTemplate template = templatePool.get(tenantId); |
||||
contextBean.setOssTemplate(template); |
||||
} else { |
||||
Oss oss = contextBean.getOss(); |
||||
OssTemplate template = contextBean.getOssTemplate(); |
||||
if (Func.hasEmpty(template, oss)) { |
||||
throw new ServiceException("OSS接口读取失败!"); |
||||
} else { |
||||
templatePool.put(tenantId, template); |
||||
ossPool.put(tenantId, oss); |
||||
} |
||||
} |
||||
|
||||
} |
||||
} |
@ -0,0 +1,53 @@
|
||||
/* |
||||
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without |
||||
* modification, are permitted provided that the following conditions are met: |
||||
* |
||||
* Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* Redistributions in binary form must reproduce the above copyright |
||||
* notice, this list of conditions and the following disclaimer in the |
||||
* documentation and/or other materials provided with the distribution. |
||||
* Neither the name of the dreamlu.net developer nor the names of its |
||||
* contributors may be used to endorse or promote products derived from |
||||
* this software without specific prior written permission. |
||||
* Author: Chill 庄骞 (smallchill@163.com) |
||||
*/ |
||||
package org.springblade.resource.rule.oss; |
||||
|
||||
import com.yomahub.liteflow.annotation.LiteflowComponent; |
||||
import com.yomahub.liteflow.core.NodeSwitchComponent; |
||||
import org.springblade.core.log.exception.ServiceException; |
||||
import org.springblade.core.oss.enums.OssEnum; |
||||
import org.springblade.resource.entity.Oss; |
||||
import org.springblade.resource.rule.context.OssContext; |
||||
|
||||
/** |
||||
* Oss构建判断 |
||||
* |
||||
* @author Chill |
||||
*/ |
||||
@LiteflowComponent(id = "ossBuildRule", name = "OSS构建条件判断") |
||||
public class OssBuildRule extends NodeSwitchComponent { |
||||
|
||||
@Override |
||||
public String processSwitch() { |
||||
OssContext contextBean = this.getContextBean(OssContext.class); |
||||
Oss oss = contextBean.getOss(); |
||||
if (oss.getCategory() == OssEnum.MINIO.getCategory()) { |
||||
return "minioRule"; |
||||
} else if (oss.getCategory() == OssEnum.QINIU.getCategory()) { |
||||
return "qiniuOssRule"; |
||||
} else if (oss.getCategory() == OssEnum.ALI.getCategory()) { |
||||
return "aliOssRule"; |
||||
} else if (oss.getCategory() == OssEnum.TENCENT.getCategory()) { |
||||
return "tencentCosRule"; |
||||
} else if (oss.getCategory() == OssEnum.HUAWEI.getCategory()) { |
||||
return "huaweiObsRule"; |
||||
} else if (oss.getCategory() == OssEnum.AMAZONS3.getCategory()) { |
||||
return "amazonS3Rule"; |
||||
} |
||||
throw new ServiceException("未找到OSS配置"); |
||||
} |
||||
} |
@ -0,0 +1,42 @@
|
||||
/* |
||||
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without |
||||
* modification, are permitted provided that the following conditions are met: |
||||
* |
||||
* Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* Redistributions in binary form must reproduce the above copyright |
||||
* notice, this list of conditions and the following disclaimer in the |
||||
* documentation and/or other materials provided with the distribution. |
||||
* Neither the name of the dreamlu.net developer nor the names of its |
||||
* contributors may be used to endorse or promote products derived from |
||||
* this software without specific prior written permission. |
||||
* Author: Chill 庄骞 (smallchill@163.com) |
||||
*/ |
||||
package org.springblade.resource.rule.oss; |
||||
|
||||
import com.yomahub.liteflow.annotation.LiteflowComponent; |
||||
import com.yomahub.liteflow.core.NodeSwitchComponent; |
||||
import org.springblade.resource.rule.context.OssContext; |
||||
|
||||
/** |
||||
* Oss缓存判断 |
||||
* |
||||
* @author Chill |
||||
*/ |
||||
@LiteflowComponent(id = "ossCacheRule", name = "OSS缓存判断") |
||||
public class OssCacheRule extends NodeSwitchComponent { |
||||
|
||||
@Override |
||||
public String processSwitch() { |
||||
OssContext contextBean = this.getContextBean(OssContext.class); |
||||
// 若判断配置已缓存则直接读取,否则进入下一步构建新数据
|
||||
if (contextBean.getIsCached()) { |
||||
return "ossReadRule"; |
||||
} else { |
||||
return "ossNewRule"; |
||||
} |
||||
} |
||||
|
||||
} |
@ -0,0 +1,45 @@
|
||||
/* |
||||
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without |
||||
* modification, are permitted provided that the following conditions are met: |
||||
* |
||||
* Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* Redistributions in binary form must reproduce the above copyright |
||||
* notice, this list of conditions and the following disclaimer in the |
||||
* documentation and/or other materials provided with the distribution. |
||||
* Neither the name of the dreamlu.net developer nor the names of its |
||||
* contributors may be used to endorse or promote products derived from |
||||
* this software without specific prior written permission. |
||||
* Author: Chill 庄骞 (smallchill@163.com) |
||||
*/ |
||||
package org.springblade.resource.rule.oss; |
||||
|
||||
import com.yomahub.liteflow.annotation.LiteflowComponent; |
||||
import com.yomahub.liteflow.core.NodeComponent; |
||||
import org.springblade.core.oss.props.OssProperties; |
||||
import org.springblade.core.oss.rule.BladeOssRule; |
||||
import org.springblade.resource.entity.Oss; |
||||
import org.springblade.resource.rule.context.OssContext; |
||||
|
||||
/** |
||||
* OSS数据创建 |
||||
* |
||||
* @author Chill |
||||
*/ |
||||
@LiteflowComponent(id = "ossDataRule", name = "OSS数据创建") |
||||
public class OssDataRule extends NodeComponent { |
||||
@Override |
||||
public void process() throws Exception { |
||||
OssContext contextBean = this.getContextBean(OssContext.class); |
||||
Oss oss = contextBean.getOss(); |
||||
OssProperties ossProperties = contextBean.getOssProperties(); |
||||
// 若采用默认设置则开启多租户模式, 若是用户自定义oss则不开启
|
||||
if (oss.getEndpoint().equals(ossProperties.getEndpoint()) && oss.getAccessKey().equals(ossProperties.getAccessKey()) && ossProperties.getTenantMode()) { |
||||
contextBean.setOssRule(new BladeOssRule(Boolean.TRUE)); |
||||
} else { |
||||
contextBean.setOssRule(new BladeOssRule(Boolean.FALSE)); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,48 @@
|
||||
/* |
||||
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without |
||||
* modification, are permitted provided that the following conditions are met: |
||||
* |
||||
* Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* Redistributions in binary form must reproduce the above copyright |
||||
* notice, this list of conditions and the following disclaimer in the |
||||
* documentation and/or other materials provided with the distribution. |
||||
* Neither the name of the dreamlu.net developer nor the names of its |
||||
* contributors may be used to endorse or promote products derived from |
||||
* this software without specific prior written permission. |
||||
* Author: Chill 庄骞 (smallchill@163.com) |
||||
*/ |
||||
package org.springblade.resource.rule.oss; |
||||
|
||||
import com.yomahub.liteflow.annotation.LiteflowComponent; |
||||
import com.yomahub.liteflow.core.NodeComponent; |
||||
import org.springblade.core.log.exception.ServiceException; |
||||
import org.springblade.core.oss.OssTemplate; |
||||
import org.springblade.core.tool.utils.Func; |
||||
import org.springblade.resource.entity.Oss; |
||||
import org.springblade.resource.rule.context.OssContext; |
||||
|
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* OSS缓存读取校验 |
||||
* |
||||
* @author Chill |
||||
*/ |
||||
@LiteflowComponent(id = "ossReadRule", name = "OSS缓存读取校验") |
||||
public class OssReadRule extends NodeComponent { |
||||
@Override |
||||
public void process() throws Exception { |
||||
String tenantId = this.getRequestData(); |
||||
OssContext contextBean = this.getContextBean(OssContext.class); |
||||
Map<String, Oss> ossPool = contextBean.getOssPool(); |
||||
Map<String, OssTemplate> templatePool = contextBean.getTemplatePool(); |
||||
Oss ossCached = ossPool.get(tenantId); |
||||
OssTemplate template = templatePool.get(tenantId); |
||||
if (Func.hasEmpty(template, ossCached)) { |
||||
throw new ServiceException("OSS缓存读取失败!"); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,42 @@
|
||||
/* |
||||
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without |
||||
* modification, are permitted provided that the following conditions are met: |
||||
* |
||||
* Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* Redistributions in binary form must reproduce the above copyright |
||||
* notice, this list of conditions and the following disclaimer in the |
||||
* documentation and/or other materials provided with the distribution. |
||||
* Neither the name of the dreamlu.net developer nor the names of its |
||||
* contributors may be used to endorse or promote products derived from |
||||
* this software without specific prior written permission. |
||||
* Author: Chill 庄骞 (smallchill@163.com) |
||||
*/ |
||||
package org.springblade.resource.rule.oss; |
||||
|
||||
import com.yomahub.liteflow.annotation.LiteflowComponent; |
||||
import com.yomahub.liteflow.core.NodeComponent; |
||||
import org.springblade.core.log.exception.ServiceException; |
||||
import org.springblade.core.oss.OssTemplate; |
||||
import org.springblade.core.tool.utils.Func; |
||||
import org.springblade.resource.rule.context.OssContext; |
||||
|
||||
/** |
||||
* OSS接口读取校验 |
||||
* |
||||
* @author Chill |
||||
*/ |
||||
@LiteflowComponent(id = "ossTemplateRule", name = "OSS接口读取校验") |
||||
public class OssTemplateRule extends NodeComponent { |
||||
@Override |
||||
public void process() throws Exception { |
||||
OssContext contextBean = this.getContextBean(OssContext.class); |
||||
OssTemplate ossTemplate = contextBean.getOssTemplate(); |
||||
|
||||
if (Func.isEmpty(ossTemplate)) { |
||||
throw new ServiceException("OSS接口读取失败!"); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,52 @@
|
||||
/* |
||||
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without |
||||
* modification, are permitted provided that the following conditions are met: |
||||
* |
||||
* Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* Redistributions in binary form must reproduce the above copyright |
||||
* notice, this list of conditions and the following disclaimer in the |
||||
* documentation and/or other materials provided with the distribution. |
||||
* Neither the name of the dreamlu.net developer nor the names of its |
||||
* contributors may be used to endorse or promote products derived from |
||||
* this software without specific prior written permission. |
||||
* Author: Chill 庄骞 (smallchill@163.com) |
||||
*/ |
||||
package org.springblade.resource.rule.oss; |
||||
|
||||
import com.yomahub.liteflow.annotation.LiteflowComponent; |
||||
import com.yomahub.liteflow.core.NodeComponent; |
||||
import org.springblade.core.oss.OssTemplate; |
||||
import org.springblade.core.tool.utils.Func; |
||||
import org.springblade.resource.entity.Oss; |
||||
import org.springblade.resource.rule.context.OssContext; |
||||
|
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* Oss前置处理 |
||||
* |
||||
* @author Chill |
||||
*/ |
||||
@LiteflowComponent(id = "preOssRule", name = "OSS构建前置处理") |
||||
public class PreOssRule extends NodeComponent { |
||||
@Override |
||||
public void process() throws Exception { |
||||
String tenantId = this.getRequestData(); |
||||
OssContext contextBean = this.getContextBean(OssContext.class); |
||||
Map<String, Oss> ossPool = contextBean.getOssPool(); |
||||
Map<String, OssTemplate> templatePool = contextBean.getTemplatePool(); |
||||
Oss oss = contextBean.getOss(); |
||||
Oss ossCached = ossPool.get(tenantId); |
||||
OssTemplate template = templatePool.get(tenantId); |
||||
// 若为空或者不一致,则重新加载
|
||||
if (Func.hasEmpty(template, ossCached) || !oss.getEndpoint().equals(ossCached.getEndpoint()) || !oss.getAccessKey().equals(ossCached.getAccessKey())) { |
||||
contextBean.setIsCached(Boolean.FALSE); |
||||
} else { |
||||
contextBean.setIsCached(Boolean.TRUE); |
||||
} |
||||
} |
||||
|
||||
} |
@ -0,0 +1,52 @@
|
||||
/* |
||||
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without |
||||
* modification, are permitted provided that the following conditions are met: |
||||
* |
||||
* Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* Redistributions in binary form must reproduce the above copyright |
||||
* notice, this list of conditions and the following disclaimer in the |
||||
* documentation and/or other materials provided with the distribution. |
||||
* Neither the name of the dreamlu.net developer nor the names of its |
||||
* contributors may be used to endorse or promote products derived from |
||||
* this software without specific prior written permission. |
||||
* Author: Chill 庄骞 (smallchill@163.com) |
||||
*/ |
||||
package org.springblade.resource.rule.sms; |
||||
|
||||
import com.yomahub.liteflow.annotation.LiteflowComponent; |
||||
import com.yomahub.liteflow.core.NodeComponent; |
||||
import org.springblade.core.log.exception.ServiceException; |
||||
import org.springblade.core.sms.SmsTemplate; |
||||
import org.springblade.core.tool.utils.Func; |
||||
import org.springblade.resource.entity.Sms; |
||||
import org.springblade.resource.rule.context.SmsContext; |
||||
|
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* 缓存短信构建类 |
||||
* |
||||
* @author Chill |
||||
*/ |
||||
@LiteflowComponent(id = "cacheSmsRule", name = "缓存SMS构建") |
||||
public class CacheSmsRule extends NodeComponent { |
||||
|
||||
@Override |
||||
public void process() throws Exception { |
||||
// 获取上下文
|
||||
String tenantId = this.getRequestData(); |
||||
SmsContext contextBean = this.getContextBean(SmsContext.class); |
||||
|
||||
Map<String, Sms> smsPool = contextBean.getSmsPool(); |
||||
Map<String, SmsTemplate> templatePool = contextBean.getTemplatePool(); |
||||
Sms smsCached = smsPool.get(tenantId); |
||||
SmsTemplate template = templatePool.get(tenantId); |
||||
if (Func.hasEmpty(template, smsCached)) { |
||||
throw new ServiceException("SMS缓存读取失败!"); |
||||
} |
||||
|
||||
} |
||||
} |
@ -0,0 +1,58 @@
|
||||
/* |
||||
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without |
||||
* modification, are permitted provided that the following conditions are met: |
||||
* |
||||
* Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* Redistributions in binary form must reproduce the above copyright |
||||
* notice, this list of conditions and the following disclaimer in the |
||||
* documentation and/or other materials provided with the distribution. |
||||
* Neither the name of the dreamlu.net developer nor the names of its |
||||
* contributors may be used to endorse or promote products derived from |
||||
* this software without specific prior written permission. |
||||
* Author: Chill 庄骞 (smallchill@163.com) |
||||
*/ |
||||
package org.springblade.resource.rule.sms; |
||||
|
||||
import com.yomahub.liteflow.annotation.LiteflowComponent; |
||||
import com.yomahub.liteflow.core.NodeComponent; |
||||
import org.springblade.core.log.exception.ServiceException; |
||||
import org.springblade.core.sms.SmsTemplate; |
||||
import org.springblade.core.tool.utils.Func; |
||||
import org.springblade.resource.entity.Sms; |
||||
import org.springblade.resource.rule.context.SmsContext; |
||||
|
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* Sms后置处理 |
||||
* |
||||
* @author Chill |
||||
*/ |
||||
@LiteflowComponent(id = "finallySmsRule", name = "SMS构建后置处理") |
||||
public class FinallySmsRule extends NodeComponent { |
||||
@Override |
||||
public void process() throws Exception { |
||||
String tenantId = this.getRequestData(); |
||||
SmsContext contextBean = this.getContextBean(SmsContext.class); |
||||
Map<String, Sms> smsPool = contextBean.getSmsPool(); |
||||
Map<String, SmsTemplate> templatePool = contextBean.getTemplatePool(); |
||||
|
||||
if (contextBean.getIsCached()) { |
||||
SmsTemplate template = templatePool.get(tenantId); |
||||
contextBean.setSmsTemplate(template); |
||||
} else { |
||||
Sms sms = contextBean.getSms(); |
||||
SmsTemplate template = contextBean.getSmsTemplate(); |
||||
if (Func.hasEmpty(template, sms)) { |
||||
throw new ServiceException("SMS接口读取失败!"); |
||||
} else { |
||||
templatePool.put(tenantId, template); |
||||
smsPool.put(tenantId, sms); |
||||
} |
||||
} |
||||
|
||||
} |
||||
} |
@ -0,0 +1,52 @@
|
||||
/* |
||||
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without |
||||
* modification, are permitted provided that the following conditions are met: |
||||
* |
||||
* Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* Redistributions in binary form must reproduce the above copyright |
||||
* notice, this list of conditions and the following disclaimer in the |
||||
* documentation and/or other materials provided with the distribution. |
||||
* Neither the name of the dreamlu.net developer nor the names of its |
||||
* contributors may be used to endorse or promote products derived from |
||||
* this software without specific prior written permission. |
||||
* Author: Chill 庄骞 (smallchill@163.com) |
||||
*/ |
||||
package org.springblade.resource.rule.sms; |
||||
|
||||
import com.yomahub.liteflow.annotation.LiteflowComponent; |
||||
import com.yomahub.liteflow.core.NodeComponent; |
||||
import org.springblade.core.sms.SmsTemplate; |
||||
import org.springblade.core.tool.utils.Func; |
||||
import org.springblade.resource.entity.Sms; |
||||
import org.springblade.resource.rule.context.SmsContext; |
||||
|
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* Sms前置处理 |
||||
* |
||||
* @author Chill |
||||
*/ |
||||
@LiteflowComponent(id = "preSmsRule", name = "SMS构建前置处理") |
||||
public class PreSmsRule extends NodeComponent { |
||||
@Override |
||||
public void process() throws Exception { |
||||
String tenantId = this.getRequestData(); |
||||
SmsContext contextBean = this.getContextBean(SmsContext.class); |
||||
Map<String, Sms> smsPool = contextBean.getSmsPool(); |
||||
Map<String, SmsTemplate> templatePool = contextBean.getTemplatePool(); |
||||
Sms sms = contextBean.getSms(); |
||||
Sms smsCached = smsPool.get(tenantId); |
||||
SmsTemplate template = templatePool.get(tenantId); |
||||
// 若为空或者不一致,则重新加载
|
||||
if (Func.hasEmpty(template, smsCached) || !sms.getTemplateId().equals(smsCached.getTemplateId()) || !sms.getAccessKey().equals(smsCached.getAccessKey())) { |
||||
contextBean.setIsCached(Boolean.FALSE); |
||||
} else { |
||||
contextBean.setIsCached(Boolean.TRUE); |
||||
} |
||||
} |
||||
|
||||
} |
@ -0,0 +1,53 @@
|
||||
/* |
||||
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without |
||||
* modification, are permitted provided that the following conditions are met: |
||||
* |
||||
* Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* Redistributions in binary form must reproduce the above copyright |
||||
* notice, this list of conditions and the following disclaimer in the |
||||
* documentation and/or other materials provided with the distribution. |
||||
* Neither the name of the dreamlu.net developer nor the names of its |
||||
* contributors may be used to endorse or promote products derived from |
||||
* this software without specific prior written permission. |
||||
* Author: Chill 庄骞 (smallchill@163.com) |
||||
*/ |
||||
package org.springblade.resource.rule.sms; |
||||
|
||||
import com.yomahub.liteflow.annotation.LiteflowComponent; |
||||
import com.yomahub.liteflow.core.NodeSwitchComponent; |
||||
import org.springblade.core.log.exception.ServiceException; |
||||
import org.springblade.core.sms.enums.SmsEnum; |
||||
import org.springblade.resource.entity.Sms; |
||||
import org.springblade.resource.rule.context.SmsContext; |
||||
|
||||
/** |
||||
* Sms构建判断 |
||||
* |
||||
* @author Chill |
||||
*/ |
||||
@LiteflowComponent(id = "smsBuildRule", name = "SMS构建条件判断") |
||||
public class SmsBuildRule extends NodeSwitchComponent { |
||||
|
||||
@Override |
||||
public String processSwitch() { |
||||
SmsContext contextBean = this.getContextBean(SmsContext.class); |
||||
Sms sms = contextBean.getSms(); |
||||
|
||||
if (contextBean.getIsCached()) { |
||||
return "cacheSmsRule"; |
||||
} else if (sms.getCategory() == SmsEnum.YUNPIAN.getCategory()) { |
||||
return "yunpianSmsRule"; |
||||
} else if (sms.getCategory() == SmsEnum.QINIU.getCategory()) { |
||||
return "qiniuSmsRule"; |
||||
} else if (sms.getCategory() == SmsEnum.ALI.getCategory()) { |
||||
return "aliSmsRule"; |
||||
} else if (sms.getCategory() == SmsEnum.TENCENT.getCategory()) { |
||||
return "tencentSmsRule"; |
||||
} |
||||
|
||||
throw new ServiceException("未找到SMS配置"); |
||||
} |
||||
} |
After Width: | Height: | Size: 229 KiB |
@ -0,0 +1,24 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<flow> |
||||
<chain name="ossChain"> |
||||
THEN( |
||||
preOssRule, |
||||
SWITCH(ossCacheRule).TO( |
||||
ossReadRule, |
||||
THEN( |
||||
ossDataRule, |
||||
SWITCH(ossBuildRule).TO( |
||||
aliOssRule, |
||||
amazonS3Rule, |
||||
huaweiObsRule, |
||||
minioRule, |
||||
qiniuOssRule, |
||||
tencentCosRule |
||||
), |
||||
ossTemplateRule |
||||
).id("ossNewRule") |
||||
), |
||||
finallyOssRule |
||||
); |
||||
</chain> |
||||
</flow> |
After Width: | Height: | Size: 139 KiB |
@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<flow> |
||||
<chain name="smsChain"> |
||||
THEN( |
||||
preSmsRule, |
||||
SWITCH(smsBuildRule).TO( |
||||
aliSmsRule, |
||||
qiniuSmsRule, |
||||
tencentSmsRule, |
||||
yunpianSmsRule, |
||||
cacheSmsRule |
||||
), |
||||
finallySmsRule |
||||
); |
||||
</chain> |
||||
</flow> |
@ -0,0 +1,91 @@
|
||||
/* |
||||
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without |
||||
* modification, are permitted provided that the following conditions are met: |
||||
* |
||||
* Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* Redistributions in binary form must reproduce the above copyright |
||||
* notice, this list of conditions and the following disclaimer in the |
||||
* documentation and/or other materials provided with the distribution. |
||||
* Neither the name of the dreamlu.net developer nor the names of its |
||||
* contributors may be used to endorse or promote products derived from |
||||
* this software without specific prior written permission. |
||||
* Author: Chill 庄骞 (smallchill@163.com) |
||||
*/ |
||||
package org.springblade.system.rule; |
||||
|
||||
import lombok.Data; |
||||
import org.springblade.core.tenant.TenantId; |
||||
import org.springblade.system.entity.*; |
||||
import org.springblade.system.service.IDictBizService; |
||||
import org.springblade.system.service.IMenuService; |
||||
import org.springblade.system.service.ITenantService; |
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* 租户上下文 |
||||
* |
||||
* @author Chill |
||||
*/ |
||||
@Data |
||||
public class TenantContext { |
||||
|
||||
/** |
||||
* 菜单业务 |
||||
*/ |
||||
private IMenuService menuService; |
||||
|
||||
/** |
||||
* 字典业务 |
||||
*/ |
||||
private IDictBizService dictBizService; |
||||
|
||||
/** |
||||
* 租户业务 |
||||
*/ |
||||
private ITenantService tenantService; |
||||
|
||||
/** |
||||
* 租户ID生成器 |
||||
*/ |
||||
private TenantId tenantIdGenerator; |
||||
|
||||
/** |
||||
* 租户 |
||||
*/ |
||||
private Tenant tenant; |
||||
|
||||
/** |
||||
* 角色 |
||||
*/ |
||||
private Role role; |
||||
|
||||
/** |
||||
* 角色菜单合集 |
||||
*/ |
||||
private List<RoleMenu> roleMenuList; |
||||
|
||||
/** |
||||
* 机构 |
||||
*/ |
||||
private Dept dept; |
||||
|
||||
/** |
||||
* 岗位 |
||||
*/ |
||||
private Post post; |
||||
|
||||
/** |
||||
* 业务字典合集 |
||||
*/ |
||||
private List<DictBiz> dictBizList; |
||||
|
||||
/** |
||||
* 用户 |
||||
*/ |
||||
private User user; |
||||
|
||||
} |
@ -0,0 +1,53 @@
|
||||
/* |
||||
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without |
||||
* modification, are permitted provided that the following conditions are met: |
||||
* |
||||
* Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* Redistributions in binary form must reproduce the above copyright |
||||
* notice, this list of conditions and the following disclaimer in the |
||||
* documentation and/or other materials provided with the distribution. |
||||
* Neither the name of the dreamlu.net developer nor the names of its |
||||
* contributors may be used to endorse or promote products derived from |
||||
* this software without specific prior written permission. |
||||
* Author: Chill 庄骞 (smallchill@163.com) |
||||
*/ |
||||
package org.springblade.system.rule; |
||||
|
||||
import com.yomahub.liteflow.annotation.LiteflowComponent; |
||||
import com.yomahub.liteflow.core.NodeComponent; |
||||
import org.springblade.core.tool.constant.BladeConstant; |
||||
import org.springblade.system.entity.Dept; |
||||
import org.springblade.system.entity.Tenant; |
||||
|
||||
/** |
||||
* 租户机构构建 |
||||
* |
||||
* @author Chill |
||||
*/ |
||||
@LiteflowComponent(id = "tenantDeptRule", name = "租户机构构建") |
||||
public class TenantDeptRule extends NodeComponent { |
||||
@Override |
||||
public void process() throws Exception { |
||||
// 获取上下文
|
||||
TenantContext contextBean = this.getFirstContextBean(); |
||||
Tenant tenant = contextBean.getTenant(); |
||||
|
||||
// 新建租户对应的默认部门
|
||||
Dept dept = new Dept(); |
||||
dept.setTenantId(tenant.getTenantId()); |
||||
dept.setParentId(BladeConstant.TOP_PARENT_ID); |
||||
dept.setAncestors(String.valueOf(BladeConstant.TOP_PARENT_ID)); |
||||
dept.setDeptName(tenant.getTenantName()); |
||||
dept.setFullName(tenant.getTenantName()); |
||||
dept.setDeptCategory(1); |
||||
dept.setSort(2); |
||||
dept.setIsDeleted(BladeConstant.DB_NOT_DELETED); |
||||
|
||||
// 设置上下文
|
||||
contextBean.setDept(dept); |
||||
|
||||
} |
||||
} |
@ -0,0 +1,81 @@
|
||||
/* |
||||
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without |
||||
* modification, are permitted provided that the following conditions are met: |
||||
* |
||||
* Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* Redistributions in binary form must reproduce the above copyright |
||||
* notice, this list of conditions and the following disclaimer in the |
||||
* documentation and/or other materials provided with the distribution. |
||||
* Neither the name of the dreamlu.net developer nor the names of its |
||||
* contributors may be used to endorse or promote products derived from |
||||
* this software without specific prior written permission. |
||||
* Author: Chill 庄骞 (smallchill@163.com) |
||||
*/ |
||||
package org.springblade.system.rule; |
||||
|
||||
import com.baomidou.mybatisplus.core.toolkit.IdWorker; |
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
||||
import com.yomahub.liteflow.annotation.LiteflowComponent; |
||||
import com.yomahub.liteflow.core.NodeComponent; |
||||
import org.springblade.core.tool.constant.BladeConstant; |
||||
import org.springblade.system.entity.DictBiz; |
||||
import org.springblade.system.entity.Tenant; |
||||
import org.springblade.system.service.IDictBizService; |
||||
|
||||
import java.util.LinkedList; |
||||
import java.util.List; |
||||
|
||||
/** |
||||
* 租户业务字典构建 |
||||
* |
||||
* @author Chill |
||||
*/ |
||||
@LiteflowComponent(id = "tenantDictBizRule", name = "租户业务字典构建") |
||||
public class TenantDictBizRule extends NodeComponent { |
||||
@Override |
||||
public void process() throws Exception { |
||||
// 获取上下文
|
||||
TenantContext contextBean = this.getFirstContextBean(); |
||||
Tenant tenant = contextBean.getTenant(); |
||||
IDictBizService dictBizService = contextBean.getDictBizService(); |
||||
|
||||
// 新建租户对应的默认业务字典
|
||||
LinkedList<DictBiz> dictBizs = new LinkedList<>(); |
||||
List<DictBiz> dictBizList = getDictBizs(dictBizService, tenant.getTenantId(), dictBizs); |
||||
|
||||
// 设置上下文
|
||||
contextBean.setDictBizList(dictBizList); |
||||
|
||||
} |
||||
|
||||
|
||||
private List<DictBiz> getDictBizs(IDictBizService dictBizService, String tenantId, LinkedList<DictBiz> dictBizs) { |
||||
List<DictBiz> dictBizList = dictBizService.list(Wrappers.<DictBiz>query().lambda().eq(DictBiz::getParentId, BladeConstant.TOP_PARENT_ID).eq(DictBiz::getIsDeleted, BladeConstant.DB_NOT_DELETED)); |
||||
dictBizList.forEach(dictBiz -> { |
||||
Long oldParentId = dictBiz.getId(); |
||||
Long newParentId = IdWorker.getId(); |
||||
dictBiz.setId(newParentId); |
||||
dictBiz.setTenantId(tenantId); |
||||
dictBizs.add(dictBiz); |
||||
recursionDictBiz(dictBizService, tenantId, oldParentId, newParentId, dictBizs); |
||||
}); |
||||
return dictBizs; |
||||
} |
||||
|
||||
private void recursionDictBiz(IDictBizService dictBizService, String tenantId, Long oldParentId, Long newParentId, LinkedList<DictBiz> dictBizs) { |
||||
List<DictBiz> dictBizList = dictBizService.list(Wrappers.<DictBiz>query().lambda().eq(DictBiz::getParentId, oldParentId).eq(DictBiz::getIsDeleted, BladeConstant.DB_NOT_DELETED)); |
||||
dictBizList.forEach(dictBiz -> { |
||||
Long oldSubParentId = dictBiz.getId(); |
||||
Long newSubParentId = IdWorker.getId(); |
||||
dictBiz.setId(newSubParentId); |
||||
dictBiz.setTenantId(tenantId); |
||||
dictBiz.setParentId(newParentId); |
||||
dictBizs.add(dictBiz); |
||||
recursionDictBiz(dictBizService, tenantId, oldSubParentId, newSubParentId, dictBizs); |
||||
}); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,49 @@
|
||||
/* |
||||
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without |
||||
* modification, are permitted provided that the following conditions are met: |
||||
* |
||||
* Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* Redistributions in binary form must reproduce the above copyright |
||||
* notice, this list of conditions and the following disclaimer in the |
||||
* documentation and/or other materials provided with the distribution. |
||||
* Neither the name of the dreamlu.net developer nor the names of its |
||||
* contributors may be used to endorse or promote products derived from |
||||
* this software without specific prior written permission. |
||||
* Author: Chill 庄骞 (smallchill@163.com) |
||||
*/ |
||||
package org.springblade.system.rule; |
||||
|
||||
import com.yomahub.liteflow.annotation.LiteflowComponent; |
||||
import com.yomahub.liteflow.core.NodeComponent; |
||||
import org.springblade.system.entity.Post; |
||||
import org.springblade.system.entity.Tenant; |
||||
|
||||
/** |
||||
* 租户岗位构建 |
||||
* |
||||
* @author Chill |
||||
*/ |
||||
@LiteflowComponent(id = "tenantPostRule", name = "租户岗位构建") |
||||
public class TenantPostRule extends NodeComponent { |
||||
@Override |
||||
public void process() throws Exception { |
||||
// 获取上下文
|
||||
TenantContext contextBean = this.getFirstContextBean(); |
||||
Tenant tenant = contextBean.getTenant(); |
||||
|
||||
// 新建租户对应的默认岗位
|
||||
Post post = new Post(); |
||||
post.setTenantId(tenant.getTenantId()); |
||||
post.setCategory(1); |
||||
post.setPostCode("ceo"); |
||||
post.setPostName("首席执行官"); |
||||
post.setSort(1); |
||||
|
||||
// 设置上下文
|
||||
contextBean.setPost(post); |
||||
|
||||
} |
||||
} |
@ -0,0 +1,79 @@
|
||||
/* |
||||
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without |
||||
* modification, are permitted provided that the following conditions are met: |
||||
* |
||||
* Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* Redistributions in binary form must reproduce the above copyright |
||||
* notice, this list of conditions and the following disclaimer in the |
||||
* documentation and/or other materials provided with the distribution. |
||||
* Neither the name of the dreamlu.net developer nor the names of its |
||||
* contributors may be used to endorse or promote products derived from |
||||
* this software without specific prior written permission. |
||||
* Author: Chill 庄骞 (smallchill@163.com) |
||||
*/ |
||||
package org.springblade.system.rule; |
||||
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
||||
import com.yomahub.liteflow.annotation.LiteflowComponent; |
||||
import com.yomahub.liteflow.core.NodeComponent; |
||||
import org.springblade.system.cache.ParamCache; |
||||
import org.springblade.core.tool.constant.BladeConstant; |
||||
import org.springblade.core.tool.utils.Func; |
||||
import org.springblade.system.entity.Menu; |
||||
import org.springblade.system.entity.RoleMenu; |
||||
import org.springblade.system.service.IMenuService; |
||||
|
||||
import java.util.ArrayList; |
||||
import java.util.LinkedList; |
||||
import java.util.List; |
||||
|
||||
import static org.springblade.common.constant.TenantConstant.ACCOUNT_MENU_CODE_KEY; |
||||
import static org.springblade.common.constant.TenantConstant.MENU_CODES; |
||||
|
||||
/** |
||||
* 租户角色菜单构建 |
||||
* |
||||
* @author Chill |
||||
*/ |
||||
@LiteflowComponent(id = "tenantRoleMenuRule", name = "租户角色菜单构建") |
||||
public class TenantRoleMenuRule extends NodeComponent { |
||||
@Override |
||||
public void process() throws Exception { |
||||
// 获取上下文
|
||||
TenantContext contextBean = this.getFirstContextBean(); |
||||
IMenuService menuService = contextBean.getMenuService(); |
||||
// 新建租户对应的角色菜单权限
|
||||
LinkedList<Menu> userMenus = new LinkedList<>(); |
||||
// 获取参数配置的默认菜单集合,逗号隔开
|
||||
List<String> menuCodes = Func.toStrList(ParamCache.getValue(ACCOUNT_MENU_CODE_KEY)); |
||||
List<Menu> menus = getMenus(menuService, (!menuCodes.isEmpty() ? menuCodes : MENU_CODES), userMenus); |
||||
List<RoleMenu> roleMenuList = new ArrayList<>(); |
||||
menus.forEach(menu -> { |
||||
RoleMenu roleMenu = new RoleMenu(); |
||||
roleMenu.setMenuId(menu.getId()); |
||||
roleMenuList.add(roleMenu); |
||||
}); |
||||
// 设置上下文
|
||||
contextBean.setRoleMenuList(roleMenuList); |
||||
} |
||||
|
||||
private List<Menu> getMenus(IMenuService menuService, List<String> codes, LinkedList<Menu> menus) { |
||||
codes.forEach(code -> { |
||||
Menu menu = menuService.getOne(Wrappers.<Menu>query().lambda().eq(Menu::getCode, code).eq(Menu::getIsDeleted, BladeConstant.DB_NOT_DELETED)); |
||||
if (menu != null) { |
||||
menus.add(menu); |
||||
recursionMenu(menuService, menu.getId(), menus); |
||||
} |
||||
}); |
||||
return menus; |
||||
} |
||||
|
||||
private void recursionMenu(IMenuService menuService, Long parentId, LinkedList<Menu> menus) { |
||||
List<Menu> menuList = menuService.list(Wrappers.<Menu>query().lambda().eq(Menu::getParentId, parentId).eq(Menu::getIsDeleted, BladeConstant.DB_NOT_DELETED)); |
||||
menus.addAll(menuList); |
||||
menuList.forEach(menu -> recursionMenu(menuService, menu.getId(), menus)); |
||||
} |
||||
} |
@ -0,0 +1,48 @@
|
||||
/* |
||||
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without |
||||
* modification, are permitted provided that the following conditions are met: |
||||
* |
||||
* Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* Redistributions in binary form must reproduce the above copyright |
||||
* notice, this list of conditions and the following disclaimer in the |
||||
* documentation and/or other materials provided with the distribution. |
||||
* Neither the name of the dreamlu.net developer nor the names of its |
||||
* contributors may be used to endorse or promote products derived from |
||||
* this software without specific prior written permission. |
||||
* Author: Chill 庄骞 (smallchill@163.com) |
||||
*/ |
||||
package org.springblade.system.rule; |
||||
|
||||
import com.yomahub.liteflow.annotation.LiteflowComponent; |
||||
import com.yomahub.liteflow.core.NodeComponent; |
||||
import org.springblade.core.tool.constant.BladeConstant; |
||||
import org.springblade.system.entity.Role; |
||||
import org.springblade.system.entity.Tenant; |
||||
|
||||
/** |
||||
* 租户角色构建 |
||||
* |
||||
* @author Chill |
||||
*/ |
||||
@LiteflowComponent(id = "tenantRoleRule", name = "租户角色构建") |
||||
public class TenantRoleRule extends NodeComponent { |
||||
@Override |
||||
public void process() throws Exception { |
||||
// 获取上下文
|
||||
TenantContext contextBean = this.getFirstContextBean(); |
||||
Tenant tenant = contextBean.getTenant(); |
||||
// 新建租户对应的默认角色
|
||||
Role role = new Role(); |
||||
role.setTenantId(tenant.getTenantId()); |
||||
role.setParentId(BladeConstant.TOP_PARENT_ID); |
||||
role.setRoleName("管理员"); |
||||
role.setRoleAlias("admin"); |
||||
role.setSort(2); |
||||
role.setIsDeleted(BladeConstant.DB_NOT_DELETED); |
||||
// 设置上下文
|
||||
contextBean.setRole(role); |
||||
} |
||||
} |
@ -0,0 +1,71 @@
|
||||
/* |
||||
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without |
||||
* modification, are permitted provided that the following conditions are met: |
||||
* |
||||
* Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* Redistributions in binary form must reproduce the above copyright |
||||
* notice, this list of conditions and the following disclaimer in the |
||||
* documentation and/or other materials provided with the distribution. |
||||
* Neither the name of the dreamlu.net developer nor the names of its |
||||
* contributors may be used to endorse or promote products derived from |
||||
* this software without specific prior written permission. |
||||
* Author: Chill 庄骞 (smallchill@163.com) |
||||
*/ |
||||
package org.springblade.system.rule; |
||||
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
||||
import com.yomahub.liteflow.annotation.LiteflowComponent; |
||||
import com.yomahub.liteflow.core.NodeComponent; |
||||
import org.springblade.system.cache.ParamCache; |
||||
import org.springblade.core.tenant.TenantId; |
||||
import org.springblade.core.tool.constant.BladeConstant; |
||||
import org.springblade.core.tool.utils.Func; |
||||
import org.springblade.system.entity.Tenant; |
||||
import org.springblade.system.service.ITenantService; |
||||
|
||||
import java.util.List; |
||||
import java.util.stream.Collectors; |
||||
|
||||
import static org.springblade.common.constant.TenantConstant.ACCOUNT_NUMBER_KEY; |
||||
import static org.springblade.common.constant.TenantConstant.DEFAULT_ACCOUNT_NUMBER; |
||||
|
||||
/** |
||||
* 租户构建 |
||||
* |
||||
* @author Chill |
||||
*/ |
||||
@LiteflowComponent(id = "tenantRule", name = "租户构建") |
||||
public class TenantRule extends NodeComponent { |
||||
@Override |
||||
public void process() throws Exception { |
||||
// 获取上下文
|
||||
TenantContext contextBean = this.getFirstContextBean(); |
||||
Tenant tenant = contextBean.getTenant(); |
||||
TenantId tenantIdGenerator = contextBean.getTenantIdGenerator(); |
||||
ITenantService tenantService = contextBean.getTenantService(); |
||||
|
||||
// 获取租户ID
|
||||
List<Tenant> tenants = tenantService.list(Wrappers.<Tenant>query().lambda().eq(Tenant::getIsDeleted, BladeConstant.DB_NOT_DELETED)); |
||||
List<String> codes = tenants.stream().map(Tenant::getTenantId).collect(Collectors.toList()); |
||||
String tenantId = getTenantId(tenantIdGenerator, codes); |
||||
tenant.setTenantId(tenantId); |
||||
// 获取参数配置的账号额度
|
||||
int accountNumber = Func.toInt(ParamCache.getValue(ACCOUNT_NUMBER_KEY), DEFAULT_ACCOUNT_NUMBER); |
||||
tenant.setAccountNumber(accountNumber); |
||||
|
||||
// 设置上下文
|
||||
contextBean.setTenant(tenant); |
||||
|
||||
} |
||||
|
||||
private String getTenantId(TenantId tenantIdGenerator, List<String> codes) { |
||||
String code = tenantIdGenerator.generate(); |
||||
if (codes.contains(code)) { |
||||
return getTenantId(tenantIdGenerator, codes); |
||||
} |
||||
return code; |
||||
} |
||||
} |
@ -0,0 +1,63 @@
|
||||
/* |
||||
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without |
||||
* modification, are permitted provided that the following conditions are met: |
||||
* |
||||
* Redistributions of source code must retain the above copyright notice, |
||||
* this list of conditions and the following disclaimer. |
||||
* Redistributions in binary form must reproduce the above copyright |
||||
* notice, this list of conditions and the following disclaimer in the |
||||
* documentation and/or other materials provided with the distribution. |
||||
* Neither the name of the dreamlu.net developer nor the names of its |
||||
* contributors may be used to endorse or promote products derived from |
||||
* this software without specific prior written permission. |
||||
* Author: Chill 庄骞 (smallchill@163.com) |
||||
*/ |
||||
package org.springblade.system.rule; |
||||
|
||||
import com.yomahub.liteflow.annotation.LiteflowComponent; |
||||
import com.yomahub.liteflow.core.NodeComponent; |
||||
import org.springblade.core.tool.constant.BladeConstant; |
||||
import org.springblade.core.tool.utils.Func; |
||||
import org.springblade.system.cache.ParamCache; |
||||
import org.springblade.system.entity.Tenant; |
||||
import org.springblade.system.entity.User; |
||||
import org.springblade.system.enums.UserEnum; |
||||
|
||||
import java.util.Date; |
||||
|
||||
import static org.springblade.common.constant.TenantConstant.DEFAULT_PASSWORD; |
||||
import static org.springblade.common.constant.TenantConstant.PASSWORD_KEY; |
||||
|
||||
/** |
||||
* 租户用户构建 |
||||
* |
||||
* @author Chill |
||||
*/ |
||||
@LiteflowComponent(id = "tenantUserRule", name = "租户用户构建") |
||||
public class TenantUserRule extends NodeComponent { |
||||
@Override |
||||
public void process() throws Exception { |
||||
// 获取上下文
|
||||
TenantContext contextBean = this.getFirstContextBean(); |
||||
Tenant tenant = contextBean.getTenant(); |
||||
|
||||
// 新建租户对应的默认管理用户
|
||||
User user = new User(); |
||||
user.setTenantId(tenant.getTenantId()); |
||||
user.setName("admin"); |
||||
user.setRealName("admin"); |
||||
user.setAccount("admin"); |
||||
// 获取参数配置的密码
|
||||
String password = Func.toStr(ParamCache.getValue(PASSWORD_KEY), DEFAULT_PASSWORD); |
||||
user.setPassword(password); |
||||
user.setBirthday(new Date()); |
||||
user.setSex(1); |
||||
user.setUserType(UserEnum.WEB.getCategory()); |
||||
user.setIsDeleted(BladeConstant.DB_NOT_DELETED); |
||||
|
||||
// 设置上下文
|
||||
contextBean.setUser(user); |
||||
} |
||||
} |
After Width: | Height: | Size: 105 KiB |
@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<flow> |
||||
<chain name="tenantChain"> |
||||
THEN( |
||||
tenantRule, |
||||
WHEN( |
||||
tenantRoleRule, |
||||
tenantRoleMenuRule, |
||||
tenantDeptRule, |
||||
tenantPostRule, |
||||
tenantDictBizRule, |
||||
tenantUserRule |
||||
) |
||||
); |
||||
</chain> |
||||
</flow> |
@ -1,2 +1,2 @@
|
||||
REGISTER=192.168.0.188/blade |
||||
TAG=3.1.1.RELEASE |
||||
TAG=3.2.0.RELEASE |
||||
|
@ -0,0 +1,48 @@
|
||||
version: '3.3' |
||||
services: |
||||
elasticsearch: |
||||
image: docker.elastic.co/elasticsearch/elasticsearch:7.17.11 |
||||
container_name: elasticsearch |
||||
restart: always |
||||
ports: |
||||
- 9200:9200 |
||||
- 9300:9300 |
||||
environment: |
||||
- discovery.type=single-node |
||||
- TZ=Asia/Shanghai |
||||
- bootstrap.memory_lock=true |
||||
- "ES_JAVA_OPTS=-Xms1024m -Xmx1024m" |
||||
ulimits: |
||||
memlock: |
||||
soft: -1 |
||||
hard: -1 |
||||
skywalking-oap: |
||||
image: docker.io/apache/skywalking-oap-server:9.5.0 |
||||
container_name: skywalking-oap |
||||
depends_on: |
||||
- elasticsearch |
||||
restart: always |
||||
ports: |
||||
- 11800:11800 |
||||
- 12800:12800 |
||||
environment: |
||||
SW_CORE_RECORD_DATA_TTL: 15 |
||||
SW_CORE_METRICS_DATA_TTL: 15 |
||||
SW_STORAGE: elasticsearch |
||||
SW_STORAGE_ES_CLUSTER_NODES: elasticsearch:9200 |
||||
SW_ENABLE_UPDATE_UI_TEMPLATE: "true" |
||||
TZ: Asia/Shanghai |
||||
JAVA_OPTS: "-Xms2048m -Xmx2048m" |
||||
skywalking-ui: |
||||
image: docker.io/apache/skywalking-ui:9.5.0 |
||||
container_name: skywalking-ui |
||||
depends_on: |
||||
- skywalking-oap |
||||
links: |
||||
- skywalking-oap |
||||
restart: always |
||||
ports: |
||||
- 8880:8080 |
||||
environment: |
||||
SW_OAP_ADDRESS: http://skywalking-oap:12800 |
||||
|
Loading…
Reference in new issue