部门表:
create table `sys_dept`(
`id` int not null auto_increment comment '部门id',
`name` VARCHAR(20) not null DEFAULT '' comment '部门名称',
`parent_id` int not null DEFAULT 0 comment '上级部门id' ,
`level` VARCHAR(200) not null DEFAULT '' comment '部门层级',
`seq` int not null DEFAULT 0 comment '部门在当前层级下的顺序,由小到大',
`remark` VARCHAR(200) DEFAULT '' comment '备注' ,
`operator` VARCHAR(20) not null DEFAULT '' COMMENT '操作者',
`operator_time` datetime not null DEFAULT CURRENT_TIMESTAMP ON UPDATE
CURRENT_TIMESTAMP COMMENT '最后一次操作时间' ,
`operator_ip` VARCHAR(20) not null DEFAULT '' comment '最后一名操作者的ip' ,
PRIMARY KEY (`id`)
) comment '部门表';
用户表:
CREATE TABLE `sys_user` (
`id` int(32) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键',
`username` varchar(64) NOT NULL DEFAULT '' COMMENT '用户名字',
`telephone` varchar(64) NOT NULL DEFAULT '' COMMENT '用户手机号',
`mail` varchar(64) NOT NULL DEFAULT '' COMMENT '用户邮箱',
`password` varchar(64) NOT NULL DEFAULT '' COMMENT '用户密码',
`remark` varchar(255) DEFAULT '' COMMENT '备注',
`dep_id` int(11) NOT NULL DEFAULT '0' COMMENT '用户部门表',
`status` tinyint(3) NOT NULL DEFAULT '1' COMMENT '用户的状态 1 :正常 0:冻结 2:删除',
`operator` varchar(64) NOT NULL DEFAULT '' COMMENT '操作人',
`operator_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '操作时间',
`operator_ip` varchar(64) NOT NULL DEFAULT '' COMMENT '操作人的ip',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
说明:
1.为什么not null default 0 或者 not null default '' https://blog.csdn.net/KingOfMyHeart/article/details/88893426
2.create_time 和 update_time 用的是 default current_timestamp on update current_timestamp
如果用的navicat创建表结构的话用的是now()