基于SpringBoot的学科竞赛管理系统的设计与实现

news2024/10/6 14:37:31

目录

前言

 一、技术栈

二、系统功能介绍

学生功能模块的实现

管理员功能模块的实现

教师管理界面

三、核心代码

1、登录模块

 2、文件上传模块

3、代码封装


前言

随着国家教育体制的改革,全国各地举办的竞赛活动数目也是逐年增加,面对如此大的数目的竞赛信息,传统竞赛管理方式已经无法满足需求,为了提高效率,竞赛管理系统应运而生。

本学科竞赛管理系统以实际运用为开发背景,基于Spring Boot框架、Vue框架,运用了Java语言和MYSQL数据库进行开发设计,充分保证系统的安全性和稳定性。本系统界面良好,操作简单方便,通过系统概述、系统分析、系统设计、数据库设计、系统测试这几个部分,详细的说明了系统的开发过程,最后并对整个开发过程进行了总结,实现了学科竞赛管理的重要功能。

本学科竞赛管理系统运行效果稳定,操作方便、快捷,界面友好,是一个功能全面、实用性好、安全性高,并具有良好的可扩展性、可维护性的学科竞赛管理平台。

 一、技术栈

末尾获取源码
SpringBoot+Vue+JS+ jQuery+Ajax...

二、系统功能介绍

学生功能模块的实现

学生进入本系统可查看系统信息

没有账号的学生用户可进行注册操作。

学生在登录时需输入正确的登录用户名和密码,系统会以登录用户名、密码为参数进行登录信息的验证,信息正确则登录成功,反之登录失败。

学生可选择赛项查看详情信息,登录后可进行报名操作,赛项详情界面展示。

 学生可对个人信息进行修改。

管理员功能模块的实现

管理员要想进入后台进行管理操作,必须登录系统后台 。

管理在学生管理界面可查看所有学生信息,并可对其进行修改和删除操作,同时也可添加学生信息。

教师管理界面

管理员可增删改查教师信息 。

管理员可增删改查赛项信息。

管理员可查看所有赛项报名信息,并可对其进行审核、修改和删除操作,赛项报名管理界面。

管理员可增删改查奖项统计信息。

三、核心代码

1、登录模块

 
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();
    }
}

 2、文件上传模块

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);
	}
	
}

3、代码封装

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;
	}
}

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/1038666.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

使用CRM系统提高潜在客户质量

客户是企业发展的重要资源&#xff0c;如果销售人员获得更优质的潜在客户并对这些潜在客户进行跟踪&#xff0c;企业将获得更高的销售额。想要做到这点&#xff0c;就使用CRM销售管理系统吧&#xff01;下面我们说说&#xff0c;CRM系统如何提高潜在客户质量&#xff1f; 能够…

车载娱乐系统之Android系统CarFramework流程

目录 一&#xff0c;背景介绍 1.1 Android Automotive与整个Android生态系统的关系 1.2 Android Automotive架构 二&#xff0c;CarService启动流程 三&#xff0c;CarService源码分析 四. Car API 使用方式 4.1 编译 Car API 4.2 使用 Car API 一&#xff0c;背景介…

基于Python开发的高德地图+58租房系统(源码+可执行程序+程序配置说明书+程序使用说明书)

一、项目简介 本项目是一套基于Python开发的高德地图58租房系统&#xff0c;主要针对计算机相关专业的正在做毕设的学生与需要项目实战练习的Python学习者。 包含&#xff1a;项目源码、项目文档等&#xff0c;该项目附带全部源码可作为毕设使用。 项目都经过严格调试&#xf…

一级浪涌保护器的应用解决方案

浪涌是指电力线路上出现的短暂的过电压或过电流&#xff0c;它们通常由雷击、开关操作、电力故障等原因引起&#xff0c;对电气设备和电子信息系统造成严重的损害。地凯科技浪涌保护器&#xff08;SPD&#xff09;是一种用于限制瞬态过电压和泄放电涌电流的装置&#xff0c;它至…

阿里云七代云服务器实例、倚天云服务器及通用算力型和经济型实例规格介绍

在目前阿里云的云服务器产品中&#xff0c;既有五代六代实例规格&#xff0c;也有七代和八代倚天云服务器&#xff0c;同时还有通用算力型及经济型这些刚推出不久的新品云服务器实例&#xff0c;其中第五代实例规格目前不在是主推的实例规格了&#xff0c;现在主售的实例规格是…

vue3中$refs使用调整

前言&#xff1a; vue3环境 在vue2环境中&#xff0c;可以直接通过this.$refs获取模块&#xff1b;在vue3环境中&#xff0c;通用以下两种方式获取&#xff1a; 1、通过声明ref进行获取&#xff1b; import { ref} from vue; const logoForm ref(); console.log(logoForm.va…

python九九乘法表

编写程序&#xff0c;输出九九乘法表。 源代码&#xff1a; for a in range(1, 10): for b in range(1, a1): print(f"{a}*{b}{a * b}", end" ") print() 列出测试数据和实验结果截图&#xff1a;

关于CS 4.7 Stager 逆向及 Shellcode 重写

1. 概述 一直很想有一个自己的控&#xff0c;奈何实力不允许&#xff0c;CS 仍然是目前市面上最好用的控&#xff0c;但是也被各大厂商盯得很紧&#xff0c;通过加载器的方式进行免杀效果有限&#xff0c;后来看到有人用 go 重写了 CS 的 beacon&#xff0c;感觉这个思路很好&…

MySQL学习笔记15

1、内连接查询&#xff08;重点&#xff09;&#xff1a; 基本语法&#xff1a; select 数据表1.字段列表,数据表2.字段列表 from 数据表1 inner join 数据表2 on 连接条件; 案例&#xff1a;获取产品表中每个产品的分类信息&#xff1a; mysql> select * from tb_goods …

10分钟让你拿下Linux常用命令,网安运维测试人员必掌握!

文章目录 一、目录操作 1、批量操作 二、文件操作三、文件内容操作&#xff08;查看日志&#xff0c;更改配置文件&#xff09; 1、grep(检索文件内容)2、awk(数据统计)3、sed(替换文件内容)4、管道操作符|5、cut(数据裁剪) 四、系统日志位置五、创建与删除软连接六、压缩和解压…

9.19 QT作业

完成文本编辑器的保存工作 widget.h #ifndef WIDGET_H #define WIDGET_H#include <QWidget> #include<QFontDialog> //字体对话框 #include<QFont> //字体类 #include<QMessageBox> //消息对话框 #inclu…

使用git config --global设置用户名和邮件,以及git config的全局和局部配置

文章目录 1. 文章引言2. 全局配置2.1 命令方式2.2 配置文件方式 3. 局部配置3.1 命令方式3.2 配置文件方式 4. 总结 1. 文章引言 我们为什么要设置设置用户名和邮件&#xff1f; 我们在注册github&#xff0c;gitlab等时&#xff0c;一般使用用户名或邮箱&#xff1a; 这个用户…

csgo盲盒支付接口如何申请?

csgo盲盒支付接口如何申请&#xff1f;个人认为没什么特别难懂的&#xff01; 第一点&#xff1a;确定网站的基本功能&#xff01;每个网站的玩法大概都是一样的&#xff0c;无非是拆箱盲盒&#xff0c;ROLL房间、决斗、货物、生存和更换合同&#xff0c;然后有积分购物中心&am…

systemd Linux 发行版 antiX推出antiX 23 发布

导读基于 Debian “稳定 “分支的无 systemd Linux 发行版 antiX 的开发人员宣布推出 antiX 23。 这是该项目基于 Debian 12 的第一个版本&#xff1a;”antiX 23 ‘Arditi del Popolo’是基于 Debian ‘书虫’的新版本。 像往常一样&#xff0c;我们为 32 位和 64 位架构提供…

485modbus转profinet网关在混料配料输送系统应用博图配置案例

PLC作为一个可编程的控制器&#xff0c;通过与兴达易控modbus转profinet网关&#xff08;XD-MDPN100&#xff09;之间的通信&#xff0c;将控制命令传递给变频器&#xff0c;实现对其速度和转动方向等参数的调节。同时&#xff0c;PLC还能够接收来自称重仪表的称重数值&#xf…

学习路之工具--SecureCRT的下载、安装

百度盘&#xff1a; 链接: https://pan.baidu.com/s/1r3HjEj053cKys54DTqLM4A?pwdgcac 提取码: gcac 复制这段内容后打开百度网盘手机App&#xff0c;操作更方便哦 感谢大佬 简单介绍下SecureCRT SecureCRT是一款支持SSH&#xff08;SSH1和SSH2&#xff09;的终端仿真程序&a…

JavaScript代理模式

JavaScript代理模式 1 什么是代理模式2 实现一个简单的代理模式3 保护代理和虚拟代理4 虚拟代理实现图片预加载5 虚拟代理合并HTTP请求6 缓存代理 1 什么是代理模式 代理模式是为一个对象提供一个代用品或占位符&#xff0c;以便控制对它的访问。 代理模式的关键是&#xff0…

LCR 164.破解闯关密码(数字---字符)

目录 一、题目 二、解答 一、题目 LCR 164. 破解闯关密码 - 力扣&#xff08;LeetCode&#xff09; 二、解答 std::stoi 返回的是一个 int 类型的整数。std::stoull 返回的是一个 unsigned long long 类型的整数&#xff08;无符号长整数&#xff09; class Solution { pub…

unity gb28181 rtsp 视频孪生图像拉流和矫正插件(一)

目的是为了视频孪生&#xff0c;将视频放到三维里面&#xff0c;如果使用自己写的插件&#xff0c;有更好的灵活性&#xff0c;同时断线重连等等都更好控制了。 1、矫正算法和硬件解码 最好使用opencv制作&#xff0c;可以使用opencv的cuda加速&#xff0c;opencv的编译&…