/*
* Generated by MyEclipse Struts
* Template path: templates/java/JavaClass.vtl
*/
package com.aptech.jb.epet.web.action;
import java.io.IOException;
import java.io.PrintWriter;
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.action.ActionMessage;
import org.apache.struts.action.ActionMessages;
import org.apache.struts.actions.DispatchAction;
import com.aptech.jb.epet.biz.PetInfoBiz;
import com.aptech.jb.epet.biz.impl.PetInfoBizImpl;
import com.aptech.jb.epet.entity.PetInfo;
import com.aptech.jb.epet.web.form.PetForm;
/**
* MyEclipse Struts Creation date: 02-14-2011
*
* XDoclet definition:
*
* @struts.action validate="true"
*/
public class PetAction extends DispatchAction {
/*
* Generated Methods
*/
/**
* Method execute
*
* @param mapping
* @param form
* @param request
* @param response
* @return ActionForward
* @throws IOException
*/
public ActionForward doLogin(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws IOException {
PetForm petForm = (PetForm) form;
String petId = String.valueOf(petForm.getItem().getPetId());
String petPassword = petForm.getItem().getPetPassword();
String vcode = request.getParameter("item.petVcode");
PetInfoBiz biz = new PetInfoBizImpl();
PetInfo petInfo = biz.login(petId, petPassword);
if (!vcode.equals(request.getSession().getAttribute("vcode"))) {
ActionMessages errors = new ActionMessages();
errors.add("login", new ActionMessage("error.login.wrong_vcode"));
super.saveErrors(request, errors);
return mapping.findForward("fail");
}
if (petInfo != null) {
request.getSession(true).setAttribute("CURRENT_PET", petInfo);
// this.showBaby(mapping, dynaForm, request, response);
response.sendRedirect("pet.do?id=" + petId+"&operate=showBaby");
return null;
} else {
ActionMessages errors = new ActionMessages();
errors.add("login",
new ActionMessage("error.login.wrong_id_or_pwd"));
super.saveErrors(request, errors);
return mapping.findForward("fail");
}
}
public ActionForward doFeed(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws IOException {
String petId = request.getParameter("petId");
PetInfoBiz biz = new PetInfoBizImpl();
biz.doFeed(Integer.parseInt(petId));
response.sendRedirect("pet.do?id=" + petId+"&operate=showBaby");
return null;
}
public ActionForward doGame(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws IOException {
String petId = request.getParameter("petId");
PetInfoBiz biz = new PetInfoBizImpl();
biz.doGame(Integer.parseInt(petId));
response.sendRedirect("pet.do?id=" + petId+"&operate=showBaby");
return null;
}
public ActionForward doStory(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws IOException {
String petId = request.getParameter("petId");
PetInfoBiz biz = new PetInfoBizImpl();
biz.doStory(Integer.parseInt(petId));
response.sendRedirect("pet.do?id=" + petId+"&operate=showBaby");
return null;
}
public ActionForward showBaby(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
//PetDiaryBiz pdb=new PetDiaryBizImpl();
String id =request.getParameter("id");
String error = "";
if (null == id || "".equals(id)) {
request.setAttribute("error", "没有指定宠物编号");
return mapping.findForward("error");
}
Integer petId = Integer.valueOf(id);
//List diaryList=pdb.getListByPet(petId);
PetInfoBiz biz = new PetInfoBizImpl();
PetInfo petInfo = biz.load(petId);
if (null == petInfo) {
request.setAttribute("error", "没有指定编号的宠物记录");
return mapping.findForward("error");
}
request.setAttribute("item", petInfo);
//request.setAttribute("diaryList", diaryList);
return mapping.findForward("petInfo");
}
public ActionForward toEditPet(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
String id = request.getParameter("petId");
String error = "";
if (null == id || "".equals(id)) {
request.setAttribute("error", "没有指定宠物编号");
return mapping.findForward("error");
}
Integer petId = Integer.valueOf(id);
PetInfoBiz biz = new PetInfoBizImpl();
PetInfo petInfo = biz.load(petId);
if (null == petInfo) {
request.setAttribute("error", "没有指定编号的宠物记录");
return mapping.findForward("error");
}
request.setAttribute("item", petInfo);
return mapping.findForward("update");
}
public ActionForward doEditPet(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws IOException {
PetForm petForm = (PetForm) form;
String name = petForm.getItem().getPetName();
String email = petForm.getItem().getPetOwnerEmail();
String intro = petForm.getItem().getPetIntro();
int petId = Integer.parseInt(request.getParameter("id"));
PetInfoBiz pib = new PetInfoBizImpl();
PetInfo pet = pib.load(Integer.valueOf(petId));
pet.setPetId(Integer.valueOf(petId));
pet.setPetName(name);
pet.setPetOwnerEmail(email);
pet.setPetIntro(intro);
int num = pib.updatePet(pet);
if (num > 0) {
// request.getRequestDispatcher("jsp/pet/petInfo.jsp").forward(request,
// response);
response.sendRedirect("pet.do?id=" + petId+"&operate=showBaby");
} else {
request.setAttribute("error", "更新失败");
return mapping.findForward("error");
}
return null;
}
public ActionForward toList(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
PetInfoBiz pib=new PetInfoBizImpl();
PetForm petForm=(PetForm) form;
List list=pib.search(petForm.getCondition(), petForm.getOrderBy());
if(list!=null &&list.size()>0){
request.setAttribute("list", list);
return mapping.findForward("list");
}else{
request.setAttribute("error", "没有宠物记录");
return mapping.findForward("error");
}
}
public ActionForward doAdopt(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
PetForm petForm = (PetForm) form;// TODO Auto-generated method stub
if(petForm.getItem().getPetName()==null){
return mapping.findForward("adopt");
}
PetInfo item=petForm.getItem();
PetInfoBiz pib=new PetInfoBizImpl();
pib.adopt(item);
try {
response.setContentType("text/html;charset=GBK");
PrintWriter out = response.getWriter();
out.print("<script>alert('宠物ID:"+item.getPetId()+"');location.href='pet.do?id="+item.getPetId()+"&operate=showBaby'</script>");
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
public ActionForward doDel(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws IOException {
int petId = Integer.parseInt(request.getParameter("id"));
PetInfoBiz pib = new PetInfoBizImpl();
int num = pib.del(petId);
if (num > 0) {
// request.getSession().setAttribute("CURRENT_PET",null);
response.sendRedirect("jsp/pet/index.jsp");
} else {
request.setAttribute("error", "删除失败");
return mapping.findForward("error");
}
return null;
}
}
![avatar](https://profile-avatar.csdnimg.cn/default.jpg!1)
chenglinjava
- 粉丝: 2
- 资源: 2
最新资源
- 探究动态渗透率模型下的天然气水合物降压开采:深度数值模拟分析与研究,探究动态渗透率模型下的天然气水合物降压开采:精细数值模拟与分析研究,基于动态渗透率模型的天然气水合物降压开采数值模拟研究 ,基于动态
- 基于动态渗透率模型下的天然气水合物降压开采过程数值模拟研究:探索开采策略与影响因素分析,基于动态渗透率模型与数值模拟的天然气水合物降压开采技术研究与应用分析,基于动态渗透率模型的天然气水合物降压开采数
- 煤层开挖过程与邻近煤岩层应力变形场变化及保护层效应研究模型,煤层开挖过程应力变形场变化及瓦斯流动弹塑性模型研究,煤层工作开挖过程,会引起邻近煤岩层应力、变形场发生变化,以及引起临近煤层卸压,从而达到保
- 电气安全专业基础-.pdf
- 利用PID控制器模拟智能控温建筑房间温度-Simulink在MATLAB中的实现及详细pdf介绍,基于Simulink的MATLAB环境的PID控制器模拟,实现对房间温度的精准控制附带详细pdf介绍
- 一个用 c 语言编写的学生成绩管理系统源码
- STM32微控制器的入门教程,涵盖基础知识、开发环境搭建、常用功能实现及学习路径
- 直流电机双闭环调速控制系统仿真模型:转速与电流双闭环PI控制研究及Matlab Simulink应用报告,直流电机双闭环调速控制系统仿真模型研究:转速与电流双闭环PI控制算法的探索与实践(基于Matl
- 基于Matlab Simulink的四机两区域与IEEE 39节点系统短路故障分析与潮流计算研究,基于Matlab Simulink的四机两区域与IEEE 39节点系统短路故障分析与潮流计算研究,Ma
- 一个用 c 语言编写的链表实现栈的源码
- VSG并联技术详解:专业讲解视频带你深入了解其运作原理与实际应用,VSG并联技术详解:专业讲解视频带你深入了解并联运行原理与操作应用,VSG并联,有对应讲解视频 ,VSG并联; 对应讲解视频; 电力技
- 健康评分主要受运动频率、胆固醇水平和年龄的影响
- 2000-2019年上市公司银企关系数据.xls
- Matlab Simulink下的双馈风机风电调频技术研究:含虚拟惯性惯量控制与下垂控制,快速仿真达20秒,基于MATLAB Simulink的双馈风机风电调频技术:包含虚拟惯性惯量与下垂控制策略的快
- 基于煤层渗透扩散特性消除的煤与瓦斯气固耦合模型研究:建立修正P-M渗透率模型与多物理场耦合关系分析,煤层瓦斯渗透扩散的深部采煤影响与煤固气耦合模型的构建与应用研究,立足于消除煤层渗透及扩散特性对于煤与
- Matlab Simulink下的风光火储联合调频系统:混合储能优化与等值系统分析,风电三相电压电流离散模型仿真研究,Matlab Simulink下的风光火储联合调频系统:混合储能优化与等值系统分析
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
![feedback](https://img-home.csdnimg.cn/images/20220527035711.png)
![feedback](https://img-home.csdnimg.cn/images/20220527035711.png)
![feedback-tip](https://img-home.csdnimg.cn/images/20220527035111.png)