package oa.action;

import java.util.List;


import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.opensymphony.xwork2.ActionContext;

import oa.Utils.DepartmentUtils;
import oa.domain.Department;

@Controller
@Scope("prototype")
public class DepartmentAction  extends ModelDrivenBaseAction<Department>{
	private Long parentId;
	public String list(){
		List<Department> departmentList=null;
		if(parentId==null){
			departmentList=departmentService.findTopList();
		}
		else{
			departmentList=departmentService.findChildren(parentId);
			Department parent = departmentService.findById(parentId);
			ActionContext.getContext().put("parent", parent);
		}
		ActionContext.getContext().put("departmentList", departmentList);
		return "list";
	}
	public String save(){
		model.setParent(departmentService.findById(parentId));
		departmentService.save(model);
		return "tolist";
	}
	public String saveUI(){
		List<Department> topList=departmentService.findTopList();
		List<Department> departmentList=DepartmentUtils.getAllDepartments(topList);
		ActionContext.getContext().put("departmentList", departmentList);
		return "saveUI";
	}
	public String editUI(){
		List<Department> topList=departmentService.findTopList();
		List<Department> departmentList=DepartmentUtils.getAllDepartments(topList);
		ActionContext.getContext().put("departmentList", departmentList);
		Department department=departmentService.findById(model.getId());
		ActionContext.getContext().getValueStack().push(department);
		if (department.getParent() != null) {
			parentId = department.getParent().getId();
		}
		return "editUI";
	}
	public String delete(){
		departmentService.delete(model.getId());
		return "tolist";
	}
	public String update(){
		model.setParent(departmentService.findById(parentId));
		departmentService.update(model);
		return "tolist";
	}
	public Long getParentId() {
		return parentId;
	}
	public void setParentId(Long parentId) {
		this.parentId = parentId;
	}
}
最近下载更多
lironggang  LV38 2023年11月30日
朱俪的邮件及存储  LV8 2023年1月28日
微信网友_6115804675756032  LV7 2022年12月3日
wanglinddad  LV54 2022年3月9日
and123456  LV11 2022年2月19日
xiaohe229  LV8 2021年8月9日
Demo1111  LV30 2021年3月15日
有糖吃的面面  LV3 2021年2月25日
aaa5849310  LV25 2020年9月4日
ASDZXZCDGSDFHUJD  LV9 2020年5月13日
最近浏览更多
m5433661  LV2 3月28日
123456wadff  LV3 1月15日
lironggang  LV38 2023年11月30日
2036495585  LV9 2023年9月25日
暂无贡献等级
微信网友_6467077197238272  LV1 2023年5月8日
uni-code_0123  LV1 2023年3月31日
朱俪的邮件及存储  LV8 2023年1月15日
微信网友_6115804675756032  LV7 2022年12月3日
gaoxuyang  LV8 2022年10月20日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友