From 5c3b31bb18ebb0e4b12d93e444b29ec58dce5180 Mon Sep 17 00:00:00 2001 From: ZhouXY108 Date: Sat, 25 Feb 2023 02:00:12 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E6=96=B9=E6=B3=95=E5=90=8D?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../xyz/zhouxy/plusone/jdbc/PlusoneJdbcDaoSupport.java | 10 +++++----- .../domain/model/account/AccountRepositoryImpl.java | 8 ++++---- .../system/domain/model/dict/DictRepositoryImpl.java | 2 +- .../system/domain/model/menu/MenuRepositoryImpl.java | 2 +- .../system/domain/model/role/RoleRepositoryImpl.java | 2 +- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/plusone-basic/plusone-basic-infrastructure/src/main/java/xyz/zhouxy/plusone/jdbc/PlusoneJdbcDaoSupport.java b/plusone-basic/plusone-basic-infrastructure/src/main/java/xyz/zhouxy/plusone/jdbc/PlusoneJdbcDaoSupport.java index ff90f2f..33e39e2 100644 --- a/plusone-basic/plusone-basic-infrastructure/src/main/java/xyz/zhouxy/plusone/jdbc/PlusoneJdbcDaoSupport.java +++ b/plusone-basic/plusone-basic-infrastructure/src/main/java/xyz/zhouxy/plusone/jdbc/PlusoneJdbcDaoSupport.java @@ -68,13 +68,13 @@ public abstract class PlusoneJdbcDaoSupport { return queryForStream(sql, new MapSqlParameterSource(paramName, value), elementType); } - protected final boolean queryExists(String sql, SqlParameterSource parameterSource) { - Boolean isExists = this.jdbc.queryForObject(sql, parameterSource, Boolean.TYPE); - return Boolean.TRUE.equals(isExists); + protected final boolean queryForBool(String sql, SqlParameterSource parameterSource) { + Boolean result = this.jdbc.queryForObject(sql, parameterSource, Boolean.TYPE); + return Boolean.TRUE.equals(result); } - protected final boolean queryExists(String sql, String paramName, Object value) { - return queryExists(sql, new MapSqlParameterSource(paramName, value)); + protected final boolean queryForBool(String sql, String paramName, Object value) { + return queryForBool(sql, new MapSqlParameterSource(paramName, value)); } protected final int update(String sql, SqlParameterSource parameterSource) { diff --git a/plusone-system/plusone-system-infrastructure/src/main/java/xyz/zhouxy/plusone/system/domain/model/account/AccountRepositoryImpl.java b/plusone-system/plusone-system-infrastructure/src/main/java/xyz/zhouxy/plusone/system/domain/model/account/AccountRepositoryImpl.java index c466dc0..a700c63 100644 --- a/plusone-system/plusone-system-infrastructure/src/main/java/xyz/zhouxy/plusone/system/domain/model/account/AccountRepositoryImpl.java +++ b/plusone-system/plusone-system-infrastructure/src/main/java/xyz/zhouxy/plusone/system/domain/model/account/AccountRepositoryImpl.java @@ -94,26 +94,26 @@ public class AccountRepositoryImpl extends JdbcRepositorySupport @Override public boolean exists(Long id) { - return queryExists("SELECT EXISTS (SELECT 1 FROM sys_account WHERE id = :id AND deleted = 0 LIMIT 1)", + return queryForBool("SELECT EXISTS (SELECT 1 FROM sys_account WHERE id = :id AND deleted = 0 LIMIT 1)", "id", id); } @Override public boolean existsUsername(Username username) { - return queryExists( + return queryForBool( "SELECT EXISTS (SELECT 1 FROM sys_account WHERE username = :username AND deleted = 0 LIMIT 1)", "username", username.value()); } @Override public boolean existsEmail(Email email) { - return queryExists("SELECT EXISTS (SELECT 1 FROM sys_account WHERE email = :email AND deleted = 0 LIMIT 1)", + return queryForBool("SELECT EXISTS (SELECT 1 FROM sys_account WHERE email = :email AND deleted = 0 LIMIT 1)", "email", email.value()); } @Override public boolean existsMobilePhone(MobilePhone mobilePhone) { - return queryExists( + return queryForBool( "SELECT EXISTS (SELECT 1 FROM sys_account WHERE mobile_phone = :mobile_phone AND deleted = 0 LIMIT 1)", "mobile_phone", mobilePhone.value()); } diff --git a/plusone-system/plusone-system-infrastructure/src/main/java/xyz/zhouxy/plusone/system/domain/model/dict/DictRepositoryImpl.java b/plusone-system/plusone-system-infrastructure/src/main/java/xyz/zhouxy/plusone/system/domain/model/dict/DictRepositoryImpl.java index 2bd38ee..482b039 100644 --- a/plusone-system/plusone-system-infrastructure/src/main/java/xyz/zhouxy/plusone/system/domain/model/dict/DictRepositoryImpl.java +++ b/plusone-system/plusone-system-infrastructure/src/main/java/xyz/zhouxy/plusone/system/domain/model/dict/DictRepositoryImpl.java @@ -83,7 +83,7 @@ public class DictRepositoryImpl extends JdbcRepositorySupport implem @Override public boolean exists(Long id) { - return queryExists("SELECT EXISTS (SELECT 1 FROM sys_dict_type WHERE id = :id AND deleted = 0 LIMIT 1)", + return queryForBool("SELECT EXISTS (SELECT 1 FROM sys_dict_type WHERE id = :id AND deleted = 0 LIMIT 1)", new MapSqlParameterSource("id", id)); } diff --git a/plusone-system/plusone-system-infrastructure/src/main/java/xyz/zhouxy/plusone/system/domain/model/menu/MenuRepositoryImpl.java b/plusone-system/plusone-system-infrastructure/src/main/java/xyz/zhouxy/plusone/system/domain/model/menu/MenuRepositoryImpl.java index f083e0a..d09428c 100644 --- a/plusone-system/plusone-system-infrastructure/src/main/java/xyz/zhouxy/plusone/system/domain/model/menu/MenuRepositoryImpl.java +++ b/plusone-system/plusone-system-infrastructure/src/main/java/xyz/zhouxy/plusone/system/domain/model/menu/MenuRepositoryImpl.java @@ -115,7 +115,7 @@ public class MenuRepositoryImpl extends JdbcRepositorySupport implem @Override public boolean exists(Long id) { - return queryExists("SELECT EXISTS (SELECT 1 FROM sys_menu WHERE id = :id AND deleted = 0 LIMIT 1)", + return queryForBool("SELECT EXISTS (SELECT 1 FROM sys_menu WHERE id = :id AND deleted = 0 LIMIT 1)", "id", id); } diff --git a/plusone-system/plusone-system-infrastructure/src/main/java/xyz/zhouxy/plusone/system/domain/model/role/RoleRepositoryImpl.java b/plusone-system/plusone-system-infrastructure/src/main/java/xyz/zhouxy/plusone/system/domain/model/role/RoleRepositoryImpl.java index a80206b..060718f 100644 --- a/plusone-system/plusone-system-infrastructure/src/main/java/xyz/zhouxy/plusone/system/domain/model/role/RoleRepositoryImpl.java +++ b/plusone-system/plusone-system-infrastructure/src/main/java/xyz/zhouxy/plusone/system/domain/model/role/RoleRepositoryImpl.java @@ -60,7 +60,7 @@ public class RoleRepositoryImpl extends JdbcRepositorySupport implem @Override public boolean exists(Long id) { - return queryExists("SELECT EXISTS (SELECT 1 FROM sys_role WHERE id = :id AND deleted = 0 LIMIT 1)", + return queryForBool("SELECT EXISTS (SELECT 1 FROM sys_role WHERE id = :id AND deleted = 0 LIMIT 1)", "id", id); }