@@ -0,0 +1,30 @@ | |||||
package com.ningdatech.kqapi.admin.model.enumerization; | |||||
import com.ningdatech.kqapi.common.enumeration.IEnum; | |||||
import lombok.AllArgsConstructor; | |||||
import lombok.Getter; | |||||
/** | |||||
* <p> | |||||
* HandleChannelEnum | |||||
* </p> | |||||
* | |||||
* @author WendyYang | |||||
* @since 10:09 2024/4/22 | |||||
*/ | |||||
@Getter | |||||
@AllArgsConstructor | |||||
public enum HandleChannelEnum implements IEnum<Integer, String, HandleChannelEnum> { | |||||
HANDLE_ON_WINDOW(1, "现场窗口申请"), | |||||
HANDLE_ON_NETWORK(2, "全程网办"); | |||||
private final Integer code; | |||||
private final String desc; | |||||
@Override | |||||
public HandleChannelEnum[] all() { | |||||
return values(); | |||||
} | |||||
} |
@@ -0,0 +1,42 @@ | |||||
package com.ningdatech.kqapi.common.enumeration; | |||||
import java.util.Arrays; | |||||
import java.util.Optional; | |||||
/** | |||||
* <p> | |||||
* IEnum-通用枚举类接口 | |||||
* </p> | |||||
* | |||||
* @author WendyYang | |||||
* @since 10:10 2024/4/22 | |||||
*/ | |||||
public interface IEnum<C, V, E extends Enum<E> & IEnum<C, V, E>> { | |||||
E[] all(); | |||||
C getCode(); | |||||
V getDesc(); | |||||
default boolean eq(C code) { | |||||
return getCode().equals(code); | |||||
} | |||||
default Optional<E> getByCode(C code) { | |||||
return Arrays.stream(all()) | |||||
.filter(w -> w.getCode().equals(code)) | |||||
.findFirst(); | |||||
} | |||||
default E getNoNull(C code) { | |||||
return Arrays.stream(all()) | |||||
.filter(w -> w.getCode().equals(code)).findFirst() | |||||
.orElseThrow(() -> new IllegalArgumentException("编码对应枚举值不存在")); | |||||
} | |||||
default V getDesc(C code) { | |||||
return getByCode(code).flatMap(w -> Optional.of(w.getDesc())).orElse(null); | |||||
} | |||||
} |
@@ -0,0 +1,30 @@ | |||||
package com.ningdatech.kqapi.common.enumeration; | |||||
import lombok.AllArgsConstructor; | |||||
import lombok.Getter; | |||||
/** | |||||
* <p> | |||||
* ImplSubjectNatureEnum | |||||
* </p> | |||||
* | |||||
* @author WendyYang | |||||
* @since 10:39 2024/4/22 | |||||
*/ | |||||
@Getter | |||||
@AllArgsConstructor | |||||
public enum ImplSubjectNatureEnum implements IEnum<Integer, String, ImplSubjectNatureEnum> { | |||||
STATUTORY_AUTHORITIES(1, "法定机关"), | |||||
THIRD_PARTY_INTERMEDIARIES(2, "第三方中介服务"); | |||||
private final Integer code; | |||||
private final String desc; | |||||
@Override | |||||
public ImplSubjectNatureEnum[] all() { | |||||
return values(); | |||||
} | |||||
} |