package com.iformall.domain.po;

import javax.persistence.*;
import javax.persistence.Transient;
import java.util.List;
import javax.persistence.Id;
import java.io.Serializable;

@Table(name = "wx_user_channel")
public class WxUserChannel 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;
	}
	
	
	
	/***/
	@io.swagger.annotations.ApiModelProperty(value="",name="channelName")
	private String channelName;
	/***/
	@io.swagger.annotations.ApiModelProperty(value="",name="sceneAddress")
	private String sceneAddress;
	/***/
	@io.swagger.annotations.ApiModelProperty(value="",name="description")
	private String description;
	public String  getChannelName() {
		return channelName;
	}
	public void setChannelName(String _channelName) {
		channelName = _channelName;
	}
	public String  getSceneAddress() {
		return sceneAddress;
	}
	public void setSceneAddress(String _sceneAddress) {
		sceneAddress = _sceneAddress;
	}
	public String  getDescription() {
		return description;
	}
	public void setDescription(String _description) {
		description = _description;
	}

	@Transient
	protected long count;

	public long getCount() {
		return count;
	}

	public void setCount(long count) {
		this.count = count;
	}

	public static enum Field
	{
		Id_ASC("`id` ASC"),Id_DESC("`id` DESC")
			,ChannelName_ASC("`channelName` ASC"),ChannelName_DESC("`channelName` DESC")
			,SceneAddress_ASC("`sceneAddress` ASC"),SceneAddress_DESC("`sceneAddress` DESC")
			,Description_ASC("`description` ASC"),Description_DESC("`description` 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(WxUserChannel.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());
		}
		 
	}
	
	public void setSortColumns(String sortColumns)
	{
		if (sortColumns == null || "".equals(sortColumns.trim())) {
			return;
		}
		if (sortColumns.contains(",")) {
			String[] cols = sortColumns.split(",");
			java.util.List<Field> fList = new java.util.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));
		}
	}
}
