📄 userinfoaction.java
字号:
/*
* Generated by MyEclipse Struts
* Template path: templates/java/JavaClass.vtl
*/
package org.lxh.myzngt.struts.action;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.actions.DispatchAction;
import org.lxh.myzngt.dao.IAnswerDAO;
import org.lxh.myzngt.dao.IQuestionDAO;
import org.lxh.myzngt.dao.IUserDAO;
import org.lxh.myzngt.vo.Question;
/**
* MyEclipse Struts Creation date: 07-02-2007
*
* XDoclet definition:
*
* @struts.action path="/userinfo" name="userinfoForm"
* input="/form/userinfo.jsp" parameter="status" scope="request"
* validate="true"
*/
public class UserinfoAction extends DispatchAction {
private IQuestionDAO iquestiondao;
private IAnswerDAO ianswerdao;
private IUserDAO iuserdao;
/*
* Generated Methods
*/
/**
* Method execute
*
* @param mapping
* @param form
* @param request
* @param response
* @return ActionForward
*/
public ActionForward listquestion(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
List all = null;
int currentPage = 1;
int lineSize = 10;
int allRecorders = 0;
try {
currentPage = Integer.parseInt(request.getParameter("cp"));
} catch (Exception e) {
}
try {
allRecorders = this.iquestiondao.getByUseridCount((String) request
.getSession().getAttribute("userid"));
all = this.iquestiondao.queryByUserId((String) request.getSession()
.getAttribute("userid"), currentPage, lineSize);
} catch (NumberFormatException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
request.setAttribute("currentPage", currentPage);
request.setAttribute("lineSize", lineSize);
request.setAttribute("allRecorders", allRecorders);
request.setAttribute("all", all);
request.setAttribute("jspUrl", "userinfo.do");
request.setAttribute("status", "listquestion");
return mapping.findForward("listmyquestion");
}
public ActionForward listanswer(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
int qid = 0;
Question q = null;
try {
qid = Integer.parseInt(request.getParameter("qid"));
q = this.iquestiondao.queryById(qid);
request.setAttribute("question", q);
} catch (Exception e) {
System.out.println(e);
}
return mapping.findForward("listanswer");
}
public ActionForward listquestionanswer(ActionMapping mapping,
ActionForm form, HttpServletRequest request,
HttpServletResponse response) {
List all = null;
int currentPage = 1;
int lineSize = 10;
int allRecorders = 0;
try {
currentPage = Integer.parseInt(request.getParameter("cp"));
} catch (Exception e) {
}
try {
String userid = (String) request.getSession()
.getAttribute("userid");
allRecorders = this.iquestiondao.getByUserAnswer(userid);
all = this.iquestiondao.queryByUserAnswer(userid, currentPage,
lineSize);
// System.out.println("** "+userid) ;
// System.out.println("** "+allRecorders);
// System.out.println("** "+all) ;
} catch (NumberFormatException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
request.setAttribute("currentPage", currentPage);
request.setAttribute("lineSize", lineSize);
request.setAttribute("allRecorders", allRecorders);
request.setAttribute("all", all);
request.setAttribute("jspUrl", "userinfo.do");
request.setAttribute("status", "listquestionanswer");
return mapping.findForward("listmyquestionanswer");
}
public ActionForward listaccept(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
List all = null;
int currentPage = 1;
int lineSize = 10;
int allRecorders = 0;
try {
currentPage = Integer.parseInt(request.getParameter("cp"));
} catch (Exception e) {
}
try {
String userid = (String) request.getSession()
.getAttribute("userid");
allRecorders = this.iquestiondao.getByAccept(userid, 1);
all = this.iquestiondao.queryByAccept(userid, 1, currentPage,
lineSize);
} catch (NumberFormatException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
request.setAttribute("currentPage", currentPage);
request.setAttribute("lineSize", lineSize);
request.setAttribute("allRecorders", allRecorders);
request.setAttribute("all", all);
request.setAttribute("jspUrl", "userinfo.do");
request.setAttribute("status", "listaccept");
return mapping.findForward("listmyaccept");
}
public ActionForward acceptanswer(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
// 更新answer表,使status=1
int aid = 0;
int offerscore = 0;
String uid = request.getParameter("uid");
try {
offerscore = Integer.parseInt(request.getParameter("offerscore"));
aid = Integer.parseInt(request.getParameter("aid"));
} catch (Exception e) {
}
try {
this.iuserdao.addIntegral(uid, offerscore);
this.ianswerdao.updateStatus(aid, 1);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return mapping.findForward("answerdo");
}
public ActionForward acceptquestion(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
// 已经采纳够答案:accpetflag = 1
int qid = 0;
try {
qid = Integer.parseInt(request.getParameter("qid")) ;
this.iquestiondao.updateAccept(qid, 1) ;
} catch (Exception e) {
}
return mapping.findForward("updatequestiondo");
}
// 问题已解决
public ActionForward questiondo(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
// status = 2
int qid = 0;
try {
qid = Integer.parseInt(request.getParameter("qid")) ;
this.iquestiondao.updateStatus(qid, 2) ;
} catch (Exception e) {
}
return mapping.findForward("updatequestiondo");
}
// 无满意答案
public ActionForward questionno(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
// status=3
int qid = 0;
try {
qid = Integer.parseInt(request.getParameter("qid")) ;
this.iquestiondao.updateStatus(qid, 3) ;
} catch (Exception e) {
}
return mapping.findForward("updatequestiondo");
}
public IQuestionDAO getIquestiondao() {
return iquestiondao;
}
public void setIquestiondao(IQuestionDAO iquestiondao) {
this.iquestiondao = iquestiondao;
}
public IAnswerDAO getIanswerdao() {
return ianswerdao;
}
public void setIanswerdao(IAnswerDAO ianswerdao) {
this.ianswerdao = ianswerdao;
}
public IUserDAO getIuserdao() {
return iuserdao;
}
public void setIuserdao(IUserDAO iuserdao) {
this.iuserdao = iuserdao;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -