• Java项目:基于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+bootstrap

    使用说明

    1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件;
    2. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven;
    若为maven项目,导入成功后请执行maven clean;maven install命令,然后运行;
    3. 将项目中db.properties配置文件中的数据库配置改为自己的配置;
    4. 运行项目,在浏览器中输入http://localhost:8080/DiningRoom 登录
    服务员账号/密码: 20144206169/123456
    厨师账号/密码:20144206170/123456
    经理账号/密码:20144206171/123456

    收银账号/密码:20144206172/123456

    运行截图

     

     

     

     

     

     

     

     

     

     

    代码相关

    登录管理控制器

    1. @Controller
    2. public class LoginController {
    3. @Autowired
    4. IUserService userService;
    5. @Autowired
    6. IDishService dishService;
    7. @Autowired
    8. ITradeService tradeService;
    9. @RequestMapping("/loginCheck")
    10. public void loginCheck(HttpServletRequest request,
    11. HttpServletResponse response) throws ServletException, IOException {
    12. try {
    13. Thread.sleep(1000);
    14. } catch (InterruptedException e1) {
    15. // TODO Auto-generated catch block
    16. e1.printStackTrace();
    17. }
    18. String idStr = request.getParameter("id");
    19. String password = request.getParameter("password");
    20. String validation = request.getParameter("validation");
    21. HttpSession session = request.getSession();
    22. if (idStr == null || password == null || validation == null) {
    23. response.sendRedirect("index.jsp?message=error");
    24. return;
    25. }
    26. Long id = 1l;
    27. try {
    28. id = Long.parseLong(idStr);
    29. } catch (NumberFormatException e) {
    30. }
    31. String result = "0";
    32. PrintWriter out = response.getWriter();
    33. User tempUser = userService.getUserById(id);
    34. String imgStr = (String) session.getAttribute("imgStr");
    35. if (!imgStr.equalsIgnoreCase(validation)) {
    36. result = "1";
    37. }
    38. if (tempUser!=null && result.equals("0")) {
    39. if(tempUser.getPassword().equals(MD5Util.string2MD5(password))){
    40. }
    41. session.setAttribute("user", tempUser);
    42. result = "2";
    43. }
    44. out.write(result);
    45. out.close();
    46. }
    47. @RequestMapping("/login")
    48. public ModelAndView login(HttpServletRequest request){
    49. HttpSession session = request.getSession();
    50. if (session.getAttribute("user") != null) {
    51. return new ModelAndView("redirect:toIndexUI.do");
    52. //response.sendRedirect("mianServlet?method=toIndexUI");
    53. } else {
    54. return new ModelAndView("index");
    55. }
    56. }
    57. @RequestMapping("/toIndexUI")
    58. public ModelAndView toIndexUI(HttpServletRequest request,
    59. HttpServletResponse response) throws ServletException, IOException {
    60. ModelAndView view = new ModelAndView();
    61. HttpSession session = request.getSession();
    62. User user = (User) session.getAttribute("user");
    63. if (user == null) {
    64. view.setViewName("index");
    65. return view;
    66. }
    67. List page = dishService.getPageBySaleDesc(1,10);
    68. request.setAttribute("top_sale", page);
    69. List pageTrade = tradeService.getPageList(1, 10);
    70. request.setAttribute("pageTrade", pageTrade);
    71. view.setViewName("jsp/main/index");
    72. return view;
    73. }
    74. /**
    75. * 功能描述:生成验证码
    76. * @param request
    77. * @param response
    78. * @throws IOException
    79. */
    80. @RequestMapping("/getRadomPic")
    81. public void getRadomPic(HttpServletRequest request,
    82. HttpServletResponse response) throws IOException {
    83. HttpSession session = request.getSession();
    84. // 千万注意,像此类图片一定禁止浏览器缓存
    85. response.setIntHeader("expires", 0);
    86. response.setHeader("Cache-Control", "no-cache");
    87. response.setHeader("Pragma", "no-cache");
    88. response.setHeader("content-type", "image/jpeg");
    89. Captcha captcha = new ImageUtils(120, 26, 4);// png格式验证码
    90. captcha.out(response.getOutputStream());
    91. String imgStr = captcha.getStr();
    92. session.setAttribute("imgStr", imgStr);
    93. }
    94. /**
    95. * 功能描述:后台公共跳转页面
    96. * @param page
    97. * @return
    98. */
    99. @RequestMapping(value = "/{page}.do", method = RequestMethod.GET)
    100. public ModelAndView toPage(@PathVariable String page) {
    101. ModelAndView view = new ModelAndView("/manage/"+page+"");
    102. return view;
    103. }
    104. }

     用户管理控制器

    1. @Controller
    2. @RequestMapping("/user")
    3. public class UserController {
    4. @Resource
    5. private IUserService userService;
    6. @Value("${img_dir}")
    7. private String imgDir;
    8. /**
    9. * 查询所有 and 模糊搜索
    10. * @param request
    11. * @param response
    12. * @throws ServletException
    13. * @throws IOException
    14. */
    15. @RequestMapping("/getList")
    16. @ResponseBody
    17. public String getList(HttpServletRequest request, HttpServletResponse response)
    18. throws ServletException, IOException {
    19. String p = request.getParameter("page"); //需求页码
    20. String rows = request.getParameter("rows"); //每页多少条
    21. String sel = request.getParameter("s_userName"); //如果是查询这不为空
    22. System.out.println("收到请求:"+p+" "+rows+" "+sel);
    23. Map map = new HashMap();
    24. ObjectMapper mapper = new ObjectMapper();
    25. String json = null;
    26. if(sel==null){
    27. /*List list = userService.getPageList(new User(),Integer.parseInt(p), Integer.parseInt(rows));
    28. PageInfo pageInfo = new PageInfo(list);*/
    29. /*map.put("rows", pageInfo.getList());
    30. map.put("total", pageInfo.getTotal());*/
    31. }
    32. json = mapper.writeValueAsString(map);
    33. return json;
    34. }
    35. /**
    36. * 功能描述:个人中心
    37. * @param request
    38. * @param response
    39. * @throws ServletException
    40. * @throws IOException
    41. */
    42. @RequestMapping("/toUserIndexUI")
    43. public ModelAndView toUserIndexUI(HttpServletRequest request,
    44. HttpServletResponse response) throws ServletException, IOException {
    45. ModelAndView view = new ModelAndView();
    46. view.setViewName("jsp/user/userIndex");
    47. return view;
    48. }
    49. /**
    50. * 跳转到修改密码页面
    51. * @param request
    52. * @param response
    53. * @return
    54. * @throws ServletException
    55. * @throws IOException
    56. */
    57. @RequestMapping("/toUserPasswordEditUI")
    58. public ModelAndView toUserPasswordEditUI(HttpServletRequest request,
    59. HttpServletResponse response) throws ServletException, IOException {
    60. ModelAndView view = new ModelAndView();
    61. view.setViewName("jsp/user/editPassword");
    62. return view;
    63. }
    64. /**
    65. * 功能描述:退出系统
    66. * @param request
    67. * @param response
    68. * @return
    69. * @throws ServletException
    70. * @throws IOException
    71. */
    72. @RequestMapping("/quit")
    73. public ModelAndView quit(HttpServletRequest request, HttpServletResponse response)
    74. throws ServletException, IOException {
    75. HttpSession session = request.getSession();
    76. session.invalidate();
    77. ModelAndView view = new ModelAndView();
    78. view.setViewName("../index");
    79. return view;
    80. }
    81. /**
    82. * 功能描述:用户管理
    83. * @param request
    84. * @param response
    85. * @throws ServletException
    86. * @throws IOException
    87. */
    88. @RequestMapping("/toUserManageUI")
    89. public ModelAndView toUserManageUI(User tempUser,HttpServletRequest request,
    90. HttpServletResponse response) throws ServletException, IOException {
    91. String pageStr = request.getParameter("pageNum");
    92. ModelAndView view = new ModelAndView();
    93. int pageNum = 1;
    94. int pageSize = 15;
    95. try {
    96. pageNum = Integer.parseInt(pageStr);
    97. } catch (NumberFormatException e) {
    98. }
    99. List userList = userService.getPageList(tempUser,pageNum,pageSize);
    100. PageInfo pageInfo = new PageInfo(userList);
    101. request.setAttribute("page", pageInfo);
    102. view.setViewName("jsp/user/userManage");
    103. return view;
    104. }
    105. /**
    106. * 功能描述:跳转到新增用户页面
    107. * @param request
    108. * @param response
    109. * @return
    110. * @throws ServletException
    111. * @throws IOException
    112. */
    113. @RequestMapping("/userAddUI")
    114. public ModelAndView userAddUI(HttpServletRequest request,
    115. HttpServletResponse response) throws ServletException, IOException {
    116. ModelAndView view = new ModelAndView();
    117. List roles = userService.getRoleList();
    118. request.setAttribute("roles", roles);
    119. view.setViewName("jsp/user/user-add");
    120. return view;
    121. }
    122. /**
    123. * 功能描述:保存用户信息
    124. * @param request
    125. * @param response
    126. * @throws ServletException
    127. * @throws IOException
    128. */
    129. @RequestMapping("/addUser")
    130. public ModelAndView addUser(HttpServletRequest request, HttpServletResponse response)
    131. throws ServletException, IOException {
    132. ModelAndView view = new ModelAndView();
    133. String name = request.getParameter("name");
    134. String typeStr = request.getParameter("type");
    135. String tell = request.getParameter("tell");
    136. Integer type = 2;
    137. try {
    138. type = Integer.parseInt(typeStr);
    139. } catch (NumberFormatException e) {
    140. }
    141. userService.addUser(name, type, tell);
    142. view.setViewName("redirect:toUserManageUI.do");
    143. return view;
    144. }
    145. /**
    146. * 功能描述:跳转到修改页面
    147. * @param request
    148. * @param response
    149. * @return
    150. * @throws ServletException
    151. * @throws IOException
    152. */
    153. @RequestMapping("/toModifyUI")
    154. public ModelAndView toModifyUI(HttpServletRequest request,
    155. HttpServletResponse response) throws ServletException, IOException {
    156. ModelAndView view = new ModelAndView();
    157. String idStr = request.getParameter("id");
    158. Long id = null;
    159. try {
    160. id = Long.parseLong(idStr);
    161. } catch (NumberFormatException e) {
    162. }
    163. List roles = userService.getRoleList();
    164. User user = userService.getUserById(id);
    165. request.setAttribute("roles", roles);
    166. request.setAttribute("account", user);
    167. view.setViewName("jsp/user/user-add");
    168. return view;
    169. }
    170. @RequestMapping("/editUser")
    171. public ModelAndView editUser(HttpServletRequest request,
    172. HttpServletResponse response) throws ServletException, IOException {
    173. ModelAndView view = new ModelAndView();
    174. String name = request.getParameter("name");
    175. String typeStr = request.getParameter("type");
    176. String tell = request.getParameter("tell");
    177. String pageNum = request.getParameter("pageNum");
    178. Integer type = 2;
    179. String idStr = request.getParameter("id");
    180. Long id = null;
    181. try {
    182. id = Long.parseLong(idStr);
    183. } catch (NumberFormatException e) {
    184. }
    185. try {
    186. type = Integer.parseInt(typeStr);
    187. } catch (NumberFormatException e) {
    188. }
    189. userService.editUser(id, name, type, tell);
    190. view.setViewName("redirect:toUserManageUI.do?pageNum"+pageNum);
    191. return view;
    192. }
    193. /**
    194. * 功能描述:删除用户
    195. * @param request
    196. * @param response
    197. * @return
    198. * @throws ServletException
    199. * @throws IOException
    200. */
    201. @RequestMapping("/delUser")
    202. public ModelAndView delUser(HttpServletRequest request, HttpServletResponse response)
    203. throws ServletException, IOException {
    204. ModelAndView view = new ModelAndView();
    205. String pageStr = request.getParameter("pageNum");
    206. String idStr = request.getParameter("id");
    207. Long id = null;
    208. try {
    209. id = Long.parseLong(idStr);
    210. } catch (NumberFormatException e) {
    211. }
    212. userService.delUser(id);
    213. view.setViewName("redirect:toUserManageUI.do?pageNum"+pageStr);
    214. return view;
    215. }
    216. /**
    217. * 功能描述:得到某个用户某月的业绩
    218. * @param request
    219. * @param response
    220. * @return
    221. * @throws ServletException
    222. * @throws IOException
    223. */
    224. @RequestMapping("/toSalaryUI")
    225. public ModelAndView toSalaryUI(HttpServletRequest request,
    226. HttpServletResponse response) throws ServletException, IOException {
    227. String date = request.getParameter("date");
    228. String pageNoStr = request.getParameter("pageNo");
    229. ModelAndView view = new ModelAndView();
    230. int pageNo = 1;
    231. try {
    232. pageNo = Integer.parseInt(pageNoStr);
    233. } catch (NumberFormatException e) {
    234. }
    235. HttpSession session = request.getSession();
    236. if (date != null && date.trim().length()>0) {
    237. session.setAttribute("salary_date", date);
    238. }
    239. date = (String) session.getAttribute("salary_date");
    240. if (date != null && date.trim().length()>0) {
    241. session.setAttribute("salary_date_f", date.substring(0, 4) + "年"
    242. + date.substring(5, 7) + "月");
    243. SalaryOpe salaryOpe = userService.getSalaryOpe(date, pageNo);
    244. request.setAttribute("salaryOpe", salaryOpe);
    245. }
    246. view.setViewName("jsp/user/salary");
    247. return view;
    248. }
    249. /**
    250. * 功能描述:跳转到运营分析
    251. * @param request
    252. * @param response
    253. * @return
    254. * @throws ServletException
    255. * @throws IOException
    256. */
    257. @RequestMapping("/toFinanceUI")
    258. public ModelAndView toFinanceUI(HttpServletRequest request,
    259. HttpServletResponse response) throws ServletException, IOException {
    260. ModelAndView view = new ModelAndView();
    261. view.setViewName("jsp/user/salaryAnalysis");
    262. return view;
    263. }
    264. }

    点餐管理控制器

    1. @Controller
    2. @RequestMapping("/book")
    3. public class BookController {
    4. @Autowired
    5. private IDishService dishService;
    6. @Value("${img_dir}")
    7. private String imgDir;
    8. /**
    9. * 功能描述:点餐本首页
    10. * @param request
    11. * @param response
    12. * @throws ServletException
    13. * @throws IOException
    14. */
    15. @RequestMapping("/index")
    16. public ModelAndView toIndexUI(HttpServletRequest request,
    17. HttpServletResponse response) throws ServletException, IOException {
    18. ModelAndView view = new ModelAndView();
    19. int pageNo = 1;
    20. int pageSize = 10;
    21. String condition = null;
    22. String likeStr = null;
    23. HttpSession session = request.getSession();
    24. try {
    25. condition = (String) session.getAttribute("bookCondition");
    26. likeStr = (String) session.getAttribute("bookLikeStr");
    27. } catch (Exception e) {
    28. e.printStackTrace();
    29. }
    30. if (condition == null || ("".trim()).equals(condition)) {
    31. condition = "u.id";
    32. }
    33. if (likeStr == null) {
    34. likeStr = "";
    35. }
    36. Dish tempDish = new Dish();
    37. tempDish.setOrderByCondition(condition);
    38. tempDish.setSearchKeyWord(likeStr);
    39. List dishList = dishService.getPageList(pageNo,pageSize ,tempDish);
    40. PageInfo pageInfo = new PageInfo(dishList);
    41. request.setAttribute("dishType", dishService.getDishTypeList());
    42. view.addObject("page",pageInfo);
    43. view.setViewName("jsp/book/book");
    44. return view;
    45. }
    46. /**
    47. * 功能描述:搜索菜单
    48. * @param request
    49. * @param response
    50. * @throws ServletException
    51. * @throws IOException
    52. */
    53. @RequestMapping("/searchDish")
    54. public ModelAndView searchDish(HttpServletRequest request,
    55. HttpServletResponse response) throws ServletException, IOException {
    56. ModelAndView view = new ModelAndView();
    57. String likeStr = request.getParameter("likeStr");
    58. // likeStr = new String(likeStr.getBytes("iso-8859-1"), "utf-8");
    59. likeStr = likeStr.trim();
    60. HttpSession session = request.getSession();
    61. if (likeStr != null) {
    62. session.setAttribute("bookLikeStr", likeStr);
    63. } else {
    64. session.removeAttribute("bookLikeStr");
    65. }
    66. view.setViewName("redirect:index.do");
    67. return view;
    68. }
    69. /**
    70. * 功能描述:查看更多
    71. * @param request
    72. * @param response
    73. * @throws ServletException
    74. * @throws IOException
    75. */
    76. @RequestMapping("/getMoreList")
    77. @ResponseBody
    78. public String getMoreList(HttpServletRequest request,
    79. HttpServletResponse response) throws ServletException, IOException {
    80. Map map = new HashMap();
    81. ObjectMapper mapper = new ObjectMapper();
    82. String json = null;
    83. try {
    84. Thread.sleep(500);
    85. } catch (InterruptedException e1) {
    86. // TODO Auto-generated catch block
    87. e1.printStackTrace();
    88. }
    89. String pageNumStr = request.getParameter("pageNum");
    90. int pageNum = 1;
    91. int pageSize = 10;
    92. try {
    93. pageNum = Integer.parseInt(pageNumStr);
    94. } catch (NumberFormatException e) {
    95. }
    96. String condition = null;
    97. String likeStr = null;
    98. HttpSession session = request.getSession();
    99. try {
    100. condition = (String) session.getAttribute("bookCondition");
    101. likeStr = (String) session.getAttribute("bookLikeStr");
    102. } catch (Exception e) {
    103. e.printStackTrace();
    104. }
    105. if (condition == null || ("".trim()).equals(condition)) {
    106. condition = "u.id";
    107. }
    108. if (likeStr == null) {
    109. likeStr = "";
    110. }
    111. Dish tempDish = new Dish();
    112. tempDish.setOrderByCondition(condition);
    113. List dishList = dishService.getPageList(pageNum,pageSize ,tempDish);
    114. PageInfo pageInfo = new PageInfo(dishList);
    115. json = mapper.writeValueAsString(pageInfo);
    116. return json;
    117. }
    118. /**
    119. * 根据条件获取菜单列表
    120. * @param request
    121. * @param response
    122. * @throws ServletException
    123. * @throws IOException
    124. */
    125. @RequestMapping("/setSortAttr")
    126. public ModelAndView setSortAttr(HttpServletRequest request,
    127. HttpServletResponse response) throws ServletException, IOException {
    128. ModelAndView view = new ModelAndView();
    129. HttpSession session = request.getSession();
    130. String conditionStr = request.getParameter("bookCondition");
    131. String condition = null;
    132. if ("2".equals(conditionStr)) {
    133. condition = "sale";
    134. } else if ("3".equals(conditionStr)) {
    135. condition = "price";
    136. } else {
    137. condition = "";
    138. }
    139. session.setAttribute("bookCondition", condition);
    140. view.setViewName("redirect:index.do");
    141. return view;
    142. }
    143. /**
    144. * 功能描述:菜单管理
    145. * @param request
    146. * @param response
    147. * @return
    148. * @throws ServletException
    149. * @throws IOException
    150. */
    151. @RequestMapping("/itemManageUI")
    152. public ModelAndView itemManageUI(HttpServletRequest request,
    153. HttpServletResponse response) throws ServletException, IOException {
    154. ModelAndView view = new ModelAndView();
    155. String pageNumStr = request.getParameter("pageNum");
    156. int pageNum = 1;
    157. int pageSize = 10;
    158. try {
    159. pageNum = Integer.parseInt(pageNumStr);
    160. } catch (NumberFormatException e) {
    161. }
    162. Dish tempDish = new Dish();
    163. tempDish.setOrderByCondition("u.id");
    164. List dishList = dishService.getPageList(pageNum, pageSize,tempDish);
    165. PageInfo pageInfo = new PageInfo(dishList);
    166. request.setAttribute("dishType", dishService.getDishTypeList());
    167. request.setAttribute("page", pageInfo);
    168. view.setViewName("jsp/book/itemManege");
    169. return view;
    170. }
    171. /**
    172. * 功能描述:跳转到添加菜单页面
    173. * @param request
    174. * @param response
    175. * @return
    176. * @throws ServletException
    177. * @throws IOException
    178. */
    179. @RequestMapping("/itemAddUI")
    180. public ModelAndView itemAddUI(HttpServletRequest request,
    181. HttpServletResponse response) throws ServletException, IOException {
    182. ModelAndView view = new ModelAndView();
    183. request.setAttribute("dishType", dishService.getDishTypeList());
    184. request.setAttribute("UUID", UUIDUtil.getUUID());
    185. view.setViewName("jsp/book/book-add");
    186. return view;
    187. }
    188. /**
    189. * 功能描述:新增菜单
    190. * @param request
    191. * @param response
    192. * @return
    193. * @throws ServletException
    194. * @throws IOException
    195. */
    196. @RequestMapping("/addDish")
    197. public ModelAndView addDish(HttpServletRequest request, HttpServletResponse response)
    198. throws ServletException, IOException {
    199. ModelAndView view = new ModelAndView();
    200. String name = request.getParameter("name");
    201. Integer type_id = 1;
    202. String typeIdStr = request.getParameter("type_id");
    203. Float price = 10.5F;
    204. String priceStr = request.getParameter("price");
    205. String picture = request.getParameter("picture");
    206. Long sale = 0l;
    207. Integer stock = 10;
    208. String description = request.getParameter("description");
    209. try {
    210. type_id = Integer.parseInt(typeIdStr);
    211. price = Float.parseFloat(priceStr);
    212. } catch (NumberFormatException e) {
    213. // TODO Auto-generated catch block
    214. e.printStackTrace();
    215. }
    216. dishService.addBook(name, type_id, price, picture, sale, stock,
    217. description);
    218. view.setViewName("redirect:itemManageUI.do");
    219. return view;
    220. }
    221. /**
    222. * 功能描述:跳转到修改页面
    223. * @param request
    224. * @param response
    225. * @return
    226. * @throws ServletException
    227. * @throws IOException
    228. */
    229. @RequestMapping("/itemEditUI")
    230. public ModelAndView itemEditUI(HttpServletRequest request,
    231. HttpServletResponse response) throws ServletException, IOException {
    232. String idStr = request.getParameter("id");
    233. ModelAndView view = new ModelAndView();
    234. Long id = 1l;
    235. try {
    236. id = Long.parseLong(idStr);
    237. } catch (NumberFormatException e) {
    238. // TODO Auto-generated catch block
    239. e.printStackTrace();
    240. }
    241. Dish dish = dishService.getDishById(id);
    242. request.setAttribute("dishType", dishService.getDishTypeList());
    243. request.setAttribute("dish", dish);
    244. view.setViewName("jsp/book/book-add");
    245. return view;
    246. }
    247. /**
    248. * 功能描述:保存修改信息
    249. * @param request
    250. * @param response
    251. * @return
    252. * @throws ServletException
    253. * @throws IOException
    254. */
    255. @RequestMapping("/itemEdit")
    256. public ModelAndView itemEdit(HttpServletRequest request,
    257. HttpServletResponse response) throws ServletException, IOException {
    258. String idStr = request.getParameter("id");
    259. String pageNum = request.getParameter("pageNum");
    260. ModelAndView view = new ModelAndView();
    261. Long id = 1l;
    262. try {
    263. id = Long.parseLong(idStr);
    264. } catch (NumberFormatException e) {
    265. // TODO Auto-generated catch block
    266. e.printStackTrace();
    267. }
    268. String name = request.getParameter("name");
    269. Integer type_id = 1;
    270. String typeIdStr = request.getParameter("type_id");
    271. Float price = 10.5F;
    272. String priceStr = request.getParameter("price");
    273. String picture = request.getParameter("picture");
    274. Long sale = 0l;
    275. Integer stock = 10;
    276. String description = request.getParameter("description");
    277. try {
    278. type_id = Integer.parseInt(typeIdStr);
    279. price = Float.parseFloat(priceStr);
    280. } catch (NumberFormatException e) {
    281. // TODO Auto-generated catch block
    282. e.printStackTrace();
    283. }
    284. Dish dish = dishService.getDishById(id);
    285. sale = dish.getSale();
    286. stock =dish.getStock();
    287. dishService.eidtBook(id, name, type_id, price, picture, sale, stock,
    288. description);
    289. view.setViewName("redirect:itemManageUI.do?pageNum="+pageNum);
    290. return view;
    291. }
    292. /**
    293. * 功能描述:删除菜单
    294. * @param request
    295. * @param response
    296. * @return
    297. * @throws ServletException
    298. * @throws IOException
    299. */
    300. @RequestMapping("/itemDelete")
    301. public ModelAndView itemDelete(HttpServletRequest request,
    302. HttpServletResponse response) throws ServletException, IOException {
    303. String idStr = request.getParameter("id");
    304. String pageNum = request.getParameter("pageNum");
    305. Long id = null;
    306. ModelAndView view = new ModelAndView();
    307. try {
    308. id = Long.parseLong(idStr);
    309. } catch (NumberFormatException e) {
    310. e.printStackTrace();
    311. }
    312. try {
    313. dishService.deleteBook(id);
    314. } catch (Exception e) {
    315. }
    316. view.setViewName("redirect:itemManageUI.do?pageNum="+pageNum);
    317. return view;
    318. }
    319. /**
    320. * 功能描述:销售排行榜
    321. * @param request
    322. * @param response
    323. * @throws ServletException
    324. * @throws IOException
    325. */
    326. @RequestMapping("/getTopSaleDish")
    327. @ResponseBody
    328. public String getTopSaleDish(HttpServletRequest request, HttpServletResponse response)
    329. throws ServletException, IOException {
    330. Map map = new HashMap();
    331. ObjectMapper mapper = new ObjectMapper();
    332. String json = null;
    333. List dishList = dishService.getPageBySaleDesc(1,15);
    334. json = mapper.writeValueAsString(dishList);
    335. return json;
    336. }
    337. /**
    338. * 功能描述:各大菜式销量
    339. * @param request
    340. * @param response
    341. * @return
    342. * @throws ServletException
    343. * @throws IOException
    344. */
    345. @RequestMapping("/getSaleDishType")
    346. @ResponseBody
    347. public String getSaleDishType(HttpServletRequest request, HttpServletResponse response)
    348. throws ServletException, IOException {
    349. Map map = new HashMap();
    350. ObjectMapper mapper = new ObjectMapper();
    351. String json = null;
    352. List list =dishService.getDishTypeSales();
    353. json = mapper.writeValueAsString(list);
    354. return json;
    355. }
    356. }

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

  • 相关阅读:
    @Component在类上构造器注入无法注入
    【Flutter】【widget】Table 表格widget
    FRNet代码
    雨量水位监测显示屏内涝状况提前掌握
    Time-Frequency Signal Analysis and Processing 笔记
    SpringBoot SpringBoot 运维实用篇 2 配置高级 2.3 配置文件4级分类
    第7章——链接
    橘子学Mybatis02之基本对象前置了解
    二十三种设计模式全面解析-迭代器模式进阶篇:探索变体与扩展
    STM32中断和外部中断
  • 原文地址:https://blog.csdn.net/hanyunlong1989/article/details/126091138