📄 b01e6291ca2a001d1f1386824b2f4361
字号:
/**
*
*/
package com.qrsx.qrsxcrm.action;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.beanutils.BeanUtils;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import com.qrsx.qrsxcrm.dao.DeptDAO;
import com.qrsx.qrsxcrm.model.Dept;
/**
* 部门业务处理类
* @author Administrator
*
*/
public class DeptAction extends BaseDispatchAction
{
@SuppressWarnings("unchecked")
public ActionForward save(ActionMapping mapping,ActionForm form ,HttpServletRequest request,HttpServletResponse response)throws Exception{
// ActionErrors errors=form.validate(mapping,request);
// if(!errors.isEmpty()){
// saveErrors(request,errors);
// return edit(mapping,form,request,response);
// }
Dept dept=new Dept();
BeanUtils.copyProperties(dept,form);
DeptDAO deptDao=new DeptDAO(clazz);
if( dept.getId()==null||dept.getId().trim().length()==0 ){
deptDao.create(dept);
saveMessage(request,"create" ,dept.getDeptName());
}
else{
deptDao.update(dept);
saveMessage(request,"update",dept.getDeptName());
}
return mapping.findForward("success");
}
public ActionForward list(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws Exception{
Dept dept=new Dept();
BeanUtils.copyProperties(dept,form);
//String page=request.getParameter("requestPage");
DeptDAO deptDao=new DeptDAO(clazz);
List<Dept> list=deptDao.lists(dept);
// System.out.println(dept.getDeptName());
// System.out.println(dept.getDeptId());
// System.out.println(list.size());
// System.out.println(list.get(0));
request.setAttribute("depts",list);
return mapping.findForward("list");
}
public ActionForward edit(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws Exception{
String id=request.getParameter("id");
if(id!=null&&id.trim().length()>0){
DeptDAO deptDao=new DeptDAO(clazz);
Dept dept =(Dept) deptDao.findById( Dept.class, id);
if (dept!=null){
BeanUtils.copyProperties(form,dept);
}
}
return mapping.findForward("edit");
}
@SuppressWarnings("unchecked")
public ActionForward delete(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws Exception{
String id=request.getParameter("id");
DeptDAO deptDao=new DeptDAO(clazz);
Dept dept =(Dept) deptDao.findById( Dept.class, id);
deptDao.delete(dept);
return mapping.findForward("success");
}
public ActionForward info(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws Exception{
String id=request.getParameter("id");
if(id!=null&&id.trim().length()>0){
DeptDAO deptDao=new DeptDAO(clazz);
Dept dept =(Dept) deptDao.findById( Dept.class, id);
if (dept!=null){
BeanUtils.copyProperties(form,dept);
}
}
return mapping.findForward("edit");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -