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

  

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

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

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

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

【505】基于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.core.pojo.ZTree;
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.io.IOException;
import java.util.List;

/**
 * 组织信息管理 控制层
 * Create By  on /12/18
 */
@Controller
@RequestMapping("/dept")
public class DeptController extends BaseController {

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

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

    //自动注入
    @Autowired
    private DeptService deptService;

    @Autowired
    private DeptCategoryService deptCategoryService;

    @Autowired
    private UserService userService;

    @Autowired
    private DeptServiceObjectService deptServiceObjectService;

    @Autowired
    private DeptApplicationService deptApplicationService;

    /**
     * 根据当前访问角色获取组织信息
     * @return
     */
    private Dept getDeptInfoByUserRole(){
        Dept dept = null;
        // 获取当前点击的角色
        Session session = ShiroUtils.getMySession();
        List<Role> roles = this.userService.findUserInfoById(ShiroUtils.getUserId()).getRoles();
        for (Role role : roles){
            if (role.getRoleKey().equals("manager")){
                // 组织管理者直接获取
                dept = (Dept) session.getAttribute("info");
            } else if (role.getRoleKey().equals("operators")){
                // 组织运营者需要查本组织信息
                Volunteer volunteer = (Volunteer) session.getAttribute("info");
                dept = deptService.findDeptById(volunteer.getDeptId());
            }
        }
        return dept;
    }

    /**
     * 组织管理的主页面(系统管理员界面)
     * @return
     */
    @RequiresPermissions("sys:dept:view")
    @GetMapping("/deptList")
    public String dept(ModelMap mMap){
        List<DeptCategory> deptCategories = deptCategoryService.findDeptCgAll();
        mMap.put("deptCategory", deptCategories);
        return prefix + "/dept";
    }
    @RequiresPermissions("sys:dept:list")
    @PostMapping("/list")
    @ResponseBody
    public List<Dept> list(Dept dept){
        List<Dept> deptList = deptService.findDeptList(dept);
        return deptList;
    }

    /**
     * 组织列表及关系展示(志愿者前台)
     * @return
     */
    @PostMapping("/frontList") // 列表展示
    @ResponseBody
    public TableDataInfo frontList(Dept dept){
        startPage();
        List<Dept> deptList = deptService.findDeptList(dept);
        return getDataTable(deptList);
    }
    @PostMapping("/frontTreeList") // 树型关系展示
    @ResponseBody
    public List<Dept> frontTreeList(Dept dept){
        List<Dept> deptList = deptService.findDeptList(dept);
        return deptList;
    }


    /**
     * 子组织管理的组页面(组织管理者)
     * @param mMap
     * @return
     */
//    @RequiresPermissions("sys:dept:view")
    @GetMapping("/deptChildList")
    public String deptChild(ModelMap mMap){
        // 根据当前访问角色获取组织信息
        Dept deptParent = getDeptInfoByUserRole();
        List<DeptCategory> deptCategories = deptCategoryService.findDeptCgAll();
        mMap.put("deptCategory", deptCategories);
        mMap.put("dept", deptParent);
        return prefix + "/child/deptChild";
    }
//    @RequiresPermissions("sys:dept:list")
    @PostMapping("/childList")
    @ResponseBody
    public TableDataInfo childList(Dept dept){
        startPage();
        List<Dept> deptList = deptService.findDeptList(dept);
        return getDataTable(deptList);
    }


    /**
     * 组织信息页面
     * @param mMap
     * @return
     */
    @RequiresPermissions("sys:dept:info")
    // 具备 “组织管理者” 或 “组织运营者” 的角色才能访问
    @RequiresRoles(value = {"manager","operators"},logical = Logical.OR)
    @GetMapping("/deptInfo")
    public String deptInfo(ModelMap mMap){
        // 根据当前访问角色获取组织信息
        Dept dept = getDeptInfoByUserRole();
        mMap.put("info", dept);
        List<DeptCategory> deptCategories = deptCategoryService.findDeptCgAll();
        mMap.put("deptCategory", deptCategories);
        List<DeptServiceObject> deptServiceObjects = deptServiceObjectService.findDeptServiceObjectsByDeptId(dept.getDeptId());
        mMap.put("deptServiceObjects", deptServiceObjects);
        return prefix + "/info";
    }

    /**
     * 查看某个组织的信息
     * @param deptId 组织ID
     * @param mMap
     * @return
     */
    @GetMapping("/view/{deptId}")
    public String deptView(@PathVariable("deptId") Integer deptId, ModelMap mMap){
        Dept dept = deptService.findDeptById(deptId);
//        if (StrUtils.isNotNull(dept) && deptId == 1){
//            dept.setParentName("无");
//        } if (StrUtils.isNull(dept.getParentId())){
//            dept.setParentName("暂无");
//        } if (StrUtils.isNull(dept.getDeptCategory())){
//            dept.setDeptCgname("暂无类别");
//        }
        List<DeptServiceObject> deptServiceObjects = deptServiceObjectService.findDeptServiceObjectsByDeptId(dept.getDeptId());
        mMap.put("deptServiceObjects", deptServiceObjects);
        mMap.put("dept", dept);
        return prefix + "/view";
    }

    /**
     * 查看某个审核组织的信息(组织申请时查看)
     * @param deptId
     * @param mMap
     * @return
     */
    @GetMapping("/baseView/{deptId}")
    public String deptBaseView(@PathVariable("deptId") Integer deptId, ModelMap mMap){
        Dept dept = deptService.findDeptById(deptId);
//        if (StrUtils.isNotNull(dept) && deptId == 1){
//            dept.setParentName("无");
//        } if (StrUtils.isNull(dept.getParentId())){
//            dept.setParentName("暂无");
//        } if (StrUtils.isNull(dept.getDeptCategory())){
//            dept.setDeptCgname("暂无类别");
//        }
        List<DeptServiceObject> deptServiceObjects = deptServiceObjectService.findDeptServiceObjectsByDeptId(dept.getDeptId());
        mMap.put("deptServiceObjects", deptServiceObjects);
        mMap.put("dept", dept);
        return prefix + "/viewAudit";
    }

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

    /**
     * 保存LOGO
     * @param file LOGO路径
     * @return
     */
    @PostMapping("/profile/updateAvatar")
    @ResponseBody
    public AjaxResult updateAvatar(@RequestParam("avatarFile") MultipartFile file){
        Session session = ShiroUtils.getMySession();
        Dept currentDept = (Dept) session.getAttribute("info");
        try {
            if (!file.isEmpty()){
                String avatar = FileUploadUtils.upload(Global.getAvatarPath(), file);
                currentDept.setAvatar(avatar);
                if (deptService.updateDept(currentDept) > 0){
                    session.setAttribute("info",deptService.findDeptById(currentDept.getDeptId()));
                    return success();
                }
            }
            return error();
        } catch (Exception e){
            log.error("修改LOGO失败!", e);
            return error(e.getMessage());
        }
    }

    /**
     * 组织添加页面跳转(管理员)
     * @param mMap
     * @return
     */
    @GetMapping("/add/{parentId}")
    public String deptAdd(@PathVariable("parentId") Integer parentId, ModelMap mMap){
        List<DeptCategory> deptCategories = deptCategoryService.findDeptCgAll();
        List<DeptServiceObject> deptServiceObjects = deptServiceObjectService.findDeptServiceObjectAll();
        Dept dept = deptService.findDeptById(parentId);
        mMap.put("deptCategory", deptCategories);
        mMap.put("deptServiceObjects", deptServiceObjects);
        mMap.put("dept", dept);
        return prefix + "/add";
    }

    /**
     * 组织添加页面跳转初始(管理员)
     * @param mMap
     * @return
     */
    @GetMapping("/add")
    public String deptAdds(ModelMap mMap){
        List<DeptCategory> deptCategories = deptCategoryService.findDeptCgAll();
        List<DeptServiceObject> deptServiceObjects = deptServiceObjectService.findDeptServiceObjectAll();
        Dept dept = deptService.findDeptById(1);
        mMap.put("deptCategory", deptCategories);
        mMap.put("deptServiceObjects", deptServiceObjects);
        mMap.put("dept", dept);
        return prefix + "/add";
    }

    /**
     * 组织添加(管理员)
     * @param dept 组织信息
     * @return
     */
    @RequiresPermissions("sys:dept:add")
    @PostMapping("/addSave")
    @ResponseBody
    public AjaxResult deptAdd(@Validated Dept dept,
                              @Validated DeptManager deptManager, @Validated User user,
                              @RequestParam("userPassword") String userPassword){
        // 生成用户随机盐
        String salt = ShiroUtils.randomSalt();
        user.setSalt(salt);
        // 用户密码加密
        user.setUserPassword(PassSetUtils.passSet(userPassword,salt));
        System.out.println("获取:"+dept);
        System.out.println("获取:"+deptManager);
        System.out.println("获取:"+user);
        // 用户信息放入组织表
        dept.setUser(user);
        // 组织管理者信息放入组织表
        dept.setDeptManager(deptManager);
        // 系统管理员添加的组织默认申请状态为“1.已通过”
        dept.setApplicationStatus("1");
        // 组织新增标志为“0.增加”
        return toAjax(deptService.addDept(dept,"0"));
    }

    /**
     * 组织获取文件路径方法
     * @param dept 组织信息
     * @param idFile 组织管理者身份证文件图片
     * @param recFile 组织备案文件图片
     */
    public void deptFilePathMethod(Dept dept, DeptManager deptManager, MultipartFile idFile, MultipartFile recFile) throws IOException {
        // 如果有上传身份证照片
        if (StrUtils.isNotNull(idFile) && !idFile.isEmpty()){
            // 注意存储路径(身份证路径)
            String deptMidphoto = FileUploadUtils.upload(Global.getIdCardAvatarPath(), idFile);
            deptManager.setDeptMidphoto(deptMidphoto);
        }
        // 如果有上传备案证书登记
        if (StrUtils.isNotNull(recFile) && !recFile.isEmpty()){
            // 注意存储路径(备案扫件路径)
            String deptRecordphoto = FileUploadUtils.upload(Global.getRecordPath(), recFile);
            dept.setDeptRecordphoto(deptRecordphoto);
        }
    }

    /**
     * 组织注册(游客)
     * @param mMap
     * @return
     */
    @GetMapping("/deptReg")
    public String deptReg(ModelMap mMap){
        List<DeptCategory> deptCategories = deptCategoryService.findDeptCgAll();
        List<DeptServiceObject> deptServiceObjects = deptServiceObjectService.findDeptServiceObjectAll();
//        Dept parentDept = deptService.findDeptById(1);
        mMap.put("deptCategory", deptCategories);
        mMap.put("deptServiceObjects", deptServiceObjects);
//        mMap.put("parentDept", parentDept);
        return prefix + "/toReg";
    }

    /**
     * 组织注册
     * @param dept 组织信息
     * @param deptManager 组织管理者信息
     * @param user 用户信息
     * @param idFile 组织管理者身份证文件图片
     * @param recFile 组织备案文件图片
     * @return
     */
    @PostMapping("/regInfo")
    @ResponseBody
    public AjaxResult regDept(@Validated Dept dept,
                              @Validated DeptManager deptManager,
                              @Validated User user,
                              @RequestParam(required = false, value = "deptMidphotoFile") MultipartFile idFile,
                              @RequestParam(required = false, value = "deptRecordphotoFile") MultipartFile recFile){
        // 生成用户随机盐
        String salt = ShiroUtils.randomSalt();
        user.setSalt(salt);
        // 用户密码加密
        user.setUserPassword(PassSetUtils.passSet(user.getUserPassword(),salt));

        System.out.println("..获取:"+dept);
        System.out.println("..获取:"+deptManager);
        System.out.println("..获取:"+user);
        System.out.println("..获取:"+idFile);
        System.out.println("..获取:"+recFile);
        try {
            // 组织获取文件路径方法
            deptFilePathMethod(dept, deptManager, idFile, recFile);
            // 用户信息放入组织表
            dept.setUser(user);
            // 组织管理者信息放入组织表
            dept.setDeptManager(deptManager);
            // 组织默认申请状态为“0.待通过”
            dept.setApplicationStatus("0");
            // 获取组织父ID
            int parentId = dept.getParentId();
            // 组织新增标志为“0.注册”,返回的是注册成功以后的组织ID
            int result = deptService.addDept(dept,"1");
            if (result > 0){
                // 如果注册成功就生成一条申请组织归属记录
                DeptApplication deptApplication = new DeptApplication();
                deptApplication.setDeptId(result);// 组织
                deptApplication.setParentId(parentId);// 归属组织
                deptApplication.setRemark(dept.getDeptName() + "注册归属申请");
                System.out.println("获取申请: " + deptApplication);
                int deptAppResult = deptApplicationService.addDeptApplication(deptApplication);
                if (deptAppResult > 0){
                    return success("组织 '"+dept.getDeptName()+"' 注册成功,等待归属组织审核");
                }
                return error("组织归属申请失败...");
            }
        } catch (Exception e){
            return error(e.getMessage());
        }
        return error("系统错误...");
    }

    /**
     * 组织修改页面跳转
     * @param deptId 组织ID
     * @param mMap
     * @return
     */
    @GetMapping("/edit/{deptId}")
    public String deptEdit(@PathVariable("deptId") Integer deptId, ModelMap mMap){
        Dept dept = deptService.findDeptById(deptId);
        List<DeptCategory> deptCategories = deptCategoryService.findDeptCgAll();
        List<DeptServiceObject> deptServiceObjects = deptServiceObjectService.findDeptServiceObjectsByDeptId(dept.getDeptId());
        if (StrUtils.isNotNull(dept) && deptId == 1){
            dept.setParentName("无");
        }
        mMap.put("dept", dept);
        mMap.put("deptCategory", deptCategories);
        mMap.put("deptServiceObjects", deptServiceObjects);
        return prefix + "/edit";
    }

    /**
     * 修改组织信息(管理员)
     * @param dept 组织信息
     * @return
     */
    @RequiresPermissions("sys:dept:edit")
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult deptEdit(@Validated Dept dept){
        // 判断组织规范方法
        if ("1".equals(deptService.checkDeptNameUnique(dept))){
            return error("组织名称'" + dept.getDeptName() + "'已存在,修改失败");
        }
        if (StrUtils.isNotNull(dept.getParentId()) && dept.getParentId().equals(dept.getDeptId())){
            return error("上级部门不能是'" + dept.getDeptName() + "'(自己),修改失败");
        }
        return toAjax(deptService.updateDept(dept));
    }

    /**
     * 组织信息修改方法(组织管理者)
     * @param dept 组织信息
     * @return
     */
    private AjaxResult deptUpdateMethod(Dept dept){
        Session session = ShiroUtils.getMySession();
        // 判断组织规范方法
        if ("1".equals(deptService.checkDeptNameUnique(dept))){
            return error("组织名称'" + dept.getDeptName() + "'已存在,修改失败");
        } if (StrUtils.isNotNull(dept.getParentId()) && dept.getParentId().equals(dept.getDeptId())){
            return error("上级部门不能是'" + dept.getDeptName() + "'(自己),修改失败");
        }
        if (deptService.updateDept(dept) > 0){
            //更新用户信息
            ShiroUtils.setUser(userService.findUserById(dept.getUser().getUserId()));
            //更新组织信息
            session.setAttribute("info",deptService.findDeptById(dept.getDeptId()));
            return success();
        }
        return error();
    }

    /**
     * 修改组织信息(组织管理者)
     * @param dept 组织信息
     * @return
     */
    @RequiresPermissions("sys:dept:edit")
    @PostMapping("/editInfo")
    @ResponseBody
    public AjaxResult deptUpdate(@Validated Dept dept,
                                 @Validated DeptManager deptManager,
                                 @Validated User user,
                                 @RequestParam(required = false, value = "deptMidphotoFile") MultipartFile idFile,
                                 @RequestParam(required = false, value = "deptRecordphotoFile") MultipartFile recFile){
        System.out.println("..获取:"+dept);
        System.out.println("..获取:"+deptManager);
        System.out.println("..获取:"+user);
        System.out.println("..获取:"+idFile);
        System.out.println("..获取:"+recFile);
//        Session session = ShiroUtils.getMySession();
        try {
            // 组织获取文件路径方法
            deptFilePathMethod(dept, deptManager, idFile, recFile);

            User newUser = ShiroUtils.getUser();
            if (StrUtils.isNotNull(user)){
                newUser.setUserLogname(user.getUserLogname());
                newUser.setRemark(user.getRemark());
            }
            dept.setUser(newUser);
            dept.setDeptManager(deptManager);
            // 组织信息修改方法
            return deptUpdateMethod(dept);
        } catch (Exception e){
            return error(e.getMessage());
        }
    }

    /**
     * 组织状态修改页面(组织管理者)
     * 用于子组织的管理
     * @param deptId 组织ID
     * @return
     */
    @GetMapping("/deptStatusChange/{deptId}")
    public String deptStatusEdit(@PathVariable("deptId") Integer deptId, ModelMap mMap){
        // 获取组织信息
        Dept deptInfo = deptService.findDeptById(deptId);
        deptInfo.getUser().setStatus((deptInfo.getUser().getStatus().equals("0")) ? "1" : "0");
        // 获取父组织信息
        Dept parentInfo = getDeptInfoByUserRole();
        mMap.put("dept", deptInfo);
        mMap.put("parent", parentInfo);
        return prefix + "/child/statusChanger";
    }

    /**
     * 组织状态修改(组织管理者)
     * 修改成功后还需要发送信息(邮箱)
     * @param dept 组织信息
     * @param statusRemark 原因
     * @return
     */
    @RequiresPermissions("sys:dept:edit")
    @PostMapping("/deptStatusChange")
    @ResponseBody
    public AjaxResult editDeptStatus(@Validated Dept dept,
                                     @Validated DeptManager deptManager,
                                     @Validated User user,
                                     @RequestParam(required = false, value = "sendName") String sendName,
                                     @RequestParam(required = false, value = "statusRemark") String statusRemark){
        System.out.println("..获取:"+dept);
        System.out.println("..获取:"+deptManager);
        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 + ",为此,您的'"+ dept.getDeptName() +"'组织账号'" + statusTip +"',如有疑问请联系组织管理者,谢谢。";
                // 手机号,发送人,接收人,发送内容
                String sendResult = sendSMS(deptManager.getDeptMphone(), sendName, deptManager.getName(), info);
                if (sendResult.equals("0")){
                    return success("操作成功,将操作结果发送给组织管理者...");
                }
                return success("操作成功,但短信发送失败,请另行通知该组织管理者...");
            }
        } catch (Exception e) {
            return error(e.getMessage());
        }
        return error();
    }

    /**
     * 子组织移除页面跳转(组织管理者)
     * @param deptId 组织ID
     * @return
     */
    @GetMapping("/deleteDeptParent/{deptId}")
    public String deleteDeptParent(@PathVariable("deptId") Integer deptId, ModelMap mMap){
        // 获取组织信息
        Dept deptInfo = deptService.findDeptById(deptId);
        // 获取父组织信息
        Dept parentInfo = getDeptInfoByUserRole();
        mMap.put("dept", deptInfo);
        mMap.put("parent", parentInfo);
        return prefix + "/child/deleteDeptChild";
    }

    /**
     * 移除子组织(组织管理者)
     * 移除成功后还需要发送信息(邮箱)
     * @param dept 组织信息
     * @param deleteRemark 原因
     * @return
     */
    @RequiresPermissions("sys:dept:edit")
    @PostMapping("/deleteDeptParent")
    @ResponseBody
    public AjaxResult deptParentDelete(@Validated Dept dept,
                                       @Validated DeptManager deptManager,
                                       @Validated User user,
                                       @RequestParam(required = false, value = "sendName") String sendName,
                                       @RequestParam(required = false, value = "deleteRemark") String deleteRemark){
        System.out.println("..获取:"+dept);
        System.out.println("..获取:"+user);
        System.out.println("..获取:"+deptManager);
        System.out.println("..获取:"+sendName);
        System.out.println("..获取:"+deleteRemark);
        try {
            int result = 0;
            // 如果该组织处于“停用”状态,先将其恢复“正常”状态,再删除
            if (StrUtils.isNotNull(user.getStatus()) && !user.getStatus().equals("0")){
                user.setStatus("0");
                result = userService.changeStatus(user);
                if (result <= 0) {
                    return error();
                }
            }
            if (deptService.findDeptCount(dept.getDeptId()) > 0){
                return AjaxResult.warn("该组织存在下级组织, 暂不能移除");
            } else {
                result = deptService.deleteDeptChild(dept.getDeptId());
                if (result > 0){
                    // 发送手机短信提醒
                    String info = "您的组织'"+ dept.getDeptName() +"'因" + deleteRemark + ",为此,您的组织已被踢除出'" + dept.getParentName() +"',如有疑问请联系组织管理者,谢谢。";
                    // 手机号,发送人,接收人,发送内容
                    String sendResult = sendSMS(deptManager.getDeptMphone(), sendName, deptManager.getName(), info);
                    if (sendResult.equals("0")){
                        return success("操作成功,将操作结果发送给组织管理者...");
                    }
                    return success("操作成功,但短信发送失败,请另行通知该组织管理者...");
                }
            }
        } catch (Exception e) {
            return error(e.getMessage());
        }
        return error();
    }

//    /**
//     * 修改组织管理者身份证照片(组织管理者)
//     * @param idFile 组织管理者照片
//     * @param deptManager 组织管理者信息
//     * @param dept 组织信息
//     * @return
//     */
//    @RequiresPermissions("sys:dept:edit")
//    @PostMapping("/editManagerInfo")
//    @ResponseBody
//    public AjaxResult deptMPhotoUpdate(@RequestParam("deptMidphotoFile") MultipartFile idFile,
//                                        DeptManager deptManager, Dept dept){
//        try {
//            if (!idFile.isEmpty()){
//                // 注意路径
//                String deptMidphoto = FileUploadUtils.upload(Global.getIdCardAvatarPath(), idFile);
//                deptManager.setDeptMidphoto(deptMidphoto);
//                dept.setUser(ShiroUtils.getUser());
//                dept.setDeptManager(deptManager);
//                // 组织信息修改方法
//                return deptUpdateMethod(dept);
//            }
//        } catch (Exception e){
//            return error(e.getMessage());
//        }
//        return error();
//    }

//    /**
//     * 修改组织备案照片(组织管理者)
//     * @param recFile 组织备案图片
//     * @param deptManager 组织管理者信息
//     * @param dept 组织信息
//     * @return
//     */
//    @RequiresPermissions("sys:dept:edit")
//    @PostMapping("/editRecordInfo")
//    @ResponseBody
//    public AjaxResult deptRecPhotoUpdate(@RequestParam("deptRecordphotoFile") MultipartFile recFile,
//                                       DeptManager deptManager, Dept dept){
//        try {
//            if (!recFile.isEmpty()){
//                // 注意路径
//                String deptRecordphoto = FileUploadUtils.upload(Global.getRecordPath(), recFile);
//                dept.setDeptRecordphoto(deptRecordphoto);
//                dept.setUser(ShiroUtils.getUser());
//                dept.setDeptManager(deptManager);
//                // 组织信息修改方法
//                return deptUpdateMethod(dept);
//            }
//        } catch (Exception e){
//            return error(e.getMessage());
//        }
//        return error();
//    }

    /**
     * 删除组织
     * @param deptId 组织ID
     * @return
     */
    @RequiresPermissions("sys:dept:edit")
    @GetMapping("/delete/{deptId}")
    @ResponseBody
    public AjaxResult deleteDept(@PathVariable("deptId") Integer deptId){
        System.out.println("..获取ID: " + deptId);
        if (deptService.findDeptCount(deptId) > 0){
            return AjaxResult.warn("存在下级组织,不允许删除");
        } if (deptService.checkDeptExistVolunteer(deptId)){
            return AjaxResult.warn("组织存在志愿者,不允许删除");
        }
        return toAjax(deptService.deleteDeptById(deptId));
    }

    /**
     * 组织状态修改
     * @param user 组织用于信息
     * @return
     */
    @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 mMap
     * @return
     */
    @GetMapping("/viewInfo")
    public String deptViewInfo(ModelMap mMap){
        Session session = ShiroUtils.getMySession();
        // 获取组织信息
        Volunteer volunteer = (Volunteer) session.getAttribute("info");
        Dept dept = deptService.findDeptById(volunteer.getDeptId());
        // 获取组织服务对象信息
        List<DeptServiceObject> deptServiceObjects = deptServiceObjectService.findDeptServiceObjectsByDeptId(dept.getDeptId());
        mMap.put("info", volunteer);
        mMap.put("roleGroup", session.getAttribute("role"));
        mMap.put("dept", dept);
        mMap.put("deptServiceObjects", deptServiceObjects);
        // 跳转至前台页面
        return prefixFront + "/dept/deptInfo";
    }

    /**
     * 获取某个组织的信息(志愿者前台)
     * 从组织列表里获取
     * @param deptId 组织ID
     * @param mMap
     * @return
     */
    @GetMapping("/frontView/{deptId}")
    public String frontDeptViewInfo(@PathVariable("deptId") Integer deptId, ModelMap mMap){
        Dept dept = deptService.findDeptById(deptId);
        mMap.put("dept", dept);
        // 跳转至前台页面
        return prefixFront + "/dept/frontView";
    }

    /**
     * 选择组织树
     * @param deptId 组织ID
     * @param mMap
     * @return
     */
    @GetMapping("/findDeptTree/{deptId}")
    public String findDeptTree(@PathVariable("deptId") Integer deptId, ModelMap mMap){
        mMap.put("dept", deptService.findDeptById(deptId));
        return prefix + "/tree";
    }

    /**
     * 加载组织列表树
     * @return
     */
    @GetMapping("/treeData")
    @ResponseBody
    public List<ZTree> treeData(){
        List<ZTree> zTrees = deptService.findDeptTree(new Dept());
        return zTrees;
    }


    /**
     * 加载组织下拉选择框信息
     * @return
     */
    @GetMapping("/findDeptByMessage")
    @ResponseBody
    public List<Dept> findDeptListByMessage(){
        List<Dept> depts = deptService.findDeptList(new Dept());
        return depts;
    }

    /**
     * 导出组织信息
     * @param dept 组织信息
     * @return
     */
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(Dept dept){
        System.out.println("导出条件: " + dept);
        List<Dept> list = deptService.findDeptList(dept);
        ExcelUtils<Dept> deptUtil = new ExcelUtils<Dept>(Dept.class);
        String exportName = "所有"; // 默认
        if (StrUtils.isNotNull(dept.getParentId())){
            Dept deptInfo = deptService.findDeptById(dept.getParentId());
            exportName = deptInfo.getDeptName() + "的下属";
        }
        return deptUtil.exportExcel(list, exportName + "组织信息");
    }

    /**
     * 校验组织名称
     * @param dept 组织信息
     * @return
     */
    @PostMapping("/checkDeptNameUnique")
    @ResponseBody
    public String checkDeptNameUnique(Dept dept){
        return deptService.checkDeptNameUnique(dept);
    }

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

    /**
     * 校验组织电话
     * @param dept 组织信息
     * @return
     */
    @PostMapping("/checkDeptPhoneUnique")
    @ResponseBody
    public String checkDeptPhoneUnique(Dept dept){
        return deptService.checkDeptPhoneUnique(dept);
    }

    /**
     * 校验组织邮箱
     * @param dept 组织信息
     * @return
     */
    @PostMapping("/checkDeptEmailUnique")
    @ResponseBody
    public String checkDeptEmailUnique(Dept dept){
        return deptService.checkDeptEmailUnique(dept);
    }

    /**
     * 短信发送方法
     * @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);
    }

}

 

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

程序猿毕业分享网

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

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

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

打赏作者

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

抵扣说明:

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

余额充值