Commit c87be97d by yubaogu

tett

parent b1a82e7b
...@@ -10,6 +10,7 @@ import ${entityUrl}.${entityName}; ...@@ -10,6 +10,7 @@ import ${entityUrl}.${entityName};
import ${facadeUrl}.${entityName}Facade; import ${facadeUrl}.${entityName}Facade;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import com.alibaba.dubbo.config.annotation.Reference;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import com.github.pagehelper.IPage; import com.github.pagehelper.IPage;
<#if isSwagger=="true" > <#if isSwagger=="true" >
...@@ -25,91 +26,91 @@ import io.swagger.annotations.Api; ...@@ -25,91 +26,91 @@ import io.swagger.annotations.Api;
* *
*/ */
<#if isSwagger=="true" > <#if isSwagger=="true" >
@Api(description = "${tableInfo.tableName}",value="${tableInfo.tableName}" ) @Api(description = "${tableInfo.tableComment}控制器",value="${tableInfo.tableName}" )
</#if> </#if>
@RestController @RestController
@RequestMapping("/${objectName}") @RequestMapping("/${objectName}")
public class ${entityName}Controller extends AbstractController<${entityName}Service,${entityName}>{ public class ${entityName}Controller{
@Reference @Reference
protected ${entityName}Facade baseFacade; protected ${entityName}Facade baseFacade;
/** /**
* @explain 查询对象 <swagger GET请求> * @explain 查询对象 <swagger GET请求>
* @param 对象参数:id * @param 对象参数 id
* @return BaseDtoResponse * @return BaseDtoResponse
* @author ${author} * @author ${author}
* @time ${createTime} * @time ${createTime}
*/ */
@GetMapping("/getById/{id}") @GetMapping("/getById/{id}")
<#if isSwagger=="true" > <#if isSwagger=="true" >
@ApiOperation(value = "获取对象", notes = "作者:${author}") @ApiOperation(value = "获取对象", notes = "作者:${author}")
@ApiImplicitParam(paramType="path", name = "id", value = "对象id", required = true, dataType = "Long") @ApiImplicitParam(paramType="path", name = "id", value = "对象id", required = true, dataType = "Long")
</#if> </#if>
public BaseDtoResponse<${entityName}> getById(@PathVariable("id")Long id){ public BaseDtoResponse<${entityName}> getById(@PathVariable("id")Long id){
return null; return null;
} }
/** /**
* @explain 删除对象 * @explain 删除对象
* @param 对象参数:id * @param 对象参数 id
* @return BaseDtoResponse * @return BaseDtoResponse
* @author ${author} * @author ${author}
* @time ${createTime} * @time ${createTime}
*/ */
@PostMapping("/deleteById") @PostMapping("/deleteById")
<#if isSwagger=="true" > <#if isSwagger=="true" >
@ApiOperation(value = "删除", notes = "作者:${author}") @ApiOperation(value = "删除", notes = "作者:${author}")
@ApiImplicitParam(paramType="query", name = "id", value = "对象id", required = true, dataType = "Long") @ApiImplicitParam(paramType="query", name = "id", value = "对象id", required = true, dataType = "Long")
</#if> </#if>
public BaseDtoResponse<Boolean> deleteById(Long id){ public BaseDtoResponse<Boolean> deleteById(Long id){
return null; return null;
} }
/** /**
* @explain 添加 * @explain 添加
* @param 对象参数:${entityName} * @param 对象参数:${entityName}
* @return Boolean * @return Boolean
* @author ${author} * @author ${author}
* @time ${createTime} * @time ${createTime}
*/ */
@PostMapping("/insert") @PostMapping("/insert")
<#if isSwagger=="true" > <#if isSwagger=="true" >
@ApiOperation(value = "添加", notes = "作者:${author}") @ApiOperation(value = "添加", notes = "作者:${author}")
</#if> </#if>
public BaseDtoResponse<${entityName}> insert(${entityName} entity){ public BaseDtoResponse<${entityName}> insert(${entityName} entity){
return null; return null;
} }
/** /**
* @explain 修改 * @explain 修改
* @param 对象参数:${entityName} * @param 对象参数:${entityName}
* @return Boolean * @return Boolean
* @author ${author} * @author ${author}
* @time ${createTime} * @time ${createTime}
*/ */
@PostMapping("/update") @PostMapping("/update")
<#if isSwagger=="true" > <#if isSwagger=="true" >
@ApiOperation(value = "修改", notes = "作者:${author}") @ApiOperation(value = "修改", notes = "作者:${author}")
</#if> </#if>
public BaseDtoResponse<Boolean> update(${entityName} entity){ public BaseDtoResponse<Boolean> update(${entityName} entity){
return null; return null;
} }
/** /**
* @explain 分页条件查询用户 * @explain 分页条件查询用户
* @param 对象参数:PageableDto<${entityName}> * @param 对象参数 IPage<${entityName}>
* @return PageInfo<${entityName}> * @return PageInfo<${entityName}>
* @author ${author} * @author ${author}
* @time ${createTime} * @time ${createTime}
*/ */
@GetMapping("/getPages") @GetMapping("/getPages")
<#if isSwagger=="true" > <#if isSwagger=="true" >
@ApiOperation(value = "分页查询", notes = "分页查询返回[IPage<T>],作者:${author}") @ApiOperation(value = "分页查询", notes = "分页查询返回[IPage<T>],作者:${author}")
</#if> </#if>
public BaseDtoResponse<PageInfo<${entityName}>> getPages(IPage param){ public BaseDtoResponse<PageInfo<${entityName}>> getPages(IPage param){
return null; return null;
} }
} }
\ No newline at end of file
...@@ -16,6 +16,8 @@ import lombok.EqualsAndHashCode; ...@@ -16,6 +16,8 @@ import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors; import lombok.experimental.Accessors;
import org.springframework.format.annotation.DateTimeFormat; import org.springframework.format.annotation.DateTimeFormat;
import java.io.Serializable; import java.io.Serializable;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
<#list pkgs as ps> <#list pkgs as ps>
<#if ps??> <#if ps??>
import ${ps}; import ${ps};
...@@ -34,7 +36,7 @@ import ${ps}; ...@@ -34,7 +36,7 @@ import ${ps};
@Accessors(chain = true) @Accessors(chain = true)
public class ${entityName} implements Serializable{ public class ${entityName} implements Serializable{
private static final long serialVersionUID = ${agile}L; private static final long serialVersionUID = -1L;
<#list cis as ci> <#list cis as ci>
<#if ci.javaType=="Date"> <#if ci.javaType=="Date">
...@@ -54,15 +56,11 @@ public class ${entityName} implements Serializable{ ...@@ -54,15 +56,11 @@ public class ${entityName} implements Serializable{
@GeneratedValue(generator = "JDBC") @GeneratedValue(generator = "JDBC")
</#if> </#if>
<#if isSwagger=="true" > <#if isSwagger=="true" >
@ApiModelProperty(name = "${ci.property}" , value = "${ci.comment}") @ApiModelProperty(name = "${ci.property}" , value = "${ci.comment}")
</#if> </#if>
private ${ci.javaType} ${ci.property}; private ${ci.javaType} ${ci.property};
</#list> </#list>
@Override
protected Serializable pkVal() {
return this.id;
}
} }
\ No newline at end of file
...@@ -21,18 +21,18 @@ import com.github.pagehelper.IPage; ...@@ -21,18 +21,18 @@ import com.github.pagehelper.IPage;
*/ */
public interface ${entityName}Facade { public interface ${entityName}Facade {
public BaseDtoResponse<${entityName}> getById(Long id); BaseDtoResponse<${entityName}> getById(Long id);
public BaseDtoResponse<Boolean> deleteById(Long id); BaseDtoResponse<Boolean> deleteById(Long id);
public BaseDtoResponse<${entityName}> insert(${entityName} entity); BaseDtoResponse<${entityName}> insert(${entityName} entity);
public BaseDtoResponse<Boolean> update(${entityName} entity); BaseDtoResponse<Boolean> update(${entityName} entity);
public BaseDtoResponse<PageInfo<${entityName}>> getPages(IPage param); BaseDtoResponse<PageInfo<${entityName}>> getPages(IPage param);
} }
\ No newline at end of file
...@@ -4,15 +4,15 @@ ...@@ -4,15 +4,15 @@
* Copyright(c) 2018 ${author} Co. Ltd. * Copyright(c) 2018 ${author} Co. Ltd.
* All right reserved. * All right reserved.
*/ */
package ${serviceImplUrl}; package ${facadeImplUrl};
import ${entityUrl}.${entityName}; import ${entityUrl}.${entityName};
import ${facadeUrl}.${entityName}Facade; import ${facadeUrl}.${entityName}Facade;
import org.springframework.stereotype.Service;
import com.alibaba.dubbo.config.annotation.Service; import com.alibaba.dubbo.config.annotation.Service;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import com.github.pagehelper.IPage; import com.github.pagehelper.IPage;
import com.ydl.common.dto.BaseDtoResponse;
/** /**
* @Description:TODO(${entityComment}服务实现) * @Description:TODO(${entityComment}服务实现)
* *
...@@ -34,7 +34,7 @@ public class ${entityName}FacadeImpl implements ${entityName}Facade { ...@@ -34,7 +34,7 @@ public class ${entityName}FacadeImpl implements ${entityName}Facade {
} }
@Override @Override
public BaseDtoResponse<Doctor> insert(${entityName} entity) { public BaseDtoResponse<${entityName}> insert(${entityName} entity) {
return null; return null;
} }
......
...@@ -11,7 +11,6 @@ import ${daoUrl}.${entityName}Mapper; ...@@ -11,7 +11,6 @@ import ${daoUrl}.${entityName}Mapper;
import ${serviceUrl}.${entityName}Service; import ${serviceUrl}.${entityName}Service;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.ydl.common.service.impl.BaseService; import com.ydl.common.service.impl.BaseService;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example; import tk.mybatis.mapper.entity.Example;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
/** /**
......
...@@ -39,24 +39,41 @@ public class MyGenerator implements Serializable { ...@@ -39,24 +39,41 @@ public class MyGenerator implements Serializable {
public static final String DATABASE = "ydl"; public static final String DATABASE = "ydl";
// 类信息:类名、对象名(一般是【类名】的首字母小些)、类说明、时间 // 类信息:类名、对象名(一般是【类名】的首字母小些)、类说明、时间
public static final String TABLE = "doctor"; public static final String TABLE = "doctor";
public static final String[] TABLES = {"doctor"}; public static final String[] TABLES = {"user_emergency_contact"
public static final String CLASSCOMMENT = "专家"; };
/**
"doctor_base_data","doctor_order","doctor","expert_interview","expert_interview_result","expert_result",
"doctor_education","doctor_certificate","doctor_certification","doctor_handle_cfg",
"doctor_team_certification","doctor_certificate","doctor_spirit_qualification","doctor_spirit_qualification","doctor_training_background",
"config_role","doctor_template","doctor_honorary_title","doctor_honorary_title","doctor_ren_zhi_background","doctor_interview",
"doctor_examine","doctor_examine_type_info","doctor_examine_flow","doctor_examine_log","doctor_modify",
*/
public static final String CLASSCOMMENT = "专家";
public static final String TIME = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()); public static final String TIME = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
public static final String AGILE = new Date().getTime() + ""; public static final String AGILE = new Date().getTime() + "";
// 路径信息,分开路径方便聚合工程项目,微服务项目 // 路径信息,分开路径方便聚合工程项目,微服务项目
public static final String ENTITY_URL = "com.ydl.demo.po"; public static String ENTITY_URL = "com.ydl.*project*.po";
public static final String DAO_URL = "com.ydl.demo.mapper"; public static String DAO_URL = "com.ydl.*project*.mapper";
public static final String XML_URL = "com.ydl.demo.mapper.xml"; public static String XML_URL = "sqlmap\\";
public static final String SERVICE_URL = "com.ydl.demo.service"; public static String SERVICE_URL = "com.ydl.*project*.service";
public static final String SERVICE_IMPL_URL = "com.ydl.demo.service.impl"; public static String SERVICE_IMPL_URL = "com.ydl.*project*.service.impl";
public static final String FACADE_URL = "com.ydl.demo.facade"; public static String FACADE_URL = "com.ydl.*project*.facade";
public static final String FACADE_URL_IMPL = "com.ydl.demo.facade.impl"; public static String FACADE_URL_IMPL = "com.ydl.*project*.facade";
public static final String CONTROLLER_URL = "com.ydl.demo.api"; public static String CONTROLLER_URL = "com.ydl.*project*.api";
//是否是Swagger配置 //是否是Swagger配置
public static final String IS_SWAGGER = "false"; public static final String IS_SWAGGER = "true";
public static final String PROJECT_NAME = "user";
public static void main(String[] args) throws IOException { public static void main(String[] args) throws IOException {
System.out.println(MyGenerator.class.getResource("").getPath()); System.out.println(MyGenerator.class.getResource("").getPath());
ENTITY_URL = ENTITY_URL.replace("*project*",PROJECT_NAME);
DAO_URL = DAO_URL.replace("*project*",PROJECT_NAME);
SERVICE_URL = SERVICE_URL.replace("*project*",PROJECT_NAME);
SERVICE_IMPL_URL = SERVICE_IMPL_URL.replace("*project*",PROJECT_NAME);
FACADE_URL = FACADE_URL.replace("*project*",PROJECT_NAME);
FACADE_URL_IMPL = FACADE_URL_IMPL.replace("*project*",PROJECT_NAME);
CONTROLLER_URL = CONTROLLER_URL.replace("*project*",PROJECT_NAME);
BasisInfo bi = new BasisInfo(PROJECT, AUTHOR, VERSION, URL, NAME, PASS, DATABASE, TIME, AGILE, ENTITY_URL, BasisInfo bi = new BasisInfo(PROJECT, AUTHOR, VERSION, URL, NAME, PASS, DATABASE, TIME, AGILE, ENTITY_URL,
DAO_URL, XML_URL, SERVICE_URL, SERVICE_IMPL_URL,FACADE_URL, FACADE_URL_IMPL, CONTROLLER_URL,IS_SWAGGER); DAO_URL, XML_URL, SERVICE_URL, SERVICE_IMPL_URL,FACADE_URL, FACADE_URL_IMPL, CONTROLLER_URL,IS_SWAGGER);
for(String table : TABLES) { for(String table : TABLES) {
...@@ -66,33 +83,43 @@ public class MyGenerator implements Serializable { ...@@ -66,33 +83,43 @@ public class MyGenerator implements Serializable {
bi.setEntityComment(CLASSCOMMENT); bi.setEntityComment(CLASSCOMMENT);
try { try {
bi = EntityInfoUtil.getInfo(bi); bi = EntityInfoUtil.getInfo(bi);
String fileUrl = "D:\\ydlwork\\generator\\demo\\src\\main\\java\\";// 生成文件存放位置 String localproject = "D:\\ydlwork\\user-center\\ydl-user\\";
String fileServiceUrl = localproject + "ydl-*project*-service\\src\\main\\"+ "java\\";// 生成文件存放位置
String fileServiceMapper = localproject + "ydl-*project*-service\\src\\main\\" + "resources\\";// 生成文件存放位置
String fileIntfUrl = localproject + "ydl-*project*-intf\\src\\main\\java\\";// 生成文件存放位置
String fileApiUrl = localproject + "ydl-*project*-api\\src\\main\\java\\";// 生成文件存放位置
fileServiceUrl = fileServiceUrl.replace("*project*",PROJECT_NAME);
fileServiceMapper = fileServiceMapper.replace("*project*",PROJECT_NAME);
fileIntfUrl = fileIntfUrl.replace("*project*",PROJECT_NAME);
fileApiUrl = fileApiUrl.replace("*project*",PROJECT_NAME);
//开始生成文件 //开始生成文件
String aa1 = Generator.createEntity(fileUrl, bi).toString(); String aa1 = Generator.createEntity(fileIntfUrl, bi).toString();
String aa2 = Generator.createDao(fileUrl, bi).toString(); String aa2 = Generator.createDao(fileServiceUrl, bi).toString();
String aa3 = Generator.createDaoImpl(fileUrl, bi).toString(); String aa3 = Generator.createDaoImpl(fileServiceMapper, bi).toString();
String aa4 = Generator.createService(fileUrl, bi).toString(); String aa4 = Generator.createService(fileServiceUrl, bi).toString();
String aa5 = Generator.createServiceImpl(fileUrl, bi).toString(); String aa5 = Generator.createServiceImpl(fileServiceUrl, bi).toString();
String aa6 = Generator.createController(fileUrl, bi).toString(); //String aa6 = Generator.createController(fileApiUrl, bi).toString();
// 是否创建swagger配置文件 // 是否创建swagger配置文件
//String aa7 = Generator.createSwaggerConfig(fileUrl, bi).toString(); //String aa7 = Generator.createSwaggerConfig(fileUrl, bi).toString();
String aa9 = Generator.createFacade(fileUrl, bi).toString(); //String aa9 = Generator.createFacade(fileIntfUrl, bi).toString();
String aa10 = Generator.createFacadeImpl(fileUrl, bi).toString(); //String aa10 = Generator.createFacadeImpl(fileServiceUrl, bi).toString();
System.out.println(aa1); System.out.println(aa1);
System.out.println(aa2); System.out.println(aa2);
System.out.println(aa3); System.out.println(aa3);
System.out.println(aa4); System.out.println(aa4);
System.out.println(aa5); System.out.println(aa5);
System.out.println(aa6); //System.out.println(aa6);
//System.out.println(aa7); //System.out.println(aa7);
System.out.println(aa9); //System.out.println(aa9);
System.out.println(aa10); //System.out.println(aa10);
} catch (SQLException e) { } catch (SQLException e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
} }
} }
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