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_level_config")
public class WxLevelConfig 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;
	
	/**成长值**/
	@io.swagger.annotations.ApiModelProperty(value="成长值",name="points")
	private Integer points;
	/**等级**/
	@io.swagger.annotations.ApiModelProperty(value="等级",name="level")
	private String level;
	/**描述**/
	@io.swagger.annotations.ApiModelProperty(value="描述",name="description")
	private String description;
	/**创建时间**/
	@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="capability")
	private String capability;

	/**是否启用，0:未启用，启用1，2，3，分别对应wx_merchant_discount里的rate_vip1, rate_vip2, rate_vip3**/
	@io.swagger.annotations.ApiModelProperty(value="是否启用",name="discountEnable")
	private Integer discountEnable;

	@Transient
	protected Long count;

	@Transient
	protected Long userCount;

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

	public Integer  getPoints() {
		return points;
	}
	public void setPoints(Integer _points) {
		points = _points;
	}
	public String  getLevel() {
		return level;
	}
	public void setLevel(String _level) {
		level = _level;
	}
	public String  getDescription() {
		return description;
	}
	public void setDescription(String _description) {
		description = _description;
	}
	public Date  getCreateDate() {
		return createDate;
	}
	public void setCreateDate(Date _createDate) {
		createDate = _createDate;
	}


	public Long getCount() {
		return count;
	}

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

	public Integer getDiscountEnable() {
		return discountEnable;
	}

	public void setDiscountEnable(Integer discountEnable) {
		this.discountEnable = discountEnable;
	}

	public Date getUpdateDate() {
		return updateDate;
	}

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

	public String getCapability() {
		return capability;
	}

	public void setCapability(String capability) {
		this.capability = capability;
	}

	public Long getUserCount() {
		return userCount;
	}

	public void setUserCount(Long userCount) {
		this.userCount = userCount;
	}

	public static enum Field
	{
		Id_ASC("`id` ASC"),Id_DESC("`id` DESC")
			,TenantId_ASC("`tenant_id` ASC"),TenantId_DESC("`tenant_id` DESC")
			,Points_ASC("`points` ASC"),Points_DESC("`points` DESC")
			,Level_ASC("`level` ASC"),Level_DESC("`level` DESC")
			,Description_ASC("`description` ASC"),Description_DESC("`description` DESC")
			,CreateDate_ASC("`create_date` ASC"),CreateDate_DESC("`create_date` 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(WxLevelConfig.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));
		}
	}
}
