Search in sources :

Example 1 with ConfigCode

use of com.luastar.swift.tools.enums.ConfigCode in project swift by luastar.

the class H2Utils method getPubConfigMap.

/**
 * 获取一组配置信息
 *
 * @param groupCode
 * @return
 */
public static Map<ConfigCode, PubConfig> getPubConfigMap(ConfigGroupCode groupCode) {
    try {
        if (groupCode == null) {
            return null;
        }
        String sql = "SELECT * FROM PUB_CONFIG WHERE GROUP_CODE=?";
        List<PubConfig> configList = getInstance().getQueryRunner().query(sql, new BeanListHandler<>(PubConfig.class), groupCode.getGroupCode());
        if (ObjUtils.isEmpty(configList)) {
            return null;
        }
        Map<ConfigCode, PubConfig> resMap = Maps.newHashMap();
        for (PubConfig config : configList) {
            ConfigCode configCode = ConfigCode.parse(config.getConfig_code());
            if (configCode == null) {
                continue;
            }
            resMap.put(configCode, config);
        }
        return resMap;
    } catch (Exception e) {
        logger.error("获取常用配置异常:" + e.getMessage(), e);
        return null;
    }
}
Also used : ConfigCode(com.luastar.swift.tools.enums.ConfigCode) PubConfig(com.luastar.swift.tools.model.gui.PubConfig) SQLException(java.sql.SQLException)

Example 2 with ConfigCode

use of com.luastar.swift.tools.enums.ConfigCode in project swift by luastar.

the class MybatisController method initDefaultValue.

/**
 * 设置默认值
 */
private void initDefaultValue() {
    Map<ConfigCode, PubConfig> configMap = H2Utils.getPubConfigMap(ConfigGroupCode.mybatis);
    if (ObjUtils.isEmpty(configMap)) {
        return;
    }
    // 设置默认的数据库
    dbIdCofig = configMap.get(ConfigCode.mybatis_db_id);
    setDbChoiceBoxValue();
    // 设置默认的输出目录
    PubConfig outputConfig = configMap.get(ConfigCode.mybatis_output);
    if (outputConfig != null) {
        outputTextField.setText(outputConfig.getData_content());
    }
    // 设置包名
    PubConfig modelConfig = configMap.get(ConfigCode.mybatis_model_package);
    if (modelConfig != null) {
        modelTextField.setText(modelConfig.getData_content());
    }
    PubConfig daoConfig = configMap.get(ConfigCode.mybatis_dao_package);
    if (daoConfig != null) {
        daoTextField.setText(daoConfig.getData_content());
    }
}
Also used : ConfigCode(com.luastar.swift.tools.enums.ConfigCode) PubConfig(com.luastar.swift.tools.model.gui.PubConfig)

Aggregations

ConfigCode (com.luastar.swift.tools.enums.ConfigCode)2 PubConfig (com.luastar.swift.tools.model.gui.PubConfig)2 SQLException (java.sql.SQLException)1