首页>代码>java Struts+Hibernate企业人力资源管理系统源代码下载>/rencaiSystem/src/com/sanqing/action/JobAction.java
package com.sanqing.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.hibernate.HibernateException;

import com.sanqing.dao.JobDao;
import com.sanqing.po.Job;

public class JobAction extends Action {
    private JobDao dao=new JobDao();
    public ActionForward execute(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response) throws Exception {

        String action =request.getParameter("action");
        System.out.println("\nJobAction*********************action="+action);
        if(action==null||"".equals(action)){
            return mapping.findForward("error");
        }else if("listjob".equals(action)){
            return listJob(mapping,form,request,response);
        }else if("addjob".equals(action)){
            return addJob(mapping,form,request,response);
        }else if("deletejob".equals(action)){
            return deleteJob(mapping,form,request,response);
        }else if("updatejob".equals(action)){
            return updateJob(mapping,form,request,response);
        }else if("detailjob".equals(action)){
            return detailjob(mapping,form,request,response);
        }
        return mapping.findForward("error");
    }

	private ActionForward detailjob(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response){
		Long id=new Long(request.getParameter("id"));//获得参数id
		Job j=dao.loadJob(id.longValue());//加载该ID对应的应聘信息
		request.setAttribute("job",j);//将应聘信息对象设置到request范围
		return mapping.findForward("success");
	}

    private ActionForward updateJob(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response){
        JobForm jobform=(JobForm)form;
        Job j=jobform.populate();
        dao.updateJob(j);
        return mapping.findForward("success");
    }

	private ActionForward deleteJob(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response){
	    Long id=new Long(request.getParameter("id"));//接受id参数
	    Job j=new Job();//新建一个Job对象
	    j.setId(id);//设置其id属性
	    dao.deleteJob(j);//调用dao对象完成Job对象的删除
	    return mapping.findForward("success");
	}

	private ActionForward addJob(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response){
	    JobForm jobform=(JobForm)form;//获得JobForm
	    Job job=jobform.populate();//获得表单提交的应聘信息
	    dao.addJob(job);//调用DAO完成应聘信息的保存
	    return mapping.findForward("success");//跳转到success逻辑视图
	}

	private ActionForward listJob(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response){
	    String isstock=request.getParameter("isstock");//获得isstock参数
	    if(isstock==null||"".equals(isstock)){//如果isstock为null或者为空
	        request.setAttribute("list",
	        		dao.listJob(new Byte("0").byteValue()));//查询所有没入库的应聘信息
	    }else{
	        request.setAttribute("list",
	        		dao.listJob(new Byte("1").byteValue()));//查询所有入库的应聘信息
	    }
	    return mapping.findForward("success");
	}
}
最近下载更多
qfch120  LV8 2023年3月29日
wuying8208  LV15 2023年1月1日
yuanjuntao  LV5 2022年7月5日
2297542298  LV2 2022年1月11日
1637947149  LV3 2021年11月20日
lucky金  LV3 2021年8月26日
Qolmen  LV12 2021年7月20日
吴峰123456  LV4 2021年7月13日
Demo1111  LV30 2021年6月7日
Crush  LV3 2021年5月10日
最近浏览更多
123456wadff  LV3 1月15日
Henew168  LV2 2023年11月19日
2036495585  LV9 2023年9月25日
zhangyanghao 2023年9月21日
暂无贡献等级
王王王229  LV1 2023年9月3日
8战魂5无双8  LV43 2023年8月20日
qixiansheng  LV1 2023年5月19日
592321444  LV2 2023年5月19日
王泰浩 2023年5月10日
暂无贡献等级
hjbobo6  LV3 2023年5月8日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友