package com.iformall.domain.po;

import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

@Table(name = "wx_device")
public class WxDevice implements Serializable {
	private static final long serialVersionUID = 1L;

	@Id
    protected Long id;

    @Transient
    protected List<Long> ids;
    @Transient
    protected String sortColumns;

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getSortColumns() {
		return sortColumns;
	}

	public List<Long> getIds() {
		return ids;
	}

	public void setIds(List<Long> ids) {
		this.ids = ids;
	}

	/**租户id**/
	@io.swagger.annotations.ApiModelProperty(value="租户id",name="tenantId")
	private String tenantId;

	/**设备id**/
	@io.swagger.annotations.ApiModelProperty(value="设备id",name="deviceId")
	private String deviceId;

	/**设备类型**/
	@io.swagger.annotations.ApiModelProperty(value="设备类型",name="type")
	private Integer type;

	/**设备状态**/
	@io.swagger.annotations.ApiModelProperty(value="设备状态",name="status")
	private Integer status;

	/**版本号信息**/
	@io.swagger.annotations.ApiModelProperty(value="版本号信息",name="version")
	private String version;

    /**设备名**/
    @io.swagger.annotations.ApiModelProperty(value="设备名",name="name")
    private String name;

    /**设备位置**/
    @io.swagger.annotations.ApiModelProperty(value="设备位置",name="location")
    private String location;

	/**创建时间**/
	@io.swagger.annotations.ApiModelProperty(value="创建时间",name="createDate")
	private Date createDate;

	/**更新时间**/
	@io.swagger.annotations.ApiModelProperty(value="更新时间",name="updateDate")
	private Date updateDate;

	/**在线状态**/
	@io.swagger.annotations.ApiModelProperty(value="在线状态",name="onlineStatus")
	private Integer onlineStatus;

	/**第一次连线时间**/
	@io.swagger.annotations.ApiModelProperty(value="第一次连线时间",name="firstHbTime")
	private Date firstHbTime;

	/**最后一次在线时间**/
	@io.swagger.annotations.ApiModelProperty(value="最后一次在线时间",name="lastHbTime")
	private Date lastHbTime;

	/**需要执行的命令**/
	@io.swagger.annotations.ApiModelProperty(value="最后一次在线时间",name="hbCmd")
	private Integer hbCmd;

	/**设备名**/
	@io.swagger.annotations.ApiModelProperty(value="设备配置",name="config")
	private String config;

	public String  getTenantId() {
		return tenantId;
	}
	public void setTenantId(String _tenantId) {
		tenantId = _tenantId;
	}

	public String getDeviceId() {
		return deviceId;
	}

	public void setDeviceId(String deviceId) {
		this.deviceId = deviceId;
	}

	public Integer getType() {
		return type;
	}

	public void setType(Integer type) {
		this.type = type;
	}

	public Integer getStatus() {
		return status;
	}

	public void setStatus(Integer status) {
		this.status = status;
	}

	public String getVersion() {
		return version;
	}

	public void setVersion(String version) {
		this.version = version;
	}

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getLocation() {
        return location;
    }

    public void setLocation(String location) {
        this.location = location;
    }

    public Date getCreateDate() {
		return createDate;
	}

	public void setCreateDate(Date createDate) {
		this.createDate = createDate;
	}

	public Date getUpdateDate() {
		return updateDate;
	}

	public void setUpdateDate(Date updateDate) {
		this.updateDate = updateDate;
	}

	public Integer getOnlineStatus() {
		return onlineStatus;
	}

	public void setOnlineStatus(Integer onlineStatus) {
		this.onlineStatus = onlineStatus;
	}

	public Date getFirstHbTime() {
		return firstHbTime;
	}

	public void setFirstHbTime(Date firstHbTime) {
		this.firstHbTime = firstHbTime;
	}

	public Date getLastHbTime() {
		return lastHbTime;
	}

	public void setLastHbTime(Date lastHbTime) {
		this.lastHbTime = lastHbTime;
	}

	public Integer getHbCmd() {
		return hbCmd;
	}

	public void setHbCmd(Integer hbCmd) {
		this.hbCmd = hbCmd;
	}

	public String getConfig() {
		return config;
	}

	public void setConfig(String config) {
		this.config = config;
	}

	public static enum Field
	{
		Id_ASC("`id` ASC"),Id_DESC("`id` DESC")
			,TenantId_ASC("`tenant_id` ASC"),TenantId_DESC("`tenant_id` DESC")
			,DeviceId_ASC("`device_id` ASC"),DeviceId_DESC("`device_id` DESC")
			,Type_ASC("`type` ASC"),Type_DESC("`type` DESC")
			,Status_ASC("`status` ASC"),Status_DESC("`status` DESC")
			,Version_ASC("`version` ASC"),Version_DESC("`version` DESC")
			,CreateDate_ASC("`create_date` ASC"),CreateDate_DESC("`create_date` DESC")
			,UpdateDate_ASC("`update_date` ASC"),UpdateDate_DESC("`update_date` DESC")
			,LastHbTime_ASC("`last_hb_time` ASC"),LastHbTime_DESC("`last_hb_time` DESC")
			,FirstHbTime_ASC("`first_hb_time` ASC"),FirstHbTime_DESC("`first_hb_time` DESC")
			,OnlineStatus_ASC("`online_status` ASC"),OnlineStatus_DESC("`online_status` DESC")
			,HbCmd_ASC("`hb_cmd` ASC"),HbCmd_DESC("`hb_cmd` DESC")
	;
		private String value;
		Field(String value){
			this.value = value;
		}
		public String getValue() {
			return value;
		}
		public void setCol(String value) {
			this.value = value;
		}
		@Override
		public String toString() {
			return this.getValue();
		}
	}

	public void setSortColumns(WxDevice.Field... fields)
	{
		if (fields == null || fields.length == 0) {
			return;
		}
		for (int k = 0; k < fields.length; k++) {
			if (fields[k] == null) {
				return;
			}
		}
		StringBuilder sb = new StringBuilder(fields[0].toString());
		for (int k = 1; k < fields.length; k++) {
			sb.append(",");
			sb.append(fields[k].toString());
		}

		this.sortColumns = sb.toString();

	}

	public void setSortColumns(String sortColumns)
	{
		if (sortColumns == null || "".equals(sortColumns.trim())) {
			return;
		}
		if (sortColumns.contains(",")) {
			String[] cols = sortColumns.split(",");
			List<Field> fList = new ArrayList();
			for (int k = 0; k < cols.length; k++) {
				fList.add(Field.valueOf(cols[k]));
			}
			this.setSortColumns(fList.toArray(new Field[fList.size()]));
		} else {
			this.setSortColumns(Field.valueOf(sortColumns));
		}
	}
}
