食悟后端仓库
当前访问频次受限,请登录后继续访问
Recipe_Backend
项目概述
Recipe_Backend 是一个基于 Spring Boot + PostgreSQL 的后端服务,用于管理食谱、食材、步骤、用户互动(评论、收藏、点赞)等功能。前端使用 Vue.js(单独仓库),后端提供 RESTful API 支持前端交互和数据管理。
主要功能:
- 用户管理:注册、登录、个人信息、偏好存储
- 食谱管理:增删改查、步骤、耗时统计
- 食材管理:分类、属性、库存信息
- 动态交互:评论、收藏、点赞
- 数据统计:步骤耗时统计、标签分类聚合
技术栈
- 后端:Spring Boot 3.x, Spring Data JPA
- 数据库:PostgreSQL 15+
- 前端:Vue 3 (单独仓库)
- 工具:Maven, Lombok, MapStruct, Redis(可选)
系统需求
- JDK 17+
- Maven 3.8+
- PostgreSQL 15+
- Node.js 16+(前端独立运行)
数据库配置
- 创建数据库:
CREATE DATABASE recipedb;
CREATE USER recipe_user WITH PASSWORD 'your_password';
GRANT ALL PRIVILEGES ON DATABASE recipedb TO recipe_user;
- 导入 SQL 文件: 按顺序执行:
psql -U recipe_user -d recipedb -f ./sql/step1清空数据库.sql
psql -U recipe_user -d recipedb -f ./sql/step2数据结构.sql
psql -U recipe_user -d recipedb -f ./sql/step3触发器与函数.sql
psql -U recipe_user -d recipedb -f ./sql/step4测试数据.sql
psql -U recipe_user -d recipedb -f ./sql/step5测试用户.sql
配置 Spring Boot
在 application.properties 或 application.yml 中设置数据库信息:
spring.datasource.url=jdbc:postgresql://localhost:5432/recipedb
spring.datasource.username=recipe_user
spring.datasource.password=your_password
spring.datasource.driver-class-name=org.postgresql.Driver
spring.jpa.database-platform=org.hibernate.dialect.PostgreSQLDialect
spring.jpa.show-sql=true
spring.jpa.hibernate.ddl-auto=update
项目启动
# 编译项目
mvn clean package
# 启动项目
java -jar target/recipe-backend-0.0.1-SNAPSHOT.jar
默认端口:8080
测试接口:
GET http://localhost:8080/api/recipes
开发与贡献
- 克隆仓库:
git clone https://gitcode.com/jzh_fzu/Recipe_Backend.git
- 配置本地 PostgreSQL
- 导入 SQL 数据
- 编译并启动后端