首页>代码>s2sh(struts2+spring+hibernate)框架搭建人力资源网站后台管理系统>/chen-hrms/src/main/java/com/hrms/action/DeptAction.java
                
                package com.hrms.action;
import java.util.List;
import javax.annotation.Resource;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import com.hrms.model.Dept;
import com.hrms.model.Employee;
import com.hrms.service.IDeptService;
import com.hrms.service.IEmployeeService;
import com.hrms.util.Page;
@Component("deptAction")
@Scope("prototype")
public class DeptAction extends BaseAction {
	private static final long serialVersionUID = 3927204414255792182L;
	private Dept dept;
	private Dept parentDept;
	private Integer deptId;
	private List<Dept> depts;
	private IDeptService deptService;
	private IEmployeeService employeeService;
	private Page page;
	private int currentPage=1;
	
	public String dept_list() {
		int totalSzie = deptService.getSize();
		this.page = new Page(currentPage, totalSzie);
		depts = deptService.getListByPage(currentPage, page.getPageSize());
		getSession().setAttribute("depts", depts);
		return "success";
	}
	public String dept_add() {
		String addAction = getRequest().getParameter("addAction");
		if (addAction==null) {
			List<Employee> employees = employeeService.findAll();
			getRequest().setAttribute("employees", employees);
			return "add";
		}
		Integer parentDeptId = deptId;
		dept.setDeptId(null);
		dept.setParentDept(deptService.findById(parentDeptId));
		deptService.saveOrUpdate(dept);
		if(addAction!=null && addAction.equals("2")) {
			return "adds";
		} 
		return "success";
	}
	public String dept_update() {
		String update = getRequest().getParameter("update");
		if(update != null && update.equals("update")) {
			String selParentDeptId = getRequest().getParameter("selParentDept");
			Integer parentDeptId;
			if (selParentDeptId != null && !selParentDeptId.equals("")) {
				parentDeptId= Integer.valueOf(selParentDeptId);
				dept.setParentDept(deptService.findById(parentDeptId));
			}
			deptService.update(dept);
			return "success";
		}else if(deptId != null) {
			List<Employee> employees = employeeService.findAll();
			getRequest().setAttribute("employees", employees);
			dept = deptService.findById(deptId);
			String deptMan = dept.getDeptMan();
			getRequest().setAttribute("deptMan", deptMan);
			parentDept = dept.getParentDept();
			return "update";
		} else {
			return "error";
		}
		
	}
	public String dept_delete() {
		deptService.deleteById(getDeptId());
		return "success";
	}
	
	public Dept getDept() {
		return dept;
	}
	public void setDept(Dept dept) {
		this.dept = dept;
	}
	public List<Dept> getDepts() {
		return depts;
	}
	public void setDepts(List<Dept> depts) {
		this.depts = depts;
	}
	public IDeptService getDeptService() {
		return deptService;
	}
	@Resource
	public void setDeptService(IDeptService deptService) {
		this.deptService = deptService;
	}
	public Page getPage() {
		return page;
	}
	public void setPage(Page page) {
		this.page = page;
	}
	public int getCurrentPage() {
		return currentPage;
	}
	public void setCurrentPage(int currentPage) {
		this.currentPage = currentPage;
	}
	public Integer getDeptId() {
		return deptId;
	}
	public void setDeptId(Integer deptId) {
		this.deptId = deptId;
	}
	public Dept getParentDept() {
		return parentDept;
	}
	public void setParentDept(Dept parentDept) {
		this.parentDept = parentDept;
	}
	public IEmployeeService getEmployeeService() {
		return employeeService;
	}
	@Resource
	public void setEmployeeService(IEmployeeService employeeService) {
		this.employeeService = employeeService;
	}
}
 最近下载更多
最近下载更多
                
                AOAO1234     LV2
                2024年12月24日
            
            
        
                sunlea     LV20
                2024年5月17日
            
            
        
                BruceQ     LV14
                2023年5月10日
            
            
        
                chentianqi     LV5
                2023年3月27日
            
            
        
                lcqlcl     LV11
                2023年3月27日
            
            
        
                sweetbox     LV10
                2023年2月27日
            
            
        
                sweetlove     LV20
                2022年11月28日
            
            
        
                yuanjuntao     LV5
                2022年7月5日
            
            
        
                Hugo_0901     LV5
                2022年4月27日
            
            
        
                wanglinddad     LV55
                2022年3月1日
            
            
         最近浏览更多
最近浏览更多
                
                AOAO1234     LV2
                2024年12月24日
            
            
        
                微信网友_7290593889931264    
                2024年12月10日
            
            
                    暂无贡献等级
            
        
                xs13883100     LV1
                2024年5月15日
            
            
        
                sunlea     LV20
                2024年5月9日
            
            
        
                hmf1989    
                2024年4月29日
            
            
                    暂无贡献等级
            
        
                123456wadff     LV3
                2024年1月15日
            
            
        
                WBelong     LV8
                2023年12月27日
            
            
        
                3501855841    
                2023年12月22日
            
            
                    暂无贡献等级
            
        
                 dsadasdwf     LV12
                2023年10月23日
            
            
        
                haotzy     LV3
                2023年10月8日
            
            
        
 
                 
                 
    