Commit 0e69ee74 by bianpeng

2.0.0

parent 434266a5
......@@ -3,9 +3,9 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.github</groupId>
<groupId>com.github.flying-cattle</groupId>
<artifactId>mybatis-dsc-generator</artifactId>
<version>1.1.6.RELEASE</version>
<version>2.0.0.RELEASE</version>
<packaging>jar</packaging>
<name>mybatis-dsc-generator</name>
......
......@@ -51,6 +51,10 @@ public class BasisInfo implements Serializable{
private String controllerUrl;
private String idType;
private String idJdbcType;
private List<PropertyInfo> cis;
public BasisInfo(String project, String author, String version, String dbUrl, String dbName, String dbPassword,
......
......@@ -10,27 +10,27 @@ import com.github.mybatis.util.MySqlToJavaUtil;
public class TestMain {
//基础信息
public static final String PROJECT="deal-center";
public static final String PROJECT="qixingbao-show";
public static final String AUTHOR="BianP";
public static final String VERSION="V1.0";
//数据库连接信息
public static final String URL="jdbc:mysql://127.0.0.1:3306/xin?useUnicode=true&characterEncoding=utf-8&autoReconnect=true&failOverReadOnly=false&useSSL=true";
public static final String URL="jdbc:mysql://127.0.0.1:3306/qixingbao?useUnicode=true&characterEncoding=utf-8&autoReconnect=true&failOverReadOnly=false&useSSL=true";
public static final String NAME="root";
public static final String PASSWORD="123456";
public static final String DATABASE="xin";
public static final String DATABASE="qixingbao";
//类信息
public static final String TABLE="user";
public static final String CLASSNAME="User";
public static final String CLASSCOMMENT="用户信息";
public static final String TIME="2018年6月30日";
public static final String TABLE="product";
public static final String CLASSNAME="Product";
public static final String CLASSCOMMENT="产品";
public static final String TIME="2018年7月5日";
public static final String AGILE=new Date().getTime()+"";
//路径信息
public static final String ENTITY_URL="com.xin.dealcenter.entity";
public static final String DAO_URL="com.xin.dealcenter.dao";
public static final String XML_URL="com.xin.dealcenter.dao.impl";
public static final String SERVICE_URL="com.xin.dealcenter.service";
public static final String SERVICE_IMPL_URL="com.xin.dealcenter.service.impl";
public static final String CONTROLLER_URL="com.xin.dealcenter.webApi";
public static final String ENTITY_URL="com.qixingbao.show.entity";
public static final String DAO_URL="com.qixingbao.show.dao";
public static final String XML_URL="com.qixingbao.show.dao.impl";
public static final String SERVICE_URL="com.qixingbao.show.service";
public static final String SERVICE_IMPL_URL="com.qixingbao.show.service.impl";
public static final String CONTROLLER_URL="com.qixingbao.show.webApi";
public static void main(String[] args) {
......@@ -41,19 +41,19 @@ public class TestMain {
bi.setEntityComment(CLASSCOMMENT);
try {
bi=EntityInfoUtil.getInfo(bi);
String aa1=Generator.createEntity("E:\\test_workspace\\mybatis-generator\\src\\main\\java\\", bi).toString();
/*String aa2=Generator.createDao("E:\\test_workspace\\mybatis-generator\\src\\main\\java\\", bi).toString();
String aa3=Generator.createDaoImpl("E:\\test_workspace\\mybatis-generator\\src\\main\\java\\", bi).toString();
String aa4=Generator.createService("E:\\test_workspace\\mybatis-generator\\src\\main\\java\\", bi).toString();
String aa5=Generator.createServiceImpl("E:\\test_workspace\\mybatis-generator\\src\\main\\java\\", bi).toString();
String aa6=Generator.createController("E:\\test_workspace\\mybatis-generator\\src\\main\\java\\", bi).toString();*/
String aa1=Generator.createEntity("E:\\A-ZM-work\\work_qxb2\\qxbplatform\\qixingbao-show\\src\\main\\java\\", bi).toString();
String aa2=Generator.createDao("E:\\A-ZM-work\\work_qxb2\\qxbplatform\\qixingbao-show\\src\\main\\java\\", bi).toString();
String aa3=Generator.createDaoImpl("E:\\A-ZM-work\\work_qxb2\\qxbplatform\\qixingbao-show\\src\\main\\java\\", bi).toString();
String aa4=Generator.createService("E:\\A-ZM-work\\work_qxb2\\qxbplatform\\qixingbao-show\\src\\main\\java\\", bi).toString();
String aa5=Generator.createServiceImpl("E:\\A-ZM-work\\work_qxb2\\qxbplatform\\qixingbao-show\\src\\main\\java\\", bi).toString();
String aa6=Generator.createController("E:\\A-ZM-work\\work_qxb2\\qxbplatform\\qixingbao-show\\src\\main\\java\\", bi).toString();
System.out.println(aa1);
/*System.out.println(aa2);
System.out.println(aa2);
System.out.println(aa3);
System.out.println(aa4);
System.out.println(aa5);
System.out.println(aa6);*/
System.out.println(aa6);
} catch (SQLException e) {
e.printStackTrace();
}
......
......@@ -29,19 +29,27 @@ public class EntityInfoUtil {
String comment = executeQuery.getString(3);
PropertyInfo ci=new PropertyInfo();
ci.setColumn(column);
if (jdbcType.equals("int")) {
if (jdbcType.equalsIgnoreCase("int")) {
ci.setJdbcType("Integer");
}else if (jdbcType.equalsIgnoreCase("datetime")) {
ci.setJdbcType("timestamp");
}else {
ci.setJdbcType(jdbcType);
}
ci.setComment(comment);
ci.setProperty(MySqlToJavaUtil.changeToJavaFiled(column));
ci.setJavaType(MySqlToJavaUtil.jdbcTypeToJavaType(jdbcType));
//设置注解类型
if (column.equalsIgnoreCase("id")) {
bi.setIdType(ci.getJavaType());
bi.setIdJdbcType(ci.getJdbcType());
}
columns.add(ci);
}
bi.setCis(columns);
return bi;
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException("自动生成实体类错误:"+e.getMessage());
} finally {
pstemt.close();
......
......@@ -55,8 +55,8 @@ public class ${entityName}Controller {
*/
@GetMapping("/get${entityName}ById/{id}")
@ApiOperation(value = "获取${entityComment}信息", notes = "获取${entityComment}信息[${objectName}],作者:${author}")
@ApiImplicitParam(paramType="path", name = "id", value = "${entityComment}id", required = true, dataType = "Long")
public JsonResult<${entityName}> get${entityName}ById(@PathVariable("id")Long id){
@ApiImplicitParam(paramType="path", name = "id", value = "${entityComment}id", required = true, dataType = "${idType}")
public JsonResult<${entityName}> get${entityName}ById(@PathVariable("id")${idType} id){
JsonResult<${entityName}> result=new JsonResult<${entityName}>();
try {
${entityName} ${objectName}=${objectName}ServiceImpl.selectByPrimaryKey(id);
......@@ -116,9 +116,9 @@ public class ${entityName}Controller {
*/
@PostMapping("/deleteByPrimaryKey")
@ApiOperation(value = "删除${entityComment}", notes = "删除${entityComment},作者:${author}")
@ApiImplicitParam(paramType="query", name = "id", value = "${entityComment}id", required = true, dataType = "Long")
public JsonResult deleteByPrimaryKey(Long id){
JsonResult result=new JsonResult();
@ApiImplicitParam(paramType="query", name = "id", value = "${entityComment}id", required = true, dataType = "${idType}")
public JsonResult<Object> deleteByPrimaryKey(${idType} id){
JsonResult<Object> result=new JsonResult<Object>();
try {
int reg=${objectName}ServiceImpl.deleteByPrimaryKey(id);
if (reg>0) {
......@@ -177,8 +177,8 @@ public class ${entityName}Controller {
*/
@ApiOperation(value = "条件查询${entityComment}", notes = "条件查询[${objectName}],作者:${author}")
@PostMapping("/query${entityName}List")
public JsonResult<${entityName}> query${entityName}List(${entityName} ${objectName}){
JsonResult<${entityName}> result=new JsonResult<${entityName}>();
public JsonResult<List<${entityName}>> query${entityName}List(${entityName} ${objectName}){
JsonResult<List<${entityName}>> result=new JsonResult<List<${entityName}>>();
try {
List<${entityName}> list = ${objectName}ServiceImpl.query${entityName}List(${objectName});
result.setCode(1);
......@@ -205,8 +205,8 @@ public class ${entityName}Controller {
@ApiImplicitParam(paramType="query", name = "pageNum", value = "当前页", required = true, dataType = "int"),
@ApiImplicitParam(paramType="query", name = "pageSize", value = "页行数", required = true, dataType = "int")
})
public JsonResult<${entityName}> get${entityName}BySearch(Integer pageNum,Integer pageSize){
JsonResult<${entityName}> result=new JsonResult<${entityName}>();
public JsonResult<PageInfo<${entityName}>> get${entityName}BySearch(Integer pageNum,Integer pageSize){
JsonResult<PageInfo<${entityName}>> result=new JsonResult<PageInfo<${entityName}>>();
AppPage<${entityName}> page =new AppPage<${entityName}>();
page.setPageNum(pageNum);
page.setPageSize(pageSize);
......
......@@ -21,9 +21,9 @@ import ${entityUrl}.${entityName};
@Mapper
public interface ${entityName}Dao {
public ${entityName} selectByPrimaryKey(Long id);
public ${entityName} selectByPrimaryKey(${idType} id);
public int deleteByPrimaryKey(Long id);
public int deleteByPrimaryKey(${idType} id);
public int insertSelective(${entityName} ${objectName});
......
......@@ -10,21 +10,21 @@
${agile}
</sql>
<!-- 查询 -->
<select id="selectByPrimaryKey" parameterType="java.lang.Long"
<select id="selectByPrimaryKey" parameterType="java.lang.${idType}"
resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from ${table}
where id = ${r'#{id,jdbcType=BIGINT}'}
where id = ${r'#{'}id,jdbcType=${idJdbcType?upper_case}}
</select>
<!-- 删除 -->
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
<delete id="deleteByPrimaryKey" parameterType="java.lang.${idType}">
delete from ${table}
where id = ${r'#{id,jdbcType=BIGINT}'}
where id = ${r'#{'}id,jdbcType=${idJdbcType?upper_case}}
</delete>
<!-- 选择添加 -->
<insert id="insertSelective" parameterType="${entityUrl}.${entityName}">
<selectKey keyProperty="id" order="AFTER" resultType="java.lang.Long">
<selectKey keyProperty="id" order="AFTER" resultType="java.lang.${idType}">
SELECT
LAST_INSERT_ID()
</selectKey>
......@@ -54,7 +54,7 @@
</if>
</#list>
</set>
where id = ${r'#{id,jdbcType=BIGINT}'}
where id = ${r'#{'}id,jdbcType=${idJdbcType}}
</update>
<!-- 组合条件查询 -->
<select id="query${entityName}List" parameterType="${entityUrl}.${entityName}"
......@@ -64,7 +64,7 @@
from ${table}
<where>
<if test="id != null">
id = ${r'#{'}id,jdbcType=BIGINT}
id = ${r'#{'}id,jdbcType=${idJdbcType?upper_case}}
</if>
<#list cis as ci>
<#if ci.column!="id">
......
......@@ -27,7 +27,7 @@ public interface ${entityName}Service {
* @return ${entityName}
* @author ${author}
*/
public ${entityName} selectByPrimaryKey(Long id);
public ${entityName} selectByPrimaryKey(${idType} id);
/**
* @explain 删除${entityComment}对象
......@@ -35,7 +35,7 @@ public interface ${entityName}Service {
* @return int
* @author ${author}
*/
public int deleteByPrimaryKey(Long id);
public int deleteByPrimaryKey(${idType} id);
/**
* @explain 添加${entityComment}对象
......
......@@ -34,13 +34,13 @@ public class ${entityName}ServiceImpl implements ${entityName}Service {
//查询对象
@Override
public ${entityName} selectByPrimaryKey(Long id) {
public ${entityName} selectByPrimaryKey(${idType} id) {
return ${objectName}Dao.selectByPrimaryKey(id);
}
//删除对象
@Override
public int deleteByPrimaryKey(Long id) {
public int deleteByPrimaryKey(${idType} id) {
return ${objectName}Dao.deleteByPrimaryKey(id);
}
......
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