import { FieldInfo } from 'model-util-base'
import { ConditionUtil, ConditionUtilImpl, FieldUtil, TableUtilImpl, IdType, JoinTable, SubTable } from 'model-util'
import { Container, Singleton } from 'typescript-ioc' 
import { CnGateway } from '../models/index' 

import {CnSLBMU} from './CnSLB' 
import {CnLabelRefMU} from './CnLabelRef' 
import {CnK8sPodMU} from './CnK8sPod' 


/**
 * @author auto generate
 * @version 1.0
 * @date 2021-11-05 09:52
 */
interface CnGatewayCU extends ConditionUtil<CnGatewayCU>{
    ID:FieldUtil<CnGatewayCU>;
    SERVICE_CENTER_ID:FieldUtil<CnGatewayCU>;
    APP_ID:FieldUtil<CnGatewayCU>;
    ENV_ID:FieldUtil<CnGatewayCU>;
    ENV_CODE:FieldUtil<CnGatewayCU>;
    NAME:FieldUtil<CnGatewayCU>;
    K8S_ID:FieldUtil<CnGatewayCU>;
    START_SCRIPT:FieldUtil<CnGatewayCU>;
    SPEC_TEMPLATE_ID:FieldUtil<CnGatewayCU>;
    METRICS_TEMPLATE_ID:FieldUtil<CnGatewayCU>;
    MIN_INSTANCE:FieldUtil<CnGatewayCU>;
    MAX_INSTANCE:FieldUtil<CnGatewayCU>;
    CPU:FieldUtil<CnGatewayCU>;
    MEMORY:FieldUtil<CnGatewayCU>;
    DOMAIN:FieldUtil<CnGatewayCU>;
    URI:FieldUtil<CnGatewayCU>;
    APP_OPTIONS_CONFIG:FieldUtil<CnGatewayCU>;
    DEPLOY_STATUS:FieldUtil<CnGatewayCU>;
    DEPLOY_MSG:FieldUtil<CnGatewayCU>;
    DELETED:FieldUtil<CnGatewayCU>;
    CREATE_USER_ID:FieldUtil<CnGatewayCU>;
    CREATE_TIME:FieldUtil<CnGatewayCU>;
    UPDATE_USER_ID:FieldUtil<CnGatewayCU>;
    UPDATE_TIME:FieldUtil<CnGatewayCU>;
    K8S_NAME:FieldUtil<CnGatewayCU>;
    SPEC_TEMPLATE_NAME:FieldUtil<CnGatewayCU>;
    METRICS_TEMPLATE_NAME:FieldUtil<CnGatewayCU>;
    ELASTIC_TYPE:FieldUtil<CnGatewayCU>;
    CN_SLB_ID:FieldUtil<CnGatewayCU>;
    DEPLOY_TAG:FieldUtil<CnGatewayCU>;
    CONFIG_CENTER:FieldUtil<CnGatewayCU>;
}

class CnGatewayCUImpl extends ConditionUtilImpl<CnGatewayCUImpl> implements CnGatewayCU{ 
    newInstance(): CnGatewayCUImpl {
        return new CnGatewayCUImpl();
    } 
    get ID(): FieldUtil<CnGatewayCU>{  
        return new FieldUtil('id','id','主键', this);
    }
    get SERVICE_CENTER_ID(): FieldUtil<CnGatewayCU>{  
        return new FieldUtil('service_center_id','serviceCenterId','服务中心ID', this);
    }
    get APP_ID(): FieldUtil<CnGatewayCU>{  
        return new FieldUtil('app_id','appId','应用ID', this);
    }
    get ENV_ID(): FieldUtil<CnGatewayCU>{  
        return new FieldUtil('env_id','envId','环境ID', this);
    }
    get ENV_CODE(): FieldUtil<CnGatewayCU>{  
        return new FieldUtil('env_code','envCode','TEST/PROD...', this);
    }
    get NAME(): FieldUtil<CnGatewayCU>{  
        return new FieldUtil('name','name','名称', this);
    }
    get K8S_ID(): FieldUtil<CnGatewayCU>{  
        return new FieldUtil('k8s_id','k8sId','K8S集群ID', this);
    }
    get START_SCRIPT(): FieldUtil<CnGatewayCU>{  
        return new FieldUtil('start_script','startScript','容器启动脚本：sleep 6000', this);
    }
    get SPEC_TEMPLATE_ID(): FieldUtil<CnGatewayCU>{  
        return new FieldUtil('spec_template_id','specTemplateId','容器规格id', this);
    }
    get METRICS_TEMPLATE_ID(): FieldUtil<CnGatewayCU>{  
        return new FieldUtil('metrics_template_id','metricsTemplateId','弹性伸缩模板ID', this);
    }
    get MIN_INSTANCE(): FieldUtil<CnGatewayCU>{  
        return new FieldUtil('min_instance','minInstance','最小实例数', this);
    }
    get MAX_INSTANCE(): FieldUtil<CnGatewayCU>{  
        return new FieldUtil('max_instance','maxInstance','最大实例数', this);
    }
    get CPU(): FieldUtil<CnGatewayCU>{  
        return new FieldUtil('cpu','cpu','cpu', this);
    }
    get MEMORY(): FieldUtil<CnGatewayCU>{  
        return new FieldUtil('memory','memory','内存', this);
    }
    get DOMAIN(): FieldUtil<CnGatewayCU>{  
        return new FieldUtil('domain','domain','域名', this);
    }
    get URI(): FieldUtil<CnGatewayCU>{  
        return new FieldUtil('uri','uri','URI', this);
    }
    get APP_OPTIONS_CONFIG(): FieldUtil<CnGatewayCU>{  
        return new FieldUtil('app_options_config','appOptionsConfig','应用选项配置JSON', this);
    }
    get DEPLOY_STATUS(): FieldUtil<CnGatewayCU>{  
        return new FieldUtil('deploy_status','deployStatus','0-已部署、1-待部署、2-部署中、3-部署失败、4-待释放、5-停止中、6-已释放、7-释放失败', this);
    }
    get DEPLOY_MSG(): FieldUtil<CnGatewayCU>{  
        return new FieldUtil('deploy_msg','deployMsg','部署日志信息', this);
    }
    get DELETED(): FieldUtil<CnGatewayCU>{  
        return new FieldUtil('deleted','deleted','删除标记', this);
    }
    get CREATE_USER_ID(): FieldUtil<CnGatewayCU>{  
        return new FieldUtil('create_user_id','createUserId','创建人', this);
    }
    get CREATE_TIME(): FieldUtil<CnGatewayCU>{  
        return new FieldUtil('create_time','createTime','创建时间', this);
    }
    get UPDATE_USER_ID(): FieldUtil<CnGatewayCU>{  
        return new FieldUtil('update_user_id','updateUserId','更新人', this);
    }
    get UPDATE_TIME(): FieldUtil<CnGatewayCU>{  
        return new FieldUtil('update_time','updateTime','更新时间', this);
    }
    get K8S_NAME(): FieldUtil<CnGatewayCU>{  
        return new FieldUtil('k8s_name','k8sName','k8s_name', this);
    }
    get SPEC_TEMPLATE_NAME(): FieldUtil<CnGatewayCU>{  
        return new FieldUtil('spec_template_name','specTemplateName','spec_template_name', this);
    }
    get METRICS_TEMPLATE_NAME(): FieldUtil<CnGatewayCU>{  
        return new FieldUtil('metrics_template_name','metricsTemplateName','metrics_template_name', this);
    }
    get ELASTIC_TYPE(): FieldUtil<CnGatewayCU>{  
        return new FieldUtil('elastic_type','elasticType','0:固定实例，1:弹性实例', this);
    }
    get CN_SLB_ID(): FieldUtil<CnGatewayCU>{  
        return new FieldUtil('cn_slb_id','cnSlbId','阿里云/华为云SLBID', this);
    }
    get DEPLOY_TAG(): FieldUtil<CnGatewayCU>{  
        return new FieldUtil('deploy_tag','deployTag','deploy_tag', this);
    }
    get CONFIG_CENTER(): FieldUtil<CnGatewayCU>{  
        return new FieldUtil('config_center','configCenter','配置中心JSON', this);
    }
    get SLB_NAME(): FieldInfo{  
        return new FieldInfo('slbName','名称');
    }
    get SLB_IP(): FieldInfo{  
        return new FieldInfo('slbIp','服务地址');
    }
}

@Singleton 
class CnGatewayMU extends TableUtilImpl<CnGatewayCU,CnGateway>{ 
    tableName  = 'cn_gateway';
    tableFields  = ['id','service_center_id','app_id','env_id','env_code','name','k8s_id','start_script','spec_template_id','metrics_template_id','min_instance','max_instance','cpu','memory','domain','uri','app_options_config','deploy_status','deploy_msg','deleted','create_user_id','create_time','update_user_id','update_time','k8s_name','spec_template_name','metrics_template_name','elastic_type','cn_slb_id','deploy_tag','config_center'];
    modelFields  = ['id','serviceCenterId','appId','envId','envCode','name','k8sId','startScript','specTemplateId','metricsTemplateId','minInstance','maxInstance','cpu','memory','domain','uri','appOptionsConfig','deployStatus','deployMsg','deleted','createUserId','createTime','updateUserId','updateTime','k8sName','specTemplateName','metricsTemplateName','elasticType','cnSlbId','deployTag','configCenter','slbName','slbIp'];
    modelIdFields  = ['id'];
    tableIdFields  = ['id'];
    idType = IdType.CUSTOM;
    joinTables = [{
            joinByDefault: true,
            foreignKeyFields: [CnGatewayMU.CN_SLB_ID,CnGatewayMU.DELETED],
            joinIdFields: [CnSLBMU.ID,CnSLBMU.DELETED],
            getTableUtil: ()=>{
                return Container.get(CnSLBMU);
            },
            fields: [
                {
                    fieldUtil: CnSLBMU.NAME,
                    alias: 'slbName'
                }
                ,{
                    fieldUtil: CnSLBMU.SERVICE_IP,
                    alias: 'slbIp'
                }
            ]

        } as JoinTable

];
    subTables = [{
            name: 'cnLabelRef',
            parentIdFields: [CnGatewayMU.ID,CnGatewayMU.DELETED],
            foreignKeyFields: [CnLabelRefMU.BUSSINESS_ID,CnLabelRefMU.DELETED],
            getTableUtil: ()=>{
                return Container.get(CnLabelRefMU);
            }
        } as SubTable

        ,{
            name: 'cnK8sPod',
            parentIdFields: [CnGatewayMU.ID,CnGatewayMU.DELETED],
            foreignKeyFields: [CnK8sPodMU.DEPLOY_ID,CnK8sPodMU.DELETED],
            getTableUtil: ()=>{
                return Container.get(CnK8sPodMU);
            }
        } as SubTable

];

    createConditionUtil(): CnGatewayCU {
        return new CnGatewayCUImpl();
    }   

    static get ID(): FieldUtil<CnGatewayCU>{ 
        return new FieldUtil('id','id','主键', new CnGatewayCUImpl());
    }
    static get SERVICE_CENTER_ID(): FieldUtil<CnGatewayCU>{ 
        return new FieldUtil('service_center_id','serviceCenterId','服务中心ID', new CnGatewayCUImpl());
    }
    static get APP_ID(): FieldUtil<CnGatewayCU>{ 
        return new FieldUtil('app_id','appId','应用ID', new CnGatewayCUImpl());
    }
    static get ENV_ID(): FieldUtil<CnGatewayCU>{ 
        return new FieldUtil('env_id','envId','环境ID', new CnGatewayCUImpl());
    }
    static get ENV_CODE(): FieldUtil<CnGatewayCU>{ 
        return new FieldUtil('env_code','envCode','TEST/PROD...', new CnGatewayCUImpl());
    }
    static get NAME(): FieldUtil<CnGatewayCU>{ 
        return new FieldUtil('name','name','名称', new CnGatewayCUImpl());
    }
    static get K8S_ID(): FieldUtil<CnGatewayCU>{ 
        return new FieldUtil('k8s_id','k8sId','K8S集群ID', new CnGatewayCUImpl());
    }
    static get START_SCRIPT(): FieldUtil<CnGatewayCU>{ 
        return new FieldUtil('start_script','startScript','容器启动脚本：sleep 6000', new CnGatewayCUImpl());
    }
    static get SPEC_TEMPLATE_ID(): FieldUtil<CnGatewayCU>{ 
        return new FieldUtil('spec_template_id','specTemplateId','容器规格id', new CnGatewayCUImpl());
    }
    static get METRICS_TEMPLATE_ID(): FieldUtil<CnGatewayCU>{ 
        return new FieldUtil('metrics_template_id','metricsTemplateId','弹性伸缩模板ID', new CnGatewayCUImpl());
    }
    static get MIN_INSTANCE(): FieldUtil<CnGatewayCU>{ 
        return new FieldUtil('min_instance','minInstance','最小实例数', new CnGatewayCUImpl());
    }
    static get MAX_INSTANCE(): FieldUtil<CnGatewayCU>{ 
        return new FieldUtil('max_instance','maxInstance','最大实例数', new CnGatewayCUImpl());
    }
    static get CPU(): FieldUtil<CnGatewayCU>{ 
        return new FieldUtil('cpu','cpu','cpu', new CnGatewayCUImpl());
    }
    static get MEMORY(): FieldUtil<CnGatewayCU>{ 
        return new FieldUtil('memory','memory','内存', new CnGatewayCUImpl());
    }
    static get DOMAIN(): FieldUtil<CnGatewayCU>{ 
        return new FieldUtil('domain','domain','域名', new CnGatewayCUImpl());
    }
    static get URI(): FieldUtil<CnGatewayCU>{ 
        return new FieldUtil('uri','uri','URI', new CnGatewayCUImpl());
    }
    static get APP_OPTIONS_CONFIG(): FieldUtil<CnGatewayCU>{ 
        return new FieldUtil('app_options_config','appOptionsConfig','应用选项配置JSON', new CnGatewayCUImpl());
    }
    static get DEPLOY_STATUS(): FieldUtil<CnGatewayCU>{ 
        return new FieldUtil('deploy_status','deployStatus','0-已部署、1-待部署、2-部署中、3-部署失败、4-待释放、5-停止中、6-已释放、7-释放失败', new CnGatewayCUImpl());
    }
    static get DEPLOY_MSG(): FieldUtil<CnGatewayCU>{ 
        return new FieldUtil('deploy_msg','deployMsg','部署日志信息', new CnGatewayCUImpl());
    }
    static get DELETED(): FieldUtil<CnGatewayCU>{ 
        return new FieldUtil('deleted','deleted','删除标记', new CnGatewayCUImpl());
    }
    static get CREATE_USER_ID(): FieldUtil<CnGatewayCU>{ 
        return new FieldUtil('create_user_id','createUserId','创建人', new CnGatewayCUImpl());
    }
    static get CREATE_TIME(): FieldUtil<CnGatewayCU>{ 
        return new FieldUtil('create_time','createTime','创建时间', new CnGatewayCUImpl());
    }
    static get UPDATE_USER_ID(): FieldUtil<CnGatewayCU>{ 
        return new FieldUtil('update_user_id','updateUserId','更新人', new CnGatewayCUImpl());
    }
    static get UPDATE_TIME(): FieldUtil<CnGatewayCU>{ 
        return new FieldUtil('update_time','updateTime','更新时间', new CnGatewayCUImpl());
    }
    static get K8S_NAME(): FieldUtil<CnGatewayCU>{ 
        return new FieldUtil('k8s_name','k8sName','k8s_name', new CnGatewayCUImpl());
    }
    static get SPEC_TEMPLATE_NAME(): FieldUtil<CnGatewayCU>{ 
        return new FieldUtil('spec_template_name','specTemplateName','spec_template_name', new CnGatewayCUImpl());
    }
    static get METRICS_TEMPLATE_NAME(): FieldUtil<CnGatewayCU>{ 
        return new FieldUtil('metrics_template_name','metricsTemplateName','metrics_template_name', new CnGatewayCUImpl());
    }
    static get ELASTIC_TYPE(): FieldUtil<CnGatewayCU>{ 
        return new FieldUtil('elastic_type','elasticType','0:固定实例，1:弹性实例', new CnGatewayCUImpl());
    }
    static get CN_SLB_ID(): FieldUtil<CnGatewayCU>{ 
        return new FieldUtil('cn_slb_id','cnSlbId','阿里云/华为云SLBID', new CnGatewayCUImpl());
    }
    static get DEPLOY_TAG(): FieldUtil<CnGatewayCU>{ 
        return new FieldUtil('deploy_tag','deployTag','deploy_tag', new CnGatewayCUImpl());
    }
    static get CONFIG_CENTER(): FieldUtil<CnGatewayCU>{ 
        return new FieldUtil('config_center','configCenter','配置中心JSON', new CnGatewayCUImpl());
    }
    static get SLB_NAME(): FieldInfo{  
        return new FieldInfo('slbName','名称');
    }
    static get SLB_IP(): FieldInfo{  
        return new FieldInfo('slbIp','服务地址');
    }

    get ID(): FieldUtil<CnGatewayCU>{ 
        return CnGatewayMU.ID;
    }
    get SERVICE_CENTER_ID(): FieldUtil<CnGatewayCU>{ 
        return CnGatewayMU.SERVICE_CENTER_ID;
    }
    get APP_ID(): FieldUtil<CnGatewayCU>{ 
        return CnGatewayMU.APP_ID;
    }
    get ENV_ID(): FieldUtil<CnGatewayCU>{ 
        return CnGatewayMU.ENV_ID;
    }
    get ENV_CODE(): FieldUtil<CnGatewayCU>{ 
        return CnGatewayMU.ENV_CODE;
    }
    get NAME(): FieldUtil<CnGatewayCU>{ 
        return CnGatewayMU.NAME;
    }
    get K8S_ID(): FieldUtil<CnGatewayCU>{ 
        return CnGatewayMU.K8S_ID;
    }
    get START_SCRIPT(): FieldUtil<CnGatewayCU>{ 
        return CnGatewayMU.START_SCRIPT;
    }
    get SPEC_TEMPLATE_ID(): FieldUtil<CnGatewayCU>{ 
        return CnGatewayMU.SPEC_TEMPLATE_ID;
    }
    get METRICS_TEMPLATE_ID(): FieldUtil<CnGatewayCU>{ 
        return CnGatewayMU.METRICS_TEMPLATE_ID;
    }
    get MIN_INSTANCE(): FieldUtil<CnGatewayCU>{ 
        return CnGatewayMU.MIN_INSTANCE;
    }
    get MAX_INSTANCE(): FieldUtil<CnGatewayCU>{ 
        return CnGatewayMU.MAX_INSTANCE;
    }
    get CPU(): FieldUtil<CnGatewayCU>{ 
        return CnGatewayMU.CPU;
    }
    get MEMORY(): FieldUtil<CnGatewayCU>{ 
        return CnGatewayMU.MEMORY;
    }
    get DOMAIN(): FieldUtil<CnGatewayCU>{ 
        return CnGatewayMU.DOMAIN;
    }
    get URI(): FieldUtil<CnGatewayCU>{ 
        return CnGatewayMU.URI;
    }
    get APP_OPTIONS_CONFIG(): FieldUtil<CnGatewayCU>{ 
        return CnGatewayMU.APP_OPTIONS_CONFIG;
    }
    get DEPLOY_STATUS(): FieldUtil<CnGatewayCU>{ 
        return CnGatewayMU.DEPLOY_STATUS;
    }
    get DEPLOY_MSG(): FieldUtil<CnGatewayCU>{ 
        return CnGatewayMU.DEPLOY_MSG;
    }
    get DELETED(): FieldUtil<CnGatewayCU>{ 
        return CnGatewayMU.DELETED;
    }
    get CREATE_USER_ID(): FieldUtil<CnGatewayCU>{ 
        return CnGatewayMU.CREATE_USER_ID;
    }
    get CREATE_TIME(): FieldUtil<CnGatewayCU>{ 
        return CnGatewayMU.CREATE_TIME;
    }
    get UPDATE_USER_ID(): FieldUtil<CnGatewayCU>{ 
        return CnGatewayMU.UPDATE_USER_ID;
    }
    get UPDATE_TIME(): FieldUtil<CnGatewayCU>{ 
        return CnGatewayMU.UPDATE_TIME;
    }
    get K8S_NAME(): FieldUtil<CnGatewayCU>{ 
        return CnGatewayMU.K8S_NAME;
    }
    get SPEC_TEMPLATE_NAME(): FieldUtil<CnGatewayCU>{ 
        return CnGatewayMU.SPEC_TEMPLATE_NAME;
    }
    get METRICS_TEMPLATE_NAME(): FieldUtil<CnGatewayCU>{ 
        return CnGatewayMU.METRICS_TEMPLATE_NAME;
    }
    get ELASTIC_TYPE(): FieldUtil<CnGatewayCU>{ 
        return CnGatewayMU.ELASTIC_TYPE;
    }
    get CN_SLB_ID(): FieldUtil<CnGatewayCU>{ 
        return CnGatewayMU.CN_SLB_ID;
    }
    get DEPLOY_TAG(): FieldUtil<CnGatewayCU>{ 
        return CnGatewayMU.DEPLOY_TAG;
    }
    get CONFIG_CENTER(): FieldUtil<CnGatewayCU>{ 
        return CnGatewayMU.CONFIG_CENTER;
    }
    get SLB_NAME(): FieldInfo{  
        return CnGatewayMU.SLB_NAME;
    }
    get SLB_IP(): FieldInfo{  
        return CnGatewayMU.SLB_IP;
    }
}
export {CnGatewayMU, CnGatewayCU}
