Skip to content

Commit 6aa41d5

Browse files
authored
Merge pull request #118 from chentianming11/master
支持common-mapper&修复entity和plusentity的swagger引包错误
2 parents d88303a + 18d79cf commit 6aa41d5

File tree

8 files changed

+91
-4
lines changed

8 files changed

+91
-4
lines changed

Diff for: README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
> #支持`MySQL`、Oracle、PgSQL三大主流数据库
2121
>
2222
>generate to many popular templates by ddl-sql/insert-sql/simple json<br>
23-
> 可通过`建表SQL语句``INSERT语句`或者`简单JSON`生成`JPA/JdbcTemplate/Mybatis/MybatisPlus/BeetlSQL`相关模板代码.
23+
> 可通过`建表SQL语句``INSERT语句`或者`简单JSON`生成`JPA/JdbcTemplate/Mybatis/MybatisPlus/BeetlSQL/CommonMapper`相关模板代码.
2424
>
2525
>thanks for your using and feedback,I'm inspired by the 600PV every day and github more than 700 stars <br>
2626
> 感谢大家的使用和反馈,每天六百的PV和获得超过七百多的星星是我前进和继续做下去的动力。

Diff for: generator-web/src/main/java/com/softdev/system/generator/entity/ClassInfo.java

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
public class ClassInfo {
1414

1515
private String tableName;
16+
private String originTableName;
1617
private String className;
1718
private String classComment;
1819
private List<FieldInfo> fieldList;

Diff for: generator-web/src/main/java/com/softdev/system/generator/util/TableParseUtil.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public static ClassInfo processTableIntoClassInfo(ParamInfo paramInfo)
7373
//优化对likeu.members这种命名的支持
7474
tableName = tableName.substring(tableName.indexOf(".") + 1);
7575
}
76-
76+
String originTableName = tableName;
7777
//ignore prefix
7878
if(tableName!=null && StringUtils.isNotNull(MapUtil.getString(paramInfo.getOptions(),"ignorePrefix"))){
7979
tableName = tableName.replaceAll(MapUtil.getString(paramInfo.getOptions(),"ignorePrefix"),"");
@@ -323,6 +323,7 @@ public static ClassInfo processTableIntoClassInfo(ParamInfo paramInfo)
323323
codeJavaInfo.setClassName(className);
324324
codeJavaInfo.setClassComment(classComment);
325325
codeJavaInfo.setFieldList(fieldList);
326+
codeJavaInfo.setOriginTableName(originTableName);
326327

327328
return codeJavaInfo;
328329
}

Diff for: generator-web/src/main/resources/template.json

+16-1
Original file line numberDiff line numberDiff line change
@@ -174,5 +174,20 @@
174174
"description": "swagger-yml"
175175
}
176176
]
177-
}
177+
},
178+
179+
{
180+
"group": "common-mapper",
181+
"templates": [{
182+
"id": "74",
183+
"name": "tkentity",
184+
"description": "tkentity"
185+
},
186+
{
187+
"id": "75",
188+
"name": "tkmapper",
189+
"description": "tkmapper"
190+
}
191+
]
192+
}
178193
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<#if isWithPackage?exists && isWithPackage==true>package ${packageName}.entity;</#if>
2+
3+
<#if isAutoImport?exists && isAutoImport==true>
4+
<#if isLombok?exists && isLombok==true>import lombok.Data;</#if>
5+
import java.util.Date;
6+
import java.util.List;
7+
import java.io.Serializable;
8+
import javax.persistence.*;
9+
<#if isSwagger?exists && isSwagger==true>
10+
import io.swagger.annotations.ApiModel;
11+
import io.swagger.annotations.ApiModelProperty;</#if>
12+
</#if>
13+
/**
14+
* @description ${classInfo.classComment}
15+
* @author ${authorName}
16+
* @date ${.now?string('yyyy-MM-dd')}
17+
*/
18+
<#if isLombok?exists && isLombok==true>@Data</#if>
19+
<#if isComment?exists && isComment==true>@Table(name="${classInfo.originTableName}")</#if><#if isSwagger?exists && isSwagger==true>
20+
@ApiModel("${classInfo.classComment}")</#if>
21+
public class ${classInfo.className} implements Serializable {
22+
23+
private static final long serialVersionUID = 1L;
24+
25+
@Id
26+
@GeneratedValue(strategy = GenerationType.IDENTITY)
27+
<#if classInfo.fieldList?exists && classInfo.fieldList?size gt 0>
28+
<#list classInfo.fieldList as fieldItem >
29+
<#if isComment?exists && isComment==true>/**
30+
* ${fieldItem.fieldComment}
31+
*/</#if><#if isSwagger?exists && isSwagger==true>
32+
@ApiModelProperty("${fieldItem.fieldComment}")</#if>
33+
<#if isComment?exists && isComment==true>@Column(name="${fieldItem.columnName}")</#if>
34+
private ${fieldItem.fieldClass} ${fieldItem.fieldName};
35+
36+
</#list>
37+
public ${classInfo.className}() {
38+
}
39+
</#if>
40+
41+
<#if isLombok?exists && isLombok==false>
42+
public ${fieldItem.fieldClass} get${fieldItem.fieldName?cap_first}() {
43+
return ${fieldItem.fieldName};
44+
}
45+
46+
public void set${fieldItem.fieldName?cap_first}(${fieldItem.fieldClass} ${fieldItem.fieldName}) {
47+
this.${fieldItem.fieldName} = ${fieldItem.fieldName};
48+
}
49+
</#if>
50+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<#if isWithPackage?exists && isWithPackage==true>package ${packageName}.mapper;</#if>
2+
<#if isAutoImport?exists && isAutoImport==true>
3+
import tk.mybatis.mapper.common.Mapper;
4+
import org.apache.ibatis.annotations.Mapper;
5+
import ${packageName}.entity.${classInfo.className};
6+
</#if>
7+
/**
8+
* @description ${classInfo.classComment}Mapper
9+
* @author ${authorName}
10+
* @date ${.now?string('yyyy-MM-dd')}
11+
*/
12+
@Mapper
13+
public interface ${classInfo.className}Mapper extends Mapper<${classInfo.className}> {
14+
15+
16+
}

Diff for: generator-web/src/main/resources/templates/code-generator/jpa/entity.ftl

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@ import javax.persistence.Entity;
1010
import javax.persistence.Id;
1111
import javax.persistence.Table;
1212
import javax.persistence.GeneratedValue;
13+
<#if isSwagger?exists && isSwagger==true>
1314
import io.swagger.annotations.ApiModel;
14-
import io.swagger.annotations.ApiModelProperty;
15+
import io.swagger.annotations.ApiModelProperty;</#if>
1516
</#if>
1617
/**
1718
* @description ${classInfo.classComment}

Diff for: generator-web/src/main/resources/templates/code-generator/mybatis-plus/plusentity.ftl

+3
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ import java.util.List;
77
import java.io.Serializable;
88
import com.baomidou.mybatisplus.annotation.IdType;
99
import com.baomidou.mybatisplus.annotation.TableId;
10+
<#if isSwagger?exists && isSwagger==true>
11+
import io.swagger.annotations.ApiModel;
12+
import io.swagger.annotations.ApiModelProperty;</#if>
1013
</#if>
1114
/**
1215
* @description ${classInfo.classComment}

0 commit comments

Comments
 (0)