OrgAction.java
资源名称:oa.rar [点击查看]
上传用户:kimgenplus
上传日期:2016-06-05
资源大小:20877k
文件大小:3k
源码类别:
OA系统
开发平台:
Java
- package com.bjsxt.oa.web.actions;
- import javax.servlet.http.HttpServletRequest;
- import javax.servlet.http.HttpServletResponse;
- 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 com.bjsxt.oa.managers.OrgManager;
- import com.bjsxt.oa.model.Organization;
- import com.bjsxt.oa.web.forms.OrgActionForm;
- public class OrgAction extends BaseAction {
- private OrgManager orgManager;
- /**
- * 打开机构管理主界面
- */
- @Override
- protected ActionForward unspecified(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
- OrgActionForm oaf = (OrgActionForm)form;
- request.setAttribute("pm",
- orgManager.findOrgs(oaf.getParentId())
- );
- //
- int ppid = 0;
- if(oaf.getParentId() != 0){
- Organization org = orgManager.findOrg(oaf.getParentId());
- Organization parent = org.getParent();
- if(parent != null){
- ppid = parent.getId();
- }
- }
- request.setAttribute("ppid", ppid);
- if(oaf.isSelect()){
- return mapping.findForward("select");
- }
- return mapping.findForward("index");
- }
- /**
- * 打开机构管理录入界面
- * @param mapping
- * @param form
- * @param request
- * @param response
- * @return
- * @throws Exception
- */
- public ActionForward addInput(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
- return mapping.findForward("add_input");
- }
- //添加机构信息
- public ActionForward add(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
- OrgActionForm oaf = (OrgActionForm)form;
- int parentId = oaf.getParentId();
- Organization org = new Organization();
- BeanUtils.copyProperties(org, oaf);
- orgManager.addOrg(org, parentId);
- return mapping.findForward("pub_add_success");
- }
- //删除机构信息
- public ActionForward del(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
- OrgActionForm oaf = (OrgActionForm)form;
- int id = oaf.getId();
- // try{
- orgManager.delOrg(id);
- // }catch(Exception e){
- // ActionMessages msgs = new ActionMessages();
- //
- // ActionMessage msg = new ActionMessage("errors.detail",e.getMessage());
- //
- // msgs.add("detail", msg);
- //
- // this.saveErrors(request, msgs);
- //
- // return mapping.findForward("exception");
- // }
- return mapping.findForward("pub_del_success");
- }
- public void setOrgManager(OrgManager orgManager) {
- this.orgManager = orgManager;
- }
- }