package com.bohuikeji.frame.module.admin.entity.configure;

import com.bohuikeji.frame.module.admin.annotation.TableKeyField;
import com.bohuikeji.frame.module.admin.base.SuperBase;
import com.bohuikeji.frame.module.admin.utils.ReflectUtil;
import lombok.Data;

/**
 * 外键配置
 * @author 10552
 */
@Data
public class KeyAn extends SuperBase {
    String table;
    String where;
    String[] keyShowFields;
    String[] keyLikeFields;
    String split;

    public static KeyAn getInstance(TableKeyField keyField){
        if(keyField==null){return null;}
        KeyAn keyAn=new KeyAn();
        if("".equals(keyField.table())){
            keyAn.setTable(ReflectUtil.getTableName(keyField.key()));
        }
        else{
            keyAn.setTable(keyField.table());
        }
        keyAn.setTable(keyField.table());
        keyAn.setWhere(keyField.where());
        keyAn.setKeyShowFields(keyField.keyShowFields());
        keyAn.setKeyLikeFields(keyField.keyLikeFields());
        keyAn.setSplit(keyField.symbol());
        return keyAn;
    }
}
