SpringBoot 分页处理
开始主要是要使用已经设计好的数据库
-- ----------------------------------------------------
-- 用户
-- ----------------------------------------------------
-- Table structure for `sys_user`
-- ----------------------------------------------------
CREATE TABLE `sys_user` (
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '编号',
`name` varchar(50) NOT NULL COMMENT '用户名',
`password` varchar(100) COMMENT '密码',
`salt` varchar(40) COMMENT '盐',
`email` varchar(100) COMMENT '邮箱',
`mobile` varchar(100) COMMENT '手机号',
`status` tinyint COMMENT '状态 0:禁用 1:正常',
`dept_id` bigint(20) COMMENT '机构ID',
`create_by` varchar(50) COMMENT '创建人',
`create_time` datetime COMMENT '创建时间',
`last_update_by` varchar(50) COMMENT '更新人',
`last_update_time` datetime COMMENT '更新时间',
`del_flag` tinyint DEFAULT 0 COMMENT '是否删除 -1:已删除 0:正常',
PRIMARY KEY (`id`),
UNIQUE INDEX (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='用户'; -- ----------------------------------------------------
-- 机构
-- ------------------------------------------------
-- Table structure for `sys_dept`
-- ------------------------------------------------
CREATE TABLE `sys_dept` (
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '编号',
`name` varchar(50) COMMENT '机构名称',
`parent_id` bigint COMMENT '上级机构ID,一级机构为0',
`order_num` int COMMENT '排序',
`create_by` varchar(50) COMMENT '创建人',
`create_time` datetime COMMENT '创建时间',
`last_update_by` varchar(50) COMMENT '更新人',
`last_update_time` datetime COMMENT '更新时间',
`del_flag` tinyint DEFAULT 0 COMMENT '是否删除 -1:已删除 0:正常',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='机构管理'; -- ------------------------------------------------
-- 角色
-- ------------------------------------------------
-- Table structure for `sys_role`
-- ------------------------------------------------
CREATE TABLE `sys_role` (
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '编号',
`name` varchar(100) COMMENT '角色名称',
`remark` varchar(100) COMMENT '备注',
`create_by` varchar(50) COMMENT '创建人',
`create_time` datetime COMMENT '创建时间',
`last_update_by` varchar(50) COMMENT '更新人',
`last_update_time` datetime COMMENT '更新时间',
`del_flag` tinyint DEFAULT 0 COMMENT '是否删除 -1:已删除 0:正常',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='角色'; -- ------------------------------------------------
-- 菜单
-- ------------------------------------------------
-- Table structure for `sys_menu`
-- ------------------------------------------------
CREATE TABLE `sys_menu` (
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '编号',
`name` varchar(50) COMMENT '菜单名称',
`parent_id` bigint COMMENT '父菜单ID,一级菜单为0',
`url` varchar(200) COMMENT '菜单URL',
`perms` varchar(500) COMMENT '授权(多个用逗号分隔,如:user:view,user:create)',
`type` int COMMENT '类型 0:目录 1:菜单 2:按钮',
`icon` varchar(50) COMMENT '菜单图标',
`order_num` int COMMENT '排序',
`create_by` varchar(50) COMMENT '创建人',
`create_time` datetime COMMENT '创建时间',
`last_update_by` varchar(50) COMMENT '更新人',
`last_update_time` datetime COMMENT '更新时间',
`del_flag` tinyint DEFAULT 0 COMMENT '是否删除 -1:已删除 0:正常',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='菜单管理'; -- ------------------------------------------------
-- 用户与角色对应关系
-- ------------------------------------------------
-- Table structure for `sys_user_role`
-- ------------------------------------------------
CREATE TABLE `sys_user_role` (
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '编号',
`user_id` bigint COMMENT '用户ID',
`role_id` bigint COMMENT '角色ID',
`create_by` varchar(50) COMMENT '创建人',
`create_time` datetime COMMENT '创建时间',
`last_update_by` varchar(50) COMMENT '更新人',
`last_update_time` datetime COMMENT '更新时间',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='用户与角色对应关系'; -- ------------------------------------------------
-- 角色与机构对应关系
-- ------------------------------------------------
-- Table structure for `sys_role_dept`
-- ------------------------------------------------
CREATE TABLE `sys_role_dept` (
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '编号',
`role_id` bigint COMMENT '角色ID',
`dept_id` bigint COMMENT '机构ID',
`create_by` varchar(50) COMMENT '创建人',
`create_time` datetime COMMENT '创建时间',
`last_update_by` varchar(50) COMMENT '更新人',
`last_update_time` datetime COMMENT '更新时间',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='角色与机构对应关系'; -- ------------------------------------------------
-- 角色与菜单对应关系
-- ------------------------------------------------
-- Table structure for `sys_role_menu`
-- ------------------------------------------------
CREATE TABLE `sys_role_menu` (
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '编号',
`role_id` bigint COMMENT '角色ID',
`menu_id` bigint COMMENT '菜单ID',
`create_by` varchar(50) COMMENT '创建人',
`create_time` datetime COMMENT '创建时间',
`last_update_by` varchar(50) COMMENT '更新人',
`last_update_time` datetime COMMENT '更新时间',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='角色与菜单对应关系'; -- ------------------------------------------------
-- 用户Token
-- ------------------------------------------------
-- Table structure for `sys_user_token`
-- ------------------------------------------------
CREATE TABLE `sys_user_token` (
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '编号',
`user_id` bigint NOT NULL,
`token` varchar(100) NOT NULL COMMENT 'token',
`expire_time` datetime DEFAULT NULL COMMENT '过期时间',
`create_by` varchar(50) COMMENT '创建人',
`create_time` datetime COMMENT '创建时间',
`last_update_by` varchar(50) COMMENT '更新人',
`last_update_time` datetime COMMENT '更新时间',
PRIMARY KEY (`id`),
UNIQUE KEY `token` (`token`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='用户Token'; -- ------------------------------------------------
-- 系统日志
-- ------------------------------------------------
-- Table structure for `sys_log`
-- ------------------------------------------------
CREATE TABLE `sys_log` (
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '编号',
`user_name` varchar(50) COMMENT '用户名',
`operation` varchar(50) COMMENT '用户操作',
`method` varchar(200) COMMENT '请求方法',
`params` varchar(5000) COMMENT '请求参数',
`time` bigint NOT NULL COMMENT '执行时长(毫秒)',
`ip` varchar(64) COMMENT 'IP地址',
`create_by` varchar(50) COMMENT '创建人',
`create_time` datetime COMMENT '创建时间',
`last_update_by` varchar(50) COMMENT '更新人',
`last_update_time` datetime COMMENT '更新时间',
PRIMARY KEY (`id`)
) ENGINE=`InnoDB` DEFAULT CHARACTER SET utf8 COMMENT='系统日志'; -- ------------------------------------------------
-- 数据字典
-- ------------------------------------------------
-- Table structure for `sys_dict`
-- ------------------------------------------------
DROP TABLE IF EXISTS `sys_dict`;
CREATE TABLE `sys_dict` (
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '编号',
`value` varchar(100) NOT NULL COMMENT '数据值',
`label` varchar(100) NOT NULL COMMENT '标签名',
`type` varchar(100) NOT NULL COMMENT '类型',
`description` varchar(100) NOT NULL COMMENT '描述',
`sort` decimal(10,0) NOT NULL COMMENT '排序(升序)',
`create_by` varchar(50) COMMENT '创建人',
`create_time` datetime COMMENT '创建时间',
`last_update_by` varchar(50) COMMENT '更新人',
`last_update_time` datetime COMMENT '更新时间',
`remarks` varchar(255) DEFAULT NULL COMMENT '备注信息',
`del_flag` tinyint DEFAULT 0 COMMENT '是否删除 -1:已删除 0:正常',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='字典表'; -- --------------------------------------
-- 初始数据
-- --------------------------------------
-- Records of `sys_user`
-- --------------------------------------
INSERT INTO `sys_user` (`id`, `name`, `password`, `salt`, `dept_id`, `email`, `mobile`, `status`, `create_time`) VALUES ('', 'admin', '9ec9750e709431dad22365cabc5c625482e574c74adaebba7dd02f1129e4ce1d', 'YzcmCZNvbXocrsz9dm8e', '', 'admin@qq.com', '', '', '2018-08-14 11:11:11');
INSERT INTO `sys_user` (`id`, `name`, `password`, `salt`, `dept_id`, `email`, `mobile`, `status`, `create_time`) VALUES ('', 'Louis', '9ec9750e709431dad22365cabc5c625482e574c74adaebba7dd02f1129e4ce1d', 'YzcmCZNvbXocrsz9dm8e', '', 'louis@qq.com', '', '', '2018-08-14 11:11:11');
INSERT INTO `sys_user` (`id`, `name`, `password`, `salt`, `dept_id`, `email`, `mobile`, `status`, `create_time`) VALUES ('', 'Kobe', '9ec9750e709431dad22365cabc5c625482e574c74adaebba7dd02f1129e4ce1d', 'YzcmCZNvbXocrsz9dm8e', '', 'kobe@qq.com', '', '', '2018-08-14 11:11:11');
INSERT INTO `sys_user` (`id`, `name`, `password`, `salt`, `dept_id`, `email`, `mobile`, `status`, `create_time`) VALUES ('', 'Iverson', '9ec9750e709431dad22365cabc5c625482e574c74adaebba7dd02f1129e4ce1d', 'YzcmCZNvbXocrsz9dm8e', '', 'iverson@qq.com', '', '', '2018-08-14 11:11:11');
INSERT INTO `sys_user` (`id`, `name`, `password`, `salt`, `dept_id`, `email`, `mobile`, `status`, `create_time`) VALUES ('', 'Iverson5', '9ec9750e709431dad22365cabc5c625482e574c74adaebba7dd02f1129e4ce1d', 'YzcmCZNvbXocrsz9dm8e', '', 'iverson@qq.com', '', '', '2018-08-14 11:11:11');
INSERT INTO `sys_user` (`id`, `name`, `password`, `salt`, `dept_id`, `email`, `mobile`, `status`, `create_time`) VALUES ('', 'Iverson6', '9ec9750e709431dad22365cabc5c625482e574c74adaebba7dd02f1129e4ce1d', 'YzcmCZNvbXocrsz9dm8e', '', 'iverson@qq.com', '', '', '2018-08-14 11:11:11');
INSERT INTO `sys_user` (`id`, `name`, `password`, `salt`, `dept_id`, `email`, `mobile`, `status`, `create_time`) VALUES ('', 'Iverson7', '9ec9750e709431dad22365cabc5c625482e574c74adaebba7dd02f1129e4ce1d', 'YzcmCZNvbXocrsz9dm8e', '', 'iverson@qq.com', '', '', '2018-08-14 11:11:11');
INSERT INTO `sys_user` (`id`, `name`, `password`, `salt`, `dept_id`, `email`, `mobile`, `status`, `create_time`) VALUES ('', 'Iverson8', '9ec9750e709431dad22365cabc5c625482e574c74adaebba7dd02f1129e4ce1d', 'YzcmCZNvbXocrsz9dm8e', '', 'iverson@qq.com', '', '', '2018-08-14 11:11:11');
INSERT INTO `sys_user` (`id`, `name`, `password`, `salt`, `dept_id`, `email`, `mobile`, `status`, `create_time`) VALUES ('', 'Iverson9', '9ec9750e709431dad22365cabc5c625482e574c74adaebba7dd02f1129e4ce1d', 'YzcmCZNvbXocrsz9dm8e', '', 'iverson@qq.com', '', '', '2018-08-14 11:11:11');
INSERT INTO `sys_user` (`id`, `name`, `password`, `salt`, `dept_id`, `email`, `mobile`, `status`, `create_time`) VALUES ('', 'Iverson10', '9ec9750e709431dad22365cabc5c625482e574c74adaebba7dd02f1129e4ce1d', 'YzcmCZNvbXocrsz9dm8e', '', 'iverson@qq.com', '', '', '2018-08-14 11:11:11');
INSERT INTO `sys_user` (`id`, `name`, `password`, `salt`, `dept_id`, `email`, `mobile`, `status`, `create_time`) VALUES ('', 'Iverson11', '9ec9750e709431dad22365cabc5c625482e574c74adaebba7dd02f1129e4ce1d', 'YzcmCZNvbXocrsz9dm8e', '', 'iverson@qq.com', '', '', '2018-08-14 11:11:11');
INSERT INTO `sys_user` (`id`, `name`, `password`, `salt`, `dept_id`, `email`, `mobile`, `status`, `create_time`) VALUES ('', 'Iverson12', '9ec9750e709431dad22365cabc5c625482e574c74adaebba7dd02f1129e4ce1d', 'YzcmCZNvbXocrsz9dm8e', '', 'iverson@qq.com', '', '', '2018-08-14 11:11:11');
-- --------------------------------------
-- Records of `sys_role`
-- --------------------------------------
INSERT INTO `sys_role` (`id`, `name`, `remark`, `create_time`) VALUES ('', 'admin', '超级管理员', '2018-08-14 11:11:11');
INSERT INTO `sys_role` (`id`, `name`, `remark`, `create_time`) VALUES ('', 'dev', '开发人员', '2018-08-14 11:11:11');
INSERT INTO `sys_role` (`id`, `name`, `remark`, `create_time`) VALUES ('', 'test', '测试人员', '2018-08-14 11:11:11');
-- --------------------------------------
-- Records of `sys_user_role`
-- --------------------------------------
INSERT INTO `sys_user_role` (`id`, `user_id`, `role_id`) VALUES ('', '', '');
INSERT INTO `sys_user_role` (`id`, `user_id`, `role_id`) VALUES ('', '', '');
INSERT INTO `sys_user_role` (`id`, `user_id`, `role_id`) VALUES ('', '', '');
INSERT INTO `sys_user_role` (`id`, `user_id`, `role_id`) VALUES ('', '', '');
-- --------------------------------------
-- Records of `sys_dept`
-- --------------------------------------
INSERT INTO `sys_dept` (`id`, `parent_id`, `name`, `order_num`, `del_flag`) VALUES ('', '', '轻尘集团', '', '');
INSERT INTO `sys_dept` (`id`, `parent_id`, `name`, `order_num`, `del_flag`) VALUES ('', '', '北京分公司', '', '');
INSERT INTO `sys_dept` (`id`, `parent_id`, `name`, `order_num`, `del_flag`) VALUES ('', '', '上海分公司', '', '');
INSERT INTO `sys_dept` (`id`, `parent_id`, `name`, `order_num`, `del_flag`) VALUES ('', '', '技术部', '', '');
INSERT INTO `sys_dept` (`id`, `parent_id`, `name`, `order_num`, `del_flag`) VALUES ('', '', '宣传部', '', '');
INSERT INTO `sys_dept` (`id`, `parent_id`, `name`, `order_num`, `del_flag`) VALUES ('', '', '销售部', '', '');
INSERT INTO `sys_dept` (`id`, `parent_id`, `name`, `order_num`, `del_flag`) VALUES ('', '', '市场部', '', '');
INSERT INTO `sys_dept` (`id`, `parent_id`, `name`, `order_num`, `del_flag`) VALUES ('', '', '牧尘集团', '', '');
INSERT INTO `sys_dept` (`id`, `parent_id`, `name`, `order_num`, `del_flag`) VALUES ('', '', '北京分公司', '', '');
INSERT INTO `sys_dept` (`id`, `parent_id`, `name`, `order_num`, `del_flag`) VALUES ('', '', '上海分公司', '', '');
INSERT INTO `sys_dept` (`id`, `parent_id`, `name`, `order_num`, `del_flag`) VALUES ('', '', '技术部', '', '');
INSERT INTO `sys_dept` (`id`, `parent_id`, `name`, `order_num`, `del_flag`) VALUES ('', '', '宣传部', '', '');
INSERT INTO `sys_dept` (`id`, `parent_id`, `name`, `order_num`, `del_flag`) VALUES ('', '', '销售部', '', '');
INSERT INTO `sys_dept` (`id`, `parent_id`, `name`, `order_num`, `del_flag`) VALUES ('', '', '市场部', '', '');
-- --------------------------------------
-- Records of `sys_menu`
-- --------------------------------------
INSERT INTO `sys_menu` (`id`, `parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`) VALUES ('', '', '系统管理', NULL, NULL, '', 'fa el-icon-setting', '');
INSERT INTO `sys_menu` (`id`, `parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`) VALUES ('', '', '用户管理', '/sys/user', NULL, '', 'el-icon-service', '');
INSERT INTO `sys_menu` (`id`, `parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`) VALUES ('', '', '机构管理', '/sys/dept', NULL, '', 'el-icon-news', '');
INSERT INTO `sys_menu` (`id`, `parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`) VALUES ('', '', '角色管理', '/sys/role', NULL, '', 'el-icon-view', '');
INSERT INTO `sys_menu` (`id`, `parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`) VALUES ('', '', '菜单管理', '/sys/menu', NULL, '', 'el-icon-menu', '');
INSERT INTO `sys_menu` (`id`, `parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`) VALUES ('', '', 'SQL监控', '/druid/sql', NULL, '', 'el-icon-info', '');
INSERT INTO `sys_menu` (`id`, `parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`) VALUES ('', '', '系统日志', '/sys/log', 'sys:log:view', '', 'el-icon-info', '');
INSERT INTO `sys_menu` (`id`, `parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`) VALUES ('', '', '查看', NULL, 'sys:user:view', '', NULL, '');
INSERT INTO `sys_menu` (`id`, `parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`) VALUES ('', '', '新增', NULL, 'sys:user:add', '', NULL, '');
INSERT INTO `sys_menu` (`id`, `parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`) VALUES ('', '', '修改', NULL, 'sys:user:edit', '', NULL, '');
INSERT INTO `sys_menu` (`id`, `parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`) VALUES ('', '', '删除', NULL, 'sys:user:delete', '', NULL, '');
INSERT INTO `sys_menu` (`id`, `parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`) VALUES ('', '', '查看', NULL, 'sys:dept:view', '', NULL, '');
INSERT INTO `sys_menu` (`id`, `parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`) VALUES ('', '', '新增', NULL, 'sys:dept:add', '', NULL, '');
INSERT INTO `sys_menu` (`id`, `parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`) VALUES ('', '', '修改', NULL, 'sys:dept:edit', '', NULL, '');
INSERT INTO `sys_menu` (`id`, `parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`) VALUES ('', '', '删除', NULL, 'sys:dept:delete', '', NULL, '');
INSERT INTO `sys_menu` (`id`, `parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`) VALUES ('', '', '查看', NULL, 'sys:role:view', '', NULL, '');
INSERT INTO `sys_menu` (`id`, `parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`) VALUES ('', '', '新增', NULL, 'sys:role:add', '', NULL, '');
INSERT INTO `sys_menu` (`id`, `parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`) VALUES ('', '', '修改', NULL, 'sys:role:edit', '', NULL, '');
INSERT INTO `sys_menu` (`id`, `parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`) VALUES ('', '', '删除', NULL, 'sys:role:delete', '', NULL, '');
INSERT INTO `sys_menu` (`id`, `parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`) VALUES ('', '', '查看', NULL, 'sys:menu:view', '', NULL, '');
INSERT INTO `sys_menu` (`id`, `parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`) VALUES ('', '', '新增', NULL, 'sys:menu:add', '', NULL, '');
INSERT INTO `sys_menu` (`id`, `parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`) VALUES ('', '', '修改', NULL, 'sys:menu:edit', '', NULL, '');
INSERT INTO `sys_menu` (`id`, `parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`) VALUES ('', '', '删除', NULL, 'sys:menu:delete', '', NULL, '');
INSERT INTO `sys_menu` (`id`, `parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`) VALUES ('', '', '内容管理', NULL, NULL, '', 'el-icon-document', '');
INSERT INTO `sys_menu` (`id`, `parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`) VALUES ('', '', '栏目管理', '/content/category', NULL, '', 'el-icon-tickets', '');
INSERT INTO `sys_menu` (`id`, `parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`) VALUES ('', '', '文章管理', '/content/artical', NULL, '', 'el-icon-tickets', '');
INSERT INTO `sys_menu` (`id`, `parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`) VALUES ('', '', '使用案例', NULL, NULL, '', 'el-icon-picture-outline', '');
INSERT INTO `sys_menu` (`id`, `parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`) VALUES ('', '', '国际化', '/demo/i18n', NULL, '', 'el-icon-edit', '');
INSERT INTO `sys_menu` (`id`, `parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`) VALUES ('', '', '换皮肤', '/demo/theme', NULL, '', 'el-icon-picture', '');
-- --------------------------------------
-- Records of `sys_role_menu`
-- --------------------------------------
INSERT INTO `sys_role_menu` (`id`, `role_id`, `menu_id`) VALUES ('', '', '');
INSERT INTO `sys_role_menu` (`id`, `role_id`, `menu_id`) VALUES ('', '', '');
INSERT INTO `sys_role_menu` (`id`, `role_id`, `menu_id`) VALUES ('', '', '');
INSERT INTO `sys_role_menu` (`id`, `role_id`, `menu_id`) VALUES ('', '', '');
INSERT INTO `sys_role_menu` (`id`, `role_id`, `menu_id`) VALUES ('', '', '');
INSERT INTO `sys_role_menu` (`id`, `role_id`, `menu_id`) VALUES ('', '', '');
INSERT INTO `sys_role_menu` (`id`, `role_id`, `menu_id`) VALUES ('', '', '');
INSERT INTO `sys_role_menu` (`id`, `role_id`, `menu_id`) VALUES ('', '', '');
INSERT INTO `sys_role_menu` (`id`, `role_id`, `menu_id`) VALUES ('', '', '');
INSERT INTO `sys_role_menu` (`id`, `role_id`, `menu_id`) VALUES ('', '', '');
INSERT INTO `sys_role_menu` (`id`, `role_id`, `menu_id`) VALUES ('', '', '');
INSERT INTO `sys_role_menu` (`id`, `role_id`, `menu_id`) VALUES ('', '', ''); -- --------------------------------------
-- Records of `sys_dict`
-- --------------------------------------
INSERT INTO `sys_dict` (`id`, `value`, `label`, `type`, `description`, `sort`) VALUES ('', 'male', '男', 'sex', '男性', '');
INSERT INTO `sys_dict` (`id`, `value`, `label`, `type`, `description`, `sort`) VALUES ('', 'female', '女', 'sex', '女性', '');
然后使用Mybatis-Generator自动生成Model,还有Mapper类,以及*.xml文件
一、首先在pom.xml中引入pagehelper-spring-boot-starter包
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper-spring-boot-starter</artifactId>
<version>${pagehelper.version}</version>
</dependency>
完整的pom如下:
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.4.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<groupId>com.louis.springboot.demo</groupId>
<artifactId>springboot-demo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging> <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<mybatis.spring.version>1.3.2</mybatis.spring.version>
<com.alibaba.druid.version>1.1.10</com.alibaba.druid.version>
<log4j.version>1.2.17</log4j.version>
<pagehelper.version>1.2.5</pagehelper.version>
</properties> <dependencies>
<!-- spring boot -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency> <dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency> <!-- mybatis -->
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>${mybatis.spring.version}</version>
</dependency>
<!-- mysql -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid-spring-boot-starter</artifactId>
<version>${com.alibaba.druid.version}</version>
</dependency>
<!-- log4j -->
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>${log4j.version}</version>
</dependency>
<!-- swagger -->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.9.2</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.9.2</version>
</dependency>
<!-- pagehelper -->
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper-spring-boot-starter</artifactId>
<version>${pagehelper.version}</version>
</dependency>
</dependencies> <build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
<!-- 打包时拷贝MyBatis的映射文件 -->
<resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/sqlmap/*.xml</include>
</includes>
<filtering>false</filtering>
</resource>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>**/*.*</include>
</includes>
<filtering>true</filtering>
</resource>
</resources>
</build>
</project>
二、然后开始编写请求的PageRequest.java和PageResult.java类
PageRequest.java
public class PageRequest { /**
* 当前页码
*/
private int pageNum;
/**
* 每页数量
*/
private int pageSize; public int getPageNum() {
return pageNum;
}
public int getPageSize() {
return pageSize;
}
public void setPageNum(int pageNum) {
this.pageNum = pageNum;
}
public void setPageSize(int pageSize) {
this.pageSize = pageSize;
} }
PageResult.java
public class PageResult { //当前页码
private int pageNum;
//每页数量
private int pageSize;
//数据总条数
private long totalSize;
//页码总数
private int totalPages;
//数据
private List<?> conent;
public int getPageNum() {
return pageNum;
}
public int getPageSize() {
return pageSize;
}
public long getTotalSize() {
return totalSize;
}
public int getTotalPages() {
return totalPages;
}
public List<?> getConent() {
return conent;
}
public void setPageNum(int pageNum) {
this.pageNum = pageNum;
}
public void setPageSize(int pageSize) {
this.pageSize = pageSize;
}
public void setTotalSize(long totalSize) {
this.totalSize = totalSize;
}
public void setTotalPages(int totalPages) {
this.totalPages = totalPages;
}
public void setConent(List<?> conent) {
this.conent = conent;
} }
三、然后开始编写Controller类
@RestController
@RequestMapping("menu")
public class SysMenuController { @Autowired
private SysMenuService sysMenuService; /**
* @Title: findPage
* @Description: 此处controller要使用POST的请求方式,主要是@RequestBody 提交的数据需要时POST形式提交
* @param pageRequest
* @return HttpResult 返回类型
* @throws
*/
@PostMapping(value = "/findPage")
public HttpResult findPage(@RequestBody PageRequest pageRequest ) {
return HttpResult.ok(this.sysMenuService.findPage(pageRequest ));
}
}
SysMenuService.java
public interface SysMenuService extends CurdService<SysMenu>{ /**
* @Title: findPage
* @Description: 分页查询接口
* @param @param pageQuery
* @param @return 参数说明
* @return Object 返回类型
* @throws
*/
PageResult findPage(PageRequest pageRequest); }
SysMenuServiceImpl.java
@Service
public class SysMenuServiceImpl implements SysMenuService { @Autowired
private SysMenuMapper sysMenuMapper; /*
* Title: save
*Description:
* @param record
* @return
* @see com.louis.kitty.core.service.CurdService#save(java.lang.Object)
*/
@Override
public int save(SysMenu record) {
return this.sysMenuMapper.insertSelective(record);
} /*
* Title: upate
*Description:
* @param record
* @return
* @see com.louis.kitty.core.service.CurdService#upate(java.lang.Object)
*/
@Override
public int upate(SysMenu record) {
return this.sysMenuMapper.updateByPrimaryKeySelective(record);
} /*
* Title: delete
*Description:
* @param record
* @return
* @see com.louis.kitty.core.service.CurdService#delete(java.lang.Object)
*/
@Override
public int delete(SysMenu record) {
return this.sysMenuMapper.deleteByPrimaryKey(record.getId());
} /*
* Title: delete
*Description:
* @param records
* @return
* @see com.louis.kitty.core.service.CurdService#delete(java.util.List)
*/
@Override
public int delete(List<SysMenu> records) {
for (SysMenu record : records) {
delete(record);
}
return 1;
} /*
* Title: findById
*Description:
* @param id
* @return
* @see com.louis.kitty.core.service.CurdService#findById(java.lang.Long)
*/
@Override
public SysMenu findById(Long id) {
return this.sysMenuMapper.selectByPrimaryKey(id);
} /*
* Title: findPage
*Description:
* @param pageResult
* @return
* @see com.louis.kitty.core.service.CurdService#findPage(com.louis.kitty.admin.page.PageRequest)
*/
@Override
public PageResult findPage(PageRequest pageRequest) {
return PageUtils.getPageResult(pageRequest, pageInfo(pageRequest));
} /**
* @Title: pageInfo
* @Description: TODO(这里用一句话描述这个方法的作用)
* @param @param pageRequest
* @param @return 参数说明
* @return PageInfo<?> 返回类型
* @throws
*/
private PageInfo<SysMenu> pageInfo(PageRequest pageRequest) {
int pageNum = pageRequest.getPageNum();
int pageSize = pageRequest.getPageSize();
PageHelper.startPage(pageNum, pageSize);
List<SysMenu> sysMenus = this.sysMenuMapper.findPage();
return new PageInfo<SysMenu>(sysMenus);
}
}
其中基础服务类如下CurdService.java
/**
* @ClassName: CurdService
* @Description: 通用CURD操作
* @author lr
* @date 2018年11月6日 上午10:42:23
*
*/
public interface CurdService<T> {
/**
* @Title: save
* @Description: 保存操作
* @param @param record
* @param @return 参数说明
* @return int 返回类型
* @throws
*/
int save(T record);
/**
* @Title: upate
* @Description: 更新操作
* @param @param record
* @param @return 参数说明
* @return int 返回类型
* @throws
*/
int upate(T record);
/**
* @Title: delete
* @Description: 删除操作
* @param @param record
* @param @return 参数说明
* @return int 返回类型
* @throws
*/
int delete(T record);
/**
* @Title: delete
* @Description: 批量删除操作
* @param @param records
* @param @return 参数说明
* @return int 返回类型
* @throws
*/
int delete(List<T> records);
/**
* @Title: findById
* @Description: 根据ID查询
* @param @param id
* @param @return 参数说明
* @return T 返回类型
* @throws
*/
T findById(Long id); /**
* @Title: findPage
* @Description: 分页查询
* @param pageRequest 自定义统一分页查询要求
* @return PageResult 自定义统一分返回类型
* @throws
*/
PageResult findPage(PageRequest pageRequest);
}
controller的返回结果HttpResult.java
/**
* @ClassName: HttpResult
* @Description: TODO(这里用一句话描述这个类的作用)
* @author lr
* @date 2018年11月6日 上午10:32:30
*
*/
public class HttpResult { private int code;
private String msg;
private Object data; public static HttpResult error() {
return error(HttpStatus.SC_INTERNAL_SERVER_ERROR, "未知异常,请联系管理员");
} public static HttpResult error(String msg) {
return error(HttpStatus.SC_INTERNAL_SERVER_ERROR, msg);
} public static HttpResult error(int code, String msg) {
HttpResult r = new HttpResult();
r.setCode(code);
r.setMsg(msg);
return r;
} public static HttpResult ok() {
return new HttpResult();
} public static HttpResult ok(Object data) {
HttpResult r = new HttpResult();
r.setData(data);
return r;
} public static HttpResult ok(String msg) {
HttpResult r = new HttpResult();
r.setMsg(msg);
return r;
}
public int getCode() {
return code;
} public String getMsg() {
return msg;
} public Object getData() {
return data;
} public void setCode(int code) {
this.code = code;
} public void setMsg(String msg) {
this.msg = msg;
} public void setData(Object data) {
this.data = data;
} }
ReflectionUtils.java 类如下:
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method; /**
* 反射相关辅助方法
* @author Louis
* @date Aug 19, 2018
*/
public class ReflectionUtils { /**
* 根据方法名调用指定对象的方法
* @param object 要调用方法的对象
* @param method 要调用的方法名
* @param args 参数对象数组
* @return
*/
public static Object invoke(Object object, String method, Object... args) {
Object result = null;
Class<? extends Object> clazz = object.getClass();
Method queryMethod = getMethod(clazz, method, args);
if(queryMethod != null) {
try {
result = queryMethod.invoke(object, args);
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
}
} else {
try {
throw new NoSuchMethodException(clazz.getName() + " 类中没有找到 " + method + " 方法。");
} catch (NoSuchMethodException e) {
e.printStackTrace();
}
}
return result;
} /**
* 根据方法名和参数对象查找方法
* @param clazz
* @param name
* @param args 参数实例数据
* @return
*/
public static Method getMethod(Class<? extends Object> clazz, String name, Object[] args) {
Method queryMethod = null;
Method[] methods = clazz.getMethods();
for(Method method:methods) {
if(method.getName().equals(name)) {
Class<?>[] parameterTypes = method.getParameterTypes();
if(parameterTypes.length == args.length) {
boolean isSameMethod = true;
for(int i=0; i<parameterTypes.length; i++) {
Object arg = args[i];
if(arg == null) {
arg = "";
}
if(!parameterTypes[i].equals(args[i].getClass())) {
isSameMethod = false;
}
}
if(isSameMethod) {
queryMethod = method;
break ;
}
}
}
}
return queryMethod;
}
}
然后启动就可以看到接口数据了:
主要返回的数据如下:
{
"code": 0,
"msg": null,
"data": {
"pageNum": 1,
"pageSize": 10,
"totalSize": 29,
"totalPages": 3,
"conent": [
{
"id": 1,
"createBy": null,
"createTime": null,
"lastUpdateBy": null,
"lastUpdateTime": null,
"parentId": 0,
"name": "系统管理",
"url": null,
"perms": null,
"type": 0,
"icon": "fa el-icon-setting",
"orderNum": 0,
"delFlag": 0,
"parentName": null,
"level": null,
"children": null
},
{
"id": 2,
"createBy": null,
"createTime": null,
"lastUpdateBy": null,
"lastUpdateTime": null,
"parentId": 1,
"name": "用户管理",
"url": "/sys/user",
"perms": null,
"type": 1,
"icon": "el-icon-service",
"orderNum": 1,
"delFlag": 0,
"parentName": null,
"level": null,
"children": null
},
{
"id": 3,
"createBy": null,
"createTime": null,
"lastUpdateBy": null,
"lastUpdateTime": null,
"parentId": 1,
"name": "机构管理",
"url": "/sys/dept",
"perms": null,
"type": 1,
"icon": "el-icon-news",
"orderNum": 2,
"delFlag": 0,
"parentName": null,
"level": null,
"children": null
},
{
"id": 4,
"createBy": null,
"createTime": null,
"lastUpdateBy": null,
"lastUpdateTime": null,
"parentId": 1,
"name": "角色管理",
"url": "/sys/role",
"perms": null,
"type": 1,
"icon": "el-icon-view",
"orderNum": 4,
"delFlag": 0,
"parentName": null,
"level": null,
"children": null
},
{
"id": 5,
"createBy": null,
"createTime": null,
"lastUpdateBy": null,
"lastUpdateTime": null,
"parentId": 1,
"name": "菜单管理",
"url": "/sys/menu",
"perms": null,
"type": 1,
"icon": "el-icon-menu",
"orderNum": 5,
"delFlag": 0,
"parentName": null,
"level": null,
"children": null
},
{
"id": 6,
"createBy": null,
"createTime": null,
"lastUpdateBy": null,
"lastUpdateTime": null,
"parentId": 1,
"name": "SQL监控",
"url": "/druid/sql",
"perms": null,
"type": 1,
"icon": "el-icon-info",
"orderNum": 6,
"delFlag": 0,
"parentName": null,
"level": null,
"children": null
},
{
"id": 8,
"createBy": null,
"createTime": null,
"lastUpdateBy": null,
"lastUpdateTime": null,
"parentId": 1,
"name": "系统日志",
"url": "/sys/log",
"perms": "sys:log:view",
"type": 1,
"icon": "el-icon-info",
"orderNum": 7,
"delFlag": 0,
"parentName": null,
"level": null,
"children": null
},
{
"id": 9,
"createBy": null,
"createTime": null,
"lastUpdateBy": null,
"lastUpdateTime": null,
"parentId": 2,
"name": "查看",
"url": null,
"perms": "sys:user:view",
"type": 2,
"icon": null,
"orderNum": 0,
"delFlag": 0,
"parentName": null,
"level": null,
"children": null
},
{
"id": 10,
"createBy": null,
"createTime": null,
"lastUpdateBy": null,
"lastUpdateTime": null,
"parentId": 2,
"name": "新增",
"url": null,
"perms": "sys:user:add",
"type": 2,
"icon": null,
"orderNum": 0,
"delFlag": 0,
"parentName": null,
"level": null,
"children": null
},
{
"id": 11,
"createBy": null,
"createTime": null,
"lastUpdateBy": null,
"lastUpdateTime": null,
"parentId": 2,
"name": "修改",
"url": null,
"perms": "sys:user:edit",
"type": 2,
"icon": null,
"orderNum": 0,
"delFlag": 0,
"parentName": null,
"level": null,
"children": null
}
]
}
}
SpringBoot 分页处理的更多相关文章
- spring-boot分页插件
1.分页插件,spring-boot.,第一次调用时,存值到 model.addAttribute("status", id);页面获取2.页面获取 后台存入的值,放在input ...
- springboot分页插件的使用
在springboot工程下的pom.xml中添加依赖 <!--分页 pagehelper --> <dependency> <groupId>com.github ...
- vue+ springboot 分页(两种方式:sql分页 & PageHelper 分页)
方法一:sql分页 思路:使用数据库进行分页 前端使用element-ui的分页组件,往后台传第几页的起始行offest 以及每页多少行pageSize,后台根据起始行数和每页的行数可以算出该页的 ...
- SpringBoot使用PageHelper进行分页
因为SpringBoot就是为了实现没有配置文件,因此之前手动在Mybatis中配置的PageHelper现在需要重新配置,而且配置方式与之前的SSM框架中还是有点点区别. 首先需要在pom文件 ...
- 基于springboot的ssm
参考该网址成功搭建: https://blog.csdn.net/liboyang71/article/details/73459909 目前有几个问题: 1.我使用application.yml配置 ...
- 1、springboot+mybatis+zookeeper+dubbox+maven+pagehelper
一.创建普通的maven的web项目 2.配置KD42WF_Part1下的pom.xml <?xml version="1.0" encoding="UTF-8&q ...
- 记录一个pom文件
rt <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://m ...
- SpringBoot JPA实现增删改查、分页、排序、事务操作等功能
今天给大家介绍一下SpringBoot中JPA的一些常用操作,例如:增删改查.分页.排序.事务操作等功能.下面先来介绍一下JPA中一些常用的查询操作: //And --- 等价于 SQL 中的 and ...
- springboot用thymeleaf模板的paginate分页
本文根据一个简单的user表为例,展示 springboot集成mybatis,再到前端分页完整代码(新手自学,不足之处欢迎纠正): 先看java部分 pom.xml 加入 <!--支持 Web ...
随机推荐
- socket tcp缓冲区大小的默认值、最大值
Author:阿冬哥 Created:2013-4-17 Blog:http://blog.csdn.net/c359719435/ Copyright 2013 阿冬哥 http://blog.cs ...
- Linux内核:分析coredump文件 - 内核代码崩溃
转自:http://blog.csdn.net/guowenyan001/article/details/12975221 一.分析Core文件 1.1 找到core文件目录,启动mycrash:my ...
- USB OTG简单介绍、与普通USB线的差别
USB有三类接口A类接口 -----------最常见的扁平接口,四芯 VCC GND D+ D- B类接口 ...
- [Web 前端 ] 五大WEB主流浏览器及四大内核
现在国内常见的浏览器有:IE.Firefox.Safari.Opera.Google Chome.QQ浏览器.搜狗浏览器.百度浏览器.猎豹浏览器.UC浏览器.360浏览器.遨游浏览器.世界之窗浏览器等 ...
- dubbo源码解析-spi(二)
前言 上一篇简单的介绍了spi的基本一些概念,在末尾也提到了,dubbo对jdk的spi进行了一些改进,具体改进了什么,来看看文档的描述 JDK 标准的 SPI 会一次性实例化扩展点所有实现,如果有扩 ...
- mysql-5.7.18解压版启动mysql服务
1.下载mysql社区版 2.解压到D:\Program Files 3.在D:\Program Files\mysql-5.7.18-winx64\bin下,新建文件my.ini,内容如下: [cl ...
- HttpWebRequest 对象池 HTTP协议 HttpWebRequest和 Socket的一点总结
相信接触过网络开发的人对HTTP.HttpWebRequest.Socket这些东西都不陌生吧.它们之间的一些介绍和关系我这里都忽略了.开我们平时开发过程中也是很少有机会接触大什么大并发这个东东,一般 ...
- jQuery 发送验证码倒计时按钮
{ wait:90, hsTime:function(that){ if (this.wait == 0) { $('#hsbtn').removeAttr("disabled") ...
- ofstream的使用方法--超级精细。C++文件写入、读出函数(转)
ofstream的使用方法ofstream是从内存到硬盘,ifstream是从硬盘到内存,其实所谓的流缓冲就是内存空间; 在C++中,有一个stream这个类,所有的I/O都以这个“流”类为基础的, ...
- java web文件下载功能实现 (转)
http://blog.csdn.net/longshengguoji/article/details/39433307 需求:实现一个具有文件下载功能的网页,主要下载压缩包和图片 两种实现方法: 一 ...