package com.oa.action;
import java.util.List;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import org.apache.struts2.interceptor.ServletRequestAware;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import com.oa.Service.OrgIService;
import com.oa.po.Organazition;
import com.oa.po.PagerModel;
import com.opensymphony.xwork2.ActionSupport;
@Component("org")
@Scope("prototype")
public class OrgAction extends ActionSupport implements ServletRequestAware{
private OrgIService orgIService;
//作为父节点显示子节点
private int jgId;
//返回时的ID
private int backId;
//存储Organazition的list
private List<Organazition> orgList;
//存储Organazition的对象
private Organazition organazition;
private HttpServletRequest request;
private PagerModel pager=new PagerModel();
/**
* 返回jsp页面 获取parentId
* @return
*/
public String searchParentId(){
return "addPage";
}
/**
* 添加Organazition
* @return
*/
public String saveOrganazition(){
this.orgIService.saveOrganazition(organazition);
return "pub_add_success";
}
/**
* 删除Organazition
* @return
*/
public String delOrganazition() throws RuntimeException{
try{
this.orgIService.delOrganazition(jgId);
}catch(RuntimeException e){
request.setAttribute("errorMessage", e.getMessage());
return "pub_del_error";
}
return "pub_del_success";
}
/**
* 更新Organazition
* @return
*/
public String updateOrganazition(){
this.orgIService.updateOrganazition(organazition);
return "pub_update_success";
}
/**
* 查询一条记录
* @return
*/
public String findOneRecord(){
organazition=this.orgIService.findOneRecord(jgId);
return "search";
}
/**
* 分页 当点父节点时 返回按钮赋值
* @param jgId
* @return
*/
public String searchNextOrgs() {
int offset=0;
try {
offset=Integer.parseInt(request.getParameter("pager.offset").toString());
} catch (Exception ignore) {
}
backId=this.orgIService.nextBackId(jgId);
pager=this.orgIService.searchNextOrgs(jgId,offset);
return "next";
}
/**
* 分页 当点返回时 返回按钮赋值
* @param jgId
* @return
*/
public String searchBackOrgs() {
int offset=0;
try {
offset=Integer.parseInt(request.getParameter("pager.offset").toString());
} catch (Exception ignore) {
}
backId=this.orgIService.backBackId(backId);
pager=this.orgIService.searchBackOrgs(offset,backId);
return "back";
}
/**
* 分页 查询机构(人员管理查询页面)
* @param jgId
* @return
*/
public String personSearchOrgs() {
int offset=0;
try {
offset=Integer.parseInt(request.getParameter("pager.offset").toString());
} catch (Exception ignore) {
}
backId=this.orgIService.nextBackId(jgId);
pager=this.orgIService.searchNextOrgs(jgId,offset);
return "personSearchOrgs";
}
/**
* 分页 当点返回时 返回按钮赋值(人员管理查询页面)
* @param jgId
* @return
*/
public String personSearchBackOrgs() {
int offset=0;
try {
offset=Integer.parseInt(request.getParameter("pager.offset").toString());
} catch (Exception ignore) {
}
backId=this.orgIService.backBackId(backId);
pager=this.orgIService.searchBackOrgs(offset,backId);
return "personSearchBackOrgs";
}
public OrgIService getOrgIService() {
return orgIService;
}
@Resource
public void setOrgIService(OrgIService orgIService) {
this.orgIService = orgIService;
}
public int getJgId() {
return jgId;
}
public void setJgId(int jgId) {
this.jgId = jgId;
}
public List<Organazition> getOrgList() {
return orgList;
}
public void setOrgList(List<Organazition> orgList) {
this.orgList = orgList;
}
public int getBackId() {
return backId;
}
public void setBackId(int backId) {
this.backId = backId;
}
public Organazition getOrganazition() {
return organazition;
}
public void setOrganazition(Organazition organazition) {
this.organazition = organazition;
}
public void setServletRequest(HttpServletRequest request) {
this.request=request;
}
public PagerModel getPager() {
return pager;
}
public void setPager(PagerModel pager) {
this.pager = pager;
}
}