|
|
|
@ -0,0 +1,616 @@
|
|
|
|
|
// 包声明,指定该类所属的包路径
|
|
|
|
|
package com.farm.wcp.controller;
|
|
|
|
|
|
|
|
|
|
// 导入 Map 接口,用于处理键值对集合
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
|
|
// 导入 Resource 注解,用于依赖注入
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
// 导入 HttpServletRequest 类,用于处理 HTTP 请求
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
|
// 导入 HttpSession 类,用于管理用户会话
|
|
|
|
|
import javax.servlet.http.HttpSession;
|
|
|
|
|
|
|
|
|
|
// 导入 Controller 注解,将该类标记为 Spring MVC 的控制器
|
|
|
|
|
import org.springframework.stereotype.Controller;
|
|
|
|
|
// 导入 RequestMapping 注解,用于映射请求路径
|
|
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
|
// 导入 RequestMethod 枚举,用于指定请求方法
|
|
|
|
|
import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
|
|
// 导入 ResponseBody 注解,用于将方法的返回值直接写入响应体
|
|
|
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
|
|
// 导入 ModelAndView 类,用于封装模型数据和视图信息
|
|
|
|
|
import org.springframework.web.servlet.ModelAndView;
|
|
|
|
|
|
|
|
|
|
// 导入 ViewMode 类,用于处理视图模式相关操作
|
|
|
|
|
import com.farm.core.page.ViewMode;
|
|
|
|
|
// 导入 DataResult 类,用于处理数据库查询结果
|
|
|
|
|
import com.farm.core.sql.result.DataResult;
|
|
|
|
|
// 导入 FarmDocgroup 类,用于表示文档小组实体
|
|
|
|
|
import com.farm.doc.domain.FarmDocgroup;
|
|
|
|
|
// 导入 DocEntire 类,用于表示完整的文档实体
|
|
|
|
|
import com.farm.doc.domain.ex.DocEntire;
|
|
|
|
|
// 导入 GroupEntire 类,用于表示完整的小组实体
|
|
|
|
|
import com.farm.doc.domain.ex.GroupEntire;
|
|
|
|
|
// 导入 CanNoReadException 异常类,用于处理无权限读取文档的异常情况
|
|
|
|
|
import com.farm.doc.exception.CanNoReadException;
|
|
|
|
|
// 导入 DocNoExistException 异常类,用于处理文档不存在的异常情况
|
|
|
|
|
import com.farm.doc.exception.DocNoExistException;
|
|
|
|
|
// 导入 NoGroupAuthForLicenceException 异常类,用于处理无小组授权许可的异常情况
|
|
|
|
|
import com.farm.doc.exception.NoGroupAuthForLicenceException;
|
|
|
|
|
// 导入 FarmDocManagerInter 接口,用于文档管理操作
|
|
|
|
|
import com.farm.doc.server.FarmDocManagerInter;
|
|
|
|
|
// 导入 FarmDocOperateRightInter 接口,用于文档操作权限管理
|
|
|
|
|
import com.farm.doc.server.FarmDocOperateRightInter;
|
|
|
|
|
// 导入 FarmDocRunInfoInter 接口,用于文档运行信息管理
|
|
|
|
|
import com.farm.doc.server.FarmDocRunInfoInter;
|
|
|
|
|
// 导入 FarmDocgroupManagerInter 接口,用于文档小组管理操作
|
|
|
|
|
import com.farm.doc.server.FarmDocgroupManagerInter;
|
|
|
|
|
// 导入 SearchType 枚举,用于指定搜索类型
|
|
|
|
|
import com.farm.doc.server.FarmDocgroupManagerInter.SearchType;
|
|
|
|
|
// 导入 FarmDocmessageManagerInter 接口,用于文档消息管理
|
|
|
|
|
import com.farm.doc.server.FarmDocmessageManagerInter;
|
|
|
|
|
// 导入 FarmFileManagerInter 接口,用于文件管理操作
|
|
|
|
|
import com.farm.doc.server.FarmFileManagerInter;
|
|
|
|
|
// 导入 UsermessageServiceInter 接口,用于用户消息服务
|
|
|
|
|
import com.farm.doc.server.UsermessageServiceInter;
|
|
|
|
|
// 导入 KnowServiceInter 接口,用于知识服务相关操作
|
|
|
|
|
import com.farm.wcp.know.service.KnowServiceInter;
|
|
|
|
|
// 导入 ThemesUtil 类,用于处理主题相关的工具方法
|
|
|
|
|
import com.farm.wcp.util.ThemesUtil;
|
|
|
|
|
// 导入 WebUtils 类,可能包含一些通用的 Web 工具方法
|
|
|
|
|
import com.farm.web.WebUtils;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 工作小组控制器类
|
|
|
|
|
*
|
|
|
|
|
* @author wangdong
|
|
|
|
|
*/
|
|
|
|
|
// 定义请求映射的根路径为 /webgroup
|
|
|
|
|
@RequestMapping("/webgroup")
|
|
|
|
|
// 将该类标记为 Spring MVC 的控制器
|
|
|
|
|
@Controller
|
|
|
|
|
// 继承 WebUtils 类,以获取其中的工具方法
|
|
|
|
|
public class DocGroupController extends WebUtils {
|
|
|
|
|
// 注入 FarmDocgroupManagerInter 接口的实现类实例,用于文档小组管理
|
|
|
|
|
@Resource
|
|
|
|
|
private FarmDocgroupManagerInter farmDocgroupManagerImpl;
|
|
|
|
|
// 注入 FarmFileManagerInter 接口的实现类实例,用于文件管理
|
|
|
|
|
@Resource
|
|
|
|
|
private FarmFileManagerInter farmFileManagerImpl;
|
|
|
|
|
// 注入 FarmDocManagerInter 接口的实现类实例,用于文档管理
|
|
|
|
|
@Resource
|
|
|
|
|
private FarmDocManagerInter farmDocManagerImpl;
|
|
|
|
|
// 注入 FarmDocRunInfoInter 接口的实现类实例,用于文档运行信息管理
|
|
|
|
|
@Resource
|
|
|
|
|
private FarmDocRunInfoInter farmDocRunInfoImpl;
|
|
|
|
|
// 注入 KnowServiceInter 接口的实现类实例,用于知识服务
|
|
|
|
|
@Resource
|
|
|
|
|
private KnowServiceInter KnowServiceImpl;
|
|
|
|
|
// 注入 FarmDocmessageManagerInter 接口的实现类实例,用于文档消息管理
|
|
|
|
|
@Resource
|
|
|
|
|
private FarmDocmessageManagerInter farmDocmessageManagerImpl;
|
|
|
|
|
// 注入 FarmDocOperateRightInter 接口的实现类实例,用于文档操作权限管理
|
|
|
|
|
@Resource
|
|
|
|
|
private FarmDocOperateRightInter farmDocOperateRightImpl;
|
|
|
|
|
// 注入 UsermessageServiceInter 接口的实现类实例,用于用户消息服务
|
|
|
|
|
@Resource
|
|
|
|
|
private UsermessageServiceInter usermessageServiceImpl;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 进入创建小组页面
|
|
|
|
|
*
|
|
|
|
|
* @param session HTTP 会话对象
|
|
|
|
|
* @param request HTTP 请求对象
|
|
|
|
|
* @return ModelAndView 对象,包含视图信息
|
|
|
|
|
*/
|
|
|
|
|
// 映射 /add 请求路径,处理 GET 请求
|
|
|
|
|
@RequestMapping("/add")
|
|
|
|
|
public ModelAndView add(HttpSession session, HttpServletRequest request) {
|
|
|
|
|
// 返回创建小组页面的视图模型,视图路径通过 ThemesUtil 获取主题路径后拼接
|
|
|
|
|
return ViewMode.getInstance().returnModelAndView(ThemesUtil.getThemePath() + "/docgroup/editGroup");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 进入修改小组页面
|
|
|
|
|
*
|
|
|
|
|
* @param groupid 小组 ID
|
|
|
|
|
* @param session HTTP 会话对象
|
|
|
|
|
* @param request HTTP 请求对象
|
|
|
|
|
* @return ModelAndView 对象,包含小组信息和视图信息
|
|
|
|
|
*/
|
|
|
|
|
// 映射 /edit 请求路径,处理 GET 请求
|
|
|
|
|
@RequestMapping("/edit")
|
|
|
|
|
public ModelAndView edit(String groupid, HttpSession session, HttpServletRequest request) {
|
|
|
|
|
// 根据小组 ID 获取小组的完整信息
|
|
|
|
|
GroupEntire group = farmDocgroupManagerImpl.getFarmDocgroup(groupid);
|
|
|
|
|
// 将小组信息放入视图模型,并返回修改小组页面的视图模型
|
|
|
|
|
return ViewMode.getInstance().putAttr("group", group)
|
|
|
|
|
.returnModelAndView(ThemesUtil.getThemePath() + "/docgroup/editGroup");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 进入小组成员管理页面
|
|
|
|
|
*
|
|
|
|
|
* @param page 页码,默认为 1
|
|
|
|
|
* @param groupid 小组 ID
|
|
|
|
|
* @param session HTTP 会话对象
|
|
|
|
|
* @param request HTTP 请求对象
|
|
|
|
|
* @return ModelAndView 对象,包含成员申请信息、小组信息、成员信息和视图信息
|
|
|
|
|
*/
|
|
|
|
|
// 映射 /userMag 请求路径,处理 GET 请求
|
|
|
|
|
@RequestMapping("/userMag")
|
|
|
|
|
public ModelAndView userEdit(Integer page, String groupid, HttpSession session, HttpServletRequest request) {
|
|
|
|
|
// 如果页码为空,设置为 1
|
|
|
|
|
if (page == null) {
|
|
|
|
|
page = 1;
|
|
|
|
|
}
|
|
|
|
|
// 根据小组 ID 获取小组的完整信息
|
|
|
|
|
GroupEntire group = farmDocgroupManagerImpl.getFarmDocgroup(groupid);
|
|
|
|
|
// 获取当前成员申请信息,筛选条件为已申请(yes),未处理(none),非成员(none)
|
|
|
|
|
DataResult result = farmDocgroupManagerImpl.getGroupUser(groupid, SearchType.yes, SearchType.none,
|
|
|
|
|
SearchType.none, 1, 10);
|
|
|
|
|
// 获取成员信息,筛选条件为非申请(no),未处理(none),非成员(none)
|
|
|
|
|
DataResult users = farmDocgroupManagerImpl.getGroupUser(groupid, SearchType.no, SearchType.none,
|
|
|
|
|
SearchType.none, page, 10);
|
|
|
|
|
// 将成员申请信息、小组信息、成员信息和小组 ID 放入视图模型,并返回小组成员管理页面的视图模型
|
|
|
|
|
return ViewMode.getInstance().putAttr("applys", result).putAttr("group", group).putAttr("users", users)
|
|
|
|
|
.putAttr("groupid", groupid)
|
|
|
|
|
.returnModelAndView(ThemesUtil.getThemePath() + "/docgroup/groupAdminConsole");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 添加小组
|
|
|
|
|
*
|
|
|
|
|
* @param group 小组实体对象
|
|
|
|
|
* @param session HTTP 会话对象
|
|
|
|
|
* @return ModelAndView 对象,根据操作结果重定向或返回错误页面
|
|
|
|
|
*/
|
|
|
|
|
// 映射 /addCommit 请求路径,处理 POST 请求(默认)
|
|
|
|
|
@RequestMapping("/addCommit")
|
|
|
|
|
public ModelAndView addCommit(FarmDocgroup group, HttpSession session) {
|
|
|
|
|
try {
|
|
|
|
|
// 如果小组存在且小组 ID 不为空但长度为 0,将小组 ID 设置为 null
|
|
|
|
|
if (group != null && group.getId() != null && group.getId().trim().length() <= 0) {
|
|
|
|
|
group.setId(null);
|
|
|
|
|
}
|
|
|
|
|
// 创建小组,传入小组名称、标签、图片、是否需要审核、小组备注和当前用户信息
|
|
|
|
|
group = farmDocgroupManagerImpl.creatDocGroup(group.getGroupname(), group.getGrouptag(),
|
|
|
|
|
group.getGroupimg(), group.getJoincheck().equals("1")? true : false, group.getGroupnote(),
|
|
|
|
|
getCurrentUser(session));
|
|
|
|
|
// 将小组 ID 放入视图模型,并重定向到小组首页
|
|
|
|
|
return ViewMode.getInstance().putAttr("id", group.getId()).returnRedirectUrl("/webgroup/PubHome.html");
|
|
|
|
|
} catch (NoGroupAuthForLicenceException e) {
|
|
|
|
|
// 如果捕获到无小组授权许可异常,重定向到小组首页
|
|
|
|
|
return ViewMode.getInstance().returnRedirectUrl("/webgroup/PubHome.html");
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
// 如果捕获到其他异常,重定向到小组首页
|
|
|
|
|
return ViewMode.getInstance().returnRedirectUrl("/webgroup/PubHome.html");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 修改小组
|
|
|
|
|
*
|
|
|
|
|
* @param group 小组实体对象
|
|
|
|
|
* @param session HTTP 会话对象
|
|
|
|
|
* @return ModelAndView 对象,根据操作结果重定向或返回错误页面
|
|
|
|
|
*/
|
|
|
|
|
// 映射 /editCommit 请求路径,处理 POST 请求(默认)
|
|
|
|
|
@RequestMapping("/editCommit")
|
|
|
|
|
public ModelAndView editCommit(FarmDocgroup group, HttpSession session) {
|
|
|
|
|
try {
|
|
|
|
|
// 设置小组状态为 "1"
|
|
|
|
|
group.setPstate("1");
|
|
|
|
|
// 编辑小组信息,传入小组实体和当前用户信息
|
|
|
|
|
farmDocgroupManagerImpl.editFarmDocgroupEntity(group, getCurrentUser(session));
|
|
|
|
|
// 重定向到小组展示页面,带上小组 ID
|
|
|
|
|
return ViewMode.getInstance().returnRedirectUrl("/webgroup/Pubshow.do?groupid=" + group.getId());
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
// 如果捕获到异常,打印异常堆栈信息,并重定向到小组展示页面
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
return ViewMode.getInstance().returnRedirectUrl("/webgroup/Pubshow.do?groupid=" + group.getId());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 编辑小组首页
|
|
|
|
|
*
|
|
|
|
|
* @param groupId 小组 ID
|
|
|
|
|
* @param docid 文档 ID
|
|
|
|
|
* @param text 文档文本内容
|
|
|
|
|
* @param editNote 编辑备注
|
|
|
|
|
* @param session HTTP 会话对象
|
|
|
|
|
* @return ModelAndView 对象,根据操作结果重定向或返回错误页面
|
|
|
|
|
*/
|
|
|
|
|
// 映射 /homeeditCommit 请求路径,处理 POST 请求(默认)
|
|
|
|
|
@RequestMapping("/homeeditCommit")
|
|
|
|
|
public ModelAndView homeeditCommit(String groupId, String docid, String text, String editNote,
|
|
|
|
|
HttpSession session) {
|
|
|
|
|
try {
|
|
|
|
|
// 根据文档 ID 获取文档的完整信息(此处 @SuppressWarnings 抑制了关于方法过时的警告)
|
|
|
|
|
@SuppressWarnings("deprecation")
|
|
|
|
|
DocEntire doc = farmDocManagerImpl.getDoc(docid);
|
|
|
|
|
// 设置文档的文本内容和当前用户信息
|
|
|
|
|
doc.setTexts(text, getCurrentUser(session));
|
|
|
|
|
// 编辑文档,传入文档实体、编辑备注和当前用户信息
|
|
|
|
|
farmDocManagerImpl.editDoc(doc, editNote, getCurrentUser(session));
|
|
|
|
|
// 重定向到小组展示页面,带上小组 ID
|
|
|
|
|
return ViewMode.getInstance().returnRedirectUrl("/webgroup/Pubshow.do?groupid=" + groupId);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
// 如果捕获到异常,打印异常堆栈信息,并重定向到小组展示页面
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
return ViewMode.getInstance().returnRedirectUrl("/webgroup/Pubshow.do?groupid=" + groupId);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 进入编辑小组首页
|
|
|
|
|
*
|
|
|
|
|
* @param groupid 小组 ID
|
|
|
|
|
* @param session HTTP 会话对象
|
|
|
|
|
* @param request HTTP 请求对象
|
|
|
|
|
* @return ModelAndView 对象,包含小组信息、文档信息和视图信息
|
|
|
|
|
*/
|
|
|
|
|
// 映射 /homeedit 请求路径,处理 GET 请求
|
|
|
|
|
@RequestMapping("/homeedit")
|
|
|
|
|
public ModelAndView homeedit(String groupid, HttpSession session, HttpServletRequest request) {
|
|
|
|
|
// 获取视图模式实例
|
|
|
|
|
ViewMode mode = ViewMode.getInstance();
|
|
|
|
|
try {
|
|
|
|
|
// 根据小组 ID 获取小组实体信息
|
|
|
|
|
FarmDocgroup group = farmDocgroupManagerImpl.getFarmDocgroupEntity(groupid);
|
|
|
|
|
// 获取小组首页文档 ID
|
|
|
|
|
String homedocid = group.getHomedocid();
|
|
|
|
|
// 根据首页文档 ID 获取文档的完整信息(此处 @SuppressWarnings 抑制了关于方法过时的警告)
|
|
|
|
|
@SuppressWarnings("deprecation")
|
|
|
|
|
DocEntire doc = farmDocManagerImpl.getDoc(homedocid);
|
|
|
|
|
// 将小组信息和文档信息放入视图模型
|
|
|
|
|
mode.putAttr("group", group).putAttr("doc", doc);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
// 如果捕获到异常,设置错误信息并返回错误页面的视图模型
|
|
|
|
|
return ViewMode.getInstance().setError(e.toString())
|
|
|
|
|
.returnModelAndView(ThemesUtil.getThemePath() + "/error");
|
|
|
|
|
}
|
|
|
|
|
// 返回编辑小组首页的视图模型
|
|
|
|
|
return mode.returnModelAndView(ThemesUtil.getThemePath() + "/docgroup/editHomePage");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 进入小组页面
|
|
|
|
|
*
|
|
|
|
|
* @param typeid 类型 ID(未使用)
|
|
|
|
|
* @param pagenum 页码,默认为 1
|
|
|
|
|
* @param groupid 小组 ID
|
|
|
|
|
* @param session HTTP 会话对象
|
|
|
|
|
* @param request HTTP 请求对象
|
|
|
|
|
* @return ModelAndView 对象,包含文档数量、首页文档信息、小组 ID、小组信息和视图信息
|
|
|
|
|
*/
|
|
|
|
|
// 映射 /Pubshow 请求路径,处理 GET 请求
|
|
|
|
|
@RequestMapping("/Pubshow")
|
|
|
|
|
public ModelAndView show(String typeid, Integer pagenum, String groupid, HttpSession session,
|
|
|
|
|
HttpServletRequest request) {
|
|
|
|
|
// 获取视图模式实例
|
|
|
|
|
ViewMode mode = ViewMode.getInstance();
|
|
|
|
|
// 根据小组 ID 获取小组的完整信息
|
|
|
|
|
GroupEntire docgroup = farmDocgroupManagerImpl.getFarmDocgroup(groupid);
|
|
|
|
|
// 初始化文档实体对象
|
|
|
|
|
DocEntire doc = null;
|
|
|
|
|
try {
|
|
|
|
|
// 根据小组首页文档 ID 和当前用户信息获取文档的完整信息
|
|
|
|
|
doc = farmDocManagerImpl.getDoc(docgroup.getHomedocid(), getCurrentUser(session));
|
|
|
|
|
} catch (CanNoReadException | DocNoExistException e) {
|
|
|
|
|
// 如果捕获到无权限读取或文档不存在异常,设置错误信息并返回错误页面的视图模型
|
|
|
|
|
return ViewMode.getInstance().setError("没有权限,或不存在")
|
|
|
|
|
.returnModelAndView(ThemesUtil.getThemePath() + "/error");
|
|
|
|
|
}
|
|
|
|
|
// 如果当前用户存在
|
|
|
|
|
if (getCurrentUser(session) != null) {
|
|
|
|
|
// 获取当前用户在小组中的权限信息,并放入视图模型
|
|
|
|
|
mode.putAttr("usergroup",
|
|
|
|
|
farmDocgroupManagerImpl.getFarmDocgroupUser(docgroup.getId(), getCurrentUser(session).getId()));
|
|
|
|
|
}
|
|
|
|
|
// 获取小组内文档数量
|
|
|
|
|
int docnum = farmDocgroupManagerImpl.getGroupDocNum(groupid);
|
|
|
|
|
// 获取小组最新知识,传入当前用户、小组 ID、数量和页码
|
|
|
|
|
mode.putAttr("docs",
|
|
|
|
|
farmDocgroupManagerImpl.getNewGroupDoc(getCurrentUser(session) == null? null : getCurrentUser(session),
|
|
|
|
|
groupid, 10, pagenum == null? 1 : pagenum));
|
|
|
|
|
// 将文档数量、首页文档信息、小组 ID、小组信息放入视图模型,并返回小组页面的视图模型
|
|
|
|
|
return mode.putAttr("docnum", docnum).putAttr("home", doc).putAttr("groupid", groupid)
|
|
|
|
|
.putAttr("docgroup", docgroup).returnModelAndView(ThemesUtil.getThemePath() + "/docgroup/groupSite");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 小组栏目首页
|
|
|
|
|
*
|
|
|
|
|
* @param pagenum 页码,默认为 1
|
|
|
|
|
* @param session HTTP 会话对象
|
|
|
|
|
* @param request HTTP 请求对象
|
|
|
|
|
* @return ModelAndView 对象,包含小组信息和视图信息
|
|
|
|
|
* @throws Exception 可能抛出的异常
|
|
|
|
|
*/
|
|
|
|
|
// 映射 /PubHome 请求路径,处理 GET 请求
|
|
|
|
|
@RequestMapping(value = "/PubHome", method = RequestMethod.GET)
|
|
|
|
|
public ModelAndView showDoc(Integer pagenum, HttpSession session, HttpServletRequest request) throws Exception {
|
|
|
|
|
// 如果页码为空,设置为 1
|
|
|
|
|
if (pagenum == null) {
|
|
|
|
|
pagenum = 1;
|
|
|
|
|
}
|
|
|
|
|
// 获取最热的小组信息,传入数量和页码
|
|
|
|
|
DataResult groups = farmDocgroupManagerImpl.getGroups(12, pagenum);
|
|
|
|
|
// 将小组信息放入视图模型,并返回小组栏目
|
|
|
|
|
// 将最热小组信息放入视图模式的属性中,并返回小组栏目首页的视图模型
|
|
|
|
|
return ViewMode.getInstance().putAttr("groups", groups)
|
|
|
|
|
.returnModelAndView(ThemesUtil.getThemePath() + "/docgroup/groupHome");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 取消用户管理员权限
|
|
|
|
|
*
|
|
|
|
|
* @param groupUserId 小组用户 ID
|
|
|
|
|
* @param session HTTP 会话
|
|
|
|
|
* @return 包含操作结果的 Map 对象
|
|
|
|
|
*/
|
|
|
|
|
// 定义请求映射,处理 /wipeAdmin 路径的请求
|
|
|
|
|
@RequestMapping("/wipeAdmin")
|
|
|
|
|
// 将方法返回值直接作为响应体返回
|
|
|
|
|
@ResponseBody
|
|
|
|
|
public Map<String, Object> groupWipeAdmin(String groupUserId, HttpSession session) {
|
|
|
|
|
try {
|
|
|
|
|
// 调用服务方法,取消指定用户在小组中的管理员权限
|
|
|
|
|
farmDocgroupManagerImpl.wipeAdminFromGroup(groupUserId, getCurrentUser(session));
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
// 若出现异常,设置错误信息并返回操作结果
|
|
|
|
|
return ViewMode.getInstance().setError(e.getMessage()).returnObjMode();
|
|
|
|
|
}
|
|
|
|
|
// 若操作成功,返回操作结果
|
|
|
|
|
return ViewMode.getInstance().returnObjMode();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 设置为小组管理员
|
|
|
|
|
*
|
|
|
|
|
* @param groupUserId 小组用户 ID
|
|
|
|
|
* @param session HTTP 会话
|
|
|
|
|
* @return 包含操作结果的 Map 对象
|
|
|
|
|
*/
|
|
|
|
|
// 定义请求映射,处理 /groupSetAdmin 路径的请求
|
|
|
|
|
@RequestMapping("/groupSetAdmin")
|
|
|
|
|
// 将方法返回值直接作为响应体返回
|
|
|
|
|
@ResponseBody
|
|
|
|
|
public Map<String, Object> groupSetAdmin(String groupUserId, HttpSession session) {
|
|
|
|
|
try {
|
|
|
|
|
// 调用服务方法,将指定用户设置为小组管理员
|
|
|
|
|
farmDocgroupManagerImpl.setAdminForGroup(groupUserId, getCurrentUser(session));
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
// 若出现异常,设置错误信息并返回操作结果
|
|
|
|
|
return ViewMode.getInstance().setError(e.getMessage()).returnObjMode();
|
|
|
|
|
}
|
|
|
|
|
// 若操作成功,返回操作结果
|
|
|
|
|
return ViewMode.getInstance().returnObjMode();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 去除小组编辑权限
|
|
|
|
|
*
|
|
|
|
|
* @param groupUserId 小组用户 ID
|
|
|
|
|
* @param session HTTP 会话
|
|
|
|
|
* @return 包含操作结果的 Map 对象
|
|
|
|
|
*/
|
|
|
|
|
// 定义请求映射,处理 /groupWipeEditor 路径的请求
|
|
|
|
|
@RequestMapping("/groupWipeEditor")
|
|
|
|
|
// 将方法返回值直接作为响应体返回
|
|
|
|
|
@ResponseBody
|
|
|
|
|
public Map<String, Object> groupWipeEditor(String groupUserId, HttpSession session) {
|
|
|
|
|
try {
|
|
|
|
|
// 调用服务方法,去除指定用户在小组中的编辑权限
|
|
|
|
|
farmDocgroupManagerImpl.wipeEditorForGroup(groupUserId, getCurrentUser(session));
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
// 若出现异常,设置错误信息并返回操作结果
|
|
|
|
|
return ViewMode.getInstance().setError(e.getMessage()).returnObjMode();
|
|
|
|
|
}
|
|
|
|
|
// 若操作成功,返回操作结果
|
|
|
|
|
return ViewMode.getInstance().returnObjMode();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 设置小组编辑权限
|
|
|
|
|
*
|
|
|
|
|
* @param groupUserId 小组用户 ID
|
|
|
|
|
* @param session HTTP 会话
|
|
|
|
|
* @return 包含操作结果的 Map 对象
|
|
|
|
|
*/
|
|
|
|
|
// 定义请求映射,处理 /groupSetEditor 路径的请求
|
|
|
|
|
@RequestMapping("/groupSetEditor")
|
|
|
|
|
// 将方法返回值直接作为响应体返回
|
|
|
|
|
@ResponseBody
|
|
|
|
|
public Map<String, Object> groupSetEditor(String groupUserId, HttpSession session) {
|
|
|
|
|
try {
|
|
|
|
|
// 调用服务方法,为指定用户设置小组编辑权限
|
|
|
|
|
farmDocgroupManagerImpl.setEditorForGroup(groupUserId, getCurrentUser(session));
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
// 若出现异常,设置错误信息并返回操作结果
|
|
|
|
|
return ViewMode.getInstance().setError(e.getMessage()).returnObjMode();
|
|
|
|
|
}
|
|
|
|
|
// 若操作成功,返回操作结果
|
|
|
|
|
return ViewMode.getInstance().returnObjMode();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 将用户退出小组
|
|
|
|
|
*
|
|
|
|
|
* @param groupUserId 小组用户 ID
|
|
|
|
|
* @param session HTTP 会话
|
|
|
|
|
* @return 包含操作结果的 Map 对象
|
|
|
|
|
*/
|
|
|
|
|
// 定义请求映射,处理 /groupQuit 路径的请求
|
|
|
|
|
@RequestMapping("/groupQuit")
|
|
|
|
|
// 将方法返回值直接作为响应体返回
|
|
|
|
|
@ResponseBody
|
|
|
|
|
public Map<String, Object> groupQuit(String groupUserId, HttpSession session) {
|
|
|
|
|
try {
|
|
|
|
|
// 调用服务方法,将指定用户从小组中移除
|
|
|
|
|
farmDocgroupManagerImpl.leaveGroup(groupUserId, getCurrentUser(session));
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
// 若出现异常,设置错误信息并返回操作结果
|
|
|
|
|
return ViewMode.getInstance().setError(e.getMessage()).returnObjMode();
|
|
|
|
|
}
|
|
|
|
|
// 若操作成功,返回操作结果
|
|
|
|
|
return ViewMode.getInstance().returnObjMode();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 同意加入小组
|
|
|
|
|
*
|
|
|
|
|
* @param groupUserId 小组用户 ID
|
|
|
|
|
* @param session HTTP 会话
|
|
|
|
|
* @return 包含操作结果的 Map 对象
|
|
|
|
|
*/
|
|
|
|
|
// 定义请求映射,处理 /agreeApply 路径的请求
|
|
|
|
|
@RequestMapping("/agreeApply")
|
|
|
|
|
// 将方法返回值直接作为响应体返回
|
|
|
|
|
@ResponseBody
|
|
|
|
|
public Map<String, Object> agreeApply(String groupUserId, HttpSession session) {
|
|
|
|
|
try {
|
|
|
|
|
// 调用服务方法,同意指定用户加入小组的申请
|
|
|
|
|
farmDocgroupManagerImpl.agreeJoinApply(groupUserId, getCurrentUser(session));
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
// 若出现异常,设置错误信息并返回操作结果
|
|
|
|
|
return ViewMode.getInstance().setError(e.getMessage()).returnObjMode();
|
|
|
|
|
}
|
|
|
|
|
// 若操作成功,返回操作结果
|
|
|
|
|
return ViewMode.getInstance().returnObjMode();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 拒绝加入小组
|
|
|
|
|
*
|
|
|
|
|
* @param groupUserId 小组用户 ID
|
|
|
|
|
* @param session HTTP 会话
|
|
|
|
|
* @return 包含操作结果的 Map 对象
|
|
|
|
|
*/
|
|
|
|
|
// 定义请求映射,处理 /refuseApply 路径的请求
|
|
|
|
|
@RequestMapping("/refuseApply")
|
|
|
|
|
// 将方法返回值直接作为响应体返回
|
|
|
|
|
@ResponseBody
|
|
|
|
|
public Map<String, Object> refuseApply(String groupUserId, HttpSession session) {
|
|
|
|
|
try {
|
|
|
|
|
// 调用服务方法,拒绝指定用户加入小组的申请
|
|
|
|
|
farmDocgroupManagerImpl.refuseJoinApply(groupUserId, getCurrentUser(session));
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
// 若出现异常,设置错误信息并返回操作结果
|
|
|
|
|
return ViewMode.getInstance().setError(e.getMessage()).returnObjMode();
|
|
|
|
|
}
|
|
|
|
|
// 若操作成功,返回操作结果
|
|
|
|
|
return ViewMode.getInstance().returnObjMode();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 是否有小组管理员存在,通过小组管理员数量判断
|
|
|
|
|
*
|
|
|
|
|
* @param groupId 小组 ID
|
|
|
|
|
* @return 包含管理员数量的 Map 对象
|
|
|
|
|
*/
|
|
|
|
|
// 定义请求映射,处理 /haveAdministratorIs 路径的请求
|
|
|
|
|
@RequestMapping("/haveAdministratorIs")
|
|
|
|
|
// 将方法返回值直接作为响应体返回
|
|
|
|
|
@ResponseBody
|
|
|
|
|
public Map<String, Object> haveAdministratorIs(String groupId) {
|
|
|
|
|
// 获取指定小组的所有管理员,并统计数量
|
|
|
|
|
int adminNum = farmDocgroupManagerImpl.getAllAdministratorByGroup(groupId).size();
|
|
|
|
|
// 将管理员数量放入视图模式的属性中,并返回操作结果
|
|
|
|
|
return ViewMode.getInstance().putAttr("adminNum", adminNum).returnObjMode();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 退出小组
|
|
|
|
|
*
|
|
|
|
|
* @param groupId 小组 ID
|
|
|
|
|
* @param session HTTP 会话
|
|
|
|
|
* @return 重定向到小组展示页面的模型视图
|
|
|
|
|
*/
|
|
|
|
|
// 定义请求映射,处理 /leaveGroup 路径的请求
|
|
|
|
|
@RequestMapping("/leaveGroup")
|
|
|
|
|
public ModelAndView leaveGroup(String groupId, HttpSession session) {
|
|
|
|
|
// 调用服务方法,将当前用户从指定小组中移除
|
|
|
|
|
farmDocgroupManagerImpl.leaveGroup(groupId, getCurrentUser(session).getId());
|
|
|
|
|
// 重定向到小组展示页面
|
|
|
|
|
return ViewMode.getInstance().returnRedirectUrl("/webgroup/Pubshow.do?groupid=" + groupId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 加入小组
|
|
|
|
|
*
|
|
|
|
|
* @param groupId 小组 ID
|
|
|
|
|
* @param session HTTP 会话
|
|
|
|
|
* @param request HTTP 请求
|
|
|
|
|
* @return 重定向到小组展示页面或错误页面的模型视图
|
|
|
|
|
* @throws Exception 可能抛出的异常
|
|
|
|
|
*/
|
|
|
|
|
// 定义请求映射,处理 /join 路径的请求
|
|
|
|
|
@RequestMapping("/join")
|
|
|
|
|
public ModelAndView joinform(String groupId, HttpSession session, HttpServletRequest request) throws Exception {
|
|
|
|
|
// 判断当前用户是否已经加入该小组
|
|
|
|
|
if (farmDocgroupManagerImpl.isJoinGroupByUser(groupId, getCurrentUser(session).getId())) {
|
|
|
|
|
// 判断当前用户的加入申请是否正在审核中
|
|
|
|
|
if (farmDocgroupManagerImpl.isAuditing(groupId, getCurrentUser(session).getId())) {
|
|
|
|
|
// 若正在审核中,设置错误信息并返回错误页面的模型视图
|
|
|
|
|
return ViewMode.getInstance().setError("正在审核中")
|
|
|
|
|
.returnModelAndView(ThemesUtil.getThemePath() + "/error");
|
|
|
|
|
} else {
|
|
|
|
|
// 若已加入且审核通过,进入小组(此处代码未做额外处理)
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
// 若未加入小组
|
|
|
|
|
// 判断该小组加入是否需要审核
|
|
|
|
|
if (farmDocgroupManagerImpl.isJoinCheck(groupId)) {
|
|
|
|
|
// 若需要审核,将小组信息放入视图模式的属性中,并返回加入申请页面的模型视图
|
|
|
|
|
return ViewMode.getInstance().putAttr("group", farmDocgroupManagerImpl.getFarmDocgroupEntity(groupId))
|
|
|
|
|
.returnModelAndView(ThemesUtil.getThemePath() + "/docgroup/joinCheckForm");
|
|
|
|
|
} else {
|
|
|
|
|
// 若不需要审核,直接调用服务方法申请加入小组
|
|
|
|
|
farmDocgroupManagerImpl.applyGroup(groupId, getCurrentUser(session).getId(), "申请加入",
|
|
|
|
|
getCurrentUser(session));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// 将小组 ID 放入视图模式的属性中,并重定向到小组展示页面
|
|
|
|
|
return ViewMode.getInstance().putAttr("groupid", groupId).returnRedirectUrl("/webgroup/Pubshow.do");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 提交小组申请
|
|
|
|
|
*
|
|
|
|
|
* @param groupId 小组 ID
|
|
|
|
|
* @param message 申请消息
|
|
|
|
|
* @param session HTTP 会话
|
|
|
|
|
* @param request HTTP 请求
|
|
|
|
|
* @return 重定向到小组展示页面、错误页面或消息提示页面的模型视图
|
|
|
|
|
* @throws Exception 可能抛出的异常
|
|
|
|
|
*/
|
|
|
|
|
// 定义请求映射,处理 /joincommit 路径的请求
|
|
|
|
|
@RequestMapping("/joincommit")
|
|
|
|
|
public ModelAndView joincommit(String groupId, String message, HttpSession session, HttpServletRequest request)
|
|
|
|
|
throws Exception {
|
|
|
|
|
// 判断当前用户是否已经加入该小组
|
|
|
|
|
if (farmDocgroupManagerImpl.isJoinGroupByUser(groupId, getCurrentUser(session).getId())) {
|
|
|
|
|
// 判断当前用户的加入申请是否正在审核中
|
|
|
|
|
if (farmDocgroupManagerImpl.isAuditing(groupId, getCurrentUser(session).getId())) {
|
|
|
|
|
// 若正在审核中,设置错误信息并返回错误页面的模型视图
|
|
|
|
|
return ViewMode.getInstance().setError("正在审核中")
|
|
|
|
|
.returnModelAndView(ThemesUtil.getThemePath() + "/error");
|
|
|
|
|
} else {
|
|
|
|
|
// 若已加入且审核通过,将小组 ID 放入视图模式的属性中,并重定向到小组展示页面
|
|
|
|
|
return ViewMode.getInstance().putAttr("groupid", groupId).returnRedirectUrl("/webgroup/Pubshow.do");
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
// 若未加入小组,直接调用服务方法申请加入小组
|
|
|
|
|
farmDocgroupManagerImpl.applyGroup(groupId, getCurrentUser(session).getId(), message,
|
|
|
|
|
getCurrentUser(session));
|
|
|
|
|
// 设置申请提交成功的提示信息,并返回消息提示页面的模型视图
|
|
|
|
|
return ViewMode.getInstance().setError("已经提交加入请求,请等待管理员审核!")
|
|
|
|
|
.returnModelAndView(ThemesUtil.getThemePath() + "/message");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|