📄 filesecondkindaction.java
字号:
package com.y2.hr.config.filesecondkind.web.action;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.beanutils.BeanUtils;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import com.y2.hr.base.web.action.BaseAction;
import com.y2.hr.config.filesecondkind.bean.ConfigFileSecondKind;
import com.y2.hr.config.filesecondkind.web.form.FileSecondKindForm;
public class FileSecondKindAction extends BaseAction {
/**
* Method execute I级机构的添加
*
* @param mapping
* @param form
* @param request
* @param response
* @return ActionForward
*/
public ActionForward doAdd(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
FileSecondKindForm fileSecondKindForm = (FileSecondKindForm) form;
String msg = null;
if ("".equals(fileSecondKindForm.getFirstKindName())
|| "".equals(fileSecondKindForm.getSecondKindName())
|| "".equals(fileSecondKindForm.getSecondKindSalaryId())
|| "".equals(fileSecondKindForm.getSecondKindSaleId())) {
msg = "新添二级机构时输入信息不允许为空!";
} else {
ConfigFileSecondKind fileSecondKind = new ConfigFileSecondKind();
try {
BeanUtils.copyProperties(fileSecondKind, fileSecondKindForm);
} catch (Exception e) {
e.printStackTrace();
}
if (this.fileSecondKindBiz.add(fileSecondKind)) {
return mapping.findForward("config_msg_ok");
} else {
msg = "新添二级机构时失败!";
}
}
request.setAttribute("msg", msg);
return mapping.findForward("config_msg_error");
}
/**
* Method execute I级机构页面中的跳转
*
* @param mapping
* @param form
* @param request
* @param response
* @return ActionForward
*/
public ActionForward toUrl(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
String url = request.getParameter("url");
if ("success".equals(url)) {
this.showPage(request, 0, 0);
} else if ("add".equals(url)) {
request.setAttribute("firstlist", this.fileFirstKindBiz
.getFirstKind());
}
return mapping.findForward(url);
}
/**
* 分页处理
*
* @param mapping
* @param form
* @param request
* @param response
* @return
*/
public ActionForward doPage(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
int count = Integer.parseInt(request.getParameter("count"));
int curPage = Integer.parseInt(request.getParameter("curPage"));
this.showPage(request, count, curPage);
return mapping.findForward("success");
}
/**
* 封装分页
*
* @param request
* @param count
* @param curPage
*/
private void showPage(HttpServletRequest request, int count, int curPage) {
if (0 == count && 0 == curPage) {
count = this.fileSecondKindBiz.sum();
curPage = 1;
}
request.setAttribute("count", count);
request.setAttribute("curPage", curPage);
request.setAttribute("secondlist", this.fileSecondKindBiz
.getPage(curPage));
}
/**
* Method execute I级构修改页面的跳转
*
* @param mapping
* @param form
* @param request
* @param response
* @return ActionForward
*/
public ActionForward toMod(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
FileSecondKindForm fileSecondKindForm = (FileSecondKindForm) form;
String fskId = request.getParameter("fskId");
ConfigFileSecondKind fileSecondKind = this.fileSecondKindBiz
.getSecondKind(fskId);
try {
BeanUtils.copyProperties(fileSecondKindForm, fileSecondKind);
} catch (Exception e) {
e.printStackTrace();
}
return mapping.findForward("mod");
}
/**
* Method execute I级机构修改操作
*
* @param mapping
* @param form
* @param request
* @param response
* @return ActionForward
*/
public ActionForward doMod(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
FileSecondKindForm fileSecondKindForm = (FileSecondKindForm) form;
String msg = null;
if ("".equals(fileSecondKindForm.getFirstKindName())
|| "".equals(fileSecondKindForm.getSecondKindName())
|| "".equals(fileSecondKindForm.getSecondKindSalaryId())
|| "".equals(fileSecondKindForm.getSecondKindSaleId())) {
msg = "修改二级机构时输入信息不允许为空!";
} else {
ConfigFileSecondKind fileSecondKind = new ConfigFileSecondKind();
try {
BeanUtils.copyProperties(fileSecondKind, fileSecondKindForm);
} catch (Exception e) {
e.printStackTrace();
}
if (this.fileSecondKindBiz.mod(fileSecondKind)) {
return mapping.findForward("config_msg_ok");
} else {
msg = "修改二级机构时失败!";
}
}
request.setAttribute("msg", msg);
return mapping.findForward("config_msg_error");
}
/**
* Method execute I级机构删除操作
*
* @param mapping
* @param form
* @param request
* @param response
* @return ActionForward
*/
public ActionForward doDel(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
String fskId = request.getParameter("fskId");
String secondKindId = request.getParameter("secondKindId");
String msg = null;
if (this.fileThirdKindBiz.isSecond(secondKindId)) {
msg = "该二级下存在可能存在三级机构的引用,不能被删除!";
} else {
ConfigFileSecondKind secondKind = new ConfigFileSecondKind();
secondKind.setFskId((short) Integer.parseInt(fskId));
if (this.fileSecondKindBiz.del(secondKind)) {
return mapping.findForward("config_msg_ok");
} else {
msg = "二级机构删除失败!";
}
}
request.setAttribute("msg", msg);
return mapping.findForward("config_msg_error");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -