添加发布电子地图数据查询接口
All checks were successful
build / build-rust (push) Successful in 2m10s

This commit is contained in:
soul-walker 2024-11-13 17:47:37 +08:00
parent 7a64171b96
commit e502f5b6a5
6 changed files with 42 additions and 58 deletions

View File

@ -43,7 +43,6 @@ fn main() {
) )
.compile_protos( .compile_protos(
&[ &[
"../../rtsa-proto-msg/src/em_data.proto",
"../../rtsa-proto-msg/src/common.proto", "../../rtsa-proto-msg/src/common.proto",
"../../rtsa-proto-msg/src/iscs_graphic_data.proto", "../../rtsa-proto-msg/src/iscs_graphic_data.proto",
"../../rtsa-proto-msg/src/simulation.proto", "../../rtsa-proto-msg/src/simulation.proto",

View File

@ -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<super::common::Canvas>,
#[prost(message, repeated, tag = "2")]
pub stations: ::prost::alloc::vec::Vec<Station>,
}
/// 公里标
#[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<super::common::CommonInfo>,
/// 车站名
#[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<KilometerMark>,
/// 是否集中站
#[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<u32>,
}

View File

@ -1,3 +1,2 @@
pub mod common; pub mod common;
pub mod em_data;
pub mod simulation; pub mod simulation;

View File

@ -7,12 +7,6 @@ pub trait DataOptions: InputType + OutputType + Serialize + DeserializeOwned {
fn to_data_options_filter_clause(&self) -> String; 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<T> DataOptions for T impl<T> DataOptions for T
where where
T: ?Sized + Serialize + DeserializeOwned + OutputType + InputType, T: ?Sized + Serialize + DeserializeOwned + OutputType + InputType,

View File

@ -74,6 +74,10 @@ impl From<PageQueryDto> for rtsa_db::common::PageQuery {
name = "ReleaseDataVersionPageDto", name = "ReleaseDataVersionPageDto",
params(release_data::ReleaseDataVersionDto) params(release_data::ReleaseDataVersionDto)
))] ))]
#[graphql(concrete(
name = "ReleaseEmDataPageDto",
params(release_data::ReleaseEmDataWithoutVersionDto)
))]
#[graphql(concrete( #[graphql(concrete(
name = "ReleaseIscsDataPageDto", name = "ReleaseIscsDataPageDto",
params(release_data::ReleaseIscsDataWithoutVersionDto) params(release_data::ReleaseIscsDataWithoutVersionDto)

View File

@ -14,7 +14,7 @@ use serde_json::Value;
use crate::apis::draft_data::DraftDataDto; use crate::apis::draft_data::DraftDataDto;
use crate::loader::RtsaDbLoader; 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::user::UserId;
use super::{PageDto, PageQueryDto}; use super::{PageDto, PageQueryDto};
@ -43,6 +43,22 @@ impl ReleaseDataQuery {
Ok(paging.into()) Ok(paging.into())
} }
/// 分页查询发布的电子地图数据
#[graphql(guard = "RoleGuard::new(Role::User)")]
async fn release_em_data_paging(
&self,
ctx: &Context<'_>,
page: PageQueryDto,
mut query: ReleaseTypedDataFilterDto<LineInfoOptions>,
) -> async_graphql::Result<PageDto<ReleaseEmDataWithoutVersionDto>> {
let db_accessor = ctx.data::<RtsaDbAccessor>()?;
query.data_type = Some(DataType::Em);
let paging = db_accessor
.paging_query_release_data_list(query.into(), page.into())
.await?;
Ok(paging.into())
}
/// 分页查询发布的ISCS数据 /// 分页查询发布的ISCS数据
#[graphql(guard = "RoleGuard::new(Role::User)")] #[graphql(guard = "RoleGuard::new(Role::User)")]
async fn release_iscs_data_paging( async fn release_iscs_data_paging(
@ -212,6 +228,7 @@ impl ReleaseDataMutation {
#[derive(Debug, InputObject)] #[derive(Debug, InputObject)]
#[graphql(concrete(name = "ReleaseDataFilterDto", params(Value)))] #[graphql(concrete(name = "ReleaseDataFilterDto", params(Value)))]
#[graphql(concrete(name = "ReleaseEmDataFilterDto", params(LineInfoOptions)))]
#[graphql(concrete(name = "ReleaseIscsDataFilterDto", params(IscsDataOptions)))] #[graphql(concrete(name = "ReleaseIscsDataFilterDto", params(IscsDataOptions)))]
pub struct ReleaseTypedDataFilterDto<T: DataOptions> { pub struct ReleaseTypedDataFilterDto<T: DataOptions> {
#[graphql(skip)] #[graphql(skip)]
@ -335,6 +352,26 @@ impl Loader<ReleaseDataVersionId> for RtsaDbLoader {
} }
} }
/// 发布的电子地图数据
#[derive(Debug, SimpleObject)]
pub struct ReleaseEmDataWithoutVersionDto {
pub release_data: ReleaseDataDto,
pub options: Option<LineInfoOptions>,
}
impl From<ReleaseDataModel> 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)] #[derive(Debug, SimpleObject)]
pub struct ReleaseIscsDataWithoutVersionDto { pub struct ReleaseIscsDataWithoutVersionDto {
pub release_data: ReleaseDataDto, pub release_data: ReleaseDataDto,