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

import {AdMaterialDetailMU} from './AdMaterialDetail' 


/**
 * @author auto generate
 * @version 1.0
 * @date 2021-05-28 10:30
 */
interface AdMaterialCU extends ConditionUtil<AdMaterialCU>{
    ID:FieldUtil<AdMaterialCU>;
    AD_STYLE_ID:FieldUtil<AdMaterialCU>;
    NAME:FieldUtil<AdMaterialCU>;
    STATUS:FieldUtil<AdMaterialCU>;
    CREATE_TIME:FieldUtil<AdMaterialCU>;
    CREATOR:FieldUtil<AdMaterialCU>;
    UPDATE_TIME:FieldUtil<AdMaterialCU>;
    UPDATOR:FieldUtil<AdMaterialCU>;
}

class AdMaterialCUImpl extends ConditionUtilImpl<AdMaterialCUImpl> implements AdMaterialCU{ 
    newInstance(): AdMaterialCUImpl {
        return new AdMaterialCUImpl();
    } 
    get ID(): FieldUtil<AdMaterialCU>{  
        return new FieldUtil('id','id','素材id', this);
    }
    get AD_STYLE_ID(): FieldUtil<AdMaterialCU>{  
        return new FieldUtil('ad_style_id','adStyleId','广告样式id', this);
    }
    get NAME(): FieldUtil<AdMaterialCU>{  
        return new FieldUtil('name','name','素材名称', this);
    }
    get STATUS(): FieldUtil<AdMaterialCU>{  
        return new FieldUtil('status','status','状态：0，启用；1，删除', this);
    }
    get CREATE_TIME(): FieldUtil<AdMaterialCU>{  
        return new FieldUtil('create_time','createTime','', this);
    }
    get CREATOR(): FieldUtil<AdMaterialCU>{  
        return new FieldUtil('creator','creator','', this);
    }
    get UPDATE_TIME(): FieldUtil<AdMaterialCU>{  
        return new FieldUtil('update_time','updateTime','', this);
    }
    get UPDATOR(): FieldUtil<AdMaterialCU>{  
        return new FieldUtil('updator','updator','', this);
    }
}

@Singleton 
class AdMaterialMU extends TableUtilImpl<AdMaterialCU,AdMaterial>{ 
    tableName  = 'ad_material';
    tableFields  = ['id','ad_style_id','name','status','create_time','creator','update_time','updator'];
    modelFields  = ['id','adStyleId','name','status','createTime','creator','updateTime','updator'];
    modelIdFields  = ['id'];
    tableIdFields  = ['id'];
    idType = IdType.CUSTOM;
    joinTables = [];
    subTables = [{
            name: 'adMaterialDetail',
            parentIdFields: [AdMaterialMU.ID],
            foreignKeyFields: [AdMaterialDetailMU.AD_MATERIAL_ID],
            getTableUtil: ()=>{
                return Container.get(AdMaterialDetailMU);
            }
        } as SubTable

];

    createConditionUtil(): AdMaterialCU {
        return new AdMaterialCUImpl();
    }   

    static get ID(): FieldUtil<AdMaterialCU>{ 
        return new FieldUtil('id','id','素材id', new AdMaterialCUImpl());
    }
    static get AD_STYLE_ID(): FieldUtil<AdMaterialCU>{ 
        return new FieldUtil('ad_style_id','adStyleId','广告样式id', new AdMaterialCUImpl());
    }
    static get NAME(): FieldUtil<AdMaterialCU>{ 
        return new FieldUtil('name','name','素材名称', new AdMaterialCUImpl());
    }
    static get STATUS(): FieldUtil<AdMaterialCU>{ 
        return new FieldUtil('status','status','状态：0，启用；1，删除', new AdMaterialCUImpl());
    }
    static get CREATE_TIME(): FieldUtil<AdMaterialCU>{ 
        return new FieldUtil('create_time','createTime','', new AdMaterialCUImpl());
    }
    static get CREATOR(): FieldUtil<AdMaterialCU>{ 
        return new FieldUtil('creator','creator','', new AdMaterialCUImpl());
    }
    static get UPDATE_TIME(): FieldUtil<AdMaterialCU>{ 
        return new FieldUtil('update_time','updateTime','', new AdMaterialCUImpl());
    }
    static get UPDATOR(): FieldUtil<AdMaterialCU>{ 
        return new FieldUtil('updator','updator','', new AdMaterialCUImpl());
    }

    get ID(): FieldUtil<AdMaterialCU>{ 
        return AdMaterialMU.ID;
    }
    get AD_STYLE_ID(): FieldUtil<AdMaterialCU>{ 
        return AdMaterialMU.AD_STYLE_ID;
    }
    get NAME(): FieldUtil<AdMaterialCU>{ 
        return AdMaterialMU.NAME;
    }
    get STATUS(): FieldUtil<AdMaterialCU>{ 
        return AdMaterialMU.STATUS;
    }
    get CREATE_TIME(): FieldUtil<AdMaterialCU>{ 
        return AdMaterialMU.CREATE_TIME;
    }
    get CREATOR(): FieldUtil<AdMaterialCU>{ 
        return AdMaterialMU.CREATOR;
    }
    get UPDATE_TIME(): FieldUtil<AdMaterialCU>{ 
        return AdMaterialMU.UPDATE_TIME;
    }
    get UPDATOR(): FieldUtil<AdMaterialCU>{ 
        return AdMaterialMU.UPDATOR;
    }
}
export {AdMaterialMU, AdMaterialCU}
