Skip to content

Commit

Permalink
style: 优化代码格式
Browse files Browse the repository at this point in the history
  • Loading branch information
Charles7c committed Dec 1, 2023
1 parent ed961db commit ce27ba8
Show file tree
Hide file tree
Showing 32 changed files with 409 additions and 677 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,39 +34,33 @@ public class JustAuthStateCacheRedisImpl implements AuthStateCache {
/**
* 存入缓存
*
* @param key
* key
* @param value
* 内容
* @param key key
* @param value 内容
*/
@Override
public void cache(String key, String value) {
// 参考:在 JustAuth 中,内置了一个基于 map 的 state 缓存器,默认缓存有效期为 3 分钟
RedisUtils.set(RedisUtils.formatKey(KEY_PREFIX, key), value,
Duration.ofMinutes(3));
Duration.ofMinutes(3));
}

/**
* 存入缓存
*
* @param key
* key
* @param value
* 内容
* @param timeout
* 缓存过期时间(毫秒)
* @param key key
* @param value 内容
* @param timeout 缓存过期时间(毫秒)
*/
@Override
public void cache(String key, String value, long timeout) {
RedisUtils.set(RedisUtils.formatKey(KEY_PREFIX, key), value,
Duration.ofMillis(timeout));
Duration.ofMillis(timeout));
}

/**
* 获取缓存内容
*
* @param key
* key
* @param key key
* @return 内容
*/
@Override
Expand All @@ -77,8 +71,7 @@ public String get(String key) {
/**
* 是否存在 key,如果对应 key 的 value 值已过期,也返回 false
*
* @param key
* key
* @param key key
* @return true:存在 key,并且 value 没过期;false:key 不存在或者已过期
*/
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ public StpInterface stpInterface() {
*/
@Configuration
@Import({SaTokenDaoConfiguration.Redis.class, SaTokenDaoConfiguration.Custom.class})
protected static class SaTokenDaoAutoConfiguration {}
protected static class SaTokenDaoAutoConfiguration {
}

/**
* 整合 JWT(简单模式)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,7 @@ public static boolean expire(final String key, final Duration duration) {
/**
* 查询缓存剩余过期时间
*
* @param key
* 键
* @param key 键
* @return 缓存剩余过期时间(单位:毫秒)
*/
public static long getTimeToLive(final String key) {
Expand All @@ -134,8 +133,7 @@ public static boolean hasKey(String key) {
/**
* 查询缓存列表
*
* @param keyPattern
* 键表达式
* @param keyPattern 键表达式
* @return 缓存列表
*/
public static Collection<String> keys(final String keyPattern) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public AsyncUncaughtExceptionHandler getAsyncUncaughtExceptionHandler() {
throwable.printStackTrace();
StringBuilder sb = new StringBuilder();
sb.append("Exception message: ").append(throwable.getMessage()).append(", Method name: ")
.append(method.getName());
.append(method.getName());
if (ArrayUtil.isNotEmpty(objects)) {
sb.append(", Parameter value: ").append(Arrays.toString(objects));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@
@EnableConfigurationProperties(ThreadPoolProperties.class)
public class ThreadPoolAutoConfiguration {

/** 核心(最小)线程数 = CPU 核心数 + 1 */
/**
* 核心(最小)线程数 = CPU 核心数 + 1
*/
private final int corePoolSize = Runtime.getRuntime().availableProcessors() + 1;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,8 @@ public class ExceptionUtils {
/**
* 打印线程异常信息
*
* @param runnable
* 线程执行内容
* @param throwable
* 异常
* @param runnable 线程执行内容
* @param throwable 异常
*/
public static void printException(Runnable runnable, Throwable throwable) {
if (null == throwable && runnable instanceof Future<?> future) {
Expand All @@ -66,10 +64,8 @@ public static void printException(Runnable runnable, Throwable throwable) {
/**
* 如果有异常,返回 null
*
* @param exSupplier
* 可能会出现异常的方法执行
* @param <T>
* /
* @param exSupplier 可能会出现异常的方法执行
* @param <T> /
* @return /
*/
public static <T> T exToNull(ExSupplier<T> exSupplier) {
Expand All @@ -79,12 +75,9 @@ public static <T> T exToNull(ExSupplier<T> exSupplier) {
/**
* 如果有异常,执行异常处理
*
* @param supplier
* 可能会出现异常的方法执行
* @param exConsumer
* 异常处理
* @param <T>
* /
* @param supplier 可能会出现异常的方法执行
* @param exConsumer 异常处理
* @param <T> /
* @return /
*/
public static <T> T exToNull(ExSupplier<T> supplier, Consumer<Exception> exConsumer) {
Expand All @@ -94,8 +87,7 @@ public static <T> T exToNull(ExSupplier<T> supplier, Consumer<Exception> exConsu
/**
* 如果有异常,返回空字符串
*
* @param exSupplier
* 可能会出现异常的方法执行
* @param exSupplier 可能会出现异常的方法执行
* @return /
*/
public static String exToBlank(ExSupplier<String> exSupplier) {
Expand All @@ -105,12 +97,9 @@ public static String exToBlank(ExSupplier<String> exSupplier) {
/**
* 如果有异常,返回默认值
*
* @param exSupplier
* 可能会出现异常的方法执行
* @param defaultValue
* 默认值
* @param <T>
* /
* @param exSupplier 可能会出现异常的方法执行
* @param defaultValue 默认值
* @param <T> /
* @return /
*/
public static <T> T exToDefault(ExSupplier<T> exSupplier, T defaultValue) {
Expand All @@ -120,14 +109,10 @@ public static <T> T exToDefault(ExSupplier<T> exSupplier, T defaultValue) {
/**
* 如果有异常,执行异常处理,返回默认值
*
* @param exSupplier
* 可能会出现异常的方法执行
* @param defaultValue
* 默认值
* @param exConsumer
* 异常处理
* @param <T>
* /
* @param exSupplier 可能会出现异常的方法执行
* @param defaultValue 默认值
* @param exConsumer 异常处理
* @param <T> /
* @return /
*/
public static <T> T exToDefault(ExSupplier<T> exSupplier, T defaultValue, Consumer<Exception> exConsumer) {
Expand All @@ -144,16 +129,14 @@ public static <T> T exToDefault(ExSupplier<T> exSupplier, T defaultValue, Consum
/**
* 异常提供者
*
* @param <T>
* /
* @param <T> /
*/
public interface ExSupplier<T> {
/**
* 获取返回值
*
* @return /
* @throws Exception
* /
* @throws Exception /
*/
T get() throws Exception;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public class MyBatisPlusExtensionProperties {
/**
* Mapper 接口扫描包(配置时必须使用:mapper-package 键名)
* <p>
* e.g. com.example.**.mapper
* e.g. com.example.**.mapper
* </p>
*/
private String mapperPackage;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
/**
* 树结构字段
*
* @see cn.hutool.core.lang.tree.TreeNodeConfig
* @author Charles7c
* @see cn.hutool.core.lang.tree.TreeNodeConfig
* @since 1.0.0
*/
@Target(ElementType.TYPE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,11 @@
/**
* 控制器基类
*
* @param <S>
* 业务接口
* @param <L>
* 列表信息
* @param <D>
* 详情信息
* @param <Q>
* 查询条件
* @param <C>
* 创建或修改信息
* @param <S> 业务接口
* @param <L> 列表信息
* @param <D> 详情信息
* @param <Q> 查询条件
* @param <C> 创建或修改信息
* @author Charles7c
* @since 1.0.0
*/
Expand All @@ -62,10 +57,8 @@ public abstract class BaseController<S extends BaseService<L, D, Q, C>, L, D, Q,
/**
* 分页查询列表
*
* @param query
* 查询条件
* @param pageQuery
* 分页查询条件
* @param query 查询条件
* @param pageQuery 分页查询条件
* @return 分页信息
*/
@Operation(summary = "分页查询列表", description = "分页查询列表")
Expand All @@ -80,10 +73,8 @@ public R<PageDataResp<L>> page(Q query, @Validated PageQuery pageQuery) {
/**
* 查询树列表
*
* @param query
* 查询条件
* @param sortQuery
* 排序查询条件
* @param query 查询条件
* @param sortQuery 排序查询条件
* @return 树列表信息
*/
@Operation(summary = "查询树列表", description = "查询树列表")
Expand All @@ -98,10 +89,8 @@ public R<List<Tree<Long>>> tree(Q query, SortQuery sortQuery) {
/**
* 查询列表
*
* @param query
* 查询条件
* @param sortQuery
* 排序查询条件
* @param query 查询条件
* @param sortQuery 排序查询条件
* @return 列表信息
*/
@Operation(summary = "查询列表", description = "查询列表")
Expand All @@ -116,8 +105,7 @@ public R<List<L>> list(Q query, SortQuery sortQuery) {
/**
* 查看详情
*
* @param id
* ID
* @param id ID
* @return 详情信息
*/
@Operation(summary = "查看详情", description = "查看详情")
Expand All @@ -133,8 +121,7 @@ public R<D> get(@PathVariable Long id) {
/**
* 新增
*
* @param req
* 创建信息
* @param req 创建信息
* @return 自增 ID
*/
@Operation(summary = "新增数据", description = "新增数据")
Expand All @@ -149,10 +136,8 @@ public R<Long> add(@Validated(ValidateGroup.Crud.Add.class) @RequestBody C req)
/**
* 修改
*
* @param req
* 修改信息
* @param id
* ID
* @param req 修改信息
* @param id ID
* @return /
*/
@Operation(summary = "修改数据", description = "修改数据")
Expand All @@ -168,8 +153,7 @@ public R update(@Validated(ValidateGroup.Crud.Update.class) @RequestBody C req,
/**
* 删除
*
* @param ids
* ID 列表
* @param ids ID 列表
* @return /
*/
@Operation(summary = "删除数据", description = "删除数据")
Expand All @@ -185,12 +169,9 @@ public R delete(@PathVariable List<Long> ids) {
/**
* 导出
*
* @param query
* 查询条件
* @param sortQuery
* 排序查询条件
* @param response
* 响应对象
* @param query 查询条件
* @param sortQuery 排序查询条件
* @param response 响应对象
*/
@Operation(summary = "导出数据", description = "导出数据")
@GetMapping("/export")
Expand All @@ -202,8 +183,7 @@ public void export(Q query, SortQuery sortQuery, HttpServletResponse response) {
/**
* 根据 API 类型进行权限验证
*
* @param api
* API 类型
* @param api API 类型
*/
private void checkPermission(Api api) {
CrudRequestMapping crudRequestMapping = this.getClass().getDeclaredAnnotation(CrudRequestMapping.class);
Expand Down
Loading

0 comments on commit ce27ba8

Please sign in to comment.