Add new field
This commit is contained in:
parent
0262889913
commit
eacf3b0700
@ -61,6 +61,7 @@ CREATE TABLE members (
|
||||
birth_year smallint NULL,
|
||||
birth_month smallint NULL,
|
||||
birth_day smallint NULL,
|
||||
dead BOOLEAN NOT NULL DEFAULT FALSE,
|
||||
death_year smallint NULL,
|
||||
death_month smallint NULL,
|
||||
death_day smallint NULL,
|
||||
|
@ -45,6 +45,8 @@ pub struct MemberRequest {
|
||||
father: Option<MemberID>,
|
||||
#[serde(flatten, with = "prefix_birth")]
|
||||
birth: Option<RequestDate>,
|
||||
#[serde(default)]
|
||||
dead: bool,
|
||||
#[serde(flatten, with = "prefix_death")]
|
||||
death: Option<RequestDate>,
|
||||
note: Option<String>,
|
||||
@ -221,6 +223,7 @@ impl MemberRequest {
|
||||
member.birth_month = self.birth.as_ref().map(|m| m.month).unwrap_or_default();
|
||||
member.birth_day = self.birth.as_ref().map(|m| m.day).unwrap_or_default();
|
||||
|
||||
member.dead = self.dead;
|
||||
member.death_year = self.death.as_ref().map(|m| m.year).unwrap_or_default();
|
||||
member.death_month = self.death.as_ref().map(|m| m.month).unwrap_or_default();
|
||||
member.death_day = self.death.as_ref().map(|m| m.day).unwrap_or_default();
|
||||
|
@ -242,6 +242,7 @@ pub struct Member {
|
||||
pub birth_year: Option<i16>,
|
||||
pub birth_month: Option<i16>,
|
||||
pub birth_day: Option<i16>,
|
||||
pub dead: bool,
|
||||
pub death_year: Option<i16>,
|
||||
pub death_month: Option<i16>,
|
||||
pub death_day: Option<i16>,
|
||||
|
@ -50,6 +50,7 @@ diesel::table! {
|
||||
birth_year -> Nullable<Int2>,
|
||||
birth_month -> Nullable<Int2>,
|
||||
birth_day -> Nullable<Int2>,
|
||||
dead -> Bool,
|
||||
death_year -> Nullable<Int2>,
|
||||
death_month -> Nullable<Int2>,
|
||||
death_day -> Nullable<Int2>,
|
||||
|
@ -75,6 +75,7 @@ pub async fn update(member: &mut Member) -> anyhow::Result<()> {
|
||||
members::dsl::birth_year.eq(member.birth_year),
|
||||
members::dsl::birth_month.eq(member.birth_month),
|
||||
members::dsl::birth_day.eq(member.birth_day),
|
||||
members::dsl::dead.eq(member.dead),
|
||||
members::dsl::death_year.eq(member.death_year),
|
||||
members::dsl::death_month.eq(member.death_month),
|
||||
members::dsl::death_day.eq(member.death_day),
|
||||
|
Loading…
Reference in New Issue
Block a user