2024-07-09 17:06:20 +00:00
|
|
|
use crate::model::schema;
|
2024-07-18 15:39:09 +00:00
|
|
|
use diesel::prelude::*;
|
2024-07-09 17:06:20 +00:00
|
|
|
|
2024-07-18 15:39:09 +00:00
|
|
|
#[derive(Queryable, Selectable, serde::Serialize, serde::Deserialize)]
|
2024-07-09 17:06:20 +00:00
|
|
|
#[diesel(table_name = schema::categories)]
|
|
|
|
|
#[diesel(check_for_backend(diesel::pg::Pg))]
|
|
|
|
|
pub struct Category {
|
|
|
|
|
id: i64,
|
|
|
|
|
uid: i64,
|
|
|
|
|
name: String,
|
2024-07-28 15:04:53 +00:00
|
|
|
level: i32,
|
|
|
|
|
parent_category_id: i64,
|
2024-07-09 17:06:20 +00:00
|
|
|
is_delete: bool,
|
|
|
|
|
create_at: chrono::NaiveDateTime,
|
|
|
|
|
update_at: chrono::NaiveDateTime,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(serde::Deserialize, Insertable)]
|
|
|
|
|
#[diesel(table_name = schema::categories)]
|
|
|
|
|
pub struct CategoryForm {
|
|
|
|
|
pub uid: i64,
|
|
|
|
|
pub name: String,
|
2024-07-28 15:04:53 +00:00
|
|
|
pub level: i32,
|
|
|
|
|
pub parent_category_id: i64,
|
2024-07-09 17:06:20 +00:00
|
|
|
}
|
2024-07-28 14:24:53 +00:00
|
|
|
|
|
|
|
|
#[derive(Queryable, Selectable, serde::Serialize, serde::Deserialize)]
|
|
|
|
|
#[diesel(table_name = schema::tags)]
|
|
|
|
|
#[diesel(check_for_backend(diesel::pg::Pg))]
|
|
|
|
|
pub struct Tag {
|
|
|
|
|
id: i64,
|
|
|
|
|
uid: i64,
|
|
|
|
|
name: String,
|
2024-07-28 15:04:53 +00:00
|
|
|
level: i32,
|
|
|
|
|
parent_tag_id: i64,
|
2024-07-28 14:24:53 +00:00
|
|
|
is_delete: bool,
|
|
|
|
|
create_at: chrono::NaiveDateTime,
|
|
|
|
|
update_at: chrono::NaiveDateTime,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(serde::Deserialize, Insertable)]
|
|
|
|
|
#[diesel(table_name = schema::tags)]
|
|
|
|
|
pub struct TagForm {
|
|
|
|
|
pub uid: i64,
|
|
|
|
|
pub name: String,
|
2024-07-28 15:04:53 +00:00
|
|
|
pub level: i32,
|
|
|
|
|
pub parent_tag_id: i64,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Queryable, Selectable, serde::Serialize, serde::Deserialize)]
|
|
|
|
|
#[diesel(table_name = schema::books)]
|
|
|
|
|
#[diesel(check_for_backend(diesel::pg::Pg))]
|
|
|
|
|
pub struct Book {
|
|
|
|
|
id: i64,
|
|
|
|
|
uid: i64,
|
|
|
|
|
name: String,
|
|
|
|
|
is_delete: bool,
|
|
|
|
|
create_at: chrono::NaiveDateTime,
|
|
|
|
|
update_at: chrono::NaiveDateTime,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(serde::Deserialize, Insertable)]
|
|
|
|
|
#[diesel(table_name = schema::books)]
|
|
|
|
|
pub struct BookForm {
|
|
|
|
|
pub uid: i64,
|
|
|
|
|
pub name: String,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#[derive(Queryable, Selectable, serde::Serialize, serde::Deserialize)]
|
|
|
|
|
#[diesel(table_name = schema::accounts)]
|
|
|
|
|
#[diesel(check_for_backend(diesel::pg::Pg))]
|
|
|
|
|
pub struct Account {
|
|
|
|
|
id: i64,
|
|
|
|
|
uid: i64,
|
|
|
|
|
name: String,
|
|
|
|
|
account_type: i64,
|
|
|
|
|
is_delete: bool,
|
|
|
|
|
create_at: chrono::NaiveDateTime,
|
|
|
|
|
update_at: chrono::NaiveDateTime,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(serde::Deserialize, Insertable)]
|
|
|
|
|
#[diesel(table_name = schema::accounts)]
|
|
|
|
|
pub struct AccountForm {
|
|
|
|
|
pub uid: i64,
|
|
|
|
|
pub name: String,
|
|
|
|
|
pub account_type: i64,
|
2024-07-28 14:24:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Queryable, Selectable, serde::Serialize)]
|
|
|
|
|
#[diesel(table_name = schema::users)]
|
|
|
|
|
pub struct User {
|
|
|
|
|
pub id: i64,
|
|
|
|
|
pub username: String,
|
|
|
|
|
pub password: String,
|
|
|
|
|
pub mail: String,
|
|
|
|
|
pub is_delete: bool,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Insertable)]
|
|
|
|
|
#[diesel(table_name = schema::users)]
|
|
|
|
|
pub struct UserForm {
|
|
|
|
|
pub username: String,
|
|
|
|
|
pub password: String,
|
|
|
|
|
pub mail: String,
|
|
|
|
|
}
|