mirror of
https://github.com/continew-org/continew-starter.git
synced 2025-11-13 16:57:12 +08:00
Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| e3de3b6721 | |||
| 5b76534df7 | |||
| 57eef274a3 | |||
| f138e5cd45 | |||
| ca6c7098b1 | |||
| 596605b27b | |||
| b5dd5c7f18 | |||
|
|
cde9b01fc1 |
25
CHANGELOG.md
25
CHANGELOG.md
@@ -1,3 +1,28 @@
|
|||||||
|
## [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)
|
## [v2.0.0](https://github.com/Charles7c/continew-starter/compare/v1.5.1...v2.0.0) (2024-04-17)
|
||||||
|
|
||||||
### ✨ 新特性
|
### ✨ 新特性
|
||||||
|
|||||||
@@ -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" />
|
<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>
|
||||||
<a href="https://github.com/Charles7c/continew-starter" target="_blank">
|
<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.1-%23ff3f59.svg" alt="Release" />
|
||||||
</a>
|
</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">
|
<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" />
|
<img src="https://app.codacy.com/project/badge/Grade/90ed633957a9410aa8745f0654827c01" alt="Codacy Badge" />
|
||||||
|
|||||||
@@ -74,6 +74,6 @@ public class JustAuthStateCacheRedisImpl implements AuthStateCache {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean containsKey(String key) {
|
public boolean containsKey(String key) {
|
||||||
return RedisUtils.hasKey(RedisUtils.formatKey(KEY_PREFIX, key));
|
return RedisUtils.exists(RedisUtils.formatKey(KEY_PREFIX, key));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -22,7 +22,6 @@ import top.continew.starter.core.constant.StringConstants;
|
|||||||
|
|
||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.stream.Stream;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Redis 工具类
|
* Redis 工具类
|
||||||
@@ -92,6 +91,28 @@ public class RedisUtils {
|
|||||||
CLIENT.getKeys().deleteByPattern(pattern);
|
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 键
|
* @param key 键
|
||||||
* @return true:存在;false:不存在
|
* @return true:存在;false:不存在
|
||||||
*/
|
*/
|
||||||
public static boolean hasKey(String key) {
|
public static boolean exists(String key) {
|
||||||
RKeys keys = CLIENT.getKeys();
|
return CLIENT.getKeys().countExists(key) > 0;
|
||||||
return keys.countExists(key) > 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -142,8 +162,7 @@ public class RedisUtils {
|
|||||||
* @return 缓存列表
|
* @return 缓存列表
|
||||||
*/
|
*/
|
||||||
public static Collection<String> keys(String pattern) {
|
public static Collection<String> keys(String pattern) {
|
||||||
Stream<String> stream = CLIENT.getKeys().getKeysStreamByPattern(pattern);
|
return CLIENT.getKeys().getKeysStreamByPattern(pattern).toList();
|
||||||
return stream.toList();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ public class BehaviorCaptchaCacheServiceImpl implements CaptchaCacheService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean exists(String key) {
|
public boolean exists(String key) {
|
||||||
return RedisUtils.hasKey(key);
|
return RedisUtils.exists(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -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}或者""或者空白,则返回指定默认字符串,否则针对字符串处理后返回
|
||||||
|
*
|
||||||
|
* @param str 要转换的字符串
|
||||||
|
* @param defaultValue 默认值
|
||||||
|
* @param mapping 针对字符串的转换方法
|
||||||
|
* @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());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -6,7 +6,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-dependencies</artifactId>
|
<artifactId>spring-boot-dependencies</artifactId>
|
||||||
<version>3.1.10</version>
|
<version>3.1.11</version>
|
||||||
<relativePath/>
|
<relativePath/>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
@@ -19,7 +19,7 @@
|
|||||||
<licenses>
|
<licenses>
|
||||||
<license>
|
<license>
|
||||||
<name>GNU LESSER GENERAL PUBLIC LICENSE</name>
|
<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>
|
</license>
|
||||||
</licenses>
|
</licenses>
|
||||||
<developers>
|
<developers>
|
||||||
@@ -43,14 +43,14 @@
|
|||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<!-- 项目版本号 -->
|
<!-- 项目版本号 -->
|
||||||
<revision>2.0.0</revision>
|
<revision>2.0.1</revision>
|
||||||
<sa-token.version>1.37.0</sa-token.version>
|
<sa-token.version>1.38.0</sa-token.version>
|
||||||
<just-auth.version>1.16.6</just-auth.version>
|
<just-auth.version>1.16.6</just-auth.version>
|
||||||
<mybatis-plus.version>3.5.5</mybatis-plus.version>
|
<mybatis-plus.version>3.5.5</mybatis-plus.version>
|
||||||
<dynamic-datasource.version>4.3.0</dynamic-datasource.version>
|
<dynamic-datasource.version>4.3.0</dynamic-datasource.version>
|
||||||
<p6spy.version>3.9.1</p6spy.version>
|
<p6spy.version>3.9.1</p6spy.version>
|
||||||
<jetcache.version>2.7.5</jetcache.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>
|
<cosid.version>2.6.8</cosid.version>
|
||||||
<sms4j.version>3.2.1</sms4j.version>
|
<sms4j.version>3.2.1</sms4j.version>
|
||||||
<aj-captcha.version>1.3.0</aj-captcha.version>
|
<aj-captcha.version>1.3.0</aj-captcha.version>
|
||||||
@@ -58,12 +58,17 @@
|
|||||||
<easy-excel.version>3.3.4</easy-excel.version>
|
<easy-excel.version>3.3.4</easy-excel.version>
|
||||||
<nashorn.version>15.4</nashorn.version>
|
<nashorn.version>15.4</nashorn.version>
|
||||||
<x-file-storage.version>2.1.0</x-file-storage.version>
|
<x-file-storage.version>2.1.0</x-file-storage.version>
|
||||||
<aws-s3.version>1.12.702</aws-s3.version>
|
<aws-s3.version>1.12.720</aws-s3.version>
|
||||||
<crane4j.version>2.7.0</crane4j.version>
|
<crane4j.version>2.8.0</crane4j.version>
|
||||||
<knife4j.version>4.5.0</knife4j.version>
|
<knife4j.version>4.5.0</knife4j.version>
|
||||||
<tlog.version>1.5.2</tlog.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>
|
<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>
|
<hutool.version>5.8.27</hutool.version>
|
||||||
<!-- Maven Plugin Versions -->
|
<!-- Maven Plugin Versions -->
|
||||||
<flatten.version>1.6.0</flatten.version>
|
<flatten.version>1.6.0</flatten.version>
|
||||||
@@ -254,6 +259,41 @@
|
|||||||
<version>${tlog.version}</version>
|
<version>${tlog.version}</version>
|
||||||
</dependency>
|
</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>
|
||||||
|
<artifactId>snakeyaml</artifactId>
|
||||||
|
<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>
|
||||||
|
<artifactId>okhttp</artifactId>
|
||||||
|
<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,异步执行时上下文传递的解决方案) -->
|
<!-- TTL(线程间传递 ThreadLocal,异步执行时上下文传递的解决方案) -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.alibaba</groupId>
|
<groupId>com.alibaba</groupId>
|
||||||
@@ -436,6 +476,7 @@
|
|||||||
<artifactId>continew-starter-core</artifactId>
|
<artifactId>continew-starter-core</artifactId>
|
||||||
<version>${revision}</version>
|
<version>${revision}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</dependencyManagement>
|
</dependencyManagement>
|
||||||
|
|
||||||
|
|||||||
@@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -18,10 +18,8 @@ package top.continew.starter.extension.crud.model.entity;
|
|||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.FieldFill;
|
import com.baomidou.mybatisplus.annotation.FieldFill;
|
||||||
import com.baomidou.mybatisplus.annotation.TableField;
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
|
||||||
|
|
||||||
import java.io.Serial;
|
import java.io.Serial;
|
||||||
import java.io.Serializable;
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -30,17 +28,11 @@ import java.time.LocalDateTime;
|
|||||||
* @author Charles7c
|
* @author Charles7c
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public class BaseDO implements Serializable {
|
public class BaseDO extends BaseIdDO {
|
||||||
|
|
||||||
@Serial
|
@Serial
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
/**
|
|
||||||
* ID
|
|
||||||
*/
|
|
||||||
@TableId
|
|
||||||
private Long id;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建人
|
* 创建人
|
||||||
*/
|
*/
|
||||||
@@ -65,14 +57,6 @@ public class BaseDO implements Serializable {
|
|||||||
@TableField(fill = FieldFill.UPDATE)
|
@TableField(fill = FieldFill.UPDATE)
|
||||||
private LocalDateTime updateTime;
|
private LocalDateTime updateTime;
|
||||||
|
|
||||||
public Long getId() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setId(Long id) {
|
|
||||||
this.id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Long getCreateUser() {
|
public Long getCreateUser() {
|
||||||
return createUser;
|
return createUser;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -18,7 +18,6 @@ package top.continew.starter.extension.crud.service;
|
|||||||
|
|
||||||
import cn.hutool.core.lang.tree.Tree;
|
import cn.hutool.core.lang.tree.Tree;
|
||||||
import jakarta.servlet.http.HttpServletResponse;
|
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.PageQuery;
|
||||||
import top.continew.starter.extension.crud.model.query.SortQuery;
|
import top.continew.starter.extension.crud.model.query.SortQuery;
|
||||||
import top.continew.starter.extension.crud.model.resp.PageResp;
|
import top.continew.starter.extension.crud.model.resp.PageResp;
|
||||||
@@ -35,7 +34,7 @@ import java.util.List;
|
|||||||
* @author Charles7c
|
* @author Charles7c
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public interface BaseService<L, D, Q, C extends BaseReq> {
|
public interface BaseService<L, D, Q, C> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 分页查询列表
|
* 分页查询列表
|
||||||
|
|||||||
@@ -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.query.QueryWrapperHelper;
|
||||||
import top.continew.starter.data.mybatis.plus.service.impl.ServiceImpl;
|
import top.continew.starter.data.mybatis.plus.service.impl.ServiceImpl;
|
||||||
import top.continew.starter.extension.crud.annotation.TreeField;
|
import top.continew.starter.extension.crud.annotation.TreeField;
|
||||||
import top.continew.starter.extension.crud.model.entity.BaseDO;
|
import top.continew.starter.extension.crud.model.entity.BaseIdDO;
|
||||||
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.PageQuery;
|
||||||
import top.continew.starter.extension.crud.model.query.SortQuery;
|
import top.continew.starter.extension.crud.model.query.SortQuery;
|
||||||
import top.continew.starter.extension.crud.model.resp.PageResp;
|
import top.continew.starter.extension.crud.model.resp.PageResp;
|
||||||
@@ -65,7 +64,7 @@ import java.util.Optional;
|
|||||||
* @author Charles7c
|
* @author Charles7c
|
||||||
* @since 1.0.0
|
* @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());
|
private final Class<?>[] typeArgumentCache = ClassUtils.getTypeArguments(this.getClass());
|
||||||
protected final Class<L> listClass = this.currentListClass();
|
protected final Class<L> listClass = this.currentListClass();
|
||||||
@@ -75,7 +74,7 @@ public abstract class BaseServiceImpl<M extends BaseMapper<T>, T extends BaseDO,
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PageResp<L> page(Q query, PageQuery pageQuery) {
|
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);
|
IPage<T> page = baseMapper.selectPage(pageQuery.toPage(), queryWrapper);
|
||||||
PageResp<L> pageResp = PageResp.build(page, listClass);
|
PageResp<L> pageResp = PageResp.build(page, listClass);
|
||||||
pageResp.getList().forEach(this::fill);
|
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())));
|
tree.setWeight(ReflectUtil.invoke(node, CharSequenceUtil.genGetter(treeField.weightKey())));
|
||||||
if (!isSimple) {
|
if (!isSimple) {
|
||||||
List<Field> fieldList = ReflectUtils.getNonStaticFields(listClass);
|
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()));
|
.parentIdKey(), treeField.nameKey(), treeField.weightKey(), treeField.childrenKey()));
|
||||||
fieldList.forEach(f -> tree.putExtra(f.getName(), ReflectUtil.invoke(node, CharSequenceUtil.genGetter(f
|
fieldList.forEach(f -> tree.putExtra(f.getName(), ReflectUtil.invoke(node, CharSequenceUtil.genGetter(f
|
||||||
.getName()))));
|
.getName()))));
|
||||||
@@ -171,7 +170,7 @@ public abstract class BaseServiceImpl<M extends BaseMapper<T>, T extends BaseDO,
|
|||||||
* @return 列表信息
|
* @return 列表信息
|
||||||
*/
|
*/
|
||||||
protected <E> List<E> list(Q query, SortQuery sortQuery, Class<E> targetClass) {
|
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);
|
this.sort(queryWrapper, sortQuery);
|
||||||
List<T> entityList = baseMapper.selectList(queryWrapper);
|
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
|
* @return QueryWrapper
|
||||||
*/
|
*/
|
||||||
protected QueryWrapper<T> handleQueryWrapper(Q query) {
|
protected QueryWrapper<T> buildQueryWrapper(Q query) {
|
||||||
QueryWrapper<T> queryWrapper = new QueryWrapper<>();
|
QueryWrapper<T> queryWrapper = new QueryWrapper<>();
|
||||||
// 解析并拼接查询条件
|
// 解析并拼接查询条件
|
||||||
return QueryWrapperHelper.build(query, queryFields, queryWrapper);
|
return QueryWrapperHelper.build(query, queryFields, queryWrapper);
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ package top.continew.starter.web.autoconfigure.xss;
|
|||||||
|
|
||||||
import cn.hutool.core.collection.CollectionUtil;
|
import cn.hutool.core.collection.CollectionUtil;
|
||||||
import cn.hutool.core.io.IoUtil;
|
import cn.hutool.core.io.IoUtil;
|
||||||
|
import cn.hutool.core.text.CharSequenceUtil;
|
||||||
import cn.hutool.core.util.*;
|
import cn.hutool.core.util.*;
|
||||||
import cn.hutool.http.HtmlUtil;
|
import cn.hutool.http.HtmlUtil;
|
||||||
import cn.hutool.http.Method;
|
import cn.hutool.http.Method;
|
||||||
@@ -49,10 +50,10 @@ public class XssServletRequestWrapper extends HttpServletRequestWrapper {
|
|||||||
public XssServletRequestWrapper(HttpServletRequest request, XssProperties xssProperties) throws IOException {
|
public XssServletRequestWrapper(HttpServletRequest request, XssProperties xssProperties) throws IOException {
|
||||||
super(request);
|
super(request);
|
||||||
this.xssProperties = xssProperties;
|
this.xssProperties = xssProperties;
|
||||||
if (StrUtil.containsAny(request.getMethod().toUpperCase(), Method.POST.name(), Method.PATCH.name(), Method.PUT
|
if (CharSequenceUtil.equalsAnyIgnoreCase(request.getMethod().toUpperCase(), Method.POST.name(), Method.PATCH
|
||||||
.name())) {
|
.name(), Method.PUT.name())) {
|
||||||
body = IoUtil.getReader(request.getReader()).readLine();
|
body = IoUtil.getReader(request.getReader()).readLine();
|
||||||
if (StrUtil.isEmpty(body)) {
|
if (CharSequenceUtil.isBlank(body)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
body = this.handleTag(body);
|
body = this.handleTag(body);
|
||||||
@@ -100,7 +101,7 @@ public class XssServletRequestWrapper extends HttpServletRequestWrapper {
|
|||||||
* @return 返回处理过后内容
|
* @return 返回处理过后内容
|
||||||
*/
|
*/
|
||||||
private String handleTag(String content) {
|
private String handleTag(String content) {
|
||||||
if (StrUtil.isEmpty(content)) {
|
if (CharSequenceUtil.isBlank(content)) {
|
||||||
return content;
|
return content;
|
||||||
}
|
}
|
||||||
XssMode mode = xssProperties.getMode();
|
XssMode mode = xssProperties.getMode();
|
||||||
|
|||||||
Reference in New Issue
Block a user