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..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 @@ -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,11 @@ 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( - major as _, - minor as _, - security as _, - )) - .build(), - ) + .previous_mandatory_version(Version::new( + major as _, + minor as _, + security as _, + )) .add_download_source( DownloadSourceItem::builder() .name("CRX") @@ -117,25 +112,20 @@ impl From for ReleaseVersion { fn from( app_version::Checked { version, - force, last_force_version, description, apk, spare_apk, baidu, 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( - last_force_version.parse().unwrap_or_log(), - ) - .build(), + .previous_mandatory_version( + last_force_version.parse().unwrap_or_log(), ) .platform(Pocket) .description(description) @@ -176,7 +166,6 @@ impl From for ReleaseVersion { fn from( desktop_version::Checked { version, - force, last_force_version, description, exe, @@ -185,18 +174,14 @@ impl From for ReleaseVersion { spare_dmg, baidu, 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( - last_force_version.parse().unwrap_or_log(), - ) - .build(), + .previous_mandatory_version( + last_force_version.parse().unwrap_or_log(), ) .platform(Desktop) .description(description) 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 3430fe88..fd09919b 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, force::ForceCtrl, - platform::ReleasePlatform, + download_source::DownloadSourceItem, platform::ReleasePlatform, }; #[derive(Debug, Serialize, Deserialize, Clone, TypedBuilder, PartialEq)] @@ -23,7 +22,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")] @@ -45,18 +44,19 @@ 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) .add_download_source( @@ -88,6 +88,7 @@ mod test { ) .build(), ) + .deleted(false) .build(); let serde = @@ -96,10 +97,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": [ @@ -119,7 +117,8 @@ mod test { } ] } - ] + ], + "deleted":false, }) );