Skip to content

Commit

Permalink
👔 增加前台返回版本列表接口
Browse files Browse the repository at this point in the history
  • Loading branch information
phidiaLam committed Dec 7, 2024
1 parent fa974e4 commit f102414
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ where
const BASE_URI: &'static str = "/version";

fn route(self) -> Router<S> {
Router::new().route("/fetch", get(Self::fetch_version))
Router::new()
.route("/fetch", get(Self::fetch_version))
.route("/all", get(Self::all_version_by_platform))
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@ 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,
axum::{extract::Query, Json}, axum_resp_result::{resp_result, MapReject}, tracing::instrument, OptionField, ValueField
};

use crate::{
Expand Down Expand Up @@ -40,7 +37,7 @@ impl crate::ReleaseVersionController {
pub async fn all_version(
logic: CeobeOperationLogic<ReleaseVersionLogic>,
MapReject(QueryVersionFilter {
platform,
platform: OptionField(platform),
deleted,
paginator: SerdeCheck(paginator),
}): MapRejecter<Query<QueryVersionFilter>>,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
use ceobe_operation_logic::{
release_version::ReleaseVersionLogic, CeobeOperationLogic,
};
use persistence::ceobe_operate::models::version::models::ReleaseVersion;
use checker::SerdeCheck;
use page_size::response::ListWithPageInfo;
use persistence::ceobe_operate::models::version::models::{ReleasePlatform, ReleaseVersion};
use serve_utils::{
axum::extract::Query,
axum_resp_result::{resp_result, MapReject},
tracing::instrument,
OptionField,
OptionField, ValueField,
};

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

Ok(release_info)
}

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

Ok(ret)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,10 @@ impl Display for QueryReleaseVersion<OptionField<Version>> {
}

#[derive(Debug, Deserialize)]
pub struct QueryVersionFilter {
pub platform: Option<ReleasePlatform>,
pub struct QueryVersionFilter<
Platform: OptionViewField<ReleasePlatform> = OptionField<ReleasePlatform>,
> {
pub platform: Platform,
#[serde(default)]
pub deleted: bool,
#[serde(flatten)]
Expand All @@ -48,7 +50,7 @@ pub struct QueryVersionFilter {

impl Display for QueryVersionFilter {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
match &self.platform {
match &self.platform.0 {
None => {
write!(f, "{{deleted: {} }}", self.deleted)
}
Expand Down
8 changes: 5 additions & 3 deletions logic/ceobe_operation_logic/src/release_version/implement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ impl ReleaseVersionLogic {
.await?;

self.tencent_cloud
.purge_urls_cache(&Some(TencentCDNPath::LATEST_VERSION))
.purge_urls_cache(&[TencentCDNPath::LATEST_VERSION, TencentCDNPath::VERSION_LIST])
.await?;

Ok(())
Expand Down Expand Up @@ -79,7 +79,7 @@ impl ReleaseVersionLogic {
.one(release)
.await?;
self.tencent_cloud
.purge_urls_cache(&Some(TencentCDNPath::LATEST_VERSION))
.purge_urls_cache(&[TencentCDNPath::LATEST_VERSION, TencentCDNPath::VERSION_LIST])
.await?;
Ok(())
}
Expand Down Expand Up @@ -126,7 +126,9 @@ impl ReleaseVersionLogic {
resources,
)
.await?;

self.tencent_cloud
.purge_urls_cache(&[TencentCDNPath::LATEST_VERSION, TencentCDNPath::VERSION_LIST])
.await?;
Ok(())
}
}
2 changes: 2 additions & 0 deletions logic/ceobe_operation_logic/src/release_version/view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@ pub struct TencentCDNPath;
impl TencentCDNPath {
pub const LATEST_VERSION: PurgeCachePath =
PurgeCachePath::new("/cdn/operate/version/fetch");
pub const VERSION_LIST: PurgeCachePath =
PurgeCachePath::new("/cdn/operate/version/all");
}

0 comments on commit f102414

Please sign in to comment.