摘要

随着互联网技术的快速发展,个性化推荐系统在电子商务、社交媒体和在线服务等领域发挥着越来越重要的作用。美食推荐平台作为个性化服务的典型应用,能够帮助用户快速发现符合自身口味和需求的菜品,提升用户体验和平台粘性。豆果美食推荐系统平台基于用户行为数据和菜品特征,采用协同过滤和内容推荐相结合的混合推荐算法,实现精准推荐。该系统不仅满足用户个性化需求,还能为商家提供数据分析支持,优化菜品供应策略。关键词:美食推荐、个性化服务、协同过滤、内容推荐、Django。

本系统采用Python Django框架作为后端开发工具,结合MySQL数据库存储用户数据和菜品信息。前端使用HTML、CSS和JavaScript实现交互界面,确保用户友好性。系统功能模块包括用户注册登录、菜品分类浏览、收藏与评分、个性化推荐以及后台管理。通过Restful API接口实现前后端数据交互,确保系统的高效性和可扩展性。推荐算法部分结合用户历史行为数据和菜品标签,计算相似度并生成推荐列表。关键词:Django框架、MySQL数据库、Restful API、推荐算法、用户行为分析。

数据表设计

用户信息数据表

用户信息数据表存储用户注册及个人偏好数据,用户ID是该表的主键,记录用户基本信息和口味偏好,结构表如表3-1所示。

字段名 数据类型 说明
user_id INT 用户唯一标识(主键)
username VARCHAR 用户名
password VARCHAR 加密存储的密码
email VARCHAR 用户邮箱
flavor_pref TEXT 用户口味偏好(JSON格式)
reg_time DATETIME 注册时间(自动生成)
菜品信息数据表

菜品信息数据表存储平台所有菜品的详细信息,菜品ID是该表的主键,记录菜品名称、分类及营养成分等属性,结构表如表3-2所示。

字段名 数据类型 说明
dish_id INT 菜品唯一标识(主键)
dish_name VARCHAR 菜品名称
category VARCHAR 菜品分类(如中式、西式)
ingredients TEXT 主要食材(JSON格式)
calories FLOAT 热量(千卡)
create_time DATETIME 菜品上架时间(自动生成)
用户行为数据表

用户行为数据表记录用户对菜品的交互行为,行为ID是该表的主键,用于分析用户偏好并生成推荐,结构表如表3-3所示。

字段名 数据类型 说明
behavior_id INT 行为记录唯一标识(主键)
user_id INT 关联用户ID
dish_id INT 关联菜品ID
action_type VARCHAR 行为类型(浏览、收藏、评分)
rating FLOAT 用户评分(1-5分)
action_time DATETIME 行为发生时间(自动生成)

博主介绍:

专业背景
专注Java企业级开发与小程序生态,全网影响力10万+开发者,CSDN特邀作者、技术专家、新星计划导师。 🎯 核心服务 📚
毕业设计智库

微信小程序方向:100个前沿选题 Java企业级方向:500个实战选题 项目实战宝库:3000+精品案例

专业指导

选题策略规划:量身定制技术路线 架构设计指导:企业级应用构建 论文写作辅导:技术文档专业化

详细视频演示

请联系我获取更详细的演示视频

系统介绍:

Python Django 豆果美食推荐系统平台完整项目源码+SQL脚本+接口文档【Django Web毕设】,拿走直接用(附源码,数据库,视频,可提供说明文档(通过AIGC技术包括:MySQL、VueJS、ElementUI、(Python或者Java或者.NET)等等功能如图所示。可以滴我获取详细的视频介绍
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

功能参考截图:

文档参考:
在这里插入图片描述

技术架构栈

🔧 后端技术:Spring Boot
Spring Boot 作为现代Java企业级开发的核心框架,以其**“约定优于配置”**的设计哲学重新定义了应用开发模式。 核心特性解析:

零配置启动:集成自动配置机制,大幅减少XML配置文件编写 嵌入式服务器:内置Tomcat/Jetty/Undertow,支持独立JAR包部署
生产就绪:集成Actuator监控组件,提供健康检查、指标收集等企业级特性 微服务友好:天然支持分布式架构,与Spring
Cloud生态无缝集成

开发优势:
通过Starter依赖体系和智能自动装配,开发者可将精力完全聚焦于业务逻辑实现,而非底层基础设施搭建。单一可执行JAR的部署模式极大简化了运维流程。

🎨 前端技术:Vue.js
Vue.js 以其渐进式框架设计和卓越的开发体验,成为现代前端开发的首选解决方案。 技术亮点:

响应式数据流:基于依赖追踪的响应式系统,实现高效的视图更新 组件化架构:单文件组件(SFC)设计,实现样式、逻辑、模板的完美封装
灵活的渐进式设计:可从简单的视图层库扩展至完整的SPA解决方案 丰富的生态系统:Vue Router、Vuex/Pinia、Vue
CLI等官方工具链完备

开发效率:
直观的模板语法结合强大的指令系统,让复杂的用户交互变得简洁明了。优秀的TypeScript支持和开发者工具,为大型项目提供可靠的开发保障。

核心代码

package com;

import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;

@SpringBootApplication
@MapperScan(basePackages = {"com.dao"})
public class SpringbootSchemaApplication extends SpringBootServletInitializer{

	public static void main(String[] args) {
		SpringApplication.run(SpringbootSchemaApplication.class, args);
	}
	
	@Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder applicationBuilder) {
        return applicationBuilder.sources(SpringbootSchemaApplication.class);
    }
}


package com.controller;

import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Map;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Date;
import java.util.List;
import javax.servlet.http.HttpServletRequest;

import com.utils.ValidatorUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.annotation.IgnoreAuth;

import com.entity.YonghuEntity;
import com.entity.view.YonghuView;

import com.service.YonghuService;
import com.service.TokenService;
import com.utils.PageUtils;
import com.utils.R;
import com.utils.MPUtil;
import com.utils.MapUtils;
import com.utils.CommonUtil;
import java.io.IOException;

/**
 * 用户
 * 后端接口
 * @author 
 * @email 
 * @date 2024-04-24 17:59:31
 */
@RestController
@RequestMapping("/yonghu")
public class YonghuController {
    @Autowired
    private YonghuService yonghuService;

	@Autowired
	private TokenService tokenService;
	
	/**
	 * 登录
	 */
	@IgnoreAuth
	@RequestMapping(value = "/login")
	public R login(String username, String password, String captcha, HttpServletRequest request) {
		YonghuEntity u = yonghuService.selectOne(new EntityWrapper<YonghuEntity>().eq("yonghuzhanghao", username));
		if(u==null || !u.getMima().equals(password)) {
			return R.error("账号或密码不正确");
		}
		
		String token = tokenService.generateToken(u.getId(), username,"yonghu",  "用户" );
		return R.ok().put("token", token);
	}

	/**
     * 注册
     */
	@IgnoreAuth
    @RequestMapping("/register")
    public R register(@RequestBody YonghuEntity yonghu){
    	//ValidatorUtils.validateEntity(yonghu);
    	YonghuEntity u = yonghuService.selectOne(new EntityWrapper<YonghuEntity>().eq("yonghuzhanghao", yonghu.getYonghuzhanghao()));
		if(u!=null) {
			return R.error("注册用户已存在");
		}
		Long uId = new Date().getTime();
		yonghu.setId(uId);
        yonghuService.insert(yonghu);
        return R.ok();
    }

	/**
	 * 退出
	 */
	@RequestMapping("/logout")
	public R logout(HttpServletRequest request) {
		request.getSession().invalidate();
		return R.ok("退出成功");
	}
	
	/**
     * 获取用户的session用户信息
     */
    @RequestMapping("/session")
    public R getCurrUser(HttpServletRequest request){
    	Long id = (Long)request.getSession().getAttribute("userId");
        YonghuEntity u = yonghuService.selectById(id);
        return R.ok().put("data", u);
    }
    
    /**
     * 密码重置
     */
    @IgnoreAuth
	@RequestMapping(value = "/resetPass")
    public R resetPass(String username, HttpServletRequest request){
    	YonghuEntity u = yonghuService.selectOne(new EntityWrapper<YonghuEntity>().eq("yonghuzhanghao", username));
    	if(u==null) {
    		return R.error("账号不存在");
    	}
        u.setMima("123456");
        yonghuService.updateById(u);
        return R.ok("密码已重置为:123456");
    }

    /**
     * 后台列表
     */
    @RequestMapping("/page")
    public R page(@RequestParam Map<String, Object> params,YonghuEntity yonghu,
		HttpServletRequest request){
        EntityWrapper<YonghuEntity> ew = new EntityWrapper<YonghuEntity>();

		PageUtils page = yonghuService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, yonghu), params), params));

        return R.ok().put("data", page);
    }
    
    /**
     * 前台列表
     */
	@IgnoreAuth
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params,YonghuEntity yonghu, 
		HttpServletRequest request){
        EntityWrapper<YonghuEntity> ew = new EntityWrapper<YonghuEntity>();

		PageUtils page = yonghuService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, yonghu), params), params));
        return R.ok().put("data", page);
    }

	/**
     * 列表
     */
    @RequestMapping("/lists")
    public R list( YonghuEntity yonghu){
       	EntityWrapper<YonghuEntity> ew = new EntityWrapper<YonghuEntity>();
      	ew.allEq(MPUtil.allEQMapPre( yonghu, "yonghu")); 
        return R.ok().put("data", yonghuService.selectListView(ew));
    }

	 /**
     * 查询
     */
    @RequestMapping("/query")
    public R query(YonghuEntity yonghu){
        EntityWrapper< YonghuEntity> ew = new EntityWrapper< YonghuEntity>();
 		ew.allEq(MPUtil.allEQMapPre( yonghu, "yonghu")); 
		YonghuView yonghuView =  yonghuService.selectView(ew);
		return R.ok("查询用户成功").put("data", yonghuView);
    }
	
    /**
     * 后台详情
     */
    @RequestMapping("/info/{id}")
    public R info(@PathVariable("id") Long id){
        YonghuEntity yonghu = yonghuService.selectById(id);
        return R.ok().put("data", yonghu);
    }

    /**
     * 前台详情
     */
	@IgnoreAuth
    @RequestMapping("/detail/{id}")
    public R detail(@PathVariable("id") Long id){
        YonghuEntity yonghu = yonghuService.selectById(id);
        return R.ok().put("data", yonghu);
    }
    
    /**
     * 后台保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody YonghuEntity yonghu, HttpServletRequest request){
        if(yonghuService.selectCount(new EntityWrapper<YonghuEntity>().eq("yonghuzhanghao", yonghu.getYonghuzhanghao()))>0) {
            return R.error("用户账号已存在");
        }
    	yonghu.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());
    	//ValidatorUtils.validateEntity(yonghu);
    	YonghuEntity u = yonghuService.selectOne(new EntityWrapper<YonghuEntity>().eq("yonghuzhanghao", yonghu.getYonghuzhanghao()));
		if(u!=null) {
			return R.error("用户已存在");
		}
		yonghu.setId(new Date().getTime());
        yonghuService.insert(yonghu);
        return R.ok();
    }
    
    /**
     * 前台保存
     */
    @RequestMapping("/add")
    public R add(@RequestBody YonghuEntity yonghu, HttpServletRequest request){
        if(yonghuService.selectCount(new EntityWrapper<YonghuEntity>().eq("yonghuzhanghao", yonghu.getYonghuzhanghao()))>0) {
            return R.error("用户账号已存在");
        }
    	yonghu.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());
    	//ValidatorUtils.validateEntity(yonghu);
    	YonghuEntity u = yonghuService.selectOne(new EntityWrapper<YonghuEntity>().eq("yonghuzhanghao", yonghu.getYonghuzhanghao()));
		if(u!=null) {
			return R.error("用户已存在");
		}
		yonghu.setId(new Date().getTime());
        yonghuService.insert(yonghu);
        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @Transactional
    public R update(@RequestBody YonghuEntity yonghu, HttpServletRequest request){
        //ValidatorUtils.validateEntity(yonghu);
        if(yonghuService.selectCount(new EntityWrapper<YonghuEntity>().ne("id", yonghu.getId()).eq("yonghuzhanghao", yonghu.getYonghuzhanghao()))>0) {
            return R.error("用户账号已存在");
        }
        yonghuService.updateById(yonghu);//全部更新
        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Long[] ids){
        yonghuService.deleteBatchIds(Arrays.asList(ids));
        return R.ok();
    }
    
}


文章下方名片联系我即可~

✌💗大家点赞、收藏、关注、评论啦 、查看✌💗
👇🏻获取联系方式👇🏻
精彩专栏推荐订阅:在下方专栏👇🏻

Logo

有“AI”的1024 = 2048,欢迎大家加入2048 AI社区

更多推荐