forked from plusone/plusone-commons
Compare commits
7 Commits
8afe83e8df
...
dev
| Author | SHA1 | Date | |
|---|---|---|---|
| 255aaf182a | |||
| 468453781e | |||
| 3b241de08c | |||
| fb46def402 | |||
| 386ede6afd | |||
| 8ec61a84c9 | |||
| 726a94a1a8 |
60
NOTICE
Normal file
60
NOTICE
Normal file
@@ -0,0 +1,60 @@
|
||||
Plusone Commons
|
||||
Copyright 2022-present ZhouXY108
|
||||
|
||||
This product includes software developed at
|
||||
Plusone Commons (http://gitea.zhouxy.xyz/plusone/plusone-commons).
|
||||
|
||||
===========================================================================
|
||||
Third-party components and their licenses:
|
||||
===========================================================================
|
||||
|
||||
This software contains code from the following third-party projects:
|
||||
|
||||
1. Apache Seata
|
||||
- Component: IdWorker class implementation
|
||||
- Source: org.apache.seata.common.util.IdWorker
|
||||
- Origin: https://github.com/apache/incubator-seata/blob/2.x/common/src/main/java/org/apache/seata/common/util/IdWorker.java
|
||||
- License: Apache License 2.0
|
||||
- License URL: https://www.apache.org/licenses/LICENSE-2.0.txt
|
||||
- Copyright: The Apache Software Foundation
|
||||
|
||||
===========================================================================
|
||||
Dependencies and their licenses:
|
||||
===========================================================================
|
||||
|
||||
The following dependencies are used in this project:
|
||||
|
||||
Required Dependencies:
|
||||
- guava: Apache License 2.0 (https://www.apache.org/licenses/LICENSE-2.0.txt)
|
||||
|
||||
Optional Dependencies:
|
||||
- gson: Apache License 2.0 (https://www.apache.org/licenses/LICENSE-2.0.txt)
|
||||
- jsr305: Apache License 2.0 (https://www.apache.org/licenses/LICENSE-2.0.txt)
|
||||
- joda-time: Apache License 2.0 (https://www.apache.org/licenses/LICENSE-2.0.txt)
|
||||
|
||||
Test Dependencies:
|
||||
- commons-lang3: Apache License 2.0 (https://www.apache.org/licenses/LICENSE-2.0.txt)
|
||||
- Logback: Eclipse Public License 1.0 (https://www.eclipse.org/org/documents/epl-1.0/EPL-1.0.txt) / LGPL 2.1 (https://www.gnu.org/licenses/old-licenses/lgpl-2.1.html)
|
||||
- Slf4j: MIT License (https://mit-license.org/)
|
||||
- JUnit: Eclipse Public License 2.0 (https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.txt)
|
||||
- lombok: MIT License (https://mit-license.org/)
|
||||
- hutool: MulanPSL-2.0 (http://license.coscl.org.cn/MulanPSL2)
|
||||
- MyBatis: Apache License 2.0 (https://www.apache.org/licenses/LICENSE-2.0.txt)
|
||||
- h2: MPL 2.0 (https://www.mozilla.org/en-US/MPL/2.0/) / EPL 1.0 (https://www.eclipse.org/org/documents/epl-1.0/EPL-1.0.txt)
|
||||
- Jackson: Apache License 2.0 (https://www.apache.org/licenses/LICENSE-2.0.txt)
|
||||
|
||||
===========================================================================
|
||||
Apache License 2.0 Notice:
|
||||
===========================================================================
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
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.
|
||||
29
README.md
29
README.md
@@ -209,9 +209,34 @@ throw LoginException.Type.TOKEN_TIMEOUT.create();
|
||||
分页结果可以存放到 `PageResult` 中,作为出参。
|
||||
|
||||
#### 2. UnifiedResponse
|
||||
UnifiedResponse 对返回给前端的数据进行封装,包含 `code`、`message`、`data。`
|
||||
|
||||
可使用 `UnifiedResponses` 快速构建 `UnifiedResponse` 对象。 `UnifiedResponses` 默认的成功代码为 "2000000", 用户按测试类 `CustomUnifiedResponseFactoryTests` 中所示范的,继承 `UnifiedResponses` 实现自己的工厂类, 自定义 `SUCCESS_CODE` 和 `DEFAULT_SUCCESS_MSG` 和工厂方法。 见 [issue#22 @Gitea](http://gitea.zhouxy.xyz/plusone/plusone-commons/issues/22)。
|
||||
`UnifiedResponse` 对返回给前端的数据进行封装,包含 `code`、`message`、`data。`
|
||||
|
||||
`UnifiedResponses` 是 `UnifiedResponse` 的工厂类。用于快速构建 `UnifiedResponse` 对象,默认的成功代码为 `2000000`。
|
||||
|
||||
用户可以继承 `UnifiedResponses` 实现自己的工厂类,自定义 SUCCESS_CODE 和 DEFAULT_SUCCESS_MSG,以及工厂方法。如下所示:
|
||||
```java
|
||||
// 自定义工厂类
|
||||
public static class CustomUnifiedResponses extends UnifiedResponses {
|
||||
public static final String SUCCESS_CODE = "000";
|
||||
public static final String DEFAULT_SUCCESS_MSG = "成功";
|
||||
public static <T> UnifiedResponse<T> success() {
|
||||
return of(SUCCESS_CODE, DEFAULT_SUCCESS_MSG);
|
||||
}
|
||||
public static <T> UnifiedResponse<T> success(@Nullable String message) {
|
||||
return of(SUCCESS_CODE, message);
|
||||
}
|
||||
public static <T> UnifiedResponse<T> success(@Nullable String message, @Nullable T data) {
|
||||
return of(SUCCESS_CODE, message, data);
|
||||
}
|
||||
private CustomUnifiedResponses() {
|
||||
super();
|
||||
}
|
||||
}
|
||||
// 使用自定义工厂类
|
||||
CustomUnifiedResponses.success("查询成功", userList); // 状态码为 000
|
||||
```
|
||||
见 [issue#22 @Gitea](http://gitea.zhouxy.xyz/plusone/plusone-commons/issues/22)
|
||||
|
||||
## 八、time - 时间 API
|
||||
### 1. 季度
|
||||
|
||||
@@ -19,7 +19,40 @@ package xyz.zhouxy.plusone.commons.model.dto;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* UnifiedResponse 工厂
|
||||
* {@link UnifiedResponse} 工厂类。
|
||||
* 用于快速构建 {@link UnifiedResponse} 对象,默认的成功代码为 {@code 2000000}。
|
||||
*
|
||||
* <p>
|
||||
* 用户可以继承 {@link UnifiedResponses} 实现自己的工厂类,
|
||||
* 自定义 SUCCESS_CODE 和 DEFAULT_SUCCESS_MSG,以及工厂方法。
|
||||
* 如下所示:
|
||||
* <pre>
|
||||
* // 自定义工厂类
|
||||
* public static class CustomUnifiedResponses extends UnifiedResponses {
|
||||
*
|
||||
* public static final String SUCCESS_CODE = "000";
|
||||
* public static final String DEFAULT_SUCCESS_MSG = "成功";
|
||||
*
|
||||
* public static <T> UnifiedResponse<T> success() {
|
||||
* return of(SUCCESS_CODE, DEFAULT_SUCCESS_MSG);
|
||||
* }
|
||||
*
|
||||
* public static <T> UnifiedResponse<T> success(@Nullable String message) {
|
||||
* return of(SUCCESS_CODE, message);
|
||||
* }
|
||||
*
|
||||
* public static <T> UnifiedResponse<T> success(@Nullable String message, @Nullable T data) {
|
||||
* return of(SUCCESS_CODE, message, data);
|
||||
* }
|
||||
*
|
||||
* private CustomUnifiedResponses() {
|
||||
* super();
|
||||
* }
|
||||
* }
|
||||
* // 使用自定义工厂类
|
||||
* CustomUnifiedResponses.success("查询成功", userList); // 状态码为 000
|
||||
* </pre>
|
||||
* 见 <a href="http://zhouxy.xyz:3000/plusone/plusone-commons/issues/22">issue#22</a>。
|
||||
*
|
||||
* @author ZhouXY108 <luquanlion@outlook.com>
|
||||
* @since 1.0.0
|
||||
|
||||
@@ -52,13 +52,11 @@
|
||||
* {@link UnifiedResponse} 对返回给前端的数据进行封装,包含 code、message、data。
|
||||
*
|
||||
* <p>
|
||||
* 可使用 {@link UnifiedResponses} 快速构建 {@link UnifiedResponse} 对象。
|
||||
* {@link UnifiedResponses} 默认的成功代码为 "2000000",
|
||||
* 用户按测试类
|
||||
* <a href="http://zhouxy.xyz:3000/plusone/plusone-commons/src/branch/main/src/test/java/xyz/zhouxy/plusone/commons/model/dto/CustomUnifiedResponseFactoryTests.java">CustomUnifiedResponseFactoryTests</a>
|
||||
* 中所示范的,继承 {@link UnifiedResponses} 实现自己的工厂类,
|
||||
* 自定义 SUCCESS_CODE 和 DEFAULT_SUCCESS_MSG 和工厂方法。
|
||||
* 见 <a href="http://zhouxy.xyz:3000/plusone/plusone-commons/issues/22">issue#22</a>。
|
||||
* {@link UnifiedResponses} 用于快速构建 {@link UnifiedResponse} 对象,默认的成功代码为 {@code 2000000}。
|
||||
*
|
||||
* <p>
|
||||
* 用户可以继承 {@link UnifiedResponses} 实现自己的工厂类,
|
||||
* 自定义 SUCCESS_CODE 和 DEFAULT_SUCCESS_MSG,以及工厂方法。
|
||||
*
|
||||
* @author ZhouXY108 <luquanlion@outlook.com>
|
||||
*/
|
||||
|
||||
@@ -1,3 +1,19 @@
|
||||
/*
|
||||
* Copyright 2025 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* 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 xyz.zhouxy.plusone.commons.util;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
|
||||
|
||||
@@ -52,6 +52,8 @@
|
||||
<jasypt.version>1.9.3</jasypt.version>
|
||||
<jbcrypt.version>0.4</jbcrypt.version>
|
||||
|
||||
<minio.version>8.6.0</minio.version>
|
||||
|
||||
<lombok.version>1.18.36</lombok.version>
|
||||
<hutool.version>5.8.37</hutool.version>
|
||||
|
||||
@@ -146,22 +148,27 @@
|
||||
<version>${gson.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- MapStruct -->
|
||||
<dependency>
|
||||
<groupId>org.mapstruct</groupId>
|
||||
<artifactId>mapstruct</artifactId>
|
||||
<version>${mapstruct.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- H2 测试数据库 -->
|
||||
<dependency>
|
||||
<groupId>com.h2database</groupId>
|
||||
<artifactId>h2</artifactId>
|
||||
<version>${h2.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- MyBatis -->
|
||||
<dependency>
|
||||
<groupId>org.mybatis</groupId>
|
||||
<artifactId>mybatis</artifactId>
|
||||
<version>${mybatis.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Query DSL -->
|
||||
<dependency>
|
||||
<groupId>com.querydsl</groupId>
|
||||
@@ -169,6 +176,7 @@
|
||||
<version>${querydsl.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Byte Buddy 字节码工具 -->
|
||||
<dependency>
|
||||
<groupId>net.bytebuddy</groupId>
|
||||
<artifactId>byte-buddy</artifactId>
|
||||
@@ -188,22 +196,34 @@
|
||||
<version>${poi.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- JWT -->
|
||||
<dependency>
|
||||
<groupId>com.auth0</groupId>
|
||||
<artifactId>java-jwt</artifactId>
|
||||
<version>${java-jwt.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- jasypt 加密解密 -->
|
||||
<dependency>
|
||||
<groupId>org.jasypt</groupId>
|
||||
<artifactId>jasypt</artifactId>
|
||||
<version>${jasypt.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Bcrypt是一种用于密码哈希的加密算法,基于Blowfish算法 -->
|
||||
<dependency>
|
||||
<groupId>org.mindrot</groupId>
|
||||
<artifactId>jbcrypt</artifactId>
|
||||
<version>${jbcrypt.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- MinIO -->
|
||||
<dependency>
|
||||
<groupId>io.minio</groupId>
|
||||
<artifactId>minio</artifactId>
|
||||
<version>${minio.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
|
||||
Reference in New Issue
Block a user