基于JAVA+Vue+SpringBoot+MySQL的农家乐订餐系统,包含了菜品类型模块、菜品档案模块、菜品收藏模块、菜品订餐模块、菜品资讯模块,还包含系统自带的用户管理、部门管理、角色管理、菜单管理、日志管理、数据字典管理、文件管理、图表展示等基础模块,农家乐订餐系统基于角色的访问控制,给订餐管理员、配送人员使用,可将权限精确到按钮级别,您可以自定义角色并分配权限,系统适合设计精确的权限约束需求。
@RequestMapping(value = "/getByPage", method = RequestMethod.GET)
@ApiOperation(value = "查询菜品类型")
public Result<IPage<DishType>> getByPage(@ModelAttribute DishType dishType ,@ModelAttribute PageVo page){
QueryWrapper<DishType> qw = new QueryWrapper<>();
if(!ZwzNullUtils.isNull(dishType.getTitle())) {
qw.like("title",dishType.getTitle());
}
if(!ZwzNullUtils.isNull(dishType.getStatus())) {
qw.eq("status",dishType.getStatus());
}
IPage<DishType> data = iDishTypeService.page(PageUtil.initMpPage(page),qw);
return new ResultUtil<IPage<DishType>>().setData(data);
}
@RequestMapping(value = "/getByPage", method = RequestMethod.GET)
@ApiOperation(value = "查询菜品")
public Result<IPage<DishVariety>> getByPage(@ModelAttribute DishVariety dishVariety ,@ModelAttribute PageVo page){
QueryWrapper<DishVariety> qw = new QueryWrapper<>();
if(!ZwzNullUtils.isNull(dishVariety.getTitle())) {
qw.like("title",dishVariety.getTitle());
}
if(!ZwzNullUtils.isNull(dishVariety.getType())) {
qw.eq("type",dishVariety.getType());
}
if(!ZwzNullUtils.isNull(dishVariety.getContent())) {
qw.like("content",dishVariety.getContent());
}
IPage<DishVariety> data = iDishVarietyService.page(PageUtil.initMpPage(page),qw);
User currUser = securityUtil.getCurrUser();
for (DishVariety vo : data.getRecords()) {
QueryWrapper<DishCollect> collQw = new QueryWrapper<>();
collQw.eq("collect_id",currUser.getId());
collQw.eq("dish_id",vo.getId());
vo.setCollectFlag(iDishCollectService.count(collQw));
QueryWrapper<DishOrder> orderQw = new QueryWrapper<>();
orderQw.eq("dish_id",vo.getId());
orderQw.eq("status","已加购");
orderQw.last("limit 1");
DishOrder order = iDishOrderService.getOne(orderQw);
vo.setBuyNumber(order == null ? BigDecimal.ZERO : order.getNumber());
}
return new ResultUtil<IPage<DishVariety>>().setData(data);
}
@RequestMapping(value = "/addOne", method = RequestMethod.GET)
@ApiOperation(value = "加购")
public Result<DishOrder> addOne(@RequestParam String id, @RequestParam BigDecimal number){
DishVariety dish = iDishVarietyService.getById(id);
if(dish == null) {
return ResultUtil.error("菜品不存在");
}
User currUser = securityUtil.getCurrUser();
QueryWrapper<DishOrder> qw = new QueryWrapper<>();
qw.eq("dish_id",dish.getId());
qw.eq("status","已加购");
qw.eq("order_id",currUser.getId());
qw.last("limit 1");
DishOrder order = iDishOrderService.getOne(qw);
if(order != null) {
order.setNumber(order.getNumber().add(number));
iDishOrderService.saveOrUpdate(order);
return ResultUtil.success();
}
DishOrder o = new DishOrder();
o.setDishId(dish.getId());
o.setTitle(dish.getTitle());
o.setType(dish.getType());
o.setContent(dish.getContent());
o.setImage(dish.getImage());
o.setPrice(dish.getPrice());
o.setStatus("已加购");
o.setNumber(number);
o.setOrderId(currUser.getId());
o.setOrderName(currUser.getNickname());
o.setOrderTime(DateUtil.now());
iDishOrderService.saveOrUpdate(o);
return ResultUtil.success();
}
@RequestMapping(value = "/addOne", method = RequestMethod.GET)
@ApiOperation(value = "新增收藏")
public Result<DishCollect> addOne(@RequestParam String id){
DishVariety dish = iDishVarietyService.getById(id);
if(dish == null) {
return ResultUtil.error("菜品不存在");
}
User currUser = securityUtil.getCurrUser();
QueryWrapper<DishCollect> qw = new QueryWrapper<>();
qw.eq("dish_id",id);
qw.eq("collect_id",currUser.getId());
if(iDishCollectService.count(qw) > 0L) {
return ResultUtil.success();
}
DishCollect dishCollect = new DishCollect();
dishCollect.setDishId(dish.getId());
dishCollect.setTitle(dish.getTitle());
dishCollect.setType(dish.getType());
dishCollect.setContent(dish.getContent());
dishCollect.setImage(dish.getImage());
dishCollect.setPrice(dish.getPrice());
dishCollect.setCollectId(currUser.getId());
dishCollect.setCollectName(currUser.getNickname());
dishCollect.setCollectTime(DateUtil.now());
iDishCollectService.saveOrUpdate(dishCollect);
return ResultUtil.success();
}
@RequestMapping(value = "/insert", method = RequestMethod.POST)
@ApiOperation(value = "新增菜品留言")
public Result<Message> insert(Message message){
User currUser = securityUtil.getCurrUser();
message.setUserId(currUser.getId());
message.setUserName(currUser.getNickname());
message.setUserTime(DateUtil.now());
message.setReplyContent("");
message.setReplyName("");
message.setReplyTime("");
message.setReplyId("");
iMessageService.saveOrUpdate(message);
return new ResultUtil<Message>().setData(message);
}
下载本系统代码或使用本系统的用户,必须同意以下内容,否则请勿下载!