From 0f393845a19432e7c965e811c96774694f4d2372 Mon Sep 17 00:00:00 2001 From: Charles7c Date: Sun, 18 Feb 2024 22:47:18 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E4=BC=98=E5=8C=96=E5=AD=97?= =?UTF-8?q?=E7=AC=A6=E4=B8=B2=E6=A8=A1=E6=9D=BF=E6=96=B9=E6=B3=95=20API=20?= =?UTF-8?q?=E4=BD=BF=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../continew/admin/system/service/impl/DeptServiceImpl.java | 6 +++--- .../charles7c/continew/admin/ContiNewAdminApplication.java | 4 ++-- .../continew/admin/webapi/auth/SocialAuthController.java | 2 +- .../continew/admin/webapi/common/CaptchaController.java | 6 +++--- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/continew-admin-system/src/main/java/top/charles7c/continew/admin/system/service/impl/DeptServiceImpl.java b/continew-admin-system/src/main/java/top/charles7c/continew/admin/system/service/impl/DeptServiceImpl.java index 1c8cda3d..10bc4364 100644 --- a/continew-admin-system/src/main/java/top/charles7c/continew/admin/system/service/impl/DeptServiceImpl.java +++ b/continew-admin-system/src/main/java/top/charles7c/continew/admin/system/service/impl/DeptServiceImpl.java @@ -133,7 +133,7 @@ public class DeptServiceImpl extends BaseServiceImpl listChildren(Long id) { - return baseMapper.lambdaQuery().apply(String.format("find_in_set(%s, ancestors)", id)).list(); + return baseMapper.lambdaQuery().apply("find_in_set(%s, ancestors)".formatted(id)).list(); } /** @@ -170,7 +170,7 @@ public class DeptServiceImpl extends BaseServiceImpl baseMapper.lambdaQuery().apply(String.format("find_in_set(%s, ancestors)", id)).count()) + .mapToLong(id -> baseMapper.lambdaQuery().apply("find_in_set(%s, ancestors)".formatted(id)).count()) .sum(); } diff --git a/continew-admin-webapi/src/main/java/top/charles7c/continew/admin/ContiNewAdminApplication.java b/continew-admin-webapi/src/main/java/top/charles7c/continew/admin/ContiNewAdminApplication.java index e23cacfb..7f5cb190 100644 --- a/continew-admin-webapi/src/main/java/top/charles7c/continew/admin/ContiNewAdminApplication.java +++ b/continew-admin-webapi/src/main/java/top/charles7c/continew/admin/ContiNewAdminApplication.java @@ -71,7 +71,7 @@ public class ContiNewAdminApplication implements ApplicationRunner { @SaIgnore @GetMapping("/") public String index() { - return String.format("%s service started successfully.", projectProperties.getName()); + return "%s service started successfully.".formatted(projectProperties.getName()); } @Override @@ -79,7 +79,7 @@ public class ContiNewAdminApplication implements ApplicationRunner { String hostAddress = InetAddress.getLocalHost().getHostAddress(); Integer port = serverProperties.getPort(); String contextPath = serverProperties.getServlet().getContextPath(); - String baseUrl = URLUtil.normalize(String.format("%s:%s%s", hostAddress, port, contextPath)); + String baseUrl = URLUtil.normalize("%s:%s%s".formatted(hostAddress, port, contextPath)); log.info("----------------------------------------------"); log.info("{} service started successfully.", projectProperties.getName()); log.info("API 地址:{}", baseUrl); diff --git a/continew-admin-webapi/src/main/java/top/charles7c/continew/admin/webapi/auth/SocialAuthController.java b/continew-admin-webapi/src/main/java/top/charles7c/continew/admin/webapi/auth/SocialAuthController.java index d5d77fea..0a7322d8 100644 --- a/continew-admin-webapi/src/main/java/top/charles7c/continew/admin/webapi/auth/SocialAuthController.java +++ b/continew-admin-webapi/src/main/java/top/charles7c/continew/admin/webapi/auth/SocialAuthController.java @@ -87,7 +87,7 @@ public class SocialAuthController { try { return authRequestFactory.get(source); } catch (Exception e) { - throw new BadRequestException(String.format("暂不支持 [%s] 平台账号登录", source)); + throw new BadRequestException("暂不支持 [%s] 平台账号登录".formatted(source)); } } } \ No newline at end of file diff --git a/continew-admin-webapi/src/main/java/top/charles7c/continew/admin/webapi/common/CaptchaController.java b/continew-admin-webapi/src/main/java/top/charles7c/continew/admin/webapi/common/CaptchaController.java index 5f54d7b0..b44dc0d5 100644 --- a/continew-admin-webapi/src/main/java/top/charles7c/continew/admin/webapi/common/CaptchaController.java +++ b/continew-admin-webapi/src/main/java/top/charles7c/continew/admin/webapi/common/CaptchaController.java @@ -121,12 +121,12 @@ public class CaptchaController { String content = TemplateUtils.render(captchaMail.getTemplatePath(), Dict.create() .set("captcha", captcha) .set("expiration", expirationInMinutes)); - MailUtils.sendHtml(email, String.format("【%s】邮箱验证码", projectProperties.getName()), content); + MailUtils.sendHtml(email, "【%s】邮箱验证码".formatted(projectProperties.getName()), content); // 保存验证码 String captchaKey = captchaKeyPrefix + email; RedisUtils.set(captchaKey, captcha, Duration.ofMinutes(expirationInMinutes)); RedisUtils.set(limitCaptchaKey, captcha, Duration.ofSeconds(captchaMail.getLimitInSeconds())); - return R.ok(String.format("发送成功,验证码有效期 %s 分钟", expirationInMinutes)); + return R.ok("发送成功,验证码有效期 %s 分钟".formatted(expirationInMinutes)); } @Operation(summary = "获取短信验证码", description = "发送验证码到指定手机号") @@ -173,6 +173,6 @@ public class CaptchaController { // 保存验证码 String captchaKey = captchaKeyPrefix + phone; RedisUtils.set(captchaKey, captcha, Duration.ofMinutes(expirationInMinutes)); - return R.ok(String.format("发送成功,验证码有效期 %s 分钟", expirationInMinutes)); + return R.ok("发送成功,验证码有效期 %s 分钟".formatted(expirationInMinutes)); } }