餐厅点菜管理系统的设计与实现
网络技术和计算机技术发展至今,已经拥有了深厚的理论基础,并在现实中进行了充分运用,尤其是基于计算机运行的软件更是受到各界的关注。加上现在人们已经步入信息时代,所以对于信息的宣传和管理就很关键。因此餐厅点菜信息的管理计算机化,系统化是必要的。设计开发餐厅点菜管理系统不仅会节约人力和管理成本,还会安全保存庞大的数据量,对于餐厅点菜信息的维护和检索也不需要花费很多时间,非常的便利。
餐厅点菜管理系统是在MySQL中建立数据表保存信息,运用Vue框架和Java语言编写。并按照软件设计开发流程进行设计实现。系统具备友好性且功能完善。其管理员管理食物库存,菜品信息,管理预订和未预定餐桌,管理店内订单流水以及外卖订单。用户查看餐厅资讯,收藏菜品,下单购买菜品,查看外卖订单,用户也可以在餐厅内预订餐桌,对菜品进行点餐,查看店内订单记录。
餐厅点菜管理系统在让餐厅点菜信息规范化的同时,也能及时通过数据输入的有效性规则检测出错误数据,让数据的录入达到准确性的目的,进而提升餐厅点菜管理系统提供的数据的可靠性,让系统数据的错误率降至最低。
Java SSM餐厅点餐系统,后端基于SSM框架进行开发,前端页面效果通过使用vue进行编码实现,主要将实现用户跟管理员角色,实现了菜品展示管理、外卖订单管理等功能。
package com.controller;
import java.util.*;
import javax.servlet.http.HttpServletRequest;
import com.entity.YudingcanzhuoEntity;
import com.service.YudingcanzhuoService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.entity.CanzhuoEntity;
import com.service.CanzhuoService;
import com.utils.PageUtils;
import com.utils.R;
/**
* 餐桌表
* 后端接口
* @author
* @email
* @date 2021-03-08
*/
@RestController
@Controller
@RequestMapping("/canzhuo")
public class CanzhuoController {
private static final Logger logger = LoggerFactory.getLogger(CanzhuoController.class);
@Autowired
private CanzhuoService canzhuoService;
@Autowired
private YudingcanzhuoService yudingcanzhuoService;
/**
* 后端列表
*/
@RequestMapping("/page")
public R page(@RequestParam Map<String, Object> params){
logger.debug("Controller:"+this.getClass().getName()+",page方法");
PageUtils page = canzhuoService.queryPage(params);
return R.ok().put("data", page);
}
/**
* 后端详情
*/
@RequestMapping("/info/{id}")
public R info(@PathVariable("id") Long id){
logger.debug("Controller:"+this.getClass().getName()+",info方法");
CanzhuoEntity canzhuo = canzhuoService.selectById(id);
if(canzhuo!=null){
return R.ok().put("data", canzhuo);
}else {
return R.error(511,"查不到数据");
}
}
/**
* 后端保存
*/
@RequestMapping("/save")
public R save(@RequestBody CanzhuoEntity canzhuo, HttpServletRequest request){
logger.debug("Controller:"+this.getClass().getName()+",save");
Wrapper<CanzhuoEntity> queryWrapper = new EntityWrapper<CanzhuoEntity>()
.eq("name", canzhuo.getName())
.eq("tableLocation", canzhuo.getTableLocation())
;
logger.info("sql语句:"+queryWrapper.getSqlSegment());
CanzhuoEntity canzhuoEntity = canzhuoService.selectOne(queryWrapper);
if(canzhuoEntity==null){
canzhuo.setSfTypes(2);
canzhuoService.insert(canzhuo);
return R.ok();
}else {
return R.error(511,"表中有相同数据");
}
}
/**
* 修改
*/
@RequestMapping("/update")
public R update(@RequestBody CanzhuoEntity canzhuo, HttpServletRequest request){
logger.debug("Controller:"+this.getClass().getName()+",update");
//根据字段查询是否有相同数据
Wrapper<CanzhuoEntity> queryWrapper = new EntityWrapper<CanzhuoEntity>()
.notIn("id",canzhuo.getId())
.eq("name", canzhuo.getName())
.eq("tableLocation", canzhuo.getTableLocation())
.eq("sf_types", canzhuo.getSfTypes())
;
logger.info("sql语句:"+queryWrapper.getSqlSegment());
CanzhuoEntity canzhuoEntity = canzhuoService.selectOne(queryWrapper);
if(canzhuoEntity==null){
canzhuoService.updateById(canzhuo);//根据id更新
return R.ok();
}else {
return R.error(511,"表中有相同数据");
}
}
/**
* 删除
*/
@RequestMapping("/delete")
public R delete(@RequestBody Long[] ids){
logger.debug("Controller:"+this.getClass().getName()+",delete");
canzhuoService.deleteBatchIds(Arrays.asList(ids));
return R.ok();
}
/**
* 预定
*/
@RequestMapping("/subscribe")
public R subscribe(Integer ids, HttpServletRequest request){
CanzhuoEntity canzhuoEntity = canzhuoService.selectById(ids);
if(canzhuoEntity == null){
return R.error();
}
canzhuoEntity.setSfTypes(1);
canzhuoService.updateById(canzhuoEntity);
YudingcanzhuoEntity yudingcanzhuoEntity = new YudingcanzhuoEntity();
yudingcanzhuoEntity.setCreateTime(new Date());
yudingcanzhuoEntity.setCzTypes(canzhuoEntity.getId());
yudingcanzhuoEntity.setYhTypes((Integer) request.getSession().getAttribute("userId"));
yudingcanzhuoService.insert(yudingcanzhuoEntity);
return R.ok();
}
}
package com.controller;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Map;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Date;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import com.utils.ValidatorUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.annotation.IgnoreAuth;
import com.entity.OrdersEntity;
import com.entity.view.OrdersView;
import com.service.OrdersService;
import com.service.TokenService;
import com.utils.PageUtils;
import com.utils.R;
import com.utils.MPUtil;
import com.utils.CommonUtil;
/**
* 订单
* 后端接口
* @author
* @email
* @date 2021-01-25 11:41:44
*/
@RestController
@RequestMapping("/orders")
public class OrdersController {
@Autowired
private OrdersService ordersService;
/**
* 后端列表
*/
@RequestMapping("/page")
public R page(@RequestParam Map<String, Object> params,OrdersEntity orders, HttpServletRequest request){
if(!request.getSession().getAttribute("role").toString().equals("管理员")) {
orders.setUserid((Integer)request.getSession().getAttribute("userId"));
}
EntityWrapper<OrdersEntity> ew = new EntityWrapper<OrdersEntity>();
PageUtils page = ordersService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, orders), params), params));
return R.ok().put("data", page);
}
/**
* 前端列表
*/
@RequestMapping("/list")
public R list(@RequestParam Map<String, Object> params,OrdersEntity orders, HttpServletRequest request){
EntityWrapper<OrdersEntity> ew = new EntityWrapper<OrdersEntity>();
PageUtils page = ordersService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, orders), params), params));
return R.ok().put("data", page);
}
/**
* 列表
*/
@RequestMapping("/lists")
public R list( OrdersEntity orders){
EntityWrapper<OrdersEntity> ew = new EntityWrapper<OrdersEntity>();
ew.allEq(MPUtil.allEQMapPre( orders, "orders"));
return R.ok().put("data", ordersService.selectListView(ew));
}
/**
* 查询
*/
@RequestMapping("/query")
public R query(OrdersEntity orders){
EntityWrapper< OrdersEntity> ew = new EntityWrapper< OrdersEntity>();
ew.allEq(MPUtil.allEQMapPre( orders, "orders"));
OrdersView ordersView = ordersService.selectView(ew);
return R.ok("查询订单成功").put("data", ordersView);
}
/**
* 后端详情
*/
@RequestMapping("/info/{id}")
public R info(@PathVariable("id") Long id){
OrdersEntity orders = ordersService.selectById(id);
return R.ok().put("data", orders);
}
/**
* 前端详情
*/
@RequestMapping("/detail/{id}")
public R detail(@PathVariable("id") Long id){
OrdersEntity orders = ordersService.selectById(id);
return R.ok().put("data", orders);
}
/**
* 后端保存
*/
@RequestMapping("/save")
public R save(@RequestBody OrdersEntity orders, HttpServletRequest request){
orders.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());
//ValidatorUtils.validateEntity(orders);
orders.setUserid((Integer)request.getSession().getAttribute("userId"));
ordersService.insert(orders);
return R.ok();
}
/**
* 前端保存
*/
@RequestMapping("/add")
public R add(@RequestBody OrdersEntity orders, HttpServletRequest request){
orders.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());
//ValidatorUtils.validateEntity(orders);
ordersService.insert(orders);
return R.ok();
}
/**
* 修改
*/
@RequestMapping("/update")
public R update(@RequestBody OrdersEntity orders, HttpServletRequest request){
//ValidatorUtils.validateEntity(orders);
ordersService.updateById(orders);//全部更新
return R.ok();
}
/**
* 删除
*/
@RequestMapping("/delete")
public R delete(@RequestBody Long[] ids){
ordersService.deleteBatchIds(Arrays.asList(ids));
return R.ok();
}
/**
* 提醒接口
*/
@RequestMapping("/remind/{columnName}/{type}")
public R remindCount(@PathVariable("columnName") String columnName, HttpServletRequest request,
@PathVariable("type") String type,@RequestParam Map<String, Object> map) {
map.put("column", columnName);
map.put("type", type);
if(type.equals("2")) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Calendar c = Calendar.getInstance();
Date remindStartDate = null;
Date remindEndDate = null;
if(map.get("remindstart")!=null) {
Integer remindStart = Integer.parseInt(map.get("remindstart").toString());
c.setTime(new Date());
c.add(Calendar.DAY_OF_MONTH,remindStart);
remindStartDate = c.getTime();
map.put("remindstart", sdf.format(remindStartDate));
}
if(map.get("remindend")!=null) {
Integer remindEnd = Integer.parseInt(map.get("remindend").toString());
c.setTime(new Date());
c.add(Calendar.DAY_OF_MONTH,remindEnd);
remindEndDate = c.getTime();
map.put("remindend", sdf.format(remindEndDate));
}
}
Wrapper<OrdersEntity> wrapper = new EntityWrapper<OrdersEntity>();
if(map.get("remindstart")!=null) {
wrapper.ge(columnName, map.get("remindstart"));
}
if(map.get("remindend")!=null) {
wrapper.le(columnName, map.get("remindend"));
}
if(!request.getSession().getAttribute("role").toString().equals("管理员")) {
wrapper.eq("userid", (Long)request.getSession().getAttribute("userId"));
}
int count = ordersService.selectCount(wrapper);
return R.ok().put("count", count);
}
}
package com.controller;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Map;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Date;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import com.entity.KuchuenEntity;
import com.utils.ValidatorUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.annotation.IgnoreAuth;
import com.entity.StoreupEntity;
import com.entity.view.StoreupView;
import com.service.StoreupService;
import com.service.TokenService;
import com.utils.PageUtils;
import com.utils.R;
import com.utils.MPUtil;
import com.utils.CommonUtil;
/**
* 收藏表
* 后端接口
* @author
* @email
* @date 2021-01-25 11:41:44
*/
@RestController
@RequestMapping("/storeup")
public class StoreupController {
@Autowired
private StoreupService storeupService;
/**
* 后端列表
*/
@RequestMapping("/page")
public R page(@RequestParam Map<String, Object> params,StoreupEntity storeup, HttpServletRequest request){
if(!request.getSession().getAttribute("role").toString().equals("管理员")) {
//String userId = (String) request.getSession().getAttribute("userId");
//Integer i = Integer.parseInt(userId);
storeup.setUserid((Integer) request.getSession().getAttribute("userId"));
}
EntityWrapper<StoreupEntity> ew = new EntityWrapper<StoreupEntity>();
PageUtils page = storeupService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, storeup), params), params));
return R.ok().put("data", page);
}
/**
* 前端列表
*/
@RequestMapping("/list")
public R list(@RequestParam Map<String, Object> params,StoreupEntity storeup, HttpServletRequest request){
if(!request.getSession().getAttribute("role").toString().equals("管理员")) {
storeup.setUserid((Integer) request.getSession().getAttribute("userId"));
}
EntityWrapper<StoreupEntity> ew = new EntityWrapper<StoreupEntity>();
PageUtils page = storeupService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, storeup), params), params));
return R.ok().put("data", page);
}
/**
* 列表
*/
@RequestMapping("/lists")
public R list( StoreupEntity storeup){
EntityWrapper<StoreupEntity> ew = new EntityWrapper<StoreupEntity>();
ew.allEq(MPUtil.allEQMapPre( storeup, "storeup"));
return R.ok().put("data", storeupService.selectListView(ew));
}
/**
* 查询
*/
@RequestMapping("/query")
public R query(StoreupEntity storeup){
EntityWrapper< StoreupEntity> ew = new EntityWrapper< StoreupEntity>();
ew.allEq(MPUtil.allEQMapPre( storeup, "storeup"));
StoreupView storeupView = storeupService.selectView(ew);
return R.ok("查询收藏表成功").put("data", storeupView);
}
/**
* 后端详情
*/
@RequestMapping("/info/{id}")
public R info(@PathVariable("id") Long id){
StoreupEntity storeup = storeupService.selectById(id);
return R.ok().put("data", storeup);
}
/**
* 前端详情
*/
@RequestMapping("/detail/{id}")
public R detail(@PathVariable("id") Long id){
StoreupEntity storeup = storeupService.selectById(id);
return R.ok().put("data", storeup);
}
/**
* 后端保存
*/
@RequestMapping("/save")
public R save(@RequestBody StoreupEntity storeup, HttpServletRequest request){
storeup.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());
Wrapper<StoreupEntity> queryWrapper = new EntityWrapper<StoreupEntity>()
.eq("refid", storeup.getRefid())
.eq("userid", storeup.getUserid())
;
StoreupEntity storeupEntity = storeupService.selectOne(queryWrapper);
if(storeupEntity != null){
return R.error("你已经收藏过了");
}
storeup.setUserid((Integer) request.getSession().getAttribute("userId"));
storeupService.insert(storeup);
return R.ok();
}
/**
* 前端保存
*/
@RequestMapping("/add")
public R add(@RequestBody StoreupEntity storeup, HttpServletRequest request){
storeup.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());
Wrapper<StoreupEntity> queryWrapper = new EntityWrapper<StoreupEntity>()
.eq("refid", storeup.getRefid())
.eq("userid", storeup.getUserid())
;
StoreupEntity storeupEntity = storeupService.selectOne(queryWrapper);
if(storeupEntity != null){
return R.error("你已经收藏过了");
}
storeup.setUserid((Integer)request.getSession().getAttribute("userId"));
storeupService.insert(storeup);
return R.ok();
}
/**
* 修改
*/
@RequestMapping("/update")
public R update(@RequestBody StoreupEntity storeup, HttpServletRequest request){
//ValidatorUtils.validateEntity(storeup);
storeupService.updateById(storeup);//全部更新
return R.ok();
}
/**
* 删除
*/
@RequestMapping("/delete")
public R delete(@RequestBody Long[] ids){
storeupService.deleteBatchIds(Arrays.asList(ids));
return R.ok();
}
/**
* 提醒接口
*/
@RequestMapping("/remind/{columnName}/{type}")
public R remindCount(@PathVariable("columnName") String columnName, HttpServletRequest request,
@PathVariable("type") String type,@RequestParam Map<String, Object> map) {
map.put("column", columnName);
map.put("type", type);
if(type.equals("2")) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Calendar c = Calendar.getInstance();
Date remindStartDate = null;
Date remindEndDate = null;
if(map.get("remindstart")!=null) {
Integer remindStart = Integer.parseInt(map.get("remindstart").toString());
c.setTime(new Date());
c.add(Calendar.DAY_OF_MONTH,remindStart);
remindStartDate = c.getTime();
map.put("remindstart", sdf.format(remindStartDate));
}
if(map.get("remindend")!=null) {
Integer remindEnd = Integer.parseInt(map.get("remindend").toString());
c.setTime(new Date());
c.add(Calendar.DAY_OF_MONTH,remindEnd);
remindEndDate = c.getTime();
map.put("remindend", sdf.format(remindEndDate));
}
}
Wrapper<StoreupEntity> wrapper = new EntityWrapper<StoreupEntity>();
if(map.get("remindstart")!=null) {
wrapper.ge(columnName, map.get("remindstart"));
}
if(map.get("remindend")!=null) {
wrapper.le(columnName, map.get("remindend"));
}
if(!request.getSession().getAttribute("role").toString().equals("管理员")) {
wrapper.eq("userid", (Long)request.getSession().getAttribute("userId"));
}
int count = storeupService.selectCount(wrapper);
return R.ok().put("count", count);
}
}
package com.controller;
import java.text.SimpleDateFormat;
import java.util.*;
import javax.servlet.http.HttpServletRequest;
import com.entity.CanzhuoEntity;
import com.service.CanzhuoService;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.entity.YudingcanzhuoEntity;
import com.service.YudingcanzhuoService;
import com.utils.PageUtils;
import com.utils.R;
/**
* 预定餐桌表
* 后端接口
* @author
* @email
* @date 2021-03-08
*/
@RestController
@Controller
@RequestMapping("/yudingcanzhuo")
public class YudingcanzhuoController {
private static final Logger logger = LoggerFactory.getLogger(YudingcanzhuoController.class);
@Autowired
private CanzhuoService canzhuoService;
@Autowired
private YudingcanzhuoService yudingcanzhuoService;
/**
* 后端列表
*/
@RequestMapping("/page")
public R page(@RequestParam Map<String, Object> params, HttpServletRequest request){
logger.debug("Controller:"+this.getClass().getName()+",page方法");
PageUtils page = null;
if(!request.getSession().getAttribute("role").equals("管理员")){
params.put("yh",request.getSession().getAttribute("userId"));
page = yudingcanzhuoService.queryPage(params);
}else{
page = yudingcanzhuoService.queryPage(params);
}
return R.ok().put("data", page);
}
/**
* 后端详情
*/
@RequestMapping("/info/{id}")
public R info(@PathVariable("id") Long id){
logger.debug("Controller:"+this.getClass().getName()+",info方法");
YudingcanzhuoEntity yudingcanzhuo = yudingcanzhuoService.selectById(id);
if(yudingcanzhuo!=null){
return R.ok().put("data", yudingcanzhuo);
}else {
return R.error(511,"查不到数据");
}
}
/**
* 后端保存
*/
@RequestMapping("/save")
public R save(@RequestBody YudingcanzhuoEntity yudingcanzhuo, HttpServletRequest request){
logger.debug("Controller:"+this.getClass().getName()+",save");
Wrapper<YudingcanzhuoEntity> queryWrapper = new EntityWrapper<YudingcanzhuoEntity>()
.eq("cz_types", yudingcanzhuo.getCzTypes())
.eq("yh_types", yudingcanzhuo.getYhTypes())
;
logger.info("sql语句:"+queryWrapper.getSqlSegment());
YudingcanzhuoEntity yudingcanzhuoEntity = yudingcanzhuoService.selectOne(queryWrapper);
if(yudingcanzhuoEntity==null){
yudingcanzhuoService.insert(yudingcanzhuo);
return R.ok();
}else {
return R.error(511,"表中有相同数据");
}
}
/**
* 修改
*/
@RequestMapping("/update")
public R update(@RequestBody YudingcanzhuoEntity yudingcanzhuo, HttpServletRequest request){
logger.debug("Controller:"+this.getClass().getName()+",update");
//根据字段查询是否有相同数据
Wrapper<YudingcanzhuoEntity> queryWrapper = new EntityWrapper<YudingcanzhuoEntity>()
.notIn("id",yudingcanzhuo.getId())
.eq("cz_types", yudingcanzhuo.getCzTypes())
.eq("yh_types", yudingcanzhuo.getYhTypes())
;
logger.info("sql语句:"+queryWrapper.getSqlSegment());
YudingcanzhuoEntity yudingcanzhuoEntity = yudingcanzhuoService.selectOne(queryWrapper);
if(yudingcanzhuoEntity==null){
yudingcanzhuoService.updateById(yudingcanzhuo);//根据id更新
return R.ok();
}else {
return R.error(511,"表中有相同数据");
}
}
//canzhuoService
/**
* 删除
*/
@RequestMapping("/delete")
public R delete(Integer ids){
YudingcanzhuoEntity yudingcanzhuoEntity = yudingcanzhuoService.selectById(ids);
if(yudingcanzhuoEntity == null){
return R.error();
}
CanzhuoEntity canzhuoEntity = canzhuoService.selectById(yudingcanzhuoEntity.getCzTypes());
if(canzhuoEntity == null){
return R.error();
}
canzhuoEntity.setSfTypes(2);
canzhuoService.updateById(canzhuoEntity);
yudingcanzhuoService.deleteById(ids);
return R.ok();
}
}