https://github.com/lovemo/build_java
根据sql创建语句生成java类属性、jersey注解类、mybatis mapper映射、sql列
https://github.com/lovemo/build_java
automatic java jersey mapper mybatis php sql
Last synced: 6 months ago
JSON representation
根据sql创建语句生成java类属性、jersey注解类、mybatis mapper映射、sql列
- Host: GitHub
- URL: https://github.com/lovemo/build_java
- Owner: lovemo
- License: mit
- Created: 2018-12-19T02:38:11.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2018-12-19T02:53:34.000Z (about 7 years ago)
- Last Synced: 2025-06-16T19:08:48.029Z (7 months ago)
- Topics: automatic, java, jersey, mapper, mybatis, php, sql
- Language: PHP
- Homepage:
- Size: 7.81 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# build_java
根据sql创建语句生成java类属性、jersey注解类、mybatis mapper映射、sql列
### step1
将创建sql语句写入input.txt中
```sql
CREATE TABLE `t_gift_shop` (
`product_id` int(10) unsigned NOT NULL,
`shop_group_id` int(10) unsigned NOT NULL,
`is_new` tinyint(3) unsigned NOT NULL,
`remark` varchar(200) NOT NULL,
`upd_dt` datetime NOT NULL,
PRIMARY KEY (`product_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
```
### step2
输入php build_java 命令
```sh
php build_java
desc 根据sql创建语句生成java类属性、jersey注解类、mapper映射、sql列
e.g. php build_java -type class
-type 转化的类型:
class: 转化为普通类
jersey: 转化为带有@JsonProperty注解的类属性
mapper: 转化为mybatis mapper映射结果集
sql: 生成sql列
```
### 生成对应结果文件
```java
// class
public class GiftShop {
private int productID;
private int shopGroupID;
private int productWeight;
private int new;
private String remark;
private Date updDT;
}
// jersey
public class GiftShop {
@JsonProperty("product_id")
private int productID;
@JsonProperty("shop_group_id")
private int shopGroupID;
@JsonProperty("product_weight")
private int productWeight;
@JsonProperty("is_new")
private int new;
@JsonProperty("remark")
private String remark;
@JsonProperty("upd_dt")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", locale = "zh", timezone = "GMT+8")
private Date updDT;
}
// mybatis mapper
// sql
product_id,shop_group_id,product_weight,is_new,remark,upd_dt
```