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_authorizer_info")
@Data
public class WxAuthorizerInfo 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="租户ID",name="tenantId")
    private String tenantId;
    @io.swagger.annotations.ApiModelProperty(value="1B端2C端",name="type")
    private Integer type;
	@io.swagger.annotations.ApiModelProperty(value="授权方appid",name="authorizerAppid")
	private String authorizerAppid;
	@io.swagger.annotations.ApiModelProperty(value="授权方头像",name="headImg")
	private String headImg;
	@io.swagger.annotations.ApiModelProperty(value="授权方公众号所设置的微信号，可能为空",name="alias")
	private String alias;
	@io.swagger.annotations.ApiModelProperty(value="二维码图片的URL，开发者最好自行也进行保存",name="qrcodeUrl")
	private String qrcodeUrl;
	@io.swagger.annotations.ApiModelProperty(value="创建时间",name="createTime")
	private Date createTime;
    @io.swagger.annotations.ApiModelProperty(value="更新时间",name="updateTime")
    private Date updateTime;
	@io.swagger.annotations.ApiModelProperty(value="授权状态,0为已授权,1为已取消授权",name="authorizationStatus")
	private Integer authorizationStatus;
    @io.swagger.annotations.ApiModelProperty(value="授权时间",name="authTime")
    private Date authTime;
    @io.swagger.annotations.ApiModelProperty(value="微信基础版本设置状态,0为已设置,1为设置失败",name="baseStatus")
    private Integer baseStatus;
    @io.swagger.annotations.ApiModelProperty(value="微信基础版本设置时间",name="baseTime")
    private Date baseTime;
    @io.swagger.annotations.ApiModelProperty(value="微信服务器域名版本设置状态,0为已设置,1为设置失败",name="domainStatus")
    private Integer domainStatus;
    @io.swagger.annotations.ApiModelProperty(value="微信服务器域名版本设置时间",name="domainTime")
    private Date domainTime;
    @io.swagger.annotations.ApiModelProperty(value="微信服务器业务域名版本设置状态,0为已设置,1为设置失败",name="webdomainStatus")
    private Integer webdomainStatus;
    @io.swagger.annotations.ApiModelProperty(value="微信服务器业务域名版本设置时间",name="webdomainTime")
    private Date webdomainTime;
    @io.swagger.annotations.ApiModelProperty(value="微信小程序模板设置状态,0为已设置,1为设置失败",name="templateStatus")
    private Integer templateStatus;
    @io.swagger.annotations.ApiModelProperty(value="微信小程序模板设置时间",name="templateTime")
    private Date templateTime;
    @io.swagger.annotations.ApiModelProperty(value="当前版本",name="currentVersion")
    private String currentVersion;
    @io.swagger.annotations.ApiModelProperty(value="当前版本描述",name="currentDesc")
    private String currentDesc;
    @io.swagger.annotations.ApiModelProperty(value="当前版本发布时间",name="releaseTime")
    private Date releaseTime;
    @io.swagger.annotations.ApiModelProperty(value="微信开放平台appId",name="openAppid")
    private String openAppid;
    @io.swagger.annotations.ApiModelProperty(value="绑定开发平台时间",name="bindOpenTime")
    private Date bindOpenTime;
    @io.swagger.annotations.ApiModelProperty(value="refresh_token",name="refreshToken")
    private String refreshToken;
    @io.swagger.annotations.ApiModelProperty(value="access_token",name="accessToken")
    private String accessToken;
    @io.swagger.annotations.ApiModelProperty(value="accessToken过期时间",name="accessTokenExpire")
    private Date accessTokenExpire;



	public static enum Field
	{
		Id_ASC("`id` ASC"),Id_DESC("`id` DESC")
            ,TenantId_ASC("`tenant_id` ASC"),TenantId_DESC("`tenant_id` DESC")
			,AuthorizerAppid_ASC("`authorizer_appid` ASC"),AuthorizerAppid_DESC("`authorizer_appid` DESC")
			,HeadImg_ASC("`head_img` ASC"),HeadImg_DESC("`head_img` DESC")
			,Alias_ASC("`alias` ASC"),Alias_DESC("`alias` DESC")
			,QrcodeUrl_ASC("`qrcode_url` ASC"),QrcodeUrl_DESC("`qrcode_url` DESC")
			,CreateTime_ASC("`create_time` ASC"),CreateTime_DESC("`create_time` DESC")
            ,UpdateTime_ASC("`update_time` ASC"),UpdateTime_DESC("`update_time` DESC")
			,AuthorizationStatus_ASC("`authorization_status` ASC"),AuthorizationStatus_DESC("`authorization_status` DESC")
            ,AuthTime_ASC("`auth_time` ASC"),AuthTime_DESC("`auth_time` DESC")
            ,BaseStatus_ASC("`base_status` ASC"),BaseStatus_DESC("`base_status` DESC")
            ,BaseTime_ASC("`base_time` ASC"),BaseTime_DESC("`base_time` DESC")
            ,DomainStatus_ASC("`domain_status` ASC"),DomainStatus_DESC("`domain_status` DESC")
            ,DomainTime_ASC("`domain_time` ASC"),DomainTime_DESC("`domain_time` DESC")
            ,WebDomainStatus_ASC("`webdomain_status` ASC"),WebDomainStatus_DESC("`webdomain_status` DESC")
            ,WebDomainTime_ASC("`webdomain_time` ASC"),WebDomainTime_DESC("`webdomain_time` DESC")
            ,TemplateStatus_ASC("`template_status` ASC"),TemplateStatus_DESC("`template_status` DESC")
            ,TemplateTime_ASC("`template_time` ASC"),TemplateTime_DESC("`template_time` DESC")
            ,CurrentVersion_ASC("`current_version` ASC"),CurrentVersion_DESC("`current_version` DESC")
            ,CurrentDesc_ASC("`current_desc` ASC"),CurrentDesc_DESC("`current_desc` DESC")
            ,ReleaseTime_ASC("`release_time` ASC"),ReleaseTime_DESC("`release_time` DESC")
            ,OpenAppId_ASC("`open_appid` ASC"),OpenAppId_DESC("`open_appid` DESC")
            ,BindOpenTime_ASC("`bind_open_time` ASC"),BindOpen_DESC("`bind_open_time` 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(WxAuthorizerInfo.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));
		}
	}
}
