mirror of
https://github.com/ZSCNetSupportDept/WechatTicketSystem.git
synced 2025-10-30 01:46:18 +08:00
new operator entity
This commit is contained in:
@@ -1,106 +1,56 @@
|
||||
package love.sola.netsupport.enums;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import static love.sola.netsupport.config.Lang.lang;
|
||||
|
||||
/**
|
||||
* ***********************************************
|
||||
* Created by Sola on 2015/11/30.
|
||||
* Don't modify this source without my agreement
|
||||
* ***********************************************
|
||||
*/
|
||||
public enum Block {
|
||||
public class Block {
|
||||
|
||||
@SerializedName("10")
|
||||
QT_18(10),
|
||||
@SerializedName("11")
|
||||
QT_19(11),
|
||||
@SerializedName("12")
|
||||
QT_16(12),
|
||||
@SerializedName("13")
|
||||
QT_17(13),
|
||||
@SerializedName("20")
|
||||
BM_7(20),
|
||||
@SerializedName("21")
|
||||
BM_8(21),
|
||||
@SerializedName("22")
|
||||
BM_9(22),
|
||||
@SerializedName("23")
|
||||
BM_10(23),
|
||||
@SerializedName("24")
|
||||
BM_11(24),
|
||||
@SerializedName("30")
|
||||
DM_12(30),
|
||||
@SerializedName("31")
|
||||
DM_13(31),
|
||||
@SerializedName("32")
|
||||
DM_14(32),
|
||||
@SerializedName("33")
|
||||
DM_15(33),
|
||||
@SerializedName("40")
|
||||
XH_A(40),
|
||||
@SerializedName("41")
|
||||
XH_B(41),
|
||||
@SerializedName("42")
|
||||
XH_C(42),
|
||||
@SerializedName("43")
|
||||
XH_D(43),
|
||||
@SerializedName("50")
|
||||
FX_1(50),
|
||||
@SerializedName("51")
|
||||
FX_2(51),
|
||||
@SerializedName("52")
|
||||
FX_3(52),
|
||||
@SerializedName("53")
|
||||
FX_4(53),
|
||||
@SerializedName("54")
|
||||
FX_5(54),
|
||||
@SerializedName("55")
|
||||
FX_6(55),
|
||||
@SerializedName("60")
|
||||
DM_20(60),
|
||||
@SerializedName("61")
|
||||
DM_21(61),
|
||||
;
|
||||
public static final int QT_18 = 10;
|
||||
public static final int QT_19 = 11;
|
||||
public static final int QT_16 = 12;
|
||||
public static final int QT_17 = 13;
|
||||
public static final int BM_7 = 20;
|
||||
public static final int BM_8 = 21;
|
||||
public static final int BM_9 = 22;
|
||||
public static final int BM_10 = 23;
|
||||
public static final int BM_11 = 24;
|
||||
public static final int DM_12 = 30;
|
||||
public static final int DM_13 = 31;
|
||||
public static final int DM_14 = 32;
|
||||
public static final int DM_15 = 33;
|
||||
public static final int XH_A = 40;
|
||||
public static final int XH_B = 41;
|
||||
public static final int XH_C = 42;
|
||||
public static final int XH_D = 43;
|
||||
public static final int FX_1 = 50;
|
||||
public static final int FX_2 = 51;
|
||||
public static final int FX_3 = 52;
|
||||
public static final int FX_4 = 53;
|
||||
public static final int FX_5 = 54;
|
||||
public static final int FX_6 = 55;
|
||||
public static final int DM_20 = 60;
|
||||
public static final int DM_21 = 61;
|
||||
|
||||
private static final Map<String, Block> NAME_MAP = new HashMap<>();
|
||||
private static final Map<Integer, Block> ID_MAP = new HashMap<>();
|
||||
public static final Map<Integer, String> inverseMap = new HashMap<>();
|
||||
|
||||
static {
|
||||
for (Block type : values()) {
|
||||
if (type.name != null) {
|
||||
NAME_MAP.put(type.name.toLowerCase(), type);
|
||||
}
|
||||
if (type.id > 0) {
|
||||
ID_MAP.put(type.id, type);
|
||||
static{
|
||||
System.out.println("Loading Blocks...");
|
||||
for (Field field : Block.class.getDeclaredFields()) {
|
||||
if (field.getType().isAssignableFrom(Integer.TYPE)) {
|
||||
try {
|
||||
inverseMap.put((Integer) field.get(null), field.getName());
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public final String name;
|
||||
public final int id;
|
||||
|
||||
Block(int id) {
|
||||
this.name = lang("BLOCK_" + name());
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public static Block fromName(String name) {
|
||||
if (name == null) {
|
||||
return null;
|
||||
}
|
||||
return NAME_MAP.get(name.toLowerCase());
|
||||
}
|
||||
|
||||
public static Block fromId(int id) {
|
||||
return ID_MAP.get(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() { return name; }
|
||||
|
||||
}
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
package love.sola.netsupport.enums;
|
||||
|
||||
import javax.persistence.AttributeConverter;
|
||||
import javax.persistence.Converter;
|
||||
|
||||
@Converter
|
||||
public class BlockConverter implements AttributeConverter<Block, Integer> {
|
||||
|
||||
@Override
|
||||
public Integer convertToDatabaseColumn(Block attribute) {
|
||||
if (attribute == null) {
|
||||
return null;
|
||||
}
|
||||
return attribute.id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Block convertToEntityAttribute(Integer dbData) {
|
||||
if (dbData == null) {
|
||||
return null;
|
||||
}
|
||||
return Block.fromId(dbData);
|
||||
}
|
||||
|
||||
}
|
||||
33
src/main/java/love/sola/netsupport/enums/Status.java
Normal file
33
src/main/java/love/sola/netsupport/enums/Status.java
Normal file
@@ -0,0 +1,33 @@
|
||||
package love.sola.netsupport.enums;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* ***********************************************
|
||||
* Created by Sola on 2015/12/6.
|
||||
* Don't modify this source without my agreement
|
||||
* ***********************************************
|
||||
*/
|
||||
public class Status {
|
||||
|
||||
public static final int UNCHECKED = 0;
|
||||
public static final int UNSOLVED = 9;
|
||||
|
||||
public static final Map<Integer, String> inverseMap = new HashMap<>();
|
||||
|
||||
static{
|
||||
System.out.println("Loading Status...");
|
||||
for (Field field : Status.class.getDeclaredFields()) {
|
||||
if (field.getType().isAssignableFrom(Integer.TYPE)) {
|
||||
try {
|
||||
inverseMap.put((Integer) field.get(null), field.getName());
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user