/**
*
*/
package org.ourlife.restrant.web.action;
import java.util.ArrayList;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
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.ourlife.restrant.biz.FTypeBiz;
import org.ourlife.restrant.biz.FoodBiz;
import org.ourlife.restrant.biz.RestrantBiz;
import org.ourlife.restrant.entity.FType;
import org.ourlife.restrant.entity.LRestrant;
import org.ourlife.restrant.entity.RFood;
import org.ourlife.restrant.web.form.FoodForm;
/**
* @author L@H
*
*/
public class FoodAction extends DispatchAction {
/*
* Generated Methods
*/
private FoodBiz foodBiz = null;
private RestrantBiz restrantBiz = null;
private FTypeBiz typeBiz = null;
/**
* 显示餐品类型列表
* @param mapping
* @param form
* @param request
* @param response
* @return
*/
public ActionForward doShowFTypeList(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
// TODO 显示餐品列表
//创建session
HttpSession session = request.getSession(true);
//若用户没有登陆则直接跳到登陆页面
if(session.getAttribute("user") == null){
return mapping.findForward("login");
}
//所有的餐品类型
List<FType> allTypes = typeBiz.getAllFTypes();
//得到餐厅编号
int restrantId = new Integer( request.getParameter("RestrantID") );
//得到餐厅
LRestrant restrant = restrantBiz.getRestrantDetail(restrantId);
//得到餐厅的餐品信息转化为餐品列表
Object[] foodListObj = restrant.getFoods().toArray();
List<RFood> foodList = new ArrayList<RFood>();
for(int i = 0; i < foodListObj.length; i++){
foodList.add((RFood)foodListObj[i]);
}
//得到餐厅经营的所有餐品类型
List<FType> typeList = new ArrayList<FType>();
for(int i = 0; i < allTypes.size(); i++){
for(int j = 0; j < foodList.size(); j++){
int typeId = foodList.get(j).getType().getTypeId();
int typeIdAll = allTypes.get(i).getTypeId();
if(typeId == typeIdAll){
typeList.add(allTypes.get(i));
break;
}
}
}
//得到第一个餐品类型的餐品信息
int currentTypeId = typeList.get(0).getTypeId();
List<RFood> foodListByType = new ArrayList<RFood>();
if(typeList.size() > 0){
for(int i = 0; i < foodList.size(); i++){
RFood food = (RFood)foodList.get(i);
int typeId = food.getType().getTypeId();
if(currentTypeId == typeId){
foodListByType.add(food);
}
}
}
//将餐品列表保存到request中
session.setAttribute("RestrantDetail", restrant);
session.setAttribute("FoodTypeList", typeList);
session.setAttribute("FoodList", foodList);
session.setAttribute("CurrentTypeId", currentTypeId);
session.setAttribute("FoodListByType", foodListByType);
//将请求转发至逻辑名为"food"的页面
ActionForward af = mapping.findForward("food");
return af;
}
/**
* 显示相应餐品类型的餐品列表
* @param mapping
* @param form
* @param request
* @param response
* @return
*/
public ActionForward doShowFoodListByType(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
// TODO 显示餐品列表
//创建session
HttpSession session = request.getSession(true);
//得到餐品类型编号
int typeId = new Integer( request.getParameter("TypeID") );
//得到餐厅的餐品信息
List<RFood> foodList = (List<RFood>)session.getAttribute("FoodList");
//得到该餐品类型的餐品信息
List<RFood> foodListByType = new ArrayList<RFood>();
for(int i = 0; i < foodList.size(); i++){
RFood food = foodList.get(i);
int currentType = food.getType().getTypeId();
if(currentType == typeId)
foodListByType.add(food);
}
//将餐品列表保存到request中
session.setAttribute("FoodListByType", foodListByType);
session.setAttribute("CurrentTypeId", typeId);
//将请求转发至逻辑名为"food"的页面
ActionForward af = mapping.findForward("food");
return af;
}
/**
* 显示餐品的详细信息
* @param mapping
* @param form
* @param request
* @param response
* @return
*/
public ActionForward doShowFoodDetail(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
// TODO 显示餐厅列表
//得到编号
String foodId = request.getParameter("FoodId") ;
//得到餐厅的详细信息
RFood food = foodBiz.getFoodDetail(foodId);
//将餐厅列表保存到request中
request.setAttribute("Food", food);
//将请求转发至逻辑名为"food"的页面
ActionForward af = mapping.findForward("food");
return af;
}
/**
* 搜索餐品
* @param mapping
* @param form
* @param request
* @param response
* @return
*/
public ActionForward doSearchFood(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
// TODO 显示餐厅列表
//创建session
HttpSession session = request.getSession(true);
//获取表单数据
FoodForm searchForm = (FoodForm)form;
LRestrant restrant = (LRestrant)session.getAttribute("RestrantDetail");
//得到餐品列表
List<RFood> foodList = foodBiz.searchFood(restrant.getResId(), searchForm.getFood());
//所有的餐品类型
List<FType> allTypes = typeBiz.getAllFTypes();
//得到餐厅经营的所有餐品类型
List<FType> typeList = new ArrayList<FType>();
for(int i = 0; i < allTypes.size(); i++){
for(int j = 0; j < foodList.size(); j++){
int typeId = foodList.get(j).getType().getTypeId();
int typeIdAll = allTypes.get(i).getTypeId();
if(typeId == typeIdAll){
typeList.add(allTypes.get(i));
break;
}
}
}
//得到第一个餐品类型的餐品信息
int currentTypeId = 0;
List<RFood> foodListByType = new ArrayList<RFood>();
if(typeList.size() > 0){
currentTypeId = typeList.get(0).getTypeId();
for(int i = 0; i < foodList.size(); i++){
RFood food = (RFood)foodList.get(i);
int typeId = food.getType().getTypeId();
if(currentTypeId == typeId){
foodListByType.add(food);
}
}
}
//将餐品列表保存到request中
session.setAttribute("RestrantDetail", restrant);
session.setAttribute("FoodTypeList", typeList);
session.setAttribute("FoodList", foodList);
session.setAttribute("CurrentTypeId", currentTypeId);
session.setAttribute("FoodListByType", foodListByType);
//将请求转发至逻辑名为"restrant"的页面
ActionForward af = mapping.findForward("food");
return af;
}
public void setFoodBiz(FoodBiz foodBiz){
this.foodBiz = foodBiz;
}
public void setRestrantBiz(RestrantBiz restrantBiz){
this.restrantBiz = restrantBiz;
}
public void setTypeBiz(FTypeBiz typeBiz){
this.typeBiz = typeBiz;
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
spring+struts+hibernate+ajax订餐网站源码
共409个文件
class:94个
java:94个
jpg:55个
4星 · 超过85%的资源 需积分: 9 71 下载量 137 浏览量
2010-06-18
14:48:52
上传
评论 3
收藏 10.45MB RAR 举报
温馨提示
用struts,hibernate,spring,ajax + sqlServer2005 做的订餐网站,可用于连锁餐厅,前台包括选餐厅,选菜,订餐,后台包括餐厅的管理,餐厅内部的订单,人员管理
资源推荐
资源详情
资源评论
收起资源包目录
spring+struts+hibernate+ajax订餐网站源码 (409个子文件)
BaseHibernateDao.class 7KB
FoodAction.class 6KB
OrderAction.class 6KB
LUser.class 6KB
LRestrant.class 5KB
PaginationTag.class 5KB
LUserBizImpl.class 5KB
RestrantAction.class 4KB
OrderBizImpl.class 4KB
ROrderDaoImpl.class 4KB
UserAction.class 4KB
FoodBizImpl.class 4KB
LManagerBizImpl.class 4KB
LRestrantDaoImpl.class 4KB
ROrder.class 4KB
CheckCode.class 4KB
RFoodDaoImpl.class 4KB
LManager.class 4KB
RestrantBizImpl.class 4KB
BTopic.class 4KB
REmployee.class 4KB
ManagerAction.class 4KB
CartAction.class 3KB
CartBizImpl.class 3KB
RFood.class 3KB
Cart.class 3KB
LManagerDaoImpl.class 3KB
ResService.class 3KB
LNews.class 3KB
LUserDaoImpl.class 3KB
BBoard.class 3KB
HibernateSessionFactory.class 2KB
BReply.class 2KB
Test.class 2KB
OItem.class 2KB
LHouse.class 2KB
PageResult.class 2KB
MTypeDaoImpl.class 2KB
UTypeDaoImpl.class 2KB
FTypeDaoImpl.class 2KB
UDetail.class 2KB
RType.class 2KB
MType.class 2KB
RTypeDaoImpl.class 2KB
FType.class 2KB
HType.class 2KB
NType.class 2KB
UType.class 2KB
REmployeeDaoImpl.class 2KB
BaseBiz.class 2KB
UserForm.class 2KB
SerialNumBase.class 2KB
OrderForm.class 1KB
MTypeBizImpl.class 1KB
RTypeBizImpl.class 1KB
BTopicDaoImpl.class 1KB
EmployeeForm.class 1KB
OItemDaoImpl.class 1KB
ROrderDao.class 1017B
RestrantForm.class 1011B
CartBiz.class 1002B
MyRequestProcessor.class 988B
FoodForm.class 971B
EmployeeBizImpl.class 965B
LogAdvice.class 901B
BReplyDaoImpl.class 893B
BBoardDaoImpl.class 892B
LRestrantDao.class 889B
RFoodDao.class 839B
FTypeBizImpl.class 814B
BaseForm.class 782B
LUserBiz.class 766B
OItemForm.class 760B
ManagerForm.class 757B
RestrantBiz.class 742B
LManagerDao.class 733B
LUserDao.class 694B
OrderBiz.class 680B
Utils.class 667B
LManagerBiz.class 574B
FoodBiz.class 572B
RTypeDao.class 504B
FTypeDao.class 504B
MTypeDao.class 489B
UTypeDao.class 479B
MTypeBiz.class 426B
BTopicDao.class 424B
REmployeeDao.class 364B
RTypeBiz.class 330B
BReplyDao.class 307B
BBoardDao.class 306B
EmployeeBiz.class 244B
FTypeBiz.class 244B
OItemDao.class 219B
.classpath 3KB
org.eclipse.wst.jsdt.ui.superType.container 49B
ddlevelsmenu-base.css 1KB
ddlevelsmenu-sidebar.css 1KB
style.css 1KB
ddlevelsmenu-topbar.css 795B
共 409 条
- 1
- 2
- 3
- 4
- 5
资源评论
- wxd2482012-08-15太简单了 不适用
- lointo2013-12-14练习之作,仅供参考
- 心安即是归处12012-05-15这个代码还是太简单了哈
- dlutls2013-09-14可惜是Myeclipse工程
QQ170224387
- 粉丝: 2
- 资源: 8
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功