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

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


/**
 * @author auto generate
 * @version 1.0
 * @date 2021-11-04 10:56
 */
interface CnBaseServiceCU extends ConditionUtil<CnBaseServiceCU>{
    ID:FieldUtil<CnBaseServiceCU>;
    SERVICE_CENTER_ID:FieldUtil<CnBaseServiceCU>;
    APP_ID:FieldUtil<CnBaseServiceCU>;
    ENV_ID:FieldUtil<CnBaseServiceCU>;
    ENV_CODE:FieldUtil<CnBaseServiceCU>;
    NAME:FieldUtil<CnBaseServiceCU>;
    K8S_ID:FieldUtil<CnBaseServiceCU>;
    START_SCRIPT:FieldUtil<CnBaseServiceCU>;
    CN_SLB_ID:FieldUtil<CnBaseServiceCU>;
    SLB_PORT_MAPPING:FieldUtil<CnBaseServiceCU>;
    SPEC_TEMPLATE_ID:FieldUtil<CnBaseServiceCU>;
    METRICS_TEMPLATE_ID:FieldUtil<CnBaseServiceCU>;
    MIN_INSTANCE:FieldUtil<CnBaseServiceCU>;
    MAX_INSTANCE:FieldUtil<CnBaseServiceCU>;
    CPU:FieldUtil<CnBaseServiceCU>;
    MEMORY:FieldUtil<CnBaseServiceCU>;
    PROGRESS_KEYWORD:FieldUtil<CnBaseServiceCU>;
    APP_OPTIONS_CONFIG:FieldUtil<CnBaseServiceCU>;
    DEPLOY_STATUS:FieldUtil<CnBaseServiceCU>;
    DELETED:FieldUtil<CnBaseServiceCU>;
    DEPLOY_MSG:FieldUtil<CnBaseServiceCU>;
    CREATE_USER_ID:FieldUtil<CnBaseServiceCU>;
    CREATE_TIME:FieldUtil<CnBaseServiceCU>;
    UPDATE_USER_ID:FieldUtil<CnBaseServiceCU>;
    UPDATE_TIME:FieldUtil<CnBaseServiceCU>;
    K8S_NAME:FieldUtil<CnBaseServiceCU>;
    SPEC_TEMPLATE_NAME:FieldUtil<CnBaseServiceCU>;
    METRICS_TEMPLATE_NAME:FieldUtil<CnBaseServiceCU>;
    DEPLOY_TAG:FieldUtil<CnBaseServiceCU>;
    CONFIG_CENTER:FieldUtil<CnBaseServiceCU>;
}

class CnBaseServiceCUImpl extends ConditionUtilImpl<CnBaseServiceCUImpl> implements CnBaseServiceCU{ 
    newInstance(): CnBaseServiceCUImpl {
        return new CnBaseServiceCUImpl();
    } 
    get ID(): FieldUtil<CnBaseServiceCU>{  
        return new FieldUtil('id','id','主键', this);
    }
    get SERVICE_CENTER_ID(): FieldUtil<CnBaseServiceCU>{  
        return new FieldUtil('service_center_id','serviceCenterId','服务中心ID', this);
    }
    get APP_ID(): FieldUtil<CnBaseServiceCU>{  
        return new FieldUtil('app_id','appId','应用ID', this);
    }
    get ENV_ID(): FieldUtil<CnBaseServiceCU>{  
        return new FieldUtil('env_id','envId','环境ID', this);
    }
    get ENV_CODE(): FieldUtil<CnBaseServiceCU>{  
        return new FieldUtil('env_code','envCode','TEST/PROD...', this);
    }
    get NAME(): FieldUtil<CnBaseServiceCU>{  
        return new FieldUtil('name','name','名称', this);
    }
    get K8S_ID(): FieldUtil<CnBaseServiceCU>{  
        return new FieldUtil('k8s_id','k8sId','K8S集群ID', this);
    }
    get START_SCRIPT(): FieldUtil<CnBaseServiceCU>{  
        return new FieldUtil('start_script','startScript','容器启动脚本：/opt/app/start.sh', this);
    }
    get CN_SLB_ID(): FieldUtil<CnBaseServiceCU>{  
        return new FieldUtil('cn_slb_id','cnSlbId','SLB设置主键', this);
    }
    get SLB_PORT_MAPPING(): FieldUtil<CnBaseServiceCU>{  
        return new FieldUtil('slb_port_mapping','slbPortMapping','slb1:pod1,slb2:pod2(例：80:81,33:38)', this);
    }
    get SPEC_TEMPLATE_ID(): FieldUtil<CnBaseServiceCU>{  
        return new FieldUtil('spec_template_id','specTemplateId','容器规格id', this);
    }
    get METRICS_TEMPLATE_ID(): FieldUtil<CnBaseServiceCU>{  
        return new FieldUtil('metrics_template_id','metricsTemplateId','弹性伸缩模板ID', this);
    }
    get MIN_INSTANCE(): FieldUtil<CnBaseServiceCU>{  
        return new FieldUtil('min_instance','minInstance','1', this);
    }
    get MAX_INSTANCE(): FieldUtil<CnBaseServiceCU>{  
        return new FieldUtil('max_instance','maxInstance','8', this);
    }
    get CPU(): FieldUtil<CnBaseServiceCU>{  
        return new FieldUtil('cpu','cpu','cpu', this);
    }
    get MEMORY(): FieldUtil<CnBaseServiceCU>{  
        return new FieldUtil('memory','memory','内存', this);
    }
    get PROGRESS_KEYWORD(): FieldUtil<CnBaseServiceCU>{  
        return new FieldUtil('progress_keyword','progressKeyword','进程关键字', this);
    }
    get APP_OPTIONS_CONFIG(): FieldUtil<CnBaseServiceCU>{  
        return new FieldUtil('app_options_config','appOptionsConfig','应用选项配置JSON', this);
    }
    get DEPLOY_STATUS(): FieldUtil<CnBaseServiceCU>{  
        return new FieldUtil('deploy_status','deployStatus','0-已部署、1-待部署、2-部署中、3-部署失败、4-待释放、5-停止中、6-已释放、7-释放失败', this);
    }
    get DELETED(): FieldUtil<CnBaseServiceCU>{  
        return new FieldUtil('deleted','deleted','删除标记', this);
    }
    get DEPLOY_MSG(): FieldUtil<CnBaseServiceCU>{  
        return new FieldUtil('deploy_msg','deployMsg','部署日志信息', this);
    }
    get CREATE_USER_ID(): FieldUtil<CnBaseServiceCU>{  
        return new FieldUtil('create_user_id','createUserId','创建人', this);
    }
    get CREATE_TIME(): FieldUtil<CnBaseServiceCU>{  
        return new FieldUtil('create_time','createTime','创建时间', this);
    }
    get UPDATE_USER_ID(): FieldUtil<CnBaseServiceCU>{  
        return new FieldUtil('update_user_id','updateUserId','更新人', this);
    }
    get UPDATE_TIME(): FieldUtil<CnBaseServiceCU>{  
        return new FieldUtil('update_time','updateTime','更新时间', this);
    }
    get K8S_NAME(): FieldUtil<CnBaseServiceCU>{  
        return new FieldUtil('k8s_name','k8sName','k8s_name', this);
    }
    get SPEC_TEMPLATE_NAME(): FieldUtil<CnBaseServiceCU>{  
        return new FieldUtil('spec_template_name','specTemplateName','spec_template_name', this);
    }
    get METRICS_TEMPLATE_NAME(): FieldUtil<CnBaseServiceCU>{  
        return new FieldUtil('metrics_template_name','metricsTemplateName','metrics_template_name', this);
    }
    get DEPLOY_TAG(): FieldUtil<CnBaseServiceCU>{  
        return new FieldUtil('deploy_tag','deployTag','deploy_tag', this);
    }
    get CONFIG_CENTER(): FieldUtil<CnBaseServiceCU>{  
        return new FieldUtil('config_center','configCenter','配置中心JSON', this);
    }
    get SLB_NAME(): FieldInfo{  
        return new FieldInfo('slbName','名称');
    }
}

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

        } as JoinTable

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

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

];

    createConditionUtil(): CnBaseServiceCU {
        return new CnBaseServiceCUImpl();
    }   

    static get ID(): FieldUtil<CnBaseServiceCU>{ 
        return new FieldUtil('id','id','主键', new CnBaseServiceCUImpl());
    }
    static get SERVICE_CENTER_ID(): FieldUtil<CnBaseServiceCU>{ 
        return new FieldUtil('service_center_id','serviceCenterId','服务中心ID', new CnBaseServiceCUImpl());
    }
    static get APP_ID(): FieldUtil<CnBaseServiceCU>{ 
        return new FieldUtil('app_id','appId','应用ID', new CnBaseServiceCUImpl());
    }
    static get ENV_ID(): FieldUtil<CnBaseServiceCU>{ 
        return new FieldUtil('env_id','envId','环境ID', new CnBaseServiceCUImpl());
    }
    static get ENV_CODE(): FieldUtil<CnBaseServiceCU>{ 
        return new FieldUtil('env_code','envCode','TEST/PROD...', new CnBaseServiceCUImpl());
    }
    static get NAME(): FieldUtil<CnBaseServiceCU>{ 
        return new FieldUtil('name','name','名称', new CnBaseServiceCUImpl());
    }
    static get K8S_ID(): FieldUtil<CnBaseServiceCU>{ 
        return new FieldUtil('k8s_id','k8sId','K8S集群ID', new CnBaseServiceCUImpl());
    }
    static get START_SCRIPT(): FieldUtil<CnBaseServiceCU>{ 
        return new FieldUtil('start_script','startScript','容器启动脚本：/opt/app/start.sh', new CnBaseServiceCUImpl());
    }
    static get CN_SLB_ID(): FieldUtil<CnBaseServiceCU>{ 
        return new FieldUtil('cn_slb_id','cnSlbId','SLB设置主键', new CnBaseServiceCUImpl());
    }
    static get SLB_PORT_MAPPING(): FieldUtil<CnBaseServiceCU>{ 
        return new FieldUtil('slb_port_mapping','slbPortMapping','slb1:pod1,slb2:pod2(例：80:81,33:38)', new CnBaseServiceCUImpl());
    }
    static get SPEC_TEMPLATE_ID(): FieldUtil<CnBaseServiceCU>{ 
        return new FieldUtil('spec_template_id','specTemplateId','容器规格id', new CnBaseServiceCUImpl());
    }
    static get METRICS_TEMPLATE_ID(): FieldUtil<CnBaseServiceCU>{ 
        return new FieldUtil('metrics_template_id','metricsTemplateId','弹性伸缩模板ID', new CnBaseServiceCUImpl());
    }
    static get MIN_INSTANCE(): FieldUtil<CnBaseServiceCU>{ 
        return new FieldUtil('min_instance','minInstance','1', new CnBaseServiceCUImpl());
    }
    static get MAX_INSTANCE(): FieldUtil<CnBaseServiceCU>{ 
        return new FieldUtil('max_instance','maxInstance','8', new CnBaseServiceCUImpl());
    }
    static get CPU(): FieldUtil<CnBaseServiceCU>{ 
        return new FieldUtil('cpu','cpu','cpu', new CnBaseServiceCUImpl());
    }
    static get MEMORY(): FieldUtil<CnBaseServiceCU>{ 
        return new FieldUtil('memory','memory','内存', new CnBaseServiceCUImpl());
    }
    static get PROGRESS_KEYWORD(): FieldUtil<CnBaseServiceCU>{ 
        return new FieldUtil('progress_keyword','progressKeyword','进程关键字', new CnBaseServiceCUImpl());
    }
    static get APP_OPTIONS_CONFIG(): FieldUtil<CnBaseServiceCU>{ 
        return new FieldUtil('app_options_config','appOptionsConfig','应用选项配置JSON', new CnBaseServiceCUImpl());
    }
    static get DEPLOY_STATUS(): FieldUtil<CnBaseServiceCU>{ 
        return new FieldUtil('deploy_status','deployStatus','0-已部署、1-待部署、2-部署中、3-部署失败、4-待释放、5-停止中、6-已释放、7-释放失败', new CnBaseServiceCUImpl());
    }
    static get DELETED(): FieldUtil<CnBaseServiceCU>{ 
        return new FieldUtil('deleted','deleted','删除标记', new CnBaseServiceCUImpl());
    }
    static get DEPLOY_MSG(): FieldUtil<CnBaseServiceCU>{ 
        return new FieldUtil('deploy_msg','deployMsg','部署日志信息', new CnBaseServiceCUImpl());
    }
    static get CREATE_USER_ID(): FieldUtil<CnBaseServiceCU>{ 
        return new FieldUtil('create_user_id','createUserId','创建人', new CnBaseServiceCUImpl());
    }
    static get CREATE_TIME(): FieldUtil<CnBaseServiceCU>{ 
        return new FieldUtil('create_time','createTime','创建时间', new CnBaseServiceCUImpl());
    }
    static get UPDATE_USER_ID(): FieldUtil<CnBaseServiceCU>{ 
        return new FieldUtil('update_user_id','updateUserId','更新人', new CnBaseServiceCUImpl());
    }
    static get UPDATE_TIME(): FieldUtil<CnBaseServiceCU>{ 
        return new FieldUtil('update_time','updateTime','更新时间', new CnBaseServiceCUImpl());
    }
    static get K8S_NAME(): FieldUtil<CnBaseServiceCU>{ 
        return new FieldUtil('k8s_name','k8sName','k8s_name', new CnBaseServiceCUImpl());
    }
    static get SPEC_TEMPLATE_NAME(): FieldUtil<CnBaseServiceCU>{ 
        return new FieldUtil('spec_template_name','specTemplateName','spec_template_name', new CnBaseServiceCUImpl());
    }
    static get METRICS_TEMPLATE_NAME(): FieldUtil<CnBaseServiceCU>{ 
        return new FieldUtil('metrics_template_name','metricsTemplateName','metrics_template_name', new CnBaseServiceCUImpl());
    }
    static get DEPLOY_TAG(): FieldUtil<CnBaseServiceCU>{ 
        return new FieldUtil('deploy_tag','deployTag','deploy_tag', new CnBaseServiceCUImpl());
    }
    static get CONFIG_CENTER(): FieldUtil<CnBaseServiceCU>{ 
        return new FieldUtil('config_center','configCenter','配置中心JSON', new CnBaseServiceCUImpl());
    }
    static get SLB_NAME(): FieldInfo{  
        return new FieldInfo('slbName','名称');
    }

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