2020-11-02 18:06:50 +00:00
|
|
|
use crate::schema::*;
|
|
|
|
use chrono::NaiveDateTime;
|
|
|
|
use serde::Serialize;
|
|
|
|
|
|
|
|
#[derive(Queryable, Debug, Serialize)]
|
2020-09-13 16:07:06 +00:00
|
|
|
pub struct Member {
|
|
|
|
pub id: i32,
|
2020-11-02 18:06:50 +00:00
|
|
|
#[serde(rename = "name")]
|
2020-09-13 16:07:06 +00:00
|
|
|
pub cmene: String,
|
|
|
|
pub picurl: String,
|
|
|
|
}
|
|
|
|
|
2020-11-02 18:06:50 +00:00
|
|
|
#[derive(Queryable, Associations)]
|
|
|
|
#[belongs_to(Member)]
|
|
|
|
#[table_name = "switches"]
|
2020-09-13 16:07:06 +00:00
|
|
|
pub struct Switch {
|
|
|
|
pub id: String,
|
2020-11-02 18:06:50 +00:00
|
|
|
pub member_id: i32,
|
|
|
|
pub started_at: NaiveDateTime,
|
|
|
|
pub ended_at: Option<NaiveDateTime>,
|
2020-11-02 19:03:32 +00:00
|
|
|
pub duration: Option<i32>,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Insertable)]
|
|
|
|
#[table_name = "switches"]
|
|
|
|
pub struct NewSwitch {
|
|
|
|
pub id: String,
|
|
|
|
pub member_id: i32,
|
|
|
|
pub started_at: NaiveDateTime,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(AsChangeset)]
|
|
|
|
#[table_name = "switches"]
|
|
|
|
pub struct UpdateSwitchTime {
|
|
|
|
pub ended_at: Option<NaiveDateTime>,
|
|
|
|
pub duration: Option<i32>,
|
2020-09-13 16:07:06 +00:00
|
|
|
}
|