mirror of
https://github.com/continew-org/continew-starter.git
synced 2025-11-13 04:57:13 +08:00
Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 9e78305e27 | |||
|
|
3e60197a31 | ||
| 881fd37dd6 | |||
| 9bee01baa3 | |||
| 1faa46e125 | |||
|
|
62121b78ec |
12
CHANGELOG.md
12
CHANGELOG.md
@@ -1,3 +1,15 @@
|
||||
## [v2.0.2](https://github.com/Charles7c/continew-starter/compare/v2.0.1...v2.0.2) (2024-05-20)
|
||||
|
||||
### ✨ 新特性
|
||||
|
||||
- 【file/excel】新增 Easy Excel List 集合转换器 ([1faa46e](https://github.com/Charles7c/continew-starter/commit/1faa46e12505c025e5ca6f1a45158324ac210799))
|
||||
|
||||
### 🐛 问题修复
|
||||
|
||||
- 【captcha/behavior】修复行为验证码接口请求次数限制 ([Gitee#17](https://gitee.com/continew/continew-starter/pulls/17))
|
||||
- 【extension/crud】修复封装分页 dataList 索引计算错误 ([3e60197](https://github.com/Charles7c/continew-starter/commit/3e60197a31f140c863868440944df0427a9cf8e8))
|
||||
- 移除部分错误依赖声明 ([881fd37](https://github.com/Charles7c/continew-starter/commit/881fd37dd61836daf3343d9053e9a7c81b005923))
|
||||
|
||||
## [v2.0.1](https://github.com/Charles7c/continew-starter/compare/v2.0.0...v2.0.1) (2024-05-13)
|
||||
|
||||
### ✨ 新特性
|
||||
|
||||
34
README.md
34
README.md
@@ -7,7 +7,7 @@
|
||||
<img src="https://img.shields.io/maven-central/v/top.continew/continew-starter.svg?label=Maven%20Central&logo=sonatype&logoColor=FFF" alt="Release" />
|
||||
</a>
|
||||
<a href="https://github.com/Charles7c/continew-starter" target="_blank">
|
||||
<img src="https://img.shields.io/badge/RELEASE-v2.0.1-%23ff3f59.svg" alt="Release" />
|
||||
<img src="https://img.shields.io/badge/RELEASE-v2.0.2-%23ff3f59.svg" alt="Release" />
|
||||
</a>
|
||||
<a href="https://app.codacy.com/gh/Charles7c/continew-starter/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_grade" target="_blank">
|
||||
<img src="https://app.codacy.com/project/badge/Grade/90ed633957a9410aa8745f0654827c01" alt="Codacy Badge" />
|
||||
@@ -16,7 +16,7 @@
|
||||
<img src="https://sonarcloud.io/api/project_badges/measure?project=Charles7c_continew-starter&metric=alert_status" alt="Sonar Status" />
|
||||
</a>
|
||||
<a href="https://spring.io/projects/spring-boot" target="_blank">
|
||||
<img src="https://img.shields.io/badge/Spring Boot-3.1.10-%236CB52D.svg?logo=Spring-Boot" alt="Spring Boot" />
|
||||
<img src="https://img.shields.io/badge/Spring Boot-3.1.11-%236CB52D.svg?logo=Spring-Boot" alt="Spring Boot" />
|
||||
</a>
|
||||
<a href="https://github.com/Charles7c/continew-starter" target="_blank">
|
||||
<img src="https://img.shields.io/badge/Open JDK-17-%236CB52D.svg?logo=OpenJDK&logoColor=FFF" alt="Open JDK" />
|
||||
@@ -141,9 +141,9 @@ continew-starter.web:
|
||||
|
||||
### 核心模块
|
||||
|
||||
| 模块名称 | 模块说明 | 依赖版本 |
|
||||
| --------------------- | ------------------------------------ | ------------------------------------------------------------ |
|
||||
| continew-starter-core | 核心模块:包含线程池、项目等自动配置 | <a href="https://spring.io/projects/spring-boot" target="_blank">Spring Boot</a>:3.1.8<br /><a href="https://www.hutool.cn/" target="_blank">Hutool</a>:5.8.25<br />mica-ip2region:3.1.7 |
|
||||
| 模块名称 | 模块说明 | 依赖版本 |
|
||||
| --------------------- | ------------------------------------ |-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||
| continew-starter-core | 核心模块:包含线程池、项目等自动配置 | <a href="https://spring.io/projects/spring-boot" target="_blank">Spring Boot</a>:3.1.11<br /><a href="https://www.hutool.cn/" target="_blank">Hutool</a>:5.8.25<br />mica-ip2region:3.1.7 |
|
||||
|
||||
### JSON模块
|
||||
|
||||
@@ -186,9 +186,9 @@ continew-starter.web:
|
||||
|
||||
### 文件处理模块
|
||||
|
||||
| 模块名称 | 模块说明 | 依赖版本 |
|
||||
| --------------------------- | -------------- | ------------------------------------------------------------ |
|
||||
| continew-starter-file-excel | Excel 相关配置 | <a href="https://easyexcel.opensource.alibaba.com/" target="_blank">Easy Excel</a>:3.3.3 |
|
||||
| 模块名称 | 模块说明 | 依赖版本 |
|
||||
| --------------------------- | -------------- |------------------------------------------------------------------------------------------|
|
||||
| continew-starter-file-excel | Excel 相关配置 | <a href="https://easyexcel.opensource.alibaba.com/" target="_blank">Easy Excel</a>:3.3.4 |
|
||||
|
||||
### 验证码模块
|
||||
|
||||
@@ -199,11 +199,11 @@ continew-starter.web:
|
||||
|
||||
### 缓存模块
|
||||
|
||||
| 模块名称 | 模块说明 | 依赖版本 |
|
||||
| ---------------------------------- | --------------------- | ------------------------------------------------------------ |
|
||||
| continew-starter-cache-redisson | Redisson 自动配置 | <a href="https://github.com/redisson/redisson/wiki/Redisson%E9%A1%B9%E7%9B%AE%E4%BB%8B%E7%BB%8D" target="_blank">Redisson</a>:3.26.0 |
|
||||
| continew-starter-cache-springcache | Spring Cache 自动配置 | |
|
||||
| continew-starter-cache-jetcache | JetCache 自动配置 | |
|
||||
| 模块名称 | 模块说明 | 依赖版本 |
|
||||
| ---------------------------------- | --------------------- |--------------------------------------------------------------------------------------------------------------------------------------|
|
||||
| continew-starter-cache-redisson | Redisson 自动配置 | <a href="https://github.com/redisson/redisson/wiki/Redisson%E9%A1%B9%E7%9B%AE%E4%BB%8B%E7%BB%8D" target="_blank">Redisson</a>:3.30.0 |
|
||||
| continew-starter-cache-springcache | Spring Cache 自动配置 | |
|
||||
| continew-starter-cache-jetcache | JetCache 自动配置 | |
|
||||
|
||||
### 数据访问模块
|
||||
|
||||
@@ -214,10 +214,10 @@ continew-starter.web:
|
||||
|
||||
### 认证模块
|
||||
|
||||
| 模块名称 | 模块说明 | 依赖版本 |
|
||||
| ------------------------------ | ----------------- | ------------------------------------------------------------ |
|
||||
| continew-starter-auth-satoken | SaToken 自动配置 | <a href="https://sa-token.dev33.cn/" target="_blank">Sa-Token</a>:1.37.0 |
|
||||
| continew-starter-auth-justauth | JustAuth 自动配置 | <a href="https://justauth.cn/" target="_blank">Just Auth</a>:1.16.6 |
|
||||
| 模块名称 | 模块说明 | 依赖版本 |
|
||||
| ------------------------------ | ----------------- |--------------------------------------------------------------------------|
|
||||
| continew-starter-auth-satoken | SaToken 自动配置 | <a href="https://sa-token.dev33.cn/" target="_blank">Sa-Token</a>:1.38.0 |
|
||||
| continew-starter-auth-justauth | JustAuth 自动配置 | <a href="https://justauth.cn/" target="_blank">Just Auth</a>:1.16.6 |
|
||||
|
||||
### 消息模块
|
||||
|
||||
|
||||
@@ -31,12 +31,10 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.context.annotation.DependsOn;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
|
||||
import org.springframework.core.io.support.ResourcePatternResolver;
|
||||
import top.continew.starter.captcha.behavior.autoconfigure.cache.BehaviorCaptchaCacheConfiguration;
|
||||
import top.continew.starter.core.constant.PropertiesConstants;
|
||||
|
||||
import java.util.HashMap;
|
||||
@@ -61,18 +59,11 @@ public class BehaviorCaptchaAutoConfiguration {
|
||||
this.properties = properties;
|
||||
}
|
||||
|
||||
/**
|
||||
* 自定义缓存实现配置
|
||||
*/
|
||||
@Configuration
|
||||
@Import({BehaviorCaptchaCacheConfiguration.Default.class, BehaviorCaptchaCacheConfiguration.Redis.class,
|
||||
BehaviorCaptchaCacheConfiguration.Custom.class})
|
||||
protected static class BehaviorCaptchaCacheAutoConfiguration {}
|
||||
|
||||
/**
|
||||
* 行为验证码服务接口
|
||||
*/
|
||||
@Bean
|
||||
@DependsOn("captchaCacheService")
|
||||
@ConditionalOnMissingBean
|
||||
public CaptchaService captchaService() {
|
||||
Properties config = new Properties();
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package top.continew.starter.captcha.behavior.autoconfigure;
|
||||
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import com.anji.captcha.model.common.CaptchaTypeEnum;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import top.continew.starter.captcha.behavior.enums.StorageType;
|
||||
@@ -75,37 +76,37 @@ public class BehaviorCaptchaProperties {
|
||||
/**
|
||||
* 历史数据清除开关(0:关闭;1:开启)
|
||||
*/
|
||||
private Integer historyDataClearEnable = 0;
|
||||
private String historyDataClearEnable = "0";
|
||||
|
||||
/**
|
||||
* 一分钟内接口请求次数限制开关(0:关闭;1:开启)
|
||||
*/
|
||||
private Integer reqFrequencyLimitEnable = 0;
|
||||
private String reqFrequencyLimitEnable = "0";
|
||||
|
||||
/**
|
||||
* 一分钟内验证码最多失败次数限制(默认:5次)
|
||||
*/
|
||||
private int reqGetLockLimit = 5;
|
||||
private String reqGetLockLimit = "5";
|
||||
|
||||
/**
|
||||
* 一分钟内验证码最多失败次数限制达标后锁定时间(默认:300秒)
|
||||
*/
|
||||
private int reqGetLockSeconds = 300;
|
||||
private String reqGetLockSeconds = "300";
|
||||
|
||||
/**
|
||||
* 获取验证码接口一分钟内请求次数限制(默认:100次)
|
||||
*/
|
||||
private int reqGetMinuteLimit = 100;
|
||||
private String reqGetMinuteLimit = "100";
|
||||
|
||||
/**
|
||||
* 校验检验码接口一分内请求次数限制(默认:100次)
|
||||
*/
|
||||
private int reqCheckMinuteLimit = 100;
|
||||
private String reqCheckMinuteLimit = "100";
|
||||
|
||||
/**
|
||||
* 二次校验检验码接口一分钟内请求次数限制(默认:100次)
|
||||
*/
|
||||
private int reqVerifyMinuteLimit = 100;
|
||||
private String reqVerifyMinuteLimit = "100";
|
||||
|
||||
/**
|
||||
* local缓存的阈值(默认:1000个)
|
||||
@@ -135,12 +136,12 @@ public class BehaviorCaptchaProperties {
|
||||
/**
|
||||
* 点选字体样式(默认:BOLD)
|
||||
*/
|
||||
private int fontStyle = Font.BOLD;
|
||||
private String fontStyle = Convert.toStr(Font.BOLD);
|
||||
|
||||
/**
|
||||
* 点选字体大小(默认:25)
|
||||
*/
|
||||
private int fontSize = 25;
|
||||
private String fontSize = "25";
|
||||
|
||||
public boolean isEnabled() {
|
||||
return enabled;
|
||||
@@ -206,59 +207,59 @@ public class BehaviorCaptchaProperties {
|
||||
this.fontType = fontType;
|
||||
}
|
||||
|
||||
public Integer getHistoryDataClearEnable() {
|
||||
public String getHistoryDataClearEnable() {
|
||||
return historyDataClearEnable;
|
||||
}
|
||||
|
||||
public void setHistoryDataClearEnable(Integer historyDataClearEnable) {
|
||||
public void setHistoryDataClearEnable(String historyDataClearEnable) {
|
||||
this.historyDataClearEnable = historyDataClearEnable;
|
||||
}
|
||||
|
||||
public Integer getReqFrequencyLimitEnable() {
|
||||
public String getReqFrequencyLimitEnable() {
|
||||
return reqFrequencyLimitEnable;
|
||||
}
|
||||
|
||||
public void setReqFrequencyLimitEnable(Integer reqFrequencyLimitEnable) {
|
||||
public void setReqFrequencyLimitEnable(String reqFrequencyLimitEnable) {
|
||||
this.reqFrequencyLimitEnable = reqFrequencyLimitEnable;
|
||||
}
|
||||
|
||||
public int getReqGetLockLimit() {
|
||||
public String getReqGetLockLimit() {
|
||||
return reqGetLockLimit;
|
||||
}
|
||||
|
||||
public void setReqGetLockLimit(int reqGetLockLimit) {
|
||||
public void setReqGetLockLimit(String reqGetLockLimit) {
|
||||
this.reqGetLockLimit = reqGetLockLimit;
|
||||
}
|
||||
|
||||
public int getReqGetLockSeconds() {
|
||||
public String getReqGetLockSeconds() {
|
||||
return reqGetLockSeconds;
|
||||
}
|
||||
|
||||
public void setReqGetLockSeconds(int reqGetLockSeconds) {
|
||||
public void setReqGetLockSeconds(String reqGetLockSeconds) {
|
||||
this.reqGetLockSeconds = reqGetLockSeconds;
|
||||
}
|
||||
|
||||
public int getReqGetMinuteLimit() {
|
||||
public String getReqGetMinuteLimit() {
|
||||
return reqGetMinuteLimit;
|
||||
}
|
||||
|
||||
public void setReqGetMinuteLimit(int reqGetMinuteLimit) {
|
||||
public void setReqGetMinuteLimit(String reqGetMinuteLimit) {
|
||||
this.reqGetMinuteLimit = reqGetMinuteLimit;
|
||||
}
|
||||
|
||||
public int getReqCheckMinuteLimit() {
|
||||
public String getReqCheckMinuteLimit() {
|
||||
return reqCheckMinuteLimit;
|
||||
}
|
||||
|
||||
public void setReqCheckMinuteLimit(int reqCheckMinuteLimit) {
|
||||
public void setReqCheckMinuteLimit(String reqCheckMinuteLimit) {
|
||||
this.reqCheckMinuteLimit = reqCheckMinuteLimit;
|
||||
}
|
||||
|
||||
public int getReqVerifyMinuteLimit() {
|
||||
public String getReqVerifyMinuteLimit() {
|
||||
return reqVerifyMinuteLimit;
|
||||
}
|
||||
|
||||
public void setReqVerifyMinuteLimit(int reqVerifyMinuteLimit) {
|
||||
public void setReqVerifyMinuteLimit(String reqVerifyMinuteLimit) {
|
||||
this.reqVerifyMinuteLimit = reqVerifyMinuteLimit;
|
||||
}
|
||||
|
||||
@@ -302,19 +303,19 @@ public class BehaviorCaptchaProperties {
|
||||
this.interferenceOptions = interferenceOptions;
|
||||
}
|
||||
|
||||
public int getFontStyle() {
|
||||
public String getFontStyle() {
|
||||
return fontStyle;
|
||||
}
|
||||
|
||||
public void setFontStyle(int fontStyle) {
|
||||
public void setFontStyle(String fontStyle) {
|
||||
this.fontStyle = fontStyle;
|
||||
}
|
||||
|
||||
public int getFontSize() {
|
||||
public String getFontSize() {
|
||||
return fontSize;
|
||||
}
|
||||
|
||||
public void setFontSize(int fontSize) {
|
||||
public void setFontSize(String fontSize) {
|
||||
this.fontSize = fontSize;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ import org.redisson.client.RedisClient;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigureBefore;
|
||||
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
@@ -36,29 +36,35 @@ import top.continew.starter.captcha.behavior.enums.StorageType;
|
||||
import top.continew.starter.core.constant.PropertiesConstants;
|
||||
|
||||
/**
|
||||
* 行为验证码缓存配置
|
||||
* 行为验证码缓存自动配置
|
||||
*
|
||||
* @author Bull-BCLS
|
||||
* @author Charles7c
|
||||
* @since 1.1.0
|
||||
*/
|
||||
public class BehaviorCaptchaCacheConfiguration {
|
||||
@AutoConfiguration
|
||||
public class BehaviorCaptchaCacheAutoConfiguration {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(BehaviorCaptchaCacheConfiguration.class);
|
||||
private static final Logger log = LoggerFactory.getLogger(BehaviorCaptchaCacheAutoConfiguration.class);
|
||||
|
||||
private BehaviorCaptchaCacheConfiguration() {
|
||||
private BehaviorCaptchaCacheAutoConfiguration() {
|
||||
}
|
||||
|
||||
/**
|
||||
* 自定义缓存实现-默认(内存)
|
||||
*/
|
||||
@AutoConfiguration
|
||||
@ConditionalOnMissingBean(CaptchaCacheService.class)
|
||||
@ConditionalOnProperty(name = PropertiesConstants.CAPTCHA_BEHAVIOR + ".cache-type", havingValue = "default", matchIfMissing = true)
|
||||
public static class Default {
|
||||
@Bean
|
||||
public CaptchaCacheService captchaCacheService() {
|
||||
return new CaptchaCacheServiceMemImpl();
|
||||
}
|
||||
|
||||
@PostConstruct
|
||||
public void postConstruct() {
|
||||
CaptchaServiceFactory.cacheService.put(StorageType.DEFAULT.name()
|
||||
.toLowerCase(), new CaptchaCacheServiceMemImpl());
|
||||
CaptchaServiceFactory.cacheService.put(StorageType.DEFAULT.name().toLowerCase(), captchaCacheService());
|
||||
log.debug("[ContiNew Starter] - Auto Configuration 'Captcha-Behavior-Cache-Default' completed initialization.");
|
||||
}
|
||||
}
|
||||
@@ -66,15 +72,19 @@ public class BehaviorCaptchaCacheConfiguration {
|
||||
/**
|
||||
* 自定义缓存实现-Redis
|
||||
*/
|
||||
@ConditionalOnMissingBean(CaptchaCacheService.class)
|
||||
@AutoConfiguration(before = RedissonAutoConfiguration.class)
|
||||
@ConditionalOnClass(RedisClient.class)
|
||||
@AutoConfigureBefore(RedissonAutoConfiguration.class)
|
||||
@ConditionalOnMissingBean(CaptchaCacheService.class)
|
||||
@ConditionalOnProperty(name = PropertiesConstants.CAPTCHA_BEHAVIOR + ".cache-type", havingValue = "redis")
|
||||
public static class Redis {
|
||||
@Bean
|
||||
public CaptchaCacheService captchaCacheService() {
|
||||
return new BehaviorCaptchaCacheServiceImpl();
|
||||
}
|
||||
|
||||
@PostConstruct
|
||||
public void postConstruct() {
|
||||
CaptchaServiceFactory.cacheService.put(StorageType.REDIS.name()
|
||||
.toLowerCase(), new BehaviorCaptchaCacheServiceImpl());
|
||||
CaptchaServiceFactory.cacheService.put(StorageType.REDIS.name().toLowerCase(), captchaCacheService());
|
||||
log.debug("[ContiNew Starter] - Auto Configuration 'Captcha-Behavior-Cache-Redis' completed initialization.");
|
||||
}
|
||||
}
|
||||
@@ -82,6 +92,7 @@ public class BehaviorCaptchaCacheConfiguration {
|
||||
/**
|
||||
* 自定义缓存实现
|
||||
*/
|
||||
@AutoConfiguration
|
||||
@ConditionalOnProperty(name = PropertiesConstants.CAPTCHA_BEHAVIOR + ".cache-type", havingValue = "custom")
|
||||
public static class Custom {
|
||||
@Bean
|
||||
@@ -16,6 +16,8 @@
|
||||
|
||||
package top.continew.starter.captcha.behavior.autoconfigure.cache;
|
||||
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.util.NumberUtil;
|
||||
import com.anji.captcha.service.CaptchaCacheService;
|
||||
import top.continew.starter.cache.redisson.util.RedisUtils;
|
||||
import top.continew.starter.captcha.behavior.enums.StorageType;
|
||||
@@ -31,7 +33,11 @@ import java.time.Duration;
|
||||
public class BehaviorCaptchaCacheServiceImpl implements CaptchaCacheService {
|
||||
@Override
|
||||
public void set(String key, String value, long expiresInSeconds) {
|
||||
RedisUtils.set(key, value, Duration.ofSeconds(expiresInSeconds));
|
||||
if (NumberUtil.isNumber(value)) {
|
||||
RedisUtils.set(key, Convert.toInt(value), Duration.ofSeconds(expiresInSeconds));
|
||||
} else {
|
||||
RedisUtils.set(key, value, Duration.ofSeconds(expiresInSeconds));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -46,11 +52,16 @@ public class BehaviorCaptchaCacheServiceImpl implements CaptchaCacheService {
|
||||
|
||||
@Override
|
||||
public String get(String key) {
|
||||
return RedisUtils.get(key);
|
||||
return Convert.toStr(RedisUtils.get(key));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String type() {
|
||||
return StorageType.REDIS.name().toLowerCase();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long increment(String key, long val) {
|
||||
return RedisUtils.incr(key);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
top.continew.starter.captcha.behavior.autoconfigure.BehaviorCaptchaAutoConfiguration
|
||||
top.continew.starter.captcha.behavior.autoconfigure.BehaviorCaptchaAutoConfiguration
|
||||
top.continew.starter.captcha.behavior.autoconfigure.cache.BehaviorCaptchaCacheAutoConfiguration
|
||||
@@ -36,11 +36,11 @@ public class StrUtils {
|
||||
*
|
||||
* @param str 要转换的字符串
|
||||
* @param defaultValue 默认值
|
||||
* @param mapping 针对字符串的转换方法
|
||||
* @param mapper 针对字符串的转换方法
|
||||
* @return 转换后的字符串或指定的默认字符串
|
||||
* @since 2.0.1
|
||||
*/
|
||||
public static <T> T blankToDefault(CharSequence str, T defaultValue, Function<String, T> mapping) {
|
||||
return CharSequenceUtil.isBlank(str) ? defaultValue : mapping.apply(str.toString());
|
||||
public static <T> T blankToDefault(CharSequence str, T defaultValue, Function<String, T> mapper) {
|
||||
return CharSequenceUtil.isBlank(str) ? defaultValue : mapper.apply(str.toString());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
|
||||
<properties>
|
||||
<!-- 项目版本号 -->
|
||||
<revision>2.0.1</revision>
|
||||
<revision>2.0.2</revision>
|
||||
<sa-token.version>1.38.0</sa-token.version>
|
||||
<just-auth.version>1.16.6</just-auth.version>
|
||||
<mybatis-plus.version>3.5.5</mybatis-plus.version>
|
||||
@@ -62,11 +62,8 @@
|
||||
<crane4j.version>2.8.0</crane4j.version>
|
||||
<knife4j.version>4.5.0</knife4j.version>
|
||||
<tlog.version>1.5.2</tlog.version>
|
||||
<ql-express.version>3.3.2</ql-express.version>
|
||||
<snakeyaml.version>2.2</snakeyaml.version>
|
||||
<okhttp.version>4.12.0</okhttp.version>
|
||||
<plexus.version>4.0.0</plexus.version>
|
||||
<commons-compress.version>1.26.1</commons-compress.version>
|
||||
<ttl.version>2.14.5</ttl.version>
|
||||
<ip2region.version>3.1.11</ip2region.version>
|
||||
<hutool.version>5.8.27</hutool.version>
|
||||
@@ -259,13 +256,6 @@
|
||||
<version>${tlog.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- QLExpress(一种强大的、轻量级的、动态的 Java 平台语言,旨在提高开发人员在不同业务场景中的生产力) -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>QLExpress</artifactId>
|
||||
<version>${ql-express.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- SnakeYAML(适用于 Java 的 YAML 1.1 解析器和发射器) -->
|
||||
<dependency>
|
||||
<groupId>org.yaml</groupId>
|
||||
@@ -273,13 +263,6 @@
|
||||
<version>${snakeyaml.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Plexus Utils(各种实用程序类的集合,可轻松处理字符串、文件、命令行等) -->
|
||||
<dependency>
|
||||
<groupId>org.codehaus.plexus</groupId>
|
||||
<artifactId>plexus-utils</artifactId>
|
||||
<version>${plexus.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- OkHTTP(一个默认高效的 HTTP 客户端) -->
|
||||
<dependency>
|
||||
<groupId>com.squareup.okhttp3</groupId>
|
||||
@@ -287,13 +270,6 @@
|
||||
<version>${okhttp.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Apache Commons Compress(一套用于处理压缩和存档格式的 API) -->
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-compress</artifactId>
|
||||
<version>${commons-compress.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- TTL(线程间传递 ThreadLocal,异步执行时上下文传递的解决方案) -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
|
||||
@@ -104,7 +104,7 @@ public class PageResp<L> implements Serializable {
|
||||
pageResp.setTotal(list.size());
|
||||
// 对列表数据进行分页
|
||||
int fromIndex = (page - 1) * size;
|
||||
int toIndex = page * size + size;
|
||||
int toIndex = page * size + fromIndex;
|
||||
if (fromIndex > list.size()) {
|
||||
pageResp.setList(new ArrayList<>(0));
|
||||
} else if (toIndex >= list.size()) {
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* Copyright (c) 2022-present Charles7c Authors. All Rights Reserved.
|
||||
* <p>
|
||||
* Licensed under the GNU LESSER GENERAL PUBLIC LICENSE 3.0;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* <p>
|
||||
* http://www.gnu.org/licenses/lgpl.html
|
||||
* <p>
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package top.continew.starter.file.excel.converter;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.excel.converters.Converter;
|
||||
import com.alibaba.excel.enums.CellDataTypeEnum;
|
||||
import com.alibaba.excel.metadata.GlobalConfiguration;
|
||||
import com.alibaba.excel.metadata.data.ReadCellData;
|
||||
import com.alibaba.excel.metadata.data.WriteCellData;
|
||||
import com.alibaba.excel.metadata.property.ExcelContentProperty;
|
||||
import org.springframework.stereotype.Component;
|
||||
import top.continew.starter.core.constant.StringConstants;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Easy Excel List 集合转换器
|
||||
*
|
||||
* <p>
|
||||
* 仅适合 List<基本类型> <=> xxx,xxx 转换
|
||||
* </p>
|
||||
*
|
||||
* @author Charles7c
|
||||
* @since 2.0.2
|
||||
*/
|
||||
@Component
|
||||
public class ExcelListConverter implements Converter<List> {
|
||||
|
||||
@Override
|
||||
public Class supportJavaTypeKey() {
|
||||
return List.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CellDataTypeEnum supportExcelTypeKey() {
|
||||
return CellDataTypeEnum.STRING;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List convertToJavaData(ReadCellData<?> cellData,
|
||||
ExcelContentProperty contentProperty,
|
||||
GlobalConfiguration globalConfiguration) {
|
||||
String stringValue = cellData.getStringValue();
|
||||
return StrUtil.split(stringValue, StringConstants.COMMA);
|
||||
}
|
||||
|
||||
@Override
|
||||
public WriteCellData<Object> convertToExcelData(List value,
|
||||
ExcelContentProperty contentProperty,
|
||||
GlobalConfiguration globalConfiguration) {
|
||||
WriteCellData<Object> writeCellData = new WriteCellData<>(CollUtil.join(value, StringConstants.COMMA));
|
||||
writeCellData.setType(CellDataTypeEnum.STRING);
|
||||
return writeCellData;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user