init
This commit is contained in:
28
ruoyi-api/ruoyi-api-resource/pom.xml
Normal file
28
ruoyi-api/ruoyi-api-resource/pom.xml
Normal file
@@ -0,0 +1,28 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<groupId>org.dromara</groupId>
|
||||
<artifactId>ruoyi-api</artifactId>
|
||||
<version>${revision}</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>ruoyi-api-resource</artifactId>
|
||||
|
||||
<description>
|
||||
ruoyi-api-resource 资源服务接口模块
|
||||
</description>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<!-- RuoYi Common Core-->
|
||||
<dependency>
|
||||
<groupId>org.dromara</groupId>
|
||||
<artifactId>ruoyi-common-core</artifactId>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
</project>
|
@@ -0,0 +1,38 @@
|
||||
package org.dromara.resource.api;
|
||||
|
||||
import org.dromara.common.core.exception.ServiceException;
|
||||
import org.dromara.resource.api.domain.RemoteFile;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 文件服务
|
||||
*
|
||||
* @author Lion Li
|
||||
*/
|
||||
public interface RemoteFileService {
|
||||
|
||||
/**
|
||||
* 上传文件
|
||||
*
|
||||
* @param file 文件信息
|
||||
* @return 结果
|
||||
*/
|
||||
RemoteFile upload(String name, String originalFilename, String contentType, byte[] file) throws ServiceException;
|
||||
|
||||
/**
|
||||
* 通过ossId查询对应的url
|
||||
*
|
||||
* @param ossIds ossId串逗号分隔
|
||||
* @return url串逗号分隔
|
||||
*/
|
||||
String selectUrlByIds(String ossIds);
|
||||
|
||||
/**
|
||||
* 通过ossId查询列表
|
||||
*
|
||||
* @param ossIds ossId串逗号分隔
|
||||
* @return 列表
|
||||
*/
|
||||
List<RemoteFile> selectByIds(String ossIds);
|
||||
}
|
@@ -0,0 +1,53 @@
|
||||
package org.dromara.resource.api;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.common.core.utils.StringUtils;
|
||||
import org.dromara.resource.api.domain.RemoteFile;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 文件服务(降级处理)
|
||||
*
|
||||
* @author Lion Li
|
||||
*/
|
||||
@Slf4j
|
||||
public class RemoteFileServiceMock implements RemoteFileService {
|
||||
|
||||
/**
|
||||
* 上传文件
|
||||
*
|
||||
* @param file 文件信息
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public RemoteFile upload(String name, String originalFilename, String contentType, byte[] file) {
|
||||
log.warn("服务调用异常 -> 降级处理");
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过ossId查询对应的url
|
||||
*
|
||||
* @param ossIds ossId串逗号分隔
|
||||
* @return url串逗号分隔
|
||||
*/
|
||||
@Override
|
||||
public String selectUrlByIds(String ossIds) {
|
||||
log.warn("服务调用异常 -> 降级处理");
|
||||
return StringUtils.EMPTY;
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过ossId查询列表
|
||||
*
|
||||
* @param ossIds ossId串逗号分隔
|
||||
* @return 列表
|
||||
*/
|
||||
@Override
|
||||
public List<RemoteFile> selectByIds(String ossIds) {
|
||||
log.warn("服务调用异常 -> 降级处理");
|
||||
return List.of();
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,21 @@
|
||||
package org.dromara.resource.api;
|
||||
|
||||
import org.dromara.common.core.exception.ServiceException;
|
||||
|
||||
/**
|
||||
* 邮件服务
|
||||
*
|
||||
* @author Lion Li
|
||||
*/
|
||||
public interface RemoteMailService {
|
||||
|
||||
/**
|
||||
* 发送邮件
|
||||
*
|
||||
* @param to 接收人
|
||||
* @param subject 标题
|
||||
* @param text 内容
|
||||
*/
|
||||
void send(String to, String subject, String text) throws ServiceException;
|
||||
|
||||
}
|
@@ -0,0 +1,26 @@
|
||||
package org.dromara.resource.api;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 消息服务
|
||||
*
|
||||
* @author Lion Li
|
||||
*/
|
||||
public interface RemoteMessageService {
|
||||
|
||||
/**
|
||||
* 发送消息
|
||||
*
|
||||
* @param sessionKey session主键 一般为用户id
|
||||
* @param message 消息文本
|
||||
*/
|
||||
void publishMessage(List<Long> sessionKey, String message);
|
||||
|
||||
/**
|
||||
* 发布订阅的消息(群发)
|
||||
*
|
||||
* @param message 消息内容
|
||||
*/
|
||||
void publishAll(String message);
|
||||
}
|
@@ -0,0 +1,47 @@
|
||||
package org.dromara.resource.api;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 消息服务
|
||||
*
|
||||
* @author Lion Li
|
||||
*/
|
||||
@Slf4j
|
||||
@RequiredArgsConstructor
|
||||
public class RemoteMessageServiceStub implements RemoteMessageService {
|
||||
|
||||
private final RemoteMessageService remoteMessageService;
|
||||
|
||||
/**
|
||||
* 发送消息
|
||||
*
|
||||
* @param sessionKey session主键 一般为用户id
|
||||
* @param message 消息文本
|
||||
*/
|
||||
@Override
|
||||
public void publishMessage(List<Long> sessionKey, String message) {
|
||||
try {
|
||||
remoteMessageService.publishMessage(sessionKey, message);
|
||||
} catch (Exception e) {
|
||||
log.warn("推送功能未开启或服务未找到");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 发布订阅的消息(群发)
|
||||
*
|
||||
* @param message 消息内容
|
||||
*/
|
||||
@Override
|
||||
public void publishAll(String message) {
|
||||
try {
|
||||
remoteMessageService.publishAll(message);
|
||||
} catch (Exception e) {
|
||||
log.warn("推送功能未开启或服务未找到");
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,145 @@
|
||||
package org.dromara.resource.api;
|
||||
|
||||
import org.dromara.resource.api.domain.RemoteSms;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 短信服务
|
||||
*
|
||||
* @author Feng
|
||||
*/
|
||||
public interface RemoteSmsService {
|
||||
|
||||
/**
|
||||
* 同步方法:发送固定消息模板短信
|
||||
*
|
||||
* @param phone 目标手机号
|
||||
* @param message 短信内容
|
||||
* @return 封装了短信发送结果的 RemoteSms 对象
|
||||
*/
|
||||
RemoteSms sendMessage(String phone, String message);
|
||||
|
||||
/**
|
||||
* 同步方法:发送固定消息模板多模板参数短信
|
||||
*
|
||||
* @param phone 目标手机号
|
||||
* @param messages 短信模板参数,使用 LinkedHashMap 以保持参数顺序
|
||||
* @return 封装了短信发送结果的 RemoteSms 对象
|
||||
*/
|
||||
RemoteSms sendMessage(String phone, LinkedHashMap<String, String> messages);
|
||||
|
||||
/**
|
||||
* 同步方法:使用自定义模板发送短信
|
||||
*
|
||||
* @param phone 目标手机号
|
||||
* @param templateId 短信模板ID
|
||||
* @param messages 短信模板参数,使用 LinkedHashMap 以保持参数顺序
|
||||
* @return 封装了短信发送结果的 RemoteSms 对象
|
||||
*/
|
||||
RemoteSms sendMessage(String phone, String templateId, LinkedHashMap<String, String> messages);
|
||||
|
||||
/**
|
||||
* 同步方法:群发固定模板短信
|
||||
*
|
||||
* @param phones 目标手机号列表(1~1000)
|
||||
* @param message 短信内容
|
||||
* @return 封装了短信发送结果的 RemoteSms 对象
|
||||
*/
|
||||
RemoteSms messageTexting(List<String> phones, String message);
|
||||
|
||||
/**
|
||||
* 同步方法:使用自定义模板群发短信
|
||||
*
|
||||
* @param phones 目标手机号列表(1~1000)(1~1000)
|
||||
* @param templateId 短信模板ID
|
||||
* @param messages 短信模板参数,使用 LinkedHashMap 以保持参数顺序
|
||||
* @return 封装了短信发送结果的 RemoteSms 对象
|
||||
*/
|
||||
RemoteSms messageTexting(List<String> phones, String templateId, LinkedHashMap<String, String> messages);
|
||||
|
||||
/**
|
||||
* 异步方法:发送固定消息模板短信
|
||||
*
|
||||
* @param phone 目标手机号
|
||||
* @param message 短信内容
|
||||
*/
|
||||
void sendMessageAsync(String phone, String message);
|
||||
|
||||
/**
|
||||
* 异步方法:使用自定义模板发送短信
|
||||
*
|
||||
* @param phone 目标手机号
|
||||
* @param templateId 短信模板ID
|
||||
* @param messages 短信模板参数,使用 LinkedHashMap 以保持参数顺序
|
||||
*/
|
||||
void sendMessageAsync(String phone, String templateId, LinkedHashMap<String, String> messages);
|
||||
|
||||
/**
|
||||
* 延迟发送:发送固定消息模板短信
|
||||
*
|
||||
* @param phone 目标手机号
|
||||
* @param message 短信内容
|
||||
* @param delayedTime 延迟发送时间(毫秒)
|
||||
*/
|
||||
void delayMessage(String phone, String message, Long delayedTime);
|
||||
|
||||
/**
|
||||
* 延迟发送:使用自定义模板发送定时短信
|
||||
*
|
||||
* @param phone 目标手机号
|
||||
* @param templateId 短信模板ID
|
||||
* @param messages 短信模板参数,使用 LinkedHashMap 以保持参数顺序
|
||||
* @param delayedTime 延迟发送时间(毫秒)
|
||||
*/
|
||||
void delayMessage(String phone, String templateId, LinkedHashMap<String, String> messages, Long delayedTime);
|
||||
|
||||
/**
|
||||
* 延迟群发:群发延迟短信
|
||||
*
|
||||
* @param phones 目标手机号列表(1~1000)
|
||||
* @param message 短信内容
|
||||
* @param delayedTime 延迟发送时间(毫秒)
|
||||
*/
|
||||
void delayMessageTexting(List<String> phones, String message, Long delayedTime);
|
||||
|
||||
/**
|
||||
* 延迟群发:使用自定义模板发送群体延迟短信
|
||||
*
|
||||
* @param phones 目标手机号列表(1~1000)
|
||||
* @param templateId 短信模板ID
|
||||
* @param messages 短信模板参数,使用 LinkedHashMap 以保持参数顺序
|
||||
* @param delayedTime 延迟发送时间(毫秒)
|
||||
*/
|
||||
void delayMessageTexting(List<String> phones, String templateId, LinkedHashMap<String, String> messages, Long delayedTime);
|
||||
|
||||
/**
|
||||
* 加入黑名单
|
||||
*
|
||||
* @param phone 手机号
|
||||
*/
|
||||
void addBlacklist(String phone);
|
||||
|
||||
/**
|
||||
* 加入黑名单
|
||||
*
|
||||
* @param phones 手机号列表
|
||||
*/
|
||||
void addBlacklist(List<String> phones);
|
||||
|
||||
/**
|
||||
* 移除黑名单
|
||||
*
|
||||
* @param phone 手机号
|
||||
*/
|
||||
void removeBlacklist(String phone);
|
||||
|
||||
/**
|
||||
* 移除黑名单
|
||||
*
|
||||
* @param phones 手机号
|
||||
*/
|
||||
void removeBlacklist(List<String> phones);
|
||||
|
||||
}
|
@@ -0,0 +1,44 @@
|
||||
package org.dromara.resource.api.domain;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 文件信息
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@Data
|
||||
public class RemoteFile implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* oss主键
|
||||
*/
|
||||
private Long ossId;
|
||||
|
||||
/**
|
||||
* 文件名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 文件地址
|
||||
*/
|
||||
private String url;
|
||||
|
||||
/**
|
||||
* 原名
|
||||
*/
|
||||
private String originalName;
|
||||
|
||||
/**
|
||||
* 文件后缀名
|
||||
*/
|
||||
private String fileSuffix;
|
||||
|
||||
}
|
@@ -0,0 +1,36 @@
|
||||
package org.dromara.resource.api.domain;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 文件信息
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@Data
|
||||
public class RemoteSms implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 是否成功
|
||||
*/
|
||||
private Boolean success;
|
||||
|
||||
/**
|
||||
* 配置标识名 如未配置取对应渠道名例如 Alibaba
|
||||
*/
|
||||
private String configId;
|
||||
|
||||
/**
|
||||
* 厂商原返回体
|
||||
* <p>
|
||||
* 可自行转换为 SDK 对应的 SendSmsResponse
|
||||
*/
|
||||
private String response;
|
||||
|
||||
}
|
Reference in New Issue
Block a user