package com.mvc.model.iotcard;

import com.mvc.utils.SecurityUtil;

/**
 * 查询所有卡信息参数
 */
public class QueryAllParamModel {
    private String page;
    private String agencyCode;
    private String key;
    private String sign;
    //是否欠费（到期或余额<=0）0：是；1：否；(经测试,此参数非必传,并且查询的条件和返回的好像也不准确,查欠费的,返回的不一定是欠费)
    private Integer isArrearage;

    public QueryAllParamModel(Integer page, String agencyCode, String key, Integer isArrearage) {
        this.page = page.toString();
        this.agencyCode = agencyCode;
        this.key = key;
        this.sign = generateSign();
        this.isArrearage = isArrearage;
    }

    private String generateSign(){
        StringBuilder sb = new StringBuilder();
        sb.append("page=");
        sb.append(page);
        sb.append("&agencyCode=");
        sb.append(agencyCode);
        sb.append("&key=");
        sb.append(key);
        return SecurityUtil.toMD5(sb.toString()).toUpperCase();
    }

    public String getPage() {
        return page;
    }

    public void setPage(String page) {
        this.page = page;
        //重新生成sign
        this.sign = generateSign();
    }

    public String getAgencyCode() {
        return agencyCode;
    }

    public void setAgencyCode(String agencyCode) {
        this.agencyCode = agencyCode;
    }

    public String getKey() {
        return key;
    }

    public void setKey(String key) {
        this.key = key;
    }

    public String getSign() {
        return sign;
    }

    public void setSign(String sign) {
        this.sign = sign;
    }

    public Integer getIsArrearage() {
        return isArrearage;
    }

    public void setIsArrearage(Integer isArrearage) {
        this.isArrearage = isArrearage;
    }
}
