feat: 初始化 Spring Boot 项目模板,搭建完整的用户认证与管理系统

- 新增项目基础配置:pom.xml 依赖管理、多环境配置(dev/prod)、Dockerfile、.env.example
  - 新增安全认证模块:JWT 工具类、JWT 过滤器、Spring Security 配置、自定义 UserDetails
  - 新增用户管理功能:注册/登录/查询/修改、角色管理(USER/ADMIN/ROOT)、分页查询、状态启禁用
  - 新增密码重置功能:邮箱验证码发送、验证码校验重置、频率限制与过期机制
  - 新增基础架构层:统一响应体 RestBean、全局异常处理、日志拦截器、Redis 工具类、JPA 配置
  - 新增 Swagger/OpenAPI 文档配置与完整的 API 接口文档(API_DOCUMENT.md)
  - 新增数据库初始化 SQL 脚本(init.sql)
This commit is contained in:
2026-03-31 08:54:06 +08:00
commit 3a9bf61839
50 changed files with 3098 additions and 0 deletions

View File

@@ -0,0 +1,118 @@
package com.aisi.template.domain;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* 通用的 REST API 响应封装类
*
* @param <V> 返回数据的类型
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class RestBean<V> {
/** 状态码 */
private int code;
/** 提示消息 */
private String message;
/** 具体数据 */
private V data;
/**
* 成功响应(默认使用 {@link RestCode#SUCCESS}
*
* @param data 返回的数据
* @param <V> 泛型参数
* @return RestBean 包装对象
*/
public static <V> RestBean<V> success(V data) {
return success(RestCode.SUCCESS, data);
}
/**
* 成功响应(指定 RestCode 和数据)
*
* @param restCode 状态码枚举
* @param data 返回的数据
* @param <V> 泛型参数
* @return RestBean 包装对象
*/
public static <V> RestBean<V> success(RestCode restCode, V data) {
return success(restCode.getCode(), restCode.getMessage(), data);
}
/**
* 成功响应(只返回状态码和消息,不带数据)
*
* @param restCode 状态码枚举
* @param <V> 泛型参数
* @return RestBean 包装对象
*/
public static <V> RestBean<V> success(RestCode restCode) {
return success(restCode, null);
}
/**
* 成功响应(自定义 code 和 message
*
* @param code 状态码
* @param message 提示消息
* @param data 返回的数据
* @param <V> 泛型参数
* @return RestBean 包装对象
*/
public static <V> RestBean<V> success(Integer code, String message, V data) {
return new RestBean<>(code, message, data);
}
/**
* 失败响应(默认使用 {@link RestCode#FAILURE}
*
* @param data 返回的数据
* @param <V> 泛型参数
* @return RestBean 包装对象
*/
public static <V> RestBean<V> failure(V data) {
return new RestBean<>(RestCode.FAILURE.getCode(), RestCode.FAILURE.getMessage(), data);
}
/**
* 失败响应(指定 RestCode 和数据)
*
* @param restCode 状态码枚举
* @param data 返回的数据
* @param <V> 泛型参数
* @return RestBean 包装对象
*/
public static <V> RestBean<V> failure(RestCode restCode, V data) {
return new RestBean<>(restCode.getCode(), restCode.getMessage(), data);
}
/**
* 失败响应(只返回状态码和消息,不带数据)
*
* @param restCode 状态码枚举
* @param <V> 泛型参数
* @return RestBean 包装对象
*/
public static <V> RestBean<V> failure(RestCode restCode) {
return new RestBean<>(restCode.getCode(), restCode.getMessage(), null);
}
/**
* 失败响应(自定义 code 和 message
*
* @param code 状态码
* @param message 提示消息
* @param data 返回的数据
* @param <V> 泛型参数
* @return RestBean 包装对象
*/
public static <V> RestBean<V> failure(int code, String message, V data) {
return new RestBean<>(code, message, data);
}
}