基于springboot志愿者管理平台源码和论文

  

志愿者是当代社会文明、传递爱心的重要体现之一,在当今的社会发展占据着重要地位。为了高效地管理志愿者的注册信息,合理地调配志愿者,以减少工作量,提高工作效率,受益者也能够得到志愿者更快更好的服务,开发此系统也许能解决此类问题。

首先,调查与分析了寮步志愿者管理的现状;其次,对于当前主流软件开发平台、技术以及数据库进行了研究,在此基础上提出了基于Idea平台,采用SpringBoot+Shiro+MyBatis框架以及采用Ajax、Thymeleaf等技术开发,并使用MySQL5.7数据库管理数据的开发方案;再次采用UML建模技术对系统进行需求分析、功能设计以及类的设计;最后实现了了一个具有志愿者管理、组织管理、活动管理、通知管理、公告管理、系统管理等功能的寮步志愿者管理平台。

经过测试和运行,系统的应用,将为寮步志愿组织及其志愿者提供一个日常操作的管理平台,节省了管理的人力资源和实践成本。

关键词:志愿者管理  SpringBoot  Shiro  MyBatis

【578】基于springboot志愿者管理平台源码和论文

ABSTRACT

The volunteer is one of the important manifestations of civilization and love in contemporary society, and they occupy an important position in today’s social development. In order to efficiently manage the registration information of volunteers and reasonably deploy volunteers to reduce workload and improve work efficiency, beneficiaries can also get faster and better services from volunteers, the development of this system may be can able to solve such problems.

Firstly, the present situation of the management of the volunteers in Liaobu was investigated and analyzed. Secondly, the current mainstream software development platform, technology and database are researched. Based on this, an Idea platform based on SpringBoot + Shiro + MyBatis framework and technologies, such as Ajax and Thymeleaf are developed. The database is managed using MySQL5.7 Development plan. Thirdly, UML modeling technology is used again to analyze the requirments of the system, functional design and class design. Finally, a volunteer management, organization management, A step-by-step volunteer management platform with functions such as event management, notification management, announcement management, and system management is realized.

After testing and running, the application of the system will provide a daily operation management platform for Liaobu voluntary organizations and their volunteers, saving management human resources and practical costs.

Keywords:The management of volunteer  SpringBoot  Shiro  MyBatis  

package com.yjy.zdemo.controller;

import com.yjy.zdemo._common.core.controller.BaseController;
import com.yjy.zdemo._common.core.page.TableDataInfo;
import com.yjy.zdemo._common.core.pojo.AjaxResult;
import com.yjy.zdemo._common.exceptions.BusinessException;
import com.yjy.zdemo._framework.config.Global;
import com.yjy.zdemo._framework.shiro.utils.ShiroUtils;
import com.yjy.zdemo.pojo.*;
import com.yjy.zdemo.service.*;
import com.yjy.zdemo.utils.ExcelUtils;
import com.yjy.zdemo.utils.Files.FileUploadUtils;
import com.yjy.zdemo.utils.PhoneSmsUtils;
import com.yjy.zdemo.utils.Security.PassSetUtils;
import com.yjy.zdemo.utils.StrUtils;
import org.apache.shiro.authz.annotation.Logical;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.apache.shiro.authz.annotation.RequiresRoles;
import org.apache.shiro.session.Session;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.ArrayList;
import java.util.List;

/**
 * 志愿者信息管理 控制层
 * Create By YuJiaYe on 2021/12/1
 */
@Controller
@RequestMapping("/volunteer")
public class VolunteerController extends BaseController {

    private static final Logger log = LoggerFactory.getLogger(DeptController.class);

    // 自定义路径
    private String prefix = "system/volunteer";
    // 自定义前台路径
    private String prefixFront = "system/webFrontEnd";

    @Autowired
    private UserService userService;

    @Autowired
    private VolunteerService volunteerService;

    @Autowired
    private DeptService deptService;

    @Autowired
    private VolunteerApplyService volunteerApplyService;

    @Autowired
    private NationService nationService;

    @Autowired
    private EducationService educationService;

    @Autowired
    private PoliticsService politicsService;

    @Autowired
    private WorkService workService;

    @Autowired
    private ActivityRecordService activityRecordService;

    /**
     * 获取志愿者相关信息的方法
     * @param mMap
     */
    public void getInfoMethod(ModelMap mMap){
        // 加入动态列表
        List<Nation> nationList = nationService.findNationAll();
        List<Education> educationList = educationService.findEducationAll();
        List<Politics> politicsList = politicsService.findPoliticsAll();
        List<Work> workList = workService.findWorkAll();
        // 放入集合
        mMap.put("nationList",nationList); // 民族
        mMap.put("educationList",educationList);// 最高学历
        mMap.put("politicsList",politicsList);// 政治面貌
        mMap.put("workList",workList);// 从业情况
    }

    /**
     * 获取用户角色组名称的方法
     * @param userId 获取
     * @return
     */
    public List<String> roleNames(Integer userId){
        List<Role> roles = userService.findUserInfoById(userId).getRoles();
        List<String> roleNames = new ArrayList<String>();
        for (Role role : roles){
            roleNames.add(role.getRoleName());
        }
        return roleNames;
    }

    /**
     * 跳转到修改头像页面
     * @param mMap
     * @return
     */
    @GetMapping("/avatar")
    public String avatar(ModelMap mMap){
        Session session = ShiroUtils.getMySession();
        mMap.put("info", session.getAttribute("info"));
        return prefix + "/avatar";
    }

    /**
     * 保存图像
     * @param file 保存图像路径
     * @return
     */
    @PostMapping("/profile/updateAvatar")
    @ResponseBody
    public AjaxResult updateAvatar(@RequestParam("avatarFile") MultipartFile file){
        Session session = ShiroUtils.getMySession();
        Volunteer currentVolunteer = (Volunteer) session.getAttribute("info");
        try {
            if (!file.isEmpty()){
                String avatar = FileUploadUtils.upload(Global.getAvatarPath(), file);
                currentVolunteer.setAvatar(avatar);
                if (volunteerService.updateVolunteer(currentVolunteer) > 0){
                    session.setAttribute("info", volunteerService.findVolunteerById(currentVolunteer.getVolId()));
                    return success();
                }
            }
            return error();
        } catch (Exception e){
            log.error("修改头像失败!", e);
            return error(e.getMessage());
        }
    }

    /**
     * 获取志愿者信息方法
     * @param mMap
     */
    public void getVolInfoMethod(ModelMap mMap){
        Session session = ShiroUtils.getMySession();
        Volunteer volunteer = (Volunteer) session.getAttribute("info");
        // 根据志愿者ID查询志愿者的正常参加的活动记录
        activityRecordService.findActivityRecordByVol(volunteer);
        // 获取志愿者相关信息的方法
        getInfoMethod(mMap);
        mMap.put("info", volunteer);
        mMap.put("roleGroup", session.getAttribute("role"));
    }

    /**
     * 志愿者信息页面(后台)
     * @param mMap
     * @return
     */
    @RequiresRoles("volunteer")
    @GetMapping("/volInfo")
    public String volunteerInfo(ModelMap mMap){
        // 获取志愿者信息方法
        getVolInfoMethod(mMap);
        return prefix + "/info";
    }

    /**
     * 志愿者信息页面(前台)
     * @param mMap
     * @return
     */
    @RequiresRoles("volunteer")
    @GetMapping("/volInfoFront")
    public String volunteerInfoFront(ModelMap mMap){
        Session session = ShiroUtils.getMySession();
        Volunteer volunteer = (Volunteer) session.getAttribute("info");
        // 根据志愿者ID查询志愿者的正常参加的活动记录
        activityRecordService.findActivityRecordByVol(volunteer);
        // 获取志愿者相关信息的方法
        getInfoMethod(mMap);
        mMap.put("info", volunteer);
        mMap.put("roleGroup", session.getAttribute("role"));
        // 获取志愿者是否还有待审核的申请
        mMap.put("appFlag", volunteerApplyService.findApplicationFlag(volunteer.getVolId()));
        // 如果该志愿者已存在归属组织才执行
        if (StrUtils.isNotNull(volunteer.getDeptId())){
            // 查找出归属组织信息
            Dept dept = deptService.findDeptById(volunteer.getDeptId());
            mMap.put("dept", dept);
        }
        return  prefixFront + "/volunteer/volInfo";
    }

    /**
     * 志愿者管理的主页面(系统管理员)
     * @return
     */
    @RequiresPermissions("sys:volunteer:view")
    @GetMapping("/volunteerList")
    public String volunteerList(ModelMap mMap){
        // 获取志愿者相关信息的方法
        getInfoMethod(mMap);
        return prefix + "/volunteer";
    }
    @RequiresPermissions("sys:volunteer:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(Volunteer volunteer){
        startPage();
        List<Volunteer> volunteerList = volunteerService.findVolunteerList(volunteer);
        return getDataTable(volunteerList);
    }

    /**
     * 志愿者管理的主页面(组织管理者)
     * @param mMap
     * @return
     */
//    @RequiresPermissions("sys:volunteer:view")
    @GetMapping("/deptVolList")
    public String deptVolList(ModelMap mMap){
        // 获取志愿者相关信息的方法
        getInfoMethod(mMap);
        // 该组织信息
        mMap.put("info", ShiroUtils.getMySession().getAttribute("info"));
        return prefix + "/deptVol/deptVolunteer";
    }
//    @RequiresPermissions("sys:volunteer:list")
    @PostMapping("/volList")
    @ResponseBody
    public TableDataInfo volList(Volunteer volunteer){
        startPage();
        List<Volunteer> volunteerList = volunteerService.findVolunteerListOnly(volunteer);
        return getDataTable(volunteerList);
    }

    /**
     * 查看某个志愿者的信息(管理员,组织管理者)
     * @param volId 志愿者ID
     * @param mMap
     * @return
     */
    @GetMapping("/view/{volId}")
    public String volunteerView(@PathVariable("volId") Integer volId, ModelMap mMap){
        Volunteer volunteer = volunteerService.findVolunteerById(volId);
        if (StrUtils.isNull(volunteer.getDept())){
            volunteer.setDeptName("暂无归属组织");
        }
        // 根据志愿者ID查询志愿者的正常参加的活动记录
        activityRecordService.findActivityRecordByVol(volunteer);
        // 获取该用户角色名称
        mMap.put("roleGroup", roleNames(volunteer.getUserId()));
//        // 获取志愿者相关信息的方法
//        getInfoMethod(mMap);
        mMap.put("volunteer", volunteer);
        return prefix + "/view";
    }

    /**
     * 查看某个志愿者的信息(志愿者前台)
     * 志愿者查看其组织的志愿者基本信息
     * @param volId 志愿者ID
     * @param mMap
     * @return
     */
    @GetMapping("/viewFront/{volId}")
    public String volunteerViewFront(@PathVariable("volId") Integer volId, ModelMap mMap){
        Volunteer volunteer = volunteerService.findVolunteerById(volId);
        // 根据志愿者ID查询志愿者的正常参加的活动记录
        activityRecordService.findActivityRecordByVol(volunteer);
        mMap.put("volunteer", volunteer);
        return prefixFront + "/volunteer/volForntView";
    }

    /**
     * 志愿者注册(游客)
     * @param mMap
     * @return
     */
    @GetMapping("/volunteerReg")
    public String volunteerReg(ModelMap mMap){
        // 获取志愿者相关信息的方法
        getInfoMethod(mMap);
        return prefix + "/toReg";
    }

    /**
     * 志愿者注册
     * @param volunteer 志愿者信息
     * @return
     */
    @PostMapping("/regInfo")
    @ResponseBody
    public AjaxResult regVolunteer(@Validated Volunteer volunteer,
                                   @Validated User user){
        // 生成用户随机盐
        String salt = ShiroUtils.randomSalt();
        user.setSalt(salt);
        // 用户密码加密
        user.setUserPassword(PassSetUtils.passSet(user.getUserPassword(),salt));
        // 用户信息放入志愿者表
        volunteer.setUser(user);
        System.out.println("..获取:"+volunteer);
        System.out.println("..获取:"+user);
        // 获取归属组织ID
        int deptId = volunteer.getDeptId();
        // 返回的是注册成功以后的志愿者ID
        int result = volunteerService.regVolunteer(volunteer);
        try {
            if (result > 0){
                // 如果注册成功就生成一条申请志愿者归属记录
                VolunteerApply volunteerApply = new VolunteerApply();
                volunteerApply.setVolId(result);
                volunteerApply.setDeptId(deptId);
                volunteerApply.setApplyRemark(volunteer.getName() + "注册归属申请");
                System.out.println("获取申请: " + volunteerApply);
                int volAppResult = volunteerApplyService.addVolunteerApply(volunteerApply);
                if (volAppResult > 0){
                    return success("志愿者 '"+volunteer.getName()+"' 注册成功,等待归属组织审核");
                }
                return error("志愿者归属申请失败...");
            }
        } catch (Exception e){
            e.printStackTrace();
            return error(e.getMessage());
        }
        return error("系统错误...");
    }

    /**
     * 修改志愿者信息(组织管理者)
     * @param volunteer 志愿者信息
     * @return
     */
    @PostMapping("/editInfo")
    @ResponseBody
    public AjaxResult volUpdate(@Validated Volunteer volunteer){
        System.out.println("..获取:"+volunteer);
        User user = ShiroUtils.getUser();
        user.setUserLogname(volunteer.getUser().getUserLogname());
        user.setRemark(volunteer.getUser().getRemark());
        volunteer.setUser(user);
        Session session = ShiroUtils.getMySession();
        if (volunteerService.updateVolunteer(volunteer) > 0){
            // 更新用户信息
            ShiroUtils.setUser(userService.findUserById(volunteer.getUserId()));
            // 更新志愿者信息
            session.setAttribute("info", volunteerService.findVolunteerById(volunteer.getVolId()));
            return success();
        }
        return error();
    }

    /**
     * 志愿者状态修改
     * @param user 志愿者用户信息
     * @return
     */
    @RequiresPermissions("sys:volunteer:edit")
    @PostMapping("/changeStatus")
    @ResponseBody
    public AjaxResult changStatus(User user){
        System.out.println("..获取:"+user);
        try {
            int result = userService.changeStatus(user);
            if (result > 0){
                return success();
            }
            return error();
        } catch (BusinessException e) {
            return error(e.getMessage());
        }
    }

    /**
     * 加载志愿者下拉选择框信息
     * 通知发送
     * @param volunteer 志愿者信息
     * @return
     */
    @PostMapping("/findVolunteerByDeptId")
    @ResponseBody
    public List<Volunteer> findVolunteerByDeptId(Volunteer volunteer){
        List<Volunteer> volunteers = volunteerService.findVolunteerListOnly(volunteer);
        return volunteers;
    }

    /**
     * 志愿者状态修改页面(组织管理者)
     * 用于志愿者的管理
     * @param volId 志愿者ID
     * @param mMap
     * @return
     */
    @GetMapping("/volunteerStatusChange/{volId}")
    public String volStatusEdit(@PathVariable("volId") Integer volId, ModelMap mMap){
        // 获取志愿者信息
        Volunteer volunteer = volunteerService.findVolunteerById(volId);
        volunteer.getUser().setStatus((volunteer.getUser().getStatus().equals("0")) ? "1" : "0");
//        // 获取归属织信息
//        Session session = ShiroUtils.getMySession();
//        Dept deptInfo = (Dept) session.getAttribute("info");
        mMap.put("info", volunteer);
        return prefix + "/deptVol/statusChanger";
    }

    /**
     * 志愿者状态修改(组织管理者)
     * 修改成功后还需要发送信息(邮箱、手机)
     * @param volunteer 志愿者信息
     * @param sendName 发送人
     * @param statusRemark 内容
     * @return
     */
    @RequiresPermissions("sys:volunteer:edit")
    @PostMapping("/volunteerStatusChange")
    @ResponseBody
    public AjaxResult editVolStatus(@Validated Volunteer volunteer,
                                    @Validated User user,
                                    @RequestParam("sendName") String sendName,
                                    @RequestParam("statusRemark") String statusRemark){
        System.out.println("..获取:"+volunteer);
        System.out.println("..获取:"+user);
        System.out.println("..获取:"+sendName);
        System.out.println("..获取:"+statusRemark);
        try {
            int result = userService.changeStatus(user);
            if (result > 0){
                // 发送手机短信提醒
                String statusTip;
                if(user.getStatus().equals("0")){// 启用志愿者
                    statusTip = "已被启用";
                } else {// 停用志愿者
                    statusTip = "已被停用";
                }
                String info = "您因" + statusRemark + ",为此,您的账号'" + statusTip +"',如有疑问请联系组织管理者,谢谢。";
                // 手机号,发送人,接收人,发送内容
                String sendResult = sendSMS(volunteer.getVolPhone(), sendName, volunteer.getName(), info);
                if (sendResult.equals("0")){
                    return success("操作成功,将操作结果发送给志愿者...");
                }
                return success("操作成功,但短信发送失败,请另行通知该志愿者...");
            }
        } catch (Exception e) {
            return error(e.getMessage());
        }
        return error();
    }

    /**
     * 志愿者移除页面跳转(组织管理者)
     * @param volId 志愿者ID
     * @param mMap
     * @return
     */
    @GetMapping("/deleteVolDept/{volId}")
    public String deleteVolDept(@PathVariable("volId") Integer volId, ModelMap mMap){
        // 获取志愿者信息
        Volunteer volunteer = volunteerService.findVolunteerById(volId);
        mMap.put("info", volunteer);
        return prefix + "/deptVol/deleteVolDept";
    }

    /**
     * 移除志愿者(组织管理者)
     * @param volunteer 志愿者信息
     * @param sendName 发送者
     * @param deleteRemark 删除原因
     * @return
     */
    @RequiresPermissions("sys:volunteer:edit")
    @PostMapping("/deleteVolDept")
    @ResponseBody
    public AjaxResult deleteVolDept(@Validated Volunteer volunteer,
                                    @Validated User user,
                                    @RequestParam(required = false, value = "sendName") String sendName,
                                    @RequestParam(required = false, value = "deleteRemark") String deleteRemark){
        System.out.println("..获取:"+volunteer);
        System.out.println("..获取:"+user);
        System.out.println("..获取:"+sendName);
        System.out.println("..获取:"+deleteRemark);
        try {
            int result = 0;
            // 如果该志愿者处于“停用”状态,先将其恢复“正常”状态,再删除
            if (StrUtils.isNotNull(user) && !user.getStatus().equals("0")){
                user.setStatus("0");
                result = userService.changeStatus(user);
                if (result <= 0) {
                    return error();
                }
            }
            result = volunteerService.deleteVolDept(volunteer.getVolId());
            if (result > 0){
                // 发送手机短信提醒
                String info = "您因" + deleteRemark + ",为此,您已被踢除出'" + volunteer.getDeptName() +"',如有疑问请联系组织管理者,谢谢。";
                // 手机号,发送人,接收人,发送内容
                String sendResult = sendSMS(volunteer.getVolPhone(), sendName, volunteer.getName(), info);
                if (sendResult.equals("0")){
                    return success("操作成功,将操作结果发送给志愿者...");
                }
                return success("操作成功,但短信发送失败,请另行通知该志愿者...");
            }
        } catch (Exception e) {
            return error(e.getMessage());
        }
        return error();
    }

    /**
     * 导出志愿者信息
     * @param volunteer
     * @return
     */
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(Volunteer volunteer){
        System.out.println("导出条件: " + volunteer);
        List<Volunteer> list = volunteerService.findVolunteerList(volunteer);
        ExcelUtils<Volunteer> volUtil = new ExcelUtils<Volunteer>(Volunteer.class);
        String exportName = "所有"; // 默认
        if (StrUtils.isNotNull(volunteer.getDeptId())){
            Dept dept = deptService.findDeptById(volunteer.getDeptId());
            exportName = dept.getDeptName();
        }
        return volUtil.exportExcel(list, exportName + "志愿者信息");
    }

    /**
     * 校验志愿者手机
     * @param volunteer 志愿者信息
     * @return
     */
    @PostMapping("/checkPhoneUnique")
    @ResponseBody
    public String checkPhoneUnique(Volunteer volunteer){
        return volunteerService.checkPhoneUnique(volunteer);
    }

    /**
     * 校验用户账号唯一性
     * @param user 用户信息
     * @return
     */
    @PostMapping("/checkLoginNameUnique")
    @ResponseBody
    public String checkLoginNameUnique(User user){
        return userService.checkLoginNameUnique(user);
    }

    /**
     * 短信发送方法
     * @param telPhone 接收方手机号
     * @param sendName 接收人
     * @param receiveName 发送人
     * @param message 内容
     * @return
     */
    private String sendSMS(String telPhone,
                           String sendName, String receiveName,
                           String message){
        return PhoneSmsUtils.smsPhone(telPhone, sendName, receiveName, message);
    }

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

程序猿毕业分享网

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值