Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

统一版本接口 #200

Open
wants to merge 60 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
ba3af8d
:wrench: 将持久化模块添加到workspace
Goodjooy Jul 4, 2024
95c252a
:sparkles: 添加统一版本接口的相关结构体
Goodjooy Jul 4, 2024
e4524df
:white_check_mark: 添加序列化验证单元测试
Goodjooy Jul 4, 2024
d82d011
:art: cargo clippy & fmt
Goodjooy Jul 4, 2024
c8f1961
:recycle: 调整统一版本结构
Goodjooy Jul 4, 2024
9aeecfb
:art: cargo fmt
Goodjooy Jul 4, 2024
5cfc6fd
:recycle: 调整入库结构
Goodjooy Jul 5, 2024
91add47
:sparkles: 添加对应Checker
Goodjooy Jul 5, 2024
2859d25
:card_file_box: 添加release-version的数据migration
Goodjooy Jul 5, 2024
42e076d
:sparkles: database-operate 模块添加辅助功能以及导出
Goodjooy Jul 5, 2024
e7e9d3c
:sparkles: 添加统一版本的DAO层实现
Goodjooy Jul 5, 2024
06c3e0a
:art: cargo fmt
Goodjooy Jul 5, 2024
a55da0b
:sparkles: 添加旧版Version到新版转换
Goodjooy Jul 8, 2024
2da042a
:sparkles: 添加旧版Version到新版转换
Goodjooy Jul 8, 2024
e22accc
:alien: resp_result 更名为axum-resp-result
Goodjooy Jul 8, 2024
4b9b108
:sparkles: 添加ReleaseVersion接口
Goodjooy Jul 8, 2024
5612ae5
:sparkles: 添加接口日志信息
Goodjooy Jul 8, 2024
a62184a
:art: cargo fmt
Goodjooy Jul 8, 2024
64a3897
:sparkles: 添加启动迁移实现
Goodjooy Jul 8, 2024
e5ac427
:art: cargo fmt + clippy
Goodjooy Jul 8, 2024
be4aa4f
:art: cargo fmt
Goodjooy Jul 8, 2024
9a52884
:recycle: 调整日志实现
Goodjooy Jul 8, 2024
af8bcaa
:art: cargo clippy
Goodjooy Jul 8, 2024
1577b77
:recycle: 将统一版本获取移动到CDN
Goodjooy Aug 9, 2024
a5f4c8a
:art: cargo fmt
Goodjooy Aug 9, 2024
606b8a3
:sparkles: 添加可撤回的版本接口
Goodjooy Aug 9, 2024
08a9053
:sparkles: 添加基本的独立controller模块
Goodjooy Aug 19, 2024
d5c1f66
:sparkles: 添加基本的独立controller模块
Goodjooy Aug 19, 2024
254b434
:sparkles: 添加终端区分路由支持
Goodjooy Aug 19, 2024
8daad45
:recycle: 调整接口
Goodjooy Aug 19, 2024
b31b1c2
:recycle: 将当前重构的统一版本移动到一起
Goodjooy Aug 19, 2024
974436e
:sparkles: 添加管理查看与添加版本接口
Goodjooy Aug 19, 2024
66c4720
:art: cargo clippy & cargo fmt
Goodjooy Aug 19, 2024
4216cd0
:twisted_rightwards_arrows: merge `master` into `feat\union-version`
Goodjooy Aug 25, 2024
b3ed8ec
:art: cargo fmt
Goodjooy Aug 25, 2024
da3f2ae
:sparkles: 添加腾讯云缓存刷新逻辑
Goodjooy Aug 25, 2024
38b268f
:fire: 删除不必要的modify-state
Goodjooy Aug 25, 2024
ec2330a
:sparkles: 添加 使用ZIP安装的平台
Goodjooy Aug 25, 2024
d03a276
:recycle: 将校验版本的实现移动到`verify`
Goodjooy Aug 25, 2024
5932412
:pencil2: 调整部分转换文本
Goodjooy Aug 25, 2024
d902d88
:art: cargo clippy + cargo fmt
Goodjooy Aug 25, 2024
52b0b99
:art: cargo clippy + cargo fmt
Goodjooy Aug 25, 2024
b1e7e35
:recycle: 为`CheckExtract` 添加 `ToInner` 实现,以能够用于`MapReject`
Goodjooy Sep 4, 2024
489aafa
:sparkles: 为`release_version_service` 提供的`AdminEnd` 的接口添加可选的分页支持与总量获取接口
Goodjooy Sep 4, 2024
33eb780
:rotating_light: 修复checker问题
Goodjooy Sep 4, 2024
b90fa9c
:art: cargo fmt
Goodjooy Sep 4, 2024
4fe9ff7
Merge branch 'master' into feat/union-version
Goodjooy Sep 4, 2024
42fb01b
:art: cargo fmt
Goodjooy Sep 4, 2024
dda6d19
♻️ 添加统一版本的Logic层
Goodjooy Sep 8, 2024
7b1620d
♻️ 将逻辑层添加到http-serve层
Goodjooy Sep 8, 2024
45a1d5b
✨ page_info 现在可以不携带分页信息
Goodjooy Sep 8, 2024
b8a5a14
🎨 cargo clippy & cargo fmt
Goodjooy Sep 8, 2024
f98de90
🎨 cargo fmt
Goodjooy Sep 8, 2024
32c891d
👷 调整rustc 版本
Goodjooy Sep 8, 2024
45d6e93
🔥 移除总量统计接口
Goodjooy Sep 8, 2024
14ff238
:sparkles: 添加更新接口
Goodjooy Sep 9, 2024
5d47b84
:sparkles: 添加更新handler
Goodjooy Sep 9, 2024
1026080
:art: cargo clippy + cargo fmt
Goodjooy Sep 9, 2024
af2421d
:recycle: 合并更新接口
Goodjooy Sep 12, 2024
200ad45
:art: cargo fmt + cargo clippy
Goodjooy Sep 12, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/checker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
- name: Rust toolchain Stable
uses: actions-rs/toolchain@v1
with:
toolchain: 1.78.0
toolchain: 1.80.1
components: clippy
default: true
- name: Rust toolchain Nightly
Expand Down
21 changes: 17 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,16 @@ debug = 1
members = [
"libs/*",
"persistence/persistence",
"persistence/dao/*",
"persistence/database/*",
"persistence/migrate/*",
"persistence/models/*",
"./macros/*",
"./middle-server/*",
"./logic/*",
"./global/*",
"./service/*",
"http_service/ceobe_operation/*",
]

[workspace.dependencies]
Expand All @@ -48,7 +53,8 @@ once_cell = "1"
reqwest = { version = "0.12", default-features = false, features = [
"rustls-tls",
] }
resp-result = { version = "0.7", package = "axum-resp-result"}
axum-resp-result = { version = "0.7.1"}

sea-orm = { version = "0.12", default-features = false, features = [
"sqlx-mysql",
"runtime-tokio-rustls",
Expand Down Expand Up @@ -103,6 +109,10 @@ hex = "0.4"
serde_qs = "0.13.0"
request-clients = { version = "0.1.0", path = "middle-server/request-clients" }
mime = "0.3.16"
serve-utils = {version = "0.1.0", path="libs/serve_utils"}
tower = { version = "0.4", features = ["limit"] }
status-err={path = "./libs/status-err"}


[dependencies]

Expand Down Expand Up @@ -134,7 +144,7 @@ reqwest = { workspace = true }
sha2 = { workspace = true }
tap = { workspace = true }
thiserror = { workspace = true }
tower = { version = "0.4", features = ["limit"] }
tower.workspace = true
tower-http = { version = "0.5", features = ["trace", "catch-panic", "set-header", "compression-full", "auth", "add-extension", "cors"] }
typed-builder = { workspace = true }
url = { workspace = true }
Expand All @@ -156,6 +166,9 @@ bitmap-convert.workspace = true
bitmaps.workspace = true
persistence = { workspace = true, features = ["prelude", "migrate"] }
tencent-cloud-server.workspace = true
semver = { version = "1.0.23", features = ["serde"] }
release_version_service = { version = "0.1.0", path = "http_service/ceobe_operation/release_version_service" }
serve_utils = { version = "0.1.0", path = "libs/serve_utils" }
mimalloc = "0.1.43"


Expand All @@ -179,9 +192,9 @@ path = "./libs/range-limit"
path = "./libs/logger"

[dependencies.status-err]
path = "./libs/status-err"
workspace = true

[dependencies.resp-result]
[dependencies.axum-resp-result]
workspace = true

[dependencies.checker]
Expand Down
90 changes: 48 additions & 42 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,24 @@
| `database`/`db` | `logger` | 否 | `bool` | 是否开始数据库操作日志 | 默认关闭 |
| `logger`/`log` | `to_stdout` | 否 | `bool` | 同时将日志输出到 Stdout | 默认为 true |
| `logger`/`log` | `to_file` | 否 | `String` | 同时将日志输出的文件 | 有值将会同时将日志输出到指定文件 |
| `logger`/`log` | `level` | 是 | `off` 或者</br>`error`或者</br>`warm` 或者</br>`info` 或者</br>`debug` 或者</br>`trace` | 日志输出过滤等级 | 无 |
| `logger`/`log` | `level` | 是 | `off` 或者</br>`error`或者</br>`warm` 或者</br>`info` 或者</br>`debug`
或者</br>`trace` | 日志输出过滤等级 | 无 |
| `resp_result`/ `rresult` | `body` | 是 | `String` | 响应成功时的响应体字段名称 | 无 |
| `resp_result`/ `rresult` | `err-msg` | 是 | `String` | 响应失败时异常字段名称 | 无 |
| `resp_result`/ `rresult` | `fix-field` | 是 | `bool` | 响应体固定字段 | 如果无需该字段值将为`null` |
| `resp_result`/ `rresult` | `bool-status` | 否 | `Option<String>` | 使用一个 `bool` 类型标记响应成功与否 | 该字段缺省表示不使用 |
| `resp_result`/ `rresult` | `body-extra-err` | 否 | `Option<String>` | 额外的异常信息在响应体中字段 | 该字段缺省表示不使用 |
| `resp_result`/ `rresult` | `header-extra-err` | 否 | `Option<String>` | 额外的异常信息在响应头中的字段名称 | 该字段缺省表示不使用 |
| `resp_result`/ `rresult` | `bool-status` | 否 | `Option<String>` | 使用一个 `bool` 类型标记响应成功与否 |
该字段缺省表示不使用 |
| `resp_result`/ `rresult` | `body-extra-err` | 否 | `Option<String>` | 额外的异常信息在响应体中字段 |
该字段缺省表示不使用 |
| `resp_result`/ `rresult` | `header-extra-err` | 否 | `Option<String>` | 额外的异常信息在响应头中的字段名称 |
该字段缺省表示不使用 |
| `mongodb`/ `mongo` | `username` | 是 | `String` | Mongodb 进行数据库连接使用的用户 | 该用户需要完整 Admin 权限 |
| `mongodb`/ `mongo` | `password` | 是 | `String` | Mongodb 进行数据库连接使用的用户密码 | 无 |
| `mongodb`/ `mongo` | `host` | 否 | `String` | Mongodb 进行数据库连接使用的 host | 默认为`localhost` |
| `mongodb`/ `mongo` | `port` | 否 | `String` | Mongodb 进行数据库连接使用的端口 | 默认为`27017` |
| `mongodb`/ `mongo` | `db_name` | 是 | `String` | Mongodb 进行数据库连接使用的数据库 | 无 |
| `user_auth`/ `auth` | `jwt`/`jwt-key` | 否 | `String` | 用户鉴权使用的`Jwt`密钥 | 最大长度不超过 32 位。过长部分将会被截断,过短部分将会被随机数填充 |
| `user_auth`/ `auth` | `jwt`/`jwt-key` | 否 | `String` | 用户鉴权使用的`Jwt`密钥 | 最大长度不超过 32
位。过长部分将会被截断,过短部分将会被随机数填充 |
| `user_auth`/ `auth` | `header`/`header_name` | 否 | `String` | 获取 token 的 Header | 默认为`Token` |
| `user_auth`/ `auth` | `mob_header` | 否 | `String` | 获取 mob_id 的 Header | 默认为`mob-id` |
| `admin_user`/ `user` | `username` | 是 | `String` | 默认后台第一个最高权限用户名 | |
Expand Down Expand Up @@ -116,20 +121,20 @@
| `M` | 数据未变更 |
| `A` | 权限认证异常 |
| `Q` | 七牛云上传异常 |
| `L` | 日志报告异常 |
| `L` | 日志报告异常 |
- 服务异常

| 前缀 | 异常码 | httpCode | 说明 |
| :--: | :----: | :------: | :--------------------- |
| :--: | :----: | :------: | :--------------------- |
| `F` | 0001 | 500 | 服务器发生未预期 Panic |
| `F` | 0002 | 500 | 管道发生未预期关闭 |

- Io 异常

| 前缀 | 异常码 | httpCode | 说明 |
| :--: |:----:| :------: |:------------------|
| :--: |:----:| :------: |:------------------|
| `I` | 0001 | 500 | `std::io::Error` |
| `I` | 0002 | 500 | `core::fmt::Error`|
| `I` | 0002 | 500 | `core::fmt::Error`|
- 类型转换异常

| 前缀 | 异常码 | httpCode | 说明 |
Expand All @@ -143,37 +148,38 @@
| `P` | 0007 | 500 | 非法 Http 请求头内容 |
| `P` | 0008 | 500 | UUID解析异常 |

- 数据校验异常

| 前缀 | 异常码 | httpCode | 说明 |
| :--: |:----:| :------: |:------------------------------------|
| `C` | 0001 | 400 | 范围检查未通过 |
| `C` | 0002 | 400 | 饼学大厦 id 格式不是 {int}.{int} |
| `C` | 0003 | 400 | 错误的 Fraction 值范围(0~5) |
| `C` | 0004 | 400 | `Json` 序列化/反序列化异常 |
| `C` | 0005 | 400 | `Path` 数据加载异常 |
| `C` | 0006 | 400 | 未知的预期确信度等级 |
| `C` | 0007 | 400 | `Query` 加载异常 |
| `C` | 0008 | 409 | 饼学大厦的 Id 已经存在 |
| `C` | 0009 | 400 | BV 号格式错误 |
| `C` | 000A | 400 | 版本号格式错误 |
| `C` | 000B | 409 | 版本号已经被使用 |
| `C` | 000C | 400 | `Bincode` 序列化/反序列化异常 |
| `C` | 000D | 500 | 存在多个可用的资源全可用的记录 |
| `C` | 000E | 400 | 预期为 0 值取得非 0 值 |
| `C` | 000F | 400 | 获取`MultiPart`异常 |
| `C` | 0010 | 400 | 解析`MultiPart`异常 |
| `C` | 0011 | 400 | `MultiPart` Field 不存在 |
| `C` | 0012 | 500 | 平台下存在数据源,无法删除平台 |
| `C` | 0013 | 400 | 未找到平台 |
| `C` | 0014 | 400 | `{origin}` 无法被 `{RHS}` 整除,余数`{rem}` |
| `C` | 0015 | 400 | Json 对象不符合预期 |
- | `C` | 0016 | 400 | Bson 序列化异常 |
数据校验异常

| 前缀 | 异常码 | httpCode | 说明 |
|:-----:|:----:|:--------:|:------------------------------------|
| `C` | 0001 | 400 | 范围检查未通过 |
| `C` | 0002 | 400 | 饼学大厦 id 格式不是 {int}.{int} |
| `C` | 0003 | 400 | 错误的 Fraction 值范围(0~5) |
| `C` | 0004 | 400 | `Json` 序列化/反序列化异常 |
| `C` | 0005 | 400 | `Path` 数据加载异常 |
| `C` | 0006 | 400 | 未知的预期确信度等级 |
| `C` | 0007 | 400 | `Query` 加载异常 |
| `C` | 0008 | 409 | 饼学大厦的 Id 已经存在 |
| `C` | 0009 | 400 | BV 号格式错误 |
| `C` | 000A | 400 | 版本号格式错误 |
| `C` | 000B | 409 | 版本号已经被使用 |
| `C` | 000C | 400 | `Bincode` 序列化/反序列化异常 |
| `C` | 000D | 500 | 存在多个可用的资源全可用的记录 |
| `C` | 000E | 400 | 预期为 0 值取得非 0 值 |
| `C` | 000F | 400 | 获取`MultiPart`异常 |
| `C` | 0010 | 400 | 解析`MultiPart`异常 |
| `C` | 0011 | 400 | `MultiPart` Field 不存在 |
| `C` | 0012 | 500 | 平台下存在数据源,无法删除平台 |
| `C` | 0013 | 400 | 未找到平台 |
| `C` | 0014 | 400 | `{origin}` 无法被 `{RHS}` 整除,余数`{rem}` |
| `C` | 0015 | 400 | Json 对象不符合预期 |
| `C` | 0016 | 400 | Bson 序列化异常 |
| `C` | 0017 | 409 | 版本号过旧 |

- 数据库异常(SeaOrm)

| 前缀 | 异常码 | httpCode | 说明 |
| :--: | :----: | :------: | :------------------- |
| :--: | :----: | :------: | :------------------- |
| `D` | 0001 | 500 | 数据库连接失败 |
| `D` | 0002 | 500 | 数据库请求操作失败 |
| `D` | 0003 | 500 | 数据库查询失败 |
Expand All @@ -186,7 +192,7 @@
- 数据库异常(MongoDb)

| 前缀 | 异常码 | httpCode | 说明 |
| :--: | :----: | :------: | :----------------------- |
| :--: | :----: | :------: | :----------------------- |
| `G` | 0001 | 500 | 非法参数 |
| `G` | 0002 | 500 | 权限不足 |
| `G` | 0003 | 500 | `Bson`反序列化失败 |
Expand All @@ -210,7 +216,7 @@
- Redis 异常

| 前缀 | 异常码 | httpCode | 说明 |
| :--: | :----: | :------: | :------------------------------- |
| :--: | :----: | :------: | :------------------------------- |
| `R` | 0001 | 500 | 无效响应 |
| `R` | 0002 | 500 | 权限不足 |
| `R` | 0003 | 500 | 类型不匹配 |
Expand All @@ -232,7 +238,7 @@
- 数据未变更

| 前缀 | 异常码 | httpCode | 说明 |
| :--: | :----: | :------: | :----------------------------- |
| :--: | :----: | :------: | :----------------------------- |
| `M` | 0001 | 304 | Ceobe 在当前提供时间戳下无更新 |

- 资源查找异常
Expand All @@ -250,7 +256,7 @@
- 权限认证异常

| 前缀 | 异常码 | httpCode | 说明 |
| :--: | :----: | :------: | :------------------- |
| :--: | :----: | :------: | :------------------- |
| `A` | 0001 | 401 | 缺少 Token 字段 |
| `A` | 0002 | 401 | 权限不足 |
| `A` | 0003 | 404 | Token 对应信息不存在 |
Expand All @@ -265,13 +271,13 @@
- 七牛云上传异常

| 前缀 | 异常码 | httpCode | 说明 |
| :--: | :----: | :------: | :------------------- |
| :--: | :----: | :------: | :------------------- |
| `Q` | 0001 | 500 | 上传七牛云时出现异常 |

- 日志报告异常

|前缀 | 异常码 | httpCode | 说明|
| :--: | :----: | :------: | :------------------- |
| :--: | :----: | :------: | :------------------- |
| `L` | 0001 | 500 | 与Grpc服务端建立连接失败 |
| `L` | 0002 | 500 | Grpc service 返回异常响应 |
| `L` | 0003 | 500 | 发送日志时收到失败响应 |
8 changes: 3 additions & 5 deletions global/redis_global/src/type_bind/hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,11 @@ where
self.redis.hexists(&*self.key, field).await
}

pub async fn set<'arg, RV, F>(
pub async fn set<'arg, F>(
&mut self, field: F, value: T::Input,
) -> RedisResult<RV>
) -> RedisResult<()>
where
F: ToRedisArgs + Send + Sync + 'arg,
RV: FromRedisValue,
{
self.redis.hset(&*self.key, field, value).await
}
Expand Down Expand Up @@ -97,10 +96,9 @@ where
///
/// ## 参考
/// - [`AsyncCommands::hdel`]
pub async fn remove<'arg, RV, F>(&mut self, field: F) -> RedisResult<RV>
pub async fn remove<'arg, F>(&mut self, field: F) -> RedisResult<()>
where
F: ToRedisArgs + Send + Sync + 'arg,
RV: FromRedisValue,
{
self.redis.hdel(&*self.key, field).await
}
Expand Down
15 changes: 5 additions & 10 deletions global/redis_global/src/type_bind/normal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,25 +53,20 @@ where
///
/// ## 参考
/// - [`AsyncCommands::set_nx`]
pub async fn set_if_not_exist<RV>(
pub async fn set_if_not_exist(
&mut self, value: T::Input,
) -> RedisResult<RV>
where
RV: FromRedisValue,
{
) -> RedisResult<()>
where {
self.redis.set_nx(&*self.key, value).await
}

/// 写入值并添加超时时间
///
/// ## 参考
/// - [`AsyncCommands::set_ex`]
pub async fn set_with_expire<RV>(
pub async fn set_with_expire(
&mut self, value: T::Input, duration: Duration,
) -> RedisResult<RV>
where
RV: FromRedisValue,
{
) -> RedisResult<()> {
self.redis
.set_ex(&*self.key, value, duration.as_secs() as _)
.await
Expand Down
20 changes: 20 additions & 0 deletions http_service/ceobe_operation/release_version_service/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[package]
name = "release_version_service"
version = "0.1.0"
edition = "2021"

[dependencies]
persistence = { workspace = true, features = ["model-ceobe-operate", "help-crates"] }
semver = "1.0.23"
serve_utils = { version = "0.1.0", path = "../../../libs/serve_utils" }
serde = { version = "1.0.201", features = ["derive"] }
thiserror.workspace = true
status-err.workspace = true
http.workspace = true
axum-resp-result.workspace = true
tracing.workspace = true
serde_json.workspace = true
tencent-cloud-server.workspace = true
checker = { version = "0.1.0", path = "../../../libs/checker" }
page_size.workspace = true
ceobe_operation_logic = { version = "0.1.0", path = "../../../logic/ceobe_operation_logic" }
23 changes: 23 additions & 0 deletions http_service/ceobe_operation/release_version_service/src/error.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
use checker::prefabs::num_check::NonZeroUnsignedError;
use serve_utils::{
axum::extract::rejection::{JsonRejection, QueryRejection},
status_err::StatusErr,
ControllerError, ThisError,
};

#[derive(Debug, ThisError, StatusErr)]
#[status_err(resp_err)]
pub enum Error {
#[error(transparent)]
Query(#[from] QueryRejection),
#[error(transparent)]
Json(#[from] JsonRejection),
#[error(transparent)]
InvalidPaginator(#[from] NonZeroUnsignedError),
#[error(transparent)]
Logic(#[from] ceobe_operation_logic::release_version::Error),
}

impl ControllerError for crate::ReleaseVersionController {
type Error = Error;
}
Loading
Loading