2020-01-21 07:02:03 +01:00
|
|
|
use crate::{schema::apps, Error, Result};
|
2018-10-21 15:19:07 +02:00
|
|
|
use chrono::NaiveDateTime;
|
2018-11-24 12:44:17 +01:00
|
|
|
use diesel::{self, ExpressionMethods, QueryDsl, RunQueryDsl};
|
2018-10-21 15:19:07 +02:00
|
|
|
|
2019-04-28 23:17:21 +02:00
|
|
|
#[derive(Clone, Queryable, Serialize)]
|
2018-10-21 15:19:07 +02:00
|
|
|
pub struct App {
|
|
|
|
pub id: i32,
|
|
|
|
pub name: String,
|
|
|
|
pub client_id: String,
|
|
|
|
pub client_secret: String,
|
|
|
|
pub redirect_uri: Option<String>,
|
2018-10-22 15:30:04 +02:00
|
|
|
pub website: Option<String>,
|
2018-10-21 15:19:07 +02:00
|
|
|
pub creation_date: NaiveDateTime,
|
|
|
|
}
|
|
|
|
|
2018-10-21 18:22:27 +02:00
|
|
|
#[derive(Insertable)]
|
2018-11-24 12:44:17 +01:00
|
|
|
#[table_name = "apps"]
|
2018-10-21 18:22:27 +02:00
|
|
|
pub struct NewApp {
|
|
|
|
pub name: String,
|
|
|
|
pub client_id: String,
|
|
|
|
pub client_secret: String,
|
|
|
|
pub redirect_uri: Option<String>,
|
2018-10-22 15:30:04 +02:00
|
|
|
pub website: Option<String>,
|
2018-10-21 18:22:27 +02:00
|
|
|
}
|
|
|
|
|
2018-10-21 15:19:07 +02:00
|
|
|
impl App {
|
2018-10-21 18:22:27 +02:00
|
|
|
get!(apps);
|
2018-10-21 15:19:07 +02:00
|
|
|
insert!(apps, NewApp);
|
2018-11-26 10:21:52 +01:00
|
|
|
find_by!(apps, find_by_client_id, client_id as &str);
|
2018-10-22 15:30:04 +02:00
|
|
|
}
|