——————————DescriptionStart——————————
运行环境 Java≥8、MySQL≥5.7、Tomcat≥8
开发工具 eclipse/idea/myeclipse/sts等均可配置运行
适用 课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
基于javaweb的SSM+Maven在线点餐系统(java+ssm+jsp+mysql+maven)
一、项目简述
功能包括: 在线点餐,评论,购物车,下单,支付,管理员,店家多 商家管理,后台评论管理,订单管理,商品管理等等。
二、项目运行
环境配置: Jdk1.8 + Tomcat8.5 + mysql + Eclispe (IntelliJ IDEA,Eclispe,MyEclispe,Sts 都支持)
项目技术: JSP +Spring + SpringMVC + MyBatis + html+ css + JavaScript + JQuery + Ajax + layui+ maven等等。
——————————CodeStart——————————
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 if (oi.getProduct().getId().intValue()==p.getId().intValue()){ oi.setNumber(oi.getNumber()+number); orderItemService.update(oi); found = true ; break ; } } if (!found){ OrderItem oi = new OrderItem(); oi.setCstid(customer.getId()); oi.setNumber(number); oi.setPid(pid); orderItemService.save(oi); } return "success" ; } @RequestMapping("/forecart") public String cart (Model model, HttpSession session) { Customer customer =(Customer) session.getAttribute("cst" ); List<OrderItem> ois = orderItemService.listByCustomer(customer.getId()); if (ois==null || ois.size()==0 ){ return "forepage/cart_noPro" ; } int totalProductNumber = 0 ; for (OrderItem oi:ois){ totalProductNumber += oi.getNumber(); }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 InputStream is = fileStream.openStream(); State storageState = StorageManager.saveFileByInputStream(is, physicalPath, maxSize); is.close(); if (storageState.isSuccess()) { storageState.putInfo("url" , PathFormat.format(savePath)); storageState.putInfo("type" , suffix); storageState.putInfo("original" , originFileName + suffix); } return storageState; } catch (FileUploadException e) { return new BaseState(false , AppInfo.PARSE_REQUEST_ERROR); } catch (IOException e) { } return new BaseState(false , AppInfo.IO_ERROR); } private static boolean validType (String type, String[] allowTypes) { List<String> list = Arrays.asList(allowTypes); return list.contains(type); } } package com.demo.controller;
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 break ; fileStream = null ; } if (fileStream == null ) { return new BaseState(false , AppInfo.NOTFOUND_UPLOAD_DATA); } String savePath = (String) conf.get("savePath" ); String originFileName = fileStream.getName(); String suffix = FileType.getSuffixByFilename(originFileName); originFileName = originFileName.substring(0 , originFileName.length() - suffix.length()); savePath = savePath + suffix; long maxSize = ((Long) conf.get("maxSize" )).longValue(); if (!validType(suffix, (String[]) conf.get("allowFiles" ))) { return new BaseState(false , AppInfo.NOT_ALLOW_FILE_TYPE); } savePath = PathFormat.parse(savePath, originFileName); String physicalPath = (String) conf.get("rootPath" ) + savePath; InputStream is = fileStream.openStream(); State storageState = StorageManager.saveFileByInputStream(is, physicalPath, maxSize); is.close(); if (storageState.isSuccess()) { storageState.putInfo("url" , PathFormat.format(savePath)); storageState.putInfo("type" , suffix); storageState.putInfo("original" , originFileName + suffix); } return storageState; } catch (FileUploadException e) { return new BaseState(false , AppInfo.PARSE_REQUEST_ERROR);
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 session.setAttribute("subject" , subject); session.setAttribute("lastLoginTime" ,lastLoginTime); return "redirect:index" ; }else { model.addAttribute("error" , "账号已被停用!" ); return "/login" ; } } catch (AuthenticationException e) { model.addAttribute("error" , "验证失败!" ); return "/login" ; } } } package com.demo.controller;@Controller @RequestMapping("/config") public class PermissionController { @Autowired PermissionService permissionService; @RequestMapping("/adminPerAddUI") public String addUI () { return "syspage/admin-permission-add" ; }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 @Controller @RequestMapping("/config") public class UserController { @Autowired UserRoleService userRoleService; @Autowired UserService userService; @Autowired RoleService roleService; @RequestMapping("/enableStatus") @ResponseBody public String enableStatus (@RequestParam(value = "name") String name) { return userService.enableStatus(name); } @RequestMapping("/stopStatus") @ResponseBody public String stopStatus (@RequestParam(value = "name") String name) { return userService.stopStatus(name); } @RequestMapping("/adminAdd") public String adminadd (Model model) { List<Role> list = roleService.list(); model.addAttribute("rolelist" ,list); return "syspage/admin-add" ; } @RequestMapping("/listUser") public String list (Model model, Page page) { PageHelper.offsetPage(page.getStart(),page.getCount()); List<User> us= userService.list(); int total = (int ) new PageInfo<>(us).getTotal(); page.setTotal(total); model.addAttribute("us" , us); model.addAttribute("total" ,total); Map<User,List<Role>> user_roles = new HashMap<>();
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 } package com.demo.common.Interceptor;public class LoginInterceptor extends HandlerInterceptorAdapter { @Autowired OrderItemService orderItemService; @Override public boolean preHandle (HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
——————————PayStart——————————
项目链接: https://javayms.github.io?id=001422282105200cb https://javayms.pages.dev?id=001422282105200cb