Design and implementation of blog management system based on java springboot

Design and implementation of blog management system based on java springboot

Blogger introduction: 5 years of java development experience, focusing on Java development, customization, remote, guidance, etc., csdn invited author, focusing on the field of
Java technology
.
⭐Get
the source code contact information at the end of the message

foreword

Blogs, also translated as weblogs, blogs, or blogs, are websites that are usually managed by individuals and that post new articles from time to time. Articles on blogs are usually arranged in reverse order from newest to oldest according to posting time. Many blogs focus on providing commentary or news on specific topics, while others serve as more personal diaries. A typical blog combines text, images, links to other blogs or websites, and other media related to the topic. Being able to get readers to leave comments in an interactive way is an important element of many blogs. Most of the blog content is text-based, and there are still some blogs that focus on various topics such as art, photography, video, music, and podcasts. Blogs are part of social media networks. Blogging takes the free spirit of a personal website, but incorporates new modes of inspiring creativity, making it more open and constructive. As a new way of expression, it spreads not only emotions, but also a wealth of wisdom, opinions and thoughts. In a sense, it is also a new cultural phenomenon. The emergence and prosperity of blogs truly highlights the knowledge value of the Internet and marks the beginning of a higher stage of Internet development.
insert image description here

demand analysis

This system is mainly aimed at the administrators of the blog forum to effectively manage the forum information, add, delete, modify and check the number of users, the number of links, and the number of articles. It can analyze the recent development of the forum through data statistics, and can also change the category of the management forum. interface. Visitors contribute to the forum by posting articles, managing articles, and posting their own ideas.

User Management.

This module is operated by the administrator, and lists all users' usernames, email addresses, creation time, and user status on a table, which is convenient for administrators to add, delete, modify, query user information, and delete in batches .

Article management.

This module can be operated by administrators and users, and they can delete, modify, and query existing articles. They can also add sections to articles and create articles.

Link management.

This module is to add links to friendship websites on the right side of the forum page, which can help each other. It also consists of two small sections, link addition and link list. This is a section that only administrators can view and add, delete, check and modify ,

log management.

The log module is the access record of all users including the administrator forum to the background management system, which can be viewed by the administrator and can perform query, delete and batch delete operations.

data management.

The data module counts the number of posts and visits of the forum in monthly units, and converts them into a histogram. It is a tool for analyzing the status quo of the website that can only be viewed by administrators. Divided into article publication data and article browsing data.

System Management.

There is a list of front desk columns under this module, which is the classification category displayed above the front desk forum, and has the functions of adding, deleting, modifying and querying by the administrator.

Functional Analysis

User login registration:

Enter the account password to log in, the background judges whether the account authority is a normal user or an administrator, and those who have not registered can enter the registration page to registerinsert image description here

Blog home page:

After the user enters the homepage, view the category, view the blog content, click to view the details, jump to the hyperlink on the right, and log in and register
insert image description here

Article details:

insert image description here

Comment interaction:

Blog Details Comment Interaction
insert image description here

Background user management:

insert image description here
Add user:
insert image description here

Background article management:

insert image description here
insert image description here

Background link management:

insert image description here

Background log management:

insert image description here

Background data management:

Article data "published data and traffic data" are displayed on a monthly basis
insert image description here

Background menu management:

insert image description here

partial table design

Use Mysql database, INNODB storage engine and UTF8 encoding format.

user table

CREATE TABLE `NewTable` (
`id`  int(11) NOT NULL AUTO_INCREMENT COMMENT '主键' ,
`username`  varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '用户登录名' ,
`email`  varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '邮箱' ,
`password`  varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '密码' ,
`status`  varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '2' COMMENT '状态 0:正常 1:删除 2:未激活或者未启用' ,
`avatar`  varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '头像' ,
`code`  varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '激活码' ,
`create_date`  datetime NULL DEFAULT NULL COMMENT '添加时间' ,
`create_by`  varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '添加用户id' ,
`update_date`  datetime NULL DEFAULT NULL COMMENT '更新时间' ,
`update_by`  varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '更新用户id' ,
`remark`  varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '备注' ,
PRIMARY KEY (`id`)
)
ENGINE=InnoDB
DEFAULT CHARACTER SET=utf8 COLLATE=utf8_general_ci
AUTO_INCREMENT=21
ROW_FORMAT=DYNAMIC
;
 

article table

CREATE TABLE `NewTable` (
`id`  int(64) NOT NULL AUTO_INCREMENT ,
`type_id`  int(64) NOT NULL ,
`title`  varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ,
`content`  longtext CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ,
`create_date`  datetime NULL DEFAULT NULL ,
`create_by`  varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL ,
`update_date`  datetime NULL DEFAULT NULL ,
`update_by`  varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL ,
`status`  varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL ,
`read`  varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '0' ,
PRIMARY KEY (`id`)
)
ENGINE=InnoDB
DEFAULT CHARACTER SET=utf8 COLLATE=utf8_general_ci
AUTO_INCREMENT=24
ROW_FORMAT=DYNAMIC
;
 

Comment Interaction Form

CREATE TABLE `NewTable` (
`id`  int(11) NULL DEFAULT NULL ,
`news_id`  varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL ,
`content`  mediumtext CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL ,
`create_date`  date NULL DEFAULT NULL ,
`create_by`  int(11) NULL DEFAULT NULL ,
`update_time`  date NULL DEFAULT NULL ,
`update_by`  int(11) NULL DEFAULT NULL ,
`status`  varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL 
)
ENGINE=InnoDB
DEFAULT CHARACTER SET=utf8mb4 COLLATE=utf8mb4_unicode_ci
ROW_FORMAT=DYNAMIC
;
 

Partial code implementation

The function of this project is relatively simple, and the technology used is also very familiar to everyone, mainly springboot, springmvc, mybatis and basic styles such as jquery, layui, html and css at the front end. Let’s take login as a complete example. The first is to write the front-end static page and send the login request.

 
<div class="wrapper">
 
    <div class="froyo-frame login-body">
        <div class="admin-face">
            <div class="face-img">
                <img src="${ctxStatic}/images/editor.png" alt="logo">
            </div>
        </div>
        <h1 class="admin-login-tittle">「从现在开始,为每一天写下一篇记录」</h1>
        <div class="admin-login-form">
            <form class="form" action="${ctx}/login" method="post" autocomplete="off">
                <div class="admin-name"><input name="username" type="text" placeholder="用户名"></div>
                <div class="admin-password"><input name="password" type="password" placeholder="密码"></div>
                <div class="admin-button"><button type="submit" id="login-button">登录</button></div>
            </form>
          <!--   其他账号登录:
            <a href=""><img src="${ctxStatic}/images/qqLogin.png" style="width: 50px;margin: 10px" οnclick="loginQQ()"></a>
            <img src="${ctxStatic}/images/weChatLogin.png" style="width: 50px;margin: 10px">
            <img src="${ctxStatic}/images/weboLogin.png" style="width: 50px;margin: 10px"> -->
            <div class="admin-button"><a id="login-button" href="${ctx}/index">返回首页</a></div>
</div>
<script type="text/javascript" src="${ctxStatic}/plugins/layui/layui.js"></script>
<script type="text/javascript">
    layui.use('layer', function() {
      
      
        var $ = layui.jquery,
            layer = layui.layer;
        //login-button的点击事件..
        $('#login-button').click(function (event) {
      
      
            event.preventDefault();
            if (!$("input[name=username]").val()) {
      
      
                layer.msg("用户名不能为空");
                return false;
            } else if (!$("input[name=password]").val()) {
      
      
                layer.msg("密码不能为空");
                return false;
            } else {
      
      
                $('form').fadeOut(500);
                $('.wrapper').addClass('form-success');
                $('.form').submit();
            }
        });
 
</script>
</body>
</html>

After receiving the front-end login request, the background Controller performs parameter verification, judges and verifies the username, password and user role passed by the front-end, calls the LoginController.login method to perform user login verification, queries whether the current account password of the database is correct, and returns a status code For the front end, the front end performs relative page jumps and data effects according to the status code.

   /**
     * 登录验证
     *
     * @param user
     * @param map
     * @return
     */
    @PostMapping("/login")
    public String login(User user, ModelMap map) {
    
    
        if (user != null) {
    
    
            if (StringUtils.isBlank(user.getUsername()) || StringUtils.isBlank(user.getPassword())) {
    
    
                return Views.LOGIN;
            }
            AuthenticationToken token = new UsernamePasswordToken(user.getUsername(), user.getPassword(), true);
            if (token == null) {
    
    
                map.put("message", "用户名或密码错误");
                return Views.LOGIN;
            }
            //记住我
            ((UsernamePasswordToken) token).setRememberMe(true);
            try {
    
    
                SecurityUtils.getSubject().login(token);
                return Views.REDIRECT_ADMIN;
            } catch (AuthenticationException e) {
    
    
                if (e instanceof UnknownAccountException) {
    
    
                    map.put("message", "用户不存在");
                } else if (e instanceof LockedAccountException) {
    
    
                    map.put("message", "账户未激活");
                    map.put("status", 2);
                    map.put("user", user);
                } else if (e instanceof DisabledAccountException) {
    
    
                    map.put("message", "账户未启用");
                }
                e.printStackTrace();
                map.put("message", "用户认证失败");
            }
            return Views.LOGIN;
        } else {
    
    
            map.put("message", "未知异常");
            return Views.LOGIN;
        }
    }
 
 
 
}

Blogger introduction: 5 years of java development experience, focusing on Java development, customization, remote, guidance, etc., csdn invited author, focusing on the field of
Java technology
.
⭐Get
the source code contact information at the end of the message

Guess you like

Origin blog.csdn.net/qq_44664329/article/details/128909181