⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 questionfirstkindaction.java

📁 企业人力资源管理
💻 JAVA
字号:
package com.y2.hr.config.questionfirstkind.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.questionfirstkind.bean.ConfigQuestionFirstKind;
import com.y2.hr.config.questionfirstkind.web.form.QuestionFirstKindForm;

public class QuestionFirstKindAction extends BaseAction {
	/**
	 * Method execute 职位分类的添加
	 * 
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return ActionForward
	 */
	public ActionForward doAdd(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {
		QuestionFirstKindForm questionFirstKindForm = (QuestionFirstKindForm) form;
		String msg = null;
		if ("".equals(questionFirstKindForm.getFirstKindName())) {
			msg = "新添试题一级设置输入信息不允许为空!";
		} else {
			ConfigQuestionFirstKind questionFirstKind = new ConfigQuestionFirstKind();
			try {
				BeanUtils.copyProperties(questionFirstKind,
						questionFirstKindForm);
			} catch (Exception e) {
				e.printStackTrace();
			}
			if (this.questionFirstKindBiz.add(questionFirstKind)) {
				return mapping.findForward("config_msg_ok");
			} else {
				msg = "试题一级设置新添失败!";
			}
		}
		request.setAttribute("msg", msg);
		return mapping.findForward("config_msg_error");
	}

	/**
	 * Method execute 职位分类页面中的跳转
	 * 
	 * @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);
		}
		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.questionFirstKindBiz.sum();
			curPage = 1;
		}
		request.setAttribute("count", count);
		request.setAttribute("curPage", curPage);
		request.setAttribute("questionfirstlist", this.questionFirstKindBiz
				.getPage(curPage));
	}

	/**
	 * Method execute 职位分类删除操作
	 * 
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return ActionForward
	 */
	public ActionForward doDel(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {
		String qfkId = request.getParameter("qfkId");
		String firstKindId = request.getParameter("firstKindId");
		String msg = null;
		if (this.questionSecondKindBiz.isQuestionFirstKindId(firstKindId)) {
			msg = "该一级试题不能删除,可能存在二级试题引用!";
		} else {
			ConfigQuestionFirstKind firstKind = new ConfigQuestionFirstKind();
			firstKind.setQfkId((short) Integer.parseInt(qfkId));
			if (this.questionFirstKindBiz.del(firstKind)) {
				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 + -