package com.jmfy.model; import org.springframework.data.annotation.Id; import org.springframework.data.mongodb.core.index.Indexed; import org.springframework.data.mongodb.core.mapping.Document; import org.springframework.data.mongodb.core.mapping.Field; /** * * @author Administrator * @date 2015/8/13 */ @Document(collection = "server_info") public class ServerInfo implements Comparable,Cloneable { @Id private int _id; @Field(value = "name") private String name; @Field(value = "ip") private String ip; @Field(value = "port") private String port; @Indexed @Field(value = "server_id") private String server_id; @Field(value = "channel") private String channel; @Field(value = "sub_channel") private String sub_channel; /** * -1 服务器准备中 * -2 未运营 * 0 已关闭 * 1 维护 * 2 流畅 * 3 拥挤 * 4 爆满 */ @Field(value = "state") private String status; @Field(value = "plat") private String plat; @Field(value = "is_new") private String is_new; @Field(value = "register_state") private String register_state; @Field(value = "coreName") private String coreName; @Field(value = "isWhite") private String isWhite; @Field(value = "server_version") private int server_version; /** * 没啥用,但是不能删,删除需要先去登陆服兼容一下 */ @Field(value = "open_type") private String open_type; /** * 没啥用,但是不能删,删除需要先去登陆服兼容一下 */ @Field(value = "open_time") private String open_time; public ServerInfo(int _id, String name) { this._id = _id; this.server_id = String.valueOf(_id); this.name = name; } public ServerInfo() { } public int get_id() { return _id; } public void set_id(int _id) { this._id = _id; } public String getName() { return name; } public void setName(String name) { this.name = name; } public String getIp() { return ip; } public void setIp(String ip) { this.ip = ip; } public String getPort() { return port; } public void setPort(String port) { this.port = port; } public String getServer_id() { return server_id; } public void setServer_id(String server_id) { this.server_id = server_id; } public int getServerId(){ return Integer.parseInt(server_id); } public String getChannel() { return channel; } public void setChannel(String channel) { this.channel = channel; } public String getSub_channel() { return sub_channel; } public void setSub_channel(String sub_channel) { this.sub_channel = sub_channel; } public String getStatus() { return status; } public int getStatusInt() { if (status == null){ status = "0"; } return Integer.parseInt(status); } public void setStatus(String status) { this.status = status; } public String getPlat() { return plat; } public void setPlat(String plat) { this.plat = plat; } public String getIs_new() { return is_new==null?"0":is_new; } public void setIs_new(String is_new) { this.is_new = is_new; } public String getRegister_state() { return register_state==null?"1":register_state; } public void setRegister_state(String register_state) { this.register_state = register_state; } public String getCoreName() { return coreName; } public void setCoreName(String coreName) { this.coreName = coreName; } public String getIsWhite() { return isWhite; } public void setIsWhite(String isWhite) { this.isWhite = isWhite; } public int getServer_version() { return server_version; } public void setServer_version(int server_version) { this.server_version = server_version; } public String getOpen_type() { return open_type; } public void setOpen_type(String open_type) { this.open_type = open_type; } public String getOpen_time() { return open_time; } public void setOpen_time(String open_time) { this.open_time = open_time; } @Override public String toString() { return "ServerInfo{" + "_id=" + _id + ", name='" + name + '\'' + ", ip='" + ip + '\'' + ", port='" + port + '\'' + ", server_id='" + server_id + '\'' + ", channel='" + channel + '\'' + ", sub_channel='" + sub_channel + '\'' + ", status='" + status + '\'' + ", plat='" + plat + '\'' + ", is_new='" + is_new + '\'' + ", register_state='" + register_state + '\'' + ", coreName='" + coreName + '\'' + ", isWhite='" + isWhite + '\'' + ", server_version=" + server_version + ", open_type='" + open_type + '\'' + ", open_time='" + open_time + '\'' + '}'; } @Override public int compareTo(Object o) { ServerInfo info = (ServerInfo) o; int id1 = Integer.parseInt(info.getServer_id()); int id2 = Integer.parseInt(this.getServer_id()); if (id1 == id2) { return 0; } else if (id2 > id1) { return 1; } else { return -1; } } @Override public ServerInfo clone() throws CloneNotSupportedException { return (ServerInfo) super.clone(); } }