新增订单模块
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
package com.starry.common.annotation;
|
||||
|
||||
import javax.validation.Constraint;
|
||||
import javax.validation.Payload;
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
import static java.lang.annotation.ElementType.*;
|
||||
import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
||||
|
||||
/**
|
||||
* 枚举参数校验注解
|
||||
*
|
||||
* @author admin
|
||||
*/
|
||||
@Target({METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER})
|
||||
@Retention(RUNTIME)
|
||||
@Documented
|
||||
@Constraint(validatedBy = {EnumValueValidator.class})
|
||||
public @interface EnumValue {
|
||||
|
||||
// 默认错误消息
|
||||
String message() default "必须为指定值";
|
||||
|
||||
String[] strValues() default {};
|
||||
|
||||
int[] intValues() default {};
|
||||
|
||||
// 分组
|
||||
Class<?>[] groups() default {};
|
||||
|
||||
// 负载
|
||||
Class<? extends Payload>[] payload() default {};
|
||||
|
||||
// 指定多个时使用
|
||||
@Target({FIELD, METHOD, PARAMETER, ANNOTATION_TYPE})
|
||||
@Retention(RUNTIME)
|
||||
@Documented
|
||||
@interface List {
|
||||
EnumValue[] value();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.starry.common.annotation;
|
||||
|
||||
import javax.validation.ConstraintValidator;
|
||||
import javax.validation.ConstraintValidatorContext;
|
||||
|
||||
/**
|
||||
* 枚举校验注解处理类
|
||||
*/
|
||||
public class EnumValueValidator implements ConstraintValidator<EnumValue, Object> {
|
||||
|
||||
private String[] strValues;
|
||||
private int[] intValues;
|
||||
|
||||
@Override
|
||||
public void initialize(EnumValue constraintAnnotation) {
|
||||
strValues = constraintAnnotation.strValues();
|
||||
intValues = constraintAnnotation.intValues();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid(Object value, ConstraintValidatorContext context) {
|
||||
if (value instanceof String) {
|
||||
for (String s : strValues) {
|
||||
if (s.equals(value)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} else if (value instanceof Integer) {
|
||||
for (int s : intValues) {
|
||||
if (s == (Integer) value) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -13,7 +13,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
* 获取当前线程变量中的 租户id 部门id 用户id、用户名称、Token等信息
|
||||
* @since 2023/3/6
|
||||
*/
|
||||
public class SecurityContextHolder {
|
||||
public class CustomSecurityContextHolder {
|
||||
|
||||
private static final TransmittableThreadLocal<Map<String, Object>> THREAD_LOCAL = new TransmittableThreadLocal<>();
|
||||
|
||||
@@ -47,8 +47,8 @@ public class SecurityContextHolder {
|
||||
}
|
||||
|
||||
|
||||
public static Long getTenantId() {
|
||||
return Convert.toLong(get(SecurityConstants.DETAILS_TENANT_ID), 9999L);
|
||||
public static String getTenantId() {
|
||||
return Convert.toStr(get(SecurityConstants.DETAILS_TENANT_ID), "9999");
|
||||
}
|
||||
|
||||
public static void setTenantId(String tenantId) {
|
||||
Reference in New Issue
Block a user