基于SSM+JSP的大学生社团管理系统

news2024/9/29 13:33:08

末尾获取源码
开发语言:Java
Java开发工具:JDK1.8
后端框架:SSM
前端:采用JSP技术开发
数据库:MySQL5.7和Navicat管理工具结合
服务器:Tomcat8.5
开发软件:IDEA / Eclipse
是否Maven项目:是


前言

基于SSM+JSP的大学生社团管理系统有三大角色:

学生前台:查看首页、社团信息、社团活动、公告信息、个人中心、后台管理。

社长:社团信息管理、社团成员管理、退团记录管理、社团活动管理、活动报名管理、退出活动管理、社团事务管理。

管理员:学院管理、学校管理、年纪管理、班级管理、社长管理、学生管理、社团类型管理、社团信息管理、社团成员管理、退团记录管理、社团活动管理、活动报名管理、退出活动管理、社团事务管理、系统管理。

前台页面

 在前台首页可以查看首页、社团信息、社团活动、公告信息、个人中心、后台管理。

 在社团信息中,用户可以查询自己想要查看的社团信息。

 学生登录页面。

 学生注册页面。

 学生个人信息。

 信息公告页面

 学生可以选择自己喜欢的社团点击申请入团。

 学生可以在社团活动中查看社团发布的活动并且可以申请报名。

 用户的后台管理可以查看社团成员的管理、退团记录管理、活动报名管理、退出活动管理。

社长功能

 社长和管理员在后台的登录页面。

 社长登录后可以看到有社团信息管理、社团成员管理、退团记录管理、社团活动管理、活动报名管理、退出活动管理、社团事务管理。

 社团信息管理页面。

社团事务管理页面。

 

管理员功能

 管理员登录后可以看到有学院管理、学校管理、年纪管理、班级管理、社长管理、学生管理、社团类型管理、社团信息管理、社团成员管理、退团记录管理、社团活动管理、活动报名管理、退出活动管理、社团事务管理、系统管理。

年纪管理页面。


登录模块核心代码


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

文件上传核心代码

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

 封装代码

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/545720.html

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

相关文章

数字信号处理基础(二):FFT和IFFT的使用以及详细分析代码书写思路

目录 1. fft和ifft的原理1.1 fft1.2 ifft 2. 书写代码思路3. 完整代码4. 结果图 1. fft和ifft的原理 1.1 fft fft是快速傅里叶变换&#xff0c;是MATLAB中计算信号频谱的函数&#xff0c;使用方法是fft(x)&#xff0c;直接对信号x进行fft计算。 由于fft函数计算信号的频谱是0…

国考省考行测:资料分析,两年复合增长率

国考省考行测&#xff1a;资料分析&#xff0c;两年复合增长率 2022找工作是学历、能力和运气的超强结合体! 公务员特招重点就是专业技能&#xff0c;附带行测和申论&#xff0c;而常规国考省考最重要的还是申论和行测&#xff0c;所以大家认真准备吧&#xff0c;我讲一起屡屡…

考研算法第十三天:二叉排序树 【二叉排序树的插入和遍历】

这道题很妙。题目给的二叉排序树好像没学过其实就是二叉查找树。然后这道题主要的就是思路 1.节点的初始化&#xff08;记住&#xff09; struct TreeNode {int val;TreeNode *left;TreeNode *right;TreeNode(int x) : val(x), left(NULL), right(NULL) {} }; 2.节点的插入 …

HTTPS 的加密流程

文章目录 前言一.HTTPS 是什么二."加密" 是什么四.HTTPS解决了哪些问题五.HTTPS 的工作过程对称加密非对称加密引入证书 前言 本文介绍了HTTPS的加密流程&#xff0c;以及HTTPS在保护用户数据安全和确保通信机密性方面的重要性。通过详细解释HTTPS的工作原理和加密流…

网络安全里的主要岗位有哪些?小白如何快速入门?

入门Web安全、安卓安全、二进制安全、工控安全还是智能硬件安全等等&#xff0c;每个不同的领域要掌握的技能也不同。 当然入门Web安全相对难度较低&#xff0c;也是很多人的首选。主要还是看自己的兴趣方向吧。 本文就以下几个问题来说明网络安全大致学习过程&#x1f447; 网…

ChatGPT:世界已经永远改变了,而大多数人尚无所觉

1、你发现没有&#xff0c;现在跟朋友交流&#xff0c;言必聊ChatGPT。几乎所有人都在蹭GPT的热度&#xff0c;无论是头部企业还是普通的个人开发者&#xff0c;都想趁着ChatGPT东风狂赚一笔。有卖ChatGPT账号的、有借用ChatGPT的API集成服务让人付费试用的&#xff0c;还有人利…

Android第一代加壳技术的验证、测试和探究

Android第一代加壳测试&#xff0c;网上有很多文章&#xff0c;本文只是在前人基础上测试和验证。因此&#xff0c;本文的重点在于动手和实践。 第一代加壳技术有三个项目&#xff0c;分别是&#xff1a; 加壳程序。主要是把需要加壳的原程序加密后&#xff0c;放在壳程序中&…

全能超高清解码播放器_完美解码

哈喽&#xff0c;大家好。今天给各位小伙伴们测试了一款全能超高清解码播放器——完美解码。 这是一款为众多影视发烧友精心打造的专业高清播放器。超强HDTV支持&#xff0c;画质远超主流播放器&#xff01;全面开启硬件加速&#xff0c;CPU资源占用低&#xff0c;强劲高清解码…

Matplotlib绘制漂亮的饼状图|python绘制漂亮的饼状图

python绘图系列文章目录 往期python绘图合集: python绘制简单的折线图 python读取excel中数据并绘制多子图多组图在一张画布上 python绘制带误差棒的柱状图 python绘制多子图并单独显示 python读取excel数据并绘制多y轴图像 python绘制柱状图并美化|不同颜色填充柱子 python随机…

LeetCode刷题 --- 栈

栈&#xff08;stack&#xff09;是一种用于存储数据的简单数据结构。栈一个有序线性表&#xff0c;只能在表的一端&#xff08;PS&#xff1a;栈顶&#xff09;执行插人和删除操作。最后插人的元素将被第一个删除。所以&#xff0c;栈也称为后进先出&#xff08;Last In First…

AI在狂飙,ChatGPT-4可直接在iPhone上使用啦

今天凌晨&#xff0c;OpenAI 正式在 App Store 推出了 ChatGPT 的 iOS app&#xff0c;瞬间冲上苹果商店免费榜第二名&#xff0c;效率榜第一名。 于是兴致勃勃的去下载体验了一番。整体不错&#xff0c;以后手机使用官方的 ChatGPT 更方便啦&#xff01;而且使用 GPT4 不再麻…

JavaScript事件流

一、事件流和它的两个阶段 1.事件流&#xff1a;是事件完整执行过程中的流动路径 2.说明&#xff1a;假设页面里有个div&#xff0c;当触发事件时&#xff0c;会经历两个阶段&#xff0c;分别是捕获阶段、冒泡阶段 &#xff08;1&#xff09;捕获&#xff1a;从父到子 &#…

测试工程师都是怎么写测试用例的?​

很多人不知道写测试用例有什么用&#xff0c;而仅仅是像工具人一样&#xff0c;在每次提测之前&#xff0c;把测试用例照着需求文档抄一遍&#xff0c;仿佛像是走个过场。 开发提测之后&#xff0c;就照着测试用例点点点&#xff0c;可能一天就走完用例了&#xff0c;开发代码…

最优化理论-线性规划中的大M法的步骤

目录&#xff1a; 一、引言 二、线性规划的基本概念 三、最优化理论中的大M法 1. 大M法的基本思想 2. 大M法的步骤 3. 大M法的优缺点 四、大M法的应用 1. 生产计划问题 2. 运输问题 3. 投资问题 五、总结 一、引言 最优化理论是数学中的一个重要分支…

【2023/05/19】NFA

Hello&#xff01;大家好&#xff0c;我是霜淮子&#xff0c;2023倒计时第14天。 非确定有限状态自动机&#xff08;NFA&#xff09;是一种模拟复杂系统行为的数学模型 目录 一、基本概念和理论 二、优点和缺点 三、应用场景 四、问题和挑战 五、重要性、作用和使用价值 …

学习HCIP的day.07

目录 7、SPF算法 --- OSPF防环机制 OSPF区域间防环 OSPF域外防环 基于以上长篇理论总结&#xff1a; 7、SPF算法 --- OSPF防环机制 &#xff08;1&#xff09;在同一个区域每台路由具有一致的LSDB &#xff08;2&#xff09;每台路由器以自己为根计算到达每个目标的最短路…

Java泛型,数组和方法返回类型 - 协变,逆变和不变

首先&#xff0c;让我们通常理解一下子类型规则是什么。 协变vs逆变vs双变vs不变 编程语言可能有支持以下子类型规则的特性&#xff1a; 协变 允许用超类型替换子类型。 逆变 允许用子类型替换超类型。 双变 同时是协变和逆变。 不变 不允许上述任何替换。 让我们看看Java支持哪…

Intellij IDEA 如何删掉插件

在 Intellij IDEA 的配置中&#xff0c;找到插件选项。 在插件选项中&#xff0c;选择需要删除的插件&#xff0c;然后在右侧的对话框中选择 uninstall 就可以了。 卸载以后&#xff0c;可能不会要求重启&#xff0c;为了安全起见&#xff0c;还是重启下你的 IDE 吧。

C++容器详解

什么是容器 首先&#xff0c;我们必须理解一下什么是容器&#xff0c;在C 中容器被定义为&#xff1a;在数据存储上&#xff0c;有一种对象类型&#xff0c;它可以持有其它对象或指向其它对像的指针&#xff0c;这种对象类型就叫做容器。很简单&#xff0c;容器就是保存其它对…

Flutter控件之文本Text封装

Flutter控件之基类Widget封装 上篇文章&#xff0c;我们简单针对Widget做了一个基类封装&#xff0c;拓展出了很多常见又易用的属性&#xff0c;比如宽高&#xff0c;内外边距等等&#xff0c;很方便的为接下来的各个基础组件的封装&#xff0c;提供极大的便利&#xff0c;在上…