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

import {MonitorRuleTemplateMU} from './MonitorRuleTemplate' 
import {MonitorRulesettingServiceRelMU} from './MonitorRulesettingServiceRel' 
import {MonitorRulesettingContactRelMU} from './MonitorRulesettingContactRel' 


/**
 * @author auto generate
 * @version 1.0
 * @date 2021-09-15 13:46
 */
interface MonitorRuleSettingCU extends ConditionUtil<MonitorRuleSettingCU>{
    ID:FieldUtil<MonitorRuleSettingCU>;
    TEMPLATE_ID:FieldUtil<MonitorRuleSettingCU>;
    ALARM_LEVEL:FieldUtil<MonitorRuleSettingCU>;
    ENABLE:FieldUtil<MonitorRuleSettingCU>;
    DELETED:FieldUtil<MonitorRuleSettingCU>;
    CHANGED:FieldUtil<MonitorRuleSettingCU>;
    CREATE_TIME:FieldUtil<MonitorRuleSettingCU>;
    UPDATE_TIME:FieldUtil<MonitorRuleSettingCU>;
}

class MonitorRuleSettingCUImpl extends ConditionUtilImpl<MonitorRuleSettingCUImpl> implements MonitorRuleSettingCU{ 
    newInstance(): MonitorRuleSettingCUImpl {
        return new MonitorRuleSettingCUImpl();
    } 
    get ID(): FieldUtil<MonitorRuleSettingCU>{  
        return new FieldUtil('id','id','主键', this);
    }
    get TEMPLATE_ID(): FieldUtil<MonitorRuleSettingCU>{  
        return new FieldUtil('template_id','templateId','模板名称', this);
    }
    get ALARM_LEVEL(): FieldUtil<MonitorRuleSettingCU>{  
        return new FieldUtil('alarm_level','alarmLevel','报警级别', this);
    }
    get ENABLE(): FieldUtil<MonitorRuleSettingCU>{  
        return new FieldUtil('enable','enable','是否启用', this);
    }
    get DELETED(): FieldUtil<MonitorRuleSettingCU>{  
        return new FieldUtil('deleted','deleted','deleted', this);
    }
    get CHANGED(): FieldUtil<MonitorRuleSettingCU>{  
        return new FieldUtil('changed','changed','是否变更', this);
    }
    get CREATE_TIME(): FieldUtil<MonitorRuleSettingCU>{  
        return new FieldUtil('create_time','createTime','create_time', this);
    }
    get UPDATE_TIME(): FieldUtil<MonitorRuleSettingCU>{  
        return new FieldUtil('update_time','updateTime','update_time', this);
    }
    get TEMPLATE_NAME(): FieldInfo{  
        return new FieldInfo('templateName','模板名称');
    }
    get INDICATORS_CODE(): FieldInfo{  
        return new FieldInfo('indicatorsCode','指标编码');
    }
    get PERIOD(): FieldInfo{  
        return new FieldInfo('period','周期');
    }
    get STATISTICS(): FieldInfo{  
        return new FieldInfo('statistics','统计项目');
    }
    get RELATION(): FieldInfo{  
        return new FieldInfo('relation','大小关系');
    }
    get THRESHOLD(): FieldInfo{  
        return new FieldInfo('threshold','阈值');
    }
}

@Singleton 
class MonitorRuleSettingMU extends TableUtilImpl<MonitorRuleSettingCU,MonitorRuleSetting>{ 
    tableName  = 'monitor_rule_setting';
    tableFields  = ['id','template_id','alarm_level','enable','deleted','changed','create_time','update_time'];
    modelFields  = ['id','templateId','alarmLevel','enable','deleted','changed','createTime','updateTime','templateName','indicatorsCode','period','statistics','relation','threshold'];
    modelIdFields  = ['id'];
    tableIdFields  = ['id'];
    idType = IdType.CUSTOM;
    joinTables = [{
            joinByDefault: true,
            foreignKeyFields: [MonitorRuleSettingMU.TEMPLATE_ID],
            joinIdFields: [MonitorRuleTemplateMU.ID],
            getTableUtil: ()=>{
                return Container.get(MonitorRuleTemplateMU);
            },
            fields: [
                {
                    fieldUtil: MonitorRuleTemplateMU.TEMPLATE_NAME,
                    alias: 'templateName'
                }
                ,{
                    fieldUtil: MonitorRuleTemplateMU.INDICATORS_CODE,
                    alias: 'indicatorsCode'
                }
                ,{
                    fieldUtil: MonitorRuleTemplateMU.PERIOD,
                    alias: 'period'
                }
                ,{
                    fieldUtil: MonitorRuleTemplateMU.STATISTICS,
                    alias: 'statistics'
                }
                ,{
                    fieldUtil: MonitorRuleTemplateMU.RELATION,
                    alias: 'relation'
                }
                ,{
                    fieldUtil: MonitorRuleTemplateMU.THRESHOLD,
                    alias: 'threshold'
                }
            ]

        } as JoinTable

];
    subTables = [{
            name: 'monitorRulesettingServiceRel',
            parentIdFields: [MonitorRuleSettingMU.ID,MonitorRuleSettingMU.DELETED],
            foreignKeyFields: [MonitorRulesettingServiceRelMU.SETTING_ID,MonitorRulesettingServiceRelMU.DELETED],
            getTableUtil: ()=>{
                return Container.get(MonitorRulesettingServiceRelMU);
            }
        } as SubTable

        ,{
            name: 'monitorRulesettingContactRel',
            parentIdFields: [MonitorRuleSettingMU.ID,MonitorRuleSettingMU.DELETED],
            foreignKeyFields: [MonitorRulesettingContactRelMU.SETTING_ID,MonitorRulesettingContactRelMU.DELETED],
            getTableUtil: ()=>{
                return Container.get(MonitorRulesettingContactRelMU);
            }
        } as SubTable

];

    createConditionUtil(): MonitorRuleSettingCU {
        return new MonitorRuleSettingCUImpl();
    }   

    static get ID(): FieldUtil<MonitorRuleSettingCU>{ 
        return new FieldUtil('id','id','主键', new MonitorRuleSettingCUImpl());
    }
    static get TEMPLATE_ID(): FieldUtil<MonitorRuleSettingCU>{ 
        return new FieldUtil('template_id','templateId','模板名称', new MonitorRuleSettingCUImpl());
    }
    static get ALARM_LEVEL(): FieldUtil<MonitorRuleSettingCU>{ 
        return new FieldUtil('alarm_level','alarmLevel','报警级别', new MonitorRuleSettingCUImpl());
    }
    static get ENABLE(): FieldUtil<MonitorRuleSettingCU>{ 
        return new FieldUtil('enable','enable','是否启用', new MonitorRuleSettingCUImpl());
    }
    static get DELETED(): FieldUtil<MonitorRuleSettingCU>{ 
        return new FieldUtil('deleted','deleted','deleted', new MonitorRuleSettingCUImpl());
    }
    static get CHANGED(): FieldUtil<MonitorRuleSettingCU>{ 
        return new FieldUtil('changed','changed','是否变更', new MonitorRuleSettingCUImpl());
    }
    static get CREATE_TIME(): FieldUtil<MonitorRuleSettingCU>{ 
        return new FieldUtil('create_time','createTime','create_time', new MonitorRuleSettingCUImpl());
    }
    static get UPDATE_TIME(): FieldUtil<MonitorRuleSettingCU>{ 
        return new FieldUtil('update_time','updateTime','update_time', new MonitorRuleSettingCUImpl());
    }
    static get TEMPLATE_NAME(): FieldInfo{  
        return new FieldInfo('templateName','模板名称');
    }
    static get INDICATORS_CODE(): FieldInfo{  
        return new FieldInfo('indicatorsCode','指标编码');
    }
    static get PERIOD(): FieldInfo{  
        return new FieldInfo('period','周期');
    }
    static get STATISTICS(): FieldInfo{  
        return new FieldInfo('statistics','统计项目');
    }
    static get RELATION(): FieldInfo{  
        return new FieldInfo('relation','大小关系');
    }
    static get THRESHOLD(): FieldInfo{  
        return new FieldInfo('threshold','阈值');
    }

    get ID(): FieldUtil<MonitorRuleSettingCU>{ 
        return MonitorRuleSettingMU.ID;
    }
    get TEMPLATE_ID(): FieldUtil<MonitorRuleSettingCU>{ 
        return MonitorRuleSettingMU.TEMPLATE_ID;
    }
    get ALARM_LEVEL(): FieldUtil<MonitorRuleSettingCU>{ 
        return MonitorRuleSettingMU.ALARM_LEVEL;
    }
    get ENABLE(): FieldUtil<MonitorRuleSettingCU>{ 
        return MonitorRuleSettingMU.ENABLE;
    }
    get DELETED(): FieldUtil<MonitorRuleSettingCU>{ 
        return MonitorRuleSettingMU.DELETED;
    }
    get CHANGED(): FieldUtil<MonitorRuleSettingCU>{ 
        return MonitorRuleSettingMU.CHANGED;
    }
    get CREATE_TIME(): FieldUtil<MonitorRuleSettingCU>{ 
        return MonitorRuleSettingMU.CREATE_TIME;
    }
    get UPDATE_TIME(): FieldUtil<MonitorRuleSettingCU>{ 
        return MonitorRuleSettingMU.UPDATE_TIME;
    }
    get TEMPLATE_NAME(): FieldInfo{  
        return MonitorRuleSettingMU.TEMPLATE_NAME;
    }
    get INDICATORS_CODE(): FieldInfo{  
        return MonitorRuleSettingMU.INDICATORS_CODE;
    }
    get PERIOD(): FieldInfo{  
        return MonitorRuleSettingMU.PERIOD;
    }
    get STATISTICS(): FieldInfo{  
        return MonitorRuleSettingMU.STATISTICS;
    }
    get RELATION(): FieldInfo{  
        return MonitorRuleSettingMU.RELATION;
    }
    get THRESHOLD(): FieldInfo{  
        return MonitorRuleSettingMU.THRESHOLD;
    }
}
export {MonitorRuleSettingMU, MonitorRuleSettingCU}
