——————————DescriptionStart——————————
运行环境 Java≥8、MySQL≥5.7
开发工具 eclipse/idea/myeclipse/sts等均可配置运行
适用 课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
基于javaweb的SpringBoot点餐系统(java+springboot+ssm+mysql+maven)
一、项目简述
功能:数据库采用mysq昨为数据存储,系统中涉及到的关 键表有,用户表、用户详情表、商品表、订单表、商品订 单关联表、评价表等等。本系统分为前端和后端,前端功 能有:登录注册、修改个人信息、修改收货地址、查看商 品、加购商品、结算商品,对订单进行评价、用户留言等 功能;后端功能有:登录、商品管理、用户管理、订单管 理、留言公告管理等功能。本系统中的购物车功能设计、io流读写图片存放本地、订单导出、“echarts插件实现订单信 息统计、后台批量操作、pagehelper实现分页等细节值得 学习。
二、项目运行
环境配置: Jdk1.8 + mysql + Eclispe (IntelliJ IDEA,Eclispe,MyEclispe,Sts 都支持)
项目技术: JSP +Springboot+ 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 41 42 43 44 45 46 47 48 State state = null ; int actionCode = ActionMap.getType( this .actionType ); Map<String, Object> conf = null ; switch ( actionCode ) { case ActionMap.CONFIG: return this .configManager.getAllConfig().toString(); case ActionMap.UPLOAD_IMAGE: case ActionMap.UPLOAD_SCRAWL: case ActionMap.UPLOAD_VIDEO: case ActionMap.UPLOAD_FILE: conf = this .configManager.getConfig( actionCode ); state = new Uploader( request, conf ).doExec(); break ; case ActionMap.CATCH_IMAGE: conf = configManager.getConfig( actionCode ); String[] list = this .request.getParameterValues( (String)conf.get( "fieldName" ) ); state = new ImageHunter( conf ).capture( list ); break ; case ActionMap.LIST_IMAGE: case ActionMap.LIST_FILE: conf = configManager.getConfig( actionCode ); int start = this .getStartIndex(); state = new FileManager( conf ).listFile( start ); break ; } return state.toJSONString(); } public int getStartIndex () { String start = this .request.getParameter( "start" ); try { return Integer.parseInt( start ); } catch ( Exception e ) { return 0 ; }
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 @RequestMapping("/admin/toProductBanner") public String toProductBanner (Model model,@RequestParam(required = true, defaultValue = "1") Integer page) { PageHelper.startPage(page,5 ); List<ProductBanner> productBannerList = productService.findAllProductBanner(); PageInfo<ProductBanner> pageInfo = new PageInfo<>(productBannerList); model.addAttribute("page" ,pageInfo); model.addAttribute("productBannerList" ,productBannerList); return "/admin/product/product_banner_list" ; } @RequestMapping("/admin/toAddProductBanner") public String toAddProductBanner () { return "/admin/product/product_banner_edit" ; } @GetMapping(value = "/admin/validProduct/list" ,produces = "application/json;charset=utf-8") @ResponseBody public Object getValidProduct () { List<Product> validProductList = new ArrayList<>(); productService.findAllProductList(). stream().filter(product -> product.getStatus() == 1 ). collect(Collectors.toList()).forEach(product ->{ if (productService.findProductBannerById(product.getId()) == null ){ validProductList.add(product); } }); return ResponseMessageEnum.SUCCESS.appendObjectToString(validProductList); } @RequestMapping("/admin/addNewProductBanner") public String addNewProductBanner (ProductBanner productBanner) { productService.addNewProductBanner(productBanner); return "redirect:/admin/toProductBanner" ; } @RequestMapping("/admin/deleteProductBanner") public String deleteProductBanner (Integer id) {
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 46 47 48 49 for (Product product : productList) { cartMap.put(product, buyCount); } session.setAttribute("cart" , cartMap); session.setAttribute("buyCount" , 0 ); return "/pages/order/cart" ; } @GetMapping("/toMyCart") public String tocart () { return "/pages/order/cart" ; } @PostMapping("/toDelete") public String toDelete (Integer productId, HttpSession session, Model model) { Product product = productService.findProductById(productId); System.out.println(product); ((Map<Product, Integer>) session.getAttribute("cart" )).remove(product); System.out.println("size:" + ((Map<Product, Integer>) session.getAttribute("cart" )).size()); return "/pages/order/cart" ; } @PostMapping("/toOrder") public String toOrder (HttpSession session, String[] buyNum, Model model,@RequestParam("id") Integer[] id, @RequestParam("checkId") Integer[] checkId) { User user = (User) session.getAttribute("user" ); UserInfo dbUserInfo = userService.findAdressByUserId(user.getId().toString()); Map<Integer,Integer> map = new HashMap<>(); for (int i = 0 ; i < id.length; i++){ map.put(id[i],Integer.parseInt(buyNum[i])); } Subject subject = SecurityUtils.getSubject(); Map<Product, Integer> myCartMap = new HashMap<>(); subject.getSession().setAttribute("myCartMap" , myCartMap); Map<Product, Integer> myOrder = (HashMap<Product, Integer>) session.getAttribute("myCartMap" ); for (Integer cId :checkId){
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 @Controller public class LoginController { @Autowired private UserService userService; @PostMapping("/loginLogin") public String loginLogin (Model model, String username, String password) { User dbUser = userService.findUserByU_P(username, password); if (dbUser != null && dbUser.getStatus() == 0 ){ model.addAttribute("errorInfo" ,"该账号已禁用,请联系管理员..." ); return "/login" ; } Subject subject = SecurityUtils.getSubject(); UsernamePasswordToken token = new UsernamePasswordToken(username, password); try { subject.login(token); User user = (User) subject.getPrincipal(); subject.getSession().setAttribute("user" , user);
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 46 protected Map<String,Object> getTitleArrayAndVarList (List<Object> dataList) { Map<String,Object> dataMap = new HashMap<String,Object>(); String[] titleArray = { "订单序号" , "订单编号" , "订单金额" , "收货人" , "收获地址" , "下单时间" , "订单状态" }; dataMap.put("titles" , Arrays.asList(titleArray)); List<OrderExcelExportVO> varList = new ArrayList<OrderExcelExportVO>(); for (int i=0 ;i<dataList.size();i++){ OrderExcelExportVO data = (OrderExcelExportVO)dataList.get(i); List<Object> vpd = new ArrayList<>(); varList.add(data); } dataMap.put("varList" , varList); return dataMap; } protected Map<String,String> getExcelTitleAndFileName () { Map<String,String> excelMap = new HashMap<String,String>(); excelMap.put("excelTitle" ,"订单信息表格" ); DateFormat sdf = new SimpleDateFormat("yyyyMMdd" ); String time = sdf.format(new Timestamp(System.currentTimeMillis())); excelMap.put("fileName" ,"订单信息表格" + time); return excelMap; } protected AbstractExcelView getAbstractExcelView (Map<String, String> excelMap) { try { ObjectExcelViewOrder erv = new ObjectExcelViewOrder(excelMap.get("fileName" ),excelMap.get("excelTitle" )); return erv; } catch (Exception e) {
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 @Controller public class Back_ProductController { @Autowired private ProductService productService; @Autowired private ProductKindService productKindService; @RequestMapping("/admin/toSelect") public String toSelect (@RequestParam("Pname") String Pname, Model model) { List<Product> list = productService.findAllProductCondition(Pname); model.addAttribute("productList" , list); return "/admin/product/product_list" ; }
——————————PayStart——————————
项目链接: https://javayms.github.io?id=171422322105200jy https://javayms.pages.dev?id=171422322105200jy