Merge remote-tracking branch 'origin/master'
commit
86ed427d6a
|
@ -0,0 +1,38 @@
|
||||||
|
package com.muyu.common.core.enums;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: 胡杨
|
||||||
|
* @Name: SysApiState
|
||||||
|
* @Description: 接口调用字典
|
||||||
|
* @CreatedDate: 2024/8/20 下午7:56
|
||||||
|
* @FilePath: com.muyu.common.core.enums
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
public enum SysApiState {
|
||||||
|
OFF("off", "开启"),
|
||||||
|
ON("on", "停用");
|
||||||
|
|
||||||
|
private final String code;
|
||||||
|
private final String info;
|
||||||
|
|
||||||
|
SysApiState(String code, String info) {
|
||||||
|
this.code = code;
|
||||||
|
this.info = info;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 鉴别参数是否是启用状态
|
||||||
|
* @param code 需鉴别参数
|
||||||
|
* @return 如果存在返回结果turn,否则返回false
|
||||||
|
*/
|
||||||
|
public static boolean isCode(String code){
|
||||||
|
return Arrays.stream(values())
|
||||||
|
.map(SysApiState::getCode)
|
||||||
|
.anyMatch(c -> c.equals(code));
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,40 @@
|
||||||
|
package com.muyu.common.core.enums;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: 胡杨
|
||||||
|
* @Name: SysCheckState
|
||||||
|
* @Description: 审核状态字典
|
||||||
|
* @CreatedDate: 2024/8/20 下午8:01
|
||||||
|
* @FilePath: com.muyu.common.core.enums
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
public enum SysCheckState {
|
||||||
|
UN("un", "未审核"),
|
||||||
|
YES("yes", "审核通过"),
|
||||||
|
NO("no", "审核驳回");
|
||||||
|
|
||||||
|
private final String code;
|
||||||
|
private final String info;
|
||||||
|
|
||||||
|
SysCheckState(String code, String info) {
|
||||||
|
this.code = code;
|
||||||
|
this.info = info;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 鉴别参数是否是枚举的值
|
||||||
|
*
|
||||||
|
* @param code 需鉴别参数
|
||||||
|
* @return 如果存在返回结果turn, 否则返回false
|
||||||
|
*/
|
||||||
|
public static boolean isCode(String code) {
|
||||||
|
return Arrays.stream(values())
|
||||||
|
.map(SysCheckState::getCode)
|
||||||
|
.anyMatch(c -> c.equals(code));
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,41 @@
|
||||||
|
package com.muyu.common.core.enums;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: 胡杨
|
||||||
|
* @Name: SysDBType
|
||||||
|
* @Description: 数据源类型字典
|
||||||
|
* @CreatedDate: 2024/8/20 下午8:22
|
||||||
|
* @FilePath: com.muyu.common.core.enums
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
public enum SysDBType {
|
||||||
|
MYSQL("mysql", "Mysql数据库"),
|
||||||
|
REDIS("redis", "Redis数据库"),
|
||||||
|
ES("es", "Es数据库"),
|
||||||
|
OTHER("other", "其他");
|
||||||
|
|
||||||
|
private final String code;
|
||||||
|
private final String info;
|
||||||
|
|
||||||
|
SysDBType(String code, String info) {
|
||||||
|
this.code = code;
|
||||||
|
this.info = info;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 鉴别参数是否是枚举的值
|
||||||
|
*
|
||||||
|
* @param code 需鉴别参数
|
||||||
|
* @return 如果存在返回结果turn, 否则返回false
|
||||||
|
*/
|
||||||
|
public static boolean isCode(String code) {
|
||||||
|
return Arrays.stream(values())
|
||||||
|
.map(SysDBType::getCode)
|
||||||
|
.anyMatch(c -> c.equals(code));
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,6 +1,7 @@
|
||||||
package com.muyu.common.core.text;
|
package com.muyu.common.core.text;
|
||||||
|
|
||||||
import com.muyu.common.core.utils.StringUtils;
|
import com.muyu.common.core.utils.StringUtils;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.math.BigInteger;
|
import java.math.BigInteger;
|
||||||
|
@ -15,6 +16,7 @@ import java.util.Set;
|
||||||
*
|
*
|
||||||
* @author muyu
|
* @author muyu
|
||||||
*/
|
*/
|
||||||
|
@Slf4j
|
||||||
public class Convert {
|
public class Convert {
|
||||||
/**
|
/**
|
||||||
* 转换为字符串<br>
|
* 转换为字符串<br>
|
||||||
|
@ -687,7 +689,14 @@ public class Convert {
|
||||||
* @return 字符串
|
* @return 字符串
|
||||||
*/
|
*/
|
||||||
public static String str (Object obj, String charsetName) {
|
public static String str (Object obj, String charsetName) {
|
||||||
|
System.out.println(obj);
|
||||||
|
try{
|
||||||
return str(obj, Charset.forName(charsetName));
|
return str(obj, Charset.forName(charsetName));
|
||||||
|
}catch (Exception exception){
|
||||||
|
System.out.println("字符转换异常: [{"+obj+"}-{"+charsetName+"}] -> {"+exception.getMessage()+"}");
|
||||||
|
log.error("字符转换异常: [{}-{}] -> {}",obj,charsetName,exception.getMessage(),exception);
|
||||||
|
throw new RuntimeException(exception);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -699,7 +708,7 @@ public class Convert {
|
||||||
*
|
*
|
||||||
* @return 字符串
|
* @return 字符串
|
||||||
*/
|
*/
|
||||||
public static String str (Object obj, Charset charset) {
|
public static String str(Object obj, Charset charset) {
|
||||||
if (null == obj) {
|
if (null == obj) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
package com.muyu.common.core.validation;
|
||||||
|
|
||||||
|
|
||||||
|
import com.muyu.common.core.enums.*;
|
||||||
|
import com.muyu.common.core.validation.custom.*;
|
||||||
|
import jakarta.validation.ConstraintValidator;
|
||||||
|
import jakarta.validation.ConstraintValidatorContext;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: 胡杨
|
||||||
|
* @Name: IsSysApiState
|
||||||
|
* @Description: 接口调用字典判断
|
||||||
|
* @CreatedDate: 2024/8/20 下午8:07
|
||||||
|
* @FilePath: com.muyu.common.core.validation
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class IsSysApiStateValidator implements ConstraintValidator<IsSysApiState, String> {
|
||||||
|
@Override
|
||||||
|
public boolean isValid(String s, ConstraintValidatorContext constraintValidatorContext) {
|
||||||
|
return SysApiState.isCode(s);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,22 @@
|
||||||
|
package com.muyu.common.core.validation;
|
||||||
|
|
||||||
|
|
||||||
|
import com.muyu.common.core.enums.*;
|
||||||
|
import com.muyu.common.core.validation.custom.*;
|
||||||
|
import jakarta.validation.ConstraintValidator;
|
||||||
|
import jakarta.validation.ConstraintValidatorContext;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: 胡杨
|
||||||
|
* @Name: SysCheckState
|
||||||
|
* @Description: 审核状态字典判断
|
||||||
|
* @CreatedDate: 2024/8/20 下午8:09
|
||||||
|
* @FilePath: com.muyu.common.core.validation
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class IsSysCheckStateValidator implements ConstraintValidator<IsSysCheckState, String> {
|
||||||
|
@Override
|
||||||
|
public boolean isValid(String s, ConstraintValidatorContext constraintValidatorContext) {
|
||||||
|
return SysCheckState.isCode(s);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,22 @@
|
||||||
|
package com.muyu.common.core.validation;
|
||||||
|
|
||||||
|
|
||||||
|
import com.muyu.common.core.enums.*;
|
||||||
|
import com.muyu.common.core.validation.custom.*;
|
||||||
|
import jakarta.validation.ConstraintValidator;
|
||||||
|
import jakarta.validation.ConstraintValidatorContext;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: 胡杨
|
||||||
|
* @Name: SysDBType
|
||||||
|
* @Description: 数据源类型字典
|
||||||
|
* @CreatedDate: 2024/8/20 下午8:26
|
||||||
|
* @FilePath: com.muyu.common.core.validation
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class IsSysDBTypeValidator implements ConstraintValidator<IsSysDBType, String> {
|
||||||
|
@Override
|
||||||
|
public boolean isValid(String s, ConstraintValidatorContext constraintValidatorContext) {
|
||||||
|
return SysDBType.isCode(s);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,29 @@
|
||||||
|
package com.muyu.common.core.validation.custom;
|
||||||
|
|
||||||
|
import com.muyu.common.core.validation.*;
|
||||||
|
import jakarta.validation.Constraint;
|
||||||
|
import jakarta.validation.Payload;
|
||||||
|
|
||||||
|
import java.lang.annotation.*;
|
||||||
|
|
||||||
|
import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: 胡杨
|
||||||
|
* @Name: IsSysApiState
|
||||||
|
* @Description: 接口调用字典
|
||||||
|
* @CreatedDate: 2024/8/20 下午8:07
|
||||||
|
* @FilePath: com.muyu.common.core.validation.custom
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Target({ElementType.FIELD})
|
||||||
|
@Retention(RUNTIME)
|
||||||
|
@Documented
|
||||||
|
@Constraint(validatedBy = IsSysApiStateValidator.class)
|
||||||
|
public @interface IsSysApiState {
|
||||||
|
String message() default "数据字典:[接口调用字典] - 参数不合法";
|
||||||
|
|
||||||
|
Class<?>[] groups() default {};
|
||||||
|
|
||||||
|
Class<? extends Payload>[] payload() default {};
|
||||||
|
}
|
|
@ -0,0 +1,29 @@
|
||||||
|
package com.muyu.common.core.validation.custom;
|
||||||
|
|
||||||
|
import com.muyu.common.core.validation.*;
|
||||||
|
import jakarta.validation.Constraint;
|
||||||
|
import jakarta.validation.Payload;
|
||||||
|
|
||||||
|
import java.lang.annotation.*;
|
||||||
|
|
||||||
|
import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: 胡杨
|
||||||
|
* @Name: SysCheckState
|
||||||
|
* @Description: 审核状态字典
|
||||||
|
* @CreatedDate: 2024/8/20 下午8:09
|
||||||
|
* @FilePath: com.muyu.common.core.validation.custom
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Target({ElementType.FIELD})
|
||||||
|
@Retention(RUNTIME)
|
||||||
|
@Documented
|
||||||
|
@Constraint(validatedBy = IsSysCheckStateValidator.class)
|
||||||
|
public @interface IsSysCheckState {
|
||||||
|
String message() default "数据字典:[审核状态字典] - 参数不合法";
|
||||||
|
|
||||||
|
Class<?>[] groups() default {};
|
||||||
|
|
||||||
|
Class<? extends Payload>[] payload() default {};
|
||||||
|
}
|
|
@ -0,0 +1,29 @@
|
||||||
|
package com.muyu.common.core.validation.custom;
|
||||||
|
|
||||||
|
import com.muyu.common.core.validation.*;
|
||||||
|
import jakarta.validation.Constraint;
|
||||||
|
import jakarta.validation.Payload;
|
||||||
|
|
||||||
|
import java.lang.annotation.*;
|
||||||
|
|
||||||
|
import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: 胡杨
|
||||||
|
* @Name: SysDBType
|
||||||
|
* @Description: 数据源类型字典
|
||||||
|
* @CreatedDate: 2024/8/20 下午8:26
|
||||||
|
* @FilePath: com.muyu.common.core.validation.custom
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Target({ElementType.FIELD})
|
||||||
|
@Retention(RUNTIME)
|
||||||
|
@Documented
|
||||||
|
@Constraint(validatedBy = IsSysDBTypeValidator.class)
|
||||||
|
public @interface IsSysDBType {
|
||||||
|
String message() default "数据字典:[数据源类型字典] - 参数不合法";
|
||||||
|
|
||||||
|
Class<?>[] groups() default {};
|
||||||
|
|
||||||
|
Class<? extends Payload>[] payload() default {};
|
||||||
|
}
|
|
@ -1,2 +1,5 @@
|
||||||
com.muyu.common.core.utils.SpringUtils
|
com.muyu.common.core.utils.SpringUtils
|
||||||
com.muyu.common.core.feign.FeginConfig
|
com.muyu.common.core.feign.FeginConfig
|
||||||
|
com.muyu.common.core.validation.IsSysApiStateValidator
|
||||||
|
com.muyu.common.core.validation.IsSysCheckStateValidator
|
||||||
|
com.muyu.common.core.validation.IsSysDBTypeValidator
|
||||||
|
|
Loading…
Reference in New Issue