diff --git a/README.md b/README.md index f0bf17ea..1432d4e8 100644 --- a/README.md +++ b/README.md @@ -2,11 +2,11 @@ English | [中文](README_zh.md) -FreeCar is a full-stack WeChat applet based on Kitex and Hertz. +FreeCar is a cloud-native time-sharing car rental system suite based on Hertz and Kitex. -## Architecture +## Project Architecture -### Call Relations +### Call Relationship ![call_relations.png](img/call_relation.png) @@ -18,30 +18,50 @@ FreeCar is a full-stack WeChat applet based on Kitex and Hertz. ![service_relations.png](img/service_relations.png) +## Technology Stack + +| Function | Implementation | +|--------------------------------------------|-----------------------| +| HTTP Framework | Hertz | +| RPC Framework | Kitex | +| Database | MongoDB, MySQL, Redis | +| Authentication | Paseto | +| Service Discovery and Configuration Center | Consul | +| Message Queue | RabbitMQ | +| Service Governance | OpenTelemetry | +| Current Limiting Fuse | Sentinel | +| Object Storage | Minio | +| Image Recognition | Baidu OCR | +| CI | GitHub Actions | + ## Display +Small program terminal address [FreeCar-MP](https://github.com/CyanAsterisk/FreeCar-MP) + +Background management terminal address TODO + ![display.png](img/display.png) ## Catalog Introduce -| Catalog | Introduce | -|---------|------------------------------| -| Server | Core services of the project | -| Shared | Reusable code | -| Static | WeChat applet code | +| Catalog | Introduction | +|---------|------------------------------------------| +| Cmd | Project Core | +| Idl | IDL file for all services of the project | +| Shared | Reusable Code | ## Service Introduce -| Catalog | Introduce | +| Catalog | Introduction | |---------|----------------------------------------------------| -| API | Hertz-based Gateway Service | +| API | Hertz-based gateway service | | User | User Authentication Service | -| Blob | Services Related to Pictures and Tencent Cloud COS | +| Blob | Services related to image and Minio object storage | | Car | Car Service | -| Profile | Profile and Picture Recognition Services | -| Trip | Trip Service | +| Profile | Home Page and Image Recognition Service | +| Trip | Itinerary Services | -## Quick Start +## Quick start ### Start the Dependence @@ -49,60 +69,47 @@ FreeCar is a full-stack WeChat applet based on Kitex and Hertz. make start ``` -### Nacos - -> Visit `http://127.0.0.1:8848/nacos/index.html#/login` on browser. -> -> For the default namespace and configuration groups, please refer to each `config.yaml` configuration file. - -![nacos.png](img/nacos.png) +### Consul -![nacos_registry.png](img/nacos_registry.png) +> For the default Consul address and KV configuration, please refer to each `config.yaml` configuration file. -For details on the configuration of the configuration center, see [more](docs/NACOS_CONFIG.md). +![consul_service.png](img/consul_service.png) -### Create Data Table +![consul_kv.png](img/consul_kv.png) -```shell -make migrate -``` +For detailed configuration of KV key-value pairs, [see](docs/CONSUL_CONFIG.md). -### Start HTTP Service +### Start HTTP ```shell make api ``` -### Start Microservices +### Start RPC ```shell make user -make blob -make car +make blobs +make a car make profile -make trip +make a trip ``` ### Jaeger -> Visit `http://127.0.0.1:16686/` on browser. +> Visit `http://127.0.0.1:16686/` on your browser -![jaeger.jpg](img/jaeger.jpg) +![jaeger.jpg](img/jaeger.png) ### Prometheus -> Visit `http://127.0.0.1:3000/` on browser. +> Visit `http://127.0.0.1:3000/` on your browser ![prometheus.jpg](img/prometheus.png) -## API Requests - -Sample API request for the project, see [more](docs/API_REQUEST.md). +## Development Guide -## CookBook - -It is very difficult to understand this project by directly reading the source code. Here is a development guide for -developers to quickly understand and get started with this project, including frameworks such as Kitex and Hertz. +It is very difficult to understand this project by directly reading the source code. Here is a development guide for developers to quickly understand and get started with this project, including frameworks such as Kitex and Hertz. ### Preparation @@ -136,25 +143,17 @@ service UserService { #### Kitex -Execute under the new service directory, only need to change the service name and IDL path each time. - -##### Server +First generate `kitex_gen` in the `shared` folder, and then rely on `kitex_gen` in the corresponding service folder to generate. Execute under the new service directory, only need to change the service name and IDL path each time. ```shell -kitex -service user -module github.com/CyanAsterisk/FreeCar ./../../idl/user.thrift -``` - -##### Client - -```shell -kitex -module github.com/CyanAsterisk/FreeCar ./../../idl/user.thrift +kitex -module github.com/CyanAsterisk/FreeCar ./../idl/rpc/user.thrift +kitex -service user -module github.com/CyanAsterisk/FreeCar -use github.com/CyanAsterisk/FreeCar/server/shared/kitex_gen ./../../idl/rpc/user.thrift ``` Note: -- Use `-module github.com/CyanAsterisk/FreeCar` This parameter is used to specify the Go module to which the generated - code belongs to avoid path problems. -- When the current service needs to call other services, a client file needs to be generated. +- Use `-module github.com/CyanAsterisk/FreeCar` This parameter is used to specify the Go module to which the generated code belongs to avoid path problems. +- When the current service needs to call other services, it needs to rely on `kitex_gen`. #### Hertz @@ -164,12 +163,6 @@ Note: hz new -idl ./../../idl/api.proto -mod github.com/CyanAsterisk/FreeCar/server/cmd/api ``` -##### Update - -```shell -hz update -I -idl ./../../idl/api.proto -``` - Note: - Use `-module github.com/CyanAsterisk/FreeCar/server/cmd/api` This parameter is used to specify the Go module to which @@ -177,38 +170,29 @@ Note: ### Business Development -After the code is generated, some necessary components need to be added to the project. Since the api layer does not -need to be added again, the following mainly explains the part about Kitex-Server, and the code is located -under `server/cmd`. +After the code is generated, some necessary components need to be added to the project. Since the api layer does not need to be added again, the following mainly explains about Kitex-Server +section, the code is located under `server/cmd`. #### Config Refer to `server/cmd/user/config` for the configuration structure of microservices. -#### Global - -Refer to `server/cmd/user/global` to provide globally callable methods for microservices. - #### Initialize -Refer to `server/cmd/user/initialize` to provide the initialization function of the necessary components, among -which `nacos.go` `flag.go` `logger.go` are required. +Refer to `server/cmd/user/initialize` to provide the initialization function of the necessary components, among which `config.go` `registry.go` `flag.go` `logger.go` are required. -#### Tool +#### Pkg -Refer to `server/cmd/user/tool` to provide tool functions for microservices, where `port.go` is required. +Refer to `server/cmd/user/pkg` to provide calling functions of microservices, which are mainly used to implement the interfaces defined in `handler.go`. #### API -When writing the business logic of the gateway layer, you only need to update the IDL and the new microservice client -code each time. If you need to add new components, you can add them directly. The project is highly pluggable, and the -architecture is similar to the microservice layer. +When writing the business logic of the gateway layer, you only need to update the IDL and the new microservice client code each time. If you need to add new components, you can add them directly. The project is highly pluggable, and the architecture is similar to the microservice layer. -The business logic of the gateway layer is under `server/cmd/api/biz`, and most of the code will be automatically -generated. If you need to add a new route separately, you need to go to `server/cmd/api/router.go`. +The business logic of the gateway layer is under `server/cmd/api/biz`, and most of the code will be automatically generated. If you need to add a new route separately, you need to go to `server/cmd/api/router.go`. Regarding the use of middleware, you only need to add middleware logic in `server/cmd/api/biz/router/api/middleware.go`. ## License -FreeCar is distributed under the GNU General Public License, version 3.0. +FreeCar is open source under the GNU General Public License version 3.0. \ No newline at end of file diff --git a/README_zh.md b/README_zh.md index a8037a62..acc615a3 100644 --- a/README_zh.md +++ b/README_zh.md @@ -2,7 +2,7 @@ [English](README.md) | 中文 -FreeCar 是一个基于 Hertz 与 Kitex 的全栈项目。 +FreeCar 是一个基于 Hertz 与 Kitex 的云原生分时汽车租赁系统套件。 ## 项目架构 @@ -18,28 +18,48 @@ FreeCar 是一个基于 Hertz 与 Kitex 的全栈项目。 ![service_relations.png](img/service_relations.png) +## 技术栈 + +| 功能 | 实现 | +|-----------|---------------------| +| HTTP 框架 | Hertz | +| RPC 框架 | Kitex | +| 数据库 | MongoDB、MySQL、Redis | +| 身份鉴权 | Paseto | +| 服务发现与配置中心 | Consul | +| 消息队列 | RabbitMQ | +| 服务治理 | OpenTelemetry | +| 限流熔断 | Sentinel | +| 对象存储 | Minio | +| 图像识别 | 百度 OCR | +| CI | GitHub Actions | + ## 页面展示 +小程序端地址 [FreeCar-MP](https://github.com/CyanAsterisk/FreeCar-MP) + +后台管理端地址 TODO + ![display.png](img/display.png) ## 目录介绍 -| 目录 | 介绍 | -|--------|---------| -| Server | 项目核心部分 | -| Shared | 可复用代码 | -| Static | 微信小程序代码 | +| 目录 | 介绍 | +|--------|----------------| +| Cmd | 项目核心部分 | +| Idl | 项目所有服务的 IDL 文件 | +| Shared | 可复用代码 | ## 服务介绍 -| 目录 | 介绍 | -|---------|-----------------------| -| API | 基于 Hertz 的网关服务 | -| User | 用户认证服务 | -| Blob | 与图片和 Minio 对象存储 相关的服务 | -| Car | 汽车服务 | -| Profile | 主页与图片识别服务 | -| Trip | 行程服务 | +| 目录 | 介绍 | +|---------|----------------------| +| API | 基于 Hertz 的网关服务 | +| User | 用户认证服务 | +| Blob | 与图片和 Minio 对象存储相关的服务 | +| Car | 汽车服务 | +| Profile | 主页与图片识别服务 | +| Trip | 行程服务 | ## 快速开始 @@ -49,23 +69,15 @@ FreeCar 是一个基于 Hertz 与 Kitex 的全栈项目。 make start ``` -### 配置 Nacos - -> 在浏览器上访问 `http://127.0.0.1:8848/nacos/index.html#/login` 进行登录。 -> -> 默认命名空间以及配置组等请参考各个 `config.yaml` 配置文件。 - -![nacos.png](img/nacos.png) +### 配置 Consul -![nacos_registry.png](img/nacos_registry.png) +> 默认 Consul 地址与 KV 配置等请参考各个 `config.yaml` 配置文件。 -关于配置中心的详细配置,[详见](docs/NACOS_CONFIG.md)。 +![consul_service.png](img/consul_service.png) -### 生成数据表 +![consul_kv.png](img/consul_kv.png) -```shell -make migrate -``` +关于 KV 键值对的详细配置,[详见](docs/CONSUL_CONFIG.md)。 ### 启动 HTTP 服务 @@ -73,7 +85,7 @@ make migrate make api ``` -### 启动微服务 +### 启动 RPC 服务 ```shell make user @@ -87,7 +99,7 @@ make trip > 在浏览器上访问 `http://127.0.0.1:16686/` -![jaeger.jpg](img/jaeger.jpg) +![jaeger.jpg](img/jaeger.png) ### Prometheus @@ -95,10 +107,6 @@ make trip ![prometheus.jpg](img/prometheus.png) -## API 请求 - -项目的 API 请求示例[详见](docs/API_REQUEST.md)。 - ## 开发指南 通过直接阅读源码来了解此项目是非常困难的,在此提供开发指南方便开发者快速了解并上手此项目包括 Kitex、Hertz 等框架。 @@ -134,24 +142,17 @@ service UserService { #### Kitex -在新增服务目录下执行,每次仅需更改服务名与 IDL 路径。 - -##### 服务端 +首先在 `shared` 文件夹下生成 `kitex_gen`,再在相对应服务文件夹下依赖 `kitex_gen` 进行生成。在新增服务目录下执行,每次仅需更改服务名与 IDL 路径。 ```shell -kitex -service user -module github.com/CyanAsterisk/FreeCar ./../../idl/user.thrift -``` - -##### 客户端 - -```shell -kitex -module github.com/CyanAsterisk/FreeCar ./../../idl/user.thrift +kitex -module github.com/CyanAsterisk/FreeCar ./../idl/rpc/user.thrift +kitex -service user -module github.com/CyanAsterisk/FreeCar -use github.com/CyanAsterisk/FreeCar/server/shared/kitex_gen ./../../idl/rpc/user.thrift ``` 注意项: - 用 `-module github.com/CyanAsterisk/FreeCar` 该参数用于指定生成代码所属的 Go 模块,避免路径问题。 -- 当前服务需要调用其他服务时需生成客户端文件。 +- 当前服务需要调用其他服务时需依赖 `kitex_gen`。 #### Hertz @@ -161,12 +162,6 @@ kitex -module github.com/CyanAsterisk/FreeCar ./../../idl/user.thrift hz new -idl ./../../idl/api.proto -mod github.com/CyanAsterisk/FreeCar/server/cmd/api ``` -##### 更新 - -```shell -hz update -I -idl ./../../idl/api.proto -``` - 注意项: - 用 `-module github.com/CyanAsterisk/FreeCar/server/cmd/api` 该参数用于指定生成代码所属的 Go 模块,避免路径问题。 @@ -180,17 +175,13 @@ hz update -I -idl ./../../idl/api.proto 参考 `server/cmd/user/config`,为微服务的配置结构体。 -#### Global - -参考 `server/cmd/user/global`,为微服务提供可全局调用的方法。 - #### Initialize -参考 `server/cmd/user/initialize`,提供必要组件的初始化功能,其中 `nacos.go` `flag.go` `logger.go` 为必须项。 +参考 `server/cmd/user/initialize`,提供必要组件的初始化功能,其中 `config.go` `registry.go` `flag.go` `logger.go` 为必须项。 -#### Tool +#### Pkg -参考 `server/cmd/user/tool`,提供微服务的工具函数,其中 `port.go` 为必须项。 +参考 `server/cmd/user/pkg`,提供微服务的调用函数,主要用于实现 `handler.go` 中定义的接口。 #### API diff --git a/docker-compose.yaml b/docker-compose.yaml index 25eee4b1..e394c82d 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -23,6 +23,7 @@ services: restart: "no" ports: - "27017:27017" + redis: image: redis:latest restart: always diff --git a/docs/API_REQUEST.md b/docs/API_REQUEST.md deleted file mode 100644 index dff8920f..00000000 --- a/docs/API_REQUEST.md +++ /dev/null @@ -1,483 +0,0 @@ -## API Requests - -### Login - -**Request** - -```shell -curl --location --request POST '127.0.0.1:9900/user/login' \ - --header 'Content-Type: application/json' \ - --data-raw '{ - "code":"123456789" -}' -``` - -**Response** - -```json -{ - "code": 10000, - "message": "Success", - "data": { - "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJJRCI6MTYxMTMyNDQ2NjEwMzU4NjgxNiwiZXhwIjoxNjc1NTk2NzIxLCJpc3MiOiJGcmVlQ2FyIiwibmJmIjoxNjczMDA0NzIxfQ.THlMej2DgC3Lbt-TROkX55lMe9KZm9k2_VGvfKlW4Tk", - "expired_at": 1675596721 - } -} -``` - -### CreateCar - -**Request** - -```shell -curl --location --request POST '127.0.0.1:9900/car' \ - --header 'Content-Type: application/json' \ - --header 'authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJJRCI6MTYxMTMyNDQ2NjEwMzU4NjgxNiwiZXhwIjoxNjc1NTk2NzIxLCJpc3MiOiJGcmVlQ2FyIiwibmJmIjoxNjczMDA0NzIxfQ.THlMej2DgC3Lbt-TROkX55lMe9KZm9k2_VGvfKlW4Tk' -``` - -**Response** - -```json -{ - "code": 10000, - "message": "Success", - "data": { - "id": "63b808475e992cb7509b215a", - "car": { - "status": 1, - "driver": { - "id": 0, - "avatar_url": "" - }, - "position": { - "latitude": 30, - "longitude": 120 - }, - "trip_id": "" - } - } -} -``` - -### GetCar - -**Request** - -```shell -curl --location --request GET '127.0.0.1:9900/car' \ - --header 'Content-Type: application/json' \ - --header 'authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJJRCI6MTYxMTMyNDQ2NjEwMzU4NjgxNiwiZXhwIjoxNjc1NTk2NzIxLCJpc3MiOiJGcmVlQ2FyIiwibmJmIjoxNjczMDA0NzIxfQ.THlMej2DgC3Lbt-TROkX55lMe9KZm9k2_VGvfKlW4Tk' \ - --data-raw '{ - "id":"63b808475e992cb7509b215a" -}' -``` - -**Response** - -```json -{ - "code": 10000, - "message": "Success", - "data": { - "status": 1, - "driver": { - "id": 0, - "avatar_url": "" - }, - "position": { - "latitude": 30, - "longitude": 120 - }, - "trip_id": "" - } -} -``` - -### GetProfile - -**Request** - -```shell -curl --location --request GET '127.0.0.1:9900/profile' \ - --header 'Content-Type: application/json' \ - --header 'authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJJRCI6MTYxMTMyNDQ2NjEwMzU4NjgxNiwiZXhwIjoxNjc1NTk2NzIxLCJpc3MiOiJGcmVlQ2FyIiwibmJmIjoxNjczMDA0NzIxfQ.THlMej2DgC3Lbt-TROkX55lMe9KZm9k2_VGvfKlW4Tk' -``` - -**Response** - -```json -{ - "code": 10000, - "message": "Success", - "data": { - "identity": { - "lic_number": "", - "name": "", - "gender": 0, - "birth_date_millis": 0 - }, - "identity_status": 0 - } -} -``` - -### SubmitProfile - -**Request** - -```shell -curl --location --request POST '127.0.0.1:9900/profile' \ - --header 'Content-Type: application/json' \ - --header 'authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJJRCI6MTYxMTMyNDQ2NjEwMzU4NjgxNiwiZXhwIjoxNjc1NTk2NzIxLCJpc3MiOiJGcmVlQ2FyIiwibmJmIjoxNjczMDA0NzIxfQ.THlMej2DgC3Lbt-TROkX55lMe9KZm9k2_VGvfKlW4Tk' \ - --data-raw '{ - "identity": { - "lic_number": "123456789", - "name": "FreeCar", - "gender": 1, - "birth_date_millis": 1058190205 - } -}' -``` - -**Response** - -```json -{ - "code": 10000, - "message": "Success", - "data": { - "identity": { - "lic_number": "123456789", - "name": "FreeCar", - "gender": 1, - "birth_date_millis": 1058190205 - }, - "identity_status": 1 - } -} -``` - -### ClearProfile - -**Request** - -```shell -curl --location --request DELETE '127.0.0.1:9900/profile' \ - --header 'Content-Type: application/json' \ - --header 'authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJJRCI6MTYxMTMyNDQ2NjEwMzU4NjgxNiwiZXhwIjoxNjc1NTk2NzIxLCJpc3MiOiJGcmVlQ2FyIiwibmJmIjoxNjczMDA0NzIxfQ.THlMej2DgC3Lbt-TROkX55lMe9KZm9k2_VGvfKlW4Tk' -``` - -**Response** - -```json -{ - "code": 10000, - "message": "Success", - "data": { - "identity": { - "lic_number": "", - "name": "", - "gender": 0, - "birth_date_millis": 0 - }, - "identity_status": 0 - } -} -``` - -### CreateProfilePhoto - -**Request** - -```shell -curl --location --request POST '127.0.0.1:9900/profile/photo' \ - --header 'Content-Type: application/json' \ - --header 'authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJJRCI6MTYxMTMyNDQ2NjEwMzU4NjgxNiwiZXhwIjoxNjc1NTk2NzIxLCJpc3MiOiJGcmVlQ2FyIiwibmJmIjoxNjczMDA0NzIxfQ.THlMej2DgC3Lbt-TROkX55lMe9KZm9k2_VGvfKlW4Tk' -``` - -**Response** - -```json -{ - "code": 10000, - "message": "Success", - "data": { - "url": "https://freecar-1234567.cos" - } -} -``` - -### GetProfilePhoto - -**Request** - -```shell -curl --location --request GET '127.0.0.1:9900/profile/photo' \ - --header 'Content-Type: application/json' \ - --header 'authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJJRCI6MTYxMTMyNDQ2NjEwMzU4NjgxNiwiZXhwIjoxNjc1NTk2NzIxLCJpc3MiOiJGcmVlQ2FyIiwibmJmIjoxNjczMDA0NzIxfQ.THlMej2DgC3Lbt-TROkX55lMe9KZm9k2_VGvfKlW4Tk' -``` - -**Response** - -```json -{ - "code": 10000, - "message": "Success", - "data": { - "url": "https://freecar-1234567.cos" - } -} -``` - -### ClearProfilePhoto - -**Request** - -```shell -curl --location --request DELETE '127.0.0.1:9900/profile/photo' \ - --header 'Content-Type: application/json' \ - --header 'authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJJRCI6MTYxMTMyNDQ2NjEwMzU4NjgxNiwiZXhwIjoxNjc1NTk2NzIxLCJpc3MiOiJGcmVlQ2FyIiwibmJmIjoxNjczMDA0NzIxfQ.THlMej2DgC3Lbt-TROkX55lMe9KZm9k2_VGvfKlW4Tk' -``` - -**Response** - -```json -{ - "code": 10000, - "message": "Success", - "data": {} -} -``` - -### CreateTrip - -**Request** - -```shell -curl --location --request POST '127.0.0.1:9900/trip' \ - --header 'Content-Type: application/json' \ - --header 'authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJJRCI6MTYxMTMyNDQ2NjEwMzU4NjgxNiwiZXhwIjoxNjc1NTk2NzIxLCJpc3MiOiJGcmVlQ2FyIiwibmJmIjoxNjczMDA0NzIxfQ.THlMej2DgC3Lbt-TROkX55lMe9KZm9k2_VGvfKlW4Tk' \ - --data-raw '{ - "start": { - "latitude": 123.11, - "longitude": 122.78 - }, - "car_id": "63b813565e992cb7509b215d", - "avatar_url": "url" -}' -``` - -**Response** - -```json -{ - "code": 10000, - "message": "Success", - "data": { - "id": "63b81364ce0713e67dab8856", - "trip": { - "account_id": 1611324466103586816, - "car_id": "63b813565e992cb7509b215d", - "start": { - "location": { - "latitude": 123.11, - "longitude": 122.78 - }, - "fee_cent": 0, - "km_driven": 0, - "poi_name": "综合实验大楼", - "timestamp_sec": 1673007972 - }, - "current": { - "location": { - "latitude": 123.11, - "longitude": 122.78 - }, - "fee_cent": 0, - "km_driven": 0, - "poi_name": "综合实验大楼", - "timestamp_sec": 1673007972 - }, - "end": { - "location": null, - "fee_cent": 0, - "km_driven": 0, - "poi_name": "", - "timestamp_sec": 0 - }, - "status": 1, - "identity_id": "eyJsaWNfbnVtYmVyIjoiMTIzNDU2Nzg5IiwibmFtZSI6IkZyZWVDYXIiLCJnZW5kZXIiOjEsImJpcnRoX2RhdGVfbWlsbGlzIjoxMDU4MTkwMjA1fQ==" - } - } -} -``` - -### GetTrip - -**Request** - -```shell -curl --location --request GET '127.0.0.1:9900/trip/63b81364ce0713e67dab8856' \ - --header 'Content-Type: application/json' \ - --header 'authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJJRCI6MTYxMTMyNDQ2NjEwMzU4NjgxNiwiZXhwIjoxNjc1NTk2NzIxLCJpc3MiOiJGcmVlQ2FyIiwibmJmIjoxNjczMDA0NzIxfQ.THlMej2DgC3Lbt-TROkX55lMe9KZm9k2_VGvfKlW4Tk' -``` - -**Response** - -```json -{ - "code": 10000, - "message": "Success", - "data": { - "account_id": 1611324466103586816, - "car_id": "63b813565e992cb7509b215d", - "start": { - "location": { - "latitude": 123.11, - "longitude": 122.78 - }, - "fee_cent": 0, - "km_driven": 0, - "poi_name": "综合实验大楼", - "timestamp_sec": 1673007972 - }, - "current": { - "location": { - "latitude": 123.11, - "longitude": 122.78 - }, - "fee_cent": 0, - "km_driven": 0, - "poi_name": "综合实验大楼", - "timestamp_sec": 1673007972 - }, - "end": { - "location": null, - "fee_cent": 0, - "km_driven": 0, - "poi_name": "", - "timestamp_sec": 0 - }, - "status": 1, - "identity_id": "eyJsaWNfbnVtYmVyIjoiMTIzNDU2Nzg5IiwibmFtZSI6IkZyZWVDYXIiLCJnZW5kZXIiOjEsImJpcnRoX2RhdGVfbWlsbGlzIjoxMDU4MTkwMjA1fQ==" - } -} -``` - -### GetTrips - -**Request** - -```shell -curl --location --request GET '127.0.0.1:9900/trips' \ - --header 'Content-Type: application/json' \ - --header 'authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJJRCI6MTYxMTMyNDQ2NjEwMzU4NjgxNiwiZXhwIjoxNjc1NTk2NzIxLCJpc3MiOiJGcmVlQ2FyIiwibmJmIjoxNjczMDA0NzIxfQ.THlMej2DgC3Lbt-TROkX55lMe9KZm9k2_VGvfKlW4Tk' -``` - -**Response** - -```json -{ - "code": 10000, - "message": "Success", - "data": { - "trips": [ - { - "id": "63b81364ce0713e67dab8856", - "trip": { - "account_id": 1611324466103586816, - "car_id": "63b813565e992cb7509b215d", - "start": { - "location": { - "latitude": 123.11, - "longitude": 122.78 - }, - "fee_cent": 0, - "km_driven": 0, - "poi_name": "综合实验大楼", - "timestamp_sec": 1673007972 - }, - "current": { - "location": { - "latitude": 123.11, - "longitude": 122.78 - }, - "fee_cent": 0, - "km_driven": 0, - "poi_name": "综合实验大楼", - "timestamp_sec": 1673007972 - }, - "end": { - "location": null, - "fee_cent": 0, - "km_driven": 0, - "poi_name": "", - "timestamp_sec": 0 - }, - "status": 1, - "identity_id": "eyJsaWNfbnVtYmVyIjoiMTIzNDU2Nzg5IiwibmFtZSI6IkZyZWVDYXIiLCJnZW5kZXIiOjEsImJpcnRoX2RhdGVfbWlsbGlzIjoxMDU4MTkwMjA1fQ==" - } - } - ] - } -} -``` - -### UpdateTrip - -**Request** - -```shell -curl --location --request POST '127.0.0.1:9900/trip/63b81364ce0713e67dab8856' \ - --header 'Content-Type: application/json' \ - --header 'authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJJRCI6MTYxMTMyNDQ2NjEwMzU4NjgxNiwiZXhwIjoxNjc1NTk2NzIxLCJpc3MiOiJGcmVlQ2FyIiwibmJmIjoxNjczMDA0NzIxfQ.THlMej2DgC3Lbt-TROkX55lMe9KZm9k2_VGvfKlW4Tk' \ - --data-raw '{ - "current": { - "latitude": 113.11, - "longitude": 112.78 - }, - "end_trip":false -}' -``` - -**Response** - -```json -{ - "code": 10000, - "message": "Success", - "data": { - "account_id": 1611324466103586816, - "car_id": "63b813565e992cb7509b215d", - "start": { - "location": { - "latitude": 123.11, - "longitude": 122.78 - }, - "fee_cent": 0, - "km_driven": 0, - "poi_name": "综合实验大楼", - "timestamp_sec": 1673007972 - }, - "current": { - "location": { - "latitude": 113.11, - "longitude": 112.78 - }, - "fee_cent": 914, - "km_driven": 1.5129536144797615, - "poi_name": "中心食堂", - "timestamp_sec": 1673009357 - }, - "end": { - "location": null, - "fee_cent": 0, - "km_driven": 0, - "poi_name": "", - "timestamp_sec": 0 - }, - "status": 1, - "identity_id": "eyJsaWNfbnVtYmVyIjoiMTIzNDU2Nzg5IiwibmFtZSI6IkZyZWVDYXIiLCJnZW5kZXIiOjEsImJpcnRoX2RhdGVfbWlsbGlzIjoxMDU4MTkwMjA1fQ==" - } -} -``` \ No newline at end of file diff --git a/docs/NACOS_CONFIG.md b/docs/CONSUL_CONFIG.md similarity index 50% rename from docs/NACOS_CONFIG.md rename to docs/CONSUL_CONFIG.md index 5d80f445..77632e90 100644 --- a/docs/NACOS_CONFIG.md +++ b/docs/CONSUL_CONFIG.md @@ -1,105 +1,115 @@ -## Nacos Config +## Consul Config -_api => API_GROUP_ +_freecar/api_srv_ ```json { "name": "api", - "host": "your host", - "port": 9900, - "jwt": { - "key": "km!RU#a*43BsTsBVLQPpmuXI&$BJD%Sz" + "port": 8080, + "paseto": { + "pub_key": "YOUR_KEY", + "implicit": "YOUR-IMPLICIT" }, "otel": { "endpoint": ":4317" }, - "user_srv": { + "user_srv":{ "name": "user_srv" }, - "car_srv": { + "car_srv":{ "name": "car_srv" }, - "profile_srv": { + "profile_srv":{ "name": "profile_srv" }, - "trip_srv": { + "trip_srv":{ "name": "trip_srv" } } ``` -_user_srv => AUTH_GROUP_ +_freecar/user_srv_ ```json { "name": "user_srv", - "host": "your host", + "paseto": { + "pub_key": "YOUR_KEY", + "implicit": "YOUR-IMPLICIT" + }, "mysql": { "host": "127.0.0.1", "port": 3306, - "user": "root", - "password": "123456", + "user": "YOUR_USER", + "password": "YOUR_PASSWORD", "db": "FreeCar", - "salt": "FreeCar" + "salt": "YOUR_SALT" }, "otel": { "endpoint": ":4317" }, - "wx_config": { - "app_id": "your app id", - "app_secret": "your app secret" + "wx_config":{ + "app_id": "YOUR_ID", + "app_secret": "YOUR_SECRET" }, - "blob_srv": { - "name": "blob_srv" + "blob_srv":{ + "name":"blob_srv" } } ``` -_blob_srv => BLOB_GROUP_ +_freecar/blob_srv_ ```json { "name": "blob_srv", - "host": "your host", "mysql": { "host": "127.0.0.1", "port": 3306, - "user": "root", - "password": "123456", + "user": "YOUR_USER", + "password": "YOUR_PASSWORD", "db": "FreeCar", - "salt": "FreeCar" + "salt": "YOUR_SALT" + }, + "redis": { + "host": "127.0.0.1", + "port": 6379 + }, + "minio": { + "endpoint": "127.0.0.1:9000", + "access_key_id": "YOUR_KEY", + "secret_access_key": "YOUR_SECRET", + "bucket":"freecar" }, "otel": { "endpoint": ":4317" - }, - "cos_config": { - "addr": "your cos addr", - "sec_id": "your sec id", - "sec_key": "your sec key" } } ``` -_car_srv => CAR_GROUP_ +_freecar/car_srv_ ```json { "name": "car_srv", - "host": "your host", - "wsAddr": ":9090", + "wsAddr":":9992", "mongodb": { "host": "127.0.0.1", "port": 27017, - "user": "admin", - "password": "123456", + "user": "YOUR_USER", + "password": "YOUR_PASSWORD", "db": "FreeCar", "collection": "car" }, + "redis": { + "host": "127.0.0.1", + "port": 6379 + }, "rabbitmq": { "host": "127.0.0.1", "port": 5672, - "user": "guest", - "password": "guest", + "user": "YOUR_USER", + "password": "YOUR_PASSWORD", "exchange": "FreeCar" }, "otel": { @@ -111,19 +121,25 @@ _car_srv => CAR_GROUP_ } ``` -_profile_srv => RENTAL_GROUP_ +_freecar/profile_srv_ ```json { "name": "profile_srv", - "host": "your host", "mongodb": { "host": "127.0.0.1", "port": 27017, - "user": "admin", - "password": "123456", + "user": "YOUR_USER", + "password": "YOUR_PASSWORD", "db": "FreeCar", - "collection": "profile" + "collection": "car" + }, + "redis": { + "host": "127.0.0.1", + "port": 6379 + }, + "ocr": { + "access_token": "YOUR_TOKEN" }, "otel": { "endpoint": ":4317" @@ -134,19 +150,18 @@ _profile_srv => RENTAL_GROUP_ } ``` -_trip_srv => RENTAL_GROUP_ +_freecar/trip_srv_ ```json { "name": "trip_srv", - "host": "your host", "mongodb": { "host": "127.0.0.1", "port": 27017, - "user": "admin", - "password": "123456", + "user": "YOUR_USER", + "password": "YOUR_PASSWORD", "db": "FreeCar", - "collection": "trip" + "collection": "car" }, "otel": { "endpoint": ":4317" diff --git a/img/consul_kv.png b/img/consul_kv.png new file mode 100644 index 00000000..ceb79f29 Binary files /dev/null and b/img/consul_kv.png differ diff --git a/img/consul_service.png b/img/consul_service.png new file mode 100644 index 00000000..1a6a981f Binary files /dev/null and b/img/consul_service.png differ diff --git a/img/jaeger.jpg b/img/jaeger.jpg deleted file mode 100644 index 09c63078..00000000 Binary files a/img/jaeger.jpg and /dev/null differ diff --git a/img/jaeger.png b/img/jaeger.png new file mode 100644 index 00000000..15c2c638 Binary files /dev/null and b/img/jaeger.png differ diff --git a/img/nacos.png b/img/nacos.png deleted file mode 100644 index 7c3a3312..00000000 Binary files a/img/nacos.png and /dev/null differ diff --git a/img/nacos_registry.png b/img/nacos_registry.png deleted file mode 100644 index 756459cc..00000000 Binary files a/img/nacos_registry.png and /dev/null differ diff --git a/img/service_relations.png b/img/service_relations.png index a05d0505..5142088c 100644 Binary files a/img/service_relations.png and b/img/service_relations.png differ diff --git a/img/tech_arch.png b/img/tech_arch.png index 32a905aa..21c6aaed 100644 Binary files a/img/tech_arch.png and b/img/tech_arch.png differ