• 具体的类中包括枚举类写法


    package com.sf.dangbao.core.entity;

    import com.baomidou.mybatisplus.annotation.TableField;
    import com.baomidou.mybatisplus.annotation.TableName;
    import io.swagger.annotations.ApiModel;
    import io.swagger.annotations.ApiModelProperty;
    import lombok.Data;
    import org.water.base.entity.AutoIdEntity;

    @TableName("customer")
    @Data
    @ApiModel
    public class Customer extends AutoIdEntity {

    /**
    * 客户编码
    */
    @ApiModelProperty(name = "客户编码")
    private String customerCode;

    /**
    * 客户名称
    */
    @ApiModelProperty(name = "客户名称")
    private String customerName;

    /**
    * 接口参数
    */
    @ApiModelProperty(name = "接口参数")
    private String customerKey;

    /**
    * 业务类型 0揽件 1揽件&派件 2派件
    */
    @ApiModelProperty(name = "业务类型 0揽件 1揽件&派件 2派件")
    private Integer businessType;

    /**
    * 任务来源 1-API导入 2-后台每日创建
    */
    @ApiModelProperty(name = "任务来源 1-API导入 2-后台每日创建")
    private Integer jobSource;

    /**
    * 客户状态 0- 禁用 1-启用
    */
    @ApiModelProperty(name = "客户状态 0- 禁用 1-启用")
    private Integer status;

    /**
    * 类型排序
    */
    @TableField(exist = false)
    private String typeDesc;

    /**
    * 城市
    */
    @TableField(exist = false)
    private String city;

    /**
    * 地址对应经纬度
    */
    @TableField(exist = false)
    private String lngLat;

    /**
    * 业务类型枚举
    */
    public enum BusinessType{
    //
    LAN(0,"揽件"),
    PAI_LAN(1,"派件&揽件"),
    PAI(2,"派件"),
    ;
    private int val;
    private String desc;
    BusinessType(int val,String desc){
    this.val = val;
    this.desc = desc;
    }

    public static BusinessType valueOf(int val) {
    for (BusinessType businessType : BusinessType.values()) {
    if (businessType.val == val) {
    return businessType;
    }
    }
    throw new IllegalArgumentException("参数错误,找不到业务类型:"+val);
    }

    public int getVal() {
    return val;
    }

    public void setVal(int val) {
    this.val = val;
    }

    public String getDesc() {
    return desc;
    }

    public void setDesc(String desc) {
    this.desc = desc;
    }
    }


    /**
    * 客户分级
    */
    public enum Type {
    //
    COUNTY(0, "区县"),
    TOWN(1, "乡镇"),
    VILLAGE(2, "村组");
    private int value;
    private String desc;

    Type(int value, String desc) {
    this.value = value;
    this.desc = desc;
    }

    public static Type valueOfDesc(String desc) {
    for (Type type : Type.values()) {
    if (type.desc.equals(desc)) {
    return type;
    }
    }
    throw new IllegalArgumentException("参数错误,找不到对应状态:" + desc);
    }

    public static Type valueOf(int value) {
    for (Type type : Type.values()) {
    if (type.value == value) {
    return type;
    }
    }
    throw new IllegalArgumentException("参数错误,找不到对应状态:" + value);
    }

    public int getValue() {
    return value;
    }

    public void setValue(int value) {
    this.value = value;
    }

    public String getDesc() {
    return desc;
    }

    public void setDesc(String desc) {
    this.desc = desc;
    }
    }

    /**
    * 任务来源
    */
    public enum JobSource{
    //
    BY_API(1,"API导入"),
    BY_DAY(2,"后台每日创建"),
    ;
    private int val;
    private String desc;

    JobSource(int val,String desc){
    this.val = val;
    this.desc = desc;
    }

    public static JobSource valueOf(int val) {
    for (JobSource jobSource : JobSource.values()) {
    if (jobSource.val == val) {
    return jobSource;
    }
    }
    throw new IllegalArgumentException("参数错误,找不到任务创建方式:"+val);
    }

    public int getVal() {
    return val;
    }

    public void setVal(int val) {
    this.val = val;
    }

    public String getDesc() {
    return desc;
    }

    public void setDesc(String desc) {
    this.desc = desc;
    }
    }

    /**
    * 客户状态
    */
    public enum CustomerStatus{
    //
    BAN(0),
    USING(1),
    ;
    private int val;
    CustomerStatus(int val){
    this.val = val;
    }

    public static CustomerStatus valueOf(int val) {
    for (CustomerStatus customerStatus : CustomerStatus.values()) {
    if (customerStatus.val == val) {
    return customerStatus;
    }
    }
    throw new IllegalArgumentException("参数错误,找不到客户状态:"+val);
    }

    public int getVal() {
    return val;
    }

    public void setVal(int val) {
    this.val = val;
    }
    }

    }
  • 相关阅读:
    REST论文原文
    Rest无状态的一点理解(转)
    Kafka入门
    C#中@的用法总结(转)
    反应器(Reactor)用于事件多路分离和分派的体系结构模式
    数据库的脏读、不可重复读、幻读
    面向对象执行过程内存分析
    基于oracle的sql优化
    深入理解Spring中bean的生命周期
    Spring 框架原理
  • 原文地址:https://www.cnblogs.com/pxzbky/p/11752730.html
Copyright © 2020-2023  润新知