MybatisPlus自定义类型转换

MybatisPlus自定义类型转换

自定义类型转换

(tinyint转换为Boolean)

    /*数据源配置*/
    DataSourceConfig dsc = new DataSourceConfig();
    dsc.setTypeConvert(new MySqlTypeConvertCustom());
    class MySqlTypeConvertCustom extends MySqlTypeConvert implements ITypeConvert {
        @Override
        public IColumnType processTypeConvert(GlobalConfig globalConfig, String fieldType) {
            String t = fieldType.toLowerCase();
            if (t.contains("tinyint")) {
                return DbColumnType.INTEGER;
            }
            return super.processTypeConvert(globalConfig, fieldType);
        }
    }