Skip to content

Commit

Permalink
Merge pull request #221 from Enraged-Dun-Cookie-Development-Team/feat…
Browse files Browse the repository at this point in the history
…-修改版本cdn问题

Feat 修改版本cdn问题
  • Loading branch information
phidiaLam authored Dec 11, 2024
2 parents fdb5438 + 1a0976c commit 1d9d5f5
Show file tree
Hide file tree
Showing 18 changed files with 347 additions and 127 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ request-clients = { version = "0.1.0", path = "middle-server/request-clients" }
mime = "0.3.16"
tower = { version = "0.4", features = ["limit"] }
status-err={path = "./libs/status-err"}
page_next_id = { version = "0.1.0", path = "./libs/page_next_id" }


[dependencies]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ 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" }
page_next_id.workspace = true
Original file line number Diff line number Diff line change
@@ -1,23 +1,18 @@
use persistence::{
ceobe_operate::models::version::models::ReleasePlatform, operate::FromRef,
};
use persistence::operate::FromRef;
use serve_utils::{
axum::{
routing::{get, post},
Router,
},
const_field::ConstBoolField,
endpoint::{AdminEnd, CDN},
ControllerRoute, HandlerMapReject, HandlerResult, OptionField,
ValueField,
ControllerRoute, HandlerMapReject, HandlerResult,
};
use tencent_cloud_server::axum_starter::{
PartTencentCloudManagerState, RequestClient,
};

mod admin_end;
mod cdn;
mod common;

pub(crate) type Result<T> = HandlerResult<T, crate::ReleaseVersionController>;
pub(crate) type MapRejecter<T> =
Expand All @@ -34,13 +29,7 @@ where
fn route(self) -> Router<S> {
Router::new()
.route("/fetch", get(Self::fetch_version))
.route(
"/all",
get(Self::all_version::<
ConstBoolField<false>,
ValueField<ReleasePlatform>,
>),
)
.route("/all", get(Self::all_version_by_next_id))
}
}

Expand All @@ -56,13 +45,7 @@ where
Router::new()
.route("/markDelete", post(Self::mark_delete_version))
.route("/create", post(Self::new_version))
.route(
"/all",
get(Self::all_version::<
ValueField<bool>,
OptionField<ReleasePlatform>,
>),
)
.route("/all", get(Self::all_version))
.route("/modify", post(Self::modify_description))
}
}
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
use ceobe_operation_logic::{
release_version::ReleaseVersionLogic, CeobeOperationLogic,
};
use checker::SerdeCheck;
use page_size::response::ListWithPageInfo;
use persistence::ceobe_operate::models::version::models::ReleaseVersion;
use serve_utils::{
axum::{extract::Query, Json},
axum_resp_result::{resp_result, MapReject},
tracing::instrument,
ValueField,
OptionField, ValueField,
};

use crate::{
handlers::{MapRejecter, Result},
view::{QueryReleaseVersion, QueryVersionUpdate, UpdatePayload},
view::{
QueryReleaseVersion, QueryVersionFilter, QueryVersionUpdate,
UpdatePayload,
},
};

impl crate::ReleaseVersionController {
Expand Down Expand Up @@ -64,4 +69,19 @@ impl crate::ReleaseVersionController {
.await?;
Ok(())
}

#[resp_result]
#[instrument(skip_all)]
pub async fn all_version(
logic: CeobeOperationLogic<ReleaseVersionLogic>,
MapReject(QueryVersionFilter {
platform: OptionField(platform),
deleted: ValueField(deleted),
paginator: SerdeCheck(paginator),
}): MapRejecter<Query<QueryVersionFilter<ValueField<bool>>>>,
) -> Result<ListWithPageInfo<ReleaseVersion>> {
let ret = logic.all(paginator.into(), platform, deleted).await?;

Ok(ret)
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
use ceobe_operation_logic::{
release_version::ReleaseVersionLogic, CeobeOperationLogic,
};
use persistence::ceobe_operate::models::version::models::ReleaseVersion;
use page_next_id::response::ListWithNextId;
use persistence::{
ceobe_operate::models::version::models::ReleaseVersion,
mongodb::mongodb::bson::oid::ObjectId,
};
use serve_utils::{
axum::extract::Query,
axum_resp_result::{resp_result, MapReject},
Expand All @@ -10,7 +14,7 @@ use serve_utils::{
};

use super::{MapRejecter, Result};
use crate::view::QueryReleaseVersion;
use crate::view::{QueryReleaseVersion, QueryVersionNextIdFilter};
impl crate::ReleaseVersionController {
#[resp_result]
#[instrument(skip_all,fields(version = %arg_1.0))]
Expand All @@ -25,4 +29,18 @@ impl crate::ReleaseVersionController {

Ok(release_info)
}

#[resp_result]
#[instrument(skip_all)]
pub async fn all_version_by_next_id(
logic: CeobeOperationLogic<ReleaseVersionLogic>,
MapReject(QueryVersionNextIdFilter {
platform,
first_id,
}): MapRejecter<Query<QueryVersionNextIdFilter>>,
) -> Result<ListWithNextId<ReleaseVersion, ObjectId>> {
let ret = logic.all_by_page_id(first_id, platform, false).await?;

Ok(ret)
}
}

This file was deleted.

14 changes: 12 additions & 2 deletions http_service/ceobe_operation/release_version_service/src/view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@ use std::fmt::{Display, Formatter};

use checker::SerdeCheck;
use page_size::request::PageSizeChecker;
use persistence::ceobe_operate::models::version::models::{
DownloadSourceItem, ReleasePlatform,
use persistence::{
ceobe_operate::models::version::models::{
DownloadSourceItem, ReleasePlatform,
},
mongodb::mongodb::bson::oid::ObjectId,
};
use semver::Version;
use serde::Deserialize;
Expand Down Expand Up @@ -62,6 +65,13 @@ impl<D: Display + OptionViewField<bool>> Display for QueryVersionFilter<D> {
}
}

#[derive(Debug, Deserialize)]
pub struct QueryVersionNextIdFilter {
pub platform: ReleasePlatform,
#[serde(default)]
pub first_id: Option<ObjectId>,
}

#[derive(Debug, Deserialize)]
pub struct QueryVersionUpdate {
#[serde(flatten)]
Expand Down
8 changes: 8 additions & 0 deletions libs/page_next_id/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[package]
name = "page_next_id"
version = "0.1.0"
edition = "2021"

[dependencies]
serde.workspace = true
mongodb.workspace = true
1 change: 1 addition & 0 deletions libs/page_next_id/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pub mod response;
47 changes: 47 additions & 0 deletions libs/page_next_id/src/response/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
use _private::NextIdTrait;
use mongodb::bson::oid::ObjectId;
use serde::Serialize;

#[derive(Debug, Serialize)]
pub struct ListWithNextId<T, N>
where
T: Serialize,
N: Serialize + NextIdTrait,
{
list: Vec<T>,
next_id: Option<N>,
}

mod _private {
pub trait NextIdTrait {}
}

pub trait GenerateListWithNextId<N>: IntoIterator
where
Self::Item: Serialize,
N: Serialize + NextIdTrait,
{
fn with_page_next_id_info(
self, next_id: Option<N>,
) -> ListWithNextId<Self::Item, N>;
}

impl<N, T> GenerateListWithNextId<N> for T
where
T: IntoIterator,
T::Item: Serialize,
N: Serialize + NextIdTrait,
{
fn with_page_next_id_info(
self, next_id: Option<N>,
) -> ListWithNextId<Self::Item, N> {
ListWithNextId {
list: self.into_iter().collect(),
next_id,
}
}
}

// 支持成为NextId的类型
impl NextIdTrait for ObjectId {}
impl NextIdTrait for String {}
2 changes: 2 additions & 0 deletions logic/ceobe_operation_logic/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ tencent-cloud-server.workspace = true
serde_qs.workspace = true
semver = "1.0.23"
db-ops-prelude.workspace = true
tokio.workspace = true
page_next_id.workspace = true

[dependencies.checker]
path = "../../libs/checker"
10 changes: 10 additions & 0 deletions logic/ceobe_operation_logic/src/release_version/error.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
use std::convert::Infallible;

use persistence::ceobe_operate::release_version;
use status_err::ErrPrefix;
use tencent_cloud_server::error::TcCloudError;
use tokio::task::JoinError;

pub(super) type Rejection = Infallible;

Expand All @@ -11,6 +13,14 @@ pub enum Error {
Dao(#[from] release_version::Error),
#[error(transparent)]
Tencent(#[from] TcCloudError),

#[error(transparent)]
#[status_err(err(prefix = "ErrPrefix::SERVE", err_code = 0x0003,))]
JoinError(#[from] JoinError),

#[error(transparent)]
#[status_err(err = "transparent")]
SerdeQs(#[from] serde_qs::Error),
}

pub(super) type LogicResult<T> = core::result::Result<T, Error>;
Loading

0 comments on commit 1d9d5f5

Please sign in to comment.