保姆级教学:从0搭建微信小程序SpringBoot+Vue(一)对应后端源码及sql脚本 请搭配前端小程序页面使用~
立即下载
资源介绍:
xiaomaibu项目导入Idea,所用数据库为MySQL,运行sql脚本,就可以run啦。
package org.example.xiaomaibu.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.example.xiaomaibu.entity.xmb_dish;
import org.example.xiaomaibu.entity.xmb_menu;
import org.example.xiaomaibu.service.DishService;
import org.example.xiaomaibu.service.MenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
import java.util.Map;
import java.util.HashMap;
@RestController
@RequestMapping("/dish")
public class DishController {
@Autowired
private DishService dishService;
@Autowired
private MenuService menuService;
@RequestMapping("/ListAll")
public Map ListAll(){
List menuList = menuService.list();
for(xmb_menu menu : menuList){
List dishList = dishService.list(new QueryWrapper().eq("typeid",menu.getId()));
menu.setDishList(dishList);
}
Map map = new HashMap<>();
map.put("dishList",menuList);
return map;
}
}