基于Spring Boot的大学生志愿者管理系统

目录

前言

 一、技术栈

二、系统功能介绍

三、核心代码

1、登录模块

 2、文件上传模块

3、代码封装


前言

系统根据现有的管理模块进行开发和扩展,采用面向对象的开发的思想和结构化的开发方法对大学生志愿者管理的现状进行系统调查。采用结构化的分析设计,该方法要求结合一定的图表,在模块化的基础上进行系统的开发工作。在设计中采用自下而上的思想,在大学生志愿者管理系统实现了志愿者、志愿组织、组织风采、志愿活动、组织报名、活动报名、留言板的功能性。

 一、技术栈

末尾获取源码
Spring Boot+JS+ jQuery+Ajax...

二、系统功能介绍

游客打开系统的网址后,首先看到的就是首页界面在这里,游客能够看到大学生志愿者管理系统导航条显示首页、志愿组织、组织风采、志愿活动、公告信息、留言板、后台管理、个人中心。系统首页界面如图5-1所示

 在系统首页点击中间注册/登录按钮,然后页面跳转到注册登录界面,后来输入信息完成后,单击注册或者登录操作,如图5-2所示

 

志愿者点击志愿组织,志愿组织页面的搜索栏输入组织名称,进行查询然后还可以查看组织编号、组织名称、组织LOGO、成立时间、负责人、联系电话、组织简介,最后如果有需要可以点击报名或者收藏等操作;图5-3所示: 

 志愿者点击组织风采,组织风采页面搜索栏输入组织名称,进行查询,然后可以查看组织编号、组织名称、图片、视频,最后可以点击收藏操作;图5-4所示:

 在个人中心页面可以输入个人详细信息进行信息更新操作,还可以对我的收藏进行详细操作,图5-5所示

 管理员通过登录页面填写用户名和密码,选择角色完成后进行登录,如图5-6所示。

 管理员登录进入大学生志愿者管理系统的实现可以查看系统首页、个人中心、志愿者管理、志愿组织管理、组织风采管理、活动类型管理、志愿活动管理、组织报名管理、活动报名管理、留言板管理、系统管理等信息,如图5-7所示。

 管理员点击志愿者管理;在志愿者管理页面对志愿者账号、志愿者姓名、照片、性别、年龄、手机号码信息,进行查询或删除志愿者信息操作如图5-8所示。

 管理员点击志愿组织管理;在志愿组织管理页面对组织编号、组织名称、组织LOGO、成立时间、负责人、联系电话、组织简介信息,进行查询或删除志愿组织信息操作如图5-9所示。

 管理员点击组织风采管理;在组织风采管理页面对组织编号、组织名称、图片、视频信息,进行查询或删除组织风采操作如图5-10所示。

 管理员点击志愿活动管理;在志愿活动管理页面对活动主题、活动类型、活动图片、活动地点、开始时间、结束时间、组织编号、组织名称、发布时间信息,进行查询或删除志愿活动操作如图5-11所示。

 

三、核心代码

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

bAduVMS 是一款基于PHP+mysql技术架构的志愿服务管理系统,积十年经验精心策划研发,专为公益组织提供志愿服务工作无纸化办公系统解决方案,不仅能够帮助现有的网站进行资讯系统升级换代,也能够助力民间公益组织打造网络时代下的新志愿服务工作生态平台。 欢迎使用国内最专业的志愿者管理系统-八度志愿服务管理管理系统,它将是您轻松进行志愿工作的首选利器。 产品专注定位于公益组织的网络办公应用, 主要的功能模块有:文章管理,活动管理,会员管理、在线证书生成、求助、捐赠等,我们广泛调研各类公益组织运营中的需求,以内容更精准管理,功能更大,且易于维护,用户体验更佳为基本出发点,解决传统公益组织向互联网媒体转型或业务扩展中遇到的各种瓶颈,我们专注于细节,每个小的功能都是同类产品中 的佼佼者。 bAduVMS系统整合了CMS(新闻内容管理系统)、VEMS(志愿者活动管理系统)、VRMS(志愿者注册管理系统)、VCMS(志愿者认 证管理系统)、 VTMS(志愿者服务时数管理系统)等模块。通过这些系统模块帮助您的组织实现无纸化、无地域限制的志愿服务管理需求! 在模型不能满足用户所有需求的情况 下,bAduVMS推出一些互动的模块对系统进行补充,尽量满足用户的需求。 八度志愿者管理系统是国内少有的以公司力量来支撑的志愿者管理系统软件,在八度公司的研发支撑下,为广大公益团体提供免费或商业授权使用的发展路线。只有公司化经营的软件系统,才能更好的为客户解决软件系统中存在的bug漏洞、新增需求、随应时代发展需求而丰富的功能如微信公众号接入、支付宝服务号接入、小程序接入、微信支付等业务功能。在八度团队未来的构想中,它以后将会具有更大的灵活性和稳定的性能。真正意义上帮助您实现低碳办公的公益人追求的工作环境。 功能特色: 无缝支持PC或移动端访问,根据访问用户设备系统自动切换访问界面。 支持自定义格式报名表单,比如有些活动需要志愿者选择上午或者下午,是否携带朋友参加等,这些通过自定义格式报名表单就可以解决,告别千篇一律的报名格式选项,让志愿管理可以更个性更科学! 支持会员编号自定义设置格式。比如 区号+编号等。 支持在线求助于捐赠登记服务,方便志愿者与市民自主沟通。 支持无限级分类,包括文章或活动类型。 支持义工根据星级自动晋升。比如满100小时,自动升级到一星级志愿者。 支持义工证书在线生成图片,方便志愿者分享。 支持服务时数在线查询。 支持志愿者在线请假、取消参加活动等个性服务设置。 支持活动人员审批、服务时数批量管理等。 更多很赞的功能,请自行安装体验。 bAduVMS最适合应用于以下领域: 共青团政府部门 通过建立共青团官方的志愿服务门户,有利于各种信息和资源的整合,为共青团和社会公众之间加强联系和沟通,从而使共青团工作可以更快、更便捷、更有效开展工作; 公益机构 通过VMS的引入,使得公益机构之间及公益机构内部和志愿者之间进行信息传递,全面提升志愿服务工作的质量,实现科学、规范、专业的志愿管理工作生态环境; 学校社团 针对不同院系,强化内部的信息划分,体现校园志愿工作的特色,轻松实现建立院系管理账号,统一平台进行管理。 服务器环境: 支持Windows、Linux环境。 web服务器:PHP5.4版本以上并安装 Zend loader 加速器组件。 数据库环境:Mysql5.5以上版本。 常用路径: 前台登陆: http://yoursite/ 后台登陆: http://yoursite/admin (admin文件夹可修改为您需要的后台名称,如将admin文件夹修改为 manage ,那么后台登录地址为 http://yoursite/manage ) 注意事项: data、system/config、uploads文件夹需要可写支持。 运行环境必须是PHP5.4以上版本,并安装有Zend loader 加速器组件。 安装方法: 将程序包中的文件上传至您的网站根目录下,访问http://你的域名/install,根据向导完成安装。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值