Commit d6a7578c authored by 刘凯's avatar 刘凯

增加remote remoteImpl等生成文件

parent 6eec11b4
...@@ -18,7 +18,7 @@ apply plugin: "idea" ...@@ -18,7 +18,7 @@ apply plugin: "idea"
apply plugin: "eclipse" apply plugin: "eclipse"
group = "cn.com.duiba" group = "cn.com.duiba"
version = "0.2.0" version = "0.2.10"
sourceCompatibility = 1.8 sourceCompatibility = 1.8
targetCompatibility = 1.8 targetCompatibility = 1.8
......
...@@ -42,30 +42,36 @@ public class MybatisGenerator { ...@@ -42,30 +42,36 @@ public class MybatisGenerator {
} catch (SQLException e) { } catch (SQLException e) {
throw new DuibaGeneratorException(e); throw new DuibaGeneratorException(e);
} }
//生成dto文件
JavaDtoGenerator dtoGenerator = new JavaDtoGenerator(freemarkerService, tableEntity, config);
dtoGenerator.gen();
//生成entity文件 //生成entity文件
if(StringUtils.isNotBlank(config.getEntityPackage())) {
JavaEntityGenerator doGenerator = new JavaEntityGenerator(freemarkerService, tableEntity, config); JavaEntityGenerator doGenerator = new JavaEntityGenerator(freemarkerService, tableEntity, config);
doGenerator.gen(); doGenerator.gen();
}
//生成dao文件 //生成dao文件
if(StringUtils.isNotBlank(config.getDaoPackage())) {
JavaDaoGenerator daoGenerator = new JavaDaoGenerator(freemarkerService, tableEntity, config); JavaDaoGenerator daoGenerator = new JavaDaoGenerator(freemarkerService, tableEntity, config);
daoGenerator.gen(); daoGenerator.gen();
}
//生成daoImpl文件 //生成daoImpl文件
if(StringUtils.isNotBlank(config.getDaoPackage())) {
JavaDaoImplGenerator daoImplGenerator = new JavaDaoImplGenerator(freemarkerService, tableEntity, config); JavaDaoImplGenerator daoImplGenerator = new JavaDaoImplGenerator(freemarkerService, tableEntity, config);
daoImplGenerator.gen(); daoImplGenerator.gen();
}
//生成remote接口文件 //生成remote接口文件
JavaRemoteServiceInterfaceGenerator remoteInterfaceGenerator = new JavaRemoteServiceInterfaceGenerator(freemarkerService, tableEntity, config); if(StringUtils.isNotBlank(config.getRemoteImplLocation())) {
remoteInterfaceGenerator.gen();
//生成remoteImpl接口文件
JavaRemoteServiceInterfaceImplGenerator remoteImplGenerator = new JavaRemoteServiceInterfaceImplGenerator(freemarkerService, tableEntity, config); JavaRemoteServiceInterfaceImplGenerator remoteImplGenerator = new JavaRemoteServiceInterfaceImplGenerator(freemarkerService, tableEntity, config);
remoteImplGenerator.gen(); remoteImplGenerator.gen();
}
//生成Service接口文件 //生成Service接口文件
if(StringUtils.isNotBlank(config.getServiceLocation())) {
JavaServiceInterfaceGenerator serviceInterfaceGenerator = new JavaServiceInterfaceGenerator(freemarkerService, tableEntity, config); JavaServiceInterfaceGenerator serviceInterfaceGenerator = new JavaServiceInterfaceGenerator(freemarkerService, tableEntity, config);
serviceInterfaceGenerator.gen(); serviceInterfaceGenerator.gen();
}
//生成ServiceImpl接口文件 //生成ServiceImpl接口文件
if(StringUtils.isNotBlank(config.getServiceImplLocation())) {
JavaServiceInterfaceImplGenerator serviceImplGenerator = new JavaServiceInterfaceImplGenerator(freemarkerService, tableEntity, config); JavaServiceInterfaceImplGenerator serviceImplGenerator = new JavaServiceInterfaceImplGenerator(freemarkerService, tableEntity, config);
serviceImplGenerator.gen(); serviceImplGenerator.gen();
}
//生成web层-Controller接口文件 //生成web层-Controller接口文件
// JavaControllerImplGenerator controllerGenerator = new JavaControllerImplGenerator(freemarkerService, tableEntity, config); // JavaControllerImplGenerator controllerGenerator = new JavaControllerImplGenerator(freemarkerService, tableEntity, config);
// controllerGenerator.gen(); // controllerGenerator.gen();
...@@ -75,9 +81,25 @@ public class MybatisGenerator { ...@@ -75,9 +81,25 @@ public class MybatisGenerator {
voImplGenerator.gen(); voImplGenerator.gen();
} }
//生成xml文件 //生成xml文件
if(StringUtils.isNotBlank(config.getXmlLocation())){
SQLXmlGenerator sqlXmlGenerator = new SQLXmlGenerator(freemarkerService, tableEntity, config); SQLXmlGenerator sqlXmlGenerator = new SQLXmlGenerator(freemarkerService, tableEntity, config);
sqlXmlGenerator.gen(); sqlXmlGenerator.gen();
} }
if(StringUtils.isNotBlank(config.getApiModuleName())){
config.setModuleName(config.getApiModuleName());
}
//生成dto文件
if(StringUtils.isNotBlank(config.getDtoPackage())) {
JavaDtoGenerator dtoGenerator = new JavaDtoGenerator(freemarkerService, tableEntity, config);
dtoGenerator.gen();
}
//生成remoteImpl接口文件
if(StringUtils.isNotBlank(config.getRemotePackage())) {
JavaRemoteServiceInterfaceGenerator remoteInterfaceGenerator = new JavaRemoteServiceInterfaceGenerator(freemarkerService, tableEntity, config);
remoteInterfaceGenerator.gen();
}
}
private static void check(GeneratorConfig config) { private static void check(GeneratorConfig config) {
if (config == null){ if (config == null){
......
...@@ -58,6 +58,11 @@ public class GeneratorConfig { ...@@ -58,6 +58,11 @@ public class GeneratorConfig {
*/ */
private String moduleName; private String moduleName;
/**
* 模块名称
*/
private String apiModuleName;
/** /**
* true:以测试用例执行生成代码的方式 * true:以测试用例执行生成代码的方式
*/ */
...@@ -135,14 +140,17 @@ public class GeneratorConfig { ...@@ -135,14 +140,17 @@ public class GeneratorConfig {
if (StringUtils.isEmpty(serviceImplLocation)) { if (StringUtils.isEmpty(serviceImplLocation)) {
throw new DuibaGeneratorException("serviceImplLocation is null"); throw new DuibaGeneratorException("serviceImplLocation is null");
} }
if (StringUtils.isEmpty(voLocation)) {
throw new DuibaGeneratorException("voLocation is null");
} }
if (StringUtils.isEmpty(controllerLocation)) {
throw new DuibaGeneratorException("controllerLocation is null");
} }
public String getApiModuleName() {
return apiModuleName;
} }
public void setApiModuleName(String apiModuleName) {
this.apiModuleName = apiModuleName;
} }
public String getTablePrefix() { public String getTablePrefix() {
......
...@@ -23,7 +23,7 @@ public class ${table.className}DaoImpl extends BaseDao implements ${table.classN ...@@ -23,7 +23,7 @@ public class ${table.className}DaoImpl extends BaseDao implements ${table.classN
@Override @Override
public Integer save(${table.className}Entity ${table.classname}Entity){ public Integer save(${table.className}Entity ${table.classname}Entity){
insert("save",${table.classname}Entity); insert("save",${table.classname}Entity);
return ${table.classname}Entity.getId(); return ${table.classname}Entity.getId() > 0 ? 1 : 0;
} }
<#if pk??> <#if pk??>
...@@ -37,33 +37,39 @@ public class ${table.className}DaoImpl extends BaseDao implements ${table.classN ...@@ -37,33 +37,39 @@ public class ${table.className}DaoImpl extends BaseDao implements ${table.classN
@Override @Override
public void deleteBatchBy${pk.attrName}s(List<${pk.attrType}> ${pk.attrname}s){ public void deleteBatchBy${pk.attrName}s(List<${pk.attrType}> ${pk.attrname}s){
return 0; Map data = Maps.newHashMap();
data.put("${pk.attrName}s",${pk.attrname}s);
delete("deleteBatchBy${pk.attrName}",data);
} }
@Override @Override
public Integer updateBy${pk.attrName}(${table.className}Entity ${table.classname}Entity){ public Integer updateBy${pk.attrName}(${table.className}Entity ${table.classname}Entity){
return 0; return update("updateBy${pk.attrName}",${table.classname}Entity);
} }
@Override @Override
public ${table.className}Entity getBy${pk.attrName}(${pk.attrType} ${pk.attrname}){ public ${table.className}Entity getBy${pk.attrName}(${pk.attrType} ${pk.attrname}){
return null; return selectOne("getBy${pk.attrName}",${pk.attrname});
} }
@Override @Override
public List<${table.className}Entity> listBy${pk.attrName}s(List<${pk.attrType}> ${pk.attrname}s){ public List<${table.className}Entity> listBy${pk.attrName}s(List<${pk.attrType}> ${pk.attrname}s){
return null; Map data = Maps.newHashMap();
data.put("${pk.attrname}s",${pk.attrname}s);
return selectList("listBy${pk.attrName}s",data);
} }
</#if> </#if>
<#list uks?keys as key> <#list uks?keys as key>
@Override @Override
public ${table.className}Entity getBy${key}(<#assign idx=0><#list uks[key] as uk>${uk.attrType} ${uk.attrname}<#assign idx=idx+1><#if (idx<uks[key]?size)>,</#if></#list>){ public ${table.className}Entity getBy${key}(<#assign idx=0><#list uks[key] as uk>${uk.attrType} ${uk.attrname}<#assign idx=idx+1><#if (idx<uks[key]?size)>,</#if></#list>){
//todo
return null; return null;
} }
@Override @Override
public List<${table.className}Entity> listBy${key}s(<#assign idx=0><#list uks[key] as uk>List<${uk.attrType}> ${uk.attrname}s<#assign idx=idx+1><#if (idx<uks[key]?size)>,</#if></#list>){ public List<${table.className}Entity> listBy${key}s(<#assign idx=0><#list uks[key] as uk>List<${uk.attrType}> ${uk.attrname}s<#assign idx=idx+1><#if (idx<uks[key]?size)>,</#if></#list>){
//todo
return null; return null;
} }
......
...@@ -23,6 +23,7 @@ import java.io.Serializable; ...@@ -23,6 +23,7 @@ import java.io.Serializable;
</#if> </#if>
public class ${table.className}Dto implements Serializable { public class ${table.className}Dto implements Serializable {
private static final long serialVersionUID = 8065426618925769915L;
<#list columns as column> <#list columns as column>
......
...@@ -11,9 +11,9 @@ public interface Remote${table.className}Service { ...@@ -11,9 +11,9 @@ public interface Remote${table.className}Service {
Integer save(${table.className}Dto ${table.classname}Dto) throws BizException; Integer save(${table.className}Dto ${table.classname}Dto) throws BizException;
<#if pk??> <#if pk??>
Integer deleteBy${pk.attrName}(${pk.attrType} ${pk.attrname}) throws BizException; void deleteBy${pk.attrName}(${pk.attrType} ${pk.attrname}) throws BizException;
Integer deleteBatchBy${pk.attrName}s(List<${pk.attrType}> ${pk.attrname}s) throws BizException; void deleteBatchBy${pk.attrName}s(List<${pk.attrType}> ${pk.attrname}s) throws BizException;
Integer updateBy${pk.attrName}(${table.className}Dto ${table.classname}Dto) throws BizException; Integer updateBy${pk.attrName}(${table.className}Dto ${table.classname}Dto) throws BizException;
......
...@@ -25,13 +25,13 @@ public class Remote${table.className}ServiceImpl implements Remote${table.classN ...@@ -25,13 +25,13 @@ public class Remote${table.className}ServiceImpl implements Remote${table.classN
<#if pk??> <#if pk??>
@Override @Override
public Integer deleteBy${pk.attrName}(${pk.attrType} ${pk.attrname}){ public void deleteBy${pk.attrName}(${pk.attrType} ${pk.attrname}){
return ${table.classname}Service.deleteBy${pk.attrName}(${pk.attrname}); ${table.classname}Service.deleteBy${pk.attrName}(${pk.attrname});
} }
@Override @Override
public Integer deleteBatchBy${pk.attrName}s(List<${pk.attrType}> ${pk.attrname}s){ public void deleteBatchBy${pk.attrName}s(List<${pk.attrType}> ${pk.attrname}s){
return ${table.classname}Service.deleteBatchBy${pk.attrName}(${pk.attrname}s); ${table.classname}Service.deleteBatchBy${pk.attrName}(${pk.attrname}s);
} }
@Override @Override
......
...@@ -9,9 +9,9 @@ public interface ${table.className}Service { ...@@ -9,9 +9,9 @@ public interface ${table.className}Service {
Integer save(${table.className}Dto ${table.classname}Dto); Integer save(${table.className}Dto ${table.classname}Dto);
<#if pk??> <#if pk??>
Integer deleteBy${pk.attrName}(${pk.attrType} ${pk.attrname}); void deleteBy${pk.attrName}(${pk.attrType} ${pk.attrname});
Integer deleteBatchBy${pk.attrName}s(List<${pk.attrType}> ${pk.attrname}s); void deleteBatchBy${pk.attrName}s(List<${pk.attrType}> ${pk.attrname}s);
Integer updateBy${pk.attrName}(${table.className}Dto ${table.classname}Dto); Integer updateBy${pk.attrName}(${table.className}Dto ${table.classname}Dto);
......
...@@ -29,13 +29,13 @@ public class ${table.className}ServiceImpl implements ${table.className}Service{ ...@@ -29,13 +29,13 @@ public class ${table.className}ServiceImpl implements ${table.className}Service{
<#if pk??> <#if pk??>
@Override @Override
public Integer deleteBy${pk.attrName}(${pk.attrType} ${pk.attrname}){ public void deleteBy${pk.attrName}(${pk.attrType} ${pk.attrname}){
return ${table.classname}Dao.deleteBy${pk.attrName}(${pk.attrname}); ${table.classname}Dao.deleteBy${pk.attrName}(${pk.attrname});
} }
@Override @Override
public Integer deleteBatchBy${pk.attrName}s(List<${pk.attrType}> ${pk.attrname}s){ public void deleteBatchBy${pk.attrName}s(List<${pk.attrType}> ${pk.attrname}s){
return ${table.classname}Dao.deleteBatchBy${pk.attrName}(${pk.attrname}s); ${table.classname}Dao.deleteBatchBy${pk.attrName}s(${pk.attrname}s);
} }
@Override @Override
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment