BlacklistAction.java
资源名称:(J2EE)oa.rar [点击查看]
上传用户:lm2018
上传日期:2015-12-12
资源大小:30449k
文件大小:3k
源码类别:
Jsp/Servlet
开发平台:
Java
- //Created by MyEclipse Struts
- // XSL source (default): platform:/plugin/com.genuitec.eclipse.cross.easystruts.eclipse_4.1.0/xslt/JavaClass.xsl
- package com.oa.module.email.action;
- import java.lang.reflect.InvocationTargetException;
- import javax.servlet.http.HttpServletRequest;
- import javax.servlet.http.HttpServletResponse;
- import javax.servlet.http.HttpSession;
- import org.apache.commons.beanutils.BeanUtils;
- import org.apache.struts.action.ActionForm;
- import org.apache.struts.action.ActionForward;
- import org.apache.struts.action.ActionMapping;
- import org.apache.struts.actions.DispatchAction;
- import com.oa.module.email.bean.BlackListBean;
- import com.oa.module.email.blacklistform.BlacklistForm;
- import com.oa.module.email.dao.BlackListDao;
- import com.oa.module.office.user.Tuser;
- import com.oa.util.XPage;
- /**
- * 黑名单ACTION
- * MyEclipse Struts Creation date: 01-25-2008
- *
- * XDoclet definition:
- *
- * @struts.action path="/blacklist" name="blacklistForm" parameter="method"
- * scope="request" validate="true"
- */
- public class BlacklistAction extends DispatchAction {
- private BlackListDao dao;
- // --------------------------------------------------------- Instance
- // Variables
- // --------------------------------------------------------- Methods
- /**
- * 获取黑名单用户
- *
- * @param mapping
- * @param form
- * @param request
- * @param response
- * @return ActionForward
- */
- public ActionForward blackList(ActionMapping mapping, ActionForm form,
- HttpServletRequest request, HttpServletResponse response) {
- BlacklistForm blacklistForm = (BlacklistForm) form;
- String cpage = request.getParameter("currentPage");
- int currentPage = 1;
- try {
- currentPage = Integer.parseInt(cpage);
- } catch (Exception e) {
- currentPage = 1;
- }
- int count = 10;
- HttpSession session = request.getSession();
- Tuser user = (Tuser)session.getAttribute("user");
- String id = user.getUno();
- XPage page = dao.getBlackList(currentPage, count ,id);
- request.setAttribute("page", page);
- return mapping.findForward("blacklist");
- }
- /**
- * 修改用户状态
- * @param mapping
- * @param form
- * @param request
- * @param response
- * @return
- */
- public ActionForward upload(ActionMapping mapping, ActionForm form,
- HttpServletRequest request, HttpServletResponse response) {
- BlacklistForm blacklistForm = (BlacklistForm) form;
- String isblack= request.getParameter("isBlackList");
- if(isblack!=null && isblack.trim().equals("1")){
- //是黑名单里的用户 从黑名单中删除
- boolean flag = dao.delFromBlackList(request.getParameter("blackuserid"));
- return mapping.findForward("go");
- }else if(isblack!=null && isblack.trim().equals("0")){
- //加入黑名单
- BlackListBean bean = new BlackListBean();
- try {
- BeanUtils.copyProperties(bean, blacklistForm);
- } catch (IllegalAccessException e) {
- // TODO 自动生成 catch 块
- e.printStackTrace();
- } catch (InvocationTargetException e) {
- // TODO 自动生成 catch 块
- e.printStackTrace();
- }
- /**
- * 改成登录用户
- */
- HttpSession session = request.getSession();
- Tuser user = (Tuser)session.getAttribute("user");
- bean.setUserid(user.getUno());
- boolean falg = dao.addToBlackList(bean);
- return mapping.findForward("go");
- }
- return null;
- }
- public BlackListDao getDao() {
- return dao;
- }
- public void setDao(BlackListDao dao) {
- this.dao = dao;
- }
- }