com.houkunlin.system.dict.starter.json.DictValid Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of system-dict-starter Show documentation
Show all versions of system-dict-starter Show documentation
系统数据字典自动翻译成字典文本。可集合系统数据库中存储的用户数据字典,也可使用枚举做系统数据字典,主要用在返回数据给前端时自动把字典值翻译成字典文本信息;
The system data dictionary is automatically translated into dictionary text.
The user data dictionary stored in the system database can be aggregated, and the enumeration can also be used as the system data dictionary.
It is mainly used to automatically translate dictionary values into dictionary text information when returning data to the front end.
The newest version!
package com.houkunlin.system.dict.starter.json;
import javax.validation.Constraint;
import javax.validation.Payload;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* 字典校验,如果找不到字典值文本,则校验失败。
* SpringBoot 2.x 的校验用法,主要是 javax.validation 包名问题,SpringBoot 3.x 改包名了
*
* @author HouKunLin
*/
@Constraint(validatedBy = {DictValidConstraintValidator.class})
@Target({ElementType.METHOD, ElementType.FIELD})
@Retention(RetentionPolicy.RUNTIME)
public @interface DictValid {
String message() default "字典参数错误";
Class>[] groups() default {};
Class extends Payload>[] payload() default {};
/**
* 数据字典的代码。
* 当此注解在系统字典枚举上时,该字段表示字典类型代码。
*
* @return 数据字典代码
* @see DictText#value()
*/
String value();
}