Compare commits

...

14 Commits

Author SHA1 Message Date
9e78305e27 release: v2.0.2 2024-05-20 23:21:07 +08:00
joshua
3e60197a31 fix: 修复封装分页 dataList 索引计算错误 2024-05-20 23:13:02 +08:00
881fd37dd6 fix: 移除部分错误依赖声明 2024-05-20 23:12:46 +08:00
9bee01baa3 chore: 优化部分代码 2024-05-20 22:57:13 +08:00
1faa46e125 feat(file/excel): 新增 Easy Excel List 集合转换器 2024-05-20 22:56:23 +08:00
Yoofff
62121b78ec fix(captcha): 修复行为验证码接口请求次数限制 2024-05-20 20:53:38 +08:00
e3de3b6721 release: v2.0.1 2024-05-13 22:51:54 +08:00
5b76534df7 feat(extension/crud): 新增多种实体 Base 模型降低 BaseService 耦合 2024-05-13 22:30:40 +08:00
57eef274a3 refactor(web): 优化部分方法使用 2024-05-13 22:07:18 +08:00
f138e5cd45 fix(extension/crud): 修复查询树列表方法中的错误判断 2024-05-13 22:06:57 +08:00
ca6c7098b1 feat(core): 新增字符串工具类 2024-05-13 21:58:13 +08:00
596605b27b feat(cache/redisson): RedisUtils 新增递增、递减方法 2024-05-13 21:57:42 +08:00
b5dd5c7f18 chore: 升级依赖
SaToken 1.37.0 => 1.38.0
Redisson 3.28.0 => 3.30.0
Crane4j 2.7.0 => 2.8.0
AWS S3 1.12.702 => 1.12.720
IP2Region 3.1.10 => 3.1.11
2024-05-13 21:56:14 +08:00
macroju
cde9b01fc1 chore: 升级依赖修复安全漏洞 (#2) 2024-05-06 20:31:19 +08:00
20 changed files with 492 additions and 117 deletions

View File

@@ -1,3 +1,40 @@
## [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)
### ✨ 新特性
- 【cache/redisson】RedisUtils 新增递增、递减方法 ([596605b](https://github.com/Charles7c/continew-starter/commit/596605b27b046fa0488b113b1c3d87c60277e4ec))
- 【core】新增字符串工具类 ([ca6c709](https://github.com/Charles7c/continew-starter/commit/ca6c7098b124c3121fe626811ea61d53c80a9a4e))
- 【extension/crud】新增多种实体 Base 模型降低 BaseService 耦合 ([5b76534](https://github.com/Charles7c/continew-starter/commit/5b76534df7a54aa6d696515cfbf8059fcdc4a067))
### 🐛 问题修复
- 【extension/crud】修复查询树列表方法中的错误判断 ([f138e5c](https://github.com/Charles7c/continew-starter/commit/f138e5cd4526d8be0fe5e7ae54833b4541748346))
### 💎 功能优化
- 【web】优化部分方法使用 ([57eef27](https://github.com/Charles7c/continew-starter/commit/57eef274a3e34e8bb4de6073452080b2bbdbee53))
### 📦 依赖升级
- 【dependencies】Spring Boot 3.1.10 => 3.1.11 ([GitHub#2](https://github.com/Charles7c/continew-starter/pull/2))
- 【dependencies】SaToken 1.37.0 => 1.38.0 ([b5dd5c7](https://github.com/Charles7c/continew-starter/commit/b5dd5c7f18603b5bd5a509c04ef410c1d64bc2e9))
- 【dependencies】Redisson 3.28.0 => 3.30.0 ([b5dd5c7](https://github.com/Charles7c/continew-starter/commit/b5dd5c7f18603b5bd5a509c04ef410c1d64bc2e9))
- 【dependencies】Crane4j 2.7.0 => 2.8.0 ([b5dd5c7](https://github.com/Charles7c/continew-starter/commit/b5dd5c7f18603b5bd5a509c04ef410c1d64bc2e9))
- 【dependencies】AWS S3 1.12.702 => 1.12.720 ([b5dd5c7](https://github.com/Charles7c/continew-starter/commit/b5dd5c7f18603b5bd5a509c04ef410c1d64bc2e9))
- 【dependencies】IP2Region 3.1.10 => 3.1.11 ([b5dd5c7](https://github.com/Charles7c/continew-starter/commit/b5dd5c7f18603b5bd5a509c04ef410c1d64bc2e9))
## [v2.0.0](https://github.com/Charles7c/continew-starter/compare/v1.5.1...v2.0.0) (2024-04-17)
### ✨ 新特性

View File

@@ -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.0-%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-ip2region3.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-ip2region3.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 |
### 消息模块

View File

@@ -74,6 +74,6 @@ public class JustAuthStateCacheRedisImpl implements AuthStateCache {
*/
@Override
public boolean containsKey(String key) {
return RedisUtils.hasKey(RedisUtils.formatKey(KEY_PREFIX, key));
return RedisUtils.exists(RedisUtils.formatKey(KEY_PREFIX, key));
}
}

View File

@@ -22,7 +22,6 @@ import top.continew.starter.core.constant.StringConstants;
import java.time.Duration;
import java.util.Collection;
import java.util.stream.Stream;
/**
* Redis 工具类
@@ -92,6 +91,28 @@ public class RedisUtils {
CLIENT.getKeys().deleteByPattern(pattern);
}
/**
* 递增 1
*
* @param key 键
* @return 当前值
* @since 2.0.1
*/
public static long incr(String key) {
return CLIENT.getAtomicLong(key).incrementAndGet();
}
/**
* 递减 1
*
* @param key 键
* @return 当前值
* @since 2.0.1
*/
public static long decr(String key) {
return CLIENT.getAtomicLong(key).decrementAndGet();
}
/**
* 设置缓存过期时间
*
@@ -130,9 +151,8 @@ public class RedisUtils {
* @param key 键
* @return true存在false不存在
*/
public static boolean hasKey(String key) {
RKeys keys = CLIENT.getKeys();
return keys.countExists(key) > 0;
public static boolean exists(String key) {
return CLIENT.getKeys().countExists(key) > 0;
}
/**
@@ -142,8 +162,7 @@ public class RedisUtils {
* @return 缓存列表
*/
public static Collection<String> keys(String pattern) {
Stream<String> stream = CLIENT.getKeys().getKeysStreamByPattern(pattern);
return stream.toList();
return CLIENT.getKeys().getKeysStreamByPattern(pattern).toList();
}
/**

View File

@@ -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();

View File

@@ -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;
}
}

View File

@@ -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

View File

@@ -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,12 +33,16 @@ 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
public boolean exists(String key) {
return RedisUtils.hasKey(key);
return RedisUtils.exists(key);
}
@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);
}
}

View File

@@ -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

View File

@@ -0,0 +1,46 @@
/*
* 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.core.util;
import cn.hutool.core.text.CharSequenceUtil;
import java.util.function.Function;
/**
* 字符串工具类
*
* @author Charles7c
* @since 2.0.1
*/
public class StrUtils {
private StrUtils() {
}
/**
* 如果字符串是{@code null}或者&quot;&quot;或者空白,则返回指定默认字符串,否则针对字符串处理后返回
*
* @param str 要转换的字符串
* @param defaultValue 默认值
* @param mapper 针对字符串的转换方法
* @return 转换后的字符串或指定的默认字符串
* @since 2.0.1
*/
public static <T> T blankToDefault(CharSequence str, T defaultValue, Function<String, T> mapper) {
return CharSequenceUtil.isBlank(str) ? defaultValue : mapper.apply(str.toString());
}
}

View File

@@ -6,7 +6,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>3.1.10</version>
<version>3.1.11</version>
<relativePath/>
</parent>
@@ -19,7 +19,7 @@
<licenses>
<license>
<name>GNU LESSER GENERAL PUBLIC LICENSE</name>
<url>http://www.gnu.org/licenses/lgpl.html</url>
<url>https://www.gnu.org/licenses/lgpl.html</url>
</license>
</licenses>
<developers>
@@ -43,14 +43,14 @@
<properties>
<!-- 项目版本号 -->
<revision>2.0.0</revision>
<sa-token.version>1.37.0</sa-token.version>
<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>
<dynamic-datasource.version>4.3.0</dynamic-datasource.version>
<p6spy.version>3.9.1</p6spy.version>
<jetcache.version>2.7.5</jetcache.version>
<redisson.version>3.28.0</redisson.version>
<redisson.version>3.30.0</redisson.version>
<cosid.version>2.6.8</cosid.version>
<sms4j.version>3.2.1</sms4j.version>
<aj-captcha.version>1.3.0</aj-captcha.version>
@@ -58,12 +58,14 @@
<easy-excel.version>3.3.4</easy-excel.version>
<nashorn.version>15.4</nashorn.version>
<x-file-storage.version>2.1.0</x-file-storage.version>
<aws-s3.version>1.12.702</aws-s3.version>
<crane4j.version>2.7.0</crane4j.version>
<aws-s3.version>1.12.720</aws-s3.version>
<crane4j.version>2.8.0</crane4j.version>
<knife4j.version>4.5.0</knife4j.version>
<tlog.version>1.5.2</tlog.version>
<snakeyaml.version>2.2</snakeyaml.version>
<okhttp.version>4.12.0</okhttp.version>
<ttl.version>2.14.5</ttl.version>
<ip2region.version>3.1.10</ip2region.version>
<ip2region.version>3.1.11</ip2region.version>
<hutool.version>5.8.27</hutool.version>
<!-- Maven Plugin Versions -->
<flatten.version>1.6.0</flatten.version>
@@ -254,6 +256,20 @@
<version>${tlog.version}</version>
</dependency>
<!-- SnakeYAML适用于 Java 的 YAML 1.1 解析器和发射器) -->
<dependency>
<groupId>org.yaml</groupId>
<artifactId>snakeyaml</artifactId>
<version>${snakeyaml.version}</version>
</dependency>
<!-- OkHTTP一个默认高效的 HTTP 客户端) -->
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
<version>${okhttp.version}</version>
</dependency>
<!-- TTL线程间传递 ThreadLocal异步执行时上下文传递的解决方案 -->
<dependency>
<groupId>com.alibaba</groupId>
@@ -436,6 +452,7 @@
<artifactId>continew-starter-core</artifactId>
<version>${revision}</version>
</dependency>
</dependencies>
</dependencyManagement>

View File

@@ -0,0 +1,67 @@
/*
* 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.extension.crud.model.entity;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import java.io.Serial;
import java.time.LocalDateTime;
/**
* 实体类基类
*
* <p>
* 通用字段:创建人、创建时间
* </p>
*
* @author Charles7c
* @since 2.0.1
*/
public class BaseCreateDO extends BaseIdDO {
@Serial
private static final long serialVersionUID = 1L;
/**
* 创建人
*/
@TableField(fill = FieldFill.INSERT)
private Long createUser;
/**
* 创建时间
*/
@TableField(fill = FieldFill.INSERT)
private LocalDateTime createTime;
public Long getCreateUser() {
return createUser;
}
public void setCreateUser(Long createUser) {
this.createUser = createUser;
}
public LocalDateTime getCreateTime() {
return createTime;
}
public void setCreateTime(LocalDateTime createTime) {
this.createTime = createTime;
}
}

View File

@@ -18,10 +18,8 @@ package top.continew.starter.extension.crud.model.entity;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import java.io.Serial;
import java.io.Serializable;
import java.time.LocalDateTime;
/**
@@ -30,17 +28,11 @@ import java.time.LocalDateTime;
* @author Charles7c
* @since 1.0.0
*/
public class BaseDO implements Serializable {
public class BaseDO extends BaseIdDO {
@Serial
private static final long serialVersionUID = 1L;
/**
* ID
*/
@TableId
private Long id;
/**
* 创建人
*/
@@ -65,14 +57,6 @@ public class BaseDO implements Serializable {
@TableField(fill = FieldFill.UPDATE)
private LocalDateTime updateTime;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public Long getCreateUser() {
return createUser;
}

View File

@@ -0,0 +1,52 @@
/*
* 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.extension.crud.model.entity;
import com.baomidou.mybatisplus.annotation.TableId;
import java.io.Serial;
import java.io.Serializable;
/**
* 实体类基类
*
* <p>
* 通用字段ID 主键
* </p>
*
* @author Charles7c
* @since 2.0.1
*/
public class BaseIdDO implements Serializable {
@Serial
private static final long serialVersionUID = 1L;
/**
* ID
*/
@TableId
private Long id;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
}

View File

@@ -0,0 +1,67 @@
/*
* 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.extension.crud.model.entity;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import java.io.Serial;
import java.time.LocalDateTime;
/**
* 实体类基类
*
* <p>
* 通用字段:创建人、创建时间
* </p>
*
* @author Charles7c
* @since 2.0.1
*/
public class BaseUpdateDO extends BaseIdDO {
@Serial
private static final long serialVersionUID = 1L;
/**
* 修改人
*/
@TableField(fill = FieldFill.UPDATE)
private Long updateUser;
/**
* 修改时间
*/
@TableField(fill = FieldFill.UPDATE)
private LocalDateTime updateTime;
public Long getUpdateUser() {
return updateUser;
}
public void setUpdateUser(Long updateUser) {
this.updateUser = updateUser;
}
public LocalDateTime getUpdateTime() {
return updateTime;
}
public void setUpdateTime(LocalDateTime updateTime) {
this.updateTime = updateTime;
}
}

View File

@@ -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()) {

View File

@@ -18,7 +18,6 @@ package top.continew.starter.extension.crud.service;
import cn.hutool.core.lang.tree.Tree;
import jakarta.servlet.http.HttpServletResponse;
import top.continew.starter.extension.crud.model.req.BaseReq;
import top.continew.starter.extension.crud.model.query.PageQuery;
import top.continew.starter.extension.crud.model.query.SortQuery;
import top.continew.starter.extension.crud.model.resp.PageResp;
@@ -35,7 +34,7 @@ import java.util.List;
* @author Charles7c
* @since 1.0.0
*/
public interface BaseService<L, D, Q, C extends BaseReq> {
public interface BaseService<L, D, Q, C> {
/**
* 分页查询列表

View File

@@ -39,8 +39,7 @@ import top.continew.starter.data.mybatis.plus.base.BaseMapper;
import top.continew.starter.data.mybatis.plus.query.QueryWrapperHelper;
import top.continew.starter.data.mybatis.plus.service.impl.ServiceImpl;
import top.continew.starter.extension.crud.annotation.TreeField;
import top.continew.starter.extension.crud.model.entity.BaseDO;
import top.continew.starter.extension.crud.model.req.BaseReq;
import top.continew.starter.extension.crud.model.entity.BaseIdDO;
import top.continew.starter.extension.crud.model.query.PageQuery;
import top.continew.starter.extension.crud.model.query.SortQuery;
import top.continew.starter.extension.crud.model.resp.PageResp;
@@ -65,7 +64,7 @@ import java.util.Optional;
* @author Charles7c
* @since 1.0.0
*/
public abstract class BaseServiceImpl<M extends BaseMapper<T>, T extends BaseDO, L, D, Q, C extends BaseReq> extends ServiceImpl<M, T> implements BaseService<L, D, Q, C> {
public abstract class BaseServiceImpl<M extends BaseMapper<T>, T extends BaseIdDO, L, D, Q, C> extends ServiceImpl<M, T> implements BaseService<L, D, Q, C> {
private final Class<?>[] typeArgumentCache = ClassUtils.getTypeArguments(this.getClass());
protected final Class<L> listClass = this.currentListClass();
@@ -75,7 +74,7 @@ public abstract class BaseServiceImpl<M extends BaseMapper<T>, T extends BaseDO,
@Override
public PageResp<L> page(Q query, PageQuery pageQuery) {
QueryWrapper<T> queryWrapper = this.handleQueryWrapper(query);
QueryWrapper<T> queryWrapper = this.buildQueryWrapper(query);
IPage<T> page = baseMapper.selectPage(pageQuery.toPage(), queryWrapper);
PageResp<L> pageResp = PageResp.build(page, listClass);
pageResp.getList().forEach(this::fill);
@@ -104,7 +103,7 @@ public abstract class BaseServiceImpl<M extends BaseMapper<T>, T extends BaseDO,
tree.setWeight(ReflectUtil.invoke(node, CharSequenceUtil.genGetter(treeField.weightKey())));
if (!isSimple) {
List<Field> fieldList = ReflectUtils.getNonStaticFields(listClass);
fieldList.removeIf(f -> CharSequenceUtil.containsAnyIgnoreCase(f.getName(), treeField.value(), treeField
fieldList.removeIf(f -> CharSequenceUtil.equalsAnyIgnoreCase(f.getName(), treeField.value(), treeField
.parentIdKey(), treeField.nameKey(), treeField.weightKey(), treeField.childrenKey()));
fieldList.forEach(f -> tree.putExtra(f.getName(), ReflectUtil.invoke(node, CharSequenceUtil.genGetter(f
.getName()))));
@@ -171,7 +170,7 @@ public abstract class BaseServiceImpl<M extends BaseMapper<T>, T extends BaseDO,
* @return 列表信息
*/
protected <E> List<E> list(Q query, SortQuery sortQuery, Class<E> targetClass) {
QueryWrapper<T> queryWrapper = this.handleQueryWrapper(query);
QueryWrapper<T> queryWrapper = this.buildQueryWrapper(query);
// 设置排序
this.sort(queryWrapper, sortQuery);
List<T> entityList = baseMapper.selectList(queryWrapper);
@@ -222,11 +221,12 @@ public abstract class BaseServiceImpl<M extends BaseMapper<T>, T extends BaseDO,
}
/**
* 处理查询条件
* 构建 QueryWrapper
*
* @param query 查询条件
* @return QueryWrapper
*/
protected QueryWrapper<T> handleQueryWrapper(Q query) {
protected QueryWrapper<T> buildQueryWrapper(Q query) {
QueryWrapper<T> queryWrapper = new QueryWrapper<>();
// 解析并拼接查询条件
return QueryWrapperHelper.build(query, queryFields, queryWrapper);

View File

@@ -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;
}
}

View File

@@ -18,6 +18,7 @@ package top.continew.starter.web.autoconfigure.xss;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.io.IoUtil;
import cn.hutool.core.text.CharSequenceUtil;
import cn.hutool.core.util.*;
import cn.hutool.http.HtmlUtil;
import cn.hutool.http.Method;
@@ -49,10 +50,10 @@ public class XssServletRequestWrapper extends HttpServletRequestWrapper {
public XssServletRequestWrapper(HttpServletRequest request, XssProperties xssProperties) throws IOException {
super(request);
this.xssProperties = xssProperties;
if (StrUtil.containsAny(request.getMethod().toUpperCase(), Method.POST.name(), Method.PATCH.name(), Method.PUT
.name())) {
if (CharSequenceUtil.equalsAnyIgnoreCase(request.getMethod().toUpperCase(), Method.POST.name(), Method.PATCH
.name(), Method.PUT.name())) {
body = IoUtil.getReader(request.getReader()).readLine();
if (StrUtil.isEmpty(body)) {
if (CharSequenceUtil.isBlank(body)) {
return;
}
body = this.handleTag(body);
@@ -100,7 +101,7 @@ public class XssServletRequestWrapper extends HttpServletRequestWrapper {
* @return 返回处理过后内容
*/
private String handleTag(String content) {
if (StrUtil.isEmpty(content)) {
if (CharSequenceUtil.isBlank(content)) {
return content;
}
XssMode mode = xssProperties.getMode();