package com.hzya.frame.sys.dataSource.entity;


import com.hzya.frame.web.exception.BaseSystemException;

public class SysDataSourceVo   {

    /** 主键ID */
    private String id;
  /**  数据源编码 */
   private String sourceCode;
  /**  数据源名称 */
   private String sourceName;
  /**  ip */
   private String sourceIp;
  /**  端口 */
   private String sourcePort;
  /**  数据库名称 */
   private String dbName;
  /**  数据源类型 1oracle 2sqlsever 3mysql 4dm*/
   private String sourceType;
  /**  登录名 */
   private String loginName;
  /**  密码 */
   private String password;
  /**  选择oracle下服务名称 */
   private String serviceName;
  /**  使用状态1启用0锁定 */
   private Integer useState;

    public String getId() {
        return id;
    }

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

    public String getSourceCode() {
        return sourceCode;
    }

    public void setSourceCode(String sourceCode) {
        this.sourceCode = sourceCode;
    }

    public String getSourceName() {
        return sourceName;
    }

    public void setSourceName(String sourceName) {
        this.sourceName = sourceName;
    }

    public String getSourceIp() {
        return sourceIp;
    }

    public void setSourceIp(String sourceIp) {
        this.sourceIp = sourceIp;
    }

    public String getSourcePort() {
        return sourcePort;
    }

    public void setSourcePort(String sourcePort) {
        this.sourcePort = sourcePort;
    }

    public String getDbName() {
        return dbName;
    }

    public void setDbName(String dbName) {
        this.dbName = dbName;
    }

    public String getSourceType() {
        return sourceType;
    }

    public void setSourceType(String sourceType) {
        this.sourceType = sourceType;
    }

    public String getLoginName() {
        return loginName;
    }

    public void setLoginName(String loginName) {
        this.loginName = loginName;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getServiceName() {
        return serviceName;
    }

    public void setServiceName(String serviceName) {
        this.serviceName = serviceName;
    }

    public Integer getUseState() {
        return useState;
    }

    public void setUseState(Integer useState) {
        this.useState = useState;
    }

    public String getSourceUrl() {
        StringBuffer sourceUrl = new StringBuffer();
        switch (sourceType) {
            case "1": //oracle
                //jdbc:oracle:thin:@60.204.132.91:1521:ORCL
                sourceUrl.append("jdbc:oracle:thin:@").append(sourceIp).append(":").append(sourcePort).append(":").append(serviceName);
                break;
            case "2": //sqlsever
                //jdbc:sqlserver://221.12.175.82:1433;DatabaseName=U8CLOUD;encrypt=false;trustServerCertificate=true
                sourceUrl.append("jdbc:jtds:sqlserver://").append(sourceIp).append(":").append(sourcePort).append("/").append(dbName).append(";encrypt=false;trustServerCertificate=true");
                break;
            case "3": //mysql
                //jdbc:mysql://hzya.ufyct.com:9096/businesscenter?serverTimezone=UTC&useUnicode=true&characterEncoding=UTF8&serverTimezone=GMT%2B8&zeroDateTimeBehavior=convertToNull&useSSL=false
                sourceUrl.append("jdbc:mysql://").append(sourceIp).append(":").append(sourcePort).append("/").append(dbName).append("?serverTimezone=UTC&useUnicode=true&characterEncoding=UTF8&serverTimezone=GMT%2B8&zeroDateTimeBehavior=convertToNull&useSSL=false");
                break;
            case "4": //dm
                //jdbc:dm://hzya.ufyct.com:9040?schema=businesscenter&characterEncoding=UTF-8
                sourceUrl.append("jdbc:dm://").append(sourceIp).append(":").append(sourcePort).append("?schema=").append(dbName).append("&characterEncoding=UTF-8");
                break;
            default:
        }
        return sourceUrl.toString();
    }
    public String getSourceTypeName() {
        String  sourceTypeName = null;
        switch (sourceType) {
            case "1": //oracle
                sourceTypeName = "oracle";
                break;
            case "2": //sqlsever
                sourceTypeName = "sqlServer";
                break;
            case "3": //mysql
                sourceTypeName = "mysql";
                break;
            case "4": //mysql
                sourceTypeName = "dm";
                break;
            default:
        }
        return sourceTypeName;
    }
}

