Design and implementation of a scientific research information display website for university teachers based on SSM

Get the source code at the end
Development language: Java
Java development tool: JDK1.8
Back-end framework: SSM
Front-end: developed using JSP technology
Database: MySQL5.7 combined with Navicat management tools
Server: Tomcat8.5
Development software: IDEA/Eclipse
Whether it is a Maven project: yes


Table of contents

1. Project Introduction

2. System design

Design Principles

3. System project screenshots

Teacher management

Add research project

Scientific research project management

Add department

Department Management

Add college

College Management

Issue news announcements

News announcement management

change Password

Teacher information

Teacher details

Query scientific research projects

Scientific research project information

news

4. Core code

4.1 Login related

4.2 File upload

4.3 Packaging


1. Project Introduction

Since the development of the Internet, both its theory and technology have matured, and it has widely participated in all aspects of society. It allows information to be disseminated through the Internet, and combined with information management tools, it can provide good services to people. In view of the problems such as chaotic information management of university teachers' scientific research project display, high error rate, poor information security, high labor intensity, time-consuming and labor-intensive, the use of university teachers' scientific research information display website can be effectively managed, making information management more scientific and standardized.

The scientific research information display website for university teachers is coded in the Eclipse environment using Java language, and Mysql is used to create data tables to save the data generated by this system. The system can provide information display and corresponding services. Its administrators mainly manage colleges and departments in the background of the system, manage scientific research project information developed by teachers, manage teachers, and manage news information. Users mainly search for teachers and scientific research projects at the front desk of the system, download papers published by teachers, and view news information.

In short, the scientific research information display website for university teachers centrally manages information and has many advantages such as strong confidentiality, high efficiency, large storage space, and low cost. It can reduce information management costs and realize computerization of information management.


2. System design

A successfully designed system must be rich in content and user-friendly in terms of system appearance or system functions. Therefore, in order to enhance the value of the system, attract more visitors to the system, and allow visiting users to spend more time on the system, it means that the system is designed to be more professional.

Design Principles

This system needs to follow certain design principles during the design process. The purpose is to ensure that the developed system has high quality, complete functions, and is convenient and simple to operate, so that it can meet the user's requirements to the greatest extent. In addition to the basic principles of easy operation and safety, the system design principles also include the principles of accuracy, practicality, and maintainability.

The first design principle: the principle of ease of operation. The functions designed for this system must be complete and complete. When coding, the interfaces designed must be friendly. Once users use this system, they must be able to easily get started and operate the system to process data. time, it must be convenient. In addition, some necessary prompts need to be designed to guide users to operate the system.

The second design principle: the security principle. This system needs to authenticate each visitor in the login module. The system will judge based on the information entered by the visitor, use the security verification code written in advance for data comparison, and guide the successful matching. Visitors enter the specified operation interface. This prevents irrelevant visitors from stealing system data.

The third design principle: the principle of accuracy. In order to ensure that the data registered by users is correct, a data error correction mechanism needs to be designed in advance so that users can carefully check the registered error information through the system's error prompts and correct the errors in a timely manner. , fill in the correct information. For example, when setting a password, it is required that the length of the password cannot be less than 6 characters, and the data type cannot be all numbers, etc. can be standardized.

The fourth design principle: the principle of practicality. This system is mainly used to process information. In actual work, it should help users complete information processing tasks. At the same time, this system should also be able to meet the needs of information processing when facing special situations. . In addition, in order to facilitate the expansion of functions in this system later, it is also necessary to reserve space in advance.

The fifth design principle: the principle of maintainability. During the actual use of this system, it is inevitable that some faults will be encountered. Therefore, when the system responds to faults, it must be able to diagnose and weaken the faults, and can perform self-maintenance in a short time. .



3. System project screenshots

Teacher management

Administrators can manage teacher information after entering the designated function operation area. Its page is shown below. Administrators can add, delete, modify and check teacher information. Teacher information includes the teacher's college, teacher's avatar, teacher's contact information, etc. On this page, administrators can also download paper files published by teachers.

Add research project

Administrators can add scientific research projects after entering the designated function operation area. Its page is shown below. Registering a scientific research project requires the administrator to register the research and development teacher, research and development time, name of the results, pictures of the results display, etc. and upload the scientific research results documents to submit the information.

 

Scientific research project management

Administrators can manage scientific research project information after entering the designated functional operation area. Its page is shown below. The administrator can modify the scientific research project information displayed on the current page, such as modifying the scientific research project display pictures, modifying the name and description of the results, etc. The administrator can also delete the scientific research project information that needs to be deleted on this page.

 

Add department

Administrators can add departments after entering the designated function operation area. Its page is shown below. The administrator can submit the information by registering the name of the department.

 

Department Management

Administrators can manage departments after entering the designated functional operation area. Its page is shown below. The department information displayed on the current page can be modified or deleted by the administrator.

 

Add college

Administrators can add colleges after entering the designated functional operation area. Its page is shown below. The administrator can submit the information by registering the name of the college.

 

College Management

Administrators can manage the academy after entering the designated functional operation area. Its page is shown below. The administrator can modify the college name, delete college information, and query college information.

 

Issue news announcements

Administrators can issue news announcements after entering the designated functional operation area. Its page is shown below. When an administrator publishes a news announcement, he or she needs to add a picture to the announcement and then describe the content of the announcement to submit the information.

 

News announcement management

Administrators can manage news announcements after entering the designated functional operation area. Its page is shown below. After the news announcement is released, it will be displayed in the front desk. Announcements successfully released by the administrator require post-maintenance, including modifying the announcement, deleting the announcement, etc.

 

change Password

The administrator can change the password after entering the designated function operation area. Its page is shown below. The password change function mainly allows administrators to change the password information used to log in to the system, so that the data saved in the system can be protected.

 

Teacher information

Users can view teacher information after entering the system front desk. Its page is shown below. Users can query designated teachers based on the teacher's region, college or department information.

 

Teacher details

After entering the system front desk, the user can view the teacher's detailed information. Its page is shown below. In addition to viewing the teacher's profile on the teacher's detailed information page, users can also download paper files published by the teacher.

 

Query scientific research projects

After entering the system front desk, users can query scientific research projects. Its page is shown below. Users can obtain specified scientific research project information by submitting the name of their results.

 

Scientific research project information

After entering the system front desk, users can view scientific research project information. Its page is shown below. Users can click on the scientific research project display picture to enter its details page, and the user can view the brief information of the scientific research project.

 

news

Users can view news information after entering the system front desk. Its page is shown below. Once the administrator publishes news information, its information will be displayed on this page. To view news information, users only need to click on the title of the news or the picture of the news to enter its detailed introduction page to view the detailed content of the news.

 


4. Core code

4.1 Login related


package com.controller;


import java.util.Arrays;
import java.util.Calendar;
import java.util.Date;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.annotation.IgnoreAuth;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.entity.TokenEntity;
import com.entity.UserEntity;
import com.service.TokenService;
import com.service.UserService;
import com.utils.CommonUtil;
import com.utils.MD5Util;
import com.utils.MPUtil;
import com.utils.PageUtils;
import com.utils.R;
import com.utils.ValidatorUtils;

/**
 * 登录相关
 */
@RequestMapping("users")
@RestController
public class UserController{
	
	@Autowired
	private UserService userService;
	
	@Autowired
	private TokenService tokenService;

	/**
	 * 登录
	 */
	@IgnoreAuth
	@PostMapping(value = "/login")
	public R login(String username, String password, String captcha, HttpServletRequest request) {
		UserEntity user = userService.selectOne(new EntityWrapper<UserEntity>().eq("username", username));
		if(user==null || !user.getPassword().equals(password)) {
			return R.error("账号或密码不正确");
		}
		String token = tokenService.generateToken(user.getId(),username, "users", user.getRole());
		return R.ok().put("token", token);
	}
	
	/**
	 * 注册
	 */
	@IgnoreAuth
	@PostMapping(value = "/register")
	public R register(@RequestBody UserEntity user){
//    	ValidatorUtils.validateEntity(user);
    	if(userService.selectOne(new EntityWrapper<UserEntity>().eq("username", user.getUsername())) !=null) {
    		return R.error("用户已存在");
    	}
        userService.insert(user);
        return R.ok();
    }

	/**
	 * 退出
	 */
	@GetMapping(value = "logout")
	public R logout(HttpServletRequest request) {
		request.getSession().invalidate();
		return R.ok("退出成功");
	}
	
	/**
     * 密码重置
     */
    @IgnoreAuth
	@RequestMapping(value = "/resetPass")
    public R resetPass(String username, HttpServletRequest request){
    	UserEntity user = userService.selectOne(new EntityWrapper<UserEntity>().eq("username", username));
    	if(user==null) {
    		return R.error("账号不存在");
    	}
    	user.setPassword("123456");
        userService.update(user,null);
        return R.ok("密码已重置为:123456");
    }
	
	/**
     * 列表
     */
    @RequestMapping("/page")
    public R page(@RequestParam Map<String, Object> params,UserEntity user){
        EntityWrapper<UserEntity> ew = new EntityWrapper<UserEntity>();
    	PageUtils page = userService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.allLike(ew, user), params), params));
        return R.ok().put("data", page);
    }

	/**
     * 列表
     */
    @RequestMapping("/list")
    public R list( UserEntity user){
       	EntityWrapper<UserEntity> ew = new EntityWrapper<UserEntity>();
      	ew.allEq(MPUtil.allEQMapPre( user, "user")); 
        return R.ok().put("data", userService.selectListView(ew));
    }

    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    public R info(@PathVariable("id") String id){
        UserEntity user = userService.selectById(id);
        return R.ok().put("data", user);
    }
    
    /**
     * 获取用户的session用户信息
     */
    @RequestMapping("/session")
    public R getCurrUser(HttpServletRequest request){
    	Long id = (Long)request.getSession().getAttribute("userId");
        UserEntity user = userService.selectById(id);
        return R.ok().put("data", user);
    }

    /**
     * 保存
     */
    @PostMapping("/save")
    public R save(@RequestBody UserEntity user){
//    	ValidatorUtils.validateEntity(user);
    	if(userService.selectOne(new EntityWrapper<UserEntity>().eq("username", user.getUsername())) !=null) {
    		return R.error("用户已存在");
    	}
        userService.insert(user);
        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody UserEntity user){
//        ValidatorUtils.validateEntity(user);
        userService.updateById(user);//全部更新
        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Long[] ids){
        userService.deleteBatchIds(Arrays.asList(ids));
        return R.ok();
    }
}

4.2 File upload

package com.controller;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.UUID;

import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.util.ResourceUtils;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import com.annotation.IgnoreAuth;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.entity.ConfigEntity;
import com.entity.EIException;
import com.service.ConfigService;
import com.utils.R;

/**
 * 上传文件映射表
 */
@RestController
@RequestMapping("file")
@SuppressWarnings({"unchecked","rawtypes"})
public class FileController{
	@Autowired
    private ConfigService configService;
	/**
	 * 上传文件
	 */
	@RequestMapping("/upload")
	public R upload(@RequestParam("file") MultipartFile file,String type) throws Exception {
		if (file.isEmpty()) {
			throw new EIException("上传文件不能为空");
		}
		String fileExt = file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf(".")+1);
		File path = new File(ResourceUtils.getURL("classpath:static").getPath());
		if(!path.exists()) {
		    path = new File("");
		}
		File upload = new File(path.getAbsolutePath(),"/upload/");
		if(!upload.exists()) {
		    upload.mkdirs();
		}
		String fileName = new Date().getTime()+"."+fileExt;
		File dest = new File(upload.getAbsolutePath()+"/"+fileName);
		file.transferTo(dest);
		FileUtils.copyFile(dest, new File("C:\\Users\\Desktop\\jiadian\\springbootl7own\\src\\main\\resources\\static\\upload"+"/"+fileName));
		if(StringUtils.isNotBlank(type) && type.equals("1")) {
			ConfigEntity configEntity = configService.selectOne(new EntityWrapper<ConfigEntity>().eq("name", "faceFile"));
			if(configEntity==null) {
				configEntity = new ConfigEntity();
				configEntity.setName("faceFile");
				configEntity.setValue(fileName);
			} else {
				configEntity.setValue(fileName);
			}
			configService.insertOrUpdate(configEntity);
		}
		return R.ok().put("file", fileName);
	}
	
	/**
	 * 下载文件
	 */
	@IgnoreAuth
	@RequestMapping("/download")
	public ResponseEntity<byte[]> download(@RequestParam String fileName) {
		try {
			File path = new File(ResourceUtils.getURL("classpath:static").getPath());
			if(!path.exists()) {
			    path = new File("");
			}
			File upload = new File(path.getAbsolutePath(),"/upload/");
			if(!upload.exists()) {
			    upload.mkdirs();
			}
			File file = new File(upload.getAbsolutePath()+"/"+fileName);
			if(file.exists()){
				/*if(!fileService.canRead(file, SessionManager.getSessionUser())){
					getResponse().sendError(403);
				}*/
				HttpHeaders headers = new HttpHeaders();
			    headers.setContentType(MediaType.APPLICATION_OCTET_STREAM);    
			    headers.setContentDispositionFormData("attachment", fileName);    
			    return new ResponseEntity<byte[]>(FileUtils.readFileToByteArray(file),headers, HttpStatus.CREATED);
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
		return new ResponseEntity<byte[]>(HttpStatus.INTERNAL_SERVER_ERROR);
	}
	
}

4.3 Packaging

package com.utils;

import java.util.HashMap;
import java.util.Map;

/**
 * 返回数据
 */
public class R extends HashMap<String, Object> {
	private static final long serialVersionUID = 1L;
	
	public R() {
		put("code", 0);
	}
	
	public static R error() {
		return error(500, "未知异常,请联系管理员");
	}
	
	public static R error(String msg) {
		return error(500, msg);
	}
	
	public static R error(int code, String msg) {
		R r = new R();
		r.put("code", code);
		r.put("msg", msg);
		return r;
	}

	public static R ok(String msg) {
		R r = new R();
		r.put("msg", msg);
		return r;
	}
	
	public static R ok(Map<String, Object> map) {
		R r = new R();
		r.putAll(map);
		return r;
	}
	
	public static R ok() {
		return new R();
	}

	public R put(String key, Object value) {
		super.put(key, value);
		return this;
	}
}

Guess you like

Origin blog.csdn.net/weixin_52721608/article/details/132929389