package com.iformall.domain.po;

import lombok.Data;
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_weapp_basic_set")
@Data
public class WxWeappBasicSet implements Serializable {
	private static final long serialVersionUID = 1L;
	
	@Id
    protected Long id;
    
    @Transient
    protected List<Long> ids;
    @Transient
    protected String sortColumns;
	
	/**小程序类型(1-B端 2-C端)*/
	@io.swagger.annotations.ApiModelProperty(value="小程序类型(1-B端 2-C端)",name="type")
	private Integer type;
    /**部署类型(1:dev,2:test,3:prod)*/
    @io.swagger.annotations.ApiModelProperty(value="部署类型(1:dev,2:test,3:prod)",name="deploy")
    private Integer deploy;
	/**服务器域名*/
	@io.swagger.annotations.ApiModelProperty(value="服务器域名",name="domainUrl")
	private String domainUrl;
	/**小程序基础版本*/
	@io.swagger.annotations.ApiModelProperty(value="小程序基础版本",name="version")
	private String version;
	/**模板库信息*/
	@io.swagger.annotations.ApiModelProperty(value="模板库信息",name="templateInfo")
	private String templateInfo;
	/**创建时间*/
	@io.swagger.annotations.ApiModelProperty(value="创建时间",name="createDate")
	private Date createDate;
	/**更新时间*/
	@io.swagger.annotations.ApiModelProperty(value="更新时间",name="updateDate")
	private Date updateDate;



	public static enum Field
	{
		Id_ASC("`id` ASC"),Id_DESC("`id` DESC")
			,Type_ASC("`type` ASC"),Type_DESC("`type` DESC")
            ,Deploy_ASC("`deploy` ASC"),Deploy_DESC("`deploy` DESC")
			,DomainUrl_ASC("`domain_url` ASC"),DomainUrl_DESC("`domain_url` DESC")
			,Version_ASC("`version` ASC"),Version_DESC("`version` DESC")
			,TemplateInfo_ASC("`template_info` ASC"),TemplateInfo_DESC("`template_info` 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(WxWeappBasicSet.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));
		}
	}
}
