package com.iformall.domain.po;

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

@Table(name = "wx_order_press")
@Data
public class WxOrderPress implements Serializable {
	private static final long serialVersionUID = 1L;
	
	@Id
    protected Long id;
    
    @Transient
    protected List<Long> ids;
    @Transient
    protected String sortColumns;

    /**租户ID**/
    @io.swagger.annotations.ApiModelProperty(value="租户ID",name="tenantId")
    private String tenantId;
	/**订单ID*/
	@io.swagger.annotations.ApiModelProperty(value="订单ID",name="orderId")
	private Long orderId;
	/**砍价参与人ID*/
	@io.swagger.annotations.ApiModelProperty(value="砍价参与人ID",name="userId")
	private Long userId;
	/**砍下来的价值*/
	@io.swagger.annotations.ApiModelProperty(value="砍下来的价值",name="pressValue")
	private Integer pressValue;
	/**砍价时间*/
	@io.swagger.annotations.ApiModelProperty(value="砍价时间",name="createDate")
	private Date createDate;
    /**是否发起人*/
    @io.swagger.annotations.ApiModelProperty(value="是否发起人",name="first")
    private Integer first;



	public static enum Field
	{
		Id_ASC("`id` ASC"),Id_DESC("`id` DESC")
        ,TenantId_ASC("`tenant_id` ASC"),TenantId_DESC("`tenant_id` DESC")
			,OrderId_ASC("`order_id` ASC"),OrderId_DESC("`order_id` DESC")
			,UserId_ASC("`user_id` ASC"),UserId_DESC("`user_id` DESC")
			,PressValue_ASC("`press_value` ASC"),PressValue_DESC("`press_value` 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(WxOrderPress.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));
		}
	}
}
