# gCode
**[gCode](https://github.com/liuzhuogood/GenCode)**
代码生成工具,可以连接MySQL\Oracle\postgresql\sqlite根据jinjan2模板生成出自已想要的代码
### 安装
``` shell
pip install gencode
```
### 使用方式
在模板文件所在的目录里执行
``` sh
gendcode -c config.yml
```
### 配置文件
##### config.yml
``` YAML
# 生成模式: 1:数据库 2:自定义表
genMode: 1
templatePath: './'
dbConf:
db_type: MySQL
db_name: admin
user: admin
pwd: Vile123adMin_#
host: 5slive.com
# 多表使用;分割
table_name: sys_menu_router
# Java
dataTypeMapping:
varchar|text: String
decimal(10,0): int
decimal(10,2): BigDecimal
# Python
#dataTypeMapping:
# default:
# varchar|text: str
myself:
author: liuzhuo
mail: liuzhuogood@foxmail.com
sigin: 我的签名
# 直接用定义的表
table:
sys_users: 用户表
columns:
id: string
jinja2:
variable_start_string: '{{'
variable_end_string: '}}'
```
### 模板变量
| 变量 | 示例 | 说明 |
| ---------------- | ----------------- | ---- |
| XX_TABLE_NAME | SYS_BULLETIN_FILE | 表名变形 |
| xx_table_name | sys_bulletin_file | 表名变形 |
| XxTableName | SysBulletinFile | 表名变形 |
| xxTableName | sysBulletinFile | 表名变形 |
| TableName | BulletinFile | 表名变形 |
| tableName | bulletinFile | 表名变形 |
| table_name | bulletin_file | 表名变形 |
| xx | sys | 表名变形 |
| XX | SYS | 表名变形 |
| date | 2021-10-11 | 当前日期 |
| datetime | 2021-10-11 10:10:10 | 当前时间 |
| author | liuzhuo | 名称 |
| mail | liuzhuogood@foxmail | 邮箱 |
| sign | 自动生成代码 | 签名 |
| comment | 文件表 | 表备注 |
| columns | <参考columns集合> | 列集合 |
##### columns集合
| 关键字 | 说明 |
| ----------------- | ----------------------------- |
| column_name | 列名变形 |
| COLUMN_NAME | 列名变形 |
| ColumnName | 列名变形 |
| ColumnName | 列名变形 |
| columnname | 列名变形 |
| COLUMNAME | 列名变形 |
| comment | 列名备注 |
| dataType | 列名 的类型,可以通过配置映射 |
### 模板
模板可以是文件目录,也可是文件,如果是文件为了区分必须以`.gcode`后缀命名,比如:
##### {{XxTableName}}Po.java.gcode
```
package {{xx}}
/**
{{comment}} 实体类
author: {{author}}
mail: {{mail}}
*/
public class {{TableName}}{
{% for c in columns %}
private {{c.dataType}} {{c.columnName}}; //{{c.comment}}
/**{{c.comment}}*/
public {{c.dataType}} get{{c.ColumnName}}(){return {{c.columnName}};};
/**{{c.comment}}*/
public void set{{c.ColumnName}}({{c.dataType}} {{c.columnName}}){this.{{c.columnName}}={{c.columnName}};};
{% endfor %}
}
```
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
![preview](https://csdnimg.cn/release/downloadcmsfe/public/img/white-bg.ca8570fa.png)
共18个文件
py:9个
txt:5个
pkg-info:2个
![preview-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/scale.ab9e0183.png)
资源分类:Python库 所属语言:Python 资源全名:genCode-0.0.15.tar.gz 资源来源:官方 安装方法:https://lanzao.blog.csdn.net/article/details/101784059
资源推荐
资源详情
资源评论
![gz](https://img-home.csdnimg.cn/images/20210720083447.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![gz](https://img-home.csdnimg.cn/images/20210720083447.png)
![zip](https://img-home.csdnimg.cn/images/20210720083646.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083646.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
收起资源包目录
![package](https://csdnimg.cn/release/downloadcmsfe/public/img/package.f3fc750b.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/TXT.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/TXT.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/TXT.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/TXT.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/TXT.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
共 18 条
- 1
资源评论
![avatar-default](https://csdnimg.cn/release/downloadcmsfe/public/img/lazyLogo2.1882d7f4.png)
![avatar](https://profile-avatar.csdnimg.cn/277f6345dca0446498fbbc03843436aa_qq_38161040.jpg!1)
挣扎的蓝藻
- 粉丝: 13w+
- 资源: 15万+
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助
![voice](https://csdnimg.cn/release/downloadcmsfe/public/img/voice.245cc511.png)
![center-task](https://csdnimg.cn/release/downloadcmsfe/public/img/center-task.c2eda91a.png)
安全验证
文档复制为VIP权益,开通VIP直接复制
![dialog-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/green-success.6a4acb44.png)