package cn.dinner.action;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import net.sf.json.JSONObject;
import net.sf.json.JsonConfig;
import net.sf.json.util.CycleDetectionStrategy;
import net.sf.json.util.PropertyFilter;
import org.apache.commons.io.IOUtils;
import org.apache.struts2.ServletActionContext;
import org.springframework.beans.factory.annotation.Autowired;
import cn.dinner.entity.Menu;
import cn.dinner.entity.MenuType;
import cn.dinner.service.MenuTypeservice;
import cn.dinner.service.Menuservice;
import cn.dinner.util.MenuCond;
import cn.dinner.util.Page;
public class MenuAction {
/**
* 所需属性
*/
@Autowired
private Menuservice menuservice;
// 分页条件
private Page pageUtil;
private Integer page;
private Integer limit;
private JSONObject menujson;
// 查询条件
private String m_name;
private Integer m_type;
/**
* 分页获取数据
*
* @return success
*/
public String getAllMenu() {
MenuCond cond = new MenuCond();
if (m_name != null && !m_name.equals("")) {
cond.setM_name("%" + m_name + "%");
}
if (m_type != null && m_type != -1) {
cond.setM_type(m_type);
}
pageUtil = new Page();
pageUtil.setPageIndex(page);
pageUtil.setPageSize(limit);
List<Menu> menuList = menuservice.menuList(pageUtil, cond);
Map<String, Object> map = new HashMap<String, Object>();
map.put("code", 0);
map.put("msg", "");
map.put("count", pageUtil.getCount());
map.put("data", menuList);
JsonConfig config = new JsonConfig();
config.setIgnoreDefaultExcludes(false);
config.setJsonPropertyFilter(new PropertyFilter() {
@Override
//第一个是Object类型的,是你要过滤的属性的类型;第二个参数是String类型,是你要过滤的属性的名称;第三个参数是Object类型的,是你要过滤的属性的值
public boolean apply(Object obj, String name, Object val) {
if (name.equals("menuList")) {
return true;
} else {
return false;
}
}
});
menujson = JSONObject.fromObject(map,config);
System.out.println(menujson);
return "success";
}
private MenuTypeservice menuTypeservice;
// 添加条件
private String mname;
private Integer mprice;
private Integer typeid;
private String remark;
// 上传的文件
private File upload;
// 文件类型
private String uploadContentType;
// 文件名
private String uploadFileName;
/**
* 添加菜谱
*
* @throws IOException
*/
public void AddMenu() throws IOException {
PrintWriter out = ServletActionContext.getResponse().getWriter();
// 截取后缀名
String ext = uploadFileName.substring(uploadFileName.lastIndexOf("."));
// 重新定义图片名称
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
uploadFileName = sdf.format(new Date()).toString() + ext;
MenuType mtype = menuTypeservice.getOne(typeid);
Menu menu = new Menu(mtype, mname, mprice, uploadFileName, remark);
int res = menuservice.AddMenu(menu);
if (res > 0) {
// 输入流
FileInputStream fis = new FileInputStream(this.upload);
// 真实路径
String path = ServletActionContext.getServletContext().getRealPath(
"/upload");
// 输出流
FileOutputStream fos = new FileOutputStream(path + "//"
+ this.uploadFileName);
IOUtils.copy(fis, fos);
// 关闭
fis.close();
fos.close();
out.print("<script>alert('添加成功');location.href='showcaipu';</script>");
} else {
out.print("<script>alert('添加失败');location.href='showAddcaipu';</script>");
}
}
// 获取要修改的信息条件
private Integer getUpMenuInfoid;
private Menu updateMenuInfo;
private List<MenuType> mtlist;
/**
* 获取要修改的信息条件
*/
public String getgetUpMenuInfo() {
updateMenuInfo = menuservice.getMenuByid(getUpMenuInfoid);
mtlist = menuTypeservice.getAllMenuType();
return "success";
}
// 修改信息条件
private String oldimagePath;
private Integer menuid;
/**
* 修改菜谱信息
*
* @throws IOException
*/
public void UpdateMenu() throws IOException {
PrintWriter out = ServletActionContext.getResponse().getWriter();
// 截取后缀名
String ext = uploadFileName.substring(uploadFileName.lastIndexOf("."));
// 重新定义图片名称
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
uploadFileName = sdf.format(new Date()).toString() + ext;
System.out.println("原图片名字"+oldimagePath);
MenuType mtype = menuTypeservice.getOne(typeid);
Menu menu = new Menu(menuid,mtype, mname, mprice, uploadFileName, remark);
int res = menuservice.updateMenu(menu);
if (res > 0) {
// 输入流
FileInputStream fis = new FileInputStream(this.upload);
// 真实路径
String path = ServletActionContext.getServletContext().getRealPath(
"/upload");
// 输出流
FileOutputStream fos = new FileOutputStream(path + "//"
+ this.uploadFileName);
IOUtils.copy(fis, fos);
// 关闭
fis.close();
fos.close();
new File(path +"\\"+ oldimagePath).delete();
out.print("<script>alert('修改成功');location.href='showcaipu';</script>");
} else {
out.print("<script>alert('修改失败');location.href='getUpdateMenuInfo?getUpMenuInfoid="+menuid+"';</script>");
}
}
// 删除条件
private Integer delid;
private String imgpath;
/**
* 删除方法
*
* @return
* @throws IOException
*/
public void delMenu() throws IOException {
PrintWriter out = ServletActionContext.getResponse().getWriter();
int res = menuservice.delMenu(delid);
if (res > 0) {
if (imgpath != null || !imgpath.equals("") || !imgpath.equals("无")) {
String path = ServletActionContext.getServletContext()
.getRealPath("/upload");
String delimgpath = path + "\\" + imgpath;
new File(delimgpath).delete();
}
}
out.print(res);
}
// 封装
public Menuservice getMenuservice() {
return menuservice;
}
public void setMenuservice(Menuservice menuservice) {
this.menuservice = menuservice;
}
public Integer getMenuid() {
return menuid;
}
public void setMenuid(Integer menuid) {
this.menuid = menuid;
}
public Page getPageUtil() {
return pageUtil;
}
public void setPageUtil(Page pageUtil) {
this.pageUtil = pageUtil;
}
public Integer getPage() {
return page;
}
public void setPage(Integer page) {
this.page = page;
}
public String getImgpath() {
return imgpath;
}
public void setImgpath(String imgpath) {
this.imgpath = imgpath;
}
public Integer getLimit() {
return limit;
}
public void setLimit(Integer limit) {
this.limit = limit;
}
public String getM_name() {
return m_name;
}
public void setM_name(String m_name) {
this.m_name = m_name;
}
public Integer getM_type() {
return m_type;
}
public void setM_type(Integer m_type) {
this.m_type = m_type;
}
public JSONObject getMenujson() {
return menujson;
}
public void setMenujson(JSONObject menujson) {
this.menujson = menujson;
}
public File getUpload() {
return upload;
}
public void setUpload(File upload) {
this.upload = upload;
}
public String getUploadContentType() {
return uploadContentType;
}
public void setUploadContentType(String uploadContentType) {
this.uploadContentType = uploadContentType;
}
public String getUploadFileName() {
return uploadFileName;
}
public void setUploadFileName(String uploadFileName) {
this.uploadFileName = uploadFileName;
}
public String getMname() {
return mname;
}
public void setMname(String mname) {
this.mname = mname;
}
public Inte
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
一个前台结算,前台点餐,后台综合信息管理,后厨配菜的完整项目 部署说明: 1.创建mysql数据库,数据库名称为dinner,导入数据建表语句 2.项目导入IDEA或Eclipse开发工具,修改数据连接配置文件DinnerRoom/resource/applicationContext.xml中数据库连接配置(22-26行) 4将项目放入web容器(tomcat)中启动 运行环境 Eclispse/Idea+JDK1.8+Mysql+Tomcat8 项目技术 Spring+Struts+hibernate+Bootstrap+Jquery 前台账户:lisi lisi 后台账户:admin admin 点餐页面:http://localhost:8080/DinnerRoom/diancan 后台登录页面:http://localhost:8080/DinnerRoom/login.jsp 后厨配菜页面:http://localhost:8080/DinnerRoom/houchu.jsp
资源推荐
资源详情
资源评论
收起资源包目录
一个前台结算,前台点餐,后台综合信息管理,后厨配菜的完整项目 (629个子文件)
MenuAction.class 11KB
UsersAction.class 11KB
QianTaiAction.class 10KB
DinnerOrderDaoImpl.class 9KB
MemberAction.class 8KB
DianCanAction.class 6KB
DiningTableAction.class 6KB
MenuTypeAction.class 5KB
UsersDaoImpl.class 5KB
MemberTypeAction.class 5KB
DinnerOrderAction.class 5KB
DiningTableDaoImpl.class 5KB
MemberDaoImpl.class 5KB
MenuDaoImpl.class 4KB
MenuTypeDaoImpl.class 4KB
MemberTypeDaoImpl.class 4KB
HouChuActionn.class 3KB
HomeAction.class 3KB
DiningTableserviceImpl.class 3KB
Users.class 3KB
UsersserviceImpl.class 3KB
DinnerOrderserviceImpl.class 3KB
MemberserviceImpl.class 3KB
DinnerOrder.class 2KB
MemberTypeserviceImpl.class 2KB
MenuserviceImpl.class 2KB
Menu.class 2KB
MenuTypeserviceImpl.class 2KB
DinnerNoticeDaoImpl.class 2KB
Member.class 2KB
LogAndExcepion.class 2KB
DinnerNotice.class 2KB
DinnerNoticeAction.class 2KB
DinnerNoticeserviceImpl.class 2KB
DiningTable.class 2KB
MenuType.class 1KB
DinnerOrderCond.class 1KB
UserInterceptor.class 1KB
Page.class 1KB
SessionCounter.class 1KB
DinnerPc.class 1KB
UserCond.class 935B
MenuTypeAction$1.class 934B
MemberType.class 914B
MenuAction$1.class 904B
DiningTableservice.class 843B
DiningTableDao.class 831B
MemberCond.class 815B
DinnerOrderservice.class 796B
Memberservice.class 796B
MenuCond.class 794B
DinnerOrderDao.class 784B
MemberDao.class 784B
Usersservice.class 754B
UsersDao.class 742B
MemberTypeservice.class 646B
Menuservice.class 638B
MemberTypeDao.class 634B
MenuDao.class 626B
MenuTypeservice.class 614B
MenuTypeDao.class 602B
DinnerNoticeservice.class 405B
DinnerNoticeDao.class 393B
.classpath 11KB
org.eclipse.wst.common.component 559B
org.eclipse.wst.jsdt.ui.superType.container 49B
bootstrap.css 143KB
bootstrap.css 143KB
bootstrap.min.css 118KB
bootstrap.min.css 118KB
layui.css 52KB
layui.css 52KB
bootstrap-theme.css 26KB
bootstrap-theme.css 26KB
bootstrap-theme.min.css 23KB
bootstrap-theme.min.css 23KB
messenger-theme-future.css 16KB
layer.css 15KB
layer.css 14KB
layer.css 14KB
messenger-theme-flat.css 10KB
messenger-theme-air.css 10KB
layui.mobile.css 10KB
layui.mobile.css 10KB
laydate.css 9KB
laydate.css 7KB
laydate.css 7KB
messenger-theme-ice.css 4KB
messenger-theme-block.css 4KB
messenger-spinner.css 4KB
messenger.css 3KB
demo.css 3KB
component.css 2KB
style.css 2KB
normalize.css 2KB
iconfont.css 2KB
mobile.css 2KB
code.css 1KB
code.css 1KB
demo.css 553B
共 629 条
- 1
- 2
- 3
- 4
- 5
- 6
- 7
资源评论
- 二月月2022-11-10#运行顺畅 #内容详尽
- IlIlIlIlIlIlIlIlIl6952023-12-18资源内容详实,描述详尽,解决了我的问题,受益匪浅,学到了。
a123560mh
- 粉丝: 60
- 资源: 134
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 信息办公个人求职管理系统-jobgljsp.rar
- 信息办公一流网络JSP网络管理系统 v1.0-yljsp10.rar
- chirpstack学习
- 管家婆辉煌、财贸、工贸、服装,食品,千方模拟狗
- 基于python开发的工业环境老鼠检测+源码+文档(毕业设计&课程设计&项目开发)
- USB转以太网的芯片SR9900全套设计资料包括(参考设计原理图PCB+ Linux -Windows驱动程序+量产工具)
- 信息办公XML考试系统-xmlks.rar
- 基于python开发的无人机图像目标检测+实验数据+开发文档+操作流程+源码(毕业设计&课程设计&项目开发)
- 全球智能商品管理与优化系统
- IDM下载器(电脑小工具)
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功