(with source code) design and implementation of springboot campus news website computer completion 142357

Springboot Campus News Site

Summary

In the information society, there is a need for targeted information acquisition channels, but the expansion of channels is basically the direction that people are striving for. Due to the deviation in their perspective, people can often obtain different types of information, which is also the most difficult technology to overcome. topic. The main functional modules of the campus news website include campus news, news categories, exchange forums, forum categories, etc., adopting an object-oriented development model for software development and hardware erection, which can well meet the needs of actual use and improve the corresponding For software construction and program coding work, Mysql is used as the main storage unit of background data, and Springboot framework, JSP technology, and Ajax technology are used for business system coding and development, and all functions of the platform are realized.

Keywords: campus news website; Springboot framework; MySQL database

Springboot campus news website

Abstract

In the information society, there is a need for targeted information access, but the expansion of access is basically the direction of people's efforts. Due to the deviation of the perspective, people can often obtain different types of information, which is also the most difficult subject for technology to overcome. The main functional modules of campus news website include campus news, news classification, exchange forum, forum classification, etc. the object-oriented development mode is adopted for software development and hardware erection, which can well meet the needs of actual use, improve the corresponding software erection and program coding, take MySQL as the main storage unit of background data, and adopt springboot framework, JSP technology Ajax technology encodes and develops the business system, and realizes all the functions of the platform.

Key words:Campus news website; Springboot framework; Mysql database

Table of contents

Chapter 1 Introduction

1.1  Research background and significance

1.2 Structure of this paper 

Chapter 2 Introduction to Related Technologies

2.1  J2EE technology

2.2 MVVM pattern

2.3 B/S structure

2.4 Spring boot framework

2.5  Mysql database

2. 6  B/S system working principle

Chapter 3 System Analysis

3.1  Feasibility analysis

3.2  Analysis of Functional Requirements

3.2.1  Foreground user functions

3.2.2  Background administrator function

3.3  Analysis of non-functional requirements

3.4  Security Requirements Analysis

3.4.1  System security

3.4.2  Data Security

3.5  Data flow analysis

Chapter 4 System Design

4.1  System architecture design

4.2  Overall system design

4.3  System function design

4.4  Database design

4.4.1  Data Requirements Analysis

4.4.2  Database conceptual design

4.4.3  Database table design

Chapter 5 System Implementation

5.1  Implementation of registration module

5.2  Implementation of login module

5.3  Realization of User Profile Modification Module

5.4 Realization of  campus style display module

5.5 Realization of communication forum module 

5.6 Realization of Campus News Management Module 

5.7 Implementation of Exchange Forum Management Module 

Chapter 6 System Testing

6.1  Test purpose

6.2  Functional test

6.3  Performance Test

Chapter 7 Summary and Outlook

references

thank you

  1. introduction
    1. research background and meaning

With the extensive popularization and rapid promotion and application of information society networking and computer science, China's campus information network with integrated intelligence has quickly become an information technology method for the development and promotion of science education and real science in universities, middle schools and primary schools. The establishment and upgrading of the current information network exchange platform of institutions of higher learning will rapidly improve the process of scientific and technological information reform in colleges and universities, improve the network environment for school information exchange, and greatly improve the organization and management level of the information exchange platform and the work and business efficiency of the school. It is of great significance for the school to build a campus news website to facilitate the communication between teachers and students. First of all, to achieve resource sharing, the network is a large information carrier, and the campus news website is a good way to share information resources in the school. Secondly, the campus news website, as a place for information exchange, has also become an important part of campus culture construction.

The construction of campus news website is an important aspect of school education informatization construction. It is an important way to adapt to the development of modern education technology and information technology, increase school communication and publicity, and improve the efficiency of teaching, scientific research and management. The window of publicity is also a place to display the talents of teachers and students of the whole school, strengthen contact with outsiders, learn from each other, and develop together. The purpose of the construction of the campus news website is to promote the common development of teachers, students and the school.

    1. Structure of this article

The specific content of this paper includes: introduction, key technologies adopted by the system, system analysis, system design, system realization and system test. This paper emphatically describes the composition and structure of the system, expounds the design scheme, implementation method, development tools and related technologies of the system, and also analyzes the development process of some links. The system simulates the important modules of the system in a certain environment, which proves the usability and reliability of the system.

  1. Related technology introduction
    1. J2EE technology

People can master many foreign languages, but what a computer scientist is proficient in is mostly programming languages, which are not human natural languages, such as C language, Java, Perl and so on. Since the "middleware" developed by different companies is not standardized enough, Sun launched J2EE and used this standard to solve the ills. It provides a good mechanism, allowing each layer to allow the corresponding server and components to run, making the system stable and usable, efficient in development, and easy to maintain.

    1. MVVM pattern

The MVVM model is a commonly used development model, which is mainly divided into M layer, V layer and C layer in terms of code implementation.

View (View) represents the user interaction interface. A web application may have many interfaces. In the MVVM mode, the view only deals with data collection, processing, and user requests, and does not include the processing of business processes and business processes. Handled by the Model.

Model (Model) is the processing of business processes/states and the formulation of business rules. The process of the model processing the business process cannot be seen by other layers. It is like a black box. After receiving the data requested by the view, it returns the final processing result. The main core of MVVM is the design of the business model. A typical application example is the popular EJB model. It further divides the model from the perspective of application technology implementation in order to make full use of existing components, but it cannot be used as a A framework for applying design models.

The controller (Controller) can be understood as receiving the user's request, and then the view and the model are matched together to complete the user's request together. It has a very obvious role in dividing the control layer, and can clearly tell you that it is a distributor, which model and view to choose, and what kind of request from the user can be completed. The control layer does not do all the data processing, for example: the user clicks a connection, after the control layer receives the request, it does not process the business information, it just transmits the user's information to the model, and tells the model what to do, and then chooses the one that meets the requirements The view is returned to the user.

    1. B/S structure

B/S (Browser/Server) is a more convenient architecture than its predecessor architecture. It uses the Web server to complete the data transfer and exchange. You only need to download the browser as the client, then the work will achieve a "slimming" effect, and there is no need to consider the problem of non-stop installation of software.

    1. Spring boot framework

The Spring framework is an open source application framework on the Java platform that provides a container with inversion of control features. Although the Spring framework itself has no restrictions on the programming model, its frequent use in Java applications made it so popular that it was later used as a supplement or even a substitute for the EJB (EnterpriseJavaBeans) model. The Spring framework provides a series of solutions for development, such as using the core features of inversion of control, and implementing inversion of control through dependency injection to realize the containerization of the management object life cycle, using aspect-oriented programming for declarative transaction management, and integrating A variety of persistence technologies manage data access, provide a large number of excellent web frameworks to facilitate development, and so on. The Spring framework has the feature of inversion of control (IOC). IOC is designed to facilitate project maintenance and testing. It provides a method for unified configuration and management of Java objects through the Java reflection mechanism. The Spring framework uses the container to manage the life cycle of objects. The container can configure objects by scanning XML files or specific Java annotations on classes. Developers can obtain objects through dependency lookup or dependency injection. Aspect Oriented Programming(AOP) framework, the Spring AOP framework is based on the proxy mode, and can be configured at runtime; the AOP framework is mainly modularized for the cross concerns between modules. The AOP framework of the Spring framework only provides basic AOP features. Although it cannot be compared with the AspectJ framework, it can also meet the basic needs through integration with AspectJ. Functions such as transaction management and remote access under the Spring framework can be realized by using Spring AOP technology. Spring's transaction management framework brings an abstraction mechanism to the Java platform that enables local and global transactions, as well as nested transactions, to work with savepoints and in almost any environment on the Java platform. Spring integrates multiple transaction templates. The system can configure transactions through transaction templates, XML or Java annotations, and the transaction framework integrates functions such as messaging and caching. Spring's data access framework addresses common difficulties developers encounter when using databases in their applications. It not only provides support for all popular data access frameworks such as Java: JDBC, iBATS/MyBATIs, Hibernate, Java Data Objects (JDO), ApacheOJB and Apache Cayne, but also can be used with Spring's transaction management to provide data access Flexible abstraction. The Spring framework initially did not intend to build its own Web MVC framework . During the development process, its developers believed that the separation between the presentation layer and the request processing layer of the existing Struts Web framework and between the request processing layer and the model was not enough, so they created Spring MVC.

    1. Mysql database

Mysql has been updated many times, and the functional level has been very rich and perfect. From Mysql4 version to 5 version, a relatively large update has been made, and it has achieved good practical application results in actual commercial use. The latest version of Mysql supports the compression of information, and at the same time, it can also perform encryption to better meet the needs of information security. At the same time, after multiple updates of the system, the mirroring function of the database itself has also been greatly enhanced, the smoothness of operation and ease of use have been greatly improved, and the use and creation of drivers are also more efficient and faster. The biggest change is the optimization of the display of spatial information, which makes it easier to label and calculate coordinates on the application map. The powerful backup function also ensures that users will feel more at ease during the use process, and the supported Office features also support users' self-installation and use. The display form of information has also been greatly updated, and two very useful display areas have been added, one is the information area, which has classified tables and text, and the display of the interface is more refreshing and specific. The second is the information control of the instrument, which can display information in the instrument information area and compare multiple information at the same time, which brings great convenience to the actual use of users.

In the actual implementation process of the campus news website designed in this article, the main reason for choosing the Mysql database is that there will be a large number of databases that are frequently operated during the application and development of enterprise application systems, and the data security requirements It is also very high. Based on these factors, Mysql, which has a relatively high safety factor, is finally selected to store the background data of the campus news website.

2.6 B/S system working principle:

The B/S architecture adopts the working mode of browser request and server response.

Users can access information such as text, data, pictures, animation, video on demand and sound generated by the web server on the Internet through a browser;

And each web server can be connected with the database server in various ways, and a large amount of data is actually stored in the database server;

Download the program from the Web server to execute locally. If an instruction related to the database is encountered during the download process, the Web server will hand it over to the database server for interpretation and execution, and return it to the Web server, and the Web server will return it to the user. In this structure, many networks are connected together to form a huge network, that is, the global network. Each enterprise can build its own Internet on the basis of this structure.

In the B/S mode, the user requests access to many servers distributed on the network through the browser. The browser's request is processed by the server, and the processing result and corresponding information are returned to the browser. Other data Processing and requests are all completed by the Web Server. Through the frame structure and the browser embedded in the operating system, this structure has become the mainstream structure mode of today's software applications.

  1. system analysis
    1. Feasibility Analysis

To develop any system, it is necessary to analyze its feasibility and consider its time and resource constraints, which can reduce the risk of system development. At the same time, after the analysis, not only can manpower be used reasonably, but also the consumption of various resources can be saved. The following three aspects of technology, economy and society will be introduced.

In terms of practicability, the main task of this design is to realize campus communication forums, forum classification, and campus news release functions in the campus news website, which is in line with the current development trend. From the perspective of users, while also considering system operating costs and human resources, it adopts a convenient way on the Internet to realize online business, making the business process more systematic and more convenient for user experience, which is more practical.

In terms of economy, the main purpose of the campus news website designed in this project is to conduct information query management and retrieval services more conveniently and quickly, that is, information software that can be directly put into use. The main cost of the system is mainly concentrated on the operation of continuous maintenance and management update of the used data in the later period. However, once the system is put into actual operation and use, it can improve the efficiency of information query and retrieval. At the same time, it is also necessary to effectively ensure the security of the information of the inquirer. At the same time, the practical application brought by this campus news website The value of the software far exceeds the cost of developing and maintaining the actual system. Therefore, it is economically feasible to develop this software.

    1. Functional Requirements Analysis

The functions of the campus news website are mainly divided into front-end users who register and log in according to their own needs, browse campus news content and publish forums for communication. The background system administrator mainly manages campus news, news classification, exchange forums, and forums by category.

The user use case diagram is shown below.

 

Figure 3-1 User use case diagram

The administrator use case diagram is shown below.

 

Figure 3-2 Administrator use case diagram

      1. front-end user function

The functions of registered users in the foreground are as follows:

Registration and login: The user fills in personal information and verifies the mobile phone number to register the account, and can log in to the system only after the registration is successful.

Campus News: Users can browse campus news content online.

Maintain personal information: Users can modify their registration information at any time due to changes in personal information.

Communication Forum: Users publish communication topics online.

Announcement information: You can learn about the latest announcements on campus, etc.

      1. Background administrator function

The administrator functions are as follows:

Change password: Administrators can change their own login passwords to the system at any time to ensure system security.

User management: maintain and manage registered user information, etc.

Campus news management: Upload and publish campus news, maintain, add, delete, and modify information.

Forum communication management: maintain and manage the communication information published by users.

News classification management: classify and maintain news information.

Forum category management.

    1. Non-Functional Requirements Analysis

The first thing to consider is the system function software. In terms of specific design, whether it can better meet the basic functional requirements of various users. If it cannot better meet the needs of users, then the existence of this system is worthless. The non-functional analysis of the software system is carried out from 7 aspects, one is performance analysis, which is aimed at the system; one is security analysis, which is aimed at the system; the other is integrity analysis, which is aimed at the system; It is scalability analysis, for the system, and the other is performance analysis to adapt to the business. In the face of the comprehensive comparison and analysis of the performance, security, expansion, and integrity of the campus news website in seven aspects, it is found that the corresponding non-functional requirements analysis is needed.

    1. Security Requirements Analysis
      1. system security

Security is very important to every system. A well-secured system can protect school information and user information from being stolen. Improving the security of the system is not only the responsibility of the user, but also the responsibility of the school. Especially for campus news websites, there must be good security to protect the entire system.

The system has authority control for users, and limits the authority of users according to the role barriers, so as to ensure the security of the system.

      1. data security

The data in the database is input from the outside world. When the data is input, due to various reasons, the input data will be invalid or dirty. Therefore, how to ensure that the input data conforms to the regulations has become the primary concern of database systems, especially multi-user relational database systems.

Therefore, when writing to the database, data integrity, correctness, and consistency must be guaranteed.

    1. Data Flow Analysis

Analyze the data flow of the system, and the users of the system are divided into two categories, general users and administrators. The system mainly processes interface information transmission, login information verification, registration information reception, and user response to various operations.

The top-level data flow diagram of the system is shown in the figure below.

 

Figure 3-2 Top-level data flow diagram

To judge the identity of the user, it is judged according to the login data, and then jumps to the corresponding function interface. The internal users of the system can operate the data, and the database center can receive the effective data stream transmitted by the system to perform corresponding operations on the data SQL statements.

The underlying data flow diagram of the system is shown in the figure below.

 

 Figure 3-3 The underlying data flow diagram

The system can be divided into two parts, the foreground and the background. After each operation, the system returns the operation result. The data connection between the foreground and the background is mainly through the database, which means that different operations are performed on the database respectively.

  1. system design
    1. System architecture design

The architecture design of the campus news website can be divided into three layers, mainly including the Web layer, the business layer, and the Model layer. The web layer also includes the View layer and the Controller layer, and the Model layer includes the metadata extension layer and the data access layer.

The system architecture is shown in the figure below.

MVVM is to abstract the state and behavior of the View in it, and let us separate the view UI from the business logic. Of course, ViewModel has already done these things for us. It can take out the data of Model and help deal with the business logic involved in View because of the need to display content. It forcibly separates the input, output, and processing of the application into three core parts, each of which has different functions.

 

Figure 4-1 System architecture diagram

View layer View refers to the interface that is seen by the user and can interact with it. Views can display relevant data to users and receive data entered by users, but do not perform any actual business operations on user data.

The model layer processes the data passed by the view layer through the control layer. The same model can provide data to different views, and can also be reused by different views. Since the main content of the Model is data, methods, and behaviors, it is also the part with the most complex logic and the largest amount of code in MVVM, which contains business logic that needs to be used in many applications, so the development of the model layer has become particularly important. Generally, large-scale changes will not be made to the model layer in the later stage, which is also the most stable part of MVVM. The control layer is mainly responsible for data transmission and processing request operations between the view layer and the model layer. When the user sends data and requests through the view, the control layer can receive the request and data and decide which models to call and which operations of the model to process the data and requests. After the processing is completed, the control layer returns the data to the corresponding view.

    1. Overall System Design

The campus news website is generally divided into a front-end user module and a back-end administrator module.

The two modules appear to exist independently, but the accessed database is the same. The function of each module is made according to the previously completed demand analysis, and after consulting relevant materials.

To sum up, the functional structure diagram of the system is shown in the figure below.

 

Figure 4-2 System function structure diagram

    1. System function design

Login module: The login module is the entrance to the system, and all users must log in to access the system. To log in, you need to enter your username and password, and if you try to log in multiple times, you need to enter a verification code. When logging in, you need to choose the role of the user, whether it is a general user or an administrator to log in. After a successful login, the user's permissions will be obtained through the database and redirected to the user's home page.

Campus news data module: It can be divided into three modules: campus news data browsing, campus news data retrieval, and campus news data maintenance. The administrator has the authority to maintain campus news data, release new campus news data, and update existing campus news data etc.

    1. Database Design
      1. Data Requirements Analysis

It can be analyzed from the front that the most important things in the database are user information, campus news, news classification, exchange forums, etc. The analysis can get the following data description:

Platform users: used to record various information of users, including data items such as name, gender, mobile phone, email, photos, etc.

Administrator: Record the login information of the administrator. Including user name, password, permissions and other data items.

Campus News: content stored for campus news.

News classification: data items such as campus news classification.

Exchange forum information: data items such as information published by users.

      1. Database conceptual design

According to the previous data flow chart, combined with the functional module design of the system, design each information entity that conforms to the system.

The ER diagram of the system is shown in the figure below.

 

Figure 4-3 System ER diagram

      1. database table design

The data tables owned by the campus news website are as follows: user information table, exchange forum table, campus news table, news classification table, forum classification table, etc.

Due to the large number of data tables, only the main data tables of the system are displayed, as shown in the following table.

name

type

length

not null

primary key

note

ordinary_users_id

int

11

yes

yes

common user ID

user_name

varchar

64

no

no

username

user_gender

varchar

64

no

no

user gender

examine_state

varchar

16

yes

no

Approval Status

recommend

int

11

yes

no

Intelligent Recommendation

user_id

int

11

yes

no

User ID

create_time

datetime

0

yes

no

creation time

update_time

timestamp

0

yes

no

update time

name

type

length

not null

primary key

note

type_id

smallint

5

yes

yes

Category ID:

name

varchar

16

yes

no

Category Name

description

varchar

255

no

no

describe

url

varchar

255

no

no

External link address

father_id

smallint

5

yes

no

parent category ID

icon

varchar

255

no

no

Category icons:

create_time

timestamp

0

yes

no

Creation time:

update_time

timestamp

0

yes

no

Update time:

name

type

length

not null

primary key

note

comment_id

int

11

yes

yes

Comment ID:

user_id

int

11

yes

no

Reviewer ID:

reply_to_id

int

11

yes

no

Reply to comment ID

content

longtext

0

no

no

content:

nickname

varchar

255

no

no

Nick name:

avatar

varchar

255

no

no

Avatar address

create_time

timestamp

0

yes

no

Creation time:

update_time

timestamp

0

yes

no

Update time:

source_table

varchar

255

no

no

Source table:

source_field

varchar

255

no

no

Source field:

source_id

int

10

yes

no

Source ID:

name

type

length

not null

primary key

note

notice_id

mediumint

8

yes

yes

Announcement id:

title

varchar

125

yes

no

title:

content

longtext

0

no

no

text:

create_time

timestamp

0

yes

no

Creation time:

update_time

timestamp

0

yes

no

Update time:

name

type

length

not null

primary key

note

forum_id

mediumint

8

yes

yes

forum id

display

smallint

5

yes

no

to sort

user_id

mediumint

8

yes

no

User ID

nickname

varchar

16

no

no

Nickname: [0,16]

praise_len

int

10

no

no

Likes

hits

int

10

yes

no

number of visits

title

varchar

125

yes

no

title

keywords

varchar

125

no

no

Key words

description

varchar

255

no

no

describe

url

varchar

255

no

no

source address

tag

varchar

255

no

no

Label

img

text

0

no

no

cover picture

content

longtext

0

no

no

text

create_time

timestamp

0

yes

no

Creation time:

update_time

timestamp

0

yes

no

Update time:

avatar

varchar

255

no

no

Poster Avatar:

type

varchar

64

yes

no

Forum classification:

name

type

length

not null

primary key

note

upload_id

int

11

yes

yes

Upload ID

name

varchar

64

no

no

file name

path

varchar

255

no

no

access path

file

varchar

255

no

no

file path

display

varchar

255

no

no

display order

father_id

int

11

no

no

Parent ID

dir

varchar

255

no

no

folder

type

varchar

32

no

no

file type

  1. System implementation
    1. Implementation of the registration module

用户在填写数据的时候必须与注册页面上的验证相匹配否则会注册失败,注册页面的表单验证是通过验证的,用户名的长度必须在6到18之间,邮箱必须带有@符号,密码和密码确认必须相同,你输入的密码,系统会根据你输入密码的强度给出指定的值,电话号码和身份证号码必须要求输入格式与生活相符合,当你前台验证通过的时候你点击注册,表单会将你输入的值通过name值传递给后台并保存到数据库中。

用户注册流程图如下图所示。

 

图5-1用户注册流程图

用户注册界面如下图所示。

 

图5-2用户注册界面

用户注册逻辑代码如下:

/**

     * 注册

     * @param user

     * @return

     */

    @PostMapping("register")

    public Map<String, Object> signUp(@RequestBody User user) {

        // 查询用户

        Map<String, String> query = new HashMap<>();

        query.put("username",user.getUsername());

        List list = service.select(query, new HashMap<>()).getResultList();

        if (list.size()>0){

            return error(30000, "用户已存在");

        }

        user.setUserId(null);

        user.setPassword(service.encryption(user.getPassword()));

        service.save(user);

        return success(1);

}

/**

     * 用户ID:[0,8388607]用户获取其他与用户相关的数据

     */

    @Id

    @GeneratedValue(strategy = GenerationType.IDENTITY)

    @Column(name = "user_id")

    private Integer userId;

    /**

     * 账户状态:[0,10](1可用|2异常|3已冻结|4已注销)

     */

    @Basic

    @Column(name = "state")

    private Integer state;

    /**

     * 所在用户组:[0,32767]决定用户身份和权限

     */

    @Basic

    @Column(name = "user_group")

    private String userGroup;

    /**

     * 上次登录时间:

     */

    @Basic

    @Column(name = "login_time")

    private Timestamp loginTime;

    /**

     * 手机号码:[0,11]用户的手机号码,用于找回密码时或登录时

     */

    @Basic

    @Column(name = "phone")

    private String phone;

    /**

     * 手机认证:[0,1](0未认证|1审核中|2已认证)

     */

    @Basic

    @Column(name = "phone_state")

    private Integer phoneState;

    /**

     * 用户名:[0,16]用户登录时所用的账户名称

     */

    @Basic

    @Column(name = "username")

    private String username;

    /**

     * 昵称:[0,16]

     */

    @Basic

    @Column(name = "nickname")

    private String nickname;

    /**

     * 密码:[0,32]用户登录所需的密码,由6-16位数字或英文组成

     */

    @Basic

    @Column(name = "password")

    private String password;

    /**

     * 邮箱:[0,64]用户的邮箱,用于找回密码时或登录时

     */

    @Basic

    @Column(name = "email")

    private String email;

    /**

     * 邮箱认证:[0,1](0未认证|1审核中|2已认证)

     */

    @Basic

    @Column(name = "email_state")

    private Integer emailState;

    /**

     * 头像地址:[0,255]

     */

    @Basic

    @Column(name = "avatar")

    private String avatar;

    /**

     * 创建时间:

     */

    @Basic

    @Column(name = "create_time")

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")

    private Timestamp createTime;

    @Basic

    @Transient

    private String code;

}

    1. 登录模块的实现

主要由两部分组成,登录前的登录界面以及登录后的用户功能界面。登录界面,要求用户输入用户名和密码,当用户名和密码其中一个输入为空时,给出提示“用户名,密码不能为空”。获取用户名和密码后到数据库中查找,如果用户名存在,以及对应的密码正确,则登录成功,否则登录失败。登录失败后给出提示,并把焦点停在文本框中。登录成功后将该次会话的全局变量username设置为用户名。登录成功后进入会员的功能模块,主要有会员基本信息修改,已经发布考试信息管理,发布信息,和退出功能。退出功能是清除全局变量username的值,并跳回到首页。

登录流程图如下图所示。

 

图5-3登录流程图

用户登录界面如下图所示。

 

图5-4用户登录界面

用户登录的逻辑代码如下所示。

/**

     * 登录

     * @param data

     * @param httpServletRequest

     * @return

     */

    @PostMapping("login")

    public Map<String, Object> login(@RequestBody Map<String, String> data, HttpServletRequest httpServletRequest) {

        log.info("[执行登录接口]");

        String username = data.get("username");

        String email = data.get("email");

        String phone = data.get("phone");

        String password = data.get("password");

        List resultList = null;

        Map<String, String> map = new HashMap<>();

        if(username != null && "".equals(username) == false){

            map.put("username", username);

            resultList = service.select(map, new HashMap<>()).getResultList();

        }

        else if(email != null && "".equals(email) == false){

            map.put("email", email);

            resultList = service.select(map, new HashMap<>()).getResultList();

        }

        else if(phone != null && "".equals(phone) == false){

            map.put("phone", phone);

            resultList = service.select(map, new HashMap<>()).getResultList();

        }else{

            return error(30000, "账号或密码不能为空");

        }

        if (resultList == null || password == null) {

            return error(30000, "账号或密码不能为空");

        }

        //判断是否有这个用户

        if (resultList.size()<=0){

            return error(30000,"用户不存在");

        }

        User byUsername = (User) resultList.get(0);

        Map<String, String> groupMap = new HashMap<>();

        groupMap.put("name",byUsername.getUserGroup());

        List groupList = userGroupService.select(groupMap, new HashMap<>()).getResultList();

        if (groupList.size()<1){

            return error(30000,"用户组不存在");

        }

        UserGroup userGroup = (UserGroup) groupList.get(0);

        //查询用户审核状态

        if (!StringUtils.isEmpty(userGroup.getSourceTable())){

            String sql = "select examine_state from "+ userGroup.getSourceTable() +" WHERE user_id = " + byUsername.getUserId();

            String res = String.valueOf(service.runCountSql(sql).getSingleResult());

            if (res==null){

                return error(30000,"用户不存在");

            }

            if (!res.equals("已通过")){

                return error(30000,"该用户审核未通过");

            }

        }

        //查询用户状态

        if (byUsername.getState()!=1){

            return error(30000,"用户非可用状态,不能登录");

        }

        String md5password = service.encryption(password);

        if (byUsername.getPassword().equals(md5password)) {

            // 存储Token到数据库

            AccessToken accessToken = new AccessToken();

            accessToken.setToken(UUID.randomUUID().toString().replaceAll("-", ""));

            accessToken.setUser_id(byUsername.getUserId());

            tokenService.save(accessToken);

            // 返回用户信息

            JSONObject user = JSONObject.parseObject(JSONObject.toJSONString(byUsername));

            user.put("token", accessToken.getToken());

            JSONObject ret = new JSONObject();

            ret.put("obj",user);

            return success(ret);

        } else {

            return error(30000, "账号或密码不正确");

        }

}

    1. 用户资料修改模块的实现

用户登录/注册成功之后可以修改自己的基本信息。修改页面的表单中每一个input的name值都要与实体类中的参数相匹配,在用户点击修改页面的时候,如果改后用户名与数据库里面重复了,页面会提示该用户名已经存在了,否则通过Id来查询用户,并将用户的信息修改为表单提交的数据。

    1. 校园新闻展示模块的实现

如果校园新闻的信息需要修改,管理员查询校园新闻是通过ajax技术来进行查询的,需要传递校园新闻的标题、内容等参数然后在返回到该页面中,可以选中要修改或删除的那条信息,如果选中了超过一条数据,页面会挑一个窗口提醒只能选择一条数,如果没有选中数据会挑一个窗口题型必须选择一条数据。当选择确认修改的时候,后台会根据传过来的id到数据库查询,并将结果返回到修改页面中,可以在修改页面中修改刚刚选中的信息当点击确认的时候from表单会将修改的数据提交到后台并保存到数据库中,就是说如果提交的数据数据库中存在就修改,否则就保存。

校园新闻展示界面如下图所示。

 

图5-5校园新闻展示界面

校园新闻展示的逻辑代码如下:

@PostMapping("/add")

    @Transactional

    public Map<String, Object> add(HttpServletRequest request) throws IOException {

        service.insert(service.readBody(request.getReader()));

        return success(1);

    }

    @Transactional

    public Map<String, Object> addMap(Map<String,Object> map){

        service.insert(map);

        return success(1);

}

    public Map<String,Object> readBody(BufferedReader reader){

        BufferedReader br = null;

        StringBuilder sb = new StringBuilder("");

        try{

            br = reader;

            String str;

            while ((str = br.readLine()) != null){

                sb.append(str);

            }

            br.close();

            String json = sb.toString();

            return JSONObject.parseObject(json, Map.class);

        }catch (IOException e){

            e.printStackTrace();

        }finally{

            if (null != br){

                try{

                    br.close();

                }catch (IOException e){

                    e.printStackTrace();

                }

            }

        }

        return null;

}

    public void insert(Map<String,Object> body){

        StringBuffer sql = new StringBuffer("INSERT INTO ");

        sql.append("`").append(table).append("`").append(" (");

        for (Map.Entry<String,Object> entry:body.entrySet()){

            sql.append("`"+humpToLine(entry.getKey())+"`").append(",");

        }

        sql.deleteCharAt(sql.length()-1);

        sql.append(") VALUES (");

        for (Map.Entry<String,Object> entry:body.entrySet()){

            Object value = entry.getValue();

            if (value instanceof String){

                sql.append("'").append(entry.getValue()).append("'").append(",");

            }else {

                sql.append(entry.getValue()).append(",");

            }

        }

        sql.deleteCharAt(sql.length() - 1);

        sql.append(")");

        log.info("[{}] - 插入操作:{}",table,sql);

        Query query = runCountSql(sql.toString());

        query.executeUpdate();

    }

    1. 交流论坛模块的实现

交流论坛功能需要考虑高并发,防止交流信息重复等情况,特对测试这一共享数据增加锁机制。在乐观锁、悲观锁以及线程锁中,综合考虑性能效率和错误的可接受性选择了乐观锁机制。乐观锁的实现方式是使用版本标识来确定读到的数据与提交时的数据是否一致,提交后修改版本标识,不一致时可以采取丢弃和再次尝试的策略。在诈骗电话表(对应测试实体)设计中增加了version字段,每次数据提交时(更改测试状态)会判断version是否匹配,若不匹配停止本次提交,若匹配则提交成功并增加version的值。

交流论坛功能整体流程:用户发布交流信息时,同时会显示信息的状态。

交流论坛界面如下图所示。

 

图5-6交流论坛界面

交流论坛界面逻辑代码如下:

@RequestMapping("/get_list")

    public Map<String, Object> getList(HttpServletRequest request) {

        Map<String, Object> map = service.selectToPage(service.readQuery(request), service.readConfig(request));

        return success(map);

}

    1. 校园新闻管理模块的实现

此页面的关键是编写校园新闻信息,包括新闻标题、介绍详情等。单击提交按钮以完成信息的添加。如果未写入完整的校园新闻信息,例如,如果未写入标题信息等,系统将给出相应的错误提示,并且无法成功输入。数据以概念的形式以onsubmit =“return checkForm()”的形式写入以进行检查,checkForm()函数是一种用于写入数据的不同类型的校对方法,是不是为空也是经过form表单中的οnsubmit=”return checkForm()来检查。

管理员点击左侧菜单“校园新闻管理”,页面跳转到校园新闻管理外观,调用后台校园新闻查询所有校园新闻信息。并将信息密封到数据集合List,绑定到请求对象,然后页面跳转到相应的界面,显示出校园新闻信息,单击删除按钮完成校园新闻信息的删除。

校园新闻管理流程图如下图所示。

 

图5-7校园新闻管理流程图

校园新闻管理界面如下图所示。

 

图5-8校园新闻管理界面

校园新闻管理界面逻辑代码如下:

 @RequestMapping(value = {"/avg_group", "/avg"})

public Map<String, Object> avg(HttpServletRequest request) {

        Query count = service.avg(service.readQuery(request), service.readConfig(request));

        return success(count.getResultList());

}

    1. 交流论坛管理模块的实现

根据需求,需要对交流论坛进行添加、删除或修改详情信息。删除或修改交流论坛时,系统根据交流论坛的状态判定为可删除状态下,才会给出删除和修改链接,点击删除链接按钮时,请求到达后台,还会先查询交流论坛状态再次做出判定能否删除。点击修改链接按钮时,会跳转到修改信息的页面,重新填写好数据后,数据提交到后台会对数据库中相应的记录做出修改。

添加交流论坛时,会给出数据填写的页面,该页面根据填写好的交流论坛编号同样会事先发送Ajax请求查询编号是否已存在,数据填写好之后提交到后台,会调用相关服务在数据库中插入记录。

交流论坛管理流程图如下图所示。

 

图5-9交流论坛管理流程图

交流论坛管理页面效果如下图所示。

 

图5-10交流论坛管理界面

交流论坛管理界面关键代码如下:

@RestController

@RequestMapping("auth")

public class AuthController extends BaseController<Auth, AuthService> {

    /**

     * 服务对象

     */

    @Autowired

    public AuthController(AuthService service) {

        setService(service);

    }

}

  1. 系统测试
    1. 测试目的

对任何系统而言,测试都是必不可少的环节,测试可以发现系统存在的很多问题,所有的软件上线之前,都应该进行充足的测试之后才能保证上线后不会Bug频发,或者是功能不满足需求等问题的发生。下面分别从单元测试,功能测试和用例测试来对系统进行测试以保证系统的稳定性和可靠性。

    1. 功能测试

下表是校园新闻管理功能的测试用例,检测了校园新闻管理中对校园新闻信息的增加,删除,修改,查询操作是否成功运行。观察系统的响应情况,得出该功能也达到了设计目标,系统运行正确。

前置条件;用户登录系统。

表6-1 校园新闻管理的测试用例

功能描述

用于校园新闻管理

测试目的

检测校园新闻管理时的各种操作的运行情况

测试数据以及操作

预期结果

实际结果

点击添加校园新闻,必填项合法输入,点击保存

提示添加成功

与预期结果一致

点击添加校园新闻,必填项输入不合法,点击保存

提示必填项不能为空

与预期结果一致

点击修改校园新闻,必填项修改为空,点击保存

提示必填项不能为空

与预期结果一致

点击修改校园新闻,必填项输入不合法,点击保存

提示必填项不能为空

与预期结果一致

点击删除校园新闻,选择校园新闻删除

提示删除成功

与预期结果一致

点击搜索校园新闻,输入存在的校园新闻名

查找出校园新闻

与预期结果一致

点击搜索校园新闻,输入不存在的校园新闻名

不显示校园新闻

与预期结果一致

下表是交流论坛管理功能的测试用例,检测了交流论坛管理中对交流论坛信息的增加,删除,修改,查询操作是否成功运行。观察系统的响应情况,得出该功能也达到了设计目标,系统运行正确。

前置条件;用户登录系统。

表6-2 交流论坛管理的测试用例

功能描述

用于交流论坛管理

测试目的

检测交流论坛管理时的各种操作的运行情况

测试数据以及操作

预期结果

实际结果

点击添加交流论坛,必填项合法输入,点击保存

提示添加成功

与预期结果一致

点击添加交流论坛,必填项输入不合法,点击保存

提示必填项不能为空

与预期结果一致

点击修改交流论坛,必填项修改为空,点击保存

提示必填项不能为空

与预期结果一致

点击修改交流论坛,必填项输入不合法,点击保存

提示必填项不能为空

与预期结果一致

点击删除交流论坛,选择交流论坛删除

提示删除成功

与预期结果一致

点击搜索交流论坛,输入存在的交流论坛名

查找出交流论坛

与预期结果一致

点击搜索交流论坛,输入不存在的交流论坛名

不显示交流论坛

与预期结果一致

下表是公告信息管理功能的测试用例,检测了公告信息管理中分类列表的操作是否成功运行。观察系统的响应情况,得出该功能也达到了设计目标,系统运行正确。

前置条件;用户登录系统。

表6-3 公告信息管理的测试用例

功能描述

用于公告信息管理

测试目的

检测公告信息管理时各种操作的情况

测试数据以及操作

预期结果

实际结果

未选择分类,点击提交

提示请选择分类

与预期结果一致

未选择列表,点击提交

提示请选择列表

与预期结果一致

    1. 性能测试

使用阿里云PTS(Performance Testing Service)性能测试服务对线上系统进行压力测试。线上服务器环境为:1核心CPU,1G内存,1Mbps公网带宽,Centos7.0操作系统。

压测过程中使用了2台并发机器,每台机器20个用户并发,对系统主页,登录,数据查询和数据维护等模块进行并发访问,测试结果是有40个用户并发时,数据管理相关页面的响应时间甚至达到了7s,通过查看服务器出网流量发现已经达到1381kb/s,可以看出服务器的带宽已经达到峰值,如果系统使用5Mbps的带宽,系统的响应时间和TPS将会大大增加。在整个测试的过程中,CPU的使用率占用仅8%,也提现出带宽瓶颈对系统的影响非常严重。

  1. 总结与展望

随着计算机互联网技术的迅猛发展,各行各业都已经实现采用计算机相关技术对日益放大的数据进行管理。该课题是校园新闻网站为核心展开的。本研究针对校园新闻网站需求建模,数据建模及过程建模分析设计的过程。给出系统应用架构并分析优劣势,通过功能分解图,系统组件图描述功能需求。设计建立了数据库,给出系统关键数据结构的定义。通过类关系图描述组件间的协作关系,给出各个类的定义方法。通过描述每一个类的字段,属性及方法实现系统的前后端代码。最终给出系统集成整合方法,完成校园新闻网站地设计与实现。系统投入运行时,各功能均运行正常。系统的每个界面的操作符合常规逻辑,对使用者来说操作简单,界面友好。整个系统的各个功能设计合理,体现了人性化。

但是由于自己在系统开发过程中对一些用到的相关知识和技术掌握不够牢固,再加上自身开发经验欠缺,因此系统在有些方面的功能还不够完善,考虑的不够全面,因此整个系统还有待日后逐步完善。

参考文献

[1]王江霖,黄彩霞,樊旭龙.基于SSM框架的网络资源共享平台的研究与实现[J].电脑知识与技术,2021,17(28):76-78.

[2]曹华山.SSM框架在Web应用开发中的设计与实现[J].无线互联科技,2021,18(11):108-109.

[3]付吉菊.校园信息交流平台的设计与实现[J].吉林工程技术师范学院学报,2021,37(05):95-98.

[4]秦溧,艾青.基于SSM框架的学生生活服务平台的设计与实现[J].电脑知识与技术,2021,17(13):80-82.

[5]李杰. 特色校园文化在高校学术交流空间设计中的视觉展现[D].聊城大学,2019.

[6]秦钊. 面向教育领域的群组多角色互动交流平台[D].济南大学,2019.

[7]马黎.浅谈新媒体时代高校校园文化建设[J].辽宁师专学报(社会科学版),2019(02):117-118.

[8]黄晓先.基于Android的掌上校园交流系统设计与实现[J].开封教育学院学报,2019,36(03):280-281.

[9]康舜禹,姜春风,刘松,周冰寒,朱明超,沈宗宇.“阳光下”服务交流平台的开发与实现[J].吉林农业科技学院学报,2019,23(03):38-40.

[10]蒙学琼,马潜福.校园网络 助力教师专业成长[J].中国民族教育,2019(04):26-28.

[11]张晓蓉.高校校园新闻网站群建设的现状及对策分析[J].陕西教育(高教版),2019(09):60.

[12]万丽.利用校园新闻网站开拓教学空间——发挥校园新闻网站在教育教学中的作用[J].学周刊,2018(21):49.

[13]吴晓玲.高校校园新闻网站建设与应用研究[J].黑龙江科技信息,2018(31):101.

[14]林伟.资源共享 交流互动——让校园网成为农村学校腾飞的翅膀[J].中国信息技术教育,2018(05):86-87.

[15]于婧阳,高铁刚.校园新闻网站建设现状调查与反思[J].中小学信息技术教育,2018(09):87-88.

[16]张希涛 ,刘凤云.搭建校园新闻网站 推进政治学科教学[J].思想政治课教学,2018(09):38.

致谢

本次设计历时3个月。在这个毕业设计中,它离不开指导教师的指导,使事情基本顺利。指导老师无论是在毕业设计历经中,还是在论文做完中都给了了我特别大的助益。另1个方面,教师认真负责的工作姿态,谨慎的教学精神厚重的理论水准都使我获益匪浅。他勤恳谨慎的教学育人学习姿态也给我留下了特别特别深的感觉。我从老师那里学到了很多东西。在理论和实践中,我的技能得到了特别大的提高。在此,特向教师表示由衷的感激。

After all the research and development of this graduation project, my system research and development has experienced a special progress from requirement analysis to realization of detailed functions, to final testing and maintenance. Let me have a deeper understanding of system development. Now my hands-on ability and ability to deal with doubts alone have also gained a particularly large increase in practice and learning. This is the best harvest of this graduation project.

Finally, during the whole system development process, the classmates and friends around me gave me a lot of opinions, so I quickly confirmed the business idea of ​​the system. Here, I sincerely express my gratitude to them.

Please pay attention to like + private message blogger, get the source code of the project for free

Guess you like

Origin blog.csdn.net/ID3461074420/article/details/131374746