上一篇请看:记录自己的Mybatis-plus之路02-mp自定义模板
创建数据库表语句
DROP TABLE IF EXISTS `tm_user`;
CREATE TABLE `tm_user` (
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',
`name` varchar(32) DEFAULT NULL COMMENT '姓名',
`nick_name` varchar(32) DEFAULT NULL COMMENT '昵称',
`mobile_phone` varchar(32) DEFAULT NULL COMMENT '手机号',
`id_card` varchar(32) DEFAULT NULL COMMENT '身份证号',
`password` varchar(64) DEFAULT NULL COMMENT '密码',
`wrong_count` int(4) DEFAULT NULL COMMENT '错误次数',
`last_login_time` datetime DEFAULT NULL COMMENT '上次登录时间',
`last_logout_time` datetime DEFAULT NULL COMMENT '上次登出时间',
`user_status` int(4) DEFAULT NULL COMMENT '用户状态(0-初始,1-正常,2-锁定)',
`memo` varchar(128) DEFAULT NULL COMMENT '备注',
`status` int(4) DEFAULT NULL COMMENT '状态(0有效 ,1无效)',
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
`version` int(3) DEFAULT NULL COMMENT '版本号',
`update_time` datetime DEFAULT NULL COMMENT '修改时间',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COMMENT='用户表';
保存接口
http://localhost:8080/tmUser/add.json
入参:
{
"context":{
"clientMac":"00-01-6C-06-A6-29",
"clientType":"WEB",
"token":"a12fe8b8c184487facc8f222940ee397",
"timestamp":1559541118000
},
"data":{
"name":"张三",
"nickName":"GMaya",
"mobilePhone":"18888888888",
"idCard":"410888888888888888",
"password":"amdin",
"lastLoginTime":"2019-06-12 10:35:23",
"userStatus":1,
"status":0,
"version":0
},
"sign":"1078EF8F82DE0D1743418C6E255414B0"
}
出参:
{
"status": 1,
"errorMsg": null,
"data": 1
}
执行语句:
更新接口
http://localhost:8080/tmUser/updateById.json
入参:
{
"context":{
"clientMac":"00-01-6C-06-A6-29",
"clientType":"WEB",
"token":"a12fe8b8c184487facc8f222940ee397",
"timestamp":1559541118000
},
"data":{
"id":1,
"name":"李四",
"nickName":"GMaya update",
"version":0
},
"sign":"1078EF8F82DE0D1743418C6E255414B0"
}
出参:
{
"status": 1,
"errorMsg": null,
"data": 1
}
执行语句:
删除接口
http://localhost:8080/tmUser/deleteById.json
入参:
{
"context":{
"clientMac":"00-01-6C-06-A6-29",
"clientType":"WEB",
"token":"a12fe8b8c184487facc8f222940ee397",
"timestamp":1559541118000
},
"data":"1",
"sign":"1078EF8F82DE0D1743418C6E255414B0"
}
出参:
{
"status": 1,
"errorMsg": null,
"data": 1
}
执行语句:
获得单条数据
http://localhost:8080/tmUser/getById.json
入参:
{
"context":{
"clientMac":"00-01-6C-06-A6-29",
"clientType":"WEB",
"token":"a12fe8b8c184487facc8f222940ee397",
"timestamp":1559541118000
},
"data":"1",
"sign":"1078EF8F82DE0D1743418C6E255414B0"
}
出参:
{
"status": 1,
"errorMsg": null,
"data": {
"id": 1,
"name": "李四",
"nickName": "GMaya update",
"mobilePhone": "18888888888",
"idCard": "410888888888888888",
"password": "amdin",
"wrongCount": null,
"lastLoginTime": "2019-06-12T02:35:23.000+0000",
"lastLogoutTime": null,
"userStatus": 1,
"memo": null,
"status": 0,
"createTime": "2019-06-12T09:16:44.000+0000",
"version": 1,
"updateTime": "2019-06-12T09:33:56.000+0000"
}
}
执行语句:
按照条件查询全部
http://localhost:8080/tmUser/queryAll.json
入参:
{
"context":{
"clientMac":"00-01-6C-06-A6-29",
"clientType":"WEB",
"token":"a12fe8b8c184487facc8f222940ee397",
"timestamp":1559541118000
},
"data": {
"id": 1,
"name": "李四"
},
"sign":"1078EF8F82DE0D1743418C6E255414B0"
}
出参:
{
"status": 1,
"errorMsg": null,
"data": [
{
"id": 1,
"name": "李四",
"nickName": "GMaya update",
"mobilePhone": "18888888888",
"idCard": "410888888888888888",
"password": "amdin",
"wrongCount": null,
"lastLoginTime": "2019-06-12T02:35:23.000+0000",
"lastLogoutTime": null,
"userStatus": 1,
"memo": null,
"status": 0,
"createTime": "2019-06-12T09:16:44.000+0000",
"version": 1,
"updateTime": "2019-06-12T09:33:56.000+0000"
}
]
}
执行语句:
分页查询
http://localhost:8080/tmUser/queryPage.json
入参:
{
"context":{
"clientMac":"00-01-6C-06-A6-29",
"clientType":"WEB",
"token":"a12fe8b8c184487facc8f222940ee397",
"timestamp":1559541118000
},
"data": {
"id": 1,
"name": "李四",
"current":1,
"size":10
},
"sign":"1078EF8F82DE0D1743418C6E255414B0"
}
出参:
{
"status": 1,
"errorMsg": null,
"data": {
"records": [
{
"id": 1,
"name": "李四",
"nickName": "GMaya update",
"mobilePhone": "18888888888",
"idCard": "410888888888888888",
"password": "amdin",
"wrongCount": null,
"lastLoginTime": "2019-06-12T02:35:23.000+0000",
"lastLogoutTime": null,
"userStatus": 1,
"memo": null,
"status": 0,
"createTime": "2019-06-12T09:16:44.000+0000",
"version": 1,
"updateTime": "2019-06-12T09:33:56.000+0000"
}
],
"total": 1,
"size": 10,
"current": 1,
"searchCount": true,
"pages": 1
}
}
执行语句: