feat: implement update handlers for upstream and upstream target management
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
use chrono::{DateTime, Utc};
|
||||
use optfield::optfield;
|
||||
|
||||
use sea_orm::ActiveValue::{Set, Unchanged};
|
||||
use uuid::Uuid;
|
||||
@@ -11,7 +10,6 @@ use crate::{
|
||||
set_if_some,
|
||||
};
|
||||
|
||||
#[optfield(pub UpdateUpstreamTargetInfo)]
|
||||
#[derive(Clone)]
|
||||
pub struct UpstreamTargetInfo {
|
||||
pub id: uuid::Uuid,
|
||||
@@ -27,6 +25,15 @@ pub struct UpstreamTargetInfo {
|
||||
pub upstream: Option<UpstreamBasicInfo>,
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct UpdateUpstreamTargetInfo {
|
||||
pub target_host: Option<String>,
|
||||
pub target_port: Option<i64>,
|
||||
pub weight: Option<i64>,
|
||||
pub is_backup: Option<bool>,
|
||||
pub enabled: Option<bool>,
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct UpstreamBasicInfo {
|
||||
pub id: uuid::Uuid,
|
||||
@@ -146,9 +153,9 @@ impl UpdateUpstreamTargetInfo {
|
||||
weight: set_if_some!(self.weight),
|
||||
is_backup: set_if_some!(self.is_backup),
|
||||
enabled: set_if_some!(self.enabled),
|
||||
created_at: set_if_some!(self.created_at),
|
||||
updated_at: set_if_some!(self.updated_at),
|
||||
upstream_id: set_if_some!(self.upstream_id),
|
||||
created_at: Unchanged(current_model.created_at),
|
||||
updated_at: Set(chrono::Utc::now()),
|
||||
upstream_id: Unchanged(current_model.upstream_id),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user