基于java SpringBoot和Vue校园食堂网站管理系统设计

摘要

本文旨在探讨一种基于Java Spring Boot和Vue框架的校园食堂网站管理系统的设计。首先,介绍了系统开发的背景及意义,即为了提高校园食堂的管理效率和改善学生的就餐体验。接着,详细阐述了系统的技术选型,包括后端采用Spring Boot框架以简化企业级应用开发,前端选用Vue框架以实现响应式界面和良好的用户体验。然后,描述了系统的主要功能模块,如用户管理、菜单浏览、在线点餐、支付结算等,并强调了其在数据处理和安全性方面的设计考虑。最后,总结了该系统的优势,如易于维护、扩展性强和用户友好等,同时也指出了未来改进的方向,如增加个性化推荐和优化用户交互设计。本研究对于推动校园食堂信息化建设具有一定的参考价值。

功能介绍

管理员、商家和学生三种用户角色;

管理员:个人中心、管理员管理、商家管理、用户管理、用户管理、食堂管理、美食管理、基础数据管理、论坛管理、新闻公告管理、轮播图管理等;

商家:个人中心、食堂管理、美食管理、论坛管理、新闻公告管理等;

学生:首页浏览、论坛交流、美食下单、公告查看、个人中心(地址管理、收藏管理评价管理、订单管理)等。

技术介绍

后端:Java语言的Spring Boot框架、MySQL数据库、Maven依赖管理等;

前端:Vue、element-ui、axios等。

部分代码展示

java 复制代码
/**
    * 后端列表
    */
    @RequestMapping("/page")
    public R page(@RequestParam Map<String, Object> params, HttpServletRequest request){
        logger.debug("page方法:,,Controller:{},,params:{}",this.getClass().getName(),JSONObject.toJSONString(params));
        String role = String.valueOf(request.getSession().getAttribute("role"));
        if(false)
            return R.error(511,"永不会进入");
        else if("用户".equals(role))
            params.put("yonghuId",request.getSession().getAttribute("userId"));
        else if("商家".equals(role))
            params.put("shangjiaId",request.getSession().getAttribute("userId"));
        CommonUtil.checkMap(params);
        PageUtils page = cartService.queryPage(params);

        //字典表数据转换
        List<CartView> list =(List<CartView>)page.getList();
        for(CartView c:list){
            //修改对应字典表字段
            dictionaryService.dictionaryConvert(c, request);
        }
        return R.ok().put("data", page);
    }

    /**
    * 后端详情
    */
    @RequestMapping("/info/{id}")
    public R info(@PathVariable("id") Long id, HttpServletRequest request){
        logger.debug("info方法:,,Controller:{},,id:{}",this.getClass().getName(),id);
        CartEntity cart = cartService.selectById(id);
        if(cart !=null){
            //entity转view
            CartView view = new CartView();
            BeanUtils.copyProperties( cart , view );//把实体数据重构到view中
            //级联表 美食
            //级联表
            MeishiEntity meishi = meishiService.selectById(cart.getMeishiId());
            if(meishi != null){
            BeanUtils.copyProperties( meishi , view ,new String[]{ "id", "createTime", "insertTime", "updateTime", "yonghuId"});//把级联的数据添加到view中,并排除id和创建时间字段,当前表的级联注册表
            view.setMeishiId(meishi.getId());
            }
            //级联表 用户
            //级联表
            YonghuEntity yonghu = yonghuService.selectById(cart.getYonghuId());
            if(yonghu != null){
            BeanUtils.copyProperties( yonghu , view ,new String[]{ "id", "createTime", "insertTime", "updateTime", "yonghuId"});//把级联的数据添加到view中,并排除id和创建时间字段,当前表的级联注册表
            view.setYonghuId(yonghu.getId());
            }
            //修改对应字典表字段
            dictionaryService.dictionaryConvert(view, request);
            return R.ok().put("data", view);
        }else {
            return R.error(511,"查不到数据");
        }

    }

    /**
    * 后端保存
    */
    @RequestMapping("/save")
    public R save(@RequestBody CartEntity cart, HttpServletRequest request){
        logger.debug("save方法:,,Controller:{},,cart:{}",this.getClass().getName(),cart.toString());

        String role = String.valueOf(request.getSession().getAttribute("role"));
        if(false)
            return R.error(511,"永远不会进入");
        else if("用户".equals(role))
            cart.setYonghuId(Integer.valueOf(String.valueOf(request.getSession().getAttribute("userId"))));

        Wrapper<CartEntity> queryWrapper = new EntityWrapper<CartEntity>()
            .eq("yonghu_id", cart.getYonghuId())
            .eq("meishi_id", cart.getMeishiId())
            .eq("buy_number", cart.getBuyNumber())
            ;

        logger.info("sql语句:"+queryWrapper.getSqlSegment());
        CartEntity cartEntity = cartService.selectOne(queryWrapper);
        if(cartEntity==null){
            cart.setCreateTime(new Date());
            cart.setInsertTime(new Date());
            cartService.insert(cart);
            return R.ok();
        }else {
            return R.error(511,"商品已添加到购物车");
        }
    }

    /**
    * 后端修改
    */
    @RequestMapping("/update")
    public R update(@RequestBody CartEntity cart, HttpServletRequest request) throws NoSuchFieldException, ClassNotFoundException, IllegalAccessException, InstantiationException {
        logger.debug("update方法:,,Controller:{},,cart:{}",this.getClass().getName(),cart.toString());
        CartEntity oldCartEntity = cartService.selectById(cart.getId());//查询原先数据

        String role = String.valueOf(request.getSession().getAttribute("role"));

        cart.setUpdateTime(new Date());

            cartService.updateById(cart);//根据id更新
            return R.ok();
    }



    /**
    * 删除
    */
    @RequestMapping("/delete")
    public R delete(@RequestBody Integer[] ids, HttpServletRequest request){
        logger.debug("delete:,,Controller:{},,ids:{}",this.getClass().getName(),ids.toString());
        List<CartEntity> oldCartList =cartService.selectBatchIds(Arrays.asList(ids));//要删除的数据
        cartService.deleteBatchIds(Arrays.asList(ids));

        return R.ok();
    }


    /**
     * 批量上传
     */
    @RequestMapping("/batchInsert")
    public R save( String fileName, HttpServletRequest request){
        logger.debug("batchInsert方法:,,Controller:{},,fileName:{}",this.getClass().getName(),fileName);
        Integer yonghuId = Integer.valueOf(String.valueOf(request.getSession().getAttribute("userId")));
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        try {
            List<CartEntity> cartList = new ArrayList<>();//上传的东西
            Map<String, List<String>> seachFields= new HashMap<>();//要查询的字段
            Date date = new Date();
            int lastIndexOf = fileName.lastIndexOf(".");
            if(lastIndexOf == -1){
                return R.error(511,"该文件没有后缀");
            }else{
                String suffix = fileName.substring(lastIndexOf);
                if(!".xls".equals(suffix)){
                    return R.error(511,"只支持后缀为xls的excel文件");
                }else{
                    URL resource = this.getClass().getClassLoader().getResource("static/upload/" + fileName);//获取文件路径
                    File file = new File(resource.getFile());
                    if(!file.exists()){
                        return R.error(511,"找不到上传文件,请联系管理员");
                    }else{
                        List<List<String>> dataList = PoiUtil.poiImport(file.getPath());//读取xls文件
                        dataList.remove(0);//删除第一行,因为第一行是提示
                        for(List<String> data:dataList){
                            //循环
                            CartEntity cartEntity = new CartEntity();
                            cartList.add(cartEntity);


                            //把要查询是否重复的字段放入map中
                        }

                        //查询是否重复
                        cartService.insertBatch(cartList);
                        return R.ok();
                    }
                }
            }
        }catch (Exception e){
            e.printStackTrace();
            return R.error(511,"批量插入数据异常,请联系管理员");
        }
    }




    /**
    * 前端列表
    */
    @IgnoreAuth
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params, HttpServletRequest request){
        logger.debug("list方法:,,Controller:{},,params:{}",this.getClass().getName(),JSONObject.toJSONString(params));

        CommonUtil.checkMap(params);
        PageUtils page = cartService.queryPage(params);

        //字典表数据转换
        List<CartView> list =(List<CartView>)page.getList();
        for(CartView c:list)
            dictionaryService.dictionaryConvert(c, request); //修改对应字典表字段

        return R.ok().put("data", page);
    }

    /**
    * 前端详情
    */
    @RequestMapping("/detail/{id}")
    public R detail(@PathVariable("id") Long id, HttpServletRequest request){
        logger.debug("detail方法:,,Controller:{},,id:{}",this.getClass().getName(),id);
        CartEntity cart = cartService.selectById(id);
            if(cart !=null){


                //entity转view
                CartView view = new CartView();
                BeanUtils.copyProperties( cart , view );//把实体数据重构到view中

                //级联表
                    MeishiEntity meishi = meishiService.selectById(cart.getMeishiId());
                if(meishi != null){
                    BeanUtils.copyProperties( meishi , view ,new String[]{ "id", "createDate"});//把级联的数据添加到view中,并排除id和创建时间字段
                    view.setMeishiId(meishi.getId());
                }
                //级联表
                    YonghuEntity yonghu = yonghuService.selectById(cart.getYonghuId());
                if(yonghu != null){
                    BeanUtils.copyProperties( yonghu , view ,new String[]{ "id", "createDate"});//把级联的数据添加到view中,并排除id和创建时间字段
                    view.setYonghuId(yonghu.getId());
                }
                //修改对应字典表字段
                dictionaryService.dictionaryConvert(view, request);
                return R.ok().put("data", view);
            }else {
                return R.error(511,"查不到数据");
            }
    }


    /**
    * 前端保存
    */
    @RequestMapping("/add")
    public R add(@RequestBody CartEntity cart, HttpServletRequest request){
        logger.debug("add方法:,,Controller:{},,cart:{}",this.getClass().getName(),cart.toString());
        Wrapper<CartEntity> queryWrapper = new EntityWrapper<CartEntity>()
            .eq("yonghu_id", cart.getYonghuId())
            .eq("meishi_id", cart.getMeishiId())
            .eq("buy_number", cart.getBuyNumber())
//            .notIn("cart_types", new Integer[]{102})
            ;
        logger.info("sql语句:"+queryWrapper.getSqlSegment());
        CartEntity cartEntity = cartService.selectOne(queryWrapper);
        if(cartEntity==null){
            cart.setCreateTime(new Date());
            cart.setInsertTime(new Date());
        cartService.insert(cart);

            return R.ok();
        }else {
            return R.error(511,"表中有相同数据");
        }
    }

}

演示视频

Java SpringBoot和Vue校园食堂网站管理系统

相关推荐
sunbyte2 分钟前
50天50个小项目 (Vue3 + Tailwindcss V4) ✨ | GoodCheapFast(Good - Cheap - Fast三选二开关)
前端·javascript·css·vue.js·tailwindcss
Shimiy14 分钟前
第六章 面向对象编程------进阶
java
大葱白菜18 分钟前
Java Set 集合详解:从基础语法到实战应用,彻底掌握去重与唯一性集合
java·后端
大葱白菜19 分钟前
Java Map 集合详解:从基础语法到实战应用,彻底掌握键值对数据结构
java·后端
添乱19 分钟前
「Java案例」判断是否是闰年的方法
java
FG.24 分钟前
Day22
java·面试
菜鸟的迷茫26 分钟前
Redis 缓存雪崩、穿透、击穿面试题深度解析与 Spring Boot 实战代码示例
java
昵称为空C33 分钟前
SpringBoot数据存储时区选择,符合国际化和特定时区方案
spring boot·后端
珹洺37 分钟前
C++算法竞赛篇:DevC++ 如何进行debug调试
java·c++·算法
remCoding37 分钟前
Java全栈面试实录:从电商场景到AIGC的深度技术考察
spring boot·redis·spring cloud·ai·kafka·aigc·java面试