From 770beb365b298643061dd33d1e1a2529fcf7f543 Mon Sep 17 00:00:00 2001 From: smallchill Date: Tue, 5 Nov 2019 14:22:19 +0800 Subject: [PATCH] =?UTF-8?q?:tada:=20=E4=BC=98=E5=8C=96wrapper=E9=80=BB?= =?UTF-8?q?=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../springblade/auth/handler/AppLoginInSuccessHandler.java | 4 +++- .../src/main/java/org/springblade/auth/utils/TokenUtil.java | 1 - .../java/org/springblade/resource/wrapper/OssWrapper.java | 5 +++-- .../java/org/springblade/system/wrapper/ApiScopeWrapper.java | 5 +++-- .../org/springblade/system/wrapper/DataScopeWrapper.java | 5 +++-- .../java/org/springblade/system/wrapper/DeptWrapper.java | 4 +--- .../java/org/springblade/system/wrapper/DictWrapper.java | 4 ++-- .../java/org/springblade/system/wrapper/MenuWrapper.java | 4 ++-- .../java/org/springblade/system/wrapper/RoleWrapper.java | 4 ++-- .../org/springblade/system/user/wrapper/UserWrapper.java | 4 ++-- 10 files changed, 21 insertions(+), 19 deletions(-) diff --git a/blade-auth/src/main/java/org/springblade/auth/handler/AppLoginInSuccessHandler.java b/blade-auth/src/main/java/org/springblade/auth/handler/AppLoginInSuccessHandler.java index 4cc3aef5..15dd8ca1 100644 --- a/blade-auth/src/main/java/org/springblade/auth/handler/AppLoginInSuccessHandler.java +++ b/blade-auth/src/main/java/org/springblade/auth/handler/AppLoginInSuccessHandler.java @@ -57,7 +57,9 @@ public class AppLoginInSuccessHandler extends SavedRequestAwareAuthenticationSuc log.info("【AppLoginInSuccessHandler】 onAuthenticationSuccess authentication={}", authentication); String[] tokens = TokenUtil.extractAndDecodeHeader(); - assert tokens.length == 2; + if (tokens.length != 2) { + throw new UnapprovedClientAuthenticationException("client对应的配置信息不存在"); + } String clientId = tokens[0]; String clientSecret = tokens[1]; diff --git a/blade-auth/src/main/java/org/springblade/auth/utils/TokenUtil.java b/blade-auth/src/main/java/org/springblade/auth/utils/TokenUtil.java index dfc8d798..50cbc000 100644 --- a/blade-auth/src/main/java/org/springblade/auth/utils/TokenUtil.java +++ b/blade-auth/src/main/java/org/springblade/auth/utils/TokenUtil.java @@ -92,7 +92,6 @@ public class TokenUtil { */ public static String getClientIdFromHeader() { String[] tokens = extractAndDecodeHeader(); - assert tokens.length == 2; return tokens[0]; } diff --git a/blade-ops/blade-resource/src/main/java/org/springblade/resource/wrapper/OssWrapper.java b/blade-ops/blade-resource/src/main/java/org/springblade/resource/wrapper/OssWrapper.java index 11089b79..fdd6c744 100644 --- a/blade-ops/blade-resource/src/main/java/org/springblade/resource/wrapper/OssWrapper.java +++ b/blade-ops/blade-resource/src/main/java/org/springblade/resource/wrapper/OssWrapper.java @@ -22,6 +22,8 @@ import org.springblade.resource.entity.Oss; import org.springblade.resource.entity.OssVO; import org.springblade.system.cache.DictCache; +import java.util.Objects; + /** * 包装类,返回视图层所需的字段 * @@ -36,8 +38,7 @@ public class OssWrapper extends BaseEntityWrapper { @Override public OssVO entityVO(Oss oss) { - OssVO ossVO = BeanUtil.copy(oss, OssVO.class); - assert ossVO != null; + OssVO ossVO = Objects.requireNonNull(BeanUtil.copy(oss, OssVO.class)); String categoryName = DictCache.getValue("oss", oss.getCategory()); String statusName = DictCache.getValue("yes_no", oss.getStatus()); ossVO.setCategoryName(categoryName); diff --git a/blade-service/blade-system/src/main/java/org/springblade/system/wrapper/ApiScopeWrapper.java b/blade-service/blade-system/src/main/java/org/springblade/system/wrapper/ApiScopeWrapper.java index 6b4e5524..b8d8672a 100644 --- a/blade-service/blade-system/src/main/java/org/springblade/system/wrapper/ApiScopeWrapper.java +++ b/blade-service/blade-system/src/main/java/org/springblade/system/wrapper/ApiScopeWrapper.java @@ -22,6 +22,8 @@ import org.springblade.system.cache.DictCache; import org.springblade.system.entity.ApiScope; import org.springblade.system.vo.ApiScopeVO; +import java.util.Objects; + /** * 包装类,返回视图层所需的字段 @@ -36,8 +38,7 @@ public class ApiScopeWrapper extends BaseEntityWrapper { @Override public ApiScopeVO entityVO(ApiScope dataScope) { - ApiScopeVO apiScopeVO = BeanUtil.copy(dataScope, ApiScopeVO.class); - assert apiScopeVO != null; + ApiScopeVO apiScopeVO = Objects.requireNonNull(BeanUtil.copy(dataScope, ApiScopeVO.class)); String scopeTypeName = DictCache.getValue("api_scope_type", dataScope.getScopeType()); apiScopeVO.setScopeTypeName(scopeTypeName); return apiScopeVO; diff --git a/blade-service/blade-system/src/main/java/org/springblade/system/wrapper/DataScopeWrapper.java b/blade-service/blade-system/src/main/java/org/springblade/system/wrapper/DataScopeWrapper.java index abead6cf..68516353 100644 --- a/blade-service/blade-system/src/main/java/org/springblade/system/wrapper/DataScopeWrapper.java +++ b/blade-service/blade-system/src/main/java/org/springblade/system/wrapper/DataScopeWrapper.java @@ -22,6 +22,8 @@ import org.springblade.system.cache.DictCache; import org.springblade.system.entity.DataScope; import org.springblade.system.vo.DataScopeVO; +import java.util.Objects; + /** * 包装类,返回视图层所需的字段 @@ -36,8 +38,7 @@ public class DataScopeWrapper extends BaseEntityWrapper @Override public DataScopeVO entityVO(DataScope dataScope) { - DataScopeVO dataScopeVO = BeanUtil.copy(dataScope, DataScopeVO.class); - assert dataScopeVO != null; + DataScopeVO dataScopeVO = Objects.requireNonNull(BeanUtil.copy(dataScope, DataScopeVO.class)); String scopeTypeName = DictCache.getValue("data_scope_type", dataScope.getScopeType()); dataScopeVO.setScopeTypeName(scopeTypeName); return dataScopeVO; diff --git a/blade-service/blade-system/src/main/java/org/springblade/system/wrapper/DeptWrapper.java b/blade-service/blade-system/src/main/java/org/springblade/system/wrapper/DeptWrapper.java index 1765823e..7e70f44a 100644 --- a/blade-service/blade-system/src/main/java/org/springblade/system/wrapper/DeptWrapper.java +++ b/blade-service/blade-system/src/main/java/org/springblade/system/wrapper/DeptWrapper.java @@ -16,7 +16,6 @@ */ package org.springblade.system.wrapper; -import org.springblade.common.constant.CommonConstant; import org.springblade.core.mp.support.BaseEntityWrapper; import org.springblade.core.tool.constant.BladeConstant; import org.springblade.core.tool.node.ForestNodeMerger; @@ -45,8 +44,7 @@ public class DeptWrapper extends BaseEntityWrapper { @Override public DeptVO entityVO(Dept dept) { - DeptVO deptVO = BeanUtil.copy(dept, DeptVO.class); - assert deptVO != null; + DeptVO deptVO = Objects.requireNonNull(BeanUtil.copy(dept, DeptVO.class)); if (Func.equals(dept.getParentId(), BladeConstant.TOP_PARENT_ID)) { deptVO.setParentName(BladeConstant.TOP_PARENT_NAME); } else { diff --git a/blade-service/blade-system/src/main/java/org/springblade/system/wrapper/DictWrapper.java b/blade-service/blade-system/src/main/java/org/springblade/system/wrapper/DictWrapper.java index 5812565e..74aa7aab 100644 --- a/blade-service/blade-system/src/main/java/org/springblade/system/wrapper/DictWrapper.java +++ b/blade-service/blade-system/src/main/java/org/springblade/system/wrapper/DictWrapper.java @@ -27,6 +27,7 @@ import org.springblade.system.entity.Dict; import org.springblade.system.vo.DictVO; import java.util.List; +import java.util.Objects; import java.util.stream.Collectors; /** @@ -42,8 +43,7 @@ public class DictWrapper extends BaseEntityWrapper { @Override public DictVO entityVO(Dict dict) { - DictVO dictVO = BeanUtil.copy(dict, DictVO.class); - assert dictVO != null; + DictVO dictVO = Objects.requireNonNull(BeanUtil.copy(dict, DictVO.class)); if (Func.equals(dict.getParentId(), BladeConstant.TOP_PARENT_ID)) { dictVO.setParentName(BladeConstant.TOP_PARENT_NAME); } else { diff --git a/blade-service/blade-system/src/main/java/org/springblade/system/wrapper/MenuWrapper.java b/blade-service/blade-system/src/main/java/org/springblade/system/wrapper/MenuWrapper.java index 7354e68d..aef00652 100644 --- a/blade-service/blade-system/src/main/java/org/springblade/system/wrapper/MenuWrapper.java +++ b/blade-service/blade-system/src/main/java/org/springblade/system/wrapper/MenuWrapper.java @@ -27,6 +27,7 @@ import org.springblade.system.entity.Menu; import org.springblade.system.vo.MenuVO; import java.util.List; +import java.util.Objects; import java.util.stream.Collectors; /** @@ -42,8 +43,7 @@ public class MenuWrapper extends BaseEntityWrapper { @Override public MenuVO entityVO(Menu menu) { - MenuVO menuVO = BeanUtil.copy(menu, MenuVO.class); - assert menuVO != null; + MenuVO menuVO = Objects.requireNonNull(BeanUtil.copy(menu, MenuVO.class)); if (Func.equals(menu.getParentId(), BladeConstant.TOP_PARENT_ID)) { menuVO.setParentName(BladeConstant.TOP_PARENT_NAME); } else { diff --git a/blade-service/blade-system/src/main/java/org/springblade/system/wrapper/RoleWrapper.java b/blade-service/blade-system/src/main/java/org/springblade/system/wrapper/RoleWrapper.java index bd2db919..b717d947 100644 --- a/blade-service/blade-system/src/main/java/org/springblade/system/wrapper/RoleWrapper.java +++ b/blade-service/blade-system/src/main/java/org/springblade/system/wrapper/RoleWrapper.java @@ -27,6 +27,7 @@ import org.springblade.system.entity.Role; import org.springblade.system.vo.RoleVO; import java.util.List; +import java.util.Objects; import java.util.stream.Collectors; /** @@ -42,8 +43,7 @@ public class RoleWrapper extends BaseEntityWrapper { @Override public RoleVO entityVO(Role role) { - RoleVO roleVO = BeanUtil.copy(role, RoleVO.class); - assert roleVO != null; + RoleVO roleVO = Objects.requireNonNull(BeanUtil.copy(role, RoleVO.class)); if (Func.equals(role.getParentId(), BladeConstant.TOP_PARENT_ID)) { roleVO.setParentName(BladeConstant.TOP_PARENT_NAME); } else { diff --git a/blade-service/blade-user/src/main/java/org/springblade/system/user/wrapper/UserWrapper.java b/blade-service/blade-user/src/main/java/org/springblade/system/user/wrapper/UserWrapper.java index 58adb382..dce9731d 100644 --- a/blade-service/blade-user/src/main/java/org/springblade/system/user/wrapper/UserWrapper.java +++ b/blade-service/blade-user/src/main/java/org/springblade/system/user/wrapper/UserWrapper.java @@ -25,6 +25,7 @@ import org.springblade.system.user.entity.User; import org.springblade.system.user.vo.UserVO; import java.util.List; +import java.util.Objects; /** * 包装类,返回视图层所需的字段 @@ -39,8 +40,7 @@ public class UserWrapper extends BaseEntityWrapper { @Override public UserVO entityVO(User user) { - UserVO userVO = BeanUtil.copy(user, UserVO.class); - assert userVO != null; + UserVO userVO = Objects.requireNonNull(BeanUtil.copy(user, UserVO.class)); List roleName = SysCache.getRoleNames(user.getRoleId()); List deptName = SysCache.getDeptNames(user.getDeptId()); userVO.setRoleName(Func.join(roleName));