1 Star 0 Fork 0

Lucky.麒麟 / mybatis-plus-reverse

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

mybatis-plus-reverse

介绍

mybatis-plus逆向工具 输入图片说明

软件架构

这个命令行工具主要分为下面几个部分:

  • 命令行参数的解析
  • 配置文件解析并读取相关的表和表的结构
  • 生成实体、Mapperxml文件,(这里考虑到实现简单并且尽量减少依赖使用并没有使用模板引擎进行实现)

整个项目使用一些基础的依赖包

[dependencies]
# json解析
serde_json = "1.0"  
serde = { version = "1.0", features = ["derive"] }
# 命令行颜色
colored = "2.0.0"
# 时间格式化
chrono = "0.4.19"
# 数据库连接
mysql = "22.1.0"

接着看一下工具的配置文件格式(现在支持Json格式)

{
  "package_path": "com.example.demo",  # 项目主包
  "pass_print": false,
  "database": {   # 数据库配置
    "address": "127.0.0.1",
    "port": 3306,
    "username": "root",
    "password": "123456",
    "database": "test",
    "is_all": false,  # 是否逆向完整的数据库
    "table_name": ["t_user", "t_address"],  # 逆向指定的表
    "table_prefix": "t_"  # 表前缀
  },
  "entity": {  # 实体配置
    "primary_key_type": "AUTO",  # 主键生成策略
    "entity_path": "com.example.demo.entity",  # 实体包路径
    "use_lombok": true,
    "time_format": "2022-08-3 23:22:11",
    "time_zone": "GM+8"
  }
}

使用说明

执行命令:mp-reverse -a demo -p F:\temp -f F:\temp\config.json 输入图片说明 接着我们在指定目录中查看

│  config.json            # 配置文件

├─Order                  
│      Order.java         # 实体  
│      OrderMapper.java   # mapper文件
│      OrderMapper.xml    # xml文件

└─Product
        Product.java
        ProductMapper.java
        ProductMapper.xml

展示一下其中xml文件吧

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE builder PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-builder.dtd">
<mapper namespace="com.example.demo.mapper.OrderMapper">
	<!-- 通用查询映射结果 -->
	<resultMap id="BaseResultMap" type="com.example.demo.entity.Order">
		<id column="id" property="id" />
		<result column="order_num" property="orderNum" />
		<result column="order_title" property="orderTitle" />
		<result column="merchant_id" property="merchantId" />
		<result column="order_type" property="orderType" />
		<result column="product_id" property="productId" />
	</resultMap>
	<!-- 通用查询结果列 -->
	<sql id="Base_Column_List">
		id,order_num,order_title,merchant_id,order_type,product_id
	</sql>
</mapper>

参与贡献

  1. Fork 本仓库
  2. 新建 Feat_xxx 分支
  3. 提交代码
  4. 新建 Pull Request

特技

  1. 使用 Readme_XXX.md 来支持不同的语言,例如 Readme_en.md, Readme_zh.md
  2. Gitee 官方博客 blog.gitee.com
  3. 你可以 https://gitee.com/explore 这个地址来了解 Gitee 上的优秀开源项目
  4. GVP 全称是 Gitee 最有价值开源项目,是综合评定出的优秀开源项目
  5. Gitee 官方提供的使用手册 https://gitee.com/help
  6. Gitee 封面人物是一档用来展示 Gitee 会员风采的栏目 https://gitee.com/gitee-stars/
MIT License Copyright (c) 2022 Eternity.麒麟 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

mybatis-plus逆向工具 展开 收起
Rust
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
1
https://gitee.com/molonglove/mybatis-plus-reverse.git
git@gitee.com:molonglove/mybatis-plus-reverse.git
molonglove
mybatis-plus-reverse
mybatis-plus-reverse
master

搜索帮助