commit
cf8613ab97
@ -0,0 +1,37 @@
|
|||||||
|
package org.dromara.resource.api;
|
||||||
|
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.dromara.common.core.utils.StringUtils;
|
||||||
|
import org.dromara.resource.api.domain.RemoteFile;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 文件服务(降级处理)
|
||||||
|
*
|
||||||
|
* @author Lion Li
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
public class RemoteFileServiceMock implements RemoteFileService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 上传文件
|
||||||
|
*
|
||||||
|
* @param file 文件信息
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public RemoteFile upload(String name, String originalFilename, String contentType, byte[] file) {
|
||||||
|
log.warn("服务调用异常 -> 降级处理");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过ossId查询对应的url
|
||||||
|
*
|
||||||
|
* @param ossIds ossId串逗号分隔
|
||||||
|
* @return url串逗号分隔
|
||||||
|
*/
|
||||||
|
public String selectUrlByIds(String ossIds) {
|
||||||
|
log.warn("服务调用异常 -> 降级处理");
|
||||||
|
return StringUtils.EMPTY;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,38 @@
|
|||||||
|
package org.dromara.resource.api;
|
||||||
|
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 消息服务
|
||||||
|
*
|
||||||
|
* @author Lion Li
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class RemoteMessageServiceStub implements RemoteMessageService {
|
||||||
|
|
||||||
|
private final RemoteMessageService remoteMessageService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发送消息
|
||||||
|
*
|
||||||
|
* @param sessionKey session主键 一般为用户id
|
||||||
|
* @param message 消息文本
|
||||||
|
*/
|
||||||
|
public void sendMessage(Long sessionKey, String message) {
|
||||||
|
try {
|
||||||
|
remoteMessageService.sendMessage(sessionKey, message);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.warn("websocket 功能未开启或服务未找到");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void publishAll(String message) {
|
||||||
|
try {
|
||||||
|
remoteMessageService.publishAll(message);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.warn("websocket 功能未开启或服务未找到");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,29 +0,0 @@
|
|||||||
package org.dromara.common.core.exception;
|
|
||||||
|
|
||||||
import java.io.Serial;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 检查异常
|
|
||||||
*
|
|
||||||
* @author ruoyi
|
|
||||||
*/
|
|
||||||
public class CheckedException extends RuntimeException {
|
|
||||||
@Serial
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
public CheckedException(String message) {
|
|
||||||
super(message);
|
|
||||||
}
|
|
||||||
|
|
||||||
public CheckedException(Throwable cause) {
|
|
||||||
super(cause);
|
|
||||||
}
|
|
||||||
|
|
||||||
public CheckedException(String message, Throwable cause) {
|
|
||||||
super(message, cause);
|
|
||||||
}
|
|
||||||
|
|
||||||
public CheckedException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
|
|
||||||
super(message, cause, enableSuppression, writableStackTrace);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,17 +0,0 @@
|
|||||||
package org.dromara.common.core.exception;
|
|
||||||
|
|
||||||
import java.io.Serial;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 演示模式异常
|
|
||||||
*
|
|
||||||
* @author ruoyi
|
|
||||||
*/
|
|
||||||
public class DemoModeException extends RuntimeException {
|
|
||||||
|
|
||||||
@Serial
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
public DemoModeException() {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,26 +0,0 @@
|
|||||||
package org.dromara.common.core.exception;
|
|
||||||
|
|
||||||
import java.io.Serial;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 工具类异常
|
|
||||||
*
|
|
||||||
* @author ruoyi
|
|
||||||
*/
|
|
||||||
public class UtilException extends RuntimeException {
|
|
||||||
|
|
||||||
@Serial
|
|
||||||
private static final long serialVersionUID = 8247610319171014183L;
|
|
||||||
|
|
||||||
public UtilException(Throwable e) {
|
|
||||||
super(e.getMessage(), e);
|
|
||||||
}
|
|
||||||
|
|
||||||
public UtilException(String message) {
|
|
||||||
super(message);
|
|
||||||
}
|
|
||||||
|
|
||||||
public UtilException(String message, Throwable throwable) {
|
|
||||||
super(message, throwable);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,6 +1,4 @@
|
|||||||
package org.dromara.common.core.exception;
|
package org.dromara.common.core.exception.user;
|
||||||
|
|
||||||
import org.dromara.common.core.exception.user.UserException;
|
|
||||||
|
|
||||||
import java.io.Serial;
|
import java.io.Serial;
|
||||||
|
|
||||||
@ -1,18 +0,0 @@
|
|||||||
package org.dromara.common.core.exception.user;
|
|
||||||
|
|
||||||
import java.io.Serial;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 用户密码不正确或不符合规范异常类
|
|
||||||
*
|
|
||||||
* @author ruoyi
|
|
||||||
*/
|
|
||||||
public class UserPasswordNotMatchException extends UserException {
|
|
||||||
|
|
||||||
@Serial
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
public UserPasswordNotMatchException() {
|
|
||||||
super("user.password.not.match");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -0,0 +1,123 @@
|
|||||||
|
package org.dromara.common.encrypt.filter;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.RandomUtil;
|
||||||
|
import jakarta.servlet.ServletOutputStream;
|
||||||
|
import jakarta.servlet.WriteListener;
|
||||||
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
|
import jakarta.servlet.http.HttpServletResponseWrapper;
|
||||||
|
import org.dromara.common.encrypt.utils.EncryptUtils;
|
||||||
|
|
||||||
|
import java.io.ByteArrayOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.OutputStreamWriter;
|
||||||
|
import java.io.PrintWriter;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 加密响应参数包装类
|
||||||
|
*
|
||||||
|
* @author Michelle.Chung
|
||||||
|
*/
|
||||||
|
public class EncryptResponseBodyWrapper extends HttpServletResponseWrapper {
|
||||||
|
|
||||||
|
private final ByteArrayOutputStream byteArrayOutputStream;
|
||||||
|
private final ServletOutputStream servletOutputStream;
|
||||||
|
private final PrintWriter printWriter;
|
||||||
|
|
||||||
|
public EncryptResponseBodyWrapper(HttpServletResponse response) throws IOException {
|
||||||
|
super(response);
|
||||||
|
this.byteArrayOutputStream = new ByteArrayOutputStream();
|
||||||
|
this.servletOutputStream = this.getOutputStream();
|
||||||
|
this.printWriter = new PrintWriter(new OutputStreamWriter(byteArrayOutputStream));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PrintWriter getWriter() {
|
||||||
|
return printWriter;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void flushBuffer() throws IOException {
|
||||||
|
if (servletOutputStream != null) {
|
||||||
|
servletOutputStream.flush();
|
||||||
|
}
|
||||||
|
if (printWriter != null) {
|
||||||
|
printWriter.flush();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void reset() {
|
||||||
|
byteArrayOutputStream.reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte[] getResponseData() throws IOException {
|
||||||
|
flushBuffer();
|
||||||
|
return byteArrayOutputStream.toByteArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getContent() throws IOException {
|
||||||
|
flushBuffer();
|
||||||
|
return byteArrayOutputStream.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取加密内容
|
||||||
|
*
|
||||||
|
* @param servletResponse response
|
||||||
|
* @param publicKey RSA公钥 (用于加密 AES 秘钥)
|
||||||
|
* @param headerFlag 请求头标志
|
||||||
|
* @return 加密内容
|
||||||
|
* @throws IOException
|
||||||
|
*/
|
||||||
|
public String getEncryptContent(HttpServletResponse servletResponse, String publicKey, String headerFlag) throws IOException {
|
||||||
|
// 生成秘钥
|
||||||
|
String aesPassword = RandomUtil.randomString(32);
|
||||||
|
// 秘钥使用 Base64 编码
|
||||||
|
String encryptAes = EncryptUtils.encryptByBase64(aesPassword);
|
||||||
|
// Rsa 公钥加密 Base64 编码
|
||||||
|
String encryptPassword = EncryptUtils.encryptByRsa(encryptAes, publicKey);
|
||||||
|
|
||||||
|
// 设置响应头
|
||||||
|
servletResponse.setHeader(headerFlag, encryptPassword);
|
||||||
|
servletResponse.setHeader("Access-Control-Allow-Origin", "*");
|
||||||
|
servletResponse.setHeader("Access-Control-Allow-Methods", "*");
|
||||||
|
servletResponse.setCharacterEncoding(StandardCharsets.UTF_8.toString());
|
||||||
|
|
||||||
|
// 获取原始内容
|
||||||
|
String originalBody = this.getContent();
|
||||||
|
// 对内容进行加密
|
||||||
|
return EncryptUtils.encryptByAes(originalBody, aesPassword);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ServletOutputStream getOutputStream() throws IOException {
|
||||||
|
return new ServletOutputStream() {
|
||||||
|
@Override
|
||||||
|
public boolean isReady() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setWriteListener(WriteListener writeListener) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void write(int b) throws IOException {
|
||||||
|
byteArrayOutputStream.write(b);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void write(byte[] b) throws IOException {
|
||||||
|
byteArrayOutputStream.write(b);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void write(byte[] b, int off, int len) throws IOException {
|
||||||
|
byteArrayOutputStream.write(b, off, len);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,30 @@
|
|||||||
|
<?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>
|
||||||
|
<groupId>org.dromara</groupId>
|
||||||
|
<artifactId>ruoyi-common</artifactId>
|
||||||
|
<version>${revision}</version>
|
||||||
|
</parent>
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<artifactId>ruoyi-common-ratelimiter</artifactId>
|
||||||
|
|
||||||
|
<description>
|
||||||
|
ruoyi-common-ratelimiter 限流功能
|
||||||
|
</description>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.dromara</groupId>
|
||||||
|
<artifactId>ruoyi-common-core</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.dromara</groupId>
|
||||||
|
<artifactId>ruoyi-common-redis</artifactId>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
</project>
|
||||||
@ -0,0 +1,41 @@
|
|||||||
|
package org.dromara.common.ratelimiter.annotation;
|
||||||
|
|
||||||
|
import org.dromara.common.ratelimiter.enums.LimitType;
|
||||||
|
|
||||||
|
import java.lang.annotation.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 限流注解
|
||||||
|
*
|
||||||
|
* @author Lion Li
|
||||||
|
*/
|
||||||
|
@Target(ElementType.METHOD)
|
||||||
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
@Documented
|
||||||
|
public @interface RateLimiter {
|
||||||
|
/**
|
||||||
|
* 限流key,支持使用Spring el表达式来动态获取方法上的参数值
|
||||||
|
* 格式类似于 #code.id #{#code}
|
||||||
|
*/
|
||||||
|
String key() default "";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 限流时间,单位秒
|
||||||
|
*/
|
||||||
|
int time() default 60;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 限流次数
|
||||||
|
*/
|
||||||
|
int count() default 100;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 限流类型
|
||||||
|
*/
|
||||||
|
LimitType limitType() default LimitType.DEFAULT;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 提示消息 支持国际化 格式为 {code}
|
||||||
|
*/
|
||||||
|
String message() default "{rate.limiter.message}";
|
||||||
|
}
|
||||||
@ -0,0 +1,127 @@
|
|||||||
|
package org.dromara.common.ratelimiter.aspectj;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.ArrayUtil;
|
||||||
|
import org.dromara.common.core.constant.GlobalConstants;
|
||||||
|
import org.dromara.common.core.exception.ServiceException;
|
||||||
|
import org.dromara.common.core.utils.MessageUtils;
|
||||||
|
import org.dromara.common.core.utils.ServletUtils;
|
||||||
|
import org.dromara.common.core.utils.StringUtils;
|
||||||
|
import org.dromara.common.ratelimiter.annotation.RateLimiter;
|
||||||
|
import org.dromara.common.ratelimiter.enums.LimitType;
|
||||||
|
import org.dromara.common.redis.utils.RedisUtils;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.aspectj.lang.JoinPoint;
|
||||||
|
import org.aspectj.lang.annotation.Aspect;
|
||||||
|
import org.aspectj.lang.annotation.Before;
|
||||||
|
import org.aspectj.lang.reflect.MethodSignature;
|
||||||
|
import org.redisson.api.RateType;
|
||||||
|
import org.springframework.core.DefaultParameterNameDiscoverer;
|
||||||
|
import org.springframework.core.ParameterNameDiscoverer;
|
||||||
|
import org.springframework.expression.EvaluationContext;
|
||||||
|
import org.springframework.expression.Expression;
|
||||||
|
import org.springframework.expression.ExpressionParser;
|
||||||
|
import org.springframework.expression.ParserContext;
|
||||||
|
import org.springframework.expression.common.TemplateParserContext;
|
||||||
|
import org.springframework.expression.spel.standard.SpelExpressionParser;
|
||||||
|
import org.springframework.expression.spel.support.StandardEvaluationContext;
|
||||||
|
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 限流处理
|
||||||
|
*
|
||||||
|
* @author Lion Li
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@Aspect
|
||||||
|
public class RateLimiterAspect {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 定义spel表达式解析器
|
||||||
|
*/
|
||||||
|
private final ExpressionParser parser = new SpelExpressionParser();
|
||||||
|
/**
|
||||||
|
* 定义spel解析模版
|
||||||
|
*/
|
||||||
|
private final ParserContext parserContext = new TemplateParserContext();
|
||||||
|
/**
|
||||||
|
* 定义spel上下文对象进行解析
|
||||||
|
*/
|
||||||
|
private final EvaluationContext context = new StandardEvaluationContext();
|
||||||
|
/**
|
||||||
|
* 方法参数解析器
|
||||||
|
*/
|
||||||
|
private final ParameterNameDiscoverer pnd = new DefaultParameterNameDiscoverer();
|
||||||
|
|
||||||
|
@Before("@annotation(rateLimiter)")
|
||||||
|
public void doBefore(JoinPoint point, RateLimiter rateLimiter) throws Throwable {
|
||||||
|
int time = rateLimiter.time();
|
||||||
|
int count = rateLimiter.count();
|
||||||
|
String combineKey = getCombineKey(rateLimiter, point);
|
||||||
|
try {
|
||||||
|
RateType rateType = RateType.OVERALL;
|
||||||
|
if (rateLimiter.limitType() == LimitType.CLUSTER) {
|
||||||
|
rateType = RateType.PER_CLIENT;
|
||||||
|
}
|
||||||
|
long number = RedisUtils.rateLimiter(combineKey, rateType, count, time);
|
||||||
|
if (number == -1) {
|
||||||
|
String message = rateLimiter.message();
|
||||||
|
if (StringUtils.startsWith(message, "{") && StringUtils.endsWith(message, "}")) {
|
||||||
|
message = MessageUtils.message(StringUtils.substring(message, 1, message.length() - 1));
|
||||||
|
}
|
||||||
|
throw new ServiceException(message);
|
||||||
|
}
|
||||||
|
log.info("限制令牌 => {}, 剩余令牌 => {}, 缓存key => '{}'", count, number, combineKey);
|
||||||
|
} catch (Exception e) {
|
||||||
|
if (e instanceof ServiceException) {
|
||||||
|
throw e;
|
||||||
|
} else {
|
||||||
|
throw new RuntimeException("服务器限流异常,请稍候再试");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCombineKey(RateLimiter rateLimiter, JoinPoint point) {
|
||||||
|
String key = rateLimiter.key();
|
||||||
|
// 获取方法(通过方法签名来获取)
|
||||||
|
MethodSignature signature = (MethodSignature) point.getSignature();
|
||||||
|
Method method = signature.getMethod();
|
||||||
|
Class<?> targetClass = method.getDeclaringClass();
|
||||||
|
// 判断是否是spel格式
|
||||||
|
if (StringUtils.containsAny(key, "#")) {
|
||||||
|
// 获取参数值
|
||||||
|
Object[] args = point.getArgs();
|
||||||
|
// 获取方法上参数的名称
|
||||||
|
String[] parameterNames = pnd.getParameterNames(method);
|
||||||
|
if (ArrayUtil.isEmpty(parameterNames)) {
|
||||||
|
throw new ServiceException("限流key解析异常!请联系管理员!");
|
||||||
|
}
|
||||||
|
for (int i = 0; i < parameterNames.length; i++) {
|
||||||
|
context.setVariable(parameterNames[i], args[i]);
|
||||||
|
}
|
||||||
|
// 解析返回给key
|
||||||
|
try {
|
||||||
|
Expression expression;
|
||||||
|
if (StringUtils.startsWith(key, parserContext.getExpressionPrefix())
|
||||||
|
&& StringUtils.endsWith(key, parserContext.getExpressionSuffix())) {
|
||||||
|
expression = parser.parseExpression(key, parserContext);
|
||||||
|
} else {
|
||||||
|
expression = parser.parseExpression(key);
|
||||||
|
}
|
||||||
|
key = expression.getValue(context, String.class) + ":";
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new ServiceException("限流key解析异常!请联系管理员!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
StringBuilder stringBuffer = new StringBuilder(GlobalConstants.RATE_LIMIT_KEY);
|
||||||
|
stringBuffer.append(ServletUtils.getRequest().getRequestURI()).append(":");
|
||||||
|
if (rateLimiter.limitType() == LimitType.IP) {
|
||||||
|
// 获取请求ip
|
||||||
|
stringBuffer.append(ServletUtils.getClientIP()).append(":");
|
||||||
|
} else if (rateLimiter.limitType() == LimitType.CLUSTER) {
|
||||||
|
// 获取客户端实例id
|
||||||
|
stringBuffer.append(RedisUtils.getClient().getId()).append(":");
|
||||||
|
}
|
||||||
|
return stringBuffer.append(key).toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,20 @@
|
|||||||
|
package org.dromara.common.ratelimiter.config;
|
||||||
|
|
||||||
|
import org.dromara.common.ratelimiter.aspectj.RateLimiterAspect;
|
||||||
|
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.data.redis.connection.RedisConfiguration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author guangxin
|
||||||
|
* @date 2023/1/18
|
||||||
|
*/
|
||||||
|
@AutoConfiguration(after = RedisConfiguration.class)
|
||||||
|
public class RateLimiterConfig {
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public RateLimiterAspect rateLimiterAspect() {
|
||||||
|
return new RateLimiterAspect();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,24 @@
|
|||||||
|
package org.dromara.common.ratelimiter.enums;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 限流类型
|
||||||
|
*
|
||||||
|
* @author ruoyi
|
||||||
|
*/
|
||||||
|
|
||||||
|
public enum LimitType {
|
||||||
|
/**
|
||||||
|
* 默认策略全局限流
|
||||||
|
*/
|
||||||
|
DEFAULT,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据请求者IP进行限流
|
||||||
|
*/
|
||||||
|
IP,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 实例限流(集群多后端实例)
|
||||||
|
*/
|
||||||
|
CLUSTER
|
||||||
|
}
|
||||||
@ -0,0 +1 @@
|
|||||||
|
org.dromara.common.ratelimiter.config.RateLimiterConfig
|
||||||
@ -1,19 +0,0 @@
|
|||||||
package com.ruoyi.common.sms.config.properties;//package com.ruoyi.common.sms.config.properties;
|
|
||||||
//
|
|
||||||
//import lombok.Data;
|
|
||||||
//import org.springframework.boot.context.properties.ConfigurationProperties;
|
|
||||||
//import org.springframework.stereotype.Component;
|
|
||||||
//
|
|
||||||
///**
|
|
||||||
// * SMS短信 配置属性
|
|
||||||
// *
|
|
||||||
// * @author Lion Li
|
|
||||||
// * @version 4.2.0
|
|
||||||
// */
|
|
||||||
//@Data
|
|
||||||
//@ConfigurationProperties(prefix = "sms")
|
|
||||||
//public class SmsProperties {
|
|
||||||
//
|
|
||||||
// private Boolean enabled;
|
|
||||||
//
|
|
||||||
//}
|
|
||||||
@ -1,15 +1,14 @@
|
|||||||
package com.ruoyi.common.sms.config;
|
package org.dromara.common.sms.config;
|
||||||
|
|
||||||
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 短信配置类
|
* 短信配置类(暂时没用 预留扩展)
|
||||||
*
|
*
|
||||||
* @author Lion Li
|
* @author Lion Li
|
||||||
* @version 4.2.0
|
* @version 4.2.0
|
||||||
*/
|
*/
|
||||||
@AutoConfiguration
|
@AutoConfiguration
|
||||||
//@EnableConfigurationProperties(SmsProperties.class)
|
|
||||||
public class SmsAutoConfiguration {
|
public class SmsAutoConfiguration {
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -1 +1 @@
|
|||||||
com.ruoyi.common.sms.config.SmsAutoConfiguration
|
org.dromara.common.sms.config.SmsAutoConfiguration
|
||||||
|
|||||||
@ -0,0 +1,26 @@
|
|||||||
|
package org.dromara.common.translation.core.impl;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import org.apache.dubbo.config.annotation.DubboReference;
|
||||||
|
import org.dromara.common.translation.annotation.TranslationType;
|
||||||
|
import org.dromara.common.translation.constant.TransConstant;
|
||||||
|
import org.dromara.common.translation.core.TranslationInterface;
|
||||||
|
import org.dromara.system.api.RemoteUserService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户昵称翻译实现
|
||||||
|
*
|
||||||
|
* @author may
|
||||||
|
*/
|
||||||
|
@AllArgsConstructor
|
||||||
|
@TranslationType(type = TransConstant.USER_ID_TO_NICKNAME)
|
||||||
|
public class NicknameTranslationImpl implements TranslationInterface<String> {
|
||||||
|
|
||||||
|
@DubboReference
|
||||||
|
private RemoteUserService remoteUserService;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String translation(Object key, String other) {
|
||||||
|
return remoteUserService.selectNicknameById((Long) key);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,7 +1,7 @@
|
|||||||
package org.dromara.demo.esmapper;
|
package org.dromara.demo.esmapper;
|
||||||
|
|
||||||
import cn.easyes.core.conditions.interfaces.BaseEsMapper;
|
|
||||||
import org.dromara.demo.domain.Document;
|
import org.dromara.demo.domain.Document;
|
||||||
|
import org.dromara.easyes.core.core.BaseEsMapper;
|
||||||
|
|
||||||
public interface DocumentMapper extends BaseEsMapper<Document> {
|
public interface DocumentMapper extends BaseEsMapper<Document> {
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue