style: 优化代码格式

This commit is contained in:
2023-12-01 22:05:22 +08:00
parent ed961db06f
commit ce27ba8642
32 changed files with 409 additions and 677 deletions

View File

@@ -34,10 +34,8 @@ public class JustAuthStateCacheRedisImpl implements AuthStateCache {
/** /**
* 存入缓存 * 存入缓存
* *
* @param key * @param key key
* key * @param value 内容
* @param value
* 内容
*/ */
@Override @Override
public void cache(String key, String value) { public void cache(String key, String value) {
@@ -49,12 +47,9 @@ public class JustAuthStateCacheRedisImpl implements AuthStateCache {
/** /**
* 存入缓存 * 存入缓存
* *
* @param key * @param key key
* key * @param value 内容
* @param value * @param timeout 缓存过期时间(毫秒)
* 内容
* @param timeout
* 缓存过期时间(毫秒)
*/ */
@Override @Override
public void cache(String key, String value, long timeout) { public void cache(String key, String value, long timeout) {
@@ -65,8 +60,7 @@ public class JustAuthStateCacheRedisImpl implements AuthStateCache {
/** /**
* 获取缓存内容 * 获取缓存内容
* *
* @param key * @param key key
* key
* @return 内容 * @return 内容
*/ */
@Override @Override
@@ -77,8 +71,7 @@ public class JustAuthStateCacheRedisImpl implements AuthStateCache {
/** /**
* 是否存在 key如果对应 key 的 value 值已过期,也返回 false * 是否存在 key如果对应 key 的 value 值已过期,也返回 false
* *
* @param key * @param key key
* key
* @return true存在 key并且 value 没过期falsekey 不存在或者已过期 * @return true存在 key并且 value 没过期falsekey 不存在或者已过期
*/ */
@Override @Override

View File

@@ -74,7 +74,8 @@ public class SaTokenAutoConfiguration implements WebMvcConfigurer {
*/ */
@Configuration @Configuration
@Import({SaTokenDaoConfiguration.Redis.class, SaTokenDaoConfiguration.Custom.class}) @Import({SaTokenDaoConfiguration.Redis.class, SaTokenDaoConfiguration.Custom.class})
protected static class SaTokenDaoAutoConfiguration {} protected static class SaTokenDaoAutoConfiguration {
}
/** /**
* 整合 JWT简单模式 * 整合 JWT简单模式

View File

@@ -112,8 +112,7 @@ public class RedisUtils {
/** /**
* 查询缓存剩余过期时间 * 查询缓存剩余过期时间
* *
* @param key * @param key
* 键
* @return 缓存剩余过期时间(单位:毫秒) * @return 缓存剩余过期时间(单位:毫秒)
*/ */
public static long getTimeToLive(final String key) { public static long getTimeToLive(final String key) {
@@ -134,8 +133,7 @@ public class RedisUtils {
/** /**
* 查询缓存列表 * 查询缓存列表
* *
* @param keyPattern * @param keyPattern 键表达式
* 键表达式
* @return 缓存列表 * @return 缓存列表
*/ */
public static Collection<String> keys(final String keyPattern) { public static Collection<String> keys(final String keyPattern) {

View File

@@ -46,7 +46,9 @@ import java.util.concurrent.ThreadPoolExecutor;
@EnableConfigurationProperties(ThreadPoolProperties.class) @EnableConfigurationProperties(ThreadPoolProperties.class)
public class ThreadPoolAutoConfiguration { public class ThreadPoolAutoConfiguration {
/** 核心(最小)线程数 = CPU 核心数 + 1 */ /**
* 核心(最小)线程数 = CPU 核心数 + 1
*/
private final int corePoolSize = Runtime.getRuntime().availableProcessors() + 1; private final int corePoolSize = Runtime.getRuntime().availableProcessors() + 1;
/** /**

View File

@@ -39,10 +39,8 @@ public class ExceptionUtils {
/** /**
* 打印线程异常信息 * 打印线程异常信息
* *
* @param runnable * @param runnable 线程执行内容
* 线程执行内容 * @param throwable 异常
* @param throwable
* 异常
*/ */
public static void printException(Runnable runnable, Throwable throwable) { public static void printException(Runnable runnable, Throwable throwable) {
if (null == throwable && runnable instanceof Future<?> future) { if (null == throwable && runnable instanceof Future<?> future) {
@@ -66,10 +64,8 @@ public class ExceptionUtils {
/** /**
* 如果有异常,返回 null * 如果有异常,返回 null
* *
* @param exSupplier * @param exSupplier 可能会出现异常的方法执行
* 可能会出现异常的方法执行 * @param <T> /
* @param <T>
* /
* @return / * @return /
*/ */
public static <T> T exToNull(ExSupplier<T> exSupplier) { public static <T> T exToNull(ExSupplier<T> exSupplier) {
@@ -79,12 +75,9 @@ public class ExceptionUtils {
/** /**
* 如果有异常,执行异常处理 * 如果有异常,执行异常处理
* *
* @param supplier * @param supplier 可能会出现异常的方法执行
* 可能会出现异常的方法执行 * @param exConsumer 异常处理
* @param exConsumer * @param <T> /
* 异常处理
* @param <T>
* /
* @return / * @return /
*/ */
public static <T> T exToNull(ExSupplier<T> supplier, Consumer<Exception> exConsumer) { public static <T> T exToNull(ExSupplier<T> supplier, Consumer<Exception> exConsumer) {
@@ -94,8 +87,7 @@ public class ExceptionUtils {
/** /**
* 如果有异常,返回空字符串 * 如果有异常,返回空字符串
* *
* @param exSupplier * @param exSupplier 可能会出现异常的方法执行
* 可能会出现异常的方法执行
* @return / * @return /
*/ */
public static String exToBlank(ExSupplier<String> exSupplier) { public static String exToBlank(ExSupplier<String> exSupplier) {
@@ -105,12 +97,9 @@ public class ExceptionUtils {
/** /**
* 如果有异常,返回默认值 * 如果有异常,返回默认值
* *
* @param exSupplier * @param exSupplier 可能会出现异常的方法执行
* 可能会出现异常的方法执行 * @param defaultValue 默认值
* @param defaultValue * @param <T> /
* 默认值
* @param <T>
* /
* @return / * @return /
*/ */
public static <T> T exToDefault(ExSupplier<T> exSupplier, T defaultValue) { public static <T> T exToDefault(ExSupplier<T> exSupplier, T defaultValue) {
@@ -120,14 +109,10 @@ public class ExceptionUtils {
/** /**
* 如果有异常,执行异常处理,返回默认值 * 如果有异常,执行异常处理,返回默认值
* *
* @param exSupplier * @param exSupplier 可能会出现异常的方法执行
* 可能会出现异常的方法执行 * @param defaultValue 默认值
* @param defaultValue * @param exConsumer 异常处理
* 默认值 * @param <T> /
* @param exConsumer
* 异常处理
* @param <T>
* /
* @return / * @return /
*/ */
public static <T> T exToDefault(ExSupplier<T> exSupplier, T defaultValue, Consumer<Exception> exConsumer) { public static <T> T exToDefault(ExSupplier<T> exSupplier, T defaultValue, Consumer<Exception> exConsumer) {
@@ -144,16 +129,14 @@ public class ExceptionUtils {
/** /**
* 异常提供者 * 异常提供者
* *
* @param <T> * @param <T> /
* /
*/ */
public interface ExSupplier<T> { public interface ExSupplier<T> {
/** /**
* 获取返回值 * 获取返回值
* *
* @return / * @return /
* @throws Exception * @throws Exception /
* /
*/ */
T get() throws Exception; T get() throws Exception;
} }

View File

@@ -21,8 +21,8 @@ import java.lang.annotation.*;
/** /**
* 树结构字段 * 树结构字段
* *
* @see cn.hutool.core.lang.tree.TreeNodeConfig
* @author Charles7c * @author Charles7c
* @see cn.hutool.core.lang.tree.TreeNodeConfig
* @since 1.0.0 * @since 1.0.0
*/ */
@Target(ElementType.TYPE) @Target(ElementType.TYPE)

View File

@@ -40,16 +40,11 @@ import java.util.List;
/** /**
* 控制器基类 * 控制器基类
* *
* @param <S> * @param <S> 业务接口
* 业务接口 * @param <L> 列表信息
* @param <L> * @param <D> 详情信息
* 列表信息 * @param <Q> 查询条件
* @param <D> * @param <C> 创建或修改信息
* 详情信息
* @param <Q>
* 查询条件
* @param <C>
* 创建或修改信息
* @author Charles7c * @author Charles7c
* @since 1.0.0 * @since 1.0.0
*/ */
@@ -62,10 +57,8 @@ public abstract class BaseController<S extends BaseService<L, D, Q, C>, L, D, Q,
/** /**
* 分页查询列表 * 分页查询列表
* *
* @param query * @param query 查询条件
* 查询条件 * @param pageQuery 分页查询条件
* @param pageQuery
* 分页查询条件
* @return 分页信息 * @return 分页信息
*/ */
@Operation(summary = "分页查询列表", description = "分页查询列表") @Operation(summary = "分页查询列表", description = "分页查询列表")
@@ -80,10 +73,8 @@ public abstract class BaseController<S extends BaseService<L, D, Q, C>, L, D, Q,
/** /**
* 查询树列表 * 查询树列表
* *
* @param query * @param query 查询条件
* 查询条件 * @param sortQuery 排序查询条件
* @param sortQuery
* 排序查询条件
* @return 树列表信息 * @return 树列表信息
*/ */
@Operation(summary = "查询树列表", description = "查询树列表") @Operation(summary = "查询树列表", description = "查询树列表")
@@ -98,10 +89,8 @@ public abstract class BaseController<S extends BaseService<L, D, Q, C>, L, D, Q,
/** /**
* 查询列表 * 查询列表
* *
* @param query * @param query 查询条件
* 查询条件 * @param sortQuery 排序查询条件
* @param sortQuery
* 排序查询条件
* @return 列表信息 * @return 列表信息
*/ */
@Operation(summary = "查询列表", description = "查询列表") @Operation(summary = "查询列表", description = "查询列表")
@@ -116,8 +105,7 @@ public abstract class BaseController<S extends BaseService<L, D, Q, C>, L, D, Q,
/** /**
* 查看详情 * 查看详情
* *
* @param id * @param id ID
* ID
* @return 详情信息 * @return 详情信息
*/ */
@Operation(summary = "查看详情", description = "查看详情") @Operation(summary = "查看详情", description = "查看详情")
@@ -133,8 +121,7 @@ public abstract class BaseController<S extends BaseService<L, D, Q, C>, L, D, Q,
/** /**
* 新增 * 新增
* *
* @param req * @param req 创建信息
* 创建信息
* @return 自增 ID * @return 自增 ID
*/ */
@Operation(summary = "新增数据", description = "新增数据") @Operation(summary = "新增数据", description = "新增数据")
@@ -149,10 +136,8 @@ public abstract class BaseController<S extends BaseService<L, D, Q, C>, L, D, Q,
/** /**
* 修改 * 修改
* *
* @param req * @param req 修改信息
* 修改信息 * @param id ID
* @param id
* ID
* @return / * @return /
*/ */
@Operation(summary = "修改数据", description = "修改数据") @Operation(summary = "修改数据", description = "修改数据")
@@ -168,8 +153,7 @@ public abstract class BaseController<S extends BaseService<L, D, Q, C>, L, D, Q,
/** /**
* 删除 * 删除
* *
* @param ids * @param ids ID 列表
* ID 列表
* @return / * @return /
*/ */
@Operation(summary = "删除数据", description = "删除数据") @Operation(summary = "删除数据", description = "删除数据")
@@ -185,12 +169,9 @@ public abstract class BaseController<S extends BaseService<L, D, Q, C>, L, D, Q,
/** /**
* 导出 * 导出
* *
* @param query * @param query 查询条件
* 查询条件 * @param sortQuery 排序查询条件
* @param sortQuery * @param response 响应对象
* 排序查询条件
* @param response
* 响应对象
*/ */
@Operation(summary = "导出数据", description = "导出数据") @Operation(summary = "导出数据", description = "导出数据")
@GetMapping("/export") @GetMapping("/export")
@@ -202,8 +183,7 @@ public abstract class BaseController<S extends BaseService<L, D, Q, C>, L, D, Q,
/** /**
* 根据 API 类型进行权限验证 * 根据 API 类型进行权限验证
* *
* @param api * @param api API 类型
* API 类型
*/ */
private void checkPermission(Api api) { private void checkPermission(Api api) {
CrudRequestMapping crudRequestMapping = this.getClass().getDeclaredAnnotation(CrudRequestMapping.class); CrudRequestMapping crudRequestMapping = this.getClass().getDeclaredAnnotation(CrudRequestMapping.class);

View File

@@ -29,8 +29,7 @@ import java.util.Collection;
/** /**
* Mapper 基类 * Mapper 基类
* *
* @param <T> * @param <T> 实体类
* 实体类
* @author Charles7c * @author Charles7c
* @since 1.0.0 * @since 1.0.0
*/ */
@@ -39,8 +38,7 @@ public interface BaseMapper<T> extends com.baomidou.mybatisplus.core.mapper.Base
/** /**
* 批量插入记录 * 批量插入记录
* *
* @param entityList * @param entityList 实体列表
* 实体列表
* @return 是否成功 * @return 是否成功
*/ */
default boolean insertBatch(Collection<T> entityList) { default boolean insertBatch(Collection<T> entityList) {
@@ -50,8 +48,7 @@ public interface BaseMapper<T> extends com.baomidou.mybatisplus.core.mapper.Base
/** /**
* 批量更新记录 * 批量更新记录
* *
* @param entityList * @param entityList 实体列表
* 实体列表
* @return 是否成功 * @return 是否成功
*/ */
default boolean updateBatchById(Collection<T> entityList) { default boolean updateBatchById(Collection<T> entityList) {
@@ -79,8 +76,7 @@ public interface BaseMapper<T> extends com.baomidou.mybatisplus.core.mapper.Base
/** /**
* 链式查询lambda 式) * 链式查询lambda 式)
* *
* @param entity * @param entity 实体对象
* 实体对象
* @return LambdaQueryWrapper 的包装类 * @return LambdaQueryWrapper 的包装类
*/ */
default LambdaQueryChainWrapper<T> lambdaQuery(T entity) { default LambdaQueryChainWrapper<T> lambdaQuery(T entity) {
@@ -111,6 +107,6 @@ public interface BaseMapper<T> extends com.baomidou.mybatisplus.core.mapper.Base
* @return 实体类 Class 对象 * @return 实体类 Class 对象
*/ */
default Class<T> currentEntityClass() { default Class<T> currentEntityClass() {
return (Class<T>)ClassUtil.getTypeArgument(this.getClass(), 0); return (Class<T>) ClassUtil.getTypeArgument(this.getClass(), 0);
} }
} }

View File

@@ -18,6 +18,7 @@ package top.charles7c.continew.starter.extension.crud.base;
import lombok.Data; import lombok.Data;
import java.io.Serial;
import java.io.Serializable; import java.io.Serializable;
/** /**
@@ -29,5 +30,6 @@ import java.io.Serializable;
@Data @Data
public class BaseReq implements Serializable { public class BaseReq implements Serializable {
@Serial
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
} }

View File

@@ -27,14 +27,10 @@ import java.util.List;
/** /**
* 业务接口基类 * 业务接口基类
* *
* @param <L> * @param <L> 列表信息
* 列表信息 * @param <D> 详情信息
* @param <D> * @param <Q> 查询条件
* 详情信息 * @param <C> 创建或修改信息
* @param <Q>
* 查询条件
* @param <C>
* 创建或修改信息
* @author Charles7c * @author Charles7c
* @since 1.0.0 * @since 1.0.0
*/ */
@@ -43,10 +39,8 @@ public interface BaseService<L, D, Q, C extends BaseReq> {
/** /**
* 分页查询列表 * 分页查询列表
* *
* @param query * @param query 查询条件
* 查询条件 * @param pageQuery 分页查询条件
* @param pageQuery
* 分页查询条件
* @return 分页列表信息 * @return 分页列表信息
*/ */
PageDataResp<L> page(Q query, PageQuery pageQuery); PageDataResp<L> page(Q query, PageQuery pageQuery);
@@ -54,12 +48,9 @@ public interface BaseService<L, D, Q, C extends BaseReq> {
/** /**
* 查询树列表 * 查询树列表
* *
* @param query * @param query 查询条件
* 查询条件 * @param sortQuery 排序查询条件
* @param sortQuery * @param isSimple 是否为简单树结构(不包含基本树结构之外的扩展字段)
* 排序查询条件
* @param isSimple
* 是否为简单树结构(不包含基本树结构之外的扩展字段)
* @return 树列表信息 * @return 树列表信息
*/ */
List<Tree<Long>> tree(Q query, SortQuery sortQuery, boolean isSimple); List<Tree<Long>> tree(Q query, SortQuery sortQuery, boolean isSimple);
@@ -67,10 +58,8 @@ public interface BaseService<L, D, Q, C extends BaseReq> {
/** /**
* 查询列表 * 查询列表
* *
* @param query * @param query 查询条件
* 查询条件 * @param sortQuery 排序查询条件
* @param sortQuery
* 排序查询条件
* @return 列表信息 * @return 列表信息
*/ */
List<L> list(Q query, SortQuery sortQuery); List<L> list(Q query, SortQuery sortQuery);
@@ -78,8 +67,7 @@ public interface BaseService<L, D, Q, C extends BaseReq> {
/** /**
* 查看详情 * 查看详情
* *
* @param id * @param id ID
* ID
* @return 详情信息 * @return 详情信息
*/ */
D get(Long id); D get(Long id);
@@ -87,8 +75,7 @@ public interface BaseService<L, D, Q, C extends BaseReq> {
/** /**
* 新增 * 新增
* *
* @param req * @param req 创建信息
* 创建信息
* @return 自增 ID * @return 自增 ID
*/ */
Long add(C req); Long add(C req);
@@ -96,30 +83,24 @@ public interface BaseService<L, D, Q, C extends BaseReq> {
/** /**
* 修改 * 修改
* *
* @param req * @param req 修改信息
* 修改信息 * @param id ID
* @param id
* ID
*/ */
void update(C req, Long id); void update(C req, Long id);
/** /**
* 删除 * 删除
* *
* @param ids * @param ids ID 列表
* ID 列表
*/ */
void delete(List<Long> ids); void delete(List<Long> ids);
/** /**
* 导出 * 导出
* *
* @param query * @param query 查询条件
* 查询条件 * @param sortQuery 排序查询条件
* @param sortQuery * @param response 响应对象
* 排序查询条件
* @param response
* 响应对象
*/ */
void export(Q query, SortQuery sortQuery, HttpServletResponse response); void export(Q query, SortQuery sortQuery, HttpServletResponse response);
} }

View File

@@ -51,18 +51,12 @@ import java.util.List;
/** /**
* 业务实现基类 * 业务实现基类
* *
* @param <M> * @param <M> Mapper 接口
* Mapper 接口 * @param <T> 实体类
* @param <T> * @param <L> 列表信息
* 实体类 * @param <D> 详情信息
* @param <L> * @param <Q> 查询条件
* 列表信息 * @param <C> 创建或修改信息
* @param <D>
* 详情信息
* @param <Q>
* 查询条件
* @param <C>
* 创建或修改信息
* @author Charles7c * @author Charles7c
* @since 1.0.0 * @since 1.0.0
*/ */
@@ -77,9 +71,9 @@ public abstract class BaseServiceImpl<M extends BaseMapper<T>, T extends BaseDO,
private final Class<D> detailClass; private final Class<D> detailClass;
protected BaseServiceImpl() { protected BaseServiceImpl() {
this.entityClass = (Class<T>)ClassUtil.getTypeArgument(this.getClass(), 1); this.entityClass = (Class<T>) ClassUtil.getTypeArgument(this.getClass(), 1);
this.listClass = (Class<L>)ClassUtil.getTypeArgument(this.getClass(), 2); this.listClass = (Class<L>) ClassUtil.getTypeArgument(this.getClass(), 2);
this.detailClass = (Class<D>)ClassUtil.getTypeArgument(this.getClass(), 3); this.detailClass = (Class<D>) ClassUtil.getTypeArgument(this.getClass(), 3);
} }
@Override @Override
@@ -131,12 +125,9 @@ public abstract class BaseServiceImpl<M extends BaseMapper<T>, T extends BaseDO,
/** /**
* 查询列表 * 查询列表
* *
* @param query * @param query 查询条件
* 查询条件 * @param sortQuery 排序查询条件
* @param sortQuery * @param targetClass 指定类型
* 排序查询条件
* @param targetClass
* 指定类型
* @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) {
@@ -150,10 +141,8 @@ public abstract class BaseServiceImpl<M extends BaseMapper<T>, T extends BaseDO,
/** /**
* 设置排序 * 设置排序
* *
* @param queryWrapper * @param queryWrapper 查询 Wrapper
* 查询 Wrapper * @param sortQuery 排序查询条件
* @param sortQuery
* 排序查询条件
*/ */
protected void sort(QueryWrapper<T> queryWrapper, SortQuery sortQuery) { protected void sort(QueryWrapper<T> queryWrapper, SortQuery sortQuery) {
Sort sort = Opt.ofNullable(sortQuery).orElseGet(SortQuery::new).getSort(); Sort sort = Opt.ofNullable(sortQuery).orElseGet(SortQuery::new).getSort();
@@ -207,8 +196,7 @@ public abstract class BaseServiceImpl<M extends BaseMapper<T>, T extends BaseDO,
/** /**
* 根据 ID 查询 * 根据 ID 查询
* *
* @param id * @param id ID
* ID
* @return 实体信息 * @return 实体信息
*/ */
protected T getById(Object id) { protected T getById(Object id) {
@@ -220,8 +208,7 @@ public abstract class BaseServiceImpl<M extends BaseMapper<T>, T extends BaseDO,
/** /**
* 填充数据 * 填充数据
* *
* @param baseObj * @param baseObj 待填充列表信息
* 待填充列表信息
*/ */
protected void fill(Object baseObj) { protected void fill(Object baseObj) {
if (baseObj instanceof BaseResp baseResp) { if (baseObj instanceof BaseResp baseResp) {
@@ -237,8 +224,7 @@ public abstract class BaseServiceImpl<M extends BaseMapper<T>, T extends BaseDO,
/** /**
* 填充详情数据 * 填充详情数据
* *
* @param detailObj * @param detailObj 待填充详情信息
* 待填充详情信息
*/ */
public void fillDetail(Object detailObj) { public void fillDetail(Object detailObj) {
if (detailObj instanceof BaseDetailResp detail) { if (detailObj instanceof BaseDetailResp detail) {

View File

@@ -27,8 +27,7 @@ public interface CommonUserService {
/** /**
* 根据 ID 查询昵称 * 根据 ID 查询昵称
* *
* @param id * @param id ID
* ID
* @return 昵称 * @return 昵称
*/ */
String getNicknameById(Long id); String getNicknameById(Long id);

View File

@@ -23,8 +23,7 @@ import java.io.Serializable;
/** /**
* 枚举接口 * 枚举接口
* *
* @param <T> * @param <T> value 类型
* value 类型
* @author Charles7c * @author Charles7c
* @since 1.0.0 * @since 1.0.0
*/ */

View File

@@ -33,11 +33,13 @@ public interface ValidateGroup extends Default {
/** /**
* 分组校验-创建 * 分组校验-创建
*/ */
interface Add extends Crud {} interface Add extends Crud {
}
/** /**
* 分组校验-修改 * 分组校验-修改
*/ */
interface Update extends Crud {} interface Update extends Crud {
}
} }
} }

View File

@@ -85,7 +85,8 @@ public enum QueryTypeEnum implements IBaseEnum<Integer> {
/** /**
* 非空查询例如WHERE `email` IS NOT NULL * 非空查询例如WHERE `email` IS NOT NULL
*/ */
IS_NOT_NULL(14, "IS NOT NULL"),; IS_NOT_NULL(14, "IS NOT NULL"),
;
private final Integer value; private final Integer value;
private final String description; private final String description;

View File

@@ -60,9 +60,9 @@ public class GlobalErrorHandler extends BasicErrorController {
public ModelAndView errorHtml(HttpServletRequest request, HttpServletResponse response) { public ModelAndView errorHtml(HttpServletRequest request, HttpServletResponse response) {
Map<String, Object> errorAttributeMap = Map<String, Object> errorAttributeMap =
super.getErrorAttributes(request, super.getErrorAttributeOptions(request, MediaType.TEXT_HTML)); super.getErrorAttributes(request, super.getErrorAttributeOptions(request, MediaType.TEXT_HTML));
String path = (String)errorAttributeMap.get("path"); String path = (String) errorAttributeMap.get("path");
HttpStatus status = super.getStatus(request); HttpStatus status = super.getStatus(request);
R<Object> result = R.fail(status.value(), (String)errorAttributeMap.get("error")); R<Object> result = R.fail(status.value(), (String) errorAttributeMap.get("error"));
result.setData(path); result.setData(path);
try { try {
response.setStatus(HttpStatus.OK.value()); response.setStatus(HttpStatus.OK.value());
@@ -79,9 +79,9 @@ public class GlobalErrorHandler extends BasicErrorController {
public ResponseEntity<Map<String, Object>> error(HttpServletRequest request) { public ResponseEntity<Map<String, Object>> error(HttpServletRequest request) {
Map<String, Object> errorAttributeMap = Map<String, Object> errorAttributeMap =
super.getErrorAttributes(request, super.getErrorAttributeOptions(request, MediaType.ALL)); super.getErrorAttributes(request, super.getErrorAttributeOptions(request, MediaType.ALL));
String path = (String)errorAttributeMap.get("path"); String path = (String) errorAttributeMap.get("path");
HttpStatus status = super.getStatus(request); HttpStatus status = super.getStatus(request);
R<Object> result = R.fail(status.value(), (String)errorAttributeMap.get("error")); R<Object> result = R.fail(status.value(), (String) errorAttributeMap.get("error"));
result.setData(path); result.setData(path);
log.error("请求地址 [{}],发生错误,错误信息:{}。", path, JSONUtil.toJsonStr(errorAttributeMap)); log.error("请求地址 [{}],发生错误,错误信息:{}。", path, JSONUtil.toJsonStr(errorAttributeMap));
return new ResponseEntity<>(BeanUtil.beanToMap(result), HttpStatus.OK); return new ResponseEntity<>(BeanUtil.beanToMap(result), HttpStatus.OK);

View File

@@ -45,9 +45,13 @@ public class PageQuery extends SortQuery {
@Serial @Serial
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/** 默认页码1 */ /**
* 默认页码1
*/
private static final int DEFAULT_PAGE = 1; private static final int DEFAULT_PAGE = 1;
/** 默认每页条数10 */ /**
* 默认每页条数10
*/
private static final int DEFAULT_SIZE = 10; private static final int DEFAULT_SIZE = 10;
/** /**
@@ -67,8 +71,7 @@ public class PageQuery extends SortQuery {
/** /**
* 基于分页查询条件转换为 MyBatis Plus 分页条件 * 基于分页查询条件转换为 MyBatis Plus 分页条件
* *
* @param <T> * @param <T> 列表数据类型
* 列表数据类型
* @return MyBatis Plus 分页条件 * @return MyBatis Plus 分页条件
*/ */
public <T> IPage<T> toPage() { public <T> IPage<T> toPage() {

View File

@@ -30,8 +30,7 @@ import java.util.List;
/** /**
* 分页信息 * 分页信息
* *
* @param <L> * @param <L> 列表数据类型
* 列表数据类型
* @author Charles7c * @author Charles7c
* @since 1.0.0 * @since 1.0.0
*/ */
@@ -57,14 +56,10 @@ public class PageDataResp<L> implements Serializable {
/** /**
* 基于 MyBatis Plus 分页数据构建分页信息,并将源数据转换为指定类型数据 * 基于 MyBatis Plus 分页数据构建分页信息,并将源数据转换为指定类型数据
* *
* @param page * @param page MyBatis Plus 分页数据
* MyBatis Plus 分页数据 * @param targetClass 目标类型 Class 对象
* @param targetClass * @param <T> 源列表数据类型
* 目标类型 Class 对象 * @param <L> 目标列表数据类型
* @param <T>
* 源列表数据类型
* @param <L>
* 目标列表数据类型
* @return 分页信息 * @return 分页信息
*/ */
public static <T, L> PageDataResp<L> build(IPage<T> page, Class<L> targetClass) { public static <T, L> PageDataResp<L> build(IPage<T> page, Class<L> targetClass) {
@@ -80,10 +75,8 @@ public class PageDataResp<L> implements Serializable {
/** /**
* 基于 MyBatis Plus 分页数据构建分页信息 * 基于 MyBatis Plus 分页数据构建分页信息
* *
* @param page * @param page MyBatis Plus 分页数据
* MyBatis Plus 分页数据 * @param <L> 列表数据类型
* @param <L>
* 列表数据类型
* @return 分页信息 * @return 分页信息
*/ */
public static <L> PageDataResp<L> build(IPage<L> page) { public static <L> PageDataResp<L> build(IPage<L> page) {
@@ -99,14 +92,10 @@ public class PageDataResp<L> implements Serializable {
/** /**
* 基于列表数据构建分页信息 * 基于列表数据构建分页信息
* *
* @param page * @param page 页码
* 页码 * @param size 每页条数
* @param size * @param list 列表数据
* 每页条数 * @param <L> 列表数据类型
* @param list
* 列表数据
* @param <L>
* 列表数据类型
* @return 分页信息 * @return 分页信息
*/ */
public static <L> PageDataResp<L> build(int page, int size, List<L> list) { public static <L> PageDataResp<L> build(int page, int size, List<L> list) {
@@ -131,8 +120,7 @@ public class PageDataResp<L> implements Serializable {
/** /**
* 空分页信息 * 空分页信息
* *
* @param <L> * @param <L> 列表数据类型
* 列表数据类型
* @return 分页信息 * @return 分页信息
*/ */
private static <L> PageDataResp<L> empty() { private static <L> PageDataResp<L> empty() {

View File

@@ -40,29 +40,43 @@ public class R<T> implements Serializable {
@Serial @Serial
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/** 是否成功 */ /**
* 是否成功
*/
@Schema(description = "是否成功", example = "true") @Schema(description = "是否成功", example = "true")
private boolean success; private boolean success;
/** 业务状态码 */ /**
* 业务状态码
*/
@Schema(description = "业务状态码", example = "200") @Schema(description = "业务状态码", example = "200")
private int code; private int code;
/** 业务状态信息 */ /**
* 业务状态信息
*/
@Schema(description = "业务状态信息", example = "操作成功") @Schema(description = "业务状态信息", example = "操作成功")
private String msg; private String msg;
/** 响应数据 */ /**
* 响应数据
*/
@Schema(description = "响应数据") @Schema(description = "响应数据")
private T data; private T data;
/** 时间戳 */ /**
* 时间戳
*/
@Schema(description = "时间戳", example = "1691453288") @Schema(description = "时间戳", example = "1691453288")
private long timestamp = DateUtil.currentSeconds(); private long timestamp = DateUtil.currentSeconds();
/** 成功状态码 */ /**
* 成功状态码
*/
private static final int SUCCESS_CODE = HttpStatus.OK.value(); private static final int SUCCESS_CODE = HttpStatus.OK.value();
/** 失败状态码 */ /**
* 失败状态码
*/
private static final int FAIL_CODE = HttpStatus.INTERNAL_SERVER_ERROR.value(); private static final int FAIL_CODE = HttpStatus.INTERNAL_SERVER_ERROR.value();
private R(boolean success, int code, String msg, T data) { private R(boolean success, int code, String msg, T data) {

View File

@@ -46,12 +46,9 @@ public class QueryHelper {
/** /**
* 根据查询条件构建 MyBatis Plus 查询条件封装对象 * 根据查询条件构建 MyBatis Plus 查询条件封装对象
* *
* @param query * @param query 查询条件
* 查询条件 * @param <Q> 查询条件数据类型
* @param <Q> * @param <R> 查询数据类型
* 查询条件数据类型
* @param <R>
* 查询数据类型
* @return MyBatis Plus 查询条件封装对象 * @return MyBatis Plus 查询条件封装对象
*/ */
public static <Q, R> QueryWrapper<R> build(Q query) { public static <Q, R> QueryWrapper<R> build(Q query) {
@@ -69,16 +66,11 @@ public class QueryHelper {
/** /**
* 构建 MyBatis Plus 查询条件封装对象 * 构建 MyBatis Plus 查询条件封装对象
* *
* @param query * @param query 查询条件
* 查询条件 * @param field 字段
* @param field * @param queryWrapper MyBatis Plus 查询条件封装对象
* 字段 * @param <Q> 查询条件数据类型
* @param queryWrapper * @param <R> 查询数据类型
* MyBatis Plus 查询条件封装对象
* @param <Q>
* 查询条件数据类型
* @param <R>
* 查询数据类型
*/ */
private static <Q, R> void buildQuery(Q query, Field field, QueryWrapper<R> queryWrapper) { private static <Q, R> void buildQuery(Q query, Field field, QueryWrapper<R> queryWrapper) {
boolean accessible = field.canAccess(query); boolean accessible = field.canAccess(query);
@@ -112,16 +104,11 @@ public class QueryHelper {
/** /**
* 解析查询条件 * 解析查询条件
* *
* @param queryAnnotation * @param queryAnnotation 查询注解
* 查询注解 * @param fieldName 字段名
* @param fieldName * @param fieldValue 字段值
* 字段名 * @param queryWrapper MyBatis Plus 查询条件封装对象
* @param fieldValue * @param <R> 查询数据类型
* 字段值
* @param queryWrapper
* MyBatis Plus 查询条件封装对象
* @param <R>
* 查询数据类型
*/ */
private static <R> void parse(Query queryAnnotation, String fieldName, Object fieldValue, private static <R> void parse(Query queryAnnotation, String fieldName, Object fieldValue,
QueryWrapper<R> queryWrapper) { QueryWrapper<R> queryWrapper) {
@@ -151,7 +138,7 @@ public class QueryHelper {
case GREATER_THAN_OR_EQUAL -> queryWrapper.ge(columnName, fieldValue); case GREATER_THAN_OR_EQUAL -> queryWrapper.ge(columnName, fieldValue);
case LESS_THAN_OR_EQUAL -> queryWrapper.le(columnName, fieldValue); case LESS_THAN_OR_EQUAL -> queryWrapper.le(columnName, fieldValue);
case BETWEEN -> { case BETWEEN -> {
List<Object> between = new ArrayList<>((List<Object>)fieldValue); List<Object> between = new ArrayList<>((List<Object>) fieldValue);
ValidationUtils.throwIf(between.size() != 2, "[{}] 必须是一个范围", fieldName); ValidationUtils.throwIf(between.size() != 2, "[{}] 必须是一个范围", fieldName);
queryWrapper.between(columnName, between.get(0), between.get(1)); queryWrapper.between(columnName, between.get(0), between.get(1));
} }
@@ -160,11 +147,11 @@ public class QueryHelper {
case RIGHT_LIKE -> queryWrapper.likeRight(columnName, fieldValue); case RIGHT_LIKE -> queryWrapper.likeRight(columnName, fieldValue);
case IN -> { case IN -> {
ValidationUtils.throwIfEmpty(fieldValue, "[{}] 不能为空", fieldName); ValidationUtils.throwIfEmpty(fieldValue, "[{}] 不能为空", fieldName);
queryWrapper.in(columnName, (List<Object>)fieldValue); queryWrapper.in(columnName, (List<Object>) fieldValue);
} }
case NOT_IN -> { case NOT_IN -> {
ValidationUtils.throwIfEmpty(fieldValue, "[{}] 不能为空", fieldName); ValidationUtils.throwIfEmpty(fieldValue, "[{}] 不能为空", fieldName);
queryWrapper.notIn(columnName, (List<Object>)fieldValue); queryWrapper.notIn(columnName, (List<Object>) fieldValue);
} }
case IS_NULL -> queryWrapper.isNull(columnName); case IS_NULL -> queryWrapper.isNull(columnName);
case IS_NOT_NULL -> queryWrapper.isNotNull(columnName); case IS_NOT_NULL -> queryWrapper.isNotNull(columnName);

View File

@@ -39,11 +39,9 @@ public class ReflectUtils {
* 获得一个类中所有非静态字段名列表,包括其父类中的字段<br> * 获得一个类中所有非静态字段名列表,包括其父类中的字段<br>
* 如果子类与父类中存在同名字段,则这两个字段同时存在,子类字段在前,父类字段在后。 * 如果子类与父类中存在同名字段,则这两个字段同时存在,子类字段在前,父类字段在后。
* *
* @param beanClass * @param beanClass
* 类
* @return 非静态字段名列表 * @return 非静态字段名列表
* @throws SecurityException * @throws SecurityException 安全检查异常
* 安全检查异常
*/ */
public static List<String> getNonStaticFieldsName(Class<?> beanClass) throws SecurityException { public static List<String> getNonStaticFieldsName(Class<?> beanClass) throws SecurityException {
List<Field> nonStaticFields = getNonStaticFields(beanClass); List<Field> nonStaticFields = getNonStaticFields(beanClass);
@@ -54,11 +52,9 @@ public class ReflectUtils {
* 获得一个类中所有非静态字段列表,包括其父类中的字段<br> * 获得一个类中所有非静态字段列表,包括其父类中的字段<br>
* 如果子类与父类中存在同名字段,则这两个字段同时存在,子类字段在前,父类字段在后。 * 如果子类与父类中存在同名字段,则这两个字段同时存在,子类字段在前,父类字段在后。
* *
* @param beanClass * @param beanClass
* 类
* @return 非静态字段列表 * @return 非静态字段列表
* @throws SecurityException * @throws SecurityException 安全检查异常
* 安全检查异常
*/ */
public static List<Field> getNonStaticFields(Class<?> beanClass) throws SecurityException { public static List<Field> getNonStaticFields(Class<?> beanClass) throws SecurityException {
Field[] fields = ReflectUtil.getFields(beanClass); Field[] fields = ReflectUtil.getFields(beanClass);

View File

@@ -39,21 +39,19 @@ import java.util.List;
@NoArgsConstructor(access = AccessLevel.PRIVATE) @NoArgsConstructor(access = AccessLevel.PRIVATE)
public class TreeUtils { public class TreeUtils {
/** 默认字段配置对象(根据前端树结构灵活调整名称) */ /**
* 默认字段配置对象(根据前端树结构灵活调整名称)
*/
public static final TreeNodeConfig DEFAULT_CONFIG = public static final TreeNodeConfig DEFAULT_CONFIG =
TreeNodeConfig.DEFAULT_CONFIG.setNameKey("title").setIdKey("key").setWeightKey("sort"); TreeNodeConfig.DEFAULT_CONFIG.setNameKey("title").setIdKey("key").setWeightKey("sort");
/** /**
* 树构建 * 树构建
* *
* @param <T> * @param <T> 转换的实体 为数据源里的对象类型
* 转换的实体 为数据源里的对象类型 * @param <E> ID类型
* @param <E> * @param list 源数据集合
* ID类型 * @param nodeParser 转换器
* @param list
* 源数据集合
* @param nodeParser
* 转换器
* @return List 树列表 * @return List 树列表
*/ */
public static <T, E> List<Tree<E>> build(List<T> list, NodeParser<T, E> nodeParser) { public static <T, E> List<Tree<E>> build(List<T> list, NodeParser<T, E> nodeParser) {
@@ -63,31 +61,25 @@ public class TreeUtils {
/** /**
* 树构建 * 树构建
* *
* @param <T> * @param <T> 转换的实体 为数据源里的对象类型
* 转换的实体 为数据源里的对象类型 * @param <E> ID类型
* @param <E> * @param list 源数据集合
* ID类型 * @param treeNodeConfig 配置
* @param list * @param nodeParser 转换器
* 源数据集合
* @param treeNodeConfig
* 配置
* @param nodeParser
* 转换器
* @return List 树列表 * @return List 树列表
*/ */
public static <T, E> List<Tree<E>> build(List<T> list, TreeNodeConfig treeNodeConfig, NodeParser<T, E> nodeParser) { public static <T, E> List<Tree<E>> build(List<T> list, TreeNodeConfig treeNodeConfig, NodeParser<T, E> nodeParser) {
if (CollUtil.isEmpty(list)) { if (CollUtil.isEmpty(list)) {
return new ArrayList<>(0); return new ArrayList<>(0);
} }
E parentId = (E)ReflectUtil.getFieldValue(list.get(0), treeNodeConfig.getParentIdKey()); E parentId = (E) ReflectUtil.getFieldValue(list.get(0), treeNodeConfig.getParentIdKey());
return TreeUtil.build(list, parentId, treeNodeConfig, nodeParser); return TreeUtil.build(list, parentId, treeNodeConfig, nodeParser);
} }
/** /**
* 根据 @TreeField 配置生成树结构配置 * 根据 @TreeField 配置生成树结构配置
* *
* @param treeField * @param treeField 树结构字段注解
* 树结构字段注解
* @return 树结构配置 * @return 树结构配置
*/ */
public static TreeNodeConfig genTreeNodeConfig(TreeField treeField) { public static TreeNodeConfig genTreeNodeConfig(TreeField treeField) {

View File

@@ -28,8 +28,8 @@ import java.util.function.BooleanSupplier;
/** /**
* 业务参数校验工具类(抛出 500 ServiceException * 业务参数校验工具类(抛出 500 ServiceException
* *
* @see BusinessException
* @author Charles7c * @author Charles7c
* @see BusinessException
* @since 1.0.0 * @since 1.0.0
*/ */
@Slf4j @Slf4j
@@ -41,14 +41,10 @@ public class CheckUtils extends Validator {
/** /**
* 如果不存在,抛出异常 * 如果不存在,抛出异常
* *
* @param obj * @param obj 被检测的对象
* 被检测的对象 * @param entityName 实体名
* @param entityName * @param fieldName 字段名
* 实体名 * @param fieldValue 字段值
* @param fieldName
* 字段名
* @param fieldValue
* 字段值
*/ */
public static void throwIfNotExists(Object obj, String entityName, String fieldName, Object fieldValue) { public static void throwIfNotExists(Object obj, String entityName, String fieldName, Object fieldValue) {
String message = String.format("%s 为 [%s] 的 %s 记录已不存在", fieldName, fieldValue, String message = String.format("%s 为 [%s] 的 %s 记录已不存在", fieldName, fieldValue,
@@ -59,12 +55,9 @@ public class CheckUtils extends Validator {
/** /**
* 如果为空,抛出异常 * 如果为空,抛出异常
* *
* @param obj * @param obj 被检测的对象
* 被检测的对象 * @param template 异常信息模板,被替换的部分用 {} 表示,如果模板为 null返回 "null"
* @param template * @param params 参数值
* 异常信息模板,被替换的部分用 {} 表示,如果模板为 null返回 "null"
* @param params
* 参数值
*/ */
public static void throwIfNull(Object obj, String template, Object... params) { public static void throwIfNull(Object obj, String template, Object... params) {
throwIfNull(obj, StrUtil.format(template, params), EXCEPTION_TYPE); throwIfNull(obj, StrUtil.format(template, params), EXCEPTION_TYPE);
@@ -73,12 +66,9 @@ public class CheckUtils extends Validator {
/** /**
* 如果不为空,抛出异常 * 如果不为空,抛出异常
* *
* @param obj * @param obj 被检测的对象
* 被检测的对象 * @param template 异常信息模板,被替换的部分用 {} 表示,如果模板为 null返回 "null"
* @param template * @param params 参数值
* 异常信息模板,被替换的部分用 {} 表示,如果模板为 null返回 "null"
* @param params
* 参数值
*/ */
public static void throwIfNotNull(Object obj, String template, Object... params) { public static void throwIfNotNull(Object obj, String template, Object... params) {
throwIfNotNull(obj, StrUtil.format(template, params), EXCEPTION_TYPE); throwIfNotNull(obj, StrUtil.format(template, params), EXCEPTION_TYPE);
@@ -87,14 +77,10 @@ public class CheckUtils extends Validator {
/** /**
* 如果存在,抛出异常 * 如果存在,抛出异常
* *
* @param obj * @param obj 被检测的对象
* 被检测的对象 * @param entityName 实体名
* @param entityName * @param fieldName 字段名
* 实体名 * @param fieldValue 字段值
* @param fieldName
* 字段名
* @param fieldValue
* 字段值
*/ */
public static void throwIfExists(Object obj, String entityName, String fieldName, Object fieldValue) { public static void throwIfExists(Object obj, String entityName, String fieldName, Object fieldValue) {
String message = String.format("%s 为 [%s] 的 %s 记录已存在", fieldName, fieldValue, entityName); String message = String.format("%s 为 [%s] 的 %s 记录已存在", fieldName, fieldValue, entityName);
@@ -104,12 +90,9 @@ public class CheckUtils extends Validator {
/** /**
* 如果为空,抛出异常 * 如果为空,抛出异常
* *
* @param obj * @param obj 被检测的对象
* 被检测的对象 * @param template 异常信息模板,被替换的部分用 {} 表示,如果模板为 null返回 "null"
* @param template * @param params 参数值
* 异常信息模板,被替换的部分用 {} 表示,如果模板为 null返回 "null"
* @param params
* 参数值
*/ */
public static void throwIfEmpty(Object obj, String template, Object... params) { public static void throwIfEmpty(Object obj, String template, Object... params) {
throwIfEmpty(obj, StrUtil.format(template, params), EXCEPTION_TYPE); throwIfEmpty(obj, StrUtil.format(template, params), EXCEPTION_TYPE);
@@ -118,12 +101,9 @@ public class CheckUtils extends Validator {
/** /**
* 如果不为空,抛出异常 * 如果不为空,抛出异常
* *
* @param obj * @param obj 被检测的对象
* 被检测的对象 * @param template 异常信息模板,被替换的部分用 {} 表示,如果模板为 null返回 "null"
* @param template * @param params 参数值
* 异常信息模板,被替换的部分用 {} 表示,如果模板为 null返回 "null"
* @param params
* 参数值
*/ */
public static void throwIfNotEmpty(Object obj, String template, Object... params) { public static void throwIfNotEmpty(Object obj, String template, Object... params) {
throwIfNotEmpty(obj, StrUtil.format(template, params), EXCEPTION_TYPE); throwIfNotEmpty(obj, StrUtil.format(template, params), EXCEPTION_TYPE);
@@ -132,12 +112,9 @@ public class CheckUtils extends Validator {
/** /**
* 如果为空,抛出异常 * 如果为空,抛出异常
* *
* @param str * @param str 被检测的字符串
* 被检测的字符串 * @param template 异常信息模板,被替换的部分用 {} 表示,如果模板为 null返回 "null"
* @param template * @param params 参数值
* 异常信息模板,被替换的部分用 {} 表示,如果模板为 null返回 "null"
* @param params
* 参数值
*/ */
public static void throwIfBlank(CharSequence str, String template, Object... params) { public static void throwIfBlank(CharSequence str, String template, Object... params) {
throwIfBlank(str, StrUtil.format(template, params), EXCEPTION_TYPE); throwIfBlank(str, StrUtil.format(template, params), EXCEPTION_TYPE);
@@ -146,12 +123,9 @@ public class CheckUtils extends Validator {
/** /**
* 如果不为空,抛出异常 * 如果不为空,抛出异常
* *
* @param str * @param str 被检测的字符串
* 被检测的字符串 * @param template 异常信息模板,被替换的部分用 {} 表示,如果模板为 null返回 "null"
* @param template * @param params 参数值
* 异常信息模板,被替换的部分用 {} 表示,如果模板为 null返回 "null"
* @param params
* 参数值
*/ */
public static void throwIfNotBlank(CharSequence str, String template, Object... params) { public static void throwIfNotBlank(CharSequence str, String template, Object... params) {
throwIfNotBlank(str, StrUtil.format(template, params), EXCEPTION_TYPE); throwIfNotBlank(str, StrUtil.format(template, params), EXCEPTION_TYPE);
@@ -160,14 +134,10 @@ public class CheckUtils extends Validator {
/** /**
* 如果相同,抛出异常 * 如果相同,抛出异常
* *
* @param obj1 * @param obj1 要比较的对象1
* 要比较的对象1 * @param obj2 要比较的对象2
* @param obj2 * @param template 异常信息模板,被替换的部分用 {} 表示,如果模板为 null返回 "null"
* 要比较的对象2 * @param params 参数值
* @param template
* 异常信息模板,被替换的部分用 {} 表示,如果模板为 null返回 "null"
* @param params
* 参数值
*/ */
public static void throwIfEqual(Object obj1, Object obj2, String template, Object... params) { public static void throwIfEqual(Object obj1, Object obj2, String template, Object... params) {
throwIfEqual(obj1, obj2, StrUtil.format(template, params), EXCEPTION_TYPE); throwIfEqual(obj1, obj2, StrUtil.format(template, params), EXCEPTION_TYPE);
@@ -176,14 +146,10 @@ public class CheckUtils extends Validator {
/** /**
* 如果不相同,抛出异常 * 如果不相同,抛出异常
* *
* @param obj1 * @param obj1 要比较的对象1
* 要比较的对象1 * @param obj2 要比较的对象2
* @param obj2 * @param template 异常信息模板,被替换的部分用 {} 表示,如果模板为 null返回 "null"
* 要比较的对象2 * @param params 参数值
* @param template
* 异常信息模板,被替换的部分用 {} 表示,如果模板为 null返回 "null"
* @param params
* 参数值
*/ */
public static void throwIfNotEqual(Object obj1, Object obj2, String template, Object... params) { public static void throwIfNotEqual(Object obj1, Object obj2, String template, Object... params) {
throwIfNotEqual(obj1, obj2, StrUtil.format(template, params), EXCEPTION_TYPE); throwIfNotEqual(obj1, obj2, StrUtil.format(template, params), EXCEPTION_TYPE);
@@ -192,14 +158,10 @@ public class CheckUtils extends Validator {
/** /**
* 如果相同,抛出异常(不区分大小写) * 如果相同,抛出异常(不区分大小写)
* *
* @param str1 * @param str1 要比较的字符串1
* 要比较的字符串1 * @param str2 要比较的字符串2
* @param str2 * @param template 异常信息模板,被替换的部分用 {} 表示,如果模板为 null返回 "null"
* 要比较的字符串2 * @param params 参数值
* @param template
* 异常信息模板,被替换的部分用 {} 表示,如果模板为 null返回 "null"
* @param params
* 参数值
*/ */
public static void throwIfEqualIgnoreCase(CharSequence str1, CharSequence str2, String template, Object... params) { public static void throwIfEqualIgnoreCase(CharSequence str1, CharSequence str2, String template, Object... params) {
throwIfEqualIgnoreCase(str1, str2, StrUtil.format(template, params), EXCEPTION_TYPE); throwIfEqualIgnoreCase(str1, str2, StrUtil.format(template, params), EXCEPTION_TYPE);
@@ -208,14 +170,10 @@ public class CheckUtils extends Validator {
/** /**
* 如果不相同,抛出异常(不区分大小写) * 如果不相同,抛出异常(不区分大小写)
* *
* @param str1 * @param str1 要比较的字符串1
* 要比较的字符串1 * @param str2 要比较的字符串2
* @param str2 * @param template 异常信息模板,被替换的部分用 {} 表示,如果模板为 null返回 "null"
* 要比较的字符串2 * @param params 参数值
* @param template
* 异常信息模板,被替换的部分用 {} 表示,如果模板为 null返回 "null"
* @param params
* 参数值
*/ */
public static void throwIfNotEqualIgnoreCase(CharSequence str1, CharSequence str2, String template, public static void throwIfNotEqualIgnoreCase(CharSequence str1, CharSequence str2, String template,
Object... params) { Object... params) {
@@ -225,12 +183,9 @@ public class CheckUtils extends Validator {
/** /**
* 如果条件成立,抛出异常 * 如果条件成立,抛出异常
* *
* @param condition * @param condition 条件
* 条件 * @param template 异常信息模板,被替换的部分用 {} 表示,如果模板为 null返回 "null"
* @param template * @param params 参数值
* 异常信息模板,被替换的部分用 {} 表示,如果模板为 null返回 "null"
* @param params
* 参数值
*/ */
public static void throwIf(boolean condition, String template, Object... params) { public static void throwIf(boolean condition, String template, Object... params) {
throwIf(condition, StrUtil.format(template, params), EXCEPTION_TYPE); throwIf(condition, StrUtil.format(template, params), EXCEPTION_TYPE);
@@ -239,12 +194,9 @@ public class CheckUtils extends Validator {
/** /**
* 如果条件成立,抛出异常 * 如果条件成立,抛出异常
* *
* @param conditionSupplier * @param conditionSupplier 条件
* 条件 * @param template 异常信息模板,被替换的部分用 {} 表示,如果模板为 null返回 "null"
* @param template * @param params 参数值
* 异常信息模板,被替换的部分用 {} 表示,如果模板为 null返回 "null"
* @param params
* 参数值
*/ */
public static void throwIf(BooleanSupplier conditionSupplier, String template, Object... params) { public static void throwIf(BooleanSupplier conditionSupplier, String template, Object... params) {
throwIf(conditionSupplier, StrUtil.format(template, params), EXCEPTION_TYPE); throwIf(conditionSupplier, StrUtil.format(template, params), EXCEPTION_TYPE);

View File

@@ -27,8 +27,8 @@ import java.util.function.BooleanSupplier;
/** /**
* 基本参数校验工具类(抛出 400 BadRequestException * 基本参数校验工具类(抛出 400 BadRequestException
* *
* @see BadRequestException
* @author Charles7c * @author Charles7c
* @see BadRequestException
* @since 1.0.0 * @since 1.0.0
*/ */
@Slf4j @Slf4j
@@ -40,12 +40,9 @@ public class ValidationUtils extends Validator {
/** /**
* 如果为空,抛出异常 * 如果为空,抛出异常
* *
* @param obj * @param obj 被检测的对象
* 被检测的对象 * @param template 异常信息模板,被替换的部分用 {} 表示,如果模板为 null返回 "null"
* @param template * @param params 参数值
* 异常信息模板,被替换的部分用 {} 表示,如果模板为 null返回 "null"
* @param params
* 参数值
*/ */
public static void throwIfNull(Object obj, String template, Object... params) { public static void throwIfNull(Object obj, String template, Object... params) {
throwIfNull(obj, StrUtil.format(template, params), EXCEPTION_TYPE); throwIfNull(obj, StrUtil.format(template, params), EXCEPTION_TYPE);
@@ -54,12 +51,9 @@ public class ValidationUtils extends Validator {
/** /**
* 如果不为空,抛出异常 * 如果不为空,抛出异常
* *
* @param obj * @param obj 被检测的对象
* 被检测的对象 * @param template 异常信息模板,被替换的部分用 {} 表示,如果模板为 null返回 "null"
* @param template * @param params 参数值
* 异常信息模板,被替换的部分用 {} 表示,如果模板为 null返回 "null"
* @param params
* 参数值
*/ */
public static void throwIfNotNull(Object obj, String template, Object... params) { public static void throwIfNotNull(Object obj, String template, Object... params) {
throwIfNotNull(obj, StrUtil.format(template, params), EXCEPTION_TYPE); throwIfNotNull(obj, StrUtil.format(template, params), EXCEPTION_TYPE);
@@ -68,12 +62,9 @@ public class ValidationUtils extends Validator {
/** /**
* 如果为空,抛出异常 * 如果为空,抛出异常
* *
* @param obj * @param obj 被检测的对象
* 被检测的对象 * @param template 异常信息模板,被替换的部分用 {} 表示,如果模板为 null返回 "null"
* @param template * @param params 参数值
* 异常信息模板,被替换的部分用 {} 表示,如果模板为 null返回 "null"
* @param params
* 参数值
*/ */
public static void throwIfEmpty(Object obj, String template, Object... params) { public static void throwIfEmpty(Object obj, String template, Object... params) {
throwIfEmpty(obj, StrUtil.format(template, params), EXCEPTION_TYPE); throwIfEmpty(obj, StrUtil.format(template, params), EXCEPTION_TYPE);
@@ -82,12 +73,9 @@ public class ValidationUtils extends Validator {
/** /**
* 如果不为空,抛出异常 * 如果不为空,抛出异常
* *
* @param obj * @param obj 被检测的对象
* 被检测的对象 * @param template 异常信息模板,被替换的部分用 {} 表示,如果模板为 null返回 "null"
* @param template * @param params 参数值
* 异常信息模板,被替换的部分用 {} 表示,如果模板为 null返回 "null"
* @param params
* 参数值
*/ */
public static void throwIfNotEmpty(Object obj, String template, Object... params) { public static void throwIfNotEmpty(Object obj, String template, Object... params) {
throwIfNotEmpty(obj, StrUtil.format(template, params), EXCEPTION_TYPE); throwIfNotEmpty(obj, StrUtil.format(template, params), EXCEPTION_TYPE);
@@ -96,12 +84,9 @@ public class ValidationUtils extends Validator {
/** /**
* 如果为空,抛出异常 * 如果为空,抛出异常
* *
* @param str * @param str 被检测的字符串
* 被检测的字符串 * @param template 异常信息模板,被替换的部分用 {} 表示,如果模板为 null返回 "null"
* @param template * @param params 参数值
* 异常信息模板,被替换的部分用 {} 表示,如果模板为 null返回 "null"
* @param params
* 参数值
*/ */
public static void throwIfBlank(CharSequence str, String template, Object... params) { public static void throwIfBlank(CharSequence str, String template, Object... params) {
throwIfBlank(str, StrUtil.format(template, params), EXCEPTION_TYPE); throwIfBlank(str, StrUtil.format(template, params), EXCEPTION_TYPE);
@@ -110,12 +95,9 @@ public class ValidationUtils extends Validator {
/** /**
* 如果不为空,抛出异常 * 如果不为空,抛出异常
* *
* @param str * @param str 被检测的字符串
* 被检测的字符串 * @param template 异常信息模板,被替换的部分用 {} 表示,如果模板为 null返回 "null"
* @param template * @param params 参数值
* 异常信息模板,被替换的部分用 {} 表示,如果模板为 null返回 "null"
* @param params
* 参数值
*/ */
public static void throwIfNotBlank(CharSequence str, String template, Object... params) { public static void throwIfNotBlank(CharSequence str, String template, Object... params) {
throwIfNotBlank(str, StrUtil.format(template, params), EXCEPTION_TYPE); throwIfNotBlank(str, StrUtil.format(template, params), EXCEPTION_TYPE);
@@ -124,14 +106,10 @@ public class ValidationUtils extends Validator {
/** /**
* 如果相同,抛出异常 * 如果相同,抛出异常
* *
* @param obj1 * @param obj1 要比较的对象1
* 要比较的对象1 * @param obj2 要比较的对象2
* @param obj2 * @param template 异常信息模板,被替换的部分用 {} 表示,如果模板为 null返回 "null"
* 要比较的对象2 * @param params 参数值
* @param template
* 异常信息模板,被替换的部分用 {} 表示,如果模板为 null返回 "null"
* @param params
* 参数值
*/ */
public static void throwIfEqual(Object obj1, Object obj2, String template, Object... params) { public static void throwIfEqual(Object obj1, Object obj2, String template, Object... params) {
throwIfEqual(obj1, obj2, StrUtil.format(template, params), EXCEPTION_TYPE); throwIfEqual(obj1, obj2, StrUtil.format(template, params), EXCEPTION_TYPE);
@@ -140,14 +118,10 @@ public class ValidationUtils extends Validator {
/** /**
* 如果不相同,抛出异常 * 如果不相同,抛出异常
* *
* @param obj1 * @param obj1 要比较的对象1
* 要比较的对象1 * @param obj2 要比较的对象2
* @param obj2 * @param template 异常信息模板,被替换的部分用 {} 表示,如果模板为 null返回 "null"
* 要比较的对象2 * @param params 参数值
* @param template
* 异常信息模板,被替换的部分用 {} 表示,如果模板为 null返回 "null"
* @param params
* 参数值
*/ */
public static void throwIfNotEqual(Object obj1, Object obj2, String template, Object... params) { public static void throwIfNotEqual(Object obj1, Object obj2, String template, Object... params) {
throwIfNotEqual(obj1, obj2, StrUtil.format(template, params), EXCEPTION_TYPE); throwIfNotEqual(obj1, obj2, StrUtil.format(template, params), EXCEPTION_TYPE);
@@ -156,14 +130,10 @@ public class ValidationUtils extends Validator {
/** /**
* 如果相同,抛出异常(不区分大小写) * 如果相同,抛出异常(不区分大小写)
* *
* @param str1 * @param str1 要比较的字符串1
* 要比较的字符串1 * @param str2 要比较的字符串2
* @param str2 * @param template 异常信息模板,被替换的部分用 {} 表示,如果模板为 null返回 "null"
* 要比较的字符串2 * @param params 参数值
* @param template
* 异常信息模板,被替换的部分用 {} 表示,如果模板为 null返回 "null"
* @param params
* 参数值
*/ */
public static void throwIfEqualIgnoreCase(CharSequence str1, CharSequence str2, String template, Object... params) { public static void throwIfEqualIgnoreCase(CharSequence str1, CharSequence str2, String template, Object... params) {
throwIfEqualIgnoreCase(str1, str2, StrUtil.format(template, params), EXCEPTION_TYPE); throwIfEqualIgnoreCase(str1, str2, StrUtil.format(template, params), EXCEPTION_TYPE);
@@ -172,14 +142,10 @@ public class ValidationUtils extends Validator {
/** /**
* 如果不相同,抛出异常(不区分大小写) * 如果不相同,抛出异常(不区分大小写)
* *
* @param str1 * @param str1 要比较的字符串1
* 要比较的字符串1 * @param str2 要比较的字符串2
* @param str2 * @param template 异常信息模板,被替换的部分用 {} 表示,如果模板为 null返回 "null"
* 要比较的字符串2 * @param params 参数值
* @param template
* 异常信息模板,被替换的部分用 {} 表示,如果模板为 null返回 "null"
* @param params
* 参数值
*/ */
public static void throwIfNotEqualIgnoreCase(CharSequence str1, CharSequence str2, String template, public static void throwIfNotEqualIgnoreCase(CharSequence str1, CharSequence str2, String template,
Object... params) { Object... params) {
@@ -189,12 +155,9 @@ public class ValidationUtils extends Validator {
/** /**
* 如果条件成立,抛出异常 * 如果条件成立,抛出异常
* *
* @param condition * @param condition 条件
* 条件 * @param template 异常信息模板,被替换的部分用 {} 表示,如果模板为 null返回 "null"
* @param template * @param params 参数值
* 异常信息模板,被替换的部分用 {} 表示,如果模板为 null返回 "null"
* @param params
* 参数值
*/ */
public static void throwIf(boolean condition, String template, Object... params) { public static void throwIf(boolean condition, String template, Object... params) {
throwIf(condition, StrUtil.format(template, params), EXCEPTION_TYPE); throwIf(condition, StrUtil.format(template, params), EXCEPTION_TYPE);
@@ -203,12 +166,9 @@ public class ValidationUtils extends Validator {
/** /**
* 如果条件成立,抛出异常 * 如果条件成立,抛出异常
* *
* @param conditionSupplier * @param conditionSupplier 条件
* 条件 * @param template 异常信息模板,被替换的部分用 {} 表示,如果模板为 null返回 "null"
* @param template * @param params 参数值
* 异常信息模板,被替换的部分用 {} 表示,如果模板为 null返回 "null"
* @param params
* 参数值
*/ */
public static void throwIf(BooleanSupplier conditionSupplier, String template, Object... params) { public static void throwIf(BooleanSupplier conditionSupplier, String template, Object... params) {
throwIf(conditionSupplier, StrUtil.format(template, params), EXCEPTION_TYPE); throwIf(conditionSupplier, StrUtil.format(template, params), EXCEPTION_TYPE);

View File

@@ -38,12 +38,9 @@ public class Validator {
/** /**
* 如果为空,抛出异常 * 如果为空,抛出异常
* *
* @param obj * @param obj 被检测的对象
* 被检测的对象 * @param message 错误信息
* @param message * @param exceptionType 异常类型
* 错误信息
* @param exceptionType
* 异常类型
*/ */
protected static void throwIfNull(Object obj, String message, Class<? extends RuntimeException> exceptionType) { protected static void throwIfNull(Object obj, String message, Class<? extends RuntimeException> exceptionType) {
throwIf(null == obj, message, exceptionType); throwIf(null == obj, message, exceptionType);
@@ -52,12 +49,9 @@ public class Validator {
/** /**
* 如果不为空,抛出异常 * 如果不为空,抛出异常
* *
* @param obj * @param obj 被检测的对象
* 被检测的对象 * @param message 错误信息
* @param message * @param exceptionType 异常类型
* 错误信息
* @param exceptionType
* 异常类型
*/ */
protected static void throwIfNotNull(Object obj, String message, Class<? extends RuntimeException> exceptionType) { protected static void throwIfNotNull(Object obj, String message, Class<? extends RuntimeException> exceptionType) {
throwIf(null != obj, message, exceptionType); throwIf(null != obj, message, exceptionType);
@@ -66,12 +60,9 @@ public class Validator {
/** /**
* 如果为空,抛出异常 * 如果为空,抛出异常
* *
* @param obj * @param obj 被检测的对象
* 被检测的对象 * @param message 错误信息
* @param message * @param exceptionType 异常类型
* 错误信息
* @param exceptionType
* 异常类型
*/ */
protected static void throwIfEmpty(Object obj, String message, Class<? extends RuntimeException> exceptionType) { protected static void throwIfEmpty(Object obj, String message, Class<? extends RuntimeException> exceptionType) {
throwIf(ObjectUtil.isEmpty(obj), message, exceptionType); throwIf(ObjectUtil.isEmpty(obj), message, exceptionType);
@@ -80,12 +71,9 @@ public class Validator {
/** /**
* 如果不为空,抛出异常 * 如果不为空,抛出异常
* *
* @param obj * @param obj 被检测的对象
* 被检测的对象 * @param message 错误信息
* @param message * @param exceptionType 异常类型
* 错误信息
* @param exceptionType
* 异常类型
*/ */
protected static void throwIfNotEmpty(Object obj, String message, Class<? extends RuntimeException> exceptionType) { protected static void throwIfNotEmpty(Object obj, String message, Class<? extends RuntimeException> exceptionType) {
throwIf(ObjectUtil.isNotEmpty(obj), message, exceptionType); throwIf(ObjectUtil.isNotEmpty(obj), message, exceptionType);
@@ -94,12 +82,9 @@ public class Validator {
/** /**
* 如果为空,抛出异常 * 如果为空,抛出异常
* *
* @param str * @param str 被检测的字符串
* 被检测的字符串 * @param message 错误信息
* @param message * @param exceptionType 异常类型
* 错误信息
* @param exceptionType
* 异常类型
*/ */
protected static void throwIfBlank(CharSequence str, String message, protected static void throwIfBlank(CharSequence str, String message,
Class<? extends RuntimeException> exceptionType) { Class<? extends RuntimeException> exceptionType) {
@@ -109,12 +94,9 @@ public class Validator {
/** /**
* 如果不为空,抛出异常 * 如果不为空,抛出异常
* *
* @param str * @param str 被检测的字符串
* 被检测的字符串 * @param message 错误信息
* @param message * @param exceptionType 异常类型
* 错误信息
* @param exceptionType
* 异常类型
*/ */
protected static void throwIfNotBlank(CharSequence str, String message, protected static void throwIfNotBlank(CharSequence str, String message,
Class<? extends RuntimeException> exceptionType) { Class<? extends RuntimeException> exceptionType) {
@@ -124,14 +106,10 @@ public class Validator {
/** /**
* 如果相同,抛出异常 * 如果相同,抛出异常
* *
* @param obj1 * @param obj1 要比较的对象1
* 要比较的对象1 * @param obj2 要比较的对象2
* @param obj2 * @param message 错误信息
* 要比较的对象2 * @param exceptionType 异常类型
* @param message
* 错误信息
* @param exceptionType
* 异常类型
*/ */
protected static void throwIfEqual(Object obj1, Object obj2, String message, protected static void throwIfEqual(Object obj1, Object obj2, String message,
Class<? extends RuntimeException> exceptionType) { Class<? extends RuntimeException> exceptionType) {
@@ -141,14 +119,10 @@ public class Validator {
/** /**
* 如果不相同,抛出异常 * 如果不相同,抛出异常
* *
* @param obj1 * @param obj1 要比较的对象1
* 要比较的对象1 * @param obj2 要比较的对象2
* @param obj2 * @param message 错误信息
* 要比较的对象2 * @param exceptionType 异常类型
* @param message
* 错误信息
* @param exceptionType
* 异常类型
*/ */
protected static void throwIfNotEqual(Object obj1, Object obj2, String message, protected static void throwIfNotEqual(Object obj1, Object obj2, String message,
Class<? extends RuntimeException> exceptionType) { Class<? extends RuntimeException> exceptionType) {
@@ -158,14 +132,10 @@ public class Validator {
/** /**
* 如果相同,抛出异常(不区分大小写) * 如果相同,抛出异常(不区分大小写)
* *
* @param str1 * @param str1 要比较的字符串1
* 要比较的字符串1 * @param str2 要比较的字符串2
* @param str2 * @param message 错误信息
* 要比较的字符串2 * @param exceptionType 异常类型
* @param message
* 错误信息
* @param exceptionType
* 异常类型
*/ */
protected static void throwIfEqualIgnoreCase(CharSequence str1, CharSequence str2, String message, protected static void throwIfEqualIgnoreCase(CharSequence str1, CharSequence str2, String message,
Class<? extends RuntimeException> exceptionType) { Class<? extends RuntimeException> exceptionType) {
@@ -175,14 +145,10 @@ public class Validator {
/** /**
* 如果不相同,抛出异常(不区分大小写) * 如果不相同,抛出异常(不区分大小写)
* *
* @param str1 * @param str1 要比较的字符串1
* 要比较的字符串1 * @param str2 要比较的字符串2
* @param str2 * @param message 错误信息
* 要比较的字符串2 * @param exceptionType 异常类型
* @param message
* 错误信息
* @param exceptionType
* 异常类型
*/ */
protected static void throwIfNotEqualIgnoreCase(CharSequence str1, CharSequence str2, String message, protected static void throwIfNotEqualIgnoreCase(CharSequence str1, CharSequence str2, String message,
Class<? extends RuntimeException> exceptionType) { Class<? extends RuntimeException> exceptionType) {
@@ -192,12 +158,9 @@ public class Validator {
/** /**
* 如果条件成立,抛出异常 * 如果条件成立,抛出异常
* *
* @param condition * @param condition 条件
* 条件 * @param message 错误信息
* @param message * @param exceptionType 异常类型
* 错误信息
* @param exceptionType
* 异常类型
*/ */
protected static void throwIf(boolean condition, String message, Class<? extends RuntimeException> exceptionType) { protected static void throwIf(boolean condition, String message, Class<? extends RuntimeException> exceptionType) {
if (condition) { if (condition) {
@@ -209,12 +172,9 @@ public class Validator {
/** /**
* 如果条件成立,抛出异常 * 如果条件成立,抛出异常
* *
* @param conditionSupplier * @param conditionSupplier 条件
* 条件 * @param message 错误信息
* @param message * @param exceptionType 异常类型
* 错误信息
* @param exceptionType
* 异常类型
*/ */
protected static void throwIf(BooleanSupplier conditionSupplier, String message, protected static void throwIf(BooleanSupplier conditionSupplier, String message,
Class<? extends RuntimeException> exceptionType) { Class<? extends RuntimeException> exceptionType) {

View File

@@ -44,14 +44,10 @@ public class ExcelUtils {
/** /**
* 导出 * 导出
* *
* @param list * @param list 导出数据集合
* 导出数据集合 * @param fileName 文件名
* @param fileName * @param clazz 导出数据类型
* 文件名 * @param response 响应对象
* @param clazz
* 导出数据类型
* @param response
* 响应对象
*/ */
public static <T> void export(List<T> list, String fileName, Class<T> clazz, HttpServletResponse response) { public static <T> void export(List<T> list, String fileName, Class<T> clazz, HttpServletResponse response) {
export(list, fileName, "Sheet1", clazz, response); export(list, fileName, "Sheet1", clazz, response);
@@ -60,16 +56,11 @@ public class ExcelUtils {
/** /**
* 导出 * 导出
* *
* @param list * @param list 导出数据集合
* 导出数据集合 * @param fileName 文件名
* @param fileName * @param sheetName 工作表名称
* 文件名 * @param clazz 导出数据类型
* @param sheetName * @param response 响应对象
* 工作表名称
* @param clazz
* 导出数据类型
* @param response
* 响应对象
*/ */
public static <T> void export(List<T> list, String fileName, String sheetName, Class<T> clazz, public static <T> void export(List<T> list, String fileName, String sheetName, Class<T> clazz,
HttpServletResponse response) { HttpServletResponse response) {

View File

@@ -35,11 +35,17 @@ import java.io.IOException;
@JacksonStdImpl @JacksonStdImpl
public class BigNumberSerializer extends NumberSerializer { public class BigNumberSerializer extends NumberSerializer {
/** 静态实例 */ /**
* 静态实例
*/
public static final BigNumberSerializer SERIALIZER_INSTANCE = new BigNumberSerializer(Number.class); public static final BigNumberSerializer SERIALIZER_INSTANCE = new BigNumberSerializer(Number.class);
/** JSNumber.MAX_SAFE_INTEGER */ /**
* JSNumber.MAX_SAFE_INTEGER
*/
private static final long MAX_SAFE_INTEGER = 9007199254740991L; private static final long MAX_SAFE_INTEGER = 9007199254740991L;
/** JSNumber.MIN_SAFE_INTEGER */ /**
* JSNumber.MIN_SAFE_INTEGER
*/
private static final long MIN_SAFE_INTEGER = -9007199254740991L; private static final long MIN_SAFE_INTEGER = -9007199254740991L;
public BigNumberSerializer(Class<? extends Number> rawType) { public BigNumberSerializer(Class<? extends Number> rawType) {

View File

@@ -51,14 +51,10 @@ public class MailUtils {
/** /**
* 发送文本邮件给单个人 * 发送文本邮件给单个人
* *
* @param subject * @param subject 主题
* 主题 * @param content 内容
* @param content * @param to 收件人
* 内容 * @throws MessagingException /
* @param to
* 收件人
* @throws MessagingException
* /
*/ */
public static void sendText(String to, String subject, String content) throws MessagingException { public static void sendText(String to, String subject, String content) throws MessagingException {
send(splitAddress(to), null, null, subject, content, false); send(splitAddress(to), null, null, subject, content, false);
@@ -67,14 +63,10 @@ public class MailUtils {
/** /**
* 发送 HTML 邮件给单个人 * 发送 HTML 邮件给单个人
* *
* @param subject * @param subject 主题
* 主题 * @param content 内容
* @param content * @param to 收件人
* 内容 * @throws MessagingException /
* @param to
* 收件人
* @throws MessagingException
* /
*/ */
public static void sendHtml(String to, String subject, String content) throws MessagingException { public static void sendHtml(String to, String subject, String content) throws MessagingException {
send(splitAddress(to), null, null, subject, content, true); send(splitAddress(to), null, null, subject, content, true);
@@ -83,16 +75,11 @@ public class MailUtils {
/** /**
* 发送 HTML 邮件给单个人 * 发送 HTML 邮件给单个人
* *
* @param subject * @param subject 主题
* 主题 * @param content 内容
* @param content * @param to 收件人
* 内容 * @param files 附件列表
* @param to * @throws MessagingException /
* 收件人
* @param files
* 附件列表
* @throws MessagingException
* /
*/ */
public static void sendHtml(String to, String subject, String content, File... files) throws MessagingException { public static void sendHtml(String to, String subject, String content, File... files) throws MessagingException {
send(splitAddress(to), null, null, subject, content, true, files); send(splitAddress(to), null, null, subject, content, true, files);
@@ -101,16 +88,11 @@ public class MailUtils {
/** /**
* 发送 HTML 邮件给多个人 * 发送 HTML 邮件给多个人
* *
* @param subject * @param subject 主题
* 主题 * @param content 内容
* @param content * @param tos 收件人列表
* 内容 * @param files 附件列表
* @param tos * @throws MessagingException /
* 收件人列表
* @param files
* 附件列表
* @throws MessagingException
* /
*/ */
public static void sendHtml(Collection<String> tos, String subject, String content, File... files) public static void sendHtml(Collection<String> tos, String subject, String content, File... files)
throws MessagingException { throws MessagingException {
@@ -120,18 +102,12 @@ public class MailUtils {
/** /**
* 发送 HTML 邮件给多个人 * 发送 HTML 邮件给多个人
* *
* @param subject * @param subject 主题
* 主题 * @param content 内容
* @param content * @param tos 收件人列表
* 内容 * @param ccs 抄送人列表
* @param tos * @param files 附件列表
* 收件人列表 * @throws MessagingException /
* @param ccs
* 抄送人列表
* @param files
* 附件列表
* @throws MessagingException
* /
*/ */
public static void sendHtml(Collection<String> tos, Collection<String> ccs, String subject, String content, public static void sendHtml(Collection<String> tos, Collection<String> ccs, String subject, String content,
File... files) throws MessagingException { File... files) throws MessagingException {
@@ -141,20 +117,13 @@ public class MailUtils {
/** /**
* 发送 HTML 邮件给多个人 * 发送 HTML 邮件给多个人
* *
* @param subject * @param subject 主题
* 主题 * @param content 内容
* @param content * @param tos 收件人列表
* 内容 * @param ccs 抄送人列表
* @param tos * @param bccs 密送人列表
* 收件人列表 * @param files 附件列表
* @param ccs * @throws MessagingException /
* 抄送人列表
* @param bccs
* 密送人列表
* @param files
* 附件列表
* @throws MessagingException
* /
*/ */
public static void sendHtml(Collection<String> tos, Collection<String> ccs, Collection<String> bccs, String subject, public static void sendHtml(Collection<String> tos, Collection<String> ccs, Collection<String> bccs, String subject,
String content, File... files) throws MessagingException { String content, File... files) throws MessagingException {
@@ -164,22 +133,14 @@ public class MailUtils {
/** /**
* 发送邮件给多个人 * 发送邮件给多个人
* *
* @param tos * @param tos 收件人列表
* 收件人列表 * @param ccs 抄送人列表
* @param ccs * @param bccs 密送人列表
* 抄送人列表 * @param subject 主题
* @param bccs * @param content 内容
* 密送人列表 * @param isHtml 是否是 HTML
* @param subject * @param files 附件列表
* 主题 * @throws MessagingException /
* @param content
* 内容
* @param isHtml
* 是否是 HTML
* @param files
* 附件列表
* @throws MessagingException
* /
*/ */
public static void send(Collection<String> tos, Collection<String> ccs, Collection<String> bccs, String subject, public static void send(Collection<String> tos, Collection<String> ccs, Collection<String> bccs, String subject,
String content, boolean isHtml, File... files) throws MessagingException { String content, boolean isHtml, File... files) throws MessagingException {
@@ -219,8 +180,7 @@ public class MailUtils {
/** /**
* 将多个联系人转为列表,分隔符为逗号或者分号 * 将多个联系人转为列表,分隔符为逗号或者分号
* *
* @param addresses * @param addresses 多个联系人如果为空返回null
* 多个联系人如果为空返回null
* @return 联系人列表 * @return 联系人列表
*/ */
private static List<String> splitAddress(String addresses) { private static List<String> splitAddress(String addresses) {