Browse Source

🎉 优化wrapper逻辑

test
smallchill 5 years ago
parent
commit
770beb365b
  1. 4
      blade-auth/src/main/java/org/springblade/auth/handler/AppLoginInSuccessHandler.java
  2. 1
      blade-auth/src/main/java/org/springblade/auth/utils/TokenUtil.java
  3. 5
      blade-ops/blade-resource/src/main/java/org/springblade/resource/wrapper/OssWrapper.java
  4. 5
      blade-service/blade-system/src/main/java/org/springblade/system/wrapper/ApiScopeWrapper.java
  5. 5
      blade-service/blade-system/src/main/java/org/springblade/system/wrapper/DataScopeWrapper.java
  6. 4
      blade-service/blade-system/src/main/java/org/springblade/system/wrapper/DeptWrapper.java
  7. 4
      blade-service/blade-system/src/main/java/org/springblade/system/wrapper/DictWrapper.java
  8. 4
      blade-service/blade-system/src/main/java/org/springblade/system/wrapper/MenuWrapper.java
  9. 4
      blade-service/blade-system/src/main/java/org/springblade/system/wrapper/RoleWrapper.java
  10. 4
      blade-service/blade-user/src/main/java/org/springblade/system/user/wrapper/UserWrapper.java

4
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];

1
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];
}

5
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<Oss, OssVO> {
@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);

5
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<ApiScope, ApiScopeVO> {
@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;

5
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<DataScope, DataScopeVO>
@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;

4
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<Dept, DeptVO> {
@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 {

4
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<Dict, DictVO> {
@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 {

4
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<Menu, MenuVO> {
@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 {

4
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<Role, RoleVO> {
@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 {

4
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<User, UserVO> {
@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<String> roleName = SysCache.getRoleNames(user.getRoleId());
List<String> deptName = SysCache.getDeptNames(user.getDeptId());
userVO.setRoleName(Func.join(roleName));

Loading…
Cancel
Save