The blog system

myblog-mybaits

Personal blogging system (SpringBoot+Mybatis) references blog addresses

Use the source code hope to be able to indicate the original blog and source code, and prohibit commercial use, thank you!

Project Address Baidu Web disk link:Pan.baidu.com/s/1eD3xAtlG…Extraction code: P71I

I. Technology stack

1. The front end

  • JS framework: JQuery
  • CSS framework: Semantic UI official website
  • Markdown editor: Editor Markdown
  • Code highlight: Code highlight PRISM
  • Animation effects: animate.css
  • Article table of Contents: Table of contents generates Tocbot
  • Music box: ZPlayer
  • Photo Wall: Lightbox plugin

2. The back end

  • Core framework: SpringBoot 2.2.5
  • Project construction: JDk1.8, Maven 3
  • Persistence layer framework: Mybatis
  • Template framework: Thymeleaf
  • Pagination plugin: PageHelper
  • Encryption: MD5 encryption
  • Operating environment: Tencent Cloud Centos7

3. The database

  • MySQL 5.7

Second, functional requirements

Because it is a personal blog, so there is no user rights management, just a simple distinction between ordinary users and administrators, here according to ordinary users and administrators to tell about the functional requirements, in fact, from the front page of the last blog can roughly see the requirements

1. Common users

  • View article information: article list, recommended articles, article title, article content, publication time, visits, comments and other information
  • View classified articles: classified list, classified article information
  • View timeline: View articles in the order they were published
  • Search for articles: Search by keyword in the search box on the right of the navigation bar
  • Listen to music: previous song, next song, volume control, play order control, view lyrics, etc
  • Leave a message: Leave a message and reply
  • View links: View and access links added by the blogger on the links page
  • View album information: album list, photo name, photo location, photo time, photo description

2. Administrator (stack master)

  • This user has all function rights of common users
  • Login: In the home path, add /admin to go to the login page and log in to the database using the user name and password
  • Article management: query article list, add article, edit article, delete article, search article
  • Category management: query category list, add category, edit category, delete category
  • Friendchain management: query friendchain list, add friendchain, edit friendchain, delete friendchain
  • Album management: query album list, add photos, edit photos, delete photos
  • Message management: after login, it will display the profile picture information of the stack owner and the delete message button, which can delete the message

Third, database design

Since the blogger uses JPA as the persistence layer to develop this blog at the beginning, the data table is automatically generated by JPA framework. When mybatis is used as the persistence layer, the database generated by JPA is used, but the comment table and message table are changed. If jPA is also used first, Use mybatis development partner here to note that if you use Mybatis development directly can be ignored

1. Data sheets

  • Blog data table: T_blog
  • Category table: T_TYPE
  • User data table: T_user
  • Comment data table: T_comment
  • Message data table: T_message
  • Friend data table: T_friend
  • Album data table: T_picture

2. Entity relationship

  • Blogs and categories are many-to-one: one blog corresponds to one category, and one category corresponds to multiple blogs
  • Blogs and users are many-to-one: one blog corresponds to one user, and one user corresponds to multiple blogs
  • Blogs and comments have a one-to-many relationship: one blog for many comments, one comment for one blog
  • Comments and replies are one-to-many: one comment can correspond to multiple replies, and one reply to one comment

The comments and comments are the same, and the friends and album tables are not related to other tables

3. Entity attributes

Blog attributes:

Classification attributes:

User attributes:

Comment attributes:

Message attributes:

Friendchain attributes:

Album properties:

  • Blog attributes: title, content, first image, tag, number of views, open praise, open copyright, open comment, whether to publish, create time, update time, description
  • Category attribute: Category name
  • User attributes: Nickname, Username, Password, Email, Type, profile picture, creation time, and update time
  • Comment attributes: nickname, email, profile picture, comment content, creation time, Blog ID, parent comment ID, administrator ID
  • Message attributes: Nickname, Email, profile picture, message content, creation time, PARENT MESSAGE ID, and administrator ID
  • Friend link attributes: url, name, creation time, picture address
  • Album properties: picture address, picture description, picture name, shooting time and place

4. The table structure

Blogs table:

Classification:

The users table:

Comments list:

A message table:

Friends list:

Album list:

5. Build a predicate sentence

/* Navicat MySQL Data Transfer Source Server : myblog-localhost Source Server Type : MySQL Source Server Version : 50717 Source Host : localhost:3306 Source Schema : myblog Target Server Type : MySQL Target Server Version : 50717 File Encoding : 65001 Date: 30/04/2020 17:02:10 */

SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;

-- ----------------------------
-- Table structure for t_blog
-- ----------------------------
DROP TABLE IF EXISTS `t_blog`;
CREATE TABLE `t_blog`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `appreciation` bit(1) NOT NULL,
  `commentabled` bit(1) NOT NULL,
  `content` longtext CHARACTER SET utf8 COLLATE utf8_general_ci NULL,
  `create_time` datetime(0) NULL DEFAULT NULL,
  `description` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `first_picture` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `flag` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `published` bit(1) NOT NULL,
  `recommend` bit(1) NOT NULL,
  `share_statement` bit(1) NOT NULL,
  `title` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `update_time` datetime(0) NULL DEFAULT NULL,
  `views` int(11) NULL DEFAULT NULL,
  `type_id` bigint(20) NULL DEFAULT NULL,
  `user_id` bigint(20) NULL DEFAULT NULL,
  `comment_count` int(255) NULL DEFAULT NULL.PRIMARY KEY (`id`) USING BTREE,
  INDEX `FK292449gwg5yf7ocdlmswv9w4j`(`type_id`) USING BTREE,
  INDEX `FK8ky5rrsxh01nkhctmo7d48p82`(`user_id`) USING BTREE,
  CONSTRAINT `FK292449gwg5yf7ocdlmswv9w4j` FOREIGN KEY (`type_id`) REFERENCES `t_type` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `FK8ky5rrsxh01nkhctmo7d48p82` FOREIGN KEY (`user_id`) REFERENCES `t_user` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 62 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for t_comment
-- ----------------------------
DROP TABLE IF EXISTS `t_comment`;
CREATE TABLE `t_comment`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `nickname` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `email` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `content` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `avatar` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `create_time` datetime(0) NULL DEFAULT NULL,
  `blog_id` bigint(20) NULL DEFAULT NULL,
  `parent_comment_id` bigint(20) NULL DEFAULT NULL,
  `admin_comment` bit(1) NOT NULL.PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 28 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for t_friend
-- ----------------------------
DROP TABLE IF EXISTS `t_friend`;
CREATE TABLE `t_friend`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `blogaddress` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
  `blogname` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
  `create_time` datetime(0) NULL DEFAULT NULL,
  `pictureaddress` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL.PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 58 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for t_message
-- ----------------------------
DROP TABLE IF EXISTS `t_message`;
CREATE TABLE `t_message`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `nickname` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `email` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `content` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `avatar` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `create_time` datetime(0) NULL DEFAULT NULL,
  `parent_message_id` bigint(20) NULL DEFAULT NULL,
  `admin_message` bit(1) NOT NULL.PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 100 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for t_picture
-- ----------------------------
DROP TABLE IF EXISTS `t_picture`;
CREATE TABLE `t_picture`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `pictureaddress` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `picturedescription` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `picturename` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `picturetime` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL.PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 19 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for t_type
-- ----------------------------
DROP TABLE IF EXISTS `t_type`;
CREATE TABLE `t_type`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL.PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 58 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for t_user
-- ----------------------------
DROP TABLE IF EXISTS `t_user`;
CREATE TABLE `t_user`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `avatar` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `create_time` datetime(0) NULL DEFAULT NULL,
  `email` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `nickname` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `password` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `type` int(11) NULL DEFAULT NULL,
  `update_time` datetime(0) NULL DEFAULT NULL,
  `username` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL.PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 2 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;

SET FOREIGN_KEY_CHECKS = 1;

Copy the code