TableInfo { public void processTable(StrategyConfig strategyConfig, GlobalConfig globalConfig) { String entityName = strategyConfig.getNameConvert().entityNameConvert(this); this.setEntityName(strategyConfig, this.getFileName(entityName, globalConfig.getEntityName(), () -> entityName)); this.mapperName = this.getFileName(entityName, globalConfig.getMapperName(), () -> entityName + ConstVal.MAPPER); this.xmlName = this.getFileName(entityName, globalConfig.getXmlName(), () -> entityName + ConstVal.XML); this.serviceName = this.getFileName(entityName, globalConfig.getServiceName(), () -> "I" + entityName + ConstVal.SERVICE); this.serviceImplName = this.getFileName(entityName, globalConfig.getServiceImplName(), () -> entityName + ConstVal.SERVICE_IMPL); this.controllerName = this.getFileName(entityName, globalConfig.getControllerName(), () -> entityName + ConstVal.CONTROLLER); this.importPackage(strategyConfig, globalConfig); }  @Deprecated TableInfo setConvert(boolean convert); String getEntityPath(); @Deprecated TableInfo setEntityName(String entityName); TableInfo setEntityName(StrategyConfig strategyConfig, String entityName); @Deprecated TableInfo setFields(List<TableField> fields); TableInfo addFields(List<TableField> fields); TableInfo addFields(TableField... fields); @Deprecated TableInfo setImportPackages(String pkg); TableInfo addImportPackages(String... pkgs); boolean isLogicDelete(String logicDeletePropertyName); @Deprecated TableInfo setFieldNames(String fieldNames); String getFieldNames(); @Deprecated TableInfo setCommonFields(List<TableField> commonFields); TableInfo addCommonFields(TableField... commonFields); TableInfo addCommonFields(List<TableField> commonFields); void importPackage(StrategyConfig strategyConfig, GlobalConfig globalConfig); void processTable(StrategyConfig strategyConfig, GlobalConfig globalConfig); String getFileName(String entityName, String value, Supplier<String> defaultValue);  }
@Test void processTableTest() { TableInfo tableInfo = new TableInfo().setName("user"); tableInfo.processTable(new StrategyConfig(), new GlobalConfig()); Assertions.assertFalse(tableInfo.isConvert()); Assertions.assertEquals("UserMapper", tableInfo.getMapperName()); Assertions.assertEquals("UserXml", tableInfo.getXmlName()); Assertions.assertEquals("IUserService", tableInfo.getServiceName()); Assertions.assertEquals("UserServiceImpl", tableInfo.getServiceImplName()); Assertions.assertEquals("UserController", tableInfo.getControllerName()); tableInfo = new TableInfo().setName("user"); tableInfo.processTable(new StrategyConfig(), new GlobalConfig().setEntityName("%sEntity") .setXmlName("%sXml").setMapperName("%sDao").setControllerName("%sAction").setServiceName("%sService").setServiceImplName("%sServiceImp")); Assertions.assertTrue(tableInfo.isConvert()); Assertions.assertEquals("UserEntity", tableInfo.getEntityName()); Assertions.assertEquals("UserDao", tableInfo.getMapperName()); Assertions.assertEquals("UserXml", tableInfo.getXmlName()); Assertions.assertEquals("UserService", tableInfo.getServiceName()); Assertions.assertEquals("UserServiceImp", tableInfo.getServiceImplName()); Assertions.assertEquals("UserAction", tableInfo.getControllerName()); tableInfo = new TableInfo().setName("user"); tableInfo.processTable(new StrategyConfig().setNameConvert(new INameConvert() { @Override public String entityNameConvert(TableInfo tableInfo) { return "E" + tableInfo.getName(); } @Override public String propertyNameConvert(TableField field) { return field.getName(); } }), new GlobalConfig()); Assertions.assertTrue(tableInfo.isConvert()); Assertions.assertEquals("Euser", tableInfo.getEntityName()); }