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 = "push_limit")
public class PushLimit 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="",name="tenantId")
	private String tenantId;
	/**每人每天可接收短信数**/
	@io.swagger.annotations.ApiModelProperty(value="每人每天可接收短信数",name="msgAmount")
	private Integer msgAmount;
	/**每人每周可接收发券数**/
	@io.swagger.annotations.ApiModelProperty(value="每人每周可接收发券数",name="couponAmount")
	private Integer couponAmount;
	/**(每人几天内，不会收到同一个券**/
	@io.swagger.annotations.ApiModelProperty(value="每人几天内，不会收到同一个券",name="couponDay")
	private Integer couponDay;
	/**发券，发短信开始时间**/
	@io.swagger.annotations.ApiModelProperty(value="发券，发短信开始时间",name="timeStart")
	private String timeStart;
	/**发券，发短信结束时间**/
	@io.swagger.annotations.ApiModelProperty(value="发券，发短信结束时间",name="timeEnd")
	private String timeEnd;
	/***/
	@io.swagger.annotations.ApiModelProperty(value="",name="createTime")
	private Date createTime;
	/***/
	@io.swagger.annotations.ApiModelProperty(value="",name="updateTime")
	private Date updateTime;
	public String  getTenantId() {
		return tenantId;
	}
	public void setTenantId(String _tenantId) {
		tenantId = _tenantId;
	}
	public Integer  getMsgAmount() {
		return msgAmount;
	}
	public void setMsgAmount(Integer _msgAmount) {
		msgAmount = _msgAmount;
	}
	public Integer  getCouponAmount() {
		return couponAmount;
	}
	public void setCouponAmount(Integer _couponAmount) {
		couponAmount = _couponAmount;
	}
	public Integer  getCouponDay() {
		return couponDay;
	}
	public void setCouponDay(Integer _couponDay) {
		couponDay = _couponDay;
	}

	public String getTimeStart() {
		return timeStart;
	}

	public void setTimeStart(String timeStart) {
		this.timeStart = timeStart;
	}

	public String getTimeEnd() {
		return timeEnd;
	}

	public void setTimeEnd(String timeEnd) {
		this.timeEnd = timeEnd;
	}

	public Date  getCreateTime() {
		return createTime;
	}
	public void setCreateTime(Date _createTime) {
		createTime = _createTime;
	}
	public Date  getUpdateTime() {
		return updateTime;
	}
	public void setUpdateTime(Date _updateTime) {
		updateTime = _updateTime;
	}



	public static enum Field
	{
		Id_ASC("`id` ASC"),Id_DESC("`id` DESC")
		,TenantId_ASC("`tenant_id` ASC"),TenantId_DESC("`tenant_id` DESC")
		,MsgAmount_ASC("`msg_amount` ASC"),MsgAmount_DESC("`msg_amount` DESC")
		,CouponAmount_ASC("`coupon_amount` ASC"),CouponAmount_DESC("`coupon_amount` DESC")
		,CouponDay_ASC("`coupon_day` ASC"),CouponDay_DESC("`coupon_day` DESC")
		,TimeStart_ASC("`time_start` ASC"),TimeStart_DESC("`time_start` DESC")
		,TimeEnd_ASC("`time_end` ASC"),TimeEnd_DESC("`time_end` DESC")
		,CreateTime_ASC("`create_time` ASC"),CreateTime_DESC("`create_time` DESC")
		,UpdateTime_ASC("`update_time` ASC"),UpdateTime_DESC("`update_time` 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(PushLimit.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));
		}
	}
}
