mirror of
https://gitee.com/dromara/RuoYi-Cloud-Plus.git
synced 2025-09-03 11:05:58 +00:00
!145 将现有sms4j版本升级到3X
Merge pull request !145 from AprilWind/feat/dev-sms3.x
This commit is contained in:
@@ -20,13 +20,12 @@
|
||||
<dependency>
|
||||
<groupId>org.dromara.sms4j</groupId>
|
||||
<artifactId>sms4j-spring-boot-starter</artifactId>
|
||||
<exclusions>
|
||||
<!-- 排除京东短信内存在的fastjson等待作者后续修复 -->
|
||||
<exclusion>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>fastjson</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
<!-- RuoYi Common Redis-->
|
||||
<dependency>
|
||||
<groupId>org.dromara</groupId>
|
||||
<artifactId>ruoyi-common-redis</artifactId>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
@@ -1,14 +1,24 @@
|
||||
package org.dromara.common.sms.config;
|
||||
|
||||
import org.dromara.common.redis.config.RedisConfiguration;
|
||||
import org.dromara.common.sms.core.dao.PlusSmsDao;
|
||||
import org.dromara.sms4j.api.dao.SmsDao;
|
||||
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Primary;
|
||||
|
||||
/**
|
||||
* 短信配置类(暂时没用 预留扩展)
|
||||
* 短信配置类
|
||||
*
|
||||
* @author Lion Li
|
||||
* @version 4.2.0
|
||||
* @author Feng
|
||||
*/
|
||||
@AutoConfiguration
|
||||
@AutoConfiguration(after = {RedisConfiguration.class})
|
||||
public class SmsAutoConfiguration {
|
||||
|
||||
@Primary
|
||||
@Bean
|
||||
public SmsDao smsDao() {
|
||||
return new PlusSmsDao();
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1,72 @@
|
||||
package org.dromara.common.sms.core.dao;
|
||||
|
||||
import org.dromara.common.core.constant.GlobalConstants;
|
||||
import org.dromara.common.redis.utils.RedisUtils;
|
||||
import org.dromara.sms4j.api.dao.SmsDao;
|
||||
|
||||
import java.time.Duration;
|
||||
|
||||
/**
|
||||
* SmsDao缓存配置 (使用框架自带RedisUtils实现 协议统一)
|
||||
* <p>主要用于短信重试和拦截的缓存
|
||||
*
|
||||
* @author Feng
|
||||
*/
|
||||
public class PlusSmsDao implements SmsDao {
|
||||
|
||||
/**
|
||||
* 存储
|
||||
*
|
||||
* @param key 键
|
||||
* @param value 值
|
||||
* @param cacheTime 缓存时间(单位:秒)
|
||||
*/
|
||||
@Override
|
||||
public void set(String key, Object value, long cacheTime) {
|
||||
RedisUtils.setCacheObject(GlobalConstants.GLOBAL_REDIS_KEY + key, value, Duration.ofSeconds(cacheTime));
|
||||
}
|
||||
|
||||
/**
|
||||
* 存储
|
||||
*
|
||||
* @param key 键
|
||||
* @param value 值
|
||||
*/
|
||||
@Override
|
||||
public void set(String key, Object value) {
|
||||
RedisUtils.setCacheObject(GlobalConstants.GLOBAL_REDIS_KEY + key, value, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 读取
|
||||
*
|
||||
* @param key 键
|
||||
* @return 值
|
||||
*/
|
||||
@Override
|
||||
public Object get(String key) {
|
||||
return RedisUtils.getCacheObject(GlobalConstants.GLOBAL_REDIS_KEY + key);
|
||||
}
|
||||
|
||||
/**
|
||||
* remove
|
||||
* <p> 根据key移除缓存
|
||||
*
|
||||
* @param key 缓存键
|
||||
* @return 被删除的value
|
||||
* @author :Wind
|
||||
*/
|
||||
@Override
|
||||
public Object remove(String key) {
|
||||
return RedisUtils.deleteObject(GlobalConstants.GLOBAL_REDIS_KEY + key);
|
||||
}
|
||||
|
||||
/**
|
||||
* 清空
|
||||
*/
|
||||
@Override
|
||||
public void clean() {
|
||||
RedisUtils.deleteObject(GlobalConstants.GLOBAL_REDIS_KEY + "sms:");
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user