高校志愿者信息管理系统,其功能目标是实现将现有的高校志愿者信息管理系统模式向基于Internet的无纸张化志愿者信息管理模式的转变,所以它必须实现本身社团信息的管理,对参与志愿者社团活动的学生的管理。通过互联网联络协会成员的关键是要建立一个通畅的沟通平台,这样可以方便地实现会员与协会,会员与会员之间的沟通。
演示视频:
【java毕业设计】基于springboot志愿者管理平台
随着网络技术的飞速发展,现在很多国外的大学和社会其他部门都已经拥了百兆,甚至千兆的校内网络通信平台,通过计算机网络实现各种信息服务,并进行异地教育和培训。另一方面,现在的很多高校,为丰富学生的校园生活,培养学生的个性,促进特长学生的培养,学生会组织了很多社团。每个同学,根据参与自愿的原则,可以参加与自己兴趣相符的社团,但随着校园学生人数的增多,对社团及社团成员的管理,传统的方式显然不能胜任。[4]高校志愿者信息管理系统主要有两大部分:一是批准合法的志愿者申请加入社团,另一个是对具体志愿者信息管理系统本身的管理。其中很重要的一个环节就是具体社团管理,同时它也是本系统最难实现的环节。对于,一个具体的社团,学生可以自由的参加该社团组织的各种活动,如何对这类信息的管理是一个难点,另一方面,随着学生社团的增多,如何有效的对各个社团间信息的划分也是一个难点,这就需要对社团进行归类处理。显然,随着学生人数的不断增加及学生社团要求的不断提高,管理者的工作量将会越来越大,并且其工作将是一件十分烦琐和非常难以组织的事情,可以说传统的管理方式已经不能适应急剧扩大的学校规模需要。随着计算机应用的迅猛发展,网络应用不断扩大,如WWW服务、虚拟社区等等,且这些应用正逐步深入到千家万户。人们迫切要求利用这些技术来进行学生社团的组织和管理,以减轻管理者的工作负担及提高工作效率,与此同时也提高了校园的文化氛围,更加激发学生的学习兴趣。基于B/S模式的信息管理系统是现阶段研究开发的一个热点。它是建立在国际互联网上的应用系统,客户端的配置极为简单,使使用者不受地域的局限。一个完备的志愿者信息管理系统可以使学生在任一台接入校园网或Internet的计算机上,浏览志愿者社团信息,查看社团组织的各种活动,这将大大的激发学生的兴趣,使在校大学生能力、个性得以全面的培养。为了适应新形势的发展,本文进行了这一系统的初步设计工作,做了一个初步的探索,希望它能够在各类高校中发挥高效、便捷的作用,达到简化管理面向学生的目的。[4]2.2技术可行性分析目前,网络应用软件运行的模式主要有二类:Client/server模式,Browser/Web模式。前者的缺点是维护、升级较麻烦,后者是近几年伴随Internet迅速发展起来的一种技术,它与客户/服务器方式类似,客户端是一个标准的浏览器,服务器端是WebServer,而WebServer与数据库和应用服务器的紧密结合,使得这种模式的应用范围不断扩大,它已不仅仅用于网上查询,有很多部门的业务系统、企业的MIS系统纷纷采用这种模式,它的主要优点是便于扩充应用、升级维护简便。[5]Access功能强大,使用方便,是开发桌面数据库的最优秀的工具之一。Access本身具有强大的向导机制,能提供大量的数据库常用操作。如果能适当的加上少量代码,那么程序将是专业级的。这一切都靠VBA。
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 YuJiaYe on 2022/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);
}
}
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.text.Convert;
import com.yjy.zdemo._framework.shiro.utils.ShiroUtils;
import com.yjy.zdemo.pojo.Activity;
import com.yjy.zdemo.pojo.ActivityRegAudit;
import com.yjy.zdemo.pojo.ActivityType;
import com.yjy.zdemo.pojo.Volunteer;
import com.yjy.zdemo.service.*;
import com.yjy.zdemo.utils.PhoneSmsUtils;
import com.yjy.zdemo.utils.StrUtils;
import org.apache.shiro.authz.annotation.RequiresAuthentication;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.apache.shiro.session.Session;
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.List;
/**
* 活动报名管理 控制层
* Create By YuJiaYe on /2/16
*/
@Controller
@RequestMapping("/activityReg")
public class ActivityRegAuditController extends BaseController {
// 默认访问路径
private String prefix = "system/activity/reg";
// 自定义前台路径
private String prefixFront = "system/webFrontEnd";
// 自动注入
@Autowired
private ActivityRegAuditService activityRegAuditService;
@Autowired
private ActivityService activityService;
@Autowired
private ActivityTypeService activityTypeService;
@Autowired
private VolunteerService volunteerService;
@Autowired
private ActivityRecordService activityRecordService;
/**
* 可以报名的活动页面跳转(组织管理者、组织运营者)
* @param mMap
* @return
*/
@GetMapping("/activityRegList")
public String activityRegList(ModelMap mMap){
// 活动类型
List<ActivityType> activityTypes = activityTypeService.findActivityTypeAll();
// 主要用于获取组织ID信息
mMap.put("info", ShiroUtils.getMySession().getAttribute("info"));
mMap.put("activityTypes", activityTypes);
return prefix + "/regActivityAudit";
}
@PostMapping("/actRegList")
@ResponseBody
public TableDataInfo actRegList(Activity activity){
// 根据自及组织ID查询
startPage();
List<Activity> activityList = activityService.findActivityList(activity);
// 获取该活动相关报名人数以及录用人数方法
for (Activity info : activityList){
activityService.getCountForActivity(info);
}
return getDataTable(activityList);
}
/**
* 添加活动报名申请审核表
* @param activityRegAudit 申请审核信息
* @return
*/
@PostMapping("/addActivityReg")
@ResponseBody
private AjaxResult addActivityReg(@Validated ActivityRegAudit activityRegAudit,
@RequestParam(required = false,value = "actDeptId") String actDeptId,
@RequestParam(required = false,value = "volDeptId") String volDeptId,
@RequestParam(required = false,value = "activitySignlimit") String activitySignlimit,
@RequestParam(required = false,value = "volAge") String volAge,
@RequestParam(required = false,value = "activityAgelimit") String activityAgelimit,
@RequestParam(required = false,value = "volRegFlag") String volRegFlag,
@RequestParam(required = false,value = "exeStatus") String exeStatus){
System.out.println("活动状态: " + exeStatus);
System.out.println("报名状态: " + volRegFlag);
if (!exeStatus.equals("1")){
return error("非常抱歉,该活动报名时间已过.");
}
if (volDeptId.equals("1") || StrUtils.isNull(volDeptId)){
return error("非常抱歉,您还未有归属组织,暂不能参加活动哦.");
} else {
// 报名限制为只允许本组织志愿者报名
if (activitySignlimit.equals("1") && !actDeptId.equals(volDeptId)){
return error("非常抱歉,该活动仅限发布组织下的志愿者报名,感谢您的热心.");
}
}
if (activityAgelimit.equals("1") && Integer.parseInt(volAge) < 16){
return error("非常抱歉,该活动仅限16周岁及以上的志愿者报名,感谢您的热心.");
}
if (volRegFlag.equals("1")){
return error("您已提交过该活动申请了,请耐心等待审核哦.");
}
if (volRegFlag.equals("2")){
return error("您已成功报名该活动了,不能重复报名哦.");
}
// 如果判断都通过,则生成一则活动申请
int result = activityRegAuditService.addActivityRegAudit(activityRegAudit);
if (result > 0){
return success("报名成功!请等待发布组织审核录用.");
}
return error("系统错误.");
}
/**
* 志愿者查询自身的活动报名记录(志愿者前台)
* @param activityRegAudit 活动报名信息
* @return
*/
@PostMapping("/actReg/frontVolAuditList")
@ResponseBody
public TableDataInfo frontVolAuditList(ActivityRegAudit activityRegAudit){
startPage();
List<ActivityRegAudit> activityRegAudits = activityRegAuditService.findActivityRegAuditList(activityRegAudit);
return getDataTable(activityRegAudits);
}
/**
* 活动报名待审核页面跳转
* @param activityId 活动ID
* @param mMap
* @return
*/
@GetMapping("/actReg/actVolUnAudit/{activityId}")
public String actVolUnAudit(@PathVariable("activityId") Integer activityId, ModelMap mMap){
Activity activity = activityService.findActivityById(activityId);
// 获取该活动相关报名人数以及录用人数方法
activityService.getCountForActivity(activity);
mMap.put("activity", activity);
return prefix + "/regActVol";
}
/**
* 查询待审核的志愿者活动报名信息
* @param activityRegAudit 活动报名信息
* @return
*/
@PostMapping("/actReg/actVolUnAuditList")
@ResponseBody
public TableDataInfo actVolUnAuditList(ActivityRegAudit activityRegAudit){
startPage();
List<ActivityRegAudit> activityRegAudits = activityRegAuditService.findActivityRegAuditList(activityRegAudit);
return getDataTable(activityRegAudits);
}
/**
* 活动审核报名记录页面跳转
* @param activityId 活动ID
* @param mMap
* @return
*/
@GetMapping("/actReg/actVolAudit/{activityId}")
public String actVolAudit(@PathVariable("activityId") Integer activityId, ModelMap mMap){
Activity activity = activityService.findActivityById(activityId);
// 获取该活动相关报名人数以及录用人数方法
activityService.getCountForActivity(activity);
mMap.put("activity", activity);
return prefix + "/regActVols";
}
/**
* 查询已审核的志愿者活动报名信息
* @param activityRegAudit 活动报名信息
* @return
*/
@PostMapping("/actReg/actVolAuditList")
@ResponseBody
public TableDataInfo actVolAuditList(ActivityRegAudit activityRegAudit){
startPage();
List<ActivityRegAudit> activityRegAudits = activityRegAuditService.findAllAuditList(activityRegAudit);
return getDataTable(activityRegAudits);
}
/**
* 查看审核记录(组织管理者、组织运营者)
* @param araId 报名申请审核表ID
* @param mMap
* @return
*/
@GetMapping("/actReg/view/{araId}")
public String actVolRegAuditView(@PathVariable("araId") Integer araId, ModelMap mMap){
// 获取报名审核信息
ActivityRegAudit activityRegAudit = activityRegAuditService.findActivityRegAuditById(araId);
// 获取报名志愿者信息
Volunteer volunteer = volunteerService.findVolunteerById(activityRegAudit.getVolId());
// 根据志愿者ID查询志愿者的正常参加的活动记录
activityRecordService.findActivityRecordByVol(volunteer);
mMap.put("ara", activityRegAudit);
mMap.put("volunteer", volunteer);
return prefix + "/regVolAuditView";
}
/**
* 查看审核记录(志愿者前台)
* @param araId 报名申请审核表ID
* @param mMap
* @return
*/
@GetMapping("/frontActReg/view/{araId}")
public String frontActVolRegAuditView(@PathVariable("araId") Integer araId, ModelMap mMap){
// 获取报名审核信息
ActivityRegAudit activityRegAudit = activityRegAuditService.findActivityRegAuditById(araId);
mMap.put("ara", activityRegAudit);
return prefixFront + "/activity/frontRegAuditView";
}
/**
* 志愿者活动报名审核页面跳转
* @param araId 活动报名审核ID
* @param mMap
* @return
*/
@GetMapping("/actReg/edit/{araId}")
public String actVolRegAuditEdit(@PathVariable("araId") Integer araId, ModelMap mMap){
// 获取报名审核信息
ActivityRegAudit activityRegAudit = activityRegAuditService.findActivityRegAuditById(araId);
// 获取报名志愿者信息
Volunteer volunteer = volunteerService.findVolunteerById(activityRegAudit.getVolId());
// 根据志愿者ID查询志愿者的正常参加的活动记录
activityRecordService.findActivityRecordByVol(volunteer);
// 活动当前审核人信息
mMap.put("info", ShiroUtils.getMySession().getAttribute("info"));
mMap.put("ara", activityRegAudit);
mMap.put("volunteer", volunteer);
return prefix + "/regVolAudit";
}
/**
* 志愿者活动报名审核
* @param activityRegAudit 活动报名审核信息
* @param activityName 活动名称
* @param sendName 发送人名称
* @param receiveName 接收人名称
* @param volPhone 志愿者手机
* @param volEmail 志愿者邮箱
* @return
*/
// @RequiresPermissions("sys:activity:edit")
@PostMapping("/actReg/edit")
@ResponseBody
public AjaxResult editActVolRegAudit(@Validated ActivityRegAudit activityRegAudit,
@RequestParam(required = false, value = "activityName") String activityName,
@RequestParam(required = false, value = "sendName") String sendName,
@RequestParam(required = false, value = "receiveName") String receiveName,
@RequestParam(required = false, value = "volPhone") String volPhone,
@RequestParam(required = false, value = "volEmail") String volEmail){
System.out.println("..获取:" + activityRegAudit);
System.out.println("..获取:" + activityName);
System.out.println("..获取:" + sendName);
System.out.println("..获取:" + receiveName);
System.out.println("..获取:" + volPhone);
System.out.println("..获取:" + volEmail);
// 修改信息
int result = activityRegAuditService.updateActivityRegAudit(activityRegAudit);
// 如果修改成功则发送短信
if(result > 0){
String appTip;
// 审核通过
if(activityRegAudit.getAuditFlag().equals("1")){
appTip = "通过";
} else {// 不通过
appTip = "不通过";
}
String info = "您报名的' " + activityName + " '活动" + "的审核结果为:'" + appTip + "',请尽快登录寮步志愿者平台查看,谢谢。";
// 手机号,发送人,接收人,发送内容
String sendResult = sendSMS(volPhone, sendName, receiveName, info);
if (sendResult.equals("0")){
return success("审核成功,将审核信息发送给活动报名者...");
}
}
return error("系统错误.");
}
/**
* 批量修改活动报名审核操作
* @param activityRegAudit 活动报名信息
* @return
*/
@PostMapping("/actReg/editMore")
@ResponseBody
public AjaxResult editMoreActVolRegAudit(@Validated ActivityRegAudit activityRegAudit,
@RequestParam(required = false, value = "ids") String ids,
@RequestParam(required = false, value = "vIds") String vIds,
@RequestParam(required = false, value = "vPhones") String vPhones,
@RequestParam(required = false, value = "vNames") String vNames) throws Exception {
// String[] 转型成 Integer[]
// 获取审核ID数组
Integer[] araIds = Convert.toIntArray(ids);
// 获取志愿者ID数组(用于发送短信)
Integer[] volIds = Convert.toIntArray(vIds);
// 获取志愿者手机号数组(用于发送短信)
String[] volPhones = Convert.toStrArray(vPhones);
// 获取志愿者姓名数组(用于发送短信)
String[] volNames = Convert.toStrArray(vNames);
// System.out.println("获取: " + vIds);
// System.out.println("获取: " + volIds);
// System.out.println("获取: " + vPhones);
// System.out.println("获取: " + vNames);
// 放入报名审核信息
activityRegAudit.setAraIds(araIds);
activityRegAudit.setVolIds(volIds);
// 获取当前审核人的userId
activityRegAudit.setUserId(ShiroUtils.getUserId().intValue());
// 判断审核结果补充相应的审核备注
String auditFlag = activityRegAudit.getAuditFlag();
// 审核通过
if (auditFlag.equals("1")){
activityRegAudit.setRemark("审核通过");
} else {
activityRegAudit.setRemark("审核不通过");
}
int result = activityRegAuditService.volRegAuditByIds(activityRegAudit);
if (result > 0){
return success("审核成功");
}
return error("系统错误.");
}
/**
* 志愿者活动报名及记录相关信息表(志愿者前台)
* @param mMap
* @return
*/
@RequestMapping("/volAudRecList")
public String volAudRecList(ModelMap mMap){
mMap.put("info", ShiroUtils.getMySession().getAttribute("info"));
mMap.put("roleGroup", ShiroUtils.getMySession().getAttribute("role"));
// 活动类型集合
List<ActivityType> activityTypes = activityTypeService.findActivityTypeAll();
mMap.put("activityTypes", activityTypes);
return prefixFront + "/activity/volAudRecList";
}
/**
* 短信发送方法
* @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);
}
}