• 猿创征文|瑞吉外卖——移动端_手机端展示


    个人名片:

    博主酒徒ᝰ.
    专栏瑞吉外卖
    个人简介沉醉在酒中,借着一股酒劲,去拼搏一个未来。
    本篇励志成功的捷径就在于与众不同,绝不做普通的大多数人。

    本项目基于B站黑马程序员Java项目实战《瑞吉外卖》,轻松掌握springboot + mybatis plus开发核心技术的真java实战项目。

    视频链接【黑马程序员Java项目实战《瑞吉外卖》,轻松掌握springboot + mybatis
    plus开发核心技术的真java实战项目】 https://www.bilibili.com/video/BV13a411q753?
    点击观看

    1.购物车展示(页面显示)

    image.png

    分析:shoppingCart地址,GET方式,list地址
    有上述分析,可以知道这里显示的其实是购物车。当购物车显示时,页面也就跟着显示。
    这里显示的不仅有菜品,还有套餐。所以使用DishDto。
    手机端不分页。

    package com.itheima.reggie.controller;
    
    
    import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
    import com.itheima.reggie.common.R;
    import com.itheima.reggie.entity.*;
    import com.itheima.reggie.service.*;
    import lombok.extern.slf4j.Slf4j;
    import org.springframework.beans.factory.annotation.Autowired;
    import org.springframework.web.bind.annotation.GetMapping;
    import org.springframework.web.bind.annotation.RequestMapping;
    
    import org.springframework.web.bind.annotation.RestController;
    
    import javax.servlet.http.HttpSession;
    import java.util.List;
    
    /**
     * 

    * 购物车 前端控制器 *

    * * @author 酒徒 * @since 2022-09-04 */
    @Slf4j @RestController @RequestMapping("/shoppingCart") public class ShoppingCartController { @Autowired private IShoppingCartService shoppingCartService; @GetMapping("/list") public R<List<ShoppingCart>> list(HttpSession session){ //根据用户id获取购物车内所有信息 LambdaQueryWrapper<ShoppingCart> queryWrapper = new LambdaQueryWrapper<>(); queryWrapper.eq(ShoppingCart::getUserId, session.getAttribute("user")) .orderByAsc(ShoppingCart::getCreateTime); List<ShoppingCart> list = shoppingCartService.list(queryWrapper); return R.success(list); } }
    • 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

    发现一个问题,菜品没有口味信息,这个需要在DishController中进行修改

    /**
    * 套餐——新增套餐——套餐菜品显示——移动端菜品显示口味
    * @param categoryId
    * @return
    */
    @GetMapping("/list")
    public R<List<DishDto>> list(@PathParam("categoryId") Long categoryId){
        //根据categoryId查询菜品名
        LambdaQueryWrapper<Dish> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(Dish::getCategoryId, categoryId)
            .eq(Dish::getStatus, 1)
            .orderByAsc(Dish::getSort)
            .orderByDesc(Dish::getUpdateTime);
        List<Dish> list = dishService.list(queryWrapper);
        //为菜品添加口味
        List<DishDto> dishDtoList = list.stream().map((item) -> {
            //赋值每一个dish到dishDto中
            DishDto dishDto = new DishDto();
            BeanUtils.copyProperties(item, dishDto);
    
            //根据dishid查询菜品口味
            LambdaQueryWrapper<DishFlavor> wrapper = new LambdaQueryWrapper<>();
            wrapper.eq(DishFlavor::getDishId, item.getId());
            List<DishFlavor> flavors = dishFlavorService.list(wrapper);
            //添加菜品口味到dishDto中
            dishDto.setFlavors(flavors);
    
            return dishDto;
        }).collect(Collectors.toList());
    
        return R.success(dishDtoList);
    }
    
    • 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

    2.套餐展示

    image.png

    分析:setmeal地址,GET方式,list地址,category,status属性

    /**
     * 套餐显示
     * @param categoryId
     * @param status
     * @return
     */
    @GetMapping("/list")
    public  R<List<Setmeal>> list(@PathParam("categoryId") Long categoryId, int status){
        //log.info("category:{}",categoryId);
        //log.info("status:{}",status);
    
        //根据categoryId查询套餐信息
        LambdaQueryWrapper<Setmeal> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(Setmeal::getCategoryId, categoryId).eq(Setmeal::getStatus, status);
        List<Setmeal> list = setmealService.list(queryWrapper);
        return R.success(list);
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
  • 相关阅读:
    ORM数据库操作
    微服务自动化【Docker-Compose】
    网络基础2(上):http协议、tcp/udp协议
    python wechat --- 企业微信机器人API
    从Java源码探索哈希表的前世今生
    小程序容器技术加快推动国产操作系统“上车”
    什么是集成测试?集成测试方法有哪些?
    ChatGPT第八讲
    pytorch-gpu(Anaconda3+cuda+cudnn)
    大一学生WEB前端静态网页——旅游网页设计与实现-张家口 6页
  • 原文地址:https://blog.csdn.net/m0_65144570/article/details/126814922