package com.ruoyi.common.core.enums; import lombok.Getter; /** * @Description * @Author xiaochen * @Date 2023/6/8 16:42 */ public enum PurchaseStateEnum { /*购买状态 1在保 2停保 3复保 4脱保*/ UNDER_PROTECTION(1, "在保"), SUSPENSION_MAINTENANCE(2, "停保"), REINSURANCE(3, "复保"), DELISTING(4, "脱保"); @Getter private String desc; @Getter private int code; PurchaseStateEnum(int code, String desc) { this.code = code; this.desc = desc; } /** * 通过code获取枚举 * * @param code * @return */ public static PurchaseStateEnum fromCode(Integer code) { PurchaseStateEnum[] resultTypes = PurchaseStateEnum.values(); for (PurchaseStateEnum resultType : resultTypes) { if (code.equals(resultType.getCode())) { return resultType; } } return null; } }