package com.iformall.domain.po;

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

@Table(name = "wx_tags")
public class WxTags 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="name")
	private String name;
	/**1基础2生活属性3消费偏好4行为偏好**/
	@io.swagger.annotations.ApiModelProperty(value="1基础2生活属性3消费偏好4行为偏好",name="groupId")
	private Long groupId;
	/**二级属性 性别等**/
	@io.swagger.annotations.ApiModelProperty(value="二级属性 性别等",name="typeId")
	private Long typeId;
	/**1基础2生活属性3消费偏好4行为偏好**/
	@io.swagger.annotations.ApiModelProperty(value="1基础2生活属性3消费偏好4行为偏好",name="groupName")
	private String groupName;
	/**二级属性 性别等**/
	@io.swagger.annotations.ApiModelProperty(value="二级属性 性别等",name="typeName")
	private String typeName;


	@Transient
	protected Long count;
	public Long getCount() {
		return count;
	}
	public void setCount(Long count) {
		this.count = count;
	}

	public String  getName() {
		return name;
	}
	public void setName(String _name) {
		name = _name;
	}

	public Long getGroupId() {
		return groupId;
	}

	public void setGroupId(Long groupId) {
		this.groupId = groupId;
	}

	public Long getTypeId() {
		return typeId;
	}

	public void setTypeId(Long typeId) {
		this.typeId = typeId;
	}

	public String getGroupName() {
		return groupName;
	}

	public void setGroupName(String groupName) {
		this.groupName = groupName;
	}

	public String getTypeName() {
		return typeName;
	}

	public void setTypeName(String typeName) {
		this.typeName = typeName;
	}



	public enum Field
	{
		Id_ASC("`id` ASC"),Id_DESC("`id` DESC")
			,Name_ASC("`name` ASC"),Name_DESC("`name` DESC")
			,GroupId_ASC("`group_id` ASC"),GroupId_DESC("`group_id` DESC")
			,GroupName_ASC("`group_name` ASC"),GroupName_DESC("`group_name` DESC")
			,TypeId_ASC("`type_id` ASC"),TypeId_DESC("`type_id` DESC")
			,TypeName_ASC("`type_name` ASC"),TypeName_DESC("`type_name` 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(WxTags.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(",");
			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));
		}
	}
}
