From e502f5b6a537cb062da3ca3f4c577bbb87d8c0f2 Mon Sep 17 00:00:00 2001 From: soul-walker <31162815+soul-walker@users.noreply.github.com> Date: Wed, 13 Nov 2024 17:47:37 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=8F=91=E5=B8=83=E7=94=B5?= =?UTF-8?q?=E5=AD=90=E5=9C=B0=E5=9B=BE=E6=95=B0=E6=8D=AE=E6=9F=A5=E8=AF=A2?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- crates/rtsa_dto/build.rs | 1 - crates/rtsa_dto/src/pb/em_data.rs | 49 ---------------------------- crates/rtsa_dto/src/pb/mod.rs | 1 - manager/src/apis/data_options_def.rs | 6 ---- manager/src/apis/mod.rs | 4 +++ manager/src/apis/release_data.rs | 39 +++++++++++++++++++++- 6 files changed, 42 insertions(+), 58 deletions(-) delete mode 100644 crates/rtsa_dto/src/pb/em_data.rs diff --git a/crates/rtsa_dto/build.rs b/crates/rtsa_dto/build.rs index fc2d097..5f4d028 100644 --- a/crates/rtsa_dto/build.rs +++ b/crates/rtsa_dto/build.rs @@ -43,7 +43,6 @@ fn main() { ) .compile_protos( &[ - "../../rtsa-proto-msg/src/em_data.proto", "../../rtsa-proto-msg/src/common.proto", "../../rtsa-proto-msg/src/iscs_graphic_data.proto", "../../rtsa-proto-msg/src/simulation.proto", diff --git a/crates/rtsa_dto/src/pb/em_data.rs b/crates/rtsa_dto/src/pb/em_data.rs deleted file mode 100644 index 151b5aa..0000000 --- a/crates/rtsa_dto/src/pb/em_data.rs +++ /dev/null @@ -1,49 +0,0 @@ -// This file is @generated by prost-build. -/// 电子地图数据 -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct Em { - #[prost(message, optional, tag = "1")] - pub canvas: ::core::option::Option, - #[prost(message, repeated, tag = "2")] - pub stations: ::prost::alloc::vec::Vec, -} -/// 公里标 -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct KilometerMark { - /// 公里标坐标系 - #[prost(string, tag = "1")] - pub coordinate: ::prost::alloc::string::String, - /// 公里标数值 - #[prost(int64, tag = "2")] - pub value: i64, -} -/// 车站数据 -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct Station { - #[prost(message, optional, tag = "1")] - pub common: ::core::option::Option, - /// 车站名 - #[prost(string, tag = "2")] - pub name: ::prost::alloc::string::String, - /// 车站站名 - #[prost(string, tag = "3")] - pub zhan_name: ::prost::alloc::string::String, - /// 车站名拼音简写 - #[prost(string, tag = "4")] - pub name_pinyin: ::prost::alloc::string::String, - /// 公里标 - #[prost(message, optional, tag = "6")] - pub km: ::core::option::Option, - /// 是否集中站 - #[prost(bool, tag = "10")] - pub concentration: bool, - /// 是否车辆段 - #[prost(bool, tag = "11")] - pub depots: bool, - /// 集中站管理的车站-id - #[prost(uint32, repeated, tag = "13")] - pub manage_station_ids: ::prost::alloc::vec::Vec, -} diff --git a/crates/rtsa_dto/src/pb/mod.rs b/crates/rtsa_dto/src/pb/mod.rs index 00549bc..2d758fa 100644 --- a/crates/rtsa_dto/src/pb/mod.rs +++ b/crates/rtsa_dto/src/pb/mod.rs @@ -1,3 +1,2 @@ pub mod common; -pub mod em_data; pub mod simulation; diff --git a/manager/src/apis/data_options_def.rs b/manager/src/apis/data_options_def.rs index 494d916..c759546 100644 --- a/manager/src/apis/data_options_def.rs +++ b/manager/src/apis/data_options_def.rs @@ -7,12 +7,6 @@ pub trait DataOptions: InputType + OutputType + Serialize + DeserializeOwned { fn to_data_options_filter_clause(&self) -> String; } -// impl DataOptions for Value { -// fn to_data_options_filter_clause(&self) -> String { -// format!("{} @> '{}'", DraftDataColumn::Options.name(), self) -// } -// } - impl DataOptions for T where T: ?Sized + Serialize + DeserializeOwned + OutputType + InputType, diff --git a/manager/src/apis/mod.rs b/manager/src/apis/mod.rs index 8430449..b1dc60b 100644 --- a/manager/src/apis/mod.rs +++ b/manager/src/apis/mod.rs @@ -74,6 +74,10 @@ impl From for rtsa_db::common::PageQuery { name = "ReleaseDataVersionPageDto", params(release_data::ReleaseDataVersionDto) ))] +#[graphql(concrete( + name = "ReleaseEmDataPageDto", + params(release_data::ReleaseEmDataWithoutVersionDto) +))] #[graphql(concrete( name = "ReleaseIscsDataPageDto", params(release_data::ReleaseIscsDataWithoutVersionDto) diff --git a/manager/src/apis/release_data.rs b/manager/src/apis/release_data.rs index 1ba3e0e..fb3ee94 100644 --- a/manager/src/apis/release_data.rs +++ b/manager/src/apis/release_data.rs @@ -14,7 +14,7 @@ use serde_json::Value; use crate::apis::draft_data::DraftDataDto; use crate::loader::RtsaDbLoader; -use super::data_options_def::{DataOptions, IscsDataOptions}; +use super::data_options_def::{DataOptions, IscsDataOptions, LineInfoOptions}; use super::user::UserId; use super::{PageDto, PageQueryDto}; @@ -43,6 +43,22 @@ impl ReleaseDataQuery { Ok(paging.into()) } + /// 分页查询发布的电子地图数据 + #[graphql(guard = "RoleGuard::new(Role::User)")] + async fn release_em_data_paging( + &self, + ctx: &Context<'_>, + page: PageQueryDto, + mut query: ReleaseTypedDataFilterDto, + ) -> async_graphql::Result> { + let db_accessor = ctx.data::()?; + query.data_type = Some(DataType::Em); + let paging = db_accessor + .paging_query_release_data_list(query.into(), page.into()) + .await?; + Ok(paging.into()) + } + /// 分页查询发布的ISCS数据 #[graphql(guard = "RoleGuard::new(Role::User)")] async fn release_iscs_data_paging( @@ -212,6 +228,7 @@ impl ReleaseDataMutation { #[derive(Debug, InputObject)] #[graphql(concrete(name = "ReleaseDataFilterDto", params(Value)))] +#[graphql(concrete(name = "ReleaseEmDataFilterDto", params(LineInfoOptions)))] #[graphql(concrete(name = "ReleaseIscsDataFilterDto", params(IscsDataOptions)))] pub struct ReleaseTypedDataFilterDto { #[graphql(skip)] @@ -335,6 +352,26 @@ impl Loader for RtsaDbLoader { } } +/// 发布的电子地图数据 +#[derive(Debug, SimpleObject)] +pub struct ReleaseEmDataWithoutVersionDto { + pub release_data: ReleaseDataDto, + pub options: Option, +} + +impl From for ReleaseEmDataWithoutVersionDto { + fn from(model: ReleaseDataModel) -> Self { + Self { + options: model + .options + .clone() + .map(|o| serde_json::from_value(o).unwrap()), + release_data: model.into(), + } + } +} + +/// 发布的ISCS数据 #[derive(Debug, SimpleObject)] pub struct ReleaseIscsDataWithoutVersionDto { pub release_data: ReleaseDataDto,