海上捞火锅

海上捞火锅


查询具体菜品/套餐内容

<p>[TOC]</p> <h5>简要描述</h5> <ul> <li>查询具体菜品、套餐内容</li> </ul> <h5>前端页面和服务端的交互过程</h5> <ul> <li>点击移动端套餐的图片,发现会向后端发送一个get请求</li> </ul> <h5>触发事件</h5> <pre><code>v-model="detailsDialog.show" :show-confirm-button="false"</code></pre> <pre><code>v-model="setMealDialog.show" :show-confirm-button="false"</code></pre> <h5>接口调用</h5> <pre><code>const res = await dishListApi({categoryId:this.categoryId,status:1}) if(res.code === 1){ let dishList = res.data const cartData = this.cartData if(dishList.length &gt; 0 &amp;&amp; cartData.length &gt; 0){ dishList.forEach(dish=&gt;{ cartData.forEach(cart=&gt;{ if(dish.id === cart.dishId){ dish.number = cart.number } }) }) } this.dishList = dishList }</code></pre> <h5>请求URL</h5> <ul> <li><code>[context-path]/setmeal/dish/${id}</code></li> </ul> <h5>请求方式</h5> <ul> <li>GET</li> </ul> <h5>接口API</h5> <pre><code>function setMealDishDetailsApi(id) { return $axios({ 'url': `/setmeal/dish/${id}`, 'method': 'get', }) }</code></pre> <h5>返回示例</h5> <pre><code>code: 1 data: [,…] map: {} msg: null</code></pre> <h5>返回参数说明</h5> <table> <thead> <tr> <th style="text-align: left;">参数名</th> <th style="text-align: left;">类型</th> <th>说明</th> </tr> </thead> <tbody> <tr> <td style="text-align: left;">code</td> <td style="text-align: left;">int</td> <td>返回码,1:成功;0或其他:失败</td> </tr> <tr> <td style="text-align: left;">data</td> <td style="text-align: left;">object</td> <td>返回数据</td> </tr> <tr> <td style="text-align: left;">map</td> <td style="text-align: left;">map</td> <td>动态数据</td> </tr> <tr> <td style="text-align: left;">msg</td> <td style="text-align: left;">string</td> <td>错误信息</td> </tr> </tbody> </table> <h5>备注</h5> <p>data有两种返回值</p> <pre><code>public static &lt;T&gt; R&lt;T&gt; success(T object) { R&lt;T&gt; r = new R&lt;T&gt;(); r.data = object; r.code = 1; return r; } public static &lt;T&gt; R&lt;T&gt; error(String msg) { R r = new R(); r.msg = msg; r.code = 0; return r; }</code></pre> <h5>后端接口请求参数</h5> <ul> <li>通过 @PathVariable 将 URL 中占位符参数“id”绑定到控制器处理入参</li> </ul> <h5>后端代码</h5> <pre><code> @GetMapping("/dish/{id}") public R&lt;List&lt;DishDto&gt;&gt; setMealDishDetails(@PathVariable("id") Long SetmealId){ LambdaQueryWrapper&lt;SetmealDish&gt; queryWrapper = new LambdaQueryWrapper&lt;&gt;(); queryWrapper.eq(SetmealDish::getSetmealId,SetmealId); List&lt;SetmealDish&gt; list = setmealDishService.list(queryWrapper); List&lt;DishDto&gt; dishDtos = list.stream().map((setmealDish) -&gt; { DishDto dishDto = new DishDto(); BeanUtils.copyProperties(setmealDish, dishDto); Long dishId = setmealDish.getDishId(); Dish dish = dishService.getById(dishId); BeanUtils.copyProperties(dish, dishDto); return dishDto; }).collect(Collectors.toList()); return R.success(dishDtos); } }</code></pre>

页面列表

ITEM_HTML