代码拉取完成,页面将自动刷新
mybatis-plus逆向工具
这个命令行工具主要分为下面几个部分:
Mapper
和xml
文件,(这里考虑到实现简单并且尽量减少依赖使用并没有使用模板引擎进行实现)整个项目使用一些基础的依赖包
[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>
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。