From 9420f75e491b3b81053204bfcaac5ba85421a93a Mon Sep 17 00:00:00 2001 From: gitee-bot Date: Thu, 26 Jun 2025 09:28:33 +0000 Subject: [PATCH] Update README.md --- README.en.md | 124 +++++++++++++++++++++++++++++++++++++++++++++++++++ README.md | 124 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 248 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..c4b3c7c --- /dev/null +++ b/README.en.md @@ -0,0 +1,124 @@ + + +# Multi-Service Architecture Project + +This project is a microservices architecture application developed using the Go programming language. It includes three main service modules: `log_srv`, `trans_srv`, and `user_srv`, with each module responsible for different business functions. The project utilizes Gin as the web framework, GORM as the ORM tool, and RabbitMQ for inter-service message communication. + +## Service Modules + +### log_srv +The logging service module, responsible for recording and managing system operation logs. Supports viewing log lists and exporting logs via HTTP interfaces. + +- Interacts with the MySQL database using GORM. +- Receives and processes log messages using RabbitMQ. +- Includes JWT authentication middleware and admin privilege middleware. +- Supports Cross-Origin Resource Sharing (CORS). + +### trans_srv +The translation service module, providing multilingual translation functionality for managing language elements and translation content within the system. + +- Manages languages (Language) and translation elements (Element). +- Supports bulk translation and retrieval of translation content. +- Interacts with the MySQL database using GORM. +- Sends and consumes translation-related messages via RabbitMQ. +- Includes JWT authentication middleware and admin privilege middleware. + +### user_srv +The user service module, responsible for user management, including core functionalities such as registration, login, SMS verification code, and password modification. + +- CRUD operations for user information. +- Supports JWT-based user authentication. +- Integrated with SMS verification code service. +- Uses Redis to cache verification codes. +- Supports logging and inter-service communication via RabbitMQ. + +## Technology Stack + +- Go (Golang) +- Gin Web Framework +- GORM (ORM) +- RabbitMQ (message queue) +- Redis (cache) +- MySQL (database) +- JWT (authentication) +- Validator (form validation) + +## Directory Structure + +- `ioc/`: Dependency injection configuration, initializing database, RabbitMQ, Redis, configuration files, etc. +- `internal/domain/`: Defines core business models and structures. +- `internal/repository/`: Data access layer, responsible for interacting with the database. +- `internal/service/`: Business logic layer, implementing specific functional logic. +- `internal/web/`: Interface handling and route registration, including middleware, request processing, and response format definitions. +- `utils/`: Utility functions, such as RabbitMQ encapsulation and verification code generation. + +## Quick Start + +### Environment Preparation + +- Go 1.16 or higher +- MySQL database +- Redis (for verification code caching) +- RabbitMQ (for asynchronous inter-service communication) +- Docker (optional) + +### Configuration + +Each service module has its own configuration file `config-debug.yaml`. Modify the database, Redis, RabbitMQ, and other connection information as needed. + +### Build and Run + +```bash +# Build and run log_srv +cd log_srv +go build -o log_srv +./log_srv + +# Build and run trans_srv +cd trans_srv +go build -o trans_srv +./trans_srv + +# Build and run user_srv +cd user_srv +go build -o user_srv +./user_srv +``` + +### Run Using Docker + +Each service directory contains a `Dockerfile` to build and run Docker images. + +```bash +# Build and run log_srv Docker container +docker build -t log_srv -f log_srv/Dockerfile . +docker run -p 8033:8033 log_srv + +# Build and run trans_srv Docker container +docker build -t trans_srv -f trans_srv/Dockerfile . +docker run -p 8022:8022 trans_srv + +# Build and run user_srv Docker container +docker build -t user_srv -f user_srv/Dockerfile . +docker run -p 8011:8011 user_srv +``` + +## Feature Demos + +- **user_srv**: Provides functionalities such as user registration, login, SMS verification code, and user management. +- **trans_srv**: Manages multilingual translations and supports CRUD operations for translation elements. +- **log_srv**: Records all operation logs and supports paginated viewing and exporting. + +## Contribution Guide + +We welcome code contributions. Please follow these steps: + +1. Fork this repository. +2. Create a new branch (`git checkout -b feature/your-feature-name`). +3. Commit your changes (`git commit -am 'Add some feature'`). +4. Push your branch (`git push origin feature/your-feature-name`). +5. Create a Pull Request. + +## License + +This project is licensed under the MIT License. See the `LICENSE` file for details. \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..fec73e2 --- /dev/null +++ b/README.md @@ -0,0 +1,124 @@ + + +# 多服务架构项目 + +该项目是一个基于 Go 语言开发的微服务架构项目,包含三个主要的服务模块:`log_srv` 和 `trans_srv` 以及 `user_srv`,每个模块负责不同的业务功能。该项目使用了 Gin 作为 Web 框架,GORM 作为 ORM 工具,并通过 RabbitMQ 进行服务间的消息通信。 + +## 服务模块 + +### log_srv +日志服务模块,负责记录和管理系统的操作日志。支持通过 HTTP 接口查看日志列表、导出日志等操作。 + +- 使用 GORM 与 MySQL 数据库交互。 +- 使用 RabbitMQ 接收和处理日志消息。 +- 包含 JWT 认证中间件和管理员权限中间件。 +- 支持跨域请求(CORS)。 + +### trans_srv +翻译服务模块,提供多语言翻译功能,用于管理系统中的语言元素和翻译内容。 + +- 管理语言(Language)和翻译元素(Element)。 +- 支持批量翻译、获取翻译内容。 +- 使用 GORM 与 MySQL 数据库交互。 +- 通过 RabbitMQ 发送和消费翻译相关的消息。 +- 包含 JWT 认证中间件和管理员权限中间件。 + +### user_srv +用户服务模块,负责用户管理,包括用户注册、登录、短信验证码、密码修改等核心功能。 + +- 用户信息的增删改查。 +- 支持基于 JWT 的用户认证。 +- 集成短信验证码服务(SMS)。 +- 使用 Redis 缓存验证码信息。 +- 支持 RabbitMQ 进行日志记录或其他服务通信。 + +## 技术栈 + +- Go (Golang) +- Gin Web Framework +- GORM (ORM) +- RabbitMQ (消息队列) +- Redis (缓存) +- MySQL (数据库) +- JWT (身份认证) +- Validator (表单验证) + +## 目录结构说明 + +- `ioc/`: 依赖注入配置,初始化数据库、RabbitMQ、Redis、配置文件等。 +- `internal/domain/`: 定义核心业务模型和结构体。 +- `internal/repository/`: 数据访问层,负责与数据库交互。 +- `internal/service/`: 业务逻辑层,实现具体的功能逻辑。 +- `internal/web/`: 接口处理和路由注册,包含中间件、请求处理及响应格式定义。 +- `utils/`: 工具类函数,如 RabbitMQ 的封装、验证码生成等。 + +## 快速开始 + +### 环境准备 + +- Go 1.16 或更高版本 +- MySQL 数据库 +- Redis(用于验证码缓存) +- RabbitMQ(用于服务间异步通信) +- Docker(可选) + +### 配置 + +每个服务模块都有自己的配置文件 `config-debug.yaml`,请根据需要修改数据库、Redis、RabbitMQ 等连接信息。 + +### 编译与运行 + +```bash +# 构建并运行 log_srv +cd log_srv +go build -o log_srv +./log_srv + +# 构建并运行 trans_srv +cd trans_srv +go build -o trans_srv +./trans_srv + +# 构建并运行 user_srv +cd user_srv +go build -o user_srv +./user_srv +``` + +### 使用 Docker 运行 + +每个服务目录下都有 `Dockerfile`,可构建 Docker 镜像并运行。 + +```bash +# 构建并运行 log_srv Docker 容器 +docker build -t log_srv -f log_srv/Dockerfile . +docker run -p 8033:8033 log_srv + +# 构建并运行 trans_srv Docker 容器 +docker build -t trans_srv -f trans_srv/Dockerfile . +docker run -p 8022:8022 trans_srv + +# 构建并运行 user_srv Docker 容器 +docker build -t user_srv -f user_srv/Dockerfile . +docker run -p 8011:8011 user_srv +``` + +## 功能演示 + +- **user_srv**: 提供用户注册、登录、短信验证码、用户管理等功能。 +- **trans_srv**: 管理多语言翻译,支持元素翻译的增删改查。 +- **log_srv**: 记录所有操作日志,支持分页查看和导出。 + +## 贡献指南 + +欢迎贡献代码,请遵循以下步骤: + +1. Fork 本仓库 +2. 创建新分支(`git checkout -b feature/your-feature-name`) +3. 提交代码(`git commit -am 'Add some feature'`) +4. 推送分支(`git push origin feature/your-feature-name`) +5. 创建 Pull Request + +## 许可证 + +本项目采用 MIT 许可证。详见 `LICENSE` 文件。 \ No newline at end of file -- Gitee