初始化
parent
d9c3fa997b
commit
4b04b23b77
21
pom.xml
21
pom.xml
|
@ -11,6 +11,8 @@
|
|||
|
||||
<artifactId>cloud-common-core</artifactId>
|
||||
|
||||
<version>3.6.3</version>
|
||||
|
||||
<description>
|
||||
cloud-common-core核心模块
|
||||
</description>
|
||||
|
@ -132,10 +134,10 @@
|
|||
</dependency>
|
||||
|
||||
<!-- Java Specification Requests 标准库-->
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>javax.annotation</groupId>-->
|
||||
<!-- <artifactId>jsr250-api</artifactId>-->
|
||||
<!-- </dependency>-->
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>javax.annotation</groupId>-->
|
||||
<!-- <artifactId>jsr250-api</artifactId>-->
|
||||
<!-- </dependency>-->
|
||||
|
||||
<dependency>
|
||||
<groupId>javax.annotation</groupId>
|
||||
|
@ -164,6 +166,17 @@
|
|||
<groupId>cn.hutool</groupId>
|
||||
<artifactId>hutool-all</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.dtflys.forest</groupId>
|
||||
<artifactId>forest-spring-boot3-starter</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.swagger.core.v3</groupId>
|
||||
<artifactId>swagger-annotations-jakarta</artifactId>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
|
|
|
@ -0,0 +1,58 @@
|
|||
package com.muyu.common.core.enums;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* @Author: wangxinyuan
|
||||
* @Date: 2024/8/5 下午7:47
|
||||
*/
|
||||
public enum SysPayType {
|
||||
|
||||
ALI_PAY("aliPay","支付宝"),
|
||||
WECHAT_PAY("wechatPay","微信支付"),
|
||||
JD_PAY("jdPay","京东支付"),
|
||||
;
|
||||
|
||||
private final String code;
|
||||
|
||||
private final String info;
|
||||
|
||||
SysPayType (String code, String info) {
|
||||
this.code = code;
|
||||
this.info = info;
|
||||
}
|
||||
|
||||
public String getCode(){
|
||||
return code;
|
||||
}
|
||||
|
||||
public String getInfo(){
|
||||
return info;
|
||||
}
|
||||
|
||||
/**
|
||||
* 鉴别Code是否合法
|
||||
* @param code 传code
|
||||
* @return 如果存在code则返回true,不存在则返回false
|
||||
*/
|
||||
public static boolean isCode(String code){
|
||||
return Arrays.stream(values())
|
||||
.map(SysPayType::getCode)
|
||||
.anyMatch(s -> s.equals(code));
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过code获取支付渠道
|
||||
* @param code code编码
|
||||
* @return 支付渠道
|
||||
*/
|
||||
public static String getInfoByCode(String code){
|
||||
return Arrays.stream(values())
|
||||
.filter(s -> s.getCode().equals(code))
|
||||
.findFirst()
|
||||
.map(SysPayType::getInfo)
|
||||
.orElseGet(() -> "-");
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,44 @@
|
|||
package com.muyu.common.core.enums;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* @Author: wangxinyuan
|
||||
* @Date: 2024/8/5 下午7:48
|
||||
*/
|
||||
public enum SystemYesNo {
|
||||
|
||||
YES("Y","是"),
|
||||
NO("N","否"),
|
||||
;
|
||||
|
||||
private final String code;
|
||||
|
||||
private final String info;
|
||||
|
||||
SystemYesNo (String code, String info) {
|
||||
this.code = code;
|
||||
this.info = info;
|
||||
}
|
||||
|
||||
public String getCode(){
|
||||
return code;
|
||||
}
|
||||
|
||||
public String getInfo(){
|
||||
return info;
|
||||
}
|
||||
|
||||
/**
|
||||
* 鉴别Code是否合法
|
||||
* @param code 传code
|
||||
* @return 如果存在code则返回true,不存在则返回false
|
||||
*/
|
||||
public static boolean isCode(String code){
|
||||
return Arrays.stream(values())
|
||||
.map(SystemYesNo::getCode)
|
||||
.anyMatch(s -> s.equals(code));
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
package com.muyu.common.core.validation.custom;
|
||||
|
||||
import jakarta.validation.Constraint;
|
||||
import jakarta.validation.Payload;
|
||||
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
||||
|
||||
/**
|
||||
* @Author: wangxinyuan
|
||||
* @Date: 2024/8/5 下午7:50
|
||||
*/
|
||||
@Target({ElementType.FIELD})
|
||||
@Retention(RUNTIME)
|
||||
@Documented
|
||||
@Constraint(validatedBy = {SystemPayTypeValidator.class})
|
||||
public @interface IsSystemPayType {
|
||||
|
||||
String message() default "数据字典:[系统是否] - 参数不合法";
|
||||
Class<?>[] groups() default { };
|
||||
Class<? extends Payload>[] payload() default { };
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
package com.muyu.common.core.validation.custom;
|
||||
|
||||
import jakarta.validation.Constraint;
|
||||
import jakarta.validation.Payload;
|
||||
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
||||
|
||||
/**
|
||||
* @Author: wangxinyuan
|
||||
* @Date: 2024/8/5 下午7:51
|
||||
*/
|
||||
@Target({ElementType.FIELD})
|
||||
@Retention(RUNTIME)
|
||||
@Documented
|
||||
@Constraint(validatedBy = {SystemYsNoValidator.class})
|
||||
public @interface IsSystemYesNo {
|
||||
|
||||
String message() default "数据字典:[系统是否] - 参数不合法";
|
||||
Class<?>[] groups() default { };
|
||||
Class<? extends Payload>[] payload() default { };
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
package com.muyu.common.core.validation.custom;
|
||||
|
||||
import com.muyu.common.core.enums.SysPayType;
|
||||
import jakarta.validation.ConstraintValidator;
|
||||
import jakarta.validation.ConstraintValidatorContext;
|
||||
|
||||
/**
|
||||
* @Author: wangxinyuan
|
||||
* @Date: 2024/8/5 下午7:51
|
||||
*/
|
||||
public class SystemPayTypeValidator implements ConstraintValidator<IsSystemPayType, String> {
|
||||
@Override
|
||||
public boolean isValid(String value, ConstraintValidatorContext constraintValidatorContext) {
|
||||
return SysPayType.isCode(value);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
package com.muyu.common.core.validation.custom;
|
||||
|
||||
import com.muyu.common.core.enums.SystemYesNo;
|
||||
import jakarta.validation.ConstraintValidator;
|
||||
import jakarta.validation.ConstraintValidatorContext;
|
||||
|
||||
/**
|
||||
* @Author: wangxinyuan
|
||||
* @Date: 2024/8/5 下午7:52
|
||||
*/
|
||||
public class SystemYsNoValidator implements ConstraintValidator<IsSystemYesNo, String> {
|
||||
@Override
|
||||
public boolean isValid(String value, ConstraintValidatorContext constraintValidatorContext) {
|
||||
return SystemYesNo.isCode(value);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue