From 853078f85d95174c62b16301b1a4a8ab7903736e Mon Sep 17 00:00:00 2001 From: FrozenString <964413011@qq.com> Date: Sun, 1 Dec 2024 19:53:38 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E2=9C=85=20=E4=BF=AE=E5=A4=8D=E6=B5=8B?= =?UTF-8?q?=E8=AF=95=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/ceobe/operation/version/models/version.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/persistence/models/mongo-models/src/ceobe/operation/version/models/version.rs b/persistence/models/mongo-models/src/ceobe/operation/version/models/version.rs index 81ea0ee5..7bdb4005 100644 --- a/persistence/models/mongo-models/src/ceobe/operation/version/models/version.rs +++ b/persistence/models/mongo-models/src/ceobe/operation/version/models/version.rs @@ -85,8 +85,9 @@ mod test { .name("百度云备用") .build(), ) + .build(), - ) + ).deleted(false) .build(); let serde = @@ -118,7 +119,8 @@ mod test { } ] } - ] + ], + "deleted":false, }) ); From 60003ca22969b712642cb077ec66e0f591779f88 Mon Sep 17 00:00:00 2001 From: FrozenString <964413011@qq.com> Date: Sun, 1 Dec 2024 20:03:53 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=F0=9F=94=A5=20=E7=A7=BB=E9=99=A4=E9=9D=9E?= =?UTF-8?q?=E5=BF=85=E8=A6=81=E7=9A=84=E9=A2=9D=E5=A4=96=E5=BC=BA=E5=88=B6?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=B5=8C=E5=A5=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ceobe/operation/version/models/conv.rs | 33 ++++++------------- .../ceobe/operation/version/models/force.rs | 29 ---------------- .../src/ceobe/operation/version/models/mod.rs | 2 -- .../ceobe/operation/version/models/version.rs | 24 +++++++------- 4 files changed, 22 insertions(+), 66 deletions(-) delete mode 100644 persistence/models/mongo-models/src/ceobe/operation/version/models/force.rs diff --git a/persistence/models/mongo-models/src/ceobe/operation/version/models/conv.rs b/persistence/models/mongo-models/src/ceobe/operation/version/models/conv.rs index 08b245f0..445bf1de 100644 --- a/persistence/models/mongo-models/src/ceobe/operation/version/models/conv.rs +++ b/persistence/models/mongo-models/src/ceobe/operation/version/models/conv.rs @@ -5,7 +5,7 @@ use tracing_unwrap::ResultExt; use crate::ceobe::operation::{ plugin_version::{self, DownloadResource, SpareLink}, version::models::{ - DownloadSourceItem, ForceCtrl, Primary, + DownloadSourceItem, Primary, ReleasePlatform::{Desktop, Plugin, Pocket}, ReleaseVersion, ResourceUrl, SupportPlatform::{Android, MacOS, Windows}, @@ -40,16 +40,13 @@ impl From for ReleaseVersion { .version(Version::new(major as _, minor as _, security as _)) .description(description) .platform(Plugin) - .force( - ForceCtrl::builder() - .force_update() - .previous_force_version(Version::new( + .previous_mandatory_version(Version::new( major as _, minor as _, security as _, )) - .build(), - ) + + .add_download_source( DownloadSourceItem::builder() .name("CRX") @@ -117,26 +114,21 @@ impl From for ReleaseVersion { fn from( app_version::Checked { version, - force, last_force_version, description, apk, spare_apk, baidu, - baidu_text, + baidu_text,.. }: app_version::Checked, ) -> Self { ReleaseVersion::builder() // 经过校验的version,没有问题 .version(version.parse().unwrap_or_log()) - .force( - ForceCtrl::builder() - .set_force_update(force) - .previous_force_version( + .previous_mandatory_version( last_force_version.parse().unwrap_or_log(), ) - .build(), - ) + .platform(Pocket) .description(description) .add_download_source( @@ -176,7 +168,6 @@ impl From for ReleaseVersion { fn from( desktop_version::Checked { version, - force, last_force_version, description, exe, @@ -184,20 +175,16 @@ impl From for ReleaseVersion { dmg, spare_dmg, baidu, - baidu_text, + baidu_text,.. }: desktop_version::Checked, ) -> Self { ReleaseVersion::builder() // 经过校验的version,没有问题 .version(version.parse().unwrap_or_log()) - .force( - ForceCtrl::builder() - .set_force_update(force) - .previous_force_version( + .previous_mandatory_version( last_force_version.parse().unwrap_or_log(), ) - .build(), - ) + .platform(Desktop) .description(description) .add_download_source( diff --git a/persistence/models/mongo-models/src/ceobe/operation/version/models/force.rs b/persistence/models/mongo-models/src/ceobe/operation/version/models/force.rs deleted file mode 100644 index 56a7193b..00000000 --- a/persistence/models/mongo-models/src/ceobe/operation/version/models/force.rs +++ /dev/null @@ -1,29 +0,0 @@ -use semver::Version; -use serde::{Deserialize, Serialize}; -use typed_builder::TypedBuilder; - -#[derive(Debug, Serialize, Deserialize, Clone, TypedBuilder, PartialEq)] -#[builder(mutators( - pub fn force_update(&mut self){ - self.force_update = true - } - pub fn set_force_update(&mut self,force:bool){ - self.force_update = force - } -))] -pub struct ForceCtrl { - #[builder(via_mutators)] - force_update: bool, - previous_force_version: Version, -} - -#[cfg(test)] -mod test { - use semver::Version; - #[test] - fn test_version_serde() { - let ver = Version::new(1, 1, 1); - let s = serde_json::to_string(&ver).unwrap(); - assert_eq!(s, "\"1.1.1\"") - } -} diff --git a/persistence/models/mongo-models/src/ceobe/operation/version/models/mod.rs b/persistence/models/mongo-models/src/ceobe/operation/version/models/mod.rs index 9fc19a51..ac02dd9e 100644 --- a/persistence/models/mongo-models/src/ceobe/operation/version/models/mod.rs +++ b/persistence/models/mongo-models/src/ceobe/operation/version/models/mod.rs @@ -1,12 +1,10 @@ mod conv; mod download_source; -mod force; mod platform; mod primary; mod version; pub use download_source::{DownloadSourceItem, ResourceUrl}; -pub use force::ForceCtrl; pub use platform::{ReleasePlatform, SupportPlatform}; pub use primary::Primary; pub use semver::Version; diff --git a/persistence/models/mongo-models/src/ceobe/operation/version/models/version.rs b/persistence/models/mongo-models/src/ceobe/operation/version/models/version.rs index 7bdb4005..4120f060 100644 --- a/persistence/models/mongo-models/src/ceobe/operation/version/models/version.rs +++ b/persistence/models/mongo-models/src/ceobe/operation/version/models/version.rs @@ -3,7 +3,7 @@ use serde::{Deserialize, Serialize}; use typed_builder::TypedBuilder; use crate::ceobe::operation::version::models::{ - download_source::DownloadSourceItem, force::ForceCtrl, + download_source::DownloadSourceItem, platform::ReleasePlatform, }; @@ -23,7 +23,7 @@ pub struct ReleaseVersion { /// 当前要发布的版本号 pub version: Version, /// 发布的版本更新控制 - force: ForceCtrl, + previous_mandatory_version: Version, /// 发布的版本的说明 #[builder(default, setter(into, strip_option))] #[serde(skip_serializing_if = "Option::is_none")] @@ -44,17 +44,20 @@ mod test { use crate::ceobe::operation::version::models::{ platform::SupportPlatform, primary::Primary, DownloadSourceItem, - ForceCtrl, ReleasePlatform, ReleaseVersion, ResourceUrl, + ReleasePlatform, ReleaseVersion, ResourceUrl, }; - + #[test] + fn test_sem_version_serde() { + let ver = Version::new(1, 1, 1); + let s = serde_json::to_string(&ver).unwrap(); + assert_eq!(s, "\"1.1.1\"") + } #[test] fn test_version_serde() { let ver = ReleaseVersion::builder() .version(Version::new(1, 13, 2)) - .force( - ForceCtrl::builder() - .previous_force_version(Version::new(1, 0, 0)) - .build(), + .previous_mandatory_version( + Version::new(1, 0, 0) ) .description("Abc") .platform(ReleasePlatform::Desktop) @@ -96,10 +99,7 @@ mod test { serde, json!({ "version": "1.13.2", - "force": { - "force_update": false, - "previous_force_version": "1.0.0" - }, + "previous_mandatory_version": "1.0.0", "description": "Abc", "platform": "desktop", "download_source": [ From 87ee1b292efcc20722be01e0674dae28244215b2 Mon Sep 17 00:00:00 2001 From: FrozenString <964413011@qq.com> Date: Sun, 1 Dec 2024 20:05:02 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=F0=9F=8E=A8=20cargo=20fmt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ceobe/operation/version/models/conv.rs | 26 +++++++++---------- .../ceobe/operation/version/models/version.rs | 11 +++----- 2 files changed, 16 insertions(+), 21 deletions(-) diff --git a/persistence/models/mongo-models/src/ceobe/operation/version/models/conv.rs b/persistence/models/mongo-models/src/ceobe/operation/version/models/conv.rs index 445bf1de..1cd6255f 100644 --- a/persistence/models/mongo-models/src/ceobe/operation/version/models/conv.rs +++ b/persistence/models/mongo-models/src/ceobe/operation/version/models/conv.rs @@ -41,12 +41,10 @@ impl From for ReleaseVersion { .description(description) .platform(Plugin) .previous_mandatory_version(Version::new( - major as _, - minor as _, - security as _, - )) - - + major as _, + minor as _, + security as _, + )) .add_download_source( DownloadSourceItem::builder() .name("CRX") @@ -119,16 +117,16 @@ impl From for ReleaseVersion { apk, spare_apk, baidu, - baidu_text,.. + baidu_text, + .. }: app_version::Checked, ) -> Self { ReleaseVersion::builder() // 经过校验的version,没有问题 .version(version.parse().unwrap_or_log()) .previous_mandatory_version( - last_force_version.parse().unwrap_or_log(), - ) - + last_force_version.parse().unwrap_or_log(), + ) .platform(Pocket) .description(description) .add_download_source( @@ -175,16 +173,16 @@ impl From for ReleaseVersion { dmg, spare_dmg, baidu, - baidu_text,.. + baidu_text, + .. }: desktop_version::Checked, ) -> Self { ReleaseVersion::builder() // 经过校验的version,没有问题 .version(version.parse().unwrap_or_log()) .previous_mandatory_version( - last_force_version.parse().unwrap_or_log(), - ) - + last_force_version.parse().unwrap_or_log(), + ) .platform(Desktop) .description(description) .add_download_source( diff --git a/persistence/models/mongo-models/src/ceobe/operation/version/models/version.rs b/persistence/models/mongo-models/src/ceobe/operation/version/models/version.rs index 4120f060..667d976c 100644 --- a/persistence/models/mongo-models/src/ceobe/operation/version/models/version.rs +++ b/persistence/models/mongo-models/src/ceobe/operation/version/models/version.rs @@ -3,8 +3,7 @@ use serde::{Deserialize, Serialize}; use typed_builder::TypedBuilder; use crate::ceobe::operation::version::models::{ - download_source::DownloadSourceItem, - platform::ReleasePlatform, + download_source::DownloadSourceItem, platform::ReleasePlatform, }; #[derive(Debug, Serialize, Deserialize, Clone, TypedBuilder, PartialEq)] @@ -56,9 +55,7 @@ mod test { fn test_version_serde() { let ver = ReleaseVersion::builder() .version(Version::new(1, 13, 2)) - .previous_mandatory_version( - Version::new(1, 0, 0) - ) + .previous_mandatory_version(Version::new(1, 0, 0)) .description("Abc") .platform(ReleasePlatform::Desktop) .add_download_source( @@ -88,9 +85,9 @@ mod test { .name("百度云备用") .build(), ) - .build(), - ).deleted(false) + ) + .deleted(false) .build(); let serde =