feat: update UpstreamCreateInfo conversion to include upstream targets
This commit is contained in:
@@ -55,10 +55,11 @@ impl NginxConfigProvider for UpstreamInfo {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<UpstreamCreateInfo> for upstream::ActiveModel {
|
||||
fn from(val: UpstreamCreateInfo) -> Self {
|
||||
upstream::ActiveModel {
|
||||
id: sea_orm::ActiveValue::Set(Uuid::new_v4()),
|
||||
impl From<UpstreamCreateInfo> for (upstream::ActiveModel, Vec<upstream_target::ActiveModel>) {
|
||||
fn from(val: UpstreamCreateInfo) -> (upstream::ActiveModel, Vec<upstream_target::ActiveModel>) {
|
||||
let upstream_uuid = Uuid::new_v4();
|
||||
let upstream = upstream::ActiveModel {
|
||||
id: sea_orm::ActiveValue::Set(upstream_uuid),
|
||||
name: sea_orm::ActiveValue::Set(val.name),
|
||||
protocol: sea_orm::ActiveValue::Set(val.protocol),
|
||||
algorithm: sea_orm::ActiveValue::Set(val.algorithm),
|
||||
@@ -66,7 +67,17 @@ impl From<UpstreamCreateInfo> for upstream::ActiveModel {
|
||||
created_by: sea_orm::ActiveValue::Set(val.created_by),
|
||||
created_at: sea_orm::ActiveValue::Set(chrono::Utc::now()),
|
||||
updated_at: sea_orm::ActiveValue::Set(chrono::Utc::now()),
|
||||
}
|
||||
};
|
||||
let upstream_targets = val
|
||||
.upstream_targets
|
||||
.into_iter()
|
||||
.map(|target| {
|
||||
let mut active_model: upstream_target::ActiveModel = target.into();
|
||||
active_model.upstream_id = sea_orm::ActiveValue::Set(upstream_uuid);
|
||||
active_model
|
||||
})
|
||||
.collect();
|
||||
(upstream, upstream_targets)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user