初始化
This commit is contained in:
175
README.md
Normal file
175
README.md
Normal file
@@ -0,0 +1,175 @@
|
|||||||
|
# M2Pool Lease 项目介绍
|
||||||
|
|
||||||
|
## 项目概述
|
||||||
|
|
||||||
|
M2Pool Lease 是一个基于 Spring Boot 的矿机租赁平台系统,为用户提供矿机租赁、订单管理、支付处理等核心功能。
|
||||||
|
|
||||||
|
## 技术栈
|
||||||
|
|
||||||
|
### 后端框架
|
||||||
|
- **Spring Boot 2.6.7** - 核心框架
|
||||||
|
- **Spring Cloud Alibaba** - 微服务架构(Nacos 服务注册与配置中心)
|
||||||
|
- **MyBatis Plus 3.5.3** - ORM 框架
|
||||||
|
- **MySQL 8.0.28** - 数据库
|
||||||
|
- **Redis** - 缓存与会话管理
|
||||||
|
|
||||||
|
### 中间件
|
||||||
|
- **RabbitMQ** - 消息队列,用于异步订单处理和支付回调
|
||||||
|
- **Nacos 2.0.4** - 服务注册发现和配置管理
|
||||||
|
|
||||||
|
### 工具库
|
||||||
|
- **Lombok** - 简化代码
|
||||||
|
- **Hutool 5.8.24** - Java 工具类库
|
||||||
|
- **Fastjson 1.2.80** - JSON 处理
|
||||||
|
- **Knife4j 3.0.3** - API 文档(Swagger 增强)
|
||||||
|
- **Druid 1.2.8** - 数据库连接池
|
||||||
|
- **PageHelper 1.4.1** - 分页插件
|
||||||
|
|
||||||
|
### 安全与认证
|
||||||
|
- **JWT (jjwt 0.9.1)** - 令牌认证
|
||||||
|
- **Google Authenticator** - 双因素认证
|
||||||
|
- **RSA 加密** - 数据加密
|
||||||
|
|
||||||
|
### 网络通信
|
||||||
|
- **Netty** - TCP 服务器,用于与矿机客户端通信
|
||||||
|
- **Spring Boot Mail** - 邮件服务(Thymeleaf 模板)
|
||||||
|
|
||||||
|
### 其他
|
||||||
|
- **ZXing 3.3.0** - 二维码生成
|
||||||
|
- **JNA 5.12.1** - Java Native Access
|
||||||
|
- **Blake3** - 哈希算法
|
||||||
|
|
||||||
|
## 项目结构
|
||||||
|
|
||||||
|
```
|
||||||
|
m2pool_lease/
|
||||||
|
├── src/main/java/com/m2pool/lease/
|
||||||
|
│ ├── annotation/ # 自定义注解(加密、日志、数据源切换等)
|
||||||
|
│ ├── aspect/ # AOP 切面
|
||||||
|
│ ├── config/ # 配置类(Swagger、线程池、拦截器等)
|
||||||
|
│ ├── constant/ # 常量定义
|
||||||
|
│ ├── controller/ # 控制器层
|
||||||
|
│ ├── dto/ # 数据传输对象
|
||||||
|
│ ├── entity/ # 实体类
|
||||||
|
│ ├── exception/ # 异常处理
|
||||||
|
│ ├── mapper/ # MyBatis Mapper 接口
|
||||||
|
│ ├── mq/ # 消息队列相关
|
||||||
|
│ ├── netty/ # Netty TCP 服务器
|
||||||
|
│ ├── redis/ # Redis 配置和服务
|
||||||
|
│ ├── service/ # 业务逻辑层
|
||||||
|
│ ├── task/ # 定时任务
|
||||||
|
│ ├── utils/ # 工具类
|
||||||
|
│ └── vo/ # 视图对象
|
||||||
|
├── src/main/resources/
|
||||||
|
│ ├── bootstrap.yml # 启动配置
|
||||||
|
│ ├── bootstrap-dev.yml # 开发环境配置
|
||||||
|
│ ├── bootstrap-test.yml # 测试环境配置
|
||||||
|
│ ├── mapper/ # MyBatis XML 映射文件
|
||||||
|
│ └── templates/ # 邮件模板
|
||||||
|
└── pom.xml # Maven 项目配置
|
||||||
|
```
|
||||||
|
|
||||||
|
## 核心功能模块
|
||||||
|
|
||||||
|
### 1. 用户管理
|
||||||
|
- 用户注册与登录
|
||||||
|
- JWT 令牌认证
|
||||||
|
- Google 双因素认证
|
||||||
|
- 邮箱验证码
|
||||||
|
- 密码重置
|
||||||
|
|
||||||
|
### 2. 产品与矿机管理
|
||||||
|
- 产品信息管理
|
||||||
|
- 矿机配置(ASIC/GPU)
|
||||||
|
- 算力与价格配置
|
||||||
|
- 矿机库存管理
|
||||||
|
- 多币种支持
|
||||||
|
|
||||||
|
### 3. 订单系统
|
||||||
|
- 购物车功能
|
||||||
|
- 订单创建与管理
|
||||||
|
- 订单状态跟踪
|
||||||
|
- 订单费用计算
|
||||||
|
- 多版本 API 支持(V1/V2)
|
||||||
|
|
||||||
|
### 4. 支付系统
|
||||||
|
- 充值与提现
|
||||||
|
- 支付记录管理
|
||||||
|
- 支付回调处理
|
||||||
|
- 多种支付方式支持
|
||||||
|
- 自动支付处理
|
||||||
|
|
||||||
|
### 5. 矿场管理
|
||||||
|
- 矿场信息配置
|
||||||
|
- 矿场地址配置
|
||||||
|
- 矿场钱包配置
|
||||||
|
|
||||||
|
### 6. 收益管理
|
||||||
|
- 产品收益计算
|
||||||
|
- 用户收益统计
|
||||||
|
- 实时算力监控
|
||||||
|
- 挖矿收益记录
|
||||||
|
|
||||||
|
### 7. Netty 通信服务
|
||||||
|
- TCP 服务器与矿机客户端通信
|
||||||
|
- 算力数据上报
|
||||||
|
- 配置下发
|
||||||
|
- 消息编解码
|
||||||
|
|
||||||
|
### 8. 定时任务
|
||||||
|
- GPU 数据请求
|
||||||
|
- 订单与支付处理
|
||||||
|
- 自有产品管理
|
||||||
|
- 实时算力数据插入
|
||||||
|
|
||||||
|
## 数据源配置
|
||||||
|
|
||||||
|
项目支持多数据源配置,通过 MyBatis Plus 动态数据源实现:
|
||||||
|
- `HashRateDB` - 算力数据库
|
||||||
|
- `MiningDB` - 挖矿数据库
|
||||||
|
- `Pool2DB` - 矿池数据库
|
||||||
|
|
||||||
|
## 环境配置
|
||||||
|
|
||||||
|
项目支持多环境配置:
|
||||||
|
- **dev** - 开发环境
|
||||||
|
- **test** - 测试环境(默认)
|
||||||
|
- **prod** - 生产环境
|
||||||
|
|
||||||
|
通过 Maven Profile 切换环境:
|
||||||
|
```bash
|
||||||
|
mvn clean package -P dev
|
||||||
|
mvn clean package -P test
|
||||||
|
mvn clean package -P prod
|
||||||
|
```
|
||||||
|
|
||||||
|
## API 文档
|
||||||
|
|
||||||
|
项目集成 Knife4j,启动后访问:
|
||||||
|
```
|
||||||
|
http://localhost:port/doc.html
|
||||||
|
```
|
||||||
|
|
||||||
|
## 构建与运行
|
||||||
|
|
||||||
|
### 构建项目
|
||||||
|
```bash
|
||||||
|
mvn clean package
|
||||||
|
```
|
||||||
|
|
||||||
|
### 运行项目
|
||||||
|
```bash
|
||||||
|
java -jar target/lease-1.0.0.jar
|
||||||
|
```
|
||||||
|
|
||||||
|
## 注意事项
|
||||||
|
|
||||||
|
- 项目需要配置 Nacos 服务器地址
|
||||||
|
- 需要配置 MySQL 数据库连接
|
||||||
|
- 需要配置 Redis 连接
|
||||||
|
- 需要配置 RabbitMQ 连接
|
||||||
|
- demo 目录为示例模块,不包含在主项目提交中
|
||||||
|
|
||||||
|
## 许可证
|
||||||
|
|
||||||
|
本项目为内部项目,版权归 M2Pool 所有。
|
||||||
282
pom.xml
Normal file
282
pom.xml
Normal file
@@ -0,0 +1,282 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<groupId>com.m2pool</groupId>
|
||||||
|
<artifactId>lease</artifactId>
|
||||||
|
<version>1.0.0</version>
|
||||||
|
<name>m2pool_lease</name>
|
||||||
|
<description>m2pool_lease</description>
|
||||||
|
<properties>
|
||||||
|
<java.version>1.8</java.version>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||||
|
<spring-boot.version>2.6.7</spring-boot.version>
|
||||||
|
</properties>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-data-redis</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-jdbc</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-web</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.projectlombok</groupId>
|
||||||
|
<artifactId>lombok</artifactId>
|
||||||
|
<optional>true</optional>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>mysql</groupId>
|
||||||
|
<artifactId>mysql-connector-java</artifactId>
|
||||||
|
<version>8.0.28</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- 生成器默认模版 -->
|
||||||
|
<!-- <dependency>-->
|
||||||
|
<!-- <groupId>org.apache.velocity</groupId>-->
|
||||||
|
<!-- <artifactId>velocity-engine-core</artifactId>-->
|
||||||
|
<!-- <version>2.3</version>-->
|
||||||
|
<!-- </dependency>-->
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-amqp</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
|
||||||
|
<version>2021.0.1.0</version>
|
||||||
|
</dependency>
|
||||||
|
<!-- SpringCloud Alibaba Nacos Config -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
|
||||||
|
<version>2021.0.1.0</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<!-- bootstrap 启动器 -->
|
||||||
|
<groupId>org.springframework.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-starter-bootstrap</artifactId>
|
||||||
|
<version>3.1.1</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-dependencies</artifactId>
|
||||||
|
<version>2021.0.1</version>
|
||||||
|
<type>pom</type>
|
||||||
|
<scope>import</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- SpringCloud Alibaba 微服务 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-alibaba-dependencies</artifactId>
|
||||||
|
<version>2021.0.1.0</version>
|
||||||
|
<type>pom</type>
|
||||||
|
<scope>import</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- Nacos 配置 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba.nacos</groupId>
|
||||||
|
<artifactId>nacos-client</artifactId>
|
||||||
|
<version>2.0.4</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>de.codecentric</groupId>
|
||||||
|
<artifactId>spring-boot-admin-starter-client</artifactId>
|
||||||
|
<version>2.6.6</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- 导入knife4j2.0.7版本依赖 SpringBoot2.3.5.RELEASE 版本 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.github.xiaoymin</groupId>
|
||||||
|
<artifactId>knife4j-spring-boot-starter</artifactId>
|
||||||
|
<version>3.0.3</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.github.xiaoymin</groupId>
|
||||||
|
<artifactId>knife4j-spring-ui</artifactId>
|
||||||
|
<version>3.0.3</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba</groupId>
|
||||||
|
<artifactId>druid-spring-boot-starter</artifactId>
|
||||||
|
<version>1.2.8</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- Dynamic DataSource -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.baomidou</groupId>
|
||||||
|
<artifactId>dynamic-datasource-spring-boot-starter</artifactId>
|
||||||
|
<version>3.5.0</version>
|
||||||
|
</dependency>
|
||||||
|
<!-- 生成器 -->
|
||||||
|
<!-- <dependency>-->
|
||||||
|
<!-- <groupId>com.baomidou</groupId>-->
|
||||||
|
<!-- <artifactId>mybatis-plus-generator</artifactId>-->
|
||||||
|
<!-- <version>3.3.2</version>-->
|
||||||
|
<!-- </dependency>-->
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.mybatis</groupId>
|
||||||
|
<artifactId>mybatis</artifactId>
|
||||||
|
<version>3.5.7</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.baomidou</groupId>
|
||||||
|
<artifactId>mybatis-plus-boot-starter</artifactId>
|
||||||
|
<version>3.5.3</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>cn.hutool</groupId>
|
||||||
|
<artifactId>hutool-all</artifactId>
|
||||||
|
<version>5.8.24</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.github.pagehelper</groupId>
|
||||||
|
<artifactId>pagehelper-spring-boot-starter</artifactId>
|
||||||
|
<version>1.4.1</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- Velocity 模板引擎 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.velocity</groupId>
|
||||||
|
<artifactId>velocity-engine-core</artifactId>
|
||||||
|
<version>2.3</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba</groupId>
|
||||||
|
<artifactId>fastjson</artifactId>
|
||||||
|
<version>1.2.80</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- Thymeleaf 用于发送邮箱 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-thymeleaf</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
|
<!--jwt-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.jsonwebtoken</groupId>
|
||||||
|
<artifactId>jjwt</artifactId>
|
||||||
|
<version>0.9.1</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
|
<!--邮箱-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-mail</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>net.java.dev.jna</groupId>
|
||||||
|
<artifactId>jna</artifactId>
|
||||||
|
<version>5.12.1</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>pt.kcry</groupId>
|
||||||
|
<artifactId>blake3_3</artifactId>
|
||||||
|
<version>3.1.2</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.google.zxing</groupId>
|
||||||
|
<artifactId>javase</artifactId>
|
||||||
|
<version>3.3.0</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
<dependencyManagement>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-dependencies</artifactId>
|
||||||
|
<version>${spring-boot.version}</version>
|
||||||
|
<type>pom</type>
|
||||||
|
<scope>import</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</dependencyManagement>
|
||||||
|
|
||||||
|
<profiles>
|
||||||
|
<profile>
|
||||||
|
<!-- 本地环境 -->
|
||||||
|
<id>dev</id>
|
||||||
|
<properties>
|
||||||
|
<spring.profile>dev</spring.profile>
|
||||||
|
<nacos.server.address>127.0.0.1:8808</nacos.server.address>
|
||||||
|
</properties>
|
||||||
|
<activation>
|
||||||
|
<!-- 是否默认激活 -->
|
||||||
|
<activeByDefault>false</activeByDefault>
|
||||||
|
</activation>
|
||||||
|
</profile>
|
||||||
|
<profile>
|
||||||
|
<!-- 测试环境 -->
|
||||||
|
<id>test</id>
|
||||||
|
<properties>
|
||||||
|
<spring.profile>test</spring.profile>
|
||||||
|
<nacos.server.address>127.0.0.1:8808</nacos.server.address>
|
||||||
|
</properties>
|
||||||
|
<activation>
|
||||||
|
<activeByDefault>true</activeByDefault>
|
||||||
|
</activation>
|
||||||
|
</profile>
|
||||||
|
<profile>
|
||||||
|
<!-- 生产环境 -->
|
||||||
|
<id>prod</id>
|
||||||
|
<properties>
|
||||||
|
<spring.profile>prod</spring.profile>
|
||||||
|
<nacos.server.address>127.0.0.1:8808</nacos.server.address>
|
||||||
|
</properties>
|
||||||
|
<activation>
|
||||||
|
<activeByDefault>false</activeByDefault>
|
||||||
|
</activation>
|
||||||
|
</profile>
|
||||||
|
</profiles>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<!-- ... 已有代码 ... -->
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
|
<version>${spring-boot.version}</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<goals>
|
||||||
|
<goal>repackage</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
</project>
|
||||||
Reference in New Issue
Block a user