基于java+ssm+vue的志愿者管理系统

项目介绍

使用旧方法对志愿者管理系统的信息进行系统化管理已经不再让人们信赖了,把现在的网络信息技术运用在志愿者管理系统的管理上面可以解决许多信息管理上面的难题,比如处理数据时间很长,数据存在错误不能及时纠正等问题。这次开发的志愿者管理系统对字典管理、论坛管理、活动管理、活动报名管理、活动收藏管理、活动承办方管理、活动宣传管理、团委管理、志愿者管理、管理员管理等进行集中化处理。经过前面自己查阅的网络知识,加上自己在学校课堂上学习的知识,决定开发系统选择B/S模式这种高效率的模式完成系统功能开发。这种模式让操作员基于浏览器的方式进行网站访问,采用的主流的Java语言这种面向对象的语言进行志愿者管理系统程序的开发,在数据库的选择上面,选择功能强大的Mysql数据库进行数据的存放操作。志愿者管理系统的开发让用户查看活动信息变得容易,让管理员高效管理活动信息。

开发环境

编程语言:Java
数据库 :Mysql
系统架构:B/S
后端框架:SSM
编译工具:idea或者eclipse,jdk1.8,maven
支持定做:java/php/python/android/小程序/vue/爬虫/c#/asp.net

系统实现

5.1管理员功能介绍
5.1.1管理员登录
系统登录功能是程序必不可少的功能,在登录页面必填的数据有两项,一项就是账号,另一项数据就是密码,当管理员正确填写并提交这二者数据之后,管理员就可以进入系统后台功能操作区。下图就是管理员登录页面。
在这里插入图片描述

图5.1 管理员登录页面

5.1.2 活动管理
项目管理页面提供的功能操作有:查看活动,删除活动操作,新增活动操作,修改活动操作。下图就是活动管理页面。
在这里插入图片描述

图5.2 活动管理页面

5.1.3 活动收藏信息管理
活动收藏信息管理页面提供的功能操作有:收藏活动,删除收藏活动操作。下图就是活动收藏信息管理页面。
在这里插入图片描述

图5.3 活动收藏信息管理页面

5.1.4活动类型管理
活动类型管理页面显示所有活动类型,在此页面既可以让管理员添加新的活动信息类型,也能对已有的活动类型信息执行编辑更新,失效的活动类型信息也能让管理员快速删除。下图就是活动类型管理页面。
在这里插入图片描述

图5.4 活动类型列表页面
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

核心代码

package com.controller;

import java.io.File;
import java.math.BigDecimal;
import java.net.URL;
import java.text.SimpleDateFormat;
import com.alibaba.fastjson.JSONObject;
import java.util.*;
import org.springframework.beans.BeanUtils;
import javax.servlet.http.HttpServletRequest;
import org.springframework.web.context.ContextLoader;
import javax.servlet.ServletContext;
import com.service.TokenService;
import com.utils.*;
import java.lang.reflect.InvocationTargetException;

import com.service.DictionaryService;
import org.apache.commons.lang3.StringUtils;
import com.annotation.IgnoreAuth;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.entity.*;
import com.entity.view.*;
import com.service.*;
import com.utils.PageUtils;
import com.utils.R;
import com.alibaba.fastjson.*;

/**
 * 团委
 * 后端接口
 * @author
 * @email
*/
@RestController
@Controller
@RequestMapping("/tuanwei")
public class TuanweiController {
    private static final Logger logger = LoggerFactory.getLogger(TuanweiController.class);

    @Autowired
    private TuanweiService tuanweiService;


    @Autowired
    private TokenService tokenService;
    @Autowired
    private DictionaryService dictionaryService;

    //级联表service

    @Autowired
    private ZhiyuanzheService zhiyuanzheService;
    @Autowired
    private HuodongchengbanfangService huodongchengbanfangService;


    /**
    * 后端列表
    */
    @RequestMapping("/page")
    public R page(@RequestParam Map<String, Object> params, HttpServletRequest request){
        logger.debug("page方法:,,Controller:{},,params:{}",this.getClass().getName(),JSONObject.toJSONString(params));
        String role = String.valueOf(request.getSession().getAttribute("role"));
        if(false)
            return R.error(511,"永不会进入");
        else if("志愿者".equals(role))
            params.put("zhiyuanzheId",request.getSession().getAttribute("userId"));
        else if("团委".equals(role))
            params.put("tuanweiId",request.getSession().getAttribute("userId"));
        else if("活动承办方".equals(role))
            params.put("huodongchengbanfangId",request.getSession().getAttribute("userId"));
        if(params.get("orderBy")==null || params.get("orderBy")==""){
            params.put("orderBy","id");
        }
        PageUtils page = tuanweiService.queryPage(params);

        //字典表数据转换
        List<TuanweiView> list =(List<TuanweiView>)page.getList();
        for(TuanweiView c:list){
            //修改对应字典表字段
            dictionaryService.dictionaryConvert(c, request);
        }
        return R.ok().put("data", page);
    }

    /**
    * 后端详情
    */
    @RequestMapping("/info/{id}")
    public R info(@PathVariable("id") Long id, HttpServletRequest request){
        logger.debug("info方法:,,Controller:{},,id:{}",this.getClass().getName(),id);
        TuanweiEntity tuanwei = tuanweiService.selectById(id);
        if(tuanwei !=null){
            //entity转view
            TuanweiView view = new TuanweiView();
            BeanUtils.copyProperties( tuanwei , view );//把实体数据重构到view中

            //修改对应字典表字段
            dictionaryService.dictionaryConvert(view, request);
            return R.ok().put("data", view);
        }else {
            return R.error(511,"查不到数据");
        }

    }

    /**
    * 后端保存
    */
    @RequestMapping("/save")
    public R save(@RequestBody TuanweiEntity tuanwei, HttpServletRequest request){
        logger.debug("save方法:,,Controller:{},,tuanwei:{}",this.getClass().getName(),tuanwei.toString());

        String role = String.valueOf(request.getSession().getAttribute("role"));
        if(false)
            return R.error(511,"永远不会进入");

        Wrapper<TuanweiEntity> queryWrapper = new EntityWrapper<TuanweiEntity>()
            .eq("username", tuanwei.getUsername())
            ;

        logger.info("sql语句:"+queryWrapper.getSqlSegment());
        TuanweiEntity tuanweiEntity = tuanweiService.selectOne(queryWrapper);
        if(tuanweiEntity==null){
            tuanwei.setCreateTime(new Date());
            tuanwei.setPassword("123456");
            tuanweiService.insert(tuanwei);
            return R.ok();
        }else {
            return R.error(511,"账户已经被使用");
        }
    }

    /**
    * 后端修改
    */
    @RequestMapping("/update")
    public R update(@RequestBody TuanweiEntity tuanwei, HttpServletRequest request){
        logger.debug("update方法:,,Controller:{},,tuanwei:{}",this.getClass().getName(),tuanwei.toString());

        String role = String.valueOf(request.getSession().getAttribute("role"));
//        if(false)
//            return R.error(511,"永远不会进入");
        //根据字段查询是否有相同数据
        Wrapper<TuanweiEntity> queryWrapper = new EntityWrapper<TuanweiEntity>()
            .notIn("id",tuanwei.getId())
            .andNew()
            .eq("username", tuanwei.getUsername())
            ;

        logger.info("sql语句:"+queryWrapper.getSqlSegment());
        TuanweiEntity tuanweiEntity = tuanweiService.selectOne(queryWrapper);
        if(tuanweiEntity==null){
            tuanweiService.updateById(tuanwei);//根据id更新
            return R.ok();
        }else {
            return R.error(511,"账户已经被使用");
        }
    }

    /**
    * 删除
    */
    @RequestMapping("/delete")
    public R delete(@RequestBody Integer[] ids){
        logger.debug("delete:,,Controller:{},,ids:{}",this.getClass().getName(),ids.toString());
        tuanweiService.deleteBatchIds(Arrays.asList(ids));
        return R.ok();
    }


    /**
     * 批量上传
     */
    @RequestMapping("/batchInsert")
    public R save( String fileName){
        logger.debug("batchInsert方法:,,Controller:{},,fileName:{}",this.getClass().getName(),fileName);
        try {
            List<TuanweiEntity> tuanweiList = new ArrayList<>();//上传的东西
            Map<String, List<String>> seachFields= new HashMap<>();//要查询的字段
            Date date = new Date();
            int lastIndexOf = fileName.lastIndexOf(".");
            if(lastIndexOf == -1){
                return R.error(511,"该文件没有后缀");
            }else{
                String suffix = fileName.substring(lastIndexOf);
                if(!".xls".equals(suffix)){
                    return R.error(511,"只支持后缀为xls的excel文件");
                }else{
                    URL resource = this.getClass().getClassLoader().getResource("static/upload/" + fileName);//获取文件路径
                    File file = new File(resource.getFile());
                    if(!file.exists()){
                        return R.error(511,"找不到上传文件,请联系管理员");
                    }else{
                        List<List<String>> dataList = PoiUtil.poiImport(file.getPath());//读取xls文件
                        dataList.remove(0);//删除第一行,因为第一行是提示
                        for(List<String> data:dataList){
                            //循环
                            TuanweiEntity tuanweiEntity = new TuanweiEntity();
//                            tuanweiEntity.setUsername(data.get(0));                    //账户 要改的
//                            //tuanweiEntity.setPassword("123456");//密码
//                            tuanweiEntity.setTuanweiName(data.get(0));                    //团委名称 要改的
//                            tuanweiEntity.setCreateTime(date);//时间
                            tuanweiList.add(tuanweiEntity);


                            //把要查询是否重复的字段放入map中
                                //账户
                                if(seachFields.containsKey("username")){
                                    List<String> username = seachFields.get("username");
                                    username.add(data.get(0));//要改的
                                }else{
                                    List<String> username = new ArrayList<>();
                                    username.add(data.get(0));//要改的
                                    seachFields.put("username",username);
                                }
                        }

                        //查询是否重复
                         //账户
                        List<TuanweiEntity> tuanweiEntities_username = tuanweiService.selectList(new EntityWrapper<TuanweiEntity>().in("username", seachFields.get("username")));
                        if(tuanweiEntities_username.size() >0 ){
                            ArrayList<String> repeatFields = new ArrayList<>();
                            for(TuanweiEntity s:tuanweiEntities_username){
                                repeatFields.add(s.getUsername());
                            }
                            return R.error(511,"数据库的该表中的 [账户] 字段已经存在 存在数据为:"+repeatFields.toString());
                        }
                        tuanweiService.insertBatch(tuanweiList);
                        return R.ok();
                    }
                }
            }
        }catch (Exception e){
            return R.error(511,"批量插入数据异常,请联系管理员");
        }
    }


    /**
    * 登录
    */
    @IgnoreAuth
    @RequestMapping(value = "/login")
    public R login(String username, String password, String captcha, HttpServletRequest request) {
        TuanweiEntity tuanwei = tuanweiService.selectOne(new EntityWrapper<TuanweiEntity>().eq("username", username));
        if(tuanwei==null || !tuanwei.getPassword().equals(password))
            return R.error("账号或密码不正确");
        //  // 获取监听器中的字典表
        // ServletContext servletContext = ContextLoader.getCurrentWebApplicationContext().getServletContext();
        // Map<String, Map<Integer, String>> dictionaryMap= (Map<String, Map<Integer, String>>) servletContext.getAttribute("dictionaryMap");
        // Map<Integer, String> role_types = dictionaryMap.get("role_types");
        // role_types.get(.getRoleTypes());
        String token = tokenService.generateToken(tuanwei.getId(),username, "tuanwei", "团委");
        R r = R.ok();
        r.put("token", token);
        r.put("role","团委");
        r.put("username",tuanwei.getTuanweiName());
        r.put("tableName","tuanwei");
        r.put("userId",tuanwei.getId());
        return r;
    }

    /**
    * 注册
    */
    @IgnoreAuth
    @PostMapping(value = "/register")
    public R register(@RequestBody TuanweiEntity tuanwei){
//    	ValidatorUtils.validateEntity(user);
        Wrapper<TuanweiEntity> queryWrapper = new EntityWrapper<TuanweiEntity>()
            .eq("username", tuanwei.getUsername())
            ;
        TuanweiEntity tuanweiEntity = tuanweiService.selectOne(queryWrapper);
        if(tuanweiEntity != null)
            return R.error("账户已经被使用");
        tuanwei.setCreateTime(new Date());
        tuanweiService.insert(tuanwei);
        return R.ok();
    }

    /**
     * 重置密码
     */
    @GetMapping(value = "/resetPassword")
    public R resetPassword(Integer  id){
        TuanweiEntity tuanwei = new TuanweiEntity();
        tuanwei.setPassword("123456");
        tuanwei.setId(id);
        tuanweiService.updateById(tuanwei);
        return R.ok();
    }


    /**
     * 忘记密码
     */
    @IgnoreAuth
    @RequestMapping(value = "/resetPass")
    public R resetPass(String username, HttpServletRequest request) {
        TuanweiEntity tuanwei = tuanweiService.selectOne(new EntityWrapper<TuanweiEntity>().eq("username", username));
        if(tuanwei!=null){
            tuanwei.setPassword("123456");
            boolean b = tuanweiService.updateById(tuanwei);
            if(!b){
               return R.error();
            }
        }else{
           return R.error("账号不存在");
        }
        return R.ok();
    }


    /**
    * 获取用户的session用户信息
    */
    @RequestMapping("/session")
    public R getCurrTuanwei(HttpServletRequest request){
        Integer id = (Integer)request.getSession().getAttribute("userId");
        TuanweiEntity tuanwei = tuanweiService.selectById(id);
        if(tuanwei !=null){
            //entity转view
            TuanweiView view = new TuanweiView();
            BeanUtils.copyProperties( tuanwei , view );//把实体数据重构到view中

            //修改对应字典表字段
            dictionaryService.dictionaryConvert(view, request);
            return R.ok().put("data", view);
        }else {
            return R.error(511,"查不到数据");
        }
    }


    /**
    * 退出
    */
    @GetMapping(value = "logout")
    public R logout(HttpServletRequest request) {
        request.getSession().invalidate();
        return R.ok("退出成功");
    }




    /**
    * 前端列表
    */
    @IgnoreAuth
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params, HttpServletRequest request){
        logger.debug("list方法:,,Controller:{},,params:{}",this.getClass().getName(),JSONObject.toJSONString(params));

        // 没有指定排序字段就默认id倒序
        if(StringUtil.isEmpty(String.valueOf(params.get("orderBy")))){
            params.put("orderBy","id");
        }
        PageUtils page = tuanweiService.queryPage(params);

        //字典表数据转换
        List<TuanweiView> list =(List<TuanweiView>)page.getList();
        for(TuanweiView c:list)
            dictionaryService.dictionaryConvert(c, request); //修改对应字典表字段
        return R.ok().put("data", page);
    }

    /**
    * 前端详情
    */
    @RequestMapping("/detail/{id}")
    public R detail(@PathVariable("id") Long id, HttpServletRequest request){
        logger.debug("detail方法:,,Controller:{},,id:{}",this.getClass().getName(),id);
        TuanweiEntity tuanwei = tuanweiService.selectById(id);
            if(tuanwei !=null){


                //entity转view
                TuanweiView view = new TuanweiView();
                BeanUtils.copyProperties( tuanwei , view );//把实体数据重构到view中

                //修改对应字典表字段
                dictionaryService.dictionaryConvert(view, request);
                return R.ok().put("data", view);
            }else {
                return R.error(511,"查不到数据");
            }
    }


    /**
    * 前端保存
    */
    @RequestMapping("/add")
    public R add(@RequestBody TuanweiEntity tuanwei, HttpServletRequest request){
        logger.debug("add方法:,,Controller:{},,tuanwei:{}",this.getClass().getName(),tuanwei.toString());
        Wrapper<TuanweiEntity> queryWrapper = new EntityWrapper<TuanweiEntity>()
            .eq("username", tuanwei.getUsername())
            ;
        logger.info("sql语句:"+queryWrapper.getSqlSegment());
        TuanweiEntity tuanweiEntity = tuanweiService.selectOne(queryWrapper);
        if(tuanweiEntity==null){
            tuanwei.setCreateTime(new Date());
        tuanwei.setPassword("123456");
        tuanweiService.insert(tuanwei);
            return R.ok();
        }else {
            return R.error(511,"账户已经被使用");
        }
    }


}

论文参考

在这里插入图片描述

目 录
目 录 III
1 绪论 1
1.1 研究背景 1
1.2目的和意义 1
1.3 论文结构安排 2
2 相关技术 3
2.1 B/S架构介绍 3
2.2 Mysql数据库介绍 3
2.3 JAVA语言介绍 5
3 系统分析 7
3.1系统可行性分析 7
3.1.1 技术可行性分析 7
3.1.2 经济可行性分析 7
3.1.3 运行可行性分析 7
3.2系统性能分析 8
3.2.1 系统安全性 8
3.2.2 数据完整性 8
3.2.3系统可扩展性 9
3.3系统流程分析 9
3.3.1系统登录流程 10
3.3.2信息添加流程 11
3.3.3信息删除流程 11
3.4系统功能分析 12
4 系统设计 13
4.1系统概要设计 13
4.2系统功能结构设计 13
4.3数据库设计 13
4.3.1数据库E-R图设计 13
4.3.2 数据库表结构设计 14
5 系统实现 18
5.1管理员功能介绍 18
5.1.1管理员登录 18
5.1.2 活动管理 18
5.1.3 活动收藏信息管理 19
5.1.4活动类型管理 19
6系统测试 21
6.1 本系统测试  21
6.1.1 登录功能测试 21
6.1.2 注册功能测试 22
6.2测试结果分析 22
结 论 23
参考文献 25
致 谢 26

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值