init
This commit is contained in:
15
blade-ops/blade-resource/Dockerfile
Normal file
15
blade-ops/blade-resource/Dockerfile
Normal file
@@ -0,0 +1,15 @@
|
||||
FROM bladex/alpine-java:openjdk17_cn_slim
|
||||
|
||||
LABEL maintainer="bladejava@qq.com"
|
||||
|
||||
RUN mkdir -p /blade/resource
|
||||
|
||||
WORKDIR /blade/resource
|
||||
|
||||
EXPOSE 8010
|
||||
|
||||
COPY ./target/blade-resource.jar ./app.jar
|
||||
|
||||
ENTRYPOINT ["java", "--add-opens", "java.base/java.lang=ALL-UNNAMED", "--add-opens", "java.base/java.lang.reflect=ALL-UNNAMED", "-Djava.security.egd=file:/dev/./urandom", "-jar", "app.jar"]
|
||||
|
||||
CMD ["--spring.profiles.active=test"]
|
||||
131
blade-ops/blade-resource/pom.xml
Normal file
131
blade-ops/blade-resource/pom.xml
Normal file
@@ -0,0 +1,131 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>blade-ops</artifactId>
|
||||
<groupId>org.springblade</groupId>
|
||||
<version>${revision}</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>blade-resource</artifactId>
|
||||
<name>${project.artifactId}</name>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springblade</groupId>
|
||||
<artifactId>blade-common</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springblade</groupId>
|
||||
<artifactId>blade-core-boot</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springblade</groupId>
|
||||
<artifactId>blade-starter-swagger</artifactId>
|
||||
</dependency>
|
||||
<!--Oss-->
|
||||
<dependency>
|
||||
<groupId>org.springblade</groupId>
|
||||
<artifactId>blade-starter-oss</artifactId>
|
||||
</dependency>
|
||||
<!--Sms-->
|
||||
<dependency>
|
||||
<groupId>org.springblade</groupId>
|
||||
<artifactId>blade-starter-sms</artifactId>
|
||||
</dependency>
|
||||
<!--Aws S3-->
|
||||
<dependency>
|
||||
<groupId>com.amazonaws</groupId>
|
||||
<artifactId>aws-java-sdk-s3</artifactId>
|
||||
</dependency>
|
||||
<!--MinIO-->
|
||||
<dependency>
|
||||
<groupId>io.minio</groupId>
|
||||
<artifactId>minio</artifactId>
|
||||
</dependency>
|
||||
<!--Alioss-->
|
||||
<dependency>
|
||||
<groupId>com.aliyun.oss</groupId>
|
||||
<artifactId>aliyun-sdk-oss</artifactId>
|
||||
</dependency>
|
||||
<!--AliSms-->
|
||||
<dependency>
|
||||
<groupId>com.aliyun</groupId>
|
||||
<artifactId>aliyun-java-sdk-core</artifactId>
|
||||
</dependency>
|
||||
<!--华为云Obs-->
|
||||
<dependency>
|
||||
<groupId>com.huaweicloud</groupId>
|
||||
<artifactId>esdk-obs-java</artifactId>
|
||||
</dependency>
|
||||
<!--腾讯COS-->
|
||||
<dependency>
|
||||
<groupId>com.qcloud</groupId>
|
||||
<artifactId>cos_api</artifactId>
|
||||
</dependency>
|
||||
<!--腾讯SMS-->
|
||||
<dependency>
|
||||
<groupId>com.tencentcloudapi</groupId>
|
||||
<artifactId>tencentcloud-sdk-java-sms</artifactId>
|
||||
</dependency>
|
||||
<!--QiNiu-->
|
||||
<dependency>
|
||||
<groupId>com.qiniu</groupId>
|
||||
<artifactId>qiniu-java-sdk</artifactId>
|
||||
</dependency>
|
||||
<!--YunPian-->
|
||||
<dependency>
|
||||
<groupId>com.yunpian.sdk</groupId>
|
||||
<artifactId>yunpian-java-sdk</artifactId>
|
||||
</dependency>
|
||||
<!--literule-->
|
||||
<dependency>
|
||||
<groupId>org.springblade</groupId>
|
||||
<artifactId>blade-starter-literule</artifactId>
|
||||
</dependency>
|
||||
<!--api-->
|
||||
<dependency>
|
||||
<groupId>org.springblade</groupId>
|
||||
<artifactId>blade-resource-api</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springblade</groupId>
|
||||
<artifactId>blade-dict-api</artifactId>
|
||||
</dependency>
|
||||
<!-- 多租户字段隔离模式 -->
|
||||
<dependency>
|
||||
<groupId>org.springblade</groupId>
|
||||
<artifactId>blade-starter-tenant</artifactId>
|
||||
</dependency>
|
||||
<!-- 多租户数据库隔离模式则引入此配置 -->
|
||||
<!--<dependency>
|
||||
<groupId>org.springblade</groupId>
|
||||
<artifactId>blade-starter-tenant-dynamic</artifactId>
|
||||
</dependency>-->
|
||||
<!-- 集成sharding功能则引入此配置 -->
|
||||
<!--<dependency>
|
||||
<groupId>org.springblade</groupId>
|
||||
<artifactId>blade-starter-sharding</artifactId>
|
||||
</dependency>-->
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>io.fabric8</groupId>
|
||||
<artifactId>docker-maven-plugin</artifactId>
|
||||
<configuration>
|
||||
<skip>${docker.fabric.skip}</skip>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-antrun-plugin</artifactId>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
||||
@@ -0,0 +1,46 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.resource;
|
||||
|
||||
import org.springblade.core.cloud.client.BladeCloudApplication;
|
||||
import org.springblade.core.cloud.feign.EnableBladeFeign;
|
||||
import org.springblade.core.launch.BladeApplication;
|
||||
import org.springblade.core.launch.constant.AppConstant;
|
||||
|
||||
/**
|
||||
* 资源启动器
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
@BladeCloudApplication
|
||||
public class ResourceApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
BladeApplication.run(AppConstant.APPLICATION_RESOURCE_NAME, ResourceApplication.class, args);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,164 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.resource.builder;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springblade.core.cache.utils.CacheUtil;
|
||||
import org.springblade.core.literule.engine.RuleEngineExecutor;
|
||||
import org.springblade.core.literule.provider.LiteRuleResponse;
|
||||
import org.springblade.core.log.exception.ServiceException;
|
||||
import org.springblade.core.oss.OssTemplate;
|
||||
import org.springblade.core.oss.enums.OssEnum;
|
||||
import org.springblade.core.oss.enums.OssStatusEnum;
|
||||
import org.springblade.core.oss.props.OssProperties;
|
||||
import org.springblade.core.secure.utils.AuthUtil;
|
||||
import org.springblade.core.tool.utils.StringPool;
|
||||
import org.springblade.core.tool.utils.StringUtil;
|
||||
import org.springblade.core.tool.utils.WebUtil;
|
||||
import org.springblade.resource.pojo.entity.Oss;
|
||||
import org.springblade.resource.rule.context.OssContext;
|
||||
import org.springblade.resource.service.IOssService;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import static org.springblade.core.cache.constant.CacheConstant.RESOURCE_CACHE;
|
||||
import static org.springblade.resource.rule.constant.OssRuleConstant.OSS_CHAIN_ID;
|
||||
|
||||
/**
|
||||
* Oss云存储统一构建类
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
@AllArgsConstructor
|
||||
public class OssBuilder {
|
||||
|
||||
public static final String OSS_CODE = "oss:code:";
|
||||
public static final String OSS_PARAM_KEY = "code";
|
||||
|
||||
private final OssProperties ossProperties;
|
||||
private final IOssService ossService;
|
||||
private final RuleEngineExecutor ruleExecutor;
|
||||
|
||||
/**
|
||||
* OssTemplate配置缓存池
|
||||
*/
|
||||
private final Map<String, OssTemplate> templatePool = new ConcurrentHashMap<>();
|
||||
|
||||
/**
|
||||
* oss配置缓存池
|
||||
*/
|
||||
private final Map<String, Oss> ossPool = new ConcurrentHashMap<>();
|
||||
|
||||
/**
|
||||
* 获取template
|
||||
*
|
||||
* @return OssTemplate
|
||||
*/
|
||||
public OssTemplate template() {
|
||||
return template(StringPool.EMPTY);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取template
|
||||
*
|
||||
* @param code 资源编号
|
||||
* @return OssTemplate
|
||||
*/
|
||||
public OssTemplate template(String code) {
|
||||
String tenantId = AuthUtil.getTenantId();
|
||||
return template(tenantId, code);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取template
|
||||
*
|
||||
* @param tenantId 租户ID
|
||||
* @param code 资源编号
|
||||
* @return OssTemplate
|
||||
*/
|
||||
public OssTemplate template(String tenantId, String code) {
|
||||
Oss oss = getOss(tenantId, code);
|
||||
|
||||
OssContext ossContext = new OssContext();
|
||||
ossContext.setOss(oss);
|
||||
ossContext.setOssProperties(ossProperties);
|
||||
ossContext.setOssPool(ossPool);
|
||||
ossContext.setTemplatePool(templatePool);
|
||||
|
||||
LiteRuleResponse<OssContext> resp = ruleExecutor.execute(OSS_CHAIN_ID, tenantId, ossContext);
|
||||
if (resp.isSuccess()) {
|
||||
OssContext contextBean = resp.getContext();
|
||||
return contextBean.getOssTemplate();
|
||||
} else {
|
||||
throw new ServiceException("未获取到对应的对象存储配置");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取对象存储实体
|
||||
*
|
||||
* @param tenantId 租户ID
|
||||
* @return Oss
|
||||
*/
|
||||
public Oss getOss(String tenantId, String code) {
|
||||
String key = tenantId;
|
||||
LambdaQueryWrapper<Oss> lqw = Wrappers.<Oss>query().lambda().eq(Oss::getTenantId, tenantId);
|
||||
// 获取传参的资源编号并查询,若有则返回,若没有则调启用的配置
|
||||
String ossCode = StringUtil.isBlank(code) ? WebUtil.getParameter(OSS_PARAM_KEY) : code;
|
||||
if (StringUtil.isNotBlank(ossCode)) {
|
||||
key = key.concat(StringPool.DASH).concat(ossCode);
|
||||
lqw.eq(Oss::getOssCode, ossCode);
|
||||
} else {
|
||||
lqw.eq(Oss::getStatus, OssStatusEnum.ENABLE.getNum());
|
||||
}
|
||||
Oss oss = CacheUtil.get(RESOURCE_CACHE, OSS_CODE, key, () -> {
|
||||
Oss o = ossService.getOne(lqw);
|
||||
// 若为空则调用默认配置
|
||||
if (o == null || o.getId() == null) {
|
||||
Oss defaultOss = new Oss();
|
||||
defaultOss.setId(0L);
|
||||
defaultOss.setCategory(OssEnum.of(ossProperties.getName()).getCategory());
|
||||
defaultOss.setEndpoint(ossProperties.getEndpoint());
|
||||
defaultOss.setTransformEndpoint(ossProperties.getTransformEndpoint());
|
||||
defaultOss.setBucketName(ossProperties.getBucketName());
|
||||
defaultOss.setAccessKey(ossProperties.getAccessKey());
|
||||
defaultOss.setSecretKey(ossProperties.getSecretKey());
|
||||
return defaultOss;
|
||||
} else {
|
||||
return o;
|
||||
}
|
||||
});
|
||||
if (oss == null || oss.getId() == null) {
|
||||
throw new ServiceException("未获取到对应的对象存储配置");
|
||||
} else {
|
||||
return oss;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,168 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.resource.builder;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springblade.core.cache.utils.CacheUtil;
|
||||
import org.springblade.core.literule.engine.RuleEngineExecutor;
|
||||
import org.springblade.core.literule.provider.LiteRuleResponse;
|
||||
import org.springblade.core.log.exception.ServiceException;
|
||||
import org.springblade.core.redis.cache.BladeRedis;
|
||||
import org.springblade.core.secure.utils.AuthUtil;
|
||||
import org.springblade.core.sms.SmsTemplate;
|
||||
import org.springblade.core.sms.enums.SmsEnum;
|
||||
import org.springblade.core.sms.enums.SmsStatusEnum;
|
||||
import org.springblade.core.sms.props.SmsProperties;
|
||||
import org.springblade.core.tool.utils.StringPool;
|
||||
import org.springblade.core.tool.utils.StringUtil;
|
||||
import org.springblade.core.tool.utils.WebUtil;
|
||||
import org.springblade.resource.pojo.entity.Sms;
|
||||
import org.springblade.resource.rule.context.SmsContext;
|
||||
import org.springblade.resource.service.ISmsService;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import static org.springblade.core.cache.constant.CacheConstant.RESOURCE_CACHE;
|
||||
import static org.springblade.resource.rule.constant.SmsRuleConstant.SMS_CHAIN_ID;
|
||||
|
||||
/**
|
||||
* Sms短信服务统一构建类
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
@AllArgsConstructor
|
||||
public class SmsBuilder {
|
||||
|
||||
public static final String SMS_CODE = "sms:code:";
|
||||
public static final String SMS_PARAM_KEY = "code";
|
||||
|
||||
private final SmsProperties smsProperties;
|
||||
private final ISmsService smsService;
|
||||
private final BladeRedis bladeRedis;
|
||||
private final RuleEngineExecutor ruleExecutor;
|
||||
|
||||
/**
|
||||
* SmsTemplate配置缓存池
|
||||
*/
|
||||
private final Map<String, SmsTemplate> templatePool = new ConcurrentHashMap<>();
|
||||
|
||||
/**
|
||||
* Sms配置缓存池
|
||||
*/
|
||||
private final Map<String, Sms> smsPool = new ConcurrentHashMap<>();
|
||||
|
||||
|
||||
/**
|
||||
* 获取template
|
||||
*
|
||||
* @return SmsTemplate
|
||||
*/
|
||||
public SmsTemplate template() {
|
||||
return template(StringPool.EMPTY);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取template
|
||||
*
|
||||
* @param code 资源编号
|
||||
* @return SmsTemplate
|
||||
*/
|
||||
public SmsTemplate template(String code) {
|
||||
String tenantId = AuthUtil.getTenantId();
|
||||
return template(tenantId, code);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取template
|
||||
*
|
||||
* @param tenantId 租户ID
|
||||
* @param code 资源编号
|
||||
* @return SmsTemplate
|
||||
*/
|
||||
public SmsTemplate template(String tenantId, String code) {
|
||||
Sms sms = getSms(tenantId, code);
|
||||
|
||||
SmsContext smsContext = new SmsContext();
|
||||
smsContext.setSms(sms);
|
||||
smsContext.setSmsProperties(smsProperties);
|
||||
smsContext.setSmsPool(smsPool);
|
||||
smsContext.setTemplatePool(templatePool);
|
||||
smsContext.setBladeRedis(bladeRedis);
|
||||
|
||||
LiteRuleResponse<SmsContext> resp = ruleExecutor.execute(SMS_CHAIN_ID, tenantId, smsContext);
|
||||
if (resp.isSuccess()) {
|
||||
SmsContext contextBean = resp.getContext();
|
||||
return contextBean.getSmsTemplate();
|
||||
} else {
|
||||
throw new ServiceException("未获取到对应的短信配置");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取短信实体
|
||||
*
|
||||
* @param tenantId 租户ID
|
||||
* @return Sms
|
||||
*/
|
||||
public Sms getSms(String tenantId, String code) {
|
||||
String key = tenantId;
|
||||
LambdaQueryWrapper<Sms> lqw = Wrappers.<Sms>query().lambda().eq(Sms::getTenantId, tenantId);
|
||||
// 获取传参的资源编号并查询,若有则返回,若没有则调启用的配置
|
||||
String smsCode = StringUtil.isBlank(code) ? WebUtil.getParameter(SMS_PARAM_KEY) : code;
|
||||
if (StringUtil.isNotBlank(smsCode)) {
|
||||
key = key.concat(StringPool.DASH).concat(smsCode);
|
||||
lqw.eq(Sms::getSmsCode, smsCode);
|
||||
} else {
|
||||
lqw.eq(Sms::getStatus, SmsStatusEnum.ENABLE.getNum());
|
||||
}
|
||||
Sms sms = CacheUtil.get(RESOURCE_CACHE, SMS_CODE, key, () -> {
|
||||
Sms s = smsService.getOne(lqw);
|
||||
// 若为空则调用默认配置
|
||||
if (s == null || s.getId() == null) {
|
||||
Sms defaultSms = new Sms();
|
||||
defaultSms.setId(0L);
|
||||
defaultSms.setTemplateId(smsProperties.getTemplateId());
|
||||
defaultSms.setRegionId(smsProperties.getRegionId());
|
||||
defaultSms.setCategory(SmsEnum.of(smsProperties.getName()).getCategory());
|
||||
defaultSms.setAccessKey(smsProperties.getAccessKey());
|
||||
defaultSms.setSecretKey(smsProperties.getSecretKey());
|
||||
defaultSms.setSignName(smsProperties.getSignName());
|
||||
return defaultSms;
|
||||
} else {
|
||||
return s;
|
||||
}
|
||||
});
|
||||
if (sms == null || sms.getId() == null) {
|
||||
throw new ServiceException("未获取到对应的短信配置");
|
||||
} else {
|
||||
return sms;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.resource.config;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springblade.core.literule.engine.RuleEngineExecutor;
|
||||
import org.springblade.core.oss.props.OssProperties;
|
||||
import org.springblade.resource.builder.OssBuilder;
|
||||
import org.springblade.resource.service.IOssService;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* Oss配置类
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
@AllArgsConstructor
|
||||
public class BladeOssConfiguration {
|
||||
|
||||
private final OssProperties ossProperties;
|
||||
|
||||
private final IOssService ossService;
|
||||
|
||||
private final RuleEngineExecutor ruleExecutor;
|
||||
|
||||
@Bean
|
||||
public OssBuilder ossBuilder() {
|
||||
return new OssBuilder(ossProperties, ossService, ruleExecutor);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.resource.config;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springblade.core.literule.engine.RuleEngineExecutor;
|
||||
import org.springblade.core.redis.cache.BladeRedis;
|
||||
import org.springblade.core.sms.props.SmsProperties;
|
||||
import org.springblade.resource.builder.SmsBuilder;
|
||||
import org.springblade.resource.service.ISmsService;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* Sms配置类
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
@AllArgsConstructor
|
||||
public class BladeSmsConfiguration {
|
||||
|
||||
private final SmsProperties smsProperties;
|
||||
|
||||
private final ISmsService smsService;
|
||||
|
||||
private final BladeRedis bladeRedis;
|
||||
|
||||
private final RuleEngineExecutor ruleExecutor;
|
||||
|
||||
@Bean
|
||||
public SmsBuilder smsBuilder() {
|
||||
return new SmsBuilder(smsProperties, smsService, bladeRedis, ruleExecutor);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,137 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.resource.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.validation.Valid;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springblade.core.boot.ctrl.BladeController;
|
||||
import org.springblade.core.mp.support.Condition;
|
||||
import org.springblade.core.mp.support.Query;
|
||||
import org.springblade.core.secure.annotation.IsAdmin;
|
||||
import org.springblade.core.tenant.annotation.NonDS;
|
||||
import org.springblade.core.tool.api.R;
|
||||
import org.springblade.core.tool.utils.Func;
|
||||
import org.springblade.resource.pojo.entity.Attach;
|
||||
import org.springblade.resource.pojo.vo.AttachVO;
|
||||
import org.springblade.resource.service.IAttachService;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
/**
|
||||
* 附件表 控制器
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
@NonDS
|
||||
@RestController
|
||||
@AllArgsConstructor
|
||||
@IsAdmin
|
||||
@RequestMapping("/attach")
|
||||
@Tag(name = "附件", description = "附件")
|
||||
public class AttachController extends BladeController {
|
||||
|
||||
private final IAttachService attachService;
|
||||
|
||||
/**
|
||||
* 详情
|
||||
*/
|
||||
@GetMapping("/detail")
|
||||
@ApiOperationSupport(order = 1)
|
||||
@Operation(summary = "详情", description = "传入attach")
|
||||
public R<Attach> detail(Attach attach) {
|
||||
Attach detail = attachService.getOne(Condition.getQueryWrapper(attach));
|
||||
return R.data(detail);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页 附件表
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
@ApiOperationSupport(order = 2)
|
||||
@Operation(summary = "分页", description = "传入attach")
|
||||
public R<IPage<Attach>> list(Attach attach, Query query) {
|
||||
IPage<Attach> pages = attachService.page(Condition.getPage(query), Condition.getQueryWrapper(attach));
|
||||
return R.data(pages);
|
||||
}
|
||||
|
||||
/**
|
||||
* 自定义分页 附件表
|
||||
*/
|
||||
@GetMapping("/page")
|
||||
@ApiOperationSupport(order = 3)
|
||||
@Operation(summary = "分页", description = "传入attach")
|
||||
public R<IPage<AttachVO>> page(AttachVO attach, Query query) {
|
||||
IPage<AttachVO> pages = attachService.selectAttachPage(Condition.getPage(query), attach);
|
||||
return R.data(pages);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增 附件表
|
||||
*/
|
||||
@PostMapping("/save")
|
||||
@ApiOperationSupport(order = 4)
|
||||
@Operation(summary = "新增", description = "传入attach")
|
||||
public R save(@Valid @RequestBody Attach attach) {
|
||||
return R.status(attachService.save(attach));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改 附件表
|
||||
*/
|
||||
@PostMapping("/update")
|
||||
@ApiOperationSupport(order = 5)
|
||||
@Operation(summary = "修改", description = "传入attach")
|
||||
public R update(@Valid @RequestBody Attach attach) {
|
||||
return R.status(attachService.updateById(attach));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增或修改 附件表
|
||||
*/
|
||||
@PostMapping("/submit")
|
||||
@ApiOperationSupport(order = 6)
|
||||
@Operation(summary = "新增或修改", description = "传入attach")
|
||||
public R submit(@Valid @RequestBody Attach attach) {
|
||||
return R.status(attachService.saveOrUpdate(attach));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 删除 附件表
|
||||
*/
|
||||
@PostMapping("/remove")
|
||||
@ApiOperationSupport(order = 7)
|
||||
@Operation(summary = "逻辑删除", description = "传入ids")
|
||||
public R remove(@Parameter(description = "主键集合", required = true) @RequestParam String ids) {
|
||||
return R.status(attachService.removeAttach(Func.toLongList(ids)));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,158 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.resource.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
||||
import io.swagger.v3.oas.annotations.Hidden;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.validation.Valid;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springblade.core.boot.ctrl.BladeController;
|
||||
import org.springblade.core.cache.utils.CacheUtil;
|
||||
import org.springblade.core.mp.support.Condition;
|
||||
import org.springblade.core.mp.support.Query;
|
||||
import org.springblade.core.secure.annotation.IsAdmin;
|
||||
import org.springblade.core.tenant.annotation.NonDS;
|
||||
import org.springblade.core.tool.api.R;
|
||||
import org.springblade.core.tool.utils.Func;
|
||||
import org.springblade.resource.pojo.entity.Oss;
|
||||
import org.springblade.resource.pojo.vo.OssVO;
|
||||
import org.springblade.resource.service.IOssService;
|
||||
import org.springblade.resource.wrapper.OssWrapper;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import static org.springblade.core.cache.constant.CacheConstant.RESOURCE_CACHE;
|
||||
|
||||
/**
|
||||
* 控制器
|
||||
*
|
||||
* @author BladeX
|
||||
*/
|
||||
@NonDS
|
||||
@Hidden
|
||||
@RestController
|
||||
@AllArgsConstructor
|
||||
@IsAdmin
|
||||
@RequestMapping("/oss")
|
||||
@Tag(name = "对象存储接口", description = "对象存储接口")
|
||||
public class OssController extends BladeController {
|
||||
|
||||
private final IOssService ossService;
|
||||
|
||||
/**
|
||||
* 详情
|
||||
*/
|
||||
@GetMapping("/detail")
|
||||
@ApiOperationSupport(order = 1)
|
||||
@Operation(summary = "详情", description = "传入oss")
|
||||
public R<OssVO> detail(Oss oss) {
|
||||
Oss detail = ossService.getOne(Condition.getQueryWrapper(oss));
|
||||
return R.data(OssWrapper.build().entityVO(detail));
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
@ApiOperationSupport(order = 2)
|
||||
@Operation(summary = "分页", description = "传入oss")
|
||||
public R<IPage<OssVO>> list(Oss oss, Query query) {
|
||||
IPage<Oss> pages = ossService.page(Condition.getPage(query), Condition.getQueryWrapper(oss));
|
||||
return R.data(OssWrapper.build().pageVO(pages));
|
||||
}
|
||||
|
||||
/**
|
||||
* 自定义分页
|
||||
*/
|
||||
@GetMapping("/page")
|
||||
@ApiOperationSupport(order = 3)
|
||||
@Operation(summary = "分页", description = "传入oss")
|
||||
public R<IPage<OssVO>> page(OssVO oss, Query query) {
|
||||
IPage<OssVO> pages = ossService.selectOssPage(Condition.getPage(query), oss);
|
||||
return R.data(pages);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增
|
||||
*/
|
||||
@PostMapping("/save")
|
||||
@ApiOperationSupport(order = 4)
|
||||
@Operation(summary = "新增", description = "传入oss")
|
||||
public R save(@Valid @RequestBody Oss oss) {
|
||||
CacheUtil.clear(RESOURCE_CACHE);
|
||||
return R.status(ossService.save(oss));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*/
|
||||
@PostMapping("/update")
|
||||
@ApiOperationSupport(order = 5)
|
||||
@Operation(summary = "修改", description = "传入oss")
|
||||
public R update(@Valid @RequestBody Oss oss) {
|
||||
CacheUtil.clear(RESOURCE_CACHE);
|
||||
return R.status(ossService.updateById(oss));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增或修改
|
||||
*/
|
||||
@PostMapping("/submit")
|
||||
@ApiOperationSupport(order = 6)
|
||||
@Operation(summary = "新增或修改", description = "传入oss")
|
||||
public R submit(@Valid @RequestBody Oss oss) {
|
||||
CacheUtil.clear(RESOURCE_CACHE);
|
||||
return R.status(ossService.submit(oss));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
@PostMapping("/remove")
|
||||
@ApiOperationSupport(order = 7)
|
||||
@Operation(summary = "逻辑删除", description = "传入ids")
|
||||
public R remove(@Parameter(description = "主键集合", required = true) @RequestParam String ids) {
|
||||
CacheUtil.clear(RESOURCE_CACHE);
|
||||
return R.status(ossService.deleteLogic(Func.toLongList(ids)));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 启用
|
||||
*/
|
||||
@PostMapping("/enable")
|
||||
@ApiOperationSupport(order = 8)
|
||||
@Operation(summary = "配置启用", description = "传入id")
|
||||
public R enable(@Parameter(description = "主键", required = true) @RequestParam Long id) {
|
||||
CacheUtil.clear(RESOURCE_CACHE);
|
||||
return R.status(ossService.enable(id));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,159 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.resource.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
||||
import io.swagger.v3.oas.annotations.Hidden;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.validation.Valid;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springblade.core.boot.ctrl.BladeController;
|
||||
import org.springblade.core.cache.utils.CacheUtil;
|
||||
import org.springblade.core.mp.support.Condition;
|
||||
import org.springblade.core.mp.support.Query;
|
||||
import org.springblade.core.secure.annotation.IsAdmin;
|
||||
import org.springblade.core.tenant.annotation.NonDS;
|
||||
import org.springblade.core.tool.api.R;
|
||||
import org.springblade.core.tool.utils.Func;
|
||||
import org.springblade.resource.pojo.entity.Sms;
|
||||
import org.springblade.resource.pojo.vo.SmsVO;
|
||||
import org.springblade.resource.service.ISmsService;
|
||||
import org.springblade.resource.wrapper.SmsWrapper;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import static org.springblade.core.cache.constant.CacheConstant.RESOURCE_CACHE;
|
||||
|
||||
/**
|
||||
* 短信配置表 控制器
|
||||
*
|
||||
* @author BladeX
|
||||
*/
|
||||
@NonDS
|
||||
@Hidden
|
||||
@RestController
|
||||
@AllArgsConstructor
|
||||
@IsAdmin
|
||||
@RequestMapping("/sms")
|
||||
@Tag(name = "短信配置表", description = "短信配置表接口")
|
||||
public class SmsController extends BladeController {
|
||||
|
||||
private final ISmsService smsService;
|
||||
|
||||
/**
|
||||
* 详情
|
||||
*/
|
||||
@GetMapping("/detail")
|
||||
@ApiOperationSupport(order = 1)
|
||||
@Operation(summary = "详情", description = "传入sms")
|
||||
public R<SmsVO> detail(Sms sms) {
|
||||
Sms detail = smsService.getOne(Condition.getQueryWrapper(sms));
|
||||
return R.data(SmsWrapper.build().entityVO(detail));
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页 短信配置表
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
@ApiOperationSupport(order = 2)
|
||||
@Operation(summary = "分页", description = "传入sms")
|
||||
public R<IPage<SmsVO>> list(Sms sms, Query query) {
|
||||
IPage<Sms> pages = smsService.page(Condition.getPage(query), Condition.getQueryWrapper(sms));
|
||||
return R.data(SmsWrapper.build().pageVO(pages));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 自定义分页 短信配置表
|
||||
*/
|
||||
@GetMapping("/page")
|
||||
@ApiOperationSupport(order = 3)
|
||||
@Operation(summary = "分页", description = "传入sms")
|
||||
public R<IPage<SmsVO>> page(SmsVO sms, Query query) {
|
||||
IPage<SmsVO> pages = smsService.selectSmsPage(Condition.getPage(query), sms);
|
||||
return R.data(pages);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增 短信配置表
|
||||
*/
|
||||
@PostMapping("/save")
|
||||
@ApiOperationSupport(order = 4)
|
||||
@Operation(summary = "新增", description = "传入sms")
|
||||
public R save(@Valid @RequestBody Sms sms) {
|
||||
CacheUtil.clear(RESOURCE_CACHE);
|
||||
return R.status(smsService.save(sms));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改 短信配置表
|
||||
*/
|
||||
@PostMapping("/update")
|
||||
@ApiOperationSupport(order = 5)
|
||||
@Operation(summary = "修改", description = "传入sms")
|
||||
public R update(@Valid @RequestBody Sms sms) {
|
||||
CacheUtil.clear(RESOURCE_CACHE);
|
||||
return R.status(smsService.updateById(sms));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增或修改 短信配置表
|
||||
*/
|
||||
@PostMapping("/submit")
|
||||
@ApiOperationSupport(order = 6)
|
||||
@Operation(summary = "新增或修改", description = "传入sms")
|
||||
public R submit(@Valid @RequestBody Sms sms) {
|
||||
CacheUtil.clear(RESOURCE_CACHE);
|
||||
return R.status(smsService.submit(sms));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 删除 短信配置表
|
||||
*/
|
||||
@PostMapping("/remove")
|
||||
@ApiOperationSupport(order = 7)
|
||||
@Operation(summary = "逻辑删除", description = "传入ids")
|
||||
public R remove(@Parameter(description = "主键集合", required = true) @RequestParam String ids) {
|
||||
CacheUtil.clear(RESOURCE_CACHE);
|
||||
return R.status(smsService.deleteLogic(Func.toLongList(ids)));
|
||||
}
|
||||
|
||||
/**
|
||||
* 启用
|
||||
*/
|
||||
@PostMapping("/enable")
|
||||
@ApiOperationSupport(order = 8)
|
||||
@Operation(summary = "配置启用", description = "传入id")
|
||||
public R enable(@Parameter(description = "主键", required = true) @RequestParam Long id) {
|
||||
CacheUtil.clear(RESOURCE_CACHE);
|
||||
return R.status(smsService.enable(id));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,255 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.resource.endpoint;
|
||||
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.SneakyThrows;
|
||||
import org.springblade.core.oss.model.BladeFile;
|
||||
import org.springblade.core.oss.model.OssFile;
|
||||
import org.springblade.core.secure.annotation.IsAdmin;
|
||||
import org.springblade.core.tenant.annotation.NonDS;
|
||||
import org.springblade.core.tool.api.R;
|
||||
import org.springblade.core.tool.utils.FileUtil;
|
||||
import org.springblade.core.tool.utils.Func;
|
||||
import org.springblade.resource.builder.OssBuilder;
|
||||
import org.springblade.resource.pojo.entity.Attach;
|
||||
import org.springblade.resource.service.IAttachService;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
/**
|
||||
* 对象存储端点
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
@NonDS
|
||||
@RestController
|
||||
@AllArgsConstructor
|
||||
@RequestMapping("/oss/endpoint")
|
||||
@Tag(name = "对象存储端点", description = "对象存储端点")
|
||||
public class OssEndpoint {
|
||||
|
||||
/**
|
||||
* 对象存储构建类
|
||||
*/
|
||||
private final OssBuilder ossBuilder;
|
||||
|
||||
/**
|
||||
* 附件表服务
|
||||
*/
|
||||
private final IAttachService attachService;
|
||||
|
||||
/**
|
||||
* 创建存储桶
|
||||
*
|
||||
* @param bucketName 存储桶名称
|
||||
* @return Bucket
|
||||
*/
|
||||
@SneakyThrows
|
||||
@IsAdmin
|
||||
@PostMapping("/make-bucket")
|
||||
public R makeBucket(@RequestParam String bucketName) {
|
||||
ossBuilder.template().makeBucket(bucketName);
|
||||
return R.success("创建成功");
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建存储桶
|
||||
*
|
||||
* @param bucketName 存储桶名称
|
||||
* @return R
|
||||
*/
|
||||
@SneakyThrows
|
||||
@IsAdmin
|
||||
@PostMapping("/remove-bucket")
|
||||
public R removeBucket(@RequestParam String bucketName) {
|
||||
ossBuilder.template().removeBucket(bucketName);
|
||||
return R.success("删除成功");
|
||||
}
|
||||
|
||||
/**
|
||||
* 拷贝文件
|
||||
*
|
||||
* @param bucketName 存储桶名称
|
||||
* @param fileName 存储桶对象名称
|
||||
* @param destBucketName 目标存储桶名称
|
||||
* @param destFileName 目标存储桶对象名称
|
||||
* @return R
|
||||
*/
|
||||
@SneakyThrows
|
||||
@PostMapping("/copy-file")
|
||||
public R copyFile(@RequestParam String bucketName, @RequestParam String fileName, @RequestParam String destBucketName, String destFileName) {
|
||||
ossBuilder.template().copyFile(bucketName, fileName, destBucketName, destFileName);
|
||||
return R.success("操作成功");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取文件信息
|
||||
*
|
||||
* @param fileName 存储桶对象名称
|
||||
* @return InputStream
|
||||
*/
|
||||
@SneakyThrows
|
||||
@GetMapping("/stat-file")
|
||||
public R<OssFile> statFile(@RequestParam String fileName) {
|
||||
return R.data(ossBuilder.template().statFile(fileName));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取文件相对路径
|
||||
*
|
||||
* @param fileName 存储桶对象名称
|
||||
* @return String
|
||||
*/
|
||||
@SneakyThrows
|
||||
@GetMapping("/file-path")
|
||||
public R<String> filePath(@RequestParam String fileName) {
|
||||
return R.data(ossBuilder.template().filePath(fileName));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取文件外链
|
||||
*
|
||||
* @param fileName 存储桶对象名称
|
||||
* @return String
|
||||
*/
|
||||
@SneakyThrows
|
||||
@GetMapping("/file-link")
|
||||
public R<String> fileLink(@RequestParam String fileName) {
|
||||
return R.data(ossBuilder.template().fileLink(fileName));
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传文件
|
||||
*
|
||||
* @param file 文件
|
||||
* @return ObjectStat
|
||||
*/
|
||||
@SneakyThrows
|
||||
@PostMapping("/put-file")
|
||||
public R<BladeFile> putFile(@RequestParam MultipartFile file) {
|
||||
BladeFile bladeFile = ossBuilder.template().putFile(file.getOriginalFilename(), file.getInputStream());
|
||||
return R.data(bladeFile);
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传文件
|
||||
*
|
||||
* @param fileName 存储桶对象名称
|
||||
* @param file 文件
|
||||
* @return ObjectStat
|
||||
*/
|
||||
@SneakyThrows
|
||||
@PostMapping("/put-file-by-name")
|
||||
public R<BladeFile> putFile(@RequestParam String fileName, @RequestParam MultipartFile file) {
|
||||
BladeFile bladeFile = ossBuilder.template().putFile(fileName, file.getInputStream());
|
||||
return R.data(bladeFile);
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传文件并保存至附件表
|
||||
*
|
||||
* @param file 文件
|
||||
* @return ObjectStat
|
||||
*/
|
||||
@SneakyThrows
|
||||
@PostMapping("/put-file-attach")
|
||||
public R<BladeFile> putFileAttach(@RequestParam MultipartFile file) {
|
||||
String fileName = file.getOriginalFilename();
|
||||
BladeFile bladeFile = ossBuilder.template().putFile(fileName, file.getInputStream());
|
||||
Long attachId = buildAttach(fileName, file.getSize(), bladeFile);
|
||||
bladeFile.setAttachId(attachId);
|
||||
return R.data(bladeFile);
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传文件并保存至附件表
|
||||
*
|
||||
* @param fileName 存储桶对象名称
|
||||
* @param file 文件
|
||||
* @return ObjectStat
|
||||
*/
|
||||
@SneakyThrows
|
||||
@PostMapping("/put-file-attach-by-name")
|
||||
public R<BladeFile> putFileAttach(@RequestParam String fileName, @RequestParam MultipartFile file) {
|
||||
BladeFile bladeFile = ossBuilder.template().putFile(fileName, file.getInputStream());
|
||||
Long attachId = buildAttach(fileName, file.getSize(), bladeFile);
|
||||
bladeFile.setAttachId(attachId);
|
||||
return R.data(bladeFile);
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建附件表
|
||||
*
|
||||
* @param fileName 文件名
|
||||
* @param fileSize 文件大小
|
||||
* @param bladeFile 对象存储文件
|
||||
* @return attachId
|
||||
*/
|
||||
private Long buildAttach(String fileName, Long fileSize, BladeFile bladeFile) {
|
||||
String fileExtension = FileUtil.getFileExtension(fileName);
|
||||
Attach attach = new Attach();
|
||||
attach.setDomainUrl(bladeFile.getDomain());
|
||||
attach.setLink(bladeFile.getLink());
|
||||
attach.setName(bladeFile.getName());
|
||||
attach.setOriginalName(bladeFile.getOriginalName());
|
||||
attach.setAttachSize(fileSize);
|
||||
attach.setExtension(fileExtension);
|
||||
attachService.save(attach);
|
||||
return attach.getId();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除文件
|
||||
*
|
||||
* @param fileName 存储桶对象名称
|
||||
* @return R
|
||||
*/
|
||||
@SneakyThrows
|
||||
@IsAdmin
|
||||
@PostMapping("/remove-file")
|
||||
public R removeFile(@RequestParam String fileName) {
|
||||
ossBuilder.template().removeFile(fileName);
|
||||
return R.success("操作成功");
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除文件
|
||||
*
|
||||
* @param fileNames 存储桶对象名称集合
|
||||
* @return R
|
||||
*/
|
||||
@SneakyThrows
|
||||
@IsAdmin
|
||||
@PostMapping("/remove-files")
|
||||
public R removeFiles(@RequestParam String fileNames) {
|
||||
ossBuilder.template().removeFiles(Func.toStrList(fileNames));
|
||||
return R.success("操作成功");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,185 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.resource.endpoint;
|
||||
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.SneakyThrows;
|
||||
import org.springblade.core.sms.model.SmsCode;
|
||||
import org.springblade.core.sms.model.SmsData;
|
||||
import org.springblade.core.sms.model.SmsResponse;
|
||||
import org.springblade.core.tenant.annotation.NonDS;
|
||||
import org.springblade.core.tool.api.R;
|
||||
import org.springblade.core.tool.jackson.JsonUtil;
|
||||
import org.springblade.core.tool.utils.Func;
|
||||
import org.springblade.resource.builder.SmsBuilder;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.springblade.resource.utils.SmsUtil.*;
|
||||
|
||||
/**
|
||||
* 短信服务端点
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
@NonDS
|
||||
@RestController
|
||||
@AllArgsConstructor
|
||||
@RequestMapping("/sms/endpoint")
|
||||
@Tag(name = "短信服务端点", description = "短信服务端点")
|
||||
public class SmsEndpoint {
|
||||
|
||||
/**
|
||||
* 短信服务构建类
|
||||
*/
|
||||
private final SmsBuilder smsBuilder;
|
||||
|
||||
//================================= 短信服务校验 =================================
|
||||
|
||||
/**
|
||||
* 短信验证码发送
|
||||
*
|
||||
* @param phone 手机号
|
||||
*/
|
||||
@SneakyThrows
|
||||
@PostMapping("/send-validate")
|
||||
public R sendValidate(@RequestParam String phone) {
|
||||
Map<String, String> params = getValidateParams();
|
||||
SmsCode smsCode = smsBuilder.template().sendValidate(new SmsData(params).setKey(PARAM_KEY), phone);
|
||||
return smsCode.isSuccess() ? R.data(smsCode, SEND_SUCCESS) : R.fail(SEND_FAIL);
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验短信
|
||||
*
|
||||
* @param smsCode 短信校验信息
|
||||
*/
|
||||
@SneakyThrows
|
||||
@PostMapping("/validate-message")
|
||||
public R validateMessage(SmsCode smsCode) {
|
||||
boolean validate = smsBuilder.template().validateMessage(smsCode);
|
||||
return validate ? R.success(VALIDATE_SUCCESS) : R.fail(VALIDATE_FAIL);
|
||||
}
|
||||
|
||||
//========== 通用短信自定义发送(支持自定义params参数传递, 推荐用于测试, 不推荐用于生产环境) ==========
|
||||
|
||||
/**
|
||||
* 发送信息
|
||||
*
|
||||
* @param params 自定义短信参数
|
||||
* @param phones 手机号集合
|
||||
*/
|
||||
@SneakyThrows
|
||||
@PostMapping("/send-message")
|
||||
public R sendMessage(@RequestParam String code, @RequestParam String params, @RequestParam String phones) {
|
||||
SmsData smsData = new SmsData(JsonUtil.readMap(params, String.class, String.class));
|
||||
return send(code, smsData, phones);
|
||||
}
|
||||
|
||||
//========== 指定短信服务发送(可根据各种场景自定拓展定制, 损失灵活性增加安全性, 推荐用于生产环境) ==========
|
||||
|
||||
/**
|
||||
* 短信通知
|
||||
*
|
||||
* @param phones 手机号集合
|
||||
*/
|
||||
@SneakyThrows
|
||||
@PostMapping("/send-notice")
|
||||
public R sendNotice(@RequestParam String phones) {
|
||||
Map<String, String> params = new HashMap<>(3);
|
||||
params.put("title", "通知标题");
|
||||
params.put("content", "通知内容");
|
||||
params.put("date", "通知时间");
|
||||
SmsData smsData = new SmsData(params);
|
||||
return send(smsData, phones);
|
||||
}
|
||||
|
||||
/**
|
||||
* 订单通知
|
||||
*
|
||||
* @param phones 手机号集合
|
||||
*/
|
||||
@SneakyThrows
|
||||
@PostMapping("/send-order")
|
||||
public R sendOrder(@RequestParam String phones) {
|
||||
Map<String, String> params = new HashMap<>(3);
|
||||
params.put("orderNo", "订单编号");
|
||||
params.put("packageNo", "快递单号");
|
||||
params.put("user", "收件人");
|
||||
SmsData smsData = new SmsData(params);
|
||||
return send(smsData, phones);
|
||||
}
|
||||
|
||||
/**
|
||||
* 会议通知
|
||||
*
|
||||
* @param phones 手机号集合
|
||||
*/
|
||||
@SneakyThrows
|
||||
@PostMapping("/send-meeting")
|
||||
public R sendMeeting(@RequestParam String phones) {
|
||||
Map<String, String> params = new HashMap<>(2);
|
||||
params.put("roomId", "会议室");
|
||||
params.put("topic", "会议主题");
|
||||
params.put("date", "会议时间");
|
||||
SmsData smsData = new SmsData(params);
|
||||
return send(smsData, phones);
|
||||
}
|
||||
|
||||
//================================= 通用短信发送接口 =================================
|
||||
|
||||
/**
|
||||
* 通用短信发送接口
|
||||
*
|
||||
* @param smsData 短信内容
|
||||
* @param phones 手机号列表
|
||||
* @return 是否发送成功
|
||||
*/
|
||||
private R send(SmsData smsData, String phones) {
|
||||
SmsResponse response = smsBuilder.template().sendMessage(smsData, Func.toStrList(phones));
|
||||
return response.isSuccess() ? R.success(SEND_SUCCESS) : R.fail(SEND_FAIL);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通用短信发送接口
|
||||
*
|
||||
* @param code 资源编号
|
||||
* @param smsData 短信内容
|
||||
* @param phones 手机号列表
|
||||
* @return 是否发送成功
|
||||
*/
|
||||
private R send(String code, SmsData smsData, String phones) {
|
||||
SmsResponse response = smsBuilder.template(code).sendMessage(smsData, Func.toStrList(phones));
|
||||
return response.isSuccess() ? R.success(SEND_SUCCESS) : R.fail(SEND_FAIL);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.resource.feign;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springblade.core.sms.model.SmsCode;
|
||||
import org.springblade.core.sms.model.SmsData;
|
||||
import org.springblade.core.sms.model.SmsResponse;
|
||||
import org.springblade.core.tenant.annotation.NonDS;
|
||||
import org.springblade.core.tool.api.R;
|
||||
import org.springblade.core.tool.jackson.JsonUtil;
|
||||
import org.springblade.core.tool.utils.Func;
|
||||
import org.springblade.resource.builder.SmsBuilder;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import static org.springblade.resource.utils.SmsUtil.*;
|
||||
|
||||
/**
|
||||
* 短信远程调用服务
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
@NonDS
|
||||
@RestController
|
||||
@AllArgsConstructor
|
||||
public class SmsClient implements ISmsClient {
|
||||
|
||||
private final SmsBuilder smsBuilder;
|
||||
|
||||
@Override
|
||||
@PostMapping(SEND_MESSAGE)
|
||||
public R<SmsResponse> sendMessage(String code, String params, String phones) {
|
||||
SmsData smsData = new SmsData(JsonUtil.readMap(params, String.class, String.class));
|
||||
SmsResponse response = smsBuilder.template(code).sendMessage(smsData, Func.toStrList(phones));
|
||||
return R.data(response);
|
||||
}
|
||||
|
||||
@Override
|
||||
@PostMapping(SEND_MESSAGE_BY_TENANT_ID)
|
||||
public R<SmsResponse> sendMessage(String tenantId, String code, String params, String phones) {
|
||||
SmsData smsData = new SmsData(JsonUtil.readMap(params, String.class, String.class));
|
||||
SmsResponse response = smsBuilder.template(tenantId, code).sendMessage(smsData, Func.toStrList(phones));
|
||||
return R.data(response);
|
||||
}
|
||||
|
||||
@Override
|
||||
@PostMapping(SEND_VALIDATE)
|
||||
public R sendValidate(String code, String phone) {
|
||||
Map<String, String> params = getValidateParams();
|
||||
SmsCode smsCode = smsBuilder.template(code).sendValidate(new SmsData(params).setKey(PARAM_KEY), phone);
|
||||
return smsCode.isSuccess() ? R.data(smsCode, SEND_SUCCESS) : R.fail(SEND_FAIL);
|
||||
}
|
||||
|
||||
@Override
|
||||
@PostMapping(SEND_VALIDATE_BY_TENANT_ID)
|
||||
public R sendValidate(String tenantId, String code, String phone) {
|
||||
Map<String, String> params = getValidateParams();
|
||||
SmsCode smsCode = smsBuilder.template(tenantId, code).sendValidate(new SmsData(params).setKey(PARAM_KEY), phone);
|
||||
return smsCode.isSuccess() ? R.data(smsCode, SEND_SUCCESS) : R.fail(SEND_FAIL);
|
||||
}
|
||||
|
||||
@Override
|
||||
@PostMapping(VALIDATE_MESSAGE)
|
||||
public R validateMessage(String code, String id, String value, String phone) {
|
||||
SmsCode smsCode = new SmsCode().setId(id).setValue(value).setPhone(phone);
|
||||
boolean validate = smsBuilder.template(code).validateMessage(smsCode);
|
||||
return validate ? R.success(VALIDATE_SUCCESS) : R.fail(VALIDATE_FAIL);
|
||||
}
|
||||
|
||||
@Override
|
||||
@PostMapping(VALIDATE_MESSAGE_BY_TENANT_ID)
|
||||
public R validateMessage(String tenantId, String code, String id, String value, String phone) {
|
||||
SmsCode smsCode = new SmsCode().setId(id).setValue(value).setPhone(phone);
|
||||
boolean validate = smsBuilder.template(tenantId, code).validateMessage(smsCode);
|
||||
return validate ? R.success(VALIDATE_SUCCESS) : R.fail(VALIDATE_FAIL);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.resource.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import org.springblade.resource.pojo.entity.Attach;
|
||||
import org.springblade.resource.pojo.vo.AttachVO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 附件表 Mapper 接口
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
public interface AttachMapper extends BaseMapper<Attach> {
|
||||
|
||||
/**
|
||||
* 自定义分页
|
||||
*
|
||||
* @param page
|
||||
* @param attach
|
||||
* @return
|
||||
*/
|
||||
List<AttachVO> selectAttachPage(IPage page, AttachVO attach);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="org.springblade.resource.mapper.AttachMapper">
|
||||
|
||||
<!-- 通用查询映射结果 -->
|
||||
<resultMap id="attachResultMap" type="org.springblade.resource.pojo.entity.Attach">
|
||||
<result column="id" property="id"/>
|
||||
<result column="create_user" property="createUser"/>
|
||||
<result column="create_dept" property="createDept"/>
|
||||
<result column="create_time" property="createTime"/>
|
||||
<result column="update_user" property="updateUser"/>
|
||||
<result column="update_time" property="updateTime"/>
|
||||
<result column="status" property="status"/>
|
||||
<result column="is_deleted" property="isDeleted"/>
|
||||
<result column="link" property="link"/>
|
||||
<result column="domain_url" property="domainUrl"/>
|
||||
<result column="name" property="name"/>
|
||||
<result column="original_name" property="originalName"/>
|
||||
<result column="extension" property="extension"/>
|
||||
<result column="attach_size" property="attachSize"/>
|
||||
</resultMap>
|
||||
|
||||
|
||||
<select id="selectAttachPage" resultMap="attachResultMap">
|
||||
select * from blade_attach where is_deleted = 0
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,51 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.resource.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import org.springblade.resource.pojo.entity.Oss;
|
||||
import org.springblade.resource.pojo.vo.OssVO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Mapper 接口
|
||||
*
|
||||
* @author BladeX
|
||||
*/
|
||||
public interface OssMapper extends BaseMapper<Oss> {
|
||||
|
||||
/**
|
||||
* 自定义分页
|
||||
*
|
||||
* @param page
|
||||
* @param oss
|
||||
* @return
|
||||
*/
|
||||
List<OssVO> selectOssPage(IPage page, OssVO oss);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="org.springblade.resource.mapper.OssMapper">
|
||||
|
||||
<!-- 通用查询映射结果 -->
|
||||
<resultMap id="ossResultMap" type="org.springblade.resource.pojo.entity.Oss">
|
||||
<result column="id" property="id"/>
|
||||
<result column="create_user" property="createUser"/>
|
||||
<result column="create_time" property="createTime"/>
|
||||
<result column="update_user" property="updateUser"/>
|
||||
<result column="update_time" property="updateTime"/>
|
||||
<result column="status" property="status"/>
|
||||
<result column="is_deleted" property="isDeleted"/>
|
||||
<result column="oss_code" property="ossCode"/>
|
||||
<result column="category" property="category"/>
|
||||
<result column="endpoint" property="endpoint"/>
|
||||
<result column="access_key" property="accessKey"/>
|
||||
<result column="secret_key" property="secretKey"/>
|
||||
<result column="bucket_name" property="bucketName"/>
|
||||
<result column="app_id" property="appId"/>
|
||||
<result column="region" property="region"/>
|
||||
<result column="remark" property="remark"/>
|
||||
</resultMap>
|
||||
|
||||
|
||||
<select id="selectOssPage" resultMap="ossResultMap">
|
||||
select * from blade_oss where is_deleted = 0
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,50 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.resource.mapper;
|
||||
|
||||
import org.springblade.resource.pojo.entity.Sms;
|
||||
import org.springblade.resource.pojo.vo.SmsVO;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 短信配置表 Mapper 接口
|
||||
*
|
||||
* @author BladeX
|
||||
*/
|
||||
public interface SmsMapper extends BaseMapper<Sms> {
|
||||
|
||||
/**
|
||||
* 自定义分页
|
||||
*
|
||||
* @param page
|
||||
* @param sms
|
||||
* @return
|
||||
*/
|
||||
List<SmsVO> selectSmsPage(IPage page, SmsVO sms);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="org.springblade.resource.mapper.SmsMapper">
|
||||
|
||||
<!-- 通用查询映射结果 -->
|
||||
<resultMap id="smsResultMap" type="org.springblade.resource.pojo.entity.Sms">
|
||||
<result column="id" property="id"/>
|
||||
<result column="create_user" property="createUser"/>
|
||||
<result column="create_dept" property="createDept"/>
|
||||
<result column="create_time" property="createTime"/>
|
||||
<result column="update_user" property="updateUser"/>
|
||||
<result column="update_time" property="updateTime"/>
|
||||
<result column="status" property="status"/>
|
||||
<result column="is_deleted" property="isDeleted"/>
|
||||
<result column="sms_code" property="smsCode"/>
|
||||
<result column="template_id" property="templateId"/>
|
||||
<result column="category" property="category"/>
|
||||
<result column="access_key" property="accessKey"/>
|
||||
<result column="secret_key" property="secretKey"/>
|
||||
<result column="region_id" property="regionId"/>
|
||||
<result column="sign_name" property="signName"/>
|
||||
<result column="remark" property="remark"/>
|
||||
</resultMap>
|
||||
|
||||
|
||||
<select id="selectSmsPage" resultMap="smsResultMap">
|
||||
select * from blade_sms where is_deleted = 0
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,45 @@
|
||||
package org.springblade.resource.rule.builder;
|
||||
|
||||
import org.springblade.core.literule.annotation.RuleEngineComponent;
|
||||
import org.springblade.core.literule.builder.LiteRule;
|
||||
import org.springblade.core.literule.builder.RuleBuilder;
|
||||
import org.springblade.core.literule.builder.chain.RuleChain;
|
||||
|
||||
import static org.springblade.resource.rule.constant.OssRuleConstant.*;
|
||||
|
||||
/**
|
||||
* Oss规则链构建器
|
||||
*
|
||||
* @author BladeX
|
||||
*/
|
||||
@RuleEngineComponent(id = OSS_CHAIN_ID)
|
||||
public class OssRuleBuilder implements RuleBuilder {
|
||||
@Override
|
||||
public RuleChain build() {
|
||||
// 创建OSS缓存判断规则链
|
||||
RuleChain ossCacheRuleChain = LiteRule.SWITCH(OSS_CACHE_RULE).TO(
|
||||
OSS_READ_RULE,
|
||||
LiteRule.THEN(OSS_DATA_RULE)
|
||||
.THEN(
|
||||
LiteRule.SWITCH(OSS_BUILD_RULE).TO(
|
||||
ALI_OSS_RULE,
|
||||
AMAZON_S3_RULE,
|
||||
HUAWEI_OBS_RULE,
|
||||
MINIO_RULE,
|
||||
QINIU_OSS_RULE,
|
||||
TENCENT_COS_RULE,
|
||||
LOCAL_FILE_RULE
|
||||
).build()
|
||||
)
|
||||
.THEN(OSS_TEMPLATE_RULE)
|
||||
.ID(OSS_NEW_RULE)// 设置规则链ID方可在Switch节点进行调用
|
||||
.build()
|
||||
).build();
|
||||
|
||||
// 创建完整规则链
|
||||
return LiteRule.THEN(PRE_OSS_RULE)
|
||||
.THEN(ossCacheRuleChain)
|
||||
.THEN(FINALLY_OSS_RULE)
|
||||
.build();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package org.springblade.resource.rule.builder;
|
||||
|
||||
import org.springblade.core.literule.annotation.RuleEngineComponent;
|
||||
import org.springblade.core.literule.builder.LiteRule;
|
||||
import org.springblade.core.literule.builder.RuleBuilder;
|
||||
import org.springblade.core.literule.builder.chain.RuleChain;
|
||||
|
||||
import static org.springblade.resource.rule.constant.SmsRuleConstant.*;
|
||||
|
||||
/**
|
||||
* Sms规则链构建器
|
||||
*
|
||||
* @author BladeX
|
||||
*/
|
||||
@RuleEngineComponent(id = SMS_CHAIN_ID)
|
||||
public class SmsRuleBuilder implements RuleBuilder {
|
||||
@Override
|
||||
public RuleChain build() {
|
||||
// 创建SMS构建条件判断规则链
|
||||
RuleChain smsBuildRuleChain = LiteRule.SWITCH(SMS_BUILD_RULE).TO(
|
||||
ALI_SMS_RULE,
|
||||
QINIU_SMS_RULE,
|
||||
TENCENT_SMS_RULE,
|
||||
YUNPIAN_SMS_RULE,
|
||||
CACHE_SMS_RULE
|
||||
).build();
|
||||
|
||||
// 创建完整规则链
|
||||
return LiteRule.THEN(PRE_SMS_RULE)
|
||||
.THEN(smsBuildRuleChain)
|
||||
.THEN(FINALLY_SMS_RULE)
|
||||
.build();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
package org.springblade.resource.rule.constant;
|
||||
|
||||
/**
|
||||
* OssRuleConstant
|
||||
*
|
||||
* @author BladeX
|
||||
*/
|
||||
public interface OssRuleConstant {
|
||||
/**
|
||||
* OSS规则链ID
|
||||
*/
|
||||
String OSS_CHAIN_ID = "ossChain";
|
||||
|
||||
/**
|
||||
* 预处理OSS规则
|
||||
*/
|
||||
String PRE_OSS_RULE = "preOssRule";
|
||||
|
||||
/**
|
||||
* OSS缓存判断规则
|
||||
*/
|
||||
String OSS_CACHE_RULE = "ossCacheRule";
|
||||
|
||||
/**
|
||||
* OSS读取规则
|
||||
*/
|
||||
String OSS_READ_RULE = "ossReadRule";
|
||||
|
||||
/**
|
||||
* OSS新建规则ID
|
||||
*/
|
||||
String OSS_NEW_RULE = "ossNewRule";
|
||||
|
||||
/**
|
||||
* OSS数据规则
|
||||
*/
|
||||
String OSS_DATA_RULE = "ossDataRule";
|
||||
|
||||
/**
|
||||
* OSS构建条件判断规则
|
||||
*/
|
||||
String OSS_BUILD_RULE = "ossBuildRule";
|
||||
|
||||
/**
|
||||
* 阿里云OSS规则
|
||||
*/
|
||||
String ALI_OSS_RULE = "aliOssRule";
|
||||
|
||||
/**
|
||||
* 亚马逊S3规则
|
||||
*/
|
||||
String AMAZON_S3_RULE = "amazonS3Rule";
|
||||
|
||||
/**
|
||||
* 华为云OBS规则
|
||||
*/
|
||||
String HUAWEI_OBS_RULE = "huaweiObsRule";
|
||||
|
||||
/**
|
||||
* MinIO规则
|
||||
*/
|
||||
String MINIO_RULE = "minioRule";
|
||||
|
||||
/**
|
||||
* 七牛云OSS规则
|
||||
*/
|
||||
String QINIU_OSS_RULE = "qiniuOssRule";
|
||||
|
||||
/**
|
||||
* 腾讯云COS规则
|
||||
*/
|
||||
String TENCENT_COS_RULE = "tencentCosRule";
|
||||
|
||||
/**
|
||||
* 本地文件规则
|
||||
*/
|
||||
String LOCAL_FILE_RULE = "localFileRule";
|
||||
|
||||
/**
|
||||
* OSS模板规则
|
||||
*/
|
||||
String OSS_TEMPLATE_RULE = "ossTemplateRule";
|
||||
|
||||
/**
|
||||
* 最终OSS规则
|
||||
*/
|
||||
String FINALLY_OSS_RULE = "finallyOssRule";
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package org.springblade.resource.rule.constant;
|
||||
|
||||
/**
|
||||
* SmsRuleConstant
|
||||
*
|
||||
* @author BladeX
|
||||
*/
|
||||
public interface SmsRuleConstant {
|
||||
/**
|
||||
* SMS规则链ID
|
||||
*/
|
||||
String SMS_CHAIN_ID = "smsChain";
|
||||
|
||||
/**
|
||||
* 预处理SMS规则
|
||||
*/
|
||||
String PRE_SMS_RULE = "preSmsRule";
|
||||
|
||||
/**
|
||||
* SMS构建条件判断规则
|
||||
*/
|
||||
String SMS_BUILD_RULE = "smsBuildRule";
|
||||
|
||||
/**
|
||||
* 阿里云SMS规则
|
||||
*/
|
||||
String ALI_SMS_RULE = "aliSmsRule";
|
||||
|
||||
/**
|
||||
* 七牛云SMS规则
|
||||
*/
|
||||
String QINIU_SMS_RULE = "qiniuSmsRule";
|
||||
|
||||
/**
|
||||
* 腾讯云SMS规则
|
||||
*/
|
||||
String TENCENT_SMS_RULE = "tencentSmsRule";
|
||||
|
||||
/**
|
||||
* 云片SMS规则
|
||||
*/
|
||||
String YUNPIAN_SMS_RULE = "yunpianSmsRule";
|
||||
|
||||
/**
|
||||
* 缓存SMS规则
|
||||
*/
|
||||
String CACHE_SMS_RULE = "cacheSmsRule";
|
||||
|
||||
/**
|
||||
* 最终SMS规则
|
||||
*/
|
||||
String FINALLY_SMS_RULE = "finallySmsRule";
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.resource.rule.context;
|
||||
|
||||
import lombok.*;
|
||||
import org.springblade.core.literule.core.RuleContextComponent;
|
||||
import org.springblade.core.oss.OssTemplate;
|
||||
import org.springblade.core.oss.props.OssProperties;
|
||||
import org.springblade.core.oss.rule.OssRule;
|
||||
import org.springblade.resource.pojo.entity.Oss;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Oss上下文
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class OssContext extends RuleContextComponent {
|
||||
/**
|
||||
* 是否有缓存
|
||||
*/
|
||||
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,78 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.resource.rule.context;
|
||||
|
||||
import lombok.*;
|
||||
import org.springblade.core.literule.core.RuleContextComponent;
|
||||
import org.springblade.core.redis.cache.BladeRedis;
|
||||
import org.springblade.core.sms.SmsTemplate;
|
||||
import org.springblade.core.sms.props.SmsProperties;
|
||||
import org.springblade.resource.pojo.entity.Sms;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Sms上下文
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class SmsContext extends RuleContextComponent {
|
||||
/**
|
||||
* 是否有缓存
|
||||
*/
|
||||
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,87 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.resource.rule.oss;
|
||||
|
||||
import com.aliyun.oss.ClientConfiguration;
|
||||
import com.aliyun.oss.OSSClient;
|
||||
import com.aliyun.oss.common.auth.CredentialsProvider;
|
||||
import com.aliyun.oss.common.auth.DefaultCredentialProvider;
|
||||
import org.springblade.core.literule.annotation.LiteRuleComponent;
|
||||
import org.springblade.core.literule.core.RuleComponent;
|
||||
import org.springblade.core.oss.AliossTemplate;
|
||||
import org.springblade.core.oss.OssTemplate;
|
||||
import org.springblade.core.oss.props.OssProperties;
|
||||
import org.springblade.core.oss.rule.OssRule;
|
||||
import org.springblade.resource.pojo.entity.Oss;
|
||||
import org.springblade.resource.rule.context.OssContext;
|
||||
|
||||
import static org.springblade.resource.rule.constant.OssRuleConstant.ALI_OSS_RULE;
|
||||
|
||||
/**
|
||||
* 阿里云存储构建类
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
@LiteRuleComponent(id = ALI_OSS_RULE, name = "阿里云OSS构建")
|
||||
public class AliOssRule extends RuleComponent {
|
||||
|
||||
@Override
|
||||
public void process() {
|
||||
// 获取上下文
|
||||
OssContext contextBean = this.getContextBean(OssContext.class);
|
||||
Oss oss = contextBean.getOss();
|
||||
OssRule ossRule = contextBean.getOssRule();
|
||||
|
||||
// 创建配置类
|
||||
OssProperties ossProperties = new OssProperties();
|
||||
ossProperties.setEndpoint(oss.getEndpoint());
|
||||
ossProperties.setTransformEndpoint(oss.getTransformEndpoint());
|
||||
ossProperties.setAccessKey(oss.getAccessKey());
|
||||
ossProperties.setSecretKey(oss.getSecretKey());
|
||||
ossProperties.setBucketName(oss.getBucketName());
|
||||
// 创建ClientConfiguration
|
||||
ClientConfiguration conf = new ClientConfiguration();
|
||||
// 设置OSSClient允许打开的最大HTTP连接数,默认为1024个。
|
||||
conf.setMaxConnections(1024);
|
||||
// 设置Socket层传输数据的超时时间,默认为50000毫秒。
|
||||
conf.setSocketTimeout(50000);
|
||||
// 设置建立连接的超时时间,默认为50000毫秒。
|
||||
conf.setConnectionTimeout(50000);
|
||||
// 设置从连接池中获取连接的超时时间(单位:毫秒),默认不超时。
|
||||
conf.setConnectionRequestTimeout(1000);
|
||||
// 设置连接空闲超时时间。超时则关闭连接,默认为60000毫秒。
|
||||
conf.setIdleConnectionTime(60000);
|
||||
// 设置失败请求重试次数,默认为3次。
|
||||
conf.setMaxErrorRetry(5);
|
||||
CredentialsProvider credentialsProvider = new DefaultCredentialProvider(ossProperties.getAccessKey(), ossProperties.getSecretKey());
|
||||
// 创建客户端
|
||||
OSSClient ossClient = new OSSClient(ossProperties.getEndpoint(), credentialsProvider, conf);
|
||||
OssTemplate ossTemplate = new AliossTemplate(ossClient, ossProperties, ossRule);
|
||||
|
||||
// 设置上下文
|
||||
contextBean.setOssTemplate(ossTemplate);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.resource.rule.oss;
|
||||
|
||||
import com.amazonaws.ClientConfiguration;
|
||||
import com.amazonaws.auth.AWSCredentials;
|
||||
import com.amazonaws.auth.AWSStaticCredentialsProvider;
|
||||
import com.amazonaws.auth.BasicAWSCredentials;
|
||||
import com.amazonaws.client.builder.AwsClientBuilder;
|
||||
import com.amazonaws.regions.Regions;
|
||||
import com.amazonaws.services.s3.AmazonS3;
|
||||
import com.amazonaws.services.s3.AmazonS3ClientBuilder;
|
||||
import org.springblade.core.literule.annotation.LiteRuleComponent;
|
||||
import org.springblade.core.literule.core.RuleComponent;
|
||||
import org.springblade.core.oss.OssTemplate;
|
||||
import org.springblade.core.oss.S3Template;
|
||||
import org.springblade.core.oss.props.OssProperties;
|
||||
import org.springblade.core.oss.rule.OssRule;
|
||||
import org.springblade.core.tool.utils.StringUtil;
|
||||
import org.springblade.resource.pojo.entity.Oss;
|
||||
import org.springblade.resource.rule.context.OssContext;
|
||||
|
||||
import static org.springblade.resource.rule.constant.OssRuleConstant.AMAZON_S3_RULE;
|
||||
|
||||
/**
|
||||
* Amazon S3 云存储构建类
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
@LiteRuleComponent(id = AMAZON_S3_RULE, name = "amazonS3OSS构建")
|
||||
public class AmazonS3Rule extends RuleComponent {
|
||||
|
||||
@Override
|
||||
public void process() {
|
||||
// 获取上下文
|
||||
OssContext contextBean = this.getContextBean(OssContext.class);
|
||||
Oss oss = contextBean.getOss();
|
||||
OssRule ossRule = contextBean.getOssRule();
|
||||
|
||||
// 创建配置类
|
||||
OssProperties ossProperties = new OssProperties();
|
||||
ossProperties.setEndpoint(oss.getEndpoint());
|
||||
ossProperties.setTransformEndpoint(oss.getTransformEndpoint());
|
||||
ossProperties.setAccessKey(oss.getAccessKey());
|
||||
ossProperties.setSecretKey(oss.getSecretKey());
|
||||
ossProperties.setBucketName(oss.getBucketName());
|
||||
ossProperties.setRegion(oss.getRegion());
|
||||
// 创建客户端
|
||||
AWSCredentials credentials = new BasicAWSCredentials(ossProperties.getAccessKey(), ossProperties.getSecretKey());
|
||||
ClientConfiguration clientConfiguration = new ClientConfiguration();
|
||||
clientConfiguration.setSignerOverride("AWSS3V4SignerType");
|
||||
AmazonS3 amazonS3 = AmazonS3ClientBuilder
|
||||
.standard()
|
||||
.withEndpointConfiguration(new AwsClientBuilder.
|
||||
EndpointConfiguration(ossProperties.getEndpoint(),
|
||||
StringUtil.isBlank(ossProperties.getRegion()) ? Regions.DEFAULT_REGION.name() : Regions.fromName(ossProperties.getRegion()).getName()))
|
||||
.withPathStyleAccessEnabled(true)
|
||||
.withClientConfiguration(clientConfiguration)
|
||||
.withCredentials(new AWSStaticCredentialsProvider(credentials))
|
||||
.build();
|
||||
OssTemplate ossTemplate = new S3Template(amazonS3, ossRule, ossProperties);
|
||||
|
||||
// 设置上下文
|
||||
contextBean.setOssTemplate(ossTemplate);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.resource.rule.oss;
|
||||
|
||||
import org.springblade.core.literule.annotation.LiteRuleComponent;
|
||||
import org.springblade.core.literule.core.RuleComponent;
|
||||
import org.springblade.core.log.exception.ServiceException;
|
||||
import org.springblade.core.oss.OssTemplate;
|
||||
import org.springblade.core.tool.utils.Func;
|
||||
import org.springblade.resource.pojo.entity.Oss;
|
||||
import org.springblade.resource.rule.context.OssContext;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import static org.springblade.resource.rule.constant.OssRuleConstant.FINALLY_OSS_RULE;
|
||||
|
||||
/**
|
||||
* Oss后置处理
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
@LiteRuleComponent(id = FINALLY_OSS_RULE, name = "OSS构建后置处理")
|
||||
public class FinallyOssRule extends RuleComponent {
|
||||
@Override
|
||||
public void process() {
|
||||
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,85 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.resource.rule.oss;
|
||||
|
||||
import com.obs.services.ObsClient;
|
||||
import com.obs.services.ObsConfiguration;
|
||||
import org.springblade.core.literule.annotation.LiteRuleComponent;
|
||||
import org.springblade.core.literule.core.RuleComponent;
|
||||
import org.springblade.core.oss.HuaweiObsTemplate;
|
||||
import org.springblade.core.oss.OssTemplate;
|
||||
import org.springblade.core.oss.props.OssProperties;
|
||||
import org.springblade.core.oss.rule.OssRule;
|
||||
import org.springblade.resource.pojo.entity.Oss;
|
||||
import org.springblade.resource.rule.context.OssContext;
|
||||
|
||||
import static org.springblade.resource.rule.constant.OssRuleConstant.HUAWEI_OBS_RULE;
|
||||
|
||||
/**
|
||||
* 华为云存储构建类
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
@LiteRuleComponent(id = HUAWEI_OBS_RULE, name = "华为OSS构建")
|
||||
public class HuaweiObsRule extends RuleComponent {
|
||||
@Override
|
||||
public void process() {
|
||||
// 获取上下文
|
||||
OssContext contextBean = this.getContextBean(OssContext.class);
|
||||
Oss oss = contextBean.getOss();
|
||||
OssRule ossRule = contextBean.getOssRule();
|
||||
|
||||
// 创建配置类
|
||||
OssProperties ossProperties = new OssProperties();
|
||||
ossProperties.setEndpoint(oss.getEndpoint());
|
||||
ossProperties.setTransformEndpoint(oss.getTransformEndpoint());
|
||||
ossProperties.setAccessKey(oss.getAccessKey());
|
||||
ossProperties.setSecretKey(oss.getSecretKey());
|
||||
ossProperties.setBucketName(oss.getBucketName());
|
||||
// 使用可定制各参数的配置类(ObsConfiguration)创建OBS客户端(ObsClient),创建完成后不支持再次修改参数
|
||||
ObsConfiguration conf = new ObsConfiguration();
|
||||
conf.setEndPoint(ossProperties.getEndpoint());
|
||||
// 设置OSSClient允许打开的最大HTTP连接数,默认为1024个。
|
||||
conf.setMaxConnections(1024);
|
||||
// 设置Socket层传输数据的超时时间,默认为50000毫秒。
|
||||
conf.setSocketTimeout(50000);
|
||||
// 设置建立连接的超时时间,默认为50000毫秒。
|
||||
conf.setConnectionTimeout(50000);
|
||||
// 设置从连接池中获取连接的超时时间(单位:毫秒),默认不超时。
|
||||
conf.setConnectionTimeout(1000);
|
||||
// 设置连接空闲超时时间。超时则关闭连接,默认为60000毫秒。
|
||||
conf.setIdleConnectionTime(60000);
|
||||
// 设置失败请求重试次数,默认为3次。
|
||||
conf.setMaxErrorRetry(5);
|
||||
// 创建客户端
|
||||
ObsClient obsClient = new ObsClient(ossProperties.getAccessKey(), ossProperties.getSecretKey(), conf);
|
||||
OssTemplate ossTemplate = new HuaweiObsTemplate(obsClient, ossProperties, ossRule);
|
||||
|
||||
// 设置上下文
|
||||
contextBean.setOssTemplate(ossTemplate);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.resource.rule.oss;
|
||||
|
||||
import org.springblade.core.literule.annotation.LiteRuleComponent;
|
||||
import org.springblade.core.literule.core.RuleComponent;
|
||||
import org.springblade.core.oss.LocalFileTemplate;
|
||||
import org.springblade.core.oss.OssTemplate;
|
||||
import org.springblade.core.oss.props.OssProperties;
|
||||
import org.springblade.core.oss.rule.OssRule;
|
||||
import org.springblade.resource.pojo.entity.Oss;
|
||||
import org.springblade.resource.rule.context.OssContext;
|
||||
|
||||
import static org.springblade.resource.rule.constant.OssRuleConstant.LOCAL_FILE_RULE;
|
||||
|
||||
/**
|
||||
* 本地云存储构建类
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
@LiteRuleComponent(id = LOCAL_FILE_RULE, name = "localFileOSS构建")
|
||||
public class LocalFileRule extends RuleComponent {
|
||||
|
||||
@Override
|
||||
public void process() {
|
||||
// 获取上下文
|
||||
OssContext contextBean = this.getContextBean(OssContext.class);
|
||||
Oss oss = contextBean.getOss();
|
||||
OssRule ossRule = contextBean.getOssRule();
|
||||
|
||||
// 创建配置类
|
||||
OssProperties ossProperties = new OssProperties();
|
||||
ossProperties.setEndpoint(oss.getEndpoint());
|
||||
ossProperties.setTransformEndpoint(oss.getTransformEndpoint());
|
||||
ossProperties.setAccessKey(oss.getAccessKey());
|
||||
ossProperties.setBucketName(oss.getBucketName());
|
||||
|
||||
OssTemplate ossTemplate = new LocalFileTemplate(ossRule, ossProperties);
|
||||
|
||||
// 设置上下文
|
||||
contextBean.setOssTemplate(ossTemplate);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.resource.rule.oss;
|
||||
|
||||
import io.minio.MinioClient;
|
||||
import org.springblade.core.literule.annotation.LiteRuleComponent;
|
||||
import org.springblade.core.literule.core.RuleComponent;
|
||||
import org.springblade.core.oss.MinioTemplate;
|
||||
import org.springblade.core.oss.OssTemplate;
|
||||
import org.springblade.core.oss.props.OssProperties;
|
||||
import org.springblade.core.oss.rule.OssRule;
|
||||
import org.springblade.resource.pojo.entity.Oss;
|
||||
import org.springblade.resource.rule.context.OssContext;
|
||||
|
||||
import static org.springblade.resource.rule.constant.OssRuleConstant.MINIO_RULE;
|
||||
|
||||
/**
|
||||
* Minio云存储构建类
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
@LiteRuleComponent(id = MINIO_RULE, name = "minioOSS构建")
|
||||
public class MinioRule extends RuleComponent {
|
||||
|
||||
@Override
|
||||
public void process() {
|
||||
// 获取上下文
|
||||
OssContext contextBean = this.getContextBean(OssContext.class);
|
||||
Oss oss = contextBean.getOss();
|
||||
OssRule ossRule = contextBean.getOssRule();
|
||||
|
||||
// 创建配置类
|
||||
OssProperties ossProperties = new OssProperties();
|
||||
ossProperties.setEndpoint(oss.getEndpoint());
|
||||
ossProperties.setTransformEndpoint(oss.getTransformEndpoint());
|
||||
ossProperties.setAccessKey(oss.getAccessKey());
|
||||
ossProperties.setSecretKey(oss.getSecretKey());
|
||||
ossProperties.setBucketName(oss.getBucketName());
|
||||
// 创建客户端
|
||||
MinioClient minioClient = MinioClient.builder()
|
||||
.endpoint(oss.getEndpoint())
|
||||
.credentials(oss.getAccessKey(), oss.getSecretKey())
|
||||
.build();
|
||||
OssTemplate ossTemplate = new MinioTemplate(minioClient, ossRule, ossProperties);
|
||||
|
||||
// 设置上下文
|
||||
contextBean.setOssTemplate(ossTemplate);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.resource.rule.oss;
|
||||
|
||||
import org.springblade.core.literule.annotation.LiteRuleComponent;
|
||||
import org.springblade.core.literule.core.RuleSwitchComponent;
|
||||
import org.springblade.core.log.exception.ServiceException;
|
||||
import org.springblade.core.oss.enums.OssEnum;
|
||||
import org.springblade.resource.pojo.entity.Oss;
|
||||
import org.springblade.resource.rule.context.OssContext;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.springblade.resource.rule.constant.OssRuleConstant.OSS_BUILD_RULE;
|
||||
|
||||
/**
|
||||
* Oss构建判断
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
@LiteRuleComponent(id = OSS_BUILD_RULE, name = "OSS构建条件判断")
|
||||
public class OssBuildRule extends RuleSwitchComponent {
|
||||
private static final Map<Integer, String> CATEGORY_RULE_MAP = new HashMap<>();
|
||||
|
||||
static {
|
||||
CATEGORY_RULE_MAP.put(OssEnum.MINIO.getCategory(), "minioRule");
|
||||
CATEGORY_RULE_MAP.put(OssEnum.QINIU.getCategory(), "qiniuOssRule");
|
||||
CATEGORY_RULE_MAP.put(OssEnum.ALI.getCategory(), "aliOssRule");
|
||||
CATEGORY_RULE_MAP.put(OssEnum.TENCENT.getCategory(), "tencentCosRule");
|
||||
CATEGORY_RULE_MAP.put(OssEnum.HUAWEI.getCategory(), "huaweiObsRule");
|
||||
CATEGORY_RULE_MAP.put(OssEnum.AMAZONS3.getCategory(), "amazonS3Rule");
|
||||
CATEGORY_RULE_MAP.put(OssEnum.LOCAL.getCategory(), "localFileRule");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> process() {
|
||||
OssContext contextBean = this.getContextBean(OssContext.class);
|
||||
Oss oss = contextBean.getOss();
|
||||
|
||||
String ruleName = CATEGORY_RULE_MAP.get(oss.getCategory());
|
||||
if (ruleName != null) {
|
||||
return Collections.singletonList(ruleName);
|
||||
}
|
||||
throw new ServiceException("未找到OSS配置");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.resource.rule.oss;
|
||||
|
||||
import org.springblade.core.literule.annotation.LiteRuleComponent;
|
||||
import org.springblade.core.literule.core.RuleSwitchComponent;
|
||||
import org.springblade.resource.rule.context.OssContext;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import static org.springblade.resource.rule.constant.OssRuleConstant.*;
|
||||
|
||||
/**
|
||||
* Oss缓存判断
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
@LiteRuleComponent(id = OSS_CACHE_RULE, name = "OSS缓存判断")
|
||||
public class OssCacheRule extends RuleSwitchComponent {
|
||||
|
||||
@Override
|
||||
public List<String> process() {
|
||||
OssContext contextBean = this.getContextBean(OssContext.class);
|
||||
// 若判断配置已缓存则直接读取,否则进入下一步构建新数据
|
||||
String ruleName = contextBean.getIsCached() ? OSS_READ_RULE : OSS_NEW_RULE;
|
||||
return Collections.singletonList(ruleName);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.resource.rule.oss;
|
||||
|
||||
import org.springblade.core.literule.annotation.LiteRuleComponent;
|
||||
import org.springblade.core.literule.core.RuleComponent;
|
||||
import org.springblade.core.oss.props.OssProperties;
|
||||
import org.springblade.core.oss.rule.BladeOssRule;
|
||||
import org.springblade.resource.pojo.entity.Oss;
|
||||
import org.springblade.resource.rule.context.OssContext;
|
||||
|
||||
import static org.springblade.resource.rule.constant.OssRuleConstant.OSS_DATA_RULE;
|
||||
|
||||
/**
|
||||
* OSS数据创建
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
@LiteRuleComponent(id = OSS_DATA_RULE, name = "OSS数据创建")
|
||||
public class OssDataRule extends RuleComponent {
|
||||
@Override
|
||||
public void process() {
|
||||
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,59 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.resource.rule.oss;
|
||||
|
||||
import org.springblade.core.literule.annotation.LiteRuleComponent;
|
||||
import org.springblade.core.literule.core.RuleComponent;
|
||||
import org.springblade.core.log.exception.ServiceException;
|
||||
import org.springblade.core.oss.OssTemplate;
|
||||
import org.springblade.core.tool.utils.Func;
|
||||
import org.springblade.resource.pojo.entity.Oss;
|
||||
import org.springblade.resource.rule.context.OssContext;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import static org.springblade.resource.rule.constant.OssRuleConstant.OSS_READ_RULE;
|
||||
|
||||
/**
|
||||
* OSS缓存读取校验
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
@LiteRuleComponent(id = OSS_READ_RULE, name = "OSS缓存读取校验")
|
||||
public class OssReadRule extends RuleComponent {
|
||||
@Override
|
||||
public void process() {
|
||||
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,53 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.resource.rule.oss;
|
||||
|
||||
import org.springblade.core.literule.annotation.LiteRuleComponent;
|
||||
import org.springblade.core.literule.core.RuleComponent;
|
||||
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;
|
||||
|
||||
import static org.springblade.resource.rule.constant.OssRuleConstant.OSS_TEMPLATE_RULE;
|
||||
|
||||
/**
|
||||
* OSS接口读取校验
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
@LiteRuleComponent(id = OSS_TEMPLATE_RULE, name = "OSS接口读取校验")
|
||||
public class OssTemplateRule extends RuleComponent {
|
||||
@Override
|
||||
public void process() {
|
||||
OssContext contextBean = this.getContextBean(OssContext.class);
|
||||
OssTemplate ossTemplate = contextBean.getOssTemplate();
|
||||
|
||||
if (Func.isEmpty(ossTemplate)) {
|
||||
throw new ServiceException("OSS接口读取失败!");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.resource.rule.oss;
|
||||
|
||||
import org.springblade.core.literule.annotation.LiteRuleComponent;
|
||||
import org.springblade.core.literule.core.RuleComponent;
|
||||
import org.springblade.core.oss.OssTemplate;
|
||||
import org.springblade.core.tool.utils.Func;
|
||||
import org.springblade.resource.pojo.entity.Oss;
|
||||
import org.springblade.resource.rule.context.OssContext;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import static org.springblade.resource.rule.constant.OssRuleConstant.PRE_OSS_RULE;
|
||||
|
||||
/**
|
||||
* Oss前置处理
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
@LiteRuleComponent(id = PRE_OSS_RULE, name = "OSS构建前置处理")
|
||||
public class PreOssRule extends RuleComponent {
|
||||
@Override
|
||||
public void process() {
|
||||
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)
|
||||
|| !Func.equalsSafe(oss.getEndpoint(), ossCached.getEndpoint())
|
||||
|| !Func.equalsSafe(oss.getTransformEndpoint(), ossCached.getTransformEndpoint())
|
||||
|| !Func.equalsSafe(oss.getAccessKey(), ossCached.getAccessKey())) {
|
||||
contextBean.setIsCached(Boolean.FALSE);
|
||||
} else {
|
||||
contextBean.setIsCached(Boolean.TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.resource.rule.oss;
|
||||
|
||||
import com.qiniu.storage.BucketManager;
|
||||
import com.qiniu.storage.Configuration;
|
||||
import com.qiniu.storage.Region;
|
||||
import com.qiniu.storage.UploadManager;
|
||||
import com.qiniu.util.Auth;
|
||||
import org.springblade.core.literule.annotation.LiteRuleComponent;
|
||||
import org.springblade.core.literule.core.RuleComponent;
|
||||
import org.springblade.core.oss.OssTemplate;
|
||||
import org.springblade.core.oss.QiniuTemplate;
|
||||
import org.springblade.core.oss.props.OssProperties;
|
||||
import org.springblade.core.oss.rule.OssRule;
|
||||
import org.springblade.resource.pojo.entity.Oss;
|
||||
import org.springblade.resource.rule.context.OssContext;
|
||||
|
||||
import static org.springblade.resource.rule.constant.OssRuleConstant.QINIU_OSS_RULE;
|
||||
|
||||
/**
|
||||
* 七牛云存储构建类
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
@LiteRuleComponent(id = QINIU_OSS_RULE, name = "七牛OSS构建")
|
||||
public class QiniuOssRule extends RuleComponent {
|
||||
|
||||
@Override
|
||||
public void process() {
|
||||
// 获取上下文
|
||||
OssContext contextBean = this.getContextBean(OssContext.class);
|
||||
Oss oss = contextBean.getOss();
|
||||
OssRule ossRule = contextBean.getOssRule();
|
||||
|
||||
|
||||
// 创建配置类
|
||||
OssProperties ossProperties = new OssProperties();
|
||||
ossProperties.setEndpoint(oss.getEndpoint());
|
||||
ossProperties.setTransformEndpoint(oss.getTransformEndpoint());
|
||||
ossProperties.setAccessKey(oss.getAccessKey());
|
||||
ossProperties.setSecretKey(oss.getSecretKey());
|
||||
ossProperties.setBucketName(oss.getBucketName());
|
||||
// 创建客户端
|
||||
Configuration cfg = new Configuration(Region.autoRegion());
|
||||
Auth auth = Auth.create(oss.getAccessKey(), oss.getSecretKey());
|
||||
UploadManager uploadManager = new UploadManager(cfg);
|
||||
BucketManager bucketManager = new BucketManager(auth, cfg);
|
||||
OssTemplate ossTemplate = new QiniuTemplate(auth, uploadManager, bucketManager, ossProperties, ossRule);
|
||||
|
||||
// 设置上下文
|
||||
contextBean.setOssTemplate(ossTemplate);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.resource.rule.oss;
|
||||
|
||||
import com.qcloud.cos.COSClient;
|
||||
import com.qcloud.cos.ClientConfig;
|
||||
import com.qcloud.cos.auth.BasicCOSCredentials;
|
||||
import com.qcloud.cos.auth.COSCredentials;
|
||||
import com.qcloud.cos.region.Region;
|
||||
import org.springblade.core.literule.annotation.LiteRuleComponent;
|
||||
import org.springblade.core.literule.core.RuleComponent;
|
||||
import org.springblade.core.oss.OssTemplate;
|
||||
import org.springblade.core.oss.TencentCosTemplate;
|
||||
import org.springblade.core.oss.props.OssProperties;
|
||||
import org.springblade.core.oss.rule.OssRule;
|
||||
import org.springblade.resource.pojo.entity.Oss;
|
||||
import org.springblade.resource.rule.context.OssContext;
|
||||
|
||||
import static org.springblade.resource.rule.constant.OssRuleConstant.TENCENT_COS_RULE;
|
||||
|
||||
/**
|
||||
* 腾讯云存储构建类
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
@LiteRuleComponent(id = TENCENT_COS_RULE, name = "腾讯云OSS构建")
|
||||
public class TencentCosRule extends RuleComponent {
|
||||
|
||||
@Override
|
||||
public void process() {
|
||||
// 获取上下文
|
||||
OssContext contextBean = this.getContextBean(OssContext.class);
|
||||
Oss oss = contextBean.getOss();
|
||||
OssRule ossRule = contextBean.getOssRule();
|
||||
|
||||
// 创建配置类
|
||||
OssProperties ossProperties = new OssProperties();
|
||||
ossProperties.setEndpoint(oss.getEndpoint());
|
||||
ossProperties.setTransformEndpoint(oss.getTransformEndpoint());
|
||||
ossProperties.setAccessKey(oss.getAccessKey());
|
||||
ossProperties.setSecretKey(oss.getSecretKey());
|
||||
ossProperties.setBucketName(oss.getBucketName());
|
||||
ossProperties.setAppId(oss.getAppId());
|
||||
ossProperties.setRegion(oss.getRegion());
|
||||
// 初始化用户身份信息(secretId, secretKey)
|
||||
COSCredentials credentials = new BasicCOSCredentials(ossProperties.getAccessKey(), ossProperties.getSecretKey());
|
||||
// 设置 bucket 的区域, COS 地域的简称请参照 https://cloud.tencent.com/document/product/436/6224
|
||||
Region region = new Region(ossProperties.getRegion());
|
||||
// clientConfig 中包含了设置 region, https(默认 http), 超时, 代理等 set 方法, 使用可参见源码或者常见问题 Java SDK 部分。
|
||||
ClientConfig clientConfig = new ClientConfig(region);
|
||||
// 设置OSSClient允许打开的最大HTTP连接数,默认为1024个。
|
||||
clientConfig.setMaxConnectionsCount(1024);
|
||||
// 设置Socket层传输数据的超时时间,默认为50000毫秒。
|
||||
clientConfig.setSocketTimeout(50000);
|
||||
// 设置建立连接的超时时间,默认为50000毫秒。
|
||||
clientConfig.setConnectionTimeout(50000);
|
||||
// 设置从连接池中获取连接的超时时间(单位:毫秒),默认不超时。
|
||||
clientConfig.setConnectionRequestTimeout(1000);
|
||||
COSClient cosClient = new COSClient(credentials, clientConfig);
|
||||
OssTemplate ossTemplate = new TencentCosTemplate(cosClient, ossProperties, ossRule);
|
||||
|
||||
// 设置上下文
|
||||
contextBean.setOssTemplate(ossTemplate);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.resource.rule.sms;
|
||||
|
||||
import com.aliyuncs.DefaultAcsClient;
|
||||
import com.aliyuncs.IAcsClient;
|
||||
import com.aliyuncs.profile.DefaultProfile;
|
||||
import com.aliyuncs.profile.IClientProfile;
|
||||
import org.springblade.core.literule.annotation.LiteRuleComponent;
|
||||
import org.springblade.core.literule.core.RuleComponent;
|
||||
import org.springblade.core.redis.cache.BladeRedis;
|
||||
import org.springblade.core.sms.AliSmsTemplate;
|
||||
import org.springblade.core.sms.SmsTemplate;
|
||||
import org.springblade.core.sms.props.SmsProperties;
|
||||
import org.springblade.resource.pojo.entity.Sms;
|
||||
import org.springblade.resource.rule.context.SmsContext;
|
||||
|
||||
import static org.springblade.resource.rule.constant.SmsRuleConstant.ALI_SMS_RULE;
|
||||
|
||||
/**
|
||||
* 阿里云短信构建类
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
@LiteRuleComponent(id = ALI_SMS_RULE, name = "阿里SMS构建")
|
||||
public class AliSmsRule extends RuleComponent {
|
||||
|
||||
@Override
|
||||
public void process() {
|
||||
// 获取上下文
|
||||
SmsContext contextBean = this.getContextBean(SmsContext.class);
|
||||
Sms sms = contextBean.getSms();
|
||||
BladeRedis bladeRedis = contextBean.getBladeRedis();
|
||||
|
||||
SmsProperties smsProperties = new SmsProperties();
|
||||
smsProperties.setTemplateId(sms.getTemplateId());
|
||||
smsProperties.setAccessKey(sms.getAccessKey());
|
||||
smsProperties.setSecretKey(sms.getSecretKey());
|
||||
smsProperties.setRegionId(sms.getRegionId());
|
||||
smsProperties.setSignName(sms.getSignName());
|
||||
IClientProfile profile = DefaultProfile.getProfile(smsProperties.getRegionId(), smsProperties.getAccessKey(), smsProperties.getSecretKey());
|
||||
IAcsClient acsClient = new DefaultAcsClient(profile);
|
||||
SmsTemplate smsTemplate = new AliSmsTemplate(smsProperties, acsClient, bladeRedis);
|
||||
|
||||
|
||||
// 设置上下文
|
||||
contextBean.setSmsTemplate(smsTemplate);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.resource.rule.sms;
|
||||
|
||||
import org.springblade.core.literule.annotation.LiteRuleComponent;
|
||||
import org.springblade.core.literule.core.RuleComponent;
|
||||
import org.springblade.core.log.exception.ServiceException;
|
||||
import org.springblade.core.sms.SmsTemplate;
|
||||
import org.springblade.core.tool.utils.Func;
|
||||
import org.springblade.resource.pojo.entity.Sms;
|
||||
import org.springblade.resource.rule.context.SmsContext;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import static org.springblade.resource.rule.constant.SmsRuleConstant.CACHE_SMS_RULE;
|
||||
|
||||
/**
|
||||
* 缓存短信构建类
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
@LiteRuleComponent(id = CACHE_SMS_RULE, name = "缓存SMS构建")
|
||||
public class CacheSmsRule extends RuleComponent {
|
||||
|
||||
@Override
|
||||
public void process() {
|
||||
// 获取上下文
|
||||
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,69 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.resource.rule.sms;
|
||||
|
||||
import org.springblade.core.literule.annotation.LiteRuleComponent;
|
||||
import org.springblade.core.literule.core.RuleComponent;
|
||||
import org.springblade.core.log.exception.ServiceException;
|
||||
import org.springblade.core.sms.SmsTemplate;
|
||||
import org.springblade.core.tool.utils.Func;
|
||||
import org.springblade.resource.pojo.entity.Sms;
|
||||
import org.springblade.resource.rule.context.SmsContext;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import static org.springblade.resource.rule.constant.SmsRuleConstant.FINALLY_SMS_RULE;
|
||||
|
||||
/**
|
||||
* Sms后置处理
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
@LiteRuleComponent(id = FINALLY_SMS_RULE, name = "SMS构建后置处理")
|
||||
public class FinallySmsRule extends RuleComponent {
|
||||
@Override
|
||||
public void process() {
|
||||
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,63 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.resource.rule.sms;
|
||||
|
||||
import org.springblade.core.literule.annotation.LiteRuleComponent;
|
||||
import org.springblade.core.literule.core.RuleComponent;
|
||||
import org.springblade.core.sms.SmsTemplate;
|
||||
import org.springblade.core.tool.utils.Func;
|
||||
import org.springblade.resource.pojo.entity.Sms;
|
||||
import org.springblade.resource.rule.context.SmsContext;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import static org.springblade.resource.rule.constant.SmsRuleConstant.PRE_SMS_RULE;
|
||||
|
||||
/**
|
||||
* Sms前置处理
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
@LiteRuleComponent(id = PRE_SMS_RULE, name = "SMS构建前置处理")
|
||||
public class PreSmsRule extends RuleComponent {
|
||||
@Override
|
||||
public void process() {
|
||||
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,69 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.resource.rule.sms;
|
||||
|
||||
import com.qiniu.sms.SmsManager;
|
||||
import com.qiniu.util.Auth;
|
||||
import org.springblade.core.literule.annotation.LiteRuleComponent;
|
||||
import org.springblade.core.literule.core.RuleComponent;
|
||||
import org.springblade.core.redis.cache.BladeRedis;
|
||||
import org.springblade.core.sms.QiniuSmsTemplate;
|
||||
import org.springblade.core.sms.SmsTemplate;
|
||||
import org.springblade.core.sms.props.SmsProperties;
|
||||
import org.springblade.resource.pojo.entity.Sms;
|
||||
import org.springblade.resource.rule.context.SmsContext;
|
||||
|
||||
import static org.springblade.resource.rule.constant.SmsRuleConstant.QINIU_SMS_RULE;
|
||||
|
||||
/**
|
||||
* 七牛云短信构建类
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
@LiteRuleComponent(id = QINIU_SMS_RULE, name = "七牛SMS构建")
|
||||
public class QiniuSmsRule extends RuleComponent {
|
||||
|
||||
@Override
|
||||
public void process() {
|
||||
// 获取上下文
|
||||
SmsContext contextBean = this.getContextBean(SmsContext.class);
|
||||
Sms sms = contextBean.getSms();
|
||||
BladeRedis bladeRedis = contextBean.getBladeRedis();
|
||||
|
||||
SmsProperties smsProperties = new SmsProperties();
|
||||
smsProperties.setTemplateId(sms.getTemplateId());
|
||||
smsProperties.setAccessKey(sms.getAccessKey());
|
||||
smsProperties.setSecretKey(sms.getSecretKey());
|
||||
smsProperties.setSignName(sms.getSignName());
|
||||
Auth auth = Auth.create(smsProperties.getAccessKey(), smsProperties.getSecretKey());
|
||||
SmsManager smsManager = new SmsManager(auth);
|
||||
SmsTemplate smsTemplate = new QiniuSmsTemplate(smsProperties, smsManager, bladeRedis);
|
||||
|
||||
// 设置上下文
|
||||
contextBean.setSmsTemplate(smsTemplate);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.resource.rule.sms;
|
||||
|
||||
import org.springblade.core.literule.annotation.LiteRuleComponent;
|
||||
import org.springblade.core.literule.core.RuleSwitchComponent;
|
||||
import org.springblade.core.log.exception.ServiceException;
|
||||
import org.springblade.core.sms.enums.SmsEnum;
|
||||
import org.springblade.resource.pojo.entity.Sms;
|
||||
import org.springblade.resource.rule.context.SmsContext;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.springblade.resource.rule.constant.SmsRuleConstant.SMS_BUILD_RULE;
|
||||
|
||||
/**
|
||||
* Sms构建判断
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
@LiteRuleComponent(id = SMS_BUILD_RULE, name = "SMS构建条件判断")
|
||||
public class SmsBuildRule extends RuleSwitchComponent {
|
||||
|
||||
private static final Map<Integer, String> CATEGORY_RULE_MAP = new HashMap<>();
|
||||
|
||||
static {
|
||||
CATEGORY_RULE_MAP.put(SmsEnum.YUNPIAN.getCategory(), "yunpianSmsRule");
|
||||
CATEGORY_RULE_MAP.put(SmsEnum.QINIU.getCategory(), "qiniuSmsRule");
|
||||
CATEGORY_RULE_MAP.put(SmsEnum.ALI.getCategory(), "aliSmsRule");
|
||||
CATEGORY_RULE_MAP.put(SmsEnum.TENCENT.getCategory(), "tencentSmsRule");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> process() {
|
||||
SmsContext contextBean = this.getContextBean(SmsContext.class);
|
||||
if (contextBean.getIsCached()) {
|
||||
return Collections.singletonList("cacheSmsRule");
|
||||
}
|
||||
Sms sms = contextBean.getSms();
|
||||
String ruleName = CATEGORY_RULE_MAP.get(sms.getCategory());
|
||||
if (ruleName != null) {
|
||||
return Collections.singletonList(ruleName);
|
||||
}
|
||||
throw new ServiceException("未找到SMS配置");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.resource.rule.sms;
|
||||
|
||||
import com.tencentcloudapi.common.Credential;
|
||||
import com.tencentcloudapi.sms.v20210111.SmsClient;
|
||||
import org.springblade.core.literule.annotation.LiteRuleComponent;
|
||||
import org.springblade.core.literule.core.RuleComponent;
|
||||
import org.springblade.core.redis.cache.BladeRedis;
|
||||
import org.springblade.core.sms.SmsTemplate;
|
||||
import org.springblade.core.sms.TencentSmsTemplate;
|
||||
import org.springblade.core.sms.props.SmsProperties;
|
||||
import org.springblade.resource.pojo.entity.Sms;
|
||||
import org.springblade.resource.rule.context.SmsContext;
|
||||
|
||||
import static org.springblade.resource.rule.constant.SmsRuleConstant.TENCENT_SMS_RULE;
|
||||
|
||||
/**
|
||||
* 腾讯云短信构建类
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
@LiteRuleComponent(id = TENCENT_SMS_RULE, name = "腾讯SMS构建")
|
||||
public class TencentSmsRule extends RuleComponent {
|
||||
|
||||
@Override
|
||||
public void process() {
|
||||
// 获取上下文
|
||||
SmsContext contextBean = this.getContextBean(SmsContext.class);
|
||||
Sms sms = contextBean.getSms();
|
||||
BladeRedis bladeRedis = contextBean.getBladeRedis();
|
||||
|
||||
SmsProperties smsProperties = new SmsProperties();
|
||||
smsProperties.setTemplateId(sms.getTemplateId());
|
||||
smsProperties.setAccessKey(sms.getAccessKey());
|
||||
smsProperties.setSecretKey(sms.getSecretKey());
|
||||
smsProperties.setAppId(sms.getAppId());
|
||||
smsProperties.setRegionId(sms.getRegionId());
|
||||
smsProperties.setSignName(sms.getSignName());
|
||||
|
||||
Credential cred = new Credential(smsProperties.getAccessKey(), smsProperties.getSecretKey());
|
||||
SmsClient client = new SmsClient(cred, smsProperties.getRegionId());
|
||||
SmsTemplate smsTemplate = new TencentSmsTemplate(smsProperties, client, bladeRedis);
|
||||
|
||||
// 设置上下文
|
||||
contextBean.setSmsTemplate(smsTemplate);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.resource.rule.sms;
|
||||
|
||||
import com.yunpian.sdk.YunpianClient;
|
||||
import org.springblade.core.literule.annotation.LiteRuleComponent;
|
||||
import org.springblade.core.literule.core.RuleComponent;
|
||||
import org.springblade.core.redis.cache.BladeRedis;
|
||||
import org.springblade.core.sms.SmsTemplate;
|
||||
import org.springblade.core.sms.YunpianSmsTemplate;
|
||||
import org.springblade.core.sms.props.SmsProperties;
|
||||
import org.springblade.resource.pojo.entity.Sms;
|
||||
import org.springblade.resource.rule.context.SmsContext;
|
||||
|
||||
import static org.springblade.resource.rule.constant.SmsRuleConstant.YUNPIAN_SMS_RULE;
|
||||
|
||||
/**
|
||||
* 云片短信构建类
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
@LiteRuleComponent(id = YUNPIAN_SMS_RULE, name = "云片SMS构建")
|
||||
public class YunpianSmsRule extends RuleComponent {
|
||||
|
||||
@Override
|
||||
public void process() {
|
||||
// 获取上下文
|
||||
SmsContext contextBean = this.getContextBean(SmsContext.class);
|
||||
Sms sms = contextBean.getSms();
|
||||
BladeRedis bladeRedis = contextBean.getBladeRedis();
|
||||
|
||||
SmsProperties smsProperties = new SmsProperties();
|
||||
smsProperties.setTemplateId(sms.getTemplateId());
|
||||
smsProperties.setAccessKey(sms.getAccessKey());
|
||||
smsProperties.setSignName(sms.getSignName());
|
||||
YunpianClient client = new YunpianClient(smsProperties.getAccessKey()).init();
|
||||
SmsTemplate smsTemplate = new YunpianSmsTemplate(smsProperties, client, bladeRedis);
|
||||
|
||||
// 设置上下文
|
||||
contextBean.setSmsTemplate(smsTemplate);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.resource.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import org.springblade.core.mp.base.BaseService;
|
||||
import org.springblade.resource.pojo.entity.Attach;
|
||||
import org.springblade.resource.pojo.vo.AttachVO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 附件表 服务类
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
public interface IAttachService extends BaseService<Attach> {
|
||||
|
||||
/**
|
||||
* 自定义分页
|
||||
*
|
||||
* @param page
|
||||
* @param attach
|
||||
* @return
|
||||
*/
|
||||
IPage<AttachVO> selectAttachPage(IPage<AttachVO> page, AttachVO attach);
|
||||
|
||||
/**
|
||||
* 删除附件(同时删除数据库记录和OSS文件)
|
||||
*
|
||||
* @param ids 主键集合
|
||||
* @return 是否成功
|
||||
*/
|
||||
boolean removeAttach(List<Long> ids);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.resource.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import org.springblade.core.mp.base.BaseService;
|
||||
import org.springblade.resource.pojo.entity.Oss;
|
||||
import org.springblade.resource.pojo.vo.OssVO;
|
||||
|
||||
/**
|
||||
* 服务类
|
||||
*
|
||||
* @author BladeX
|
||||
*/
|
||||
public interface IOssService extends BaseService<Oss> {
|
||||
|
||||
/**
|
||||
* 自定义分页
|
||||
*
|
||||
* @param page
|
||||
* @param oss
|
||||
* @return
|
||||
*/
|
||||
IPage<OssVO> selectOssPage(IPage<OssVO> page, OssVO oss);
|
||||
|
||||
/**
|
||||
* 提交oss信息
|
||||
*
|
||||
* @param oss
|
||||
* @return
|
||||
*/
|
||||
boolean submit(Oss oss);
|
||||
|
||||
/**
|
||||
* 启动配置
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
boolean enable(Long id);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.resource.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import org.springblade.core.mp.base.BaseService;
|
||||
import org.springblade.resource.pojo.entity.Sms;
|
||||
import org.springblade.resource.pojo.vo.SmsVO;
|
||||
|
||||
/**
|
||||
* 短信配置表 服务类
|
||||
*
|
||||
* @author BladeX
|
||||
*/
|
||||
public interface ISmsService extends BaseService<Sms> {
|
||||
|
||||
/**
|
||||
* 自定义分页
|
||||
*
|
||||
* @param page
|
||||
* @param sms
|
||||
* @return
|
||||
*/
|
||||
IPage<SmsVO> selectSmsPage(IPage<SmsVO> page, SmsVO sms);
|
||||
|
||||
/**
|
||||
* 提交oss信息
|
||||
*
|
||||
* @param oss
|
||||
* @return
|
||||
*/
|
||||
boolean submit(Sms oss);
|
||||
|
||||
/**
|
||||
* 启动配置
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
boolean enable(Long id);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.resource.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springblade.core.mp.base.BaseServiceImpl;
|
||||
import org.springblade.core.tool.utils.CollectionUtil;
|
||||
import org.springblade.resource.builder.OssBuilder;
|
||||
import org.springblade.resource.mapper.AttachMapper;
|
||||
import org.springblade.resource.pojo.entity.Attach;
|
||||
import org.springblade.resource.pojo.vo.AttachVO;
|
||||
import org.springblade.resource.service.IAttachService;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 附件表 服务实现类
|
||||
*
|
||||
* @author Chill
|
||||
*/
|
||||
@Service
|
||||
@AllArgsConstructor
|
||||
public class AttachServiceImpl extends BaseServiceImpl<AttachMapper, Attach> implements IAttachService {
|
||||
|
||||
private final OssBuilder ossBuilder;
|
||||
|
||||
@Override
|
||||
public IPage<AttachVO> selectAttachPage(IPage<AttachVO> page, AttachVO attach) {
|
||||
return page.setRecords(baseMapper.selectAttachPage(page, attach));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean removeAttach(List<Long> ids) {
|
||||
// 查询附件记录获取文件名
|
||||
List<Attach> attachList = this.listByIds(ids);
|
||||
if (CollectionUtil.isNotEmpty(attachList)) {
|
||||
// 循环删除OSS文件
|
||||
attachList.stream()
|
||||
.map(Attach::getName)
|
||||
.filter(name -> name != null && !name.isEmpty())
|
||||
.forEach(fileName -> ossBuilder.template().removeFile(fileName));
|
||||
}
|
||||
// 删除数据库记录
|
||||
return this.deleteLogic(ids);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.resource.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import org.springblade.core.log.exception.ServiceException;
|
||||
import org.springblade.core.mp.base.BaseServiceImpl;
|
||||
import org.springblade.core.secure.utils.AuthUtil;
|
||||
import org.springblade.core.tool.constant.BladeConstant;
|
||||
import org.springblade.core.tool.utils.Func;
|
||||
import org.springblade.resource.pojo.entity.Oss;
|
||||
import org.springblade.resource.pojo.vo.OssVO;
|
||||
import org.springblade.resource.mapper.OssMapper;
|
||||
import org.springblade.resource.service.IOssService;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
/**
|
||||
* 服务实现类
|
||||
*
|
||||
* @author BladeX
|
||||
*/
|
||||
@Service
|
||||
public class OssServiceImpl extends BaseServiceImpl<OssMapper, Oss> implements IOssService {
|
||||
|
||||
@Override
|
||||
public IPage<OssVO> selectOssPage(IPage<OssVO> page, OssVO oss) {
|
||||
return page.setRecords(baseMapper.selectOssPage(page, oss));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean submit(Oss oss) {
|
||||
LambdaQueryWrapper<Oss> lqw = Wrappers.<Oss>query().lambda().eq(Oss::getOssCode, oss.getOssCode());
|
||||
if (AuthUtil.isAdministrator()) {
|
||||
lqw.eq(Oss::getTenantId, BladeConstant.ADMIN_TENANT_ID);
|
||||
}
|
||||
Long cnt = baseMapper.selectCount(Func.isEmpty(oss.getId()) ? lqw : lqw.notIn(Oss::getId, oss.getId()));
|
||||
if (cnt > 0L) {
|
||||
throw new ServiceException("当前资源编号已存在!");
|
||||
}
|
||||
return this.saveOrUpdate(oss);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean enable(Long id) {
|
||||
// 先禁用
|
||||
LambdaUpdateWrapper<Oss> disableWrapper = Wrappers.<Oss>update().lambda().set(Oss::getStatus, 1);
|
||||
if (AuthUtil.isAdministrator()) {
|
||||
disableWrapper.eq(Oss::getTenantId, BladeConstant.ADMIN_TENANT_ID);
|
||||
}
|
||||
boolean temp1 = this.update(disableWrapper);
|
||||
// 再启用
|
||||
LambdaUpdateWrapper<Oss> enableWrapper = Wrappers.<Oss>update().lambda().set(Oss::getStatus, 2).eq(Oss::getId, id);
|
||||
if (AuthUtil.isAdministrator()) {
|
||||
enableWrapper.eq(Oss::getTenantId, BladeConstant.ADMIN_TENANT_ID);
|
||||
}
|
||||
boolean temp2 = this.update(enableWrapper);
|
||||
return temp1 && temp2;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.resource.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import org.springblade.core.log.exception.ServiceException;
|
||||
import org.springblade.core.mp.base.BaseServiceImpl;
|
||||
import org.springblade.core.secure.utils.AuthUtil;
|
||||
import org.springblade.core.tool.utils.Func;
|
||||
import org.springblade.resource.pojo.entity.Sms;
|
||||
import org.springblade.resource.mapper.SmsMapper;
|
||||
import org.springblade.resource.service.ISmsService;
|
||||
import org.springblade.resource.pojo.vo.SmsVO;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
/**
|
||||
* 短信配置表 服务实现类
|
||||
*
|
||||
* @author BladeX
|
||||
*/
|
||||
@Service
|
||||
public class SmsServiceImpl extends BaseServiceImpl<SmsMapper, Sms> implements ISmsService {
|
||||
|
||||
@Override
|
||||
public IPage<SmsVO> selectSmsPage(IPage<SmsVO> page, SmsVO sms) {
|
||||
return page.setRecords(baseMapper.selectSmsPage(page, sms));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean submit(Sms sms) {
|
||||
LambdaQueryWrapper<Sms> lqw = Wrappers.<Sms>query().lambda()
|
||||
.eq(Sms::getSmsCode, sms.getSmsCode()).eq(Sms::getTenantId, AuthUtil.getTenantId());
|
||||
Long cnt = baseMapper.selectCount(Func.isEmpty(sms.getId()) ? lqw : lqw.notIn(Sms::getId, sms.getId()));
|
||||
if (cnt > 0L) {
|
||||
throw new ServiceException("当前资源编号已存在!");
|
||||
}
|
||||
return this.saveOrUpdate(sms);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean enable(Long id) {
|
||||
// 先禁用
|
||||
boolean temp1 = this.update(Wrappers.<Sms>update().lambda().set(Sms::getStatus, 1));
|
||||
// 在启用
|
||||
boolean temp2 = this.update(Wrappers.<Sms>update().lambda().set(Sms::getStatus, 2).eq(Sms::getId, id));
|
||||
return temp1 && temp2;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.resource.wrapper;
|
||||
|
||||
import org.springblade.core.mp.support.BaseEntityWrapper;
|
||||
import org.springblade.core.tool.utils.BeanUtil;
|
||||
import org.springblade.resource.pojo.entity.Oss;
|
||||
import org.springblade.resource.pojo.vo.OssVO;
|
||||
import org.springblade.system.cache.DictCache;
|
||||
import org.springblade.system.pojo.enums.DictEnum;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 包装类,返回视图层所需的字段
|
||||
*
|
||||
* @author BladeX
|
||||
*/
|
||||
public class OssWrapper extends BaseEntityWrapper<Oss, OssVO> {
|
||||
|
||||
public static OssWrapper build() {
|
||||
return new OssWrapper();
|
||||
}
|
||||
|
||||
@Override
|
||||
public OssVO entityVO(Oss oss) {
|
||||
OssVO ossVO = Objects.requireNonNull(BeanUtil.copyProperties(oss, OssVO.class));
|
||||
String categoryName = DictCache.getValue(DictEnum.OSS, oss.getCategory());
|
||||
String statusName = DictCache.getValue(DictEnum.YES_NO, oss.getStatus());
|
||||
ossVO.setCategoryName(categoryName);
|
||||
ossVO.setStatusName(statusName);
|
||||
return ossVO;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
/**
|
||||
* BladeX Commercial License Agreement
|
||||
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||
* <p>
|
||||
* Use of this software is governed by the Commercial License Agreement
|
||||
* obtained after purchasing a license from BladeX.
|
||||
* <p>
|
||||
* 1. This software is for development use only under a valid license
|
||||
* from BladeX.
|
||||
* <p>
|
||||
* 2. Redistribution of this software's source code to any third party
|
||||
* without a commercial license is strictly prohibited.
|
||||
* <p>
|
||||
* 3. Licensees may copyright their own code but cannot use segments
|
||||
* from this software for such purposes. Copyright of this software
|
||||
* remains with BladeX.
|
||||
* <p>
|
||||
* Using this software signifies agreement to this License, and the software
|
||||
* must not be used for illegal purposes.
|
||||
* <p>
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||
* not liable for any claims arising from secondary or illegal development.
|
||||
* <p>
|
||||
* Author: Chill Zhuang (bladejava@qq.com)
|
||||
*/
|
||||
package org.springblade.resource.wrapper;
|
||||
|
||||
import org.springblade.core.mp.support.BaseEntityWrapper;
|
||||
import org.springblade.core.tool.utils.BeanUtil;
|
||||
import org.springblade.resource.pojo.entity.Sms;
|
||||
import org.springblade.resource.pojo.vo.SmsVO;
|
||||
import org.springblade.system.cache.DictCache;
|
||||
import org.springblade.system.pojo.enums.DictEnum;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 短信配置表包装类,返回视图层所需的字段
|
||||
*
|
||||
* @author BladeX
|
||||
*/
|
||||
public class SmsWrapper extends BaseEntityWrapper<Sms, SmsVO> {
|
||||
|
||||
public static SmsWrapper build() {
|
||||
return new SmsWrapper();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SmsVO entityVO(Sms sms) {
|
||||
SmsVO smsVO = Objects.requireNonNull(BeanUtil.copyProperties(sms, SmsVO.class));
|
||||
String categoryName = DictCache.getValue(DictEnum.SMS, sms.getCategory());
|
||||
String statusName = DictCache.getValue(DictEnum.YES_NO, sms.getStatus());
|
||||
smsVO.setCategoryName(categoryName);
|
||||
smsVO.setStatusName(statusName);
|
||||
return smsVO;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
#数据源配置
|
||||
spring:
|
||||
datasource:
|
||||
url: ${blade.datasource.dev.url}
|
||||
username: ${blade.datasource.dev.username}
|
||||
password: ${blade.datasource.dev.password}
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
#数据源配置
|
||||
spring:
|
||||
datasource:
|
||||
url: ${blade.datasource.prod.url}
|
||||
username: ${blade.datasource.prod.username}
|
||||
password: ${blade.datasource.prod.password}
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
#数据源配置
|
||||
spring:
|
||||
datasource:
|
||||
url: ${blade.datasource.test.url}
|
||||
username: ${blade.datasource.test.username}
|
||||
password: ${blade.datasource.test.password}
|
||||
23
blade-ops/blade-resource/src/main/resources/application.yml
Normal file
23
blade-ops/blade-resource/src/main/resources/application.yml
Normal file
@@ -0,0 +1,23 @@
|
||||
#服务器端口
|
||||
server:
|
||||
port: 8010
|
||||
|
||||
#oss默认配置
|
||||
oss:
|
||||
#开启oss配置
|
||||
enabled: true
|
||||
#开启oss类型
|
||||
#minio、s3、qiniu、alioss、huaweiobs、tencentcos
|
||||
name: qiniu
|
||||
#租户模式
|
||||
tenant-mode: true
|
||||
#oss服务地址
|
||||
endpoint: http://prt1thnw3.bkt.clouddn.com
|
||||
#minio转换服务地址,用于内网上传后将返回地址改为转换的外网地址
|
||||
transform-endpoint: http://localhost:9000
|
||||
#访问key
|
||||
access-key: N_Loh1ngBqcJovwiAJqR91Ifj2vgOWHOf8AwBA_h
|
||||
#密钥key
|
||||
secret-key: AuzuA1KHAbkIndCU0dB3Zfii2O3crHNODDmpxHRS
|
||||
#存储桶
|
||||
bucket-name: bladex
|
||||
BIN
blade-ops/blade-resource/src/main/resources/liteflow/oss.el.png
Normal file
BIN
blade-ops/blade-resource/src/main/resources/liteflow/oss.el.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 229 KiB |
@@ -0,0 +1,25 @@
|
||||
<?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,
|
||||
localFileRule
|
||||
),
|
||||
ossTemplateRule
|
||||
).id("ossNewRule")
|
||||
),
|
||||
finallyOssRule
|
||||
);
|
||||
</chain>
|
||||
</flow>
|
||||
BIN
blade-ops/blade-resource/src/main/resources/liteflow/sms.el.png
Normal file
BIN
blade-ops/blade-resource/src/main/resources/liteflow/sms.el.png
Normal file
Binary file not shown.
|
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>
|
||||
Reference in New Issue
Block a user