- 后端:重构 oauth2 模块,方便后续 User 接入。

- 后端:重写 Admin 安全拦截器,实现类似 Shiro 的效果。
This commit is contained in:
YunaiV
2019-05-16 19:02:09 +08:00
parent 2b02b5b9e5
commit b14169a747
52 changed files with 698 additions and 481 deletions

View File

@@ -46,6 +46,7 @@ public enum CommonStatusEnum implements IntArrayValuable {
return this;
}
@Deprecated
public static boolean isValid(Integer status) {
if (status == null) {
return false;

View File

@@ -19,10 +19,12 @@ public interface MallConstants {
/**
* 用户类型 - 用户
*/
@Deprecated
Integer USER_TYPE_USER = 1;
/**
* 用户类型 - 管理员
*/
@Deprecated
Integer USER_TYPE_ADMIN = 2;
// HTTP Request Attr

View File

@@ -0,0 +1,54 @@
package cn.iocoder.common.framework.constant;
import cn.iocoder.common.framework.core.IntArrayValuable;
import java.util.Arrays;
/**
* 全局用户类型枚举
*/
public enum UserTypeEnum implements IntArrayValuable {
USER(1, "用户"),
ADMIN(2, "管理员");
public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(UserTypeEnum::getValue).toArray();
/**
* 类型
*/
private Integer value;
/**
* 类型名
*/
private String name;
UserTypeEnum(Integer value, String name) {
this.value = value;
this.name = name;
}
public Integer getValue() {
return value;
}
public UserTypeEnum setValue(Integer value) {
this.value = value;
return this;
}
public String getName() {
return name;
}
public UserTypeEnum setName(String name) {
this.name = name;
return this;
}
@Override
public int[] array() {
return ARRAYS;
}
}

View File

@@ -19,4 +19,11 @@ public class QueryWrapperX<T> extends QueryWrapper<T> {
return this;
}
public QueryWrapperX<T> eqIfPresent(String column, Object val) {
if (val != null) {
return (QueryWrapperX<T>) super.eq(column, val);
}
return this;
}
}

View File

@@ -1,5 +1,7 @@
package cn.iocoder.common.framework.util;
import org.springframework.util.CollectionUtils;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
@@ -30,4 +32,8 @@ public class CollectionUtil {
return from.stream().collect(Collectors.toMap(keyFunc, item -> item));
}
public static boolean containsAny(Collection<?> source, Collection<?> candidates) {
return CollectionUtils.containsAny(source, candidates);
}
}