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

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;
}
}

}
posted @ 2019-10-28 15:42  猿码哥  阅读(1034)  评论(0编辑  收藏  举报