SpringBoot 分頁處理
阿新 • • 發佈:2018-11-06
開始主要是要使用已經設計好的資料庫
-- ---------------------------------------------------- -- 使用者 -- ---------------------------------------------------- -- 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 ('1', 'admin', '9ec9750e709431dad22365cabc5c625482e574c74adaebba7dd02f1129e4ce1d', 'YzcmCZNvbXocrsz9dm8e', '4', '[email protected]', '13612345678', '1', '2018-08-14 11:11:11'); INSERT INTO `sys_user` (`id`, `name`, `password`, `salt`, `dept_id`, `email`, `mobile`, `status`, `create_time`) VALUES ('2', 'Louis', '9ec9750e709431dad22365cabc5c625482e574c74adaebba7dd02f1129e4ce1d', 'YzcmCZNvbXocrsz9dm8e', '6', '[email protected]', '18200932238', '1', '2018-08-14 11:11:11'); INSERT INTO `sys_user` (`id`, `name`, `password`, `salt`, `dept_id`, `email`, `mobile`, `status`, `create_time`) VALUES ('3', 'Kobe', '9ec9750e709431dad22365cabc5c625482e574c74adaebba7dd02f1129e4ce1d', 'YzcmCZNvbXocrsz9dm8e', '7', '[email protected]', '18200932238', '1', '2018-08-14 11:11:11'); INSERT INTO `sys_user` (`id`, `name`, `password`, `salt`, `dept_id`, `email`, `mobile`, `status`, `create_time`) VALUES ('4', 'Iverson', '9ec9750e709431dad22365cabc5c625482e574c74adaebba7dd02f1129e4ce1d', 'YzcmCZNvbXocrsz9dm8e', '8', '[email protected]', '18200932238', '1', '2018-08-14 11:11:11'); INSERT INTO `sys_user` (`id`, `name`, `password`, `salt`, `dept_id`, `email`, `mobile`, `status`, `create_time`) VALUES ('5', 'Iverson5', '9ec9750e709431dad22365cabc5c625482e574c74adaebba7dd02f1129e4ce1d', 'YzcmCZNvbXocrsz9dm8e', '12', '[email protected]', '18200932238', '1', '2018-08-14 11:11:11'); INSERT INTO `sys_user` (`id`, `name`, `password`, `salt`, `dept_id`, `email`, `mobile`, `status`, `create_time`) VALUES ('6', 'Iverson6', '9ec9750e709431dad22365cabc5c625482e574c74adaebba7dd02f1129e4ce1d', 'YzcmCZNvbXocrsz9dm8e', '12', '[email protected]', '18200932238', '1', '2018-08-14 11:11:11'); INSERT INTO `sys_user` (`id`, `name`, `password`, `salt`, `dept_id`, `email`, `mobile`, `status`, `create_time`) VALUES ('7', 'Iverson7', '9ec9750e709431dad22365cabc5c625482e574c74adaebba7dd02f1129e4ce1d', 'YzcmCZNvbXocrsz9dm8e', '13', '[email protected]', '18200932238', '1', '2018-08-14 11:11:11'); INSERT INTO `sys_user` (`id`, `name`, `password`, `salt`, `dept_id`, `email`, `mobile`, `status`, `create_time`) VALUES ('8', 'Iverson8', '9ec9750e709431dad22365cabc5c625482e574c74adaebba7dd02f1129e4ce1d', 'YzcmCZNvbXocrsz9dm8e', '14', '[email protected]', '18200932238', '1', '2018-08-14 11:11:11'); INSERT INTO `sys_user` (`id`, `name`, `password`, `salt`, `dept_id`, `email`, `mobile`, `status`, `create_time`) VALUES ('9', 'Iverson9', '9ec9750e709431dad22365cabc5c625482e574c74adaebba7dd02f1129e4ce1d', 'YzcmCZNvbXocrsz9dm8e', '15', '[email protected]', '18200932238', '1', '2018-08-14 11:11:11'); INSERT INTO `sys_user` (`id`, `name`, `password`, `salt`, `dept_id`, `email`, `mobile`, `status`, `create_time`) VALUES ('10', 'Iverson10', '9ec9750e709431dad22365cabc5c625482e574c74adaebba7dd02f1129e4ce1d', 'YzcmCZNvbXocrsz9dm8e', '4', '[email protected]', '18200932238', '1', '2018-08-14 11:11:11'); INSERT INTO `sys_user` (`id`, `name`, `password`, `salt`, `dept_id`, `email`, `mobile`, `status`, `create_time`) VALUES ('11', 'Iverson11', '9ec9750e709431dad22365cabc5c625482e574c74adaebba7dd02f1129e4ce1d', 'YzcmCZNvbXocrsz9dm8e', '6', '[email protected]', '18200932238', '1', '2018-08-14 11:11:11'); INSERT INTO `sys_user` (`id`, `name`, `password`, `salt`, `dept_id`, `email`, `mobile`, `status`, `create_time`) VALUES ('12', 'Iverson12', '9ec9750e709431dad22365cabc5c625482e574c74adaebba7dd02f1129e4ce1d', 'YzcmCZNvbXocrsz9dm8e', '15', '[email protected]', '18200932238', '1', '2018-08-14 11:11:11'); -- -------------------------------------- -- Records of `sys_role` -- -------------------------------------- INSERT INTO `sys_role` (`id`, `name`, `remark`, `create_time`) VALUES ('1', 'admin', '超級管理員', '2018-08-14 11:11:11'); INSERT INTO `sys_role` (`id`, `name`, `remark`, `create_time`) VALUES ('2', 'dev', '開發人員', '2018-08-14 11:11:11'); INSERT INTO `sys_role` (`id`, `name`, `remark`, `create_time`) VALUES ('3', 'test', '測試人員', '2018-08-14 11:11:11'); -- -------------------------------------- -- Records of `sys_user_role` -- -------------------------------------- INSERT INTO `sys_user_role` (`id`, `user_id`, `role_id`) VALUES ('1', '1', '1'); INSERT INTO `sys_user_role` (`id`, `user_id`, `role_id`) VALUES ('2', '2', '1'); INSERT INTO `sys_user_role` (`id`, `user_id`, `role_id`) VALUES ('3', '3', '2'); INSERT INTO `sys_user_role` (`id`, `user_id`, `role_id`) VALUES ('4', '4', '3'); -- -------------------------------------- -- Records of `sys_dept` -- -------------------------------------- INSERT INTO `sys_dept` (`id`, `parent_id`, `name`, `order_num`, `del_flag`) VALUES ('1', '0', '輕塵集團', '0', '0'); INSERT INTO `sys_dept` (`id`, `parent_id`, `name`, `order_num`, `del_flag`) VALUES ('2', '1', '北京分公司', '1', '0'); INSERT INTO `sys_dept` (`id`, `parent_id`, `name`, `order_num`, `del_flag`) VALUES ('3', '1', '上海分公司', '2', '0'); INSERT INTO `sys_dept` (`id`, `parent_id`, `name`, `order_num`, `del_flag`) VALUES ('4', '3', '技術部', '0', '0'); INSERT INTO `sys_dept` (`id`, `parent_id`, `name`, `order_num`, `del_flag`) VALUES ('6', '3', '宣傳部', '1', '0'); INSERT INTO `sys_dept` (`id`, `parent_id`, `name`, `order_num`, `del_flag`) VALUES ('7', '3', '銷售部', '2', '0'); INSERT INTO `sys_dept` (`id`, `parent_id`, `name`, `order_num`, `del_flag`) VALUES ('8', '3', '市場部', '3', '0'); INSERT INTO `sys_dept` (`id`, `parent_id`, `name`, `order_num`, `del_flag`) VALUES ('9', '0', '牧塵集團', '1', '0'); INSERT INTO `sys_dept` (`id`, `parent_id`, `name`, `order_num`, `del_flag`) VALUES ('10', '9', '北京分公司', '1', '0'); INSERT INTO `sys_dept` (`id`, `parent_id`, `name`, `order_num`, `del_flag`) VALUES ('11', '9', '上海分公司', '2', '0'); INSERT INTO `sys_dept` (`id`, `parent_id`, `name`, `order_num`, `del_flag`) VALUES ('12', '10', '技術部', '1', '0'); INSERT INTO `sys_dept` (`id`, `parent_id`, `name`, `order_num`, `del_flag`) VALUES ('13', '10', '宣傳部', '2', '0'); INSERT INTO `sys_dept` (`id`, `parent_id`, `name`, `order_num`, `del_flag`) VALUES ('14', '11', '銷售部', '1', '0'); INSERT INTO `sys_dept` (`id`, `parent_id`, `name`, `order_num`, `del_flag`) VALUES ('15', '11', '市場部', '2', '0'); -- -------------------------------------- -- Records of `sys_menu` -- -------------------------------------- INSERT INTO `sys_menu` (`id`, `parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`) VALUES ('1', '0', '系統管理', NULL, NULL, '0', 'fa el-icon-setting', '0'); INSERT INTO `sys_menu` (`id`, `parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`) VALUES ('2', '1', '使用者管理', '/sys/user', NULL, '1', 'el-icon-service', '1'); INSERT INTO `sys_menu` (`id`, `parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`) VALUES ('3', '1', '機構管理', '/sys/dept', NULL, '1', 'el-icon-news', '2'); INSERT INTO `sys_menu` (`id`, `parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`) VALUES ('4', '1', '角色管理', '/sys/role', NULL, '1', 'el-icon-view', '4'); INSERT INTO `sys_menu` (`id`, `parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`) VALUES ('5', '1', '選單管理', '/sys/menu', NULL, '1', 'el-icon-menu', '5'); INSERT INTO `sys_menu` (`id`, `parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`) VALUES ('6', '1', 'SQL監控', '/druid/sql', NULL, '1', 'el-icon-info', '6'); INSERT INTO `sys_menu` (`id`, `parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`) VALUES ('8', '1', '系統日誌', '/sys/log', 'sys:log:view', '1', 'el-icon-info', '7'); INSERT INTO `sys_menu` (`id`, `parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`) VALUES ('9', '2', '檢視', NULL, 'sys:user:view', '2', NULL, '0'); INSERT INTO `sys_menu` (`id`, `parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`) VALUES ('10', '2', '新增', NULL, 'sys:user:add', '2', NULL, '0'); INSERT INTO `sys_menu` (`id`, `parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`) VALUES ('11', '2', '修改', NULL, 'sys:user:edit', '2', NULL, '0'); INSERT INTO `sys_menu` (`id`, `parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`) VALUES ('12', '2', '刪除', NULL, 'sys:user:delete', '2', NULL, '0'); INSERT INTO `sys_menu` (`id`, `parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`) VALUES ('13', '3', '檢視', NULL, 'sys:dept:view', '2', NULL, '0'); INSERT INTO `sys_menu` (`id`, `parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`) VALUES ('14', '3', '新增', NULL, 'sys:dept:add', '2', NULL, '0'); INSERT INTO `sys_menu` (`id`, `parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`) VALUES ('15', '3', '修改', NULL, 'sys:dept:edit', '2', NULL, '0'); INSERT INTO `sys_menu` (`id`, `parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`) VALUES ('16', '3', '刪除', NULL, 'sys:dept:delete', '2', NULL, '0'); INSERT INTO `sys_menu` (`id`, `parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`) VALUES ('17', '4', '檢視', NULL, 'sys:role:view', '2', NULL, '0'); INSERT INTO `sys_menu` (`id`, `parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`) VALUES ('18', '4', '新增', NULL, 'sys:role:add', '2', NULL, '0'); INSERT INTO `sys_menu` (`id`, `parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`) VALUES ('19', '4', '修改', NULL, 'sys:role:edit', '2', NULL, '0'); INSERT INTO `sys_menu` (`id`, `parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`) VALUES ('20', '4', '刪除', NULL, 'sys:role:delete', '2', NULL, '0'); INSERT INTO `sys_menu` (`id`, `parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`) VALUES ('21', '5', '檢視', NULL, 'sys:menu:view', '2', NULL, '0'); INSERT INTO `sys_menu` (`id`, `parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`) VALUES ('22', '5', '新增', NULL, 'sys:menu:add', '2', NULL, '0'); INSERT INTO `sys_menu` (`id`, `parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`) VALUES ('23', '5', '修改', NULL, 'sys:menu:edit', '2', NULL, '0'); INSERT INTO `sys_menu` (`id`, `parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`) VALUES ('24', '5', '刪除', NULL, 'sys:menu:delete', '2', NULL, '0'); INSERT INTO `sys_menu` (`id`, `parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`) VALUES ('25', '0', '內容管理', NULL, NULL, '0', 'el-icon-document', '0'); INSERT INTO `sys_menu` (`id`, `parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`) VALUES ('26', '25', '欄目管理', '/content/category', NULL, '1', 'el-icon-tickets', '1'); INSERT INTO `sys_menu` (`id`, `parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`) VALUES ('27', '25', '文章管理', '/content/artical', NULL, '1', 'el-icon-tickets', '2'); INSERT INTO `sys_menu` (`id`, `parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`) VALUES ('28', '0', '使用案例', NULL, NULL, '0', 'el-icon-picture-outline', '0'); INSERT INTO `sys_menu` (`id`, `parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`) VALUES ('29', '28', '國際化', '/demo/i18n', NULL, '1', 'el-icon-edit', '1'); INSERT INTO `sys_menu` (`id`, `parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`) VALUES ('30', '28', '換面板', '/demo/theme', NULL, '1', 'el-icon-picture', '2'); -- -------------------------------------- -- Records of `sys_role_menu` -- -------------------------------------- INSERT INTO `sys_role_menu` (`id`, `role_id`, `menu_id`) VALUES ('1', '2', '25'); INSERT INTO `sys_role_menu` (`id`, `role_id`, `menu_id`) VALUES ('2', '2', '26'); INSERT INTO `sys_role_menu` (`id`, `role_id`, `menu_id`) VALUES ('3', '2', '27'); INSERT INTO `sys_role_menu` (`id`, `role_id`, `menu_id`) VALUES ('4', '2', '28'); INSERT INTO `sys_role_menu` (`id`, `role_id`, `menu_id`) VALUES ('5', '2', '29'); INSERT INTO `sys_role_menu` (`id`, `role_id`, `menu_id`) VALUES ('6', '2', '30'); INSERT INTO `sys_role_menu` (`id`, `role_id`, `menu_id`) VALUES ('7', '3', '25'); INSERT INTO `sys_role_menu` (`id`, `role_id`, `menu_id`) VALUES ('8', '3', '26'); INSERT INTO `sys_role_menu` (`id`, `role_id`, `menu_id`) VALUES ('9', '3', '27'); INSERT INTO `sys_role_menu` (`id`, `role_id`, `menu_id`) VALUES ('10', '3', '28'); INSERT INTO `sys_role_menu` (`id`, `role_id`, `menu_id`) VALUES ('11', '3', '29'); INSERT INTO `sys_role_menu` (`id`, `role_id`, `menu_id`) VALUES ('12', '3', '30'); -- -------------------------------------- -- Records of `sys_dict` -- -------------------------------------- INSERT INTO `sys_dict` (`id`, `value`, `label`, `type`, `description`, `sort`) VALUES ('1', 'male', '男', 'sex', '男性', '0'); INSERT INTO `sys_dict` (`id`, `value`, `label`, `type`, `description`, `sort`) VALUES ('2', 'female', '女', 'sex', '女性', '1');
然後使用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的對映檔案 <