Skip to content

Commit b0c7deb

Browse files
authored
Merge branch 'main' into dependabot/maven/org.apache.commons-commons-text-1.10.0
2 parents 121281c + 040e771 commit b0c7deb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+138
-106
lines changed

README.md

Lines changed: 31 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,51 @@
11
# Code Generator
2-
此工具主要用于将[Excel模板](template)文档转换为数据库结构、初始数据的sql脚本及多语言资源代码。
2+
3+
此工具主要用于将[Excel 模板](template)文档转换为数据库结构、初始数据的 sql 脚本及多语言资源代码。
34

45
## 主要功能
5-
* DDL - 生成数据库结构代码,支持 Mysql/SQLServer/SQLite
6-
* DML - 生成初始数据的sql代码
7-
* MSG - 生成多语言资源代码,支持 Android/IOS/JSON/Java/.NET
6+
7+
- DDL - 生成数据库结构代码,支持 Mysql/SQLServer/SQLite
8+
- DML - 生成初始数据的 sql 代码
9+
- MSG - 生成多语言资源代码,支持 Android/IOS/JSON/Java/.NET
810

911
## 安装
10-
**Mac/Linux 用户**
12+
13+
### Mac/Linux 用户
14+
1115
```sh
1216
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/excel-code-generator/code-generator/master/install.sh)"
1317
```
18+
1419
> 将以上命令粘贴至终端。
1520
16-
**Windows 用户**
21+
### Windows 用户
22+
1723
```ps1
1824
iex ((New-Object System.Net.WebClient).DownloadString('https://raw.githubusercontent.com/excel-code-generator/code-generator/master/install.ps1'))
1925
```
20-
> 将以上命令粘贴至PowerShell。
2126

22-
**更新**
27+
> 将以上命令粘贴至 PowerShell。
28+
29+
### 更新
30+
2331
```sh
2432
cg update
2533
```
34+
2635
> Windows/Mac/Linux 均相同。
2736
28-
## 在Docker中使用
37+
## 在 Docker 中使用
38+
2939
```sh
3040
docker pull yanglibing/code-generator
3141
docker run --rm -it yanglibing/code-generator
3242
```
3343

3444
## 参数说明
35-
```
45+
46+
```text
3647
用法:cg command file [options]
37-
Commands:
48+
Commands:
3849
update 检查并更新到最新版本
3950
ddl.mssql 生成SqlServer数据库结构SQL脚本(.ddl)
4051
ddl.mysql 生成MySql数据库结构SQL脚本(.ddl)
@@ -53,37 +64,40 @@ Options:
5364
-s,--sheets <names> 要处理的Excel Sheet名,默认除"#"开头外的全部Sheet
5465
-v,--version 打印版本信息
5566
56-
示例:
67+
示例:
5768
cg msg.json 001.xlsx
5869
cg msg.resx 001.xlsx --sheets Sheet1 Sheet2 Sheet5
5970
60-
帮助:
71+
帮助:
6172
cg ddl.mysql --help 显示数生成据库结构的更多帮助信息
6273
cg dml --help 显示生成初始数据的更多帮助信息
6374
cg msg.json --help 显示生成国际化资源的更多帮助信息
6475
6576
通过 cg command --help 查看指定命令的详细说明。
6677
6778
---
68-
Code Generator v4.2.0
79+
Code Generator v4.3.0
6980
By https://yanglb.com
7081
```
7182

7283
## 用法示例
84+
7385
```sh
7486
# 生成 MySql 数据库结构脚本
7587
cg ddl.mysql database.xlsx --engine myisam
7688

7789
# 生成 JSON 多语言资源
7890
cg msg.json msg.xlsx
7991
```
80-
> Excel模板请参考 [template](template)
92+
93+
> Excel 模板请参考 [template](template)
8194
8295
## 升级说明
83-
4.x版本不兼容老版本的命令行参数,但Excel模板在所有版本下均可正常使用。
96+
97+
4.x 版本不兼容老版本的命令行参数,但 Excel 模板在所有版本下均可正常使用。
8498

8599
## License
86100

87-
Copyright (c) 2015-2021 yanglb.com. All rights reserved.
101+
Copyright (c) 2015-2023 yanglb.com. All rights reserved.
88102

89103
Licensed under the [Apache License 2.0](LICENSE) license.

cg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env sh
22

3-
# Copyright 2015-2021 yanglb.com
3+
# Copyright 2015-2023 yanglb.com
44
#
55
# Licensed under the Apache License, Version 2.0 (the "License");
66
# you may not use this file except in compliance with the License.

cg.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
@echo off
2-
REM Copyright 2015-2021 yanglb.com
2+
REM Copyright 2015-2023 yanglb.com
33
REM
44
REM Licensed under the Apache License, Version 2.0 (the "License");
55
REM you may not use this file except in compliance with the License.

install.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2015-2021 yanglb.com
1+
# Copyright 2015-2023 yanglb.com
22
#
33
# Licensed under the Apache License, Version 2.0 (the "License");
44
# you may not use this file except in compliance with the License.

install.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env sh
22

3-
# Copyright 2015-2021 yanglb.com
3+
# Copyright 2015-2023 yanglb.com
44
#
55
# Licensed under the Apache License, Version 2.0 (the "License");
66
# you may not use this file except in compliance with the License.

pom.xml

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,36 +6,42 @@
66

77
<groupId>org.yanglb</groupId>
88
<artifactId>code-generator</artifactId>
9-
<version>4.2.0</version>
9+
<version>4.3.0</version>
1010
<packaging>jar</packaging>
1111

1212
<dependencies>
1313
<!-- https://mvnrepository.com/artifact/commons-cli/commons-cli -->
1414
<dependency>
1515
<groupId>commons-cli</groupId>
1616
<artifactId>commons-cli</artifactId>
17-
<version>1.4</version>
17+
<version>1.8.0</version>
1818
</dependency>
1919
<dependency>
2020
<groupId>org.apache.commons</groupId>
2121
<artifactId>commons-text</artifactId>
22-
<version>1.10.0</version>
22+
<version>1.12.0</version>
2323
</dependency>
2424
<dependency>
2525
<groupId>org.apache.poi</groupId>
2626
<artifactId>poi-excelant</artifactId>
27-
<version>3.11</version>
27+
<version>5.3.0</version>
2828
</dependency>
2929
<dependency>
3030
<groupId>org.yaml</groupId>
3131
<artifactId>snakeyaml</artifactId>
32-
<version>1.32</version>
32+
<version>2.0</version>
3333
</dependency>
3434
<!-- https://mvnrepository.com/artifact/org.json/json -->
3535
<dependency>
3636
<groupId>org.json</groupId>
3737
<artifactId>json</artifactId>
38-
<version>20200518</version>
38+
<version>20231013</version>
39+
</dependency>
40+
<!-- https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-core -->
41+
<dependency>
42+
<groupId>org.apache.logging.log4j</groupId>
43+
<artifactId>log4j-core</artifactId>
44+
<version>2.24.2</version>
3945
</dependency>
4046
</dependencies>
4147
<build>
@@ -74,4 +80,11 @@
7480
</plugin>
7581
</plugins>
7682
</build>
83+
<repositories>
84+
<repository>
85+
<id>maven_central</id>
86+
<name>Maven Central</name>
87+
<url>https://repo.maven.apache.org/maven2/</url>
88+
</repository>
89+
</repositories>
7790
</project>

src/main/java/cg.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2015-2021 yanglb.com
2+
* Copyright 2015-2023 yanglb.com
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

src/main/java/com/yanglb/codegen/converter/BeanMapConverter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2015-2021 yanglb.com
2+
* Copyright 2015-2023 yanglb.com
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

src/main/java/com/yanglb/codegen/converter/TableModelConverter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2015-2021 yanglb.com
2+
* Copyright 2015-2023 yanglb.com
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

src/main/java/com/yanglb/codegen/core/GenFactory.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2015-2021 yanglb.com
2+
* Copyright 2015-2023 yanglb.com
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

src/main/java/com/yanglb/codegen/core/generator/BaseGenerator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2015-2021 yanglb.com
2+
* Copyright 2015-2023 yanglb.com
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

src/main/java/com/yanglb/codegen/core/generator/IGenerator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2015-2021 yanglb.com
2+
* Copyright 2015-2023 yanglb.com
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

src/main/java/com/yanglb/codegen/core/generator/impl/DdlGeneratorImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2015-2021 yanglb.com
2+
* Copyright 2015-2023 yanglb.com
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

src/main/java/com/yanglb/codegen/core/generator/impl/DmlGeneratorImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2015-2021 yanglb.com
2+
* Copyright 2015-2023 yanglb.com
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

src/main/java/com/yanglb/codegen/core/generator/impl/MsgGeneratorImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2015-2021 yanglb.com
2+
* Copyright 2015-2023 yanglb.com
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

src/main/java/com/yanglb/codegen/core/parser/BaseParser.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2015-2021 yanglb.com
2+
* Copyright 2015-2023 yanglb.com
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

src/main/java/com/yanglb/codegen/core/parser/IParser.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2015-2021 yanglb.com
2+
* Copyright 2015-2023 yanglb.com
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

src/main/java/com/yanglb/codegen/core/parser/impl/DdlMySqlParser.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2015-2021 yanglb.com
2+
* Copyright 2015-2023 yanglb.com
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

src/main/java/com/yanglb/codegen/core/parser/impl/DdlParser.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2015-2021 yanglb.com
2+
* Copyright 2015-2023 yanglb.com
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

src/main/java/com/yanglb/codegen/core/parser/impl/DmlParser.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2015-2021 yanglb.com
2+
* Copyright 2015-2023 yanglb.com
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

src/main/java/com/yanglb/codegen/core/parser/impl/MsgAndroidParser.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2015-2021 yanglb.com
2+
* Copyright 2015-2023 yanglb.com
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

src/main/java/com/yanglb/codegen/core/parser/impl/MsgJSONParser.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2015-2021 yanglb.com
2+
* Copyright 2015-2023 yanglb.com
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

src/main/java/com/yanglb/codegen/core/parser/impl/MsgParser.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2015-2021 yanglb.com
2+
* Copyright 2015-2023 yanglb.com
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

src/main/java/com/yanglb/codegen/core/reader/BaseModelReader.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2015-2021 yanglb.com
2+
* Copyright 2015-2023 yanglb.com
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

src/main/java/com/yanglb/codegen/core/reader/BaseReader.java

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2015-2021 yanglb.com
2+
* Copyright 2015-2023 yanglb.com
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -31,6 +31,7 @@
3131
import java.util.List;
3232
import org.apache.poi.hssf.usermodel.HSSFFormulaEvaluator;
3333
import org.apache.poi.ss.usermodel.Cell;
34+
import org.apache.poi.ss.usermodel.CellType;
3435
import org.apache.poi.xssf.usermodel.XSSFCell;
3536
import org.apache.poi.xssf.usermodel.XSSFSheet;
3637
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
@@ -185,23 +186,23 @@ private boolean isReadable(String sheetName) {
185186
*/
186187
public String getCellStringValue(XSSFCell cell) {
187188
String result = null;
188-
int type = cell.getCellType();
189-
if(type == Cell.CELL_TYPE_FORMULA) type = cell.getCachedFormulaResultType();
190-
if(type == Cell.CELL_TYPE_BLANK) return null;
191-
if(type == Cell.CELL_TYPE_ERROR) {
189+
CellType type = cell.getCellType();
190+
if(type == CellType.FORMULA) type = cell.getCachedFormulaResultType();
191+
if(type == CellType.BLANK) return null;
192+
if(type == CellType.ERROR) {
192193
return "#VALUE!";
193194
}
194195

195196
switch(type) {
196-
case Cell.CELL_TYPE_BOOLEAN:
197+
case BOOLEAN:
197198
result = String.valueOf(cell.getBooleanCellValue());
198199
break;
199200

200-
case Cell.CELL_TYPE_STRING:
201+
case STRING:
201202
result = cell.getStringCellValue();
202203
break;
203204

204-
case Cell.CELL_TYPE_NUMERIC:
205+
case NUMERIC:
205206
{
206207
if(cell.getCellStyle().getDataFormat() == DataFormatType.FORMAT_DATE) {
207208
Date date = cell.getDateCellValue();

src/main/java/com/yanglb/codegen/core/reader/IReader.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2015-2021 yanglb.com
2+
* Copyright 2015-2023 yanglb.com
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

src/main/java/com/yanglb/codegen/core/reader/ISettingReader.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2015-2021 yanglb.com
2+
* Copyright 2015-2023 yanglb.com
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

src/main/java/com/yanglb/codegen/core/reader/ITableReader.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2015-2021 yanglb.com
2+
* Copyright 2015-2023 yanglb.com
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

0 commit comments

Comments
 (0)