论坛-项目
项目地址:https://gitee.com/zwtgit/bbs
博客地址:https://www.cnblogs.com/zwtblog/p/15217214.html
效果图
数据库
CREATE DATABASE /*!32312 IF NOT EXISTS*/`zwtBBS` /*!40100 DEFAULT CHARACTER SET utf8 */;
USE `zwtBBS`;
/*Table structure for table `zwt_blog` */
DROP TABLE IF EXISTS `zwt_blog`;
CREATE TABLE `zwt_blog` (
`id` int(10) NOT NULL AUTO_INCREMENT COMMENT '自增id',
`bid` varchar(200) NOT NULL COMMENT '博客id',
`title` varchar(200) NOT NULL COMMENT '博客标题',
`content` longtext NOT NULL COMMENT '博客内容',
`sort` int(1) NOT NULL DEFAULT '0' COMMENT '排序 0 普通 1 置顶',
`views` int(10) NOT NULL DEFAULT '0' COMMENT '浏览量',
`author_id` varchar(200) NOT NULL COMMENT '作者id',
`author_name` varchar(200) NOT NULL COMMENT '作者名',
`author_avatar` varchar(500) NOT NULL COMMENT '作者头像',
`category_id` int(10) NOT NULL COMMENT '问题分类id',
`category_name` varchar(50) NOT NULL COMMENT '问题分类名称',
`gmt_create` datetime NOT NULL COMMENT '创建时间',
`gmt_update` datetime NOT NULL COMMENT '修改时间',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=30 DEFAULT CHARSET=utf8;
/*Table structure for table `zwt_blog_category` */
DROP TABLE IF EXISTS `zwt_blog_category`;
CREATE TABLE `zwt_blog_category` (
`id` int(10) NOT NULL AUTO_INCREMENT COMMENT '自增id',
`category` varchar(50) NOT NULL COMMENT '博客分类',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=10 DEFAULT CHARSET=utf8;
/*Table structure for table `zwt_comment` */
DROP TABLE IF EXISTS `zwt_comment`;
CREATE TABLE `zwt_comment` (
`id` int(10) NOT NULL AUTO_INCREMENT COMMENT '自增id',
`comment_id` varchar(200) NOT NULL COMMENT '评论唯一id',
`topic_category` int(1) NOT NULL COMMENT '1博客 2问答',
`topic_id` varchar(200) NOT NULL COMMENT '评论主题id',
`user_id` varchar(200) NOT NULL COMMENT '评论者id',
`user_name` varchar(200) NOT NULL COMMENT '评论者昵称',
`user_avatar` varchar(500) NOT NULL COMMENT '评论者头像',
`content` longtext NOT NULL COMMENT '评论内容',
`gmt_create` datetime NOT NULL COMMENT '评论创建时间',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=137 DEFAULT CHARSET=utf8;
/*Table structure for table `zwt_download` */
DROP TABLE IF EXISTS `zwt_download`;
CREATE TABLE `zwt_download` (
`dname` varchar(100) NOT NULL COMMENT '资源名',
`ddesc` varchar(500) NOT NULL COMMENT '资源链接',
`dcode` varchar(50) NOT NULL COMMENT '提取码'
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*Table structure for table `zwt_invite` */
DROP TABLE IF EXISTS `zwt_invite`;
CREATE TABLE `zwt_invite` (
`id` int(10) NOT NULL AUTO_INCREMENT COMMENT '自增id',
`code` varchar(200) NOT NULL COMMENT '邀请码',
`uid` varchar(200) DEFAULT NULL COMMENT '用户id',
`status` int(1) NOT NULL DEFAULT '0' COMMENT '状态 0 未使用 1 使用',
`active_time` datetime DEFAULT NULL COMMENT '激活时间',
`gmt_create` datetime NOT NULL COMMENT '创建时间',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1217 DEFAULT CHARSET=utf8;
/*Table structure for table `zwt_question` */
DROP TABLE IF EXISTS `zwt_question`;
CREATE TABLE `zwt_question` (
`id` int(10) NOT NULL AUTO_INCREMENT COMMENT '自增id',
`qid` varchar(200) NOT NULL COMMENT '问题id',
`title` varchar(200) NOT NULL COMMENT '问题标题',
`content` longtext NOT NULL COMMENT '问题内容',
`status` int(1) NOT NULL DEFAULT '0' COMMENT '状态 0 未解决 1 已解决',
`sort` int(1) NOT NULL DEFAULT '0' COMMENT '排序 0 普通 1 置顶',
`views` int(10) NOT NULL DEFAULT '0' COMMENT '浏览量',
`author_id` varchar(200) NOT NULL COMMENT '作者id',
`author_name` varchar(200) NOT NULL COMMENT '作者名',
`author_avatar` varchar(500) NOT NULL COMMENT '作者头像',
`category_id` int(10) NOT NULL COMMENT '问题分类id',
`category_name` varchar(50) NOT NULL COMMENT '问题分类名称',
`gmt_create` datetime NOT NULL COMMENT '创建时间',
`gmt_update` datetime NOT NULL COMMENT '修改时间',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=35 DEFAULT CHARSET=utf8;
/*Table structure for table `zwt_question_category` */
DROP TABLE IF EXISTS `zwt_question_category`;
CREATE TABLE `zwt_question_category` (
`id` int(10) NOT NULL AUTO_INCREMENT COMMENT '自增id',
`category` varchar(50) NOT NULL COMMENT '问题分类',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=15 DEFAULT CHARSET=utf8;
/*Table structure for table `zwt_say` */
DROP TABLE IF EXISTS `zwt_say`;
CREATE TABLE `zwt_say` (
`id` varchar(200) NOT NULL COMMENT '唯一id',
`title` varchar(200) NOT NULL COMMENT '标题',
`content` varchar(5000) NOT NULL COMMENT '内容',
`gmt_create` datetime NOT NULL COMMENT '时间',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*Table structure for table `zwt_user` */
DROP TABLE IF EXISTS `zwt_user`;
CREATE TABLE `zwt_user` (
`id` int(10) NOT NULL AUTO_INCREMENT COMMENT '自增id',
`uid` varchar(200) NOT NULL COMMENT '用户编号',
`role_id` int(10) NOT NULL COMMENT '角色编号',
`username` varchar(100) NOT NULL COMMENT '用户名',
`password` varchar(200) NOT NULL COMMENT '密码',
`avatar` varchar(500) NOT NULL DEFAULT '/images/avatar/avatar-1.jpg' COMMENT '头像',
`login_date` datetime NOT NULL COMMENT '登录时间',
`gmt_create` datetime NOT NULL COMMENT '创建时间',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=840 DEFAULT CHARSET=utf8;
/*Table structure for table `zwt_user_donate` */
DROP TABLE IF EXISTS `zwt_user_donate`;
CREATE TABLE `zwt_user_donate` (
`uid` varchar(200) NOT NULL COMMENT '用户id',
`donate_json` varchar(2000) NOT NULL COMMENT '赞赏二维码信息'
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*Table structure for table `zwt_user_info` */
DROP TABLE IF EXISTS `zwt_user_info`;
CREATE TABLE `zwt_user_info` (
`uid` varchar(200) NOT NULL COMMENT '用户id',
`nickname` varchar(80) DEFAULT NULL COMMENT '用户昵称',
`realname` varchar(80) DEFAULT NULL COMMENT '真实姓名',
`qq` varchar(20) DEFAULT NULL COMMENT 'QQ',
`wechat` varchar(200) DEFAULT NULL COMMENT 'WeChat',
`email` varchar(500) DEFAULT NULL COMMENT '邮箱',
`phone` varchar(20) DEFAULT NULL COMMENT '手机',
`work` varchar(200) DEFAULT NULL COMMENT '工作',
`address` varchar(500) DEFAULT NULL COMMENT '地址',
`hobby` varchar(500) DEFAULT NULL COMMENT '爱好',
`intro` varchar(2000) DEFAULT NULL COMMENT '自我介绍'
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*Table structure for table `zwt_user_role` */
DROP TABLE IF EXISTS `zwt_user_role`;
CREATE TABLE `zwt_user_role` (
`id` int(10) NOT NULL AUTO_INCREMENT COMMENT '角色编号',
`name` varchar(200) NOT NULL COMMENT '角色名称',
`description` varchar(500) NOT NULL DEFAULT '无描述...' COMMENT '角色描述',
`gmt_create` datetime NOT NULL COMMENT '创建时间',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECzwt=@OLD_FOREIGN_KEY_CHECzwt */;
/*!40014 SET UNIQUE_CHECzwt=@OLD_UNIQUE_CHECzwt */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
导入依赖
<dependencies>
<!-- spring security-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.thymeleaf.extras</groupId>
<artifactId>thymeleaf-extras-springsecurity5</artifactId>
<version>3.0.4.RELEASE</version>
</dependency>
<!--Json&Date-->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.68</version>
</dependency>
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>2.10.1</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>
<!--数据库-->
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>3.0.5</version>
</dependency>
<dependency>
<groupId>org.apache.velocity</groupId>
<artifactId>velocity-engine-core</artifactId>
<version>2.0</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.47</version>
</dependency>
<!-- web-thymeleaf -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<!-- 开发工具 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</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>-->
</dependencies>
<!--打包插件-->
<build>
<resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.xml</include>
</includes>
<filtering>true</filtering>
</resource>
<!-- maven 过滤文件导致 iconfont展示错误 -->
<resource>
<directory>src/main/resources</directory>
<includes>
<include>*.properties</include>
<include>static/**</include>
<include>templates/**</include>
</includes>
<filtering>false</filtering>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
导入静态资源
详情见代码
配置文件
spring.profiles.active=dev
#dev
server.port=8080
# 关闭缓存
spring.thymeleaf.cache=false
# swagger
swagger.enable=true
# 数据库连接
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.datasource.url=jdbc:mysql://localhost:3306/zwtbbs?useUnicode=true&characterEncoding=utf-8&useSSL=false
spring.datasource.username=root
spring.datasource.password=240055
# mybatis日志
mybatis-plus.configuration.log-impl=org.apache.ibatis.logging.stdout.StdOutImpl
mybatis-plus.mapper-locations=classpath*:com/zwt/mapper/xml/*.xml
mybatis-plus.type-aliases-package=com.zwt.pojo
#prod
server.port=8080
# 开启缓存
spring.thymeleaf.cache=true
# swagger
swagger.enable=false
# 服务器数据库连接
# mybatis日志
# mybatis-plus.configuration.log-impl=org.apache.ibatis.logging.stdout.StdOutImpl
mybatis-plus.mapper-locations=classpath*:com/zwt/mapper/xml/*.xml
mybatis-plus.type-aliases-package=com.zwt.pojo