1.枚举类
import com.baomidou.mybatisplus.annotation.IEnum;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
import com.shinkeer.common.utils.StringUtils;import java.util.HashMap;
import java.util.Map;/*** 类型* 个人P001,团队P002,企业P003*/
@Getter
@AllArgsConstructor
public enum AssetOwnershipType {/*** 个人*/SELF(1,"个人"),/*** 团队*/TEAM(2,"团队"),;/*** 标记响应数据库的值**/@EnumValue/** 标记响应json值(序列化) **/@JsonValueprivate final Integer index;private final String name;private static Map<Integer, AssetOwnershipType> lookup = new HashMap<>();static {for (AssetOwnershipType type : values()) {lookup.put(type.getIndex(), type);}}private final String code;@Nullable@JsonCreator(mode = Mode.DELEGATING)public static AssetOwnershipTypeof(Integer index) {return map.get(index);}
}
2.查询直接使用枚举类型AssetOwnershipType 作为参数,枚举使用:
简单说明:
1.对比得使用 ==
2.使用包路径 如上图 后面的@路径@xx 就是枚举里面的值