package com.iformall.domain.vo;

import com.iformall.domain.po.WxMerchantSubsidy;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;

import javax.persistence.Transient;

@Data
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
public class WxMerchantSubsidyVo extends WxMerchantSubsidy {
    /**卡信息*/
    /**封面图**/
    @io.swagger.annotations.ApiModelProperty(value="封面图",name="coverImg")
    private String coverImg;
    /**券名称**/
    @io.swagger.annotations.ApiModelProperty(value="券名称",name="title")
    private String title;
    /**副标题**/
    @io.swagger.annotations.ApiModelProperty(value="副标题",name="subTitle")
    private String subTitle;
    /**单位**/
    @io.swagger.annotations.ApiModelProperty(value="单位0:钱分，1:小时",name="unit")
    private Integer unit;
    /**须知**/
    @io.swagger.annotations.ApiModelProperty(value="须知",name="detail")
    private String detail;
    /**购买须知**/
    @io.swagger.annotations.ApiModelProperty(value="购买须知",name="remark")
    private String remark;

    /**使用商户名**/
    @io.swagger.annotations.ApiModelProperty(value="商户名",name="name")
    private String merchantName;

    /**持有人昵称**/
    @io.swagger.annotations.ApiModelProperty(value="持有人昵称",name="nickName")
    private String nickName;

    /**持有人手机**/
    @io.swagger.annotations.ApiModelProperty(value="持有人手机",name="phone")
    private String phone;

    @Transient
    protected String sortColumns;

    public static enum Field
    {
        Id_ASC("t.`id` ASC"),Id_DESC("t.`id` DESC")
        ,TenantId_ASC("t.`tenant_id` ASC"),TenantId_DESC("t.`tenant_id` DESC")
        ,OrderId_ASC("t.`order_id` ASC"),OrderId_DESC("t.`order_id` DESC")
        ,OrderType_ASC("t.`order_type` ASC"),OrderType_DESC("t.`order_type` DESC")
        ,MerchantId_ASC("t.`merchant_id` ASC"),MerchantId_DESC("t.`merchant_id` DESC")
        ,CouponOrderId_ASC("t.`coupon_order_id` ASC"),CouponOrderId_DESC("t.`coupon_order_id` DESC")
        ,CouponType_ASC("t.`coupon_type` ASC"),CouponType_DESC("t.`coupon_type` DESC")
        ,OrderPayment_ASC("t.`order_payment` ASC"),OrderPayment_DESC("t.`order_payment` DESC")
        ,ReceiverPayment_ASC("t.`receiver_payment` ASC"),ReceiverPayment_DESC("t.`receiver_payment` DESC")
        ,RealPayment_ASC("t.`real_payment` ASC"),RealPayment_DESC("t.`real_payment` DESC")
        ,Subsidy_ASC("t.`subsidy` ASC"),Subsidy_DESC("t.`subsidy` DESC")
        ,RealSubsidy_ASC("t.`real_subsidy` ASC"),RealSubsidy_DESC("t.`real_subsidy` DESC")
        ,Status_ASC("t.`status` ASC"),Status_DESC("t.`status` DESC")
        ,CreateDate_ASC("t.`create_date` ASC"),CreateDate_DESC("t.`create_date` DESC")
        ,UpdateDate_ASC("t.`update_date` ASC"),UpdateDate_DESC("t.`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(WxMerchantSubsidy.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<WxMerchantSubsidy.Field> fList = new java.util.ArrayList();
            for (int k = 0; k < cols.length; k++) {
                fList.add(WxMerchantSubsidy.Field.valueOf(cols[k]));
            }
            this.setSortColumns(fList.toArray(new WxMerchantSubsidy.Field[fList.size()]));
        } else {
            this.setSortColumns(WxMerchantSubsidy.Field.valueOf(sortColumns));
        }
    }
}
