1、數據庫表設計java
SET NAMES utf8mb4; SET FOREIGN_KEY_CHECKS = 0; -- ---------------------------- -- Table structure for sys_permission -- ---------------------------- DROP TABLE IF EXISTS `sys_permission`; CREATE TABLE `sys_permission` ( `id` varchar(255) NOT NULL DEFAULT '', `description` varchar(255) NOT NULL DEFAULT '' COMMENT '權限描述', `name` varchar(255) NOT NULL DEFAULT '' COMMENT '權限名稱', `pid` varchar(255) NOT NULL DEFAULT '' COMMENT '父節點', `url` varchar(255) NOT NULL DEFAULT '' COMMENT '受權連接', `create_time` datetime NOT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '建立時間', `update_time` datetime NOT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '修改時間', `deleted` int(11) NOT NULL DEFAULT '0' COMMENT '刪除標誌位', `version` int(11) NOT NULL DEFAULT '0' COMMENT '版本', PRIMARY KEY (`id`) USING BTREE ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COMMENT='權限表'; -- ---------------------------- -- Table structure for sys_role -- ---------------------------- DROP TABLE IF EXISTS `sys_role`; CREATE TABLE `sys_role` ( `id` varchar(255) NOT NULL DEFAULT '', `descprtion` varchar(255) DEFAULT '' COMMENT '角色描述', `name` varchar(255) DEFAULT '' COMMENT '角色名', `create_time` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '建立時間', `update_time` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '修改時間', `deleted` int(11) NOT NULL DEFAULT '0' COMMENT '刪除標誌位', `version` int(11) NOT NULL DEFAULT '0' COMMENT '版本', PRIMARY KEY (`id`) USING BTREE ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COMMENT='角色表'; -- ---------------------------- -- Table structure for sys_role_permission -- ---------------------------- DROP TABLE IF EXISTS `sys_role_permission`; CREATE TABLE `sys_role_permission` ( `permission_id` varchar(255) NOT NULL, `role_id` varchar(255) NOT NULL DEFAULT '', KEY `FKa6jx8n8xkesmjmv6jqug6bg68` (`role_id`), KEY `FKf8yllw1ecvwqy3ehyxawqa1qp` (`permission_id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COMMENT='角色權限關聯表'; -- ---------------------------- -- Table structure for sys_uer_role -- ---------------------------- DROP TABLE IF EXISTS `sys_uer_role`; CREATE TABLE `sys_uer_role` ( `uid` varchar(255) NOT NULL, `role_id` varchar(255) NOT NULL DEFAULT '', KEY `FKdpira1rf7d4dg92yp4fg2ltij` (`role_id`), KEY `FKdb9d5h4r2iy9rld4fcvbdp7ab` (`uid`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COMMENT='用戶角色關聯表'; -- ---------------------------- -- Table structure for sys_user_info -- ---------------------------- DROP TABLE IF EXISTS `sys_user_info`; CREATE TABLE `sys_user_info` ( `id` varchar(255) NOT NULL COMMENT '主鍵', `password` varchar(255) NOT NULL COMMENT '密碼', `username` varchar(255) NOT NULL COMMENT '用戶名', `age` int(11) NOT NULL COMMENT '年齡', `create_time` datetime NOT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '建立時間', `update_time` datetime NOT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '修改時間', `email` varchar(255) NOT NULL COMMENT '郵箱', `phone` varchar(255) NOT NULL COMMENT '電話', `parent_id` varchar(255) NOT NULL COMMENT '上級', `deleted` int(11) NOT NULL DEFAULT '0' COMMENT '刪除標誌位', `version` int(11) NOT NULL DEFAULT '0' COMMENT '版本', PRIMARY KEY (`id`) USING BTREE ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COMMENT='用戶表'; SET FOREIGN_KEY_CHECKS = 1;
2、新建項目:初始化一個 Spring Boot 工程。mysql
一、添加依賴web
<?xml version="1.0" encoding="UTF-8"?> <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 https://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.1.8.RELEASE</version> <relativePath/> </parent> <groupId>com.xiao</groupId> <artifactId>permission_system</artifactId> <version>0.0.1-SNAPSHOT</version> <name>permission_system</name> <description>Demo project for Spring Boot</description> <properties> <java.version>1.8</java.version> </properties> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> <exclusions> <exclusion> <groupId>org.junit.vintage</groupId> <artifactId>junit-vintage-engine</artifactId> </exclusion> </exclusions> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-security</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-thymeleaf</artifactId> </dependency> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <scope>runtime</scope> </dependency> <dependency> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> <optional>true</optional> </dependency> <dependency> <groupId>org.springframework.security</groupId> <artifactId>spring-security-test</artifactId> <scope>test</scope> </dependency> <!-- https://mvnrepository.com/artifact/com.baomidou/mybatis-plus --> <dependency> <groupId>com.baomidou</groupId> <artifactId>mybatis-plus-boot-starter</artifactId> <version>3.1.2</version> </dependency> <dependency> <groupId>com.baomidou</groupId> <artifactId>mybatis-plus-generator</artifactId> <version>3.2.0</version> </dependency> <!-- Beetl 代碼生成使用--> <dependency> <groupId>com.ibeetl</groupId> <artifactId>beetl</artifactId> <version>2.9.10</version> </dependency> <dependency> <groupId>com.baomidou</groupId> <artifactId>mybatis-plus-extension</artifactId> <version>3.2.0</version> <scope>compile</scope> </dependency> <!-- https://mvnrepository.com/artifact/io.swagger/swagger-annotations --> <dependency> <groupId>io.swagger</groupId> <artifactId>swagger-annotations</artifactId> <version>1.5.20</version> </dependency> <dependency> <groupId>p6spy</groupId> <artifactId>p6spy</artifactId> <version>3.8.4</version> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-security</artifactId> </dependency> <dependency> <groupId>org.aspectj</groupId> <artifactId>aspectjweaver</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-thymeleaf</artifactId> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> </plugins> </build> </project>
3、項目配置spring
#數據庫配置 spring.datasource.url=jdbc:mysql://47.106.95.68:3306/permission_system?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true&useSSL=false spring.datasource.username=root spring.datasource.password=000000 spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver #spring.datasource.driver-class-name=com.p6spy.engine.spy.P6SpyDriver #spring.datasource.url=jdbc:p6spy:mysql://localhost:3306/permission_system #日誌設置 logging.level.root = warn logging.level.com.xiao.permission_system.mapper = trace logging.pattern.console = %p%m%n #mapper.xml地址 mybatis-plus.mapper-locations = classpath*:/mapper/**/*.xml #全局設置主鍵類型 mybatis-plus.global-config.db-config.id-type = uuid #設置mybatis配置文件路徑 spring.config.location = classpath:mybatis-config.xml #MyBaits 別名包掃描路徑,經過該屬性能夠給包中的類註冊別名,註冊後在 Mapper 對應的 XML 文件中能夠直接使用類名,而不用使用全限定的類名(即 XML 中調用的時候不用包含包名)。 mybatis-plus.type-aliases-package = com.xiao.permission_system.entity #邏輯刪除狀態設置 mybatis-plus.global-config.db-config.logic-not-delete-value = 0 mybatis-plus.global-config.db-config.logic-delete-value= = 1 server.port=8088 #自定義用戶名和密碼 #spring.security.user.name=admin #spring.security.user.password=000000
4、項目文件結構設計 sql
5、代碼生成 http://www.javashuo.com/article/p-mupqrllf-na.html數據庫