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_coupon_send")
public class WxCouponSend 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="couponId")
	private Long couponId;

	/*券名称**/
	@io.swagger.annotations.ApiModelProperty(value="券名称",name="title")
	private String title;
	/*发券方式(1.主动领取,2.停车发券,3.核销发券)**/
	@io.swagger.annotations.ApiModelProperty(value="发券方式(1.主动领取,2.停车发券,3.核销发券)",name="sendType")
	private Integer sendType;
	/*发券条件**/
	@io.swagger.annotations.ApiModelProperty(value="发券条件",name="condition")
	private String conditions;
	/*0：有效  1:无效**/
	@io.swagger.annotations.ApiModelProperty(value="0：有效  1:无效",name="status")
	private Integer status;

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


	/*场景发券计数**/
	@Transient
	protected int sendCount;


	public String  getTenantId() {
		return tenantId;
	}
	public void setTenantId(String _tenantId) {
		tenantId = _tenantId;
	}
	public Long  getCouponId() {
		return couponId;
	}
	public void setCouponId(Long _couponId) {
		couponId = _couponId;
	}
	public String  getTitle() {
		return title;
	}
	public void setTitle(String _title) {
		title = _title;
	}
	public Integer  getSendType() {
		return sendType;
	}
	public void setSendType(Integer _sendType) {
		sendType = _sendType;
	}

	public String getConditions() {
		return conditions;
	}

	public void setConditions(String conditions) {
		this.conditions = conditions;
	}

	public Integer  getStatus() {
		return status;
	}
	public void setStatus(Integer _status) {
		status = _status;
	}

	public Date  getCreateDate() {
		return createDate;
	}
	public void setCreateDate(Date _createDate) {
		createDate = _createDate;
	}
	public Date  getUpdateDate() {
		return updateDate;
	}
	public void setUpdateDate(Date _updateDate) {
		updateDate = _updateDate;
	}


	public int getSendCount() {
		return sendCount;
	}

	public void setSendCount(int sendCount) {
		this.sendCount = sendCount;
	}

	public static enum Field
	{
		Id_ASC("`id` ASC"),Id_DESC("`id` DESC")
		,TenantId_ASC("`tenant_id` ASC"),TenantId_DESC("`tenant_id` DESC")
		,CouponId_ASC("`coupon_id` ASC"),CouponId_DESC("`coupon_id` DESC")
		,Title_ASC("`title` ASC"),Title_DESC("`title` DESC")
		,SendType_ASC("`send_type` ASC"),SendType_DESC("`send_type` DESC")
		,Status_ASC("`status` ASC"),Status_DESC("`status` DESC")
		,CreateDate_ASC("`create_date` ASC"),CreateDate_DESC("`create_date` DESC")
		,UpdateDate_ASC("`update_date` ASC"),UpdateDate_DESC("`update_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(WxCouponSend.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));
		}
	}
}
