时间:2023-06-04 06:42:01 | 来源:网站运营
时间:2023-06-04 06:42:01 来源:网站运营
java计算机毕业设计 美食推荐系统 美食菜谱分享系统 食谱推荐系统 美食分享网站 java美食交流网站 营养食谱推荐系统:开发语言:Java
数据库:MySQL
系统架构:B/S
后台框架:SSM(Spring+SpringMVC+Mybatis)
前端:HTML+CSS+JavaScript+jQuery+Bootstrap
设计模式:MVC
@Controller@RequestMapping("/food")public class FoodController { private String prefix = "/user/"; @Resource private FoodMapper foodMapper; @Resource private CategoryMapper categoryMapper; @Resource private CollectMapper collectMapper; @Resource private RecipesItemMapper recipesItemMapper; // 美食详情 @RequestMapping("/shop.html") public String shopHtml (@RequestParam("id") int id, HttpSession session, Model model) { User user = (User) session.getAttribute(SessionConstant.KEY_USER); Food food = foodMapper.selectByPrimaryKey(id); List<Category> categoryList = categoryMapper.selectListByAll(); List<Food> foodList = foodMapper.selectListByCollectCount(10); Collect collect = collectMapper.selectByFoodIdAndUserId(id, user.getId()); // 访问量 + 1 food.setReadCount(food.getReadCount() + 1); foodMapper.updateByPrimaryKeySelective(food); model.addAttribute("food", food); model.addAttribute("categoryList", categoryList); model.addAttribute("foodList", foodList); model.addAttribute("collect", collect); return prefix + "food"; } // 搜索 @RequestMapping("/search.html") public String searchHtml (@RequestParam(value = "categoryId", required = false) Integer categoryId, @RequestParam(value = "search") String search, Model model){ List<Category> categoryList = categoryMapper.selectListByAll(); List<Food> foodList = foodMapper.selectListBySearch(categoryId, search); model.addAttribute("foodList", foodList); model.addAttribute("categoryList", categoryList); return prefix + "search"; } // 分页数据 @ResponseBody @RequestMapping("/data") public RespResult data(@RequestParam("page") Integer page, @RequestParam("limit") Integer limit, @RequestParam(value = "name", required = false, defaultValue = "") String name, @RequestParam(value = "categoryId", required = false, defaultValue = "") Integer categoryId) { if (name.equals("")) name = null; List<Food> foodList = foodMapper.selectListByPaging( (page - 1) * limit, limit, name, categoryId ); int count = foodMapper.selectCountByPaging( name, categoryId ); RespResult respResult = new RespResult(); respResult.success(foodList, count); return respResult; }}
关键词:系统,推荐,计算机,毕业,设计