package com.usoftchina.uas.office.entity;

import com.usoftchina.uas.office.jdbc.DataSourceBean;
import com.usoftchina.uas.office.util.StringUtils;

import java.util.Objects;

/**
 * @author yingp
 */
public class Master implements DataSourceBean {

    private int ma_id;
    private String ma_user;// 数据库用户名
    private String ms_pwd;// 数据库密码
    private String ma_name;// 帐套名，与bean名一致
    private String ma_function;
    private Short ma_enable;// 是否可使用
    private String ma_url;
    private String ma_driver;

    public int getMa_id() {
        return ma_id;
    }

    public void setMa_id(int ma_id) {
        this.ma_id = ma_id;
    }

    public String getMa_user() {
        return ma_user;
    }

    public void setMa_user(String ma_user) {
        this.ma_user = ma_user;
    }

    public String getMs_pwd() {
        return ms_pwd;
    }

    public void setMs_pwd(String ms_pwd) {
        this.ms_pwd = ms_pwd;
    }

    public String getMa_name() {
        return ma_name;
    }

    public void setMa_name(String ma_name) {
        this.ma_name = ma_name;
    }

    public String getMa_function() {
        return ma_function;
    }

    public void setMa_function(String ma_function) {
        this.ma_function = ma_function;
    }

    public Short getMa_enable() {
        return ma_enable;
    }

    public void setMa_enable(Short ma_enable) {
        this.ma_enable = ma_enable;
    }

    public String getMa_url() {
        return ma_url;
    }

    public void setMa_url(String ma_url) {
        this.ma_url = ma_url;
    }

    public String getMa_driver() {
        return ma_driver;
    }

    public void setMa_driver(String ma_driver) {
        this.ma_driver = ma_driver;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        Master master = (Master) o;
        return ma_id == master.ma_id &&
                Objects.equals(ma_user, master.ma_user) &&
                Objects.equals(ms_pwd, master.ms_pwd) &&
                Objects.equals(ma_name, master.ma_name) &&
                Objects.equals(ma_function, master.ma_function) &&
                Objects.equals(ma_enable, master.ma_enable) &&
                Objects.equals(ma_url, master.ma_url) &&
                Objects.equals(ma_driver, master.ma_driver);
    }

    @Override
    public int hashCode() {
        return Objects.hash(ma_id, ma_user, ms_pwd, ma_name, ma_function, ma_enable, ma_url, ma_driver);
    }

    @Override
    public String url() {
        return ma_url;
    }

    @Override
    public String username() {
        return ma_user.toUpperCase();
    }

    @Override
    public String password() {
        return ms_pwd;
    }

    @Override
    public String driverClassName() {
        return StringUtils.nvl(ma_driver, "oracle.jdbc.OracleDriver");
    }

    @Override
    public String toString() {
        return "Master{" +
                "ma_id=" + ma_id +
                ", ma_user='" + ma_user + '\'' +
                ", ms_pwd='" + ms_pwd + '\'' +
                ", ma_name='" + ma_name + '\'' +
                ", ma_function='" + ma_function + '\'' +
                ", ma_enable=" + ma_enable +
                ", ma_url='" + ma_url + '\'' +
                ", ma_driver='" + ma_driver + '\'' +
                '}';
    }
}
