Skip to content

Commit 7025aff

Browse files
committed
新增实体实现序列化接口
1 parent 474c108 commit 7025aff

File tree

3 files changed

+13
-9
lines changed

3 files changed

+13
-9
lines changed

api-boot-project/api-boot-maven-plugins/api-boot-mybatis-enhance-maven-codegen/pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,11 @@
5959
<artifactId>lombok</artifactId>
6060
<optional>true</optional>
6161
</dependency>
62+
<!--fastJson-->
63+
<dependency>
64+
<groupId>com.alibaba</groupId>
65+
<artifactId>fastjson</artifactId>
66+
</dependency>
6267
</dependencies>
6368

6469
</project>

api-boot-project/api-boot-maven-plugins/api-boot-mybatis-enhance-maven-codegen/src/main/java/org/minbox/framework/api/boot/maven/plugin/mybatis/enhance/codegen/ApiBootMybatisEnhanceCodegen.java

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ public void execute() throws MojoExecutionException, MojoFailureException {
218218

219219
if (!ObjectUtils.isEmpty(files)) {
220220
files.stream().forEach(file -> {
221-
getLog().info("generation file -> " + file.getFileName());
221+
getLog().info("generator 【" + file.getFileName() + "】 by codegen template.");
222222
// generator package dir & return full file path
223223
String fullFilePath = getNewClassPath(file.getFileName(), file.getPackageName());
224224
if (!StringUtils.isEmpty(file.getJavaContent()) && !StringUtils.isEmpty(fullFilePath)) {
@@ -241,12 +241,7 @@ private String loadCodegenSetting() {
241241

242242
// read codegen.setting.json content
243243
File file = new File(projectBaseDir + settingJsonPath);
244-
String content = FileUtils.fileRead(file);
245-
246-
getLog().info("codegen.setting.json:");
247-
getLog().info(content);
248-
249-
return content;
244+
return FileUtils.fileRead(file);
250245
} catch (Exception e) {
251246
getLog().error(e);
252247
}

api-boot-project/api-boot-maven-plugins/api-boot-mybatis-enhance-maven-codegen/src/main/java/org/minbox/framework/api/boot/maven/plugin/mybatis/enhance/codegen/builder/impl/EntityClassBuilder.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import org.springframework.util.StringUtils;
3232

3333
import java.io.IOException;
34+
import java.io.Serializable;
3435
import java.io.StringWriter;
3536
import java.math.BigDecimal;
3637
import java.sql.Date;
@@ -79,8 +80,11 @@ public String getClassContent() {
7980
// @table
8081
writer.line(String.format(TABLE_ANNOTATION, table.getTableName()));
8182

83+
// serializable
84+
SimpleType serializableInterface = new SimpleType(Serializable.class.getName(), EnhanceCodegenConstant.EMPTY_STRING, Serializable.class.getName());
85+
8286
// public class
83-
writer.beginClass(new SimpleType(getWrapper().getTableCamelName(), EnhanceCodegenConstant.EMPTY_STRING, getWrapper().getTableCamelName()));
87+
writer.beginClass(new SimpleType(getWrapper().getTableCamelName(), EnhanceCodegenConstant.EMPTY_STRING, getWrapper().getTableCamelName()), null, serializableInterface);
8488

8589
for (com.gitee.hengboy.builder.core.database.model.Column column : table.getColumns()) {
8690
// comment
@@ -111,7 +115,7 @@ public String getClassContent() {
111115
*/
112116
void chooseImport(com.gitee.hengboy.builder.core.database.model.Table table, CodeWriter writer) throws IOException {
113117
// basic imports
114-
writer.imports(Column.class, Id.class, Table.class, KeyGeneratorTypeEnum.class, Data.class);
118+
writer.imports(Column.class, Id.class, Table.class, KeyGeneratorTypeEnum.class, Data.class, Serializable.class);
115119

116120
// import bigDecimal
117121
if (table.isHasBigDecimal()) {

0 commit comments

Comments
 (0)