BlacklistAction.java
上传用户:lm2018
上传日期:2015-12-12
资源大小:30449k
文件大小:3k
源码类别:

Jsp/Servlet

开发平台:

Java

  1. //Created by MyEclipse Struts
  2. // XSL source (default): platform:/plugin/com.genuitec.eclipse.cross.easystruts.eclipse_4.1.0/xslt/JavaClass.xsl
  3. package com.oa.module.email.action;
  4. import java.lang.reflect.InvocationTargetException;
  5. import javax.servlet.http.HttpServletRequest;
  6. import javax.servlet.http.HttpServletResponse;
  7. import javax.servlet.http.HttpSession;
  8. import org.apache.commons.beanutils.BeanUtils;
  9. import org.apache.struts.action.ActionForm;
  10. import org.apache.struts.action.ActionForward;
  11. import org.apache.struts.action.ActionMapping;
  12. import org.apache.struts.actions.DispatchAction;
  13. import com.oa.module.email.bean.BlackListBean;
  14. import com.oa.module.email.blacklistform.BlacklistForm;
  15. import com.oa.module.email.dao.BlackListDao;
  16. import com.oa.module.office.user.Tuser;
  17. import com.oa.util.XPage;
  18. /**
  19.  * 黑名单ACTION
  20.  * MyEclipse Struts Creation date: 01-25-2008
  21.  * 
  22.  * XDoclet definition:
  23.  * 
  24.  * @struts.action path="/blacklist" name="blacklistForm" parameter="method"
  25.  *                scope="request" validate="true"
  26.  */
  27. public class BlacklistAction extends DispatchAction {
  28. private BlackListDao dao;
  29. // --------------------------------------------------------- Instance
  30. // Variables
  31. // --------------------------------------------------------- Methods
  32. /**
  33.  * 获取黑名单用户
  34.  * 
  35.  * @param mapping
  36.  * @param form
  37.  * @param request
  38.  * @param response
  39.  * @return ActionForward
  40.  */
  41. public ActionForward blackList(ActionMapping mapping, ActionForm form,
  42. HttpServletRequest request, HttpServletResponse response) {
  43. BlacklistForm blacklistForm = (BlacklistForm) form;
  44. String cpage = request.getParameter("currentPage");
  45. int currentPage = 1;
  46. try {
  47. currentPage = Integer.parseInt(cpage);
  48. } catch (Exception e) {
  49. currentPage = 1;
  50. }
  51. int count = 10;
  52. HttpSession session = request.getSession();
  53. Tuser user = (Tuser)session.getAttribute("user");
  54. String id = user.getUno();
  55. XPage page = dao.getBlackList(currentPage, count ,id);
  56. request.setAttribute("page", page);
  57. return mapping.findForward("blacklist");
  58. }
  59. /**
  60.  * 修改用户状态
  61.  * @param mapping
  62.  * @param form
  63.  * @param request
  64.  * @param response
  65.  * @return
  66.  */
  67. public ActionForward upload(ActionMapping mapping, ActionForm form,
  68. HttpServletRequest request, HttpServletResponse response) {
  69. BlacklistForm blacklistForm = (BlacklistForm) form;
  70. String isblack= request.getParameter("isBlackList");
  71. if(isblack!=null && isblack.trim().equals("1")){
  72. //是黑名单里的用户 从黑名单中删除
  73. boolean flag = dao.delFromBlackList(request.getParameter("blackuserid"));
  74. return mapping.findForward("go");
  75. }else if(isblack!=null && isblack.trim().equals("0")){
  76. //加入黑名单
  77. BlackListBean bean = new BlackListBean();
  78. try {
  79. BeanUtils.copyProperties(bean, blacklistForm);
  80. } catch (IllegalAccessException e) {
  81. // TODO 自动生成 catch 块
  82. e.printStackTrace();
  83. } catch (InvocationTargetException e) {
  84. // TODO 自动生成 catch 块
  85. e.printStackTrace();
  86. }
  87. /**
  88.  * 改成登录用户
  89.  */
  90. HttpSession session = request.getSession();
  91. Tuser user = (Tuser)session.getAttribute("user");
  92. bean.setUserid(user.getUno());
  93. boolean falg = dao.addToBlackList(bean);
  94. return mapping.findForward("go");
  95. }
  96. return null;
  97. }
  98. public BlackListDao getDao() {
  99. return dao;
  100. }
  101. public void setDao(BlackListDao dao) {
  102. this.dao = dao;
  103. }
  104. }