From 9b5c13ffb742128cc26e0ffec5501502f76550a0 Mon Sep 17 00:00:00 2001 From: gitee-bot Date: Sat, 6 Sep 2025 04:04:05 +0000 Subject: [PATCH] Add README.md --- README.en.md | 221 +++++++++++++++++++++++++++++++++++++++++++++++++++ README.md | 221 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 442 insertions(+) create mode 100644 README.en.md create mode 100644 README.md diff --git a/README.en.md b/README.en.md new file mode 100644 index 0000000..12c31b4 --- /dev/null +++ b/README.en.md @@ -0,0 +1,221 @@ +# Blog Backend Project + +This is a blog backend project based on Spring Boot, offering comprehensive blog functionalities including article management, categories, tags, user registration and login, comments, search, and more. The project integrates multiple technologies such as Elasticsearch, Kafka, MinIO, and Redis to build a high-performance and scalable blog system. + +--- + +## 🚀 Key Features + +- **Article Management**: Supports publishing, searching, browsing, and paginated display of articles. +- **Categories and Tags**: Supports article categorization and tag management for convenient content organization. +- **User System**: Includes functionalities such as registration, login, email verification code, and password reset. +- **Comment System**: Supports visitor留言 and display. +- **Search Functionality**: Implements full-text search and keyword suggestions using Elasticsearch. +- **Image Upload**: Stores user-uploaded images using MinIO. +- **Asynchronous Processing**: Uses Kafka to asynchronously synchronize article data to Elasticsearch. +- **Caching and Security**: Uses Redis to cache user information and JWT for secure authentication. + +--- + +## 🛠 Technology Stack + +- **Backend Framework**: Spring Boot +- **Database**: MySQL +- **Search Engine**: Elasticsearch +- **Message Queue**: Kafka +- **Object Storage**: MinIO +- **Caching**: Redis +- **Security Authentication**: JWT, Spring Security +- **Utility Libraries**: MyBatis, Lombok, Jackson, Hutool, Apache Commons + +--- + +## 📦 Environment Dependencies + +- Java 17+ +- Maven 3.8+ +- MySQL 8.0+ +- Elasticsearch 7.x+ +- Kafka 3.0+ +- Redis 6.0+ +- MinIO + +--- + +## 📁 Project Structure + +- `controller`: API controllers for handling HTTP requests. +- `service`: Business logic interfaces and implementations. +- `mapper`: MyBatis database mapping interfaces. +- `entity`: Database entity classes. +- `dto`: Data Transfer Objects for frontend-backend interaction. +- `config`: Spring configuration classes, including security, caching, thread pools, etc. +- `utils`: General utility classes, such as JWT, verification codes, file uploads, etc. +- `Exception`: Global exception handling. +- `Repository`: Elasticsearch data access interfaces. + +--- + +## 🧪 Testing and Deployment + +### Unit Testing + +Unit tests for some core functionalities have been written using `JUnit`, located in `src/test/java/com/blog/`. + +### Deployment Steps + +1. **Database Setup**: Import `blog.sql` into MySQL. +2. **Configuration Modification**: Update database, Elasticsearch, MinIO, Kafka, and other configurations in `application.yaml`. +3. **Start the Project**: + ```bash + mvn spring-boot:run + ``` +4. **Initialize Elasticsearch Index** (optional): + - The index will be automatically initialized after startup, or manually trigger via the `/public/articlesearch/init` endpoint. + +--- + +## 📝 API Documentation (Summary) + +### User-Related + +- `POST /public/user/login`: User login +- `POST /public/user/register`: User registration +- `POST /public/user/emailcode`: Get email verification code +- `POST /public/user/reset_password`: Reset password +- `GET /public/user/userinfo`: Get current user information + +### Article-Related + +- `GET /public/article/get_article/{articleId}`: Get article details +- `POST /article/addarticle`: Add an article +- `GET /public/article/pages`: Get paginated article list +- `GET /public/sidebar`: Get sidebar information +- `GET /public/advanced`: Search articles + +### Categories and Tags + +- `GET /public/category/list`: Get all categories +- `GET /public/category/page/{categoryId}`: Get article list under a category +- `GET /public/tag/list`: Get all tags +- `GET /public/tag/page/{tagId}`: Get article list under a tag + +### Comments + +- `POST /public/guestbook/add`: Add a comment +- `GET /public/guestbook/list`: Get comment list + +### Search (Elasticsearch) + +- `GET /public/articlesearch/articledetail/{keyword}`: Search articles by keyword +- `GET /public/articlesearch/suggestkeywords/{keyword}`: Get keyword suggestions + +--- + +## 📎 Third-Party Service Configuration + +### MinIO + +- Configuration file: `spring.minio` in `application.yaml` +- Used to store user-uploaded image resources. + +### Redis + +- Configuration file: `spring.redis` in `application.yaml` +- Used to cache user login information and verification codes. + +### Kafka + +- Configuration file: `spring.kafka` in `application.yaml` +- Used to asynchronously synchronize article data to Elasticsearch. + +### Elasticsearch + +- Configuration file: `spring.elasticsearch` in `application.yaml` +- Used to implement full-text search and keyword suggestions for articles. + +--- + +## 📎 License + +This project uses the [MIT License](https://opensource.org/licenses/MIT). For details, please refer to the `LICENSE` file in the project root directory. + +--- + +## 🤝 Contribution Guide + +Pull requests and issues are welcome. Please follow these steps: + +1. Fork the project +2. Create a new branch (`git checkout -b feature`) +3. Commit changes (`git commit -am 'Add some feature'`) +4. Push the branch (`git push origin feature`) +5. Create a Pull Request + +--- + +## 📬 Contact + +For any questions, please submit an issue or contact the author. + +--- + +## 📌 Version Changelog + +Please refer to the `CHANGELOG.md` file (if exists) in the project. + +--- + +## 📚 Reference Documentation + +- [Spring Boot Official Documentation](https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/) +- [Elasticsearch Official Documentation](https://www.elastic.co/elasticsearch/) +- [Kafka Official Documentation](https://kafka.apache.org/documentation/) +- [MinIO Official Documentation](https://docs.min.io/) + +--- + +## 📦 Download and Installation + +```bash +git clone https://gitee.com/cabbage12/blog_backend.git +cd blog_backend +mvn install +mvn spring-boot:run +``` + +--- + +## 📊 Project Status + +The project is currently in the **development and refinement phase**, with complete functionality suitable for learning or deployment. Feel free to follow for updates. + +--- + +## 🧠 Tips + +- Use the `@Builder` annotation to simplify object construction. +- Use `@Data` to automatically generate getter/setter/toString methods. +- Use `@Slf4j` to automatically generate a logger object. +- Use `@Resource` for dependency injection; constructor injection is recommended for better testability. +- Use `@Transactional` to manage transactions and ensure data consistency. + +--- + +## 📷 Example Screenshots (if available) + +Please refer to image resources in the project's `README.md` or `docs/` directory. + +--- + +## 📚 Reference Projects + +- [Spring Boot + Elasticsearch Example](https://spring.io/projects/spring-data-elasticsearch) +- [Spring Boot + Kafka Example](https://spring.io/projects/spring-kafka) +- [Spring Boot + MinIO Example](https://min.io/resources/docs/java-client-code-examples) + +--- + +## 📄 Last Updated + +2025-04-05 \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..d0380f4 --- /dev/null +++ b/README.md @@ -0,0 +1,221 @@ +# Blog 后端项目 + +这是一个基于 Spring Boot 的博客后端项目,提供了完整的博客功能,包括文章管理、分类、标签、用户注册与登录、评论、搜索等。项目整合了多种技术栈,如 Elasticsearch、Kafka、MinIO、Redis 等,以实现高性能和可扩展的博客系统。 + +--- + +## 🚀 主要功能 + +- **文章管理**:支持文章的发布、搜索、浏览和分页展示。 +- **分类与标签**:支持文章分类和标签管理,方便内容组织。 +- **用户系统**:包含注册、登录、邮箱验证码、密码重置等功能。 +- **评论系统**:支持访客留言与展示。 +- **搜索功能**:基于 Elasticsearch 实现全文搜索与关键词建议。 +- **图片上传**:使用 MinIO 存储用户上传的图片。 +- **异步处理**:通过 Kafka 实现文章数据的异步同步到 Elasticsearch。 +- **缓存与安全**:使用 Redis 缓存用户信息,JWT 实现安全认证。 + +--- + +## 🛠 技术栈 + +- **后端框架**:Spring Boot +- **数据库**:MySQL +- **搜索引擎**:Elasticsearch +- **消息队列**:Kafka +- **对象存储**:MinIO +- **缓存**:Redis +- **安全认证**:JWT、Spring Security +- **工具类**:MyBatis、Lombok、Jackson、Hutool、Apache Commons + +--- + +## 📦 环境依赖 + +- Java 17+ +- Maven 3.8+ +- MySQL 8.0+ +- Elasticsearch 7.x+ +- Kafka 3.0+ +- Redis 6.0+ +- MinIO + +--- + +## 📁 项目结构说明 + +- `controller`:API 控制器,处理 HTTP 请求。 +- `service`:业务逻辑接口与实现。 +- `mapper`:MyBatis 数据库映射接口。 +- `entity`:数据库实体类。 +- `dto`:数据传输对象,用于前后端交互。 +- `config`:Spring 配置类,包括安全、缓存、线程池等。 +- `utils`:通用工具类,如 JWT、验证码、文件上传等。 +- `Exception`:全局异常处理。 +- `Repository`:Elasticsearch 数据访问接口。 + +--- + +## 🧪 测试与部署 + +### 单元测试 + +使用 `JUnit` 编写了部分核心功能的单元测试,位于 `src/test/java/com/blog/`。 + +### 部署步骤 + +1. **数据库准备**:导入 `blog.sql` 到 MySQL。 +2. **配置文件修改**:修改 `application.yaml` 中的数据库、Elasticsearch、MinIO、Kafka 等配置。 +3. **启动项目**: + ```bash + mvn spring-boot:run + ``` +4. **初始化 Elasticsearch 索引**(可选): + - 启动后会自动初始化索引,或通过 `/public/articlesearch/init` 接口手动触发。 + +--- + +## 📝 接口文档(简要) + +### 用户相关 + +- `POST /public/user/login`:用户登录 +- `POST /public/user/register`:用户注册 +- `POST /public/user/emailcode`:获取邮箱验证码 +- `POST /public/user/reset_password`:重置密码 +- `GET /public/user/userinfo`:获取当前用户信息 + +### 文章相关 + +- `GET /public/article/get_article/{articleId}`:获取文章详情 +- `POST /article/addarticle`:添加文章 +- `GET /public/article/pages`:分页获取文章列表 +- `GET /public/sidebar`:获取侧边栏信息 +- `GET /public/advanced`:搜索文章 + +### 分类与标签 + +- `GET /public/category/list`:获取所有分类 +- `GET /public/category/page/{categoryId}`:获取分类下的文章列表 +- `GET /public/tag/list`:获取所有标签 +- `GET /public/tag/page/{tagId}`:获取标签下的文章列表 + +### 评论 + +- `POST /public/guestbook/add`:添加留言 +- `GET /public/guestbook/list`:获取留言列表 + +### 搜索(Elasticsearch) + +- `GET /public/articlesearch/articledetail/{keyword}`:根据关键词搜索文章 +- `GET /public/articlesearch/suggestkeywords/{keyword}`:获取关键词建议 + +--- + +## 📎 第三方服务配置 + +### MinIO + +- 配置文件:`application.yaml` 中的 `spring.minio` +- 用于存储用户上传的图片资源。 + +### Redis + +- 配置文件:`application.yaml` 中的 `spring.redis` +- 用于缓存用户登录信息、验证码等。 + +### Kafka + +- 配置文件:`application.yaml` 中的 `spring.kafka` +- 用于异步同步文章数据到 Elasticsearch。 + +### Elasticsearch + +- 配置文件:`application.yaml` 中的 `spring.elasticsearch` +- 用于实现文章的全文搜索与关键词建议。 + +--- + +## 📎 许可证 + +本项目采用 [MIT License](https://opensource.org/licenses/MIT),详情请查看项目根目录下的 `LICENSE` 文件。 + +--- + +## 🤝 贡献指南 + +欢迎提交 PR 和 Issue。请遵循以下步骤: + +1. Fork 项目 +2. 创建新分支 (`git checkout -b feature`) +3. 提交更改 (`git commit -am 'Add some feature'`) +4. 推送分支 (`git push origin feature`) +5. 创建 Pull Request + +--- + +## 📬 联系方式 + +如有问题,请提交 Issue 或联系作者。 + +--- + +## 📌 版本更新日志 + +请查看项目 `CHANGELOG.md` 文件(如存在)。 + +--- + +## 📚 参考文档 + +- [Spring Boot 官方文档](https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/) +- [Elasticsearch 官方文档](https://www.elastic.co/elasticsearch/) +- [Kafka 官方文档](https://kafka.apache.org/documentation/) +- [MinIO 官方文档](https://docs.min.io/) + +--- + +## 📦 下载与安装 + +```bash +git clone https://gitee.com/cabbage12/blog_backend.git +cd blog_backend +mvn install +mvn spring-boot:run +``` + +--- + +## 📊 项目状态 + +该项目目前处于 **开发完善阶段**,功能完整,适合学习或部署上线。欢迎持续关注更新。 + +--- + +## 🧠 小贴士 + +- 使用 `@Builder` 注解简化对象构建。 +- 使用 `@Data` 自动生成 getter/setter/toString 等方法。 +- 使用 `@Slf4j` 自动生成日志对象。 +- 使用 `@Resource` 注入依赖,推荐使用构造器注入以提高可测试性。 +- 使用 `@Transactional` 管理事务,确保数据一致性。 + +--- + +## 📷 示例截图(如存在) + +请查看项目 `README.md` 或 `docs/` 目录下的图片资源。 + +--- + +## 📚 参考项目 + +- [Spring Boot + Elasticsearch 示例](https://spring.io/projects/spring-data-elasticsearch) +- [Spring Boot + Kafka 示例](https://spring.io/projects/spring-kafka) +- [Spring Boot + MinIO 示例](https://min.io/resources/docs/java-client-code-examples) + +--- + +## 📄 最后更新时间 + +2025-04-05 \ No newline at end of file -- Gitee