• SSM在线餐饮管理系统


    作者主页:夜未央5788

     简介:Java领域优质创作者、Java项目、学习资料、技术互助

    文末获取源码

     

    项目介绍

    本项目包含管理员与普通用户两种角色;
    管理员角色包含以下功能:
    管理员登录,查看销售报表,餐桌管理,菜式管理,菜品管理,点餐明细管理,修改密码等功能。

    用户角色包含以下功能:
    用户登录,点餐,提交订单,修改密码等功能。
     

    环境需要

    1.运行环境:最好是java jdk 1.8,我们在这个平台上运行的。其他版本理论上也可以。
    2.IDE环境:IDEA,Eclipse,Myeclipse都可以。推荐IDEA;
    3.tomcat环境:Tomcat 7.x,8.x,9.x版本均可
    4.硬件环境:windows 7/8/10 1G内存以上;或者 Mac OS; 

    5.数据库:MySql 5.7版本;

    6.是否Maven项目:否;

    技术栈

    1. 后端:Spring+SpringMVC+Mybatis

    2. 前端:JSP+CSS+JavaScript+jQuery+bootstrap

    使用说明

    1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件;

    2. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven;

    若为maven项目,导入成功后请执行maven clean;maven install命令,然后运行;

    3. 将项目中WebContent/WEB-INF/config/config.properties配置文件中的数据库配置改为自己的配置;

    4. 运行项目,在浏览器中输入 http://localhost:8080/ssm_restaurentsys/

    运行截图

    管理员角色

     

     

     

     

     

    用户角色 

     

     

    相关代码

     BaseController

    1. public abstract class BaseController {
    2. protected Map<String, Object> getWhereMap(HttpServletRequest request)
    3. {
    4. Map<String, Object> map = new HashMap<String, Object>();
    5. int start = StringUtil.parseToInt(request.getParameter("start"), 0);
    6. int limit = StringUtil.parseToInt(request.getParameter("limit"), 50);
    7. map.put("start", start);
    8. map.put("limit", limit);
    9. return map;
    10. }
    11. protected Map<String, Object> getMessageMap(boolean success, String message) {
    12. Map<String, Object> map = new HashMap<String, Object>();
    13. map.put("success", success);
    14. map.put("message", message);
    15. return map;
    16. }
    17. }

    DishController

    1. @Controller
    2. @RequestMapping(value="/dish")
    3. public class DishController extends BaseController {
    4. @Autowired
    5. DishService dishService;
    6. @Autowired
    7. DishTypeService dishTypeService;
    8. @RequestMapping(value = "/list", method = RequestMethod.GET)
    9. public String get(SearchVO searchVO, HttpServletRequest request, ModelMap modelMap) {
    10. String pageNow = request.getParameter("pageNow");
    11. Page page = null;
    12. Map<String, Object> whereMap = new HashMap<String, Object>();
    13. if (!StringUtil.isEmpty(searchVO.getName())) {
    14. whereMap.put("name", " name like '%" + searchVO.getName() + "%'");
    15. }
    16. int totalCount = (int) dishService.getCount(whereMap);
    17. if (pageNow != null) {
    18. page = new Page(totalCount, Integer.parseInt(pageNow));
    19. } else {
    20. page = new Page(totalCount, 1);
    21. }
    22. whereMap.put("startPos", page.getStartPos());
    23. whereMap.put("pageSize", page.getPageSize());
    24. List<Dishes> dishes = dishService.getAll(whereMap);
    25. modelMap.addAttribute("dishes", dishes);
    26. modelMap.addAttribute("page", page);
    27. return "restaurent/dishes";
    28. }
    29. @RequestMapping(value="/save", method = RequestMethod.POST)
    30. public String save(@RequestParam(required=false, value="file")MultipartFile file, Dishes dish, ModelMap modelMap, HttpSession session) {
    31. String path = dish.getPic();
    32. if (file != null && !file.isEmpty()) {
    33. String fileName = file.getOriginalFilename();
    34. String ext = fileName.substring(fileName.lastIndexOf("."));
    35. path = "/pic/" + System.currentTimeMillis() + ext;
    36. String dir = session.getServletContext().getRealPath(path);
    37. try {
    38. FileUtils.copyInputStreamToFile(file.getInputStream(), new File(dir));
    39. } catch (IOException e) {
    40. e.printStackTrace();
    41. }
    42. } else if (StringUtil.isEmpty(path)){
    43. path = "/pic/default.jpg";
    44. }
    45. dish.setPic(path);
    46. DishType dishType = dishTypeService.getDishTypeById(dish.getDishType());
    47. dish.setTypeName(dishType.getName());
    48. if(dish.getId() == null) {
    49. dishService.insert(dish);
    50. } else {
    51. dishService.update(dish);
    52. }
    53. return "redirect:list.html";
    54. }
    55. @RequestMapping(value="/add", method = RequestMethod.GET)
    56. public String add(ModelMap modelMap) {
    57. List<DishType> dishtypes = dishTypeService.getAll();
    58. modelMap.put("dishtypes", dishtypes);
    59. return "restaurent/adddish";
    60. }
    61. @RequestMapping(value="/update", method = RequestMethod.GET)
    62. public String update(int id, ModelMap modelMap) {
    63. Dishes dish = dishService.getDishesById(id);
    64. List<DishType> dishtypes = dishTypeService.getAll();
    65. modelMap.put("dishtypes", dishtypes);
    66. modelMap.put("dish", dish);
    67. return "restaurent/adddish";
    68. }
    69. @RequestMapping(value="/delete", method = RequestMethod.GET)
    70. public String delete(int id, ModelMap modelMap) {
    71. dishService.deleteById(id);
    72. return "redirect:list.html";
    73. }
    74. }

    如果也想学习本系统,下面领取。回复:200ssm

  • 相关阅读:
    Java 流处理之收集器
    【无标题】
    数字统计
    数据库开发综合案例——仓库管理系统设计
    (缺省参数)&(函数重载)&(引用)&(内敛)&(C++中的nullptr)
    练习八-利用有限状态机进行时序逻辑的设计
    [SFML] 多个OpenGL上下文
    Spring读书笔记——bean创建(上)
    C++项目实战-makefile
    【SQL刷题】Day13----SQL分组数据专项练习
  • 原文地址:https://blog.csdn.net/hanyunlong1989/article/details/125469514