package com.iformall.domain.po;

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

@Table(name = "wx_game_template")
@Data
public class WxGameTemplate implements Serializable {
	private static final long serialVersionUID = 1L;
	
	@Id
    protected Long id;
    
    @Transient
    protected List<Long> ids;
    @Transient
    protected String sortColumns;
	
	/**游戏名称*/
	@io.swagger.annotations.ApiModelProperty(value="游戏名称",name="name")
	private String name;
	/**游戏链接*/
	@io.swagger.annotations.ApiModelProperty(value="游戏链接",name="url")
	private String url;
	/**游戏logo，c端游戏入口使用*/
	@io.swagger.annotations.ApiModelProperty(value="游戏logo，c端游戏入口使用",name="imgUrl")
	private String imgUrl;
	/**选项限制（-1：不做限制)*/
	@io.swagger.annotations.ApiModelProperty(value="选项限制（-1：不做限制)",name="optionLimit")
	private Integer optionLimit;
	/**游戏规则说明*/
	@io.swagger.annotations.ApiModelProperty(value="游戏规则说明",name="rules")
	private String rules;
	/**游戏类型(1：卡牌),目前无用*/
	@io.swagger.annotations.ApiModelProperty(value="游戏类型(1：卡牌),目前无用",name="type")
	private Integer type;

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public List<Long> getIds() {
		return ids;
	}

	public void setIds(List<Long> ids) {
		this.ids = ids;
	}

	public String getSortColumns() {
		return sortColumns;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getUrl() {
		return url;
	}

	public void setUrl(String url) {
		this.url = url;
	}

	public String getImgUrl() {
		return imgUrl;
	}

	public void setImgUrl(String imgUrl) {
		this.imgUrl = imgUrl;
	}

	public Integer getOptionLimit() {
		return optionLimit;
	}

	public void setOptionLimit(Integer optionLimit) {
		this.optionLimit = optionLimit;
	}

	public String getRules() {
		return rules;
	}

	public void setRules(String rules) {
		this.rules = rules;
	}

	public Integer getType() {
		return type;
	}

	public void setType(Integer type) {
		this.type = type;
	}

	public static enum Field
	{
		Id_ASC("`id` ASC"),Id_DESC("`id` DESC")
			,Name_ASC("`name` ASC"),Name_DESC("`name` DESC")
			,Url_ASC("`url` ASC"),Url_DESC("`url` DESC")
			,ImgUrl_ASC("`img_url` ASC"),ImgUrl_DESC("`img_url` DESC")
			,OptionLimit_ASC("`option_limit` ASC"),OptionLimit_DESC("`option_limit` DESC")
			,Rules_ASC("`rules` ASC"),Rules_DESC("`rules` DESC")
			,Type_ASC("`type` ASC"),Type_DESC("`type` 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(WxGameTemplate.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));
		}
	}
}
