fileserver/backend/src/dto.rs

206 lines
4.8 KiB
Rust
Raw Normal View History

2022-10-10 21:07:40 +00:00
#[allow(non_snake_case)]
pub mod responses {
use serde::{self, Deserialize, Serialize};
#[derive(Debug, Deserialize, Serialize, Clone)]
pub struct Error {
pub statusCode: i32,
pub message: String
}
#[derive(Debug, Deserialize, Serialize, Clone)]
pub struct Success {
pub statusCode: i32
}
#[derive(Debug, Deserialize, Serialize, Clone)]
pub struct Login {
pub statusCode: i32,
pub jwt: String
}
#[derive(Debug, Deserialize, Serialize, Clone)]
pub struct TfaSetup {
pub statusCode: i32,
pub secret: String,
pub qrCode: String
}
#[derive(Debug, Deserialize, Serialize, Clone)]
pub struct UserInfo {
pub statusCode: i32,
pub name: String,
pub gitlab: bool,
pub tfaEnabled: bool
}
#[derive(Debug, Deserialize, Serialize, Clone)]
pub struct AdminUsersEntry {
pub id: i32,
pub gitlab: bool,
pub name: String,
pub role: crate::db::UserRole,
pub tfaEnabled: bool
}
#[derive(Debug, Deserialize, Serialize, Clone)]
pub struct AdminUsers {
pub statusCode: i32,
pub users: Vec<AdminUsersEntry>
}
#[derive(Debug, Deserialize, Serialize, Clone)]
pub struct Root {
pub statusCode: i32,
pub rootId: i32
}
#[derive(Debug, Deserialize, Serialize, Clone)]
pub struct GetNodeEntry {
pub id: i32,
pub name: String,
pub isFile: bool,
pub preview: bool,
pub parent: Option<i32>,
pub size: Option<i64>
}
#[derive(Debug, Deserialize, Serialize, Clone)]
pub struct GetNode {
pub statusCode: i32,
pub id: i32,
pub name: String,
pub isFile: bool,
pub preview: bool,
pub parent: Option<i32>,
pub size: Option<i64>,
pub children: Option<Vec<GetNodeEntry>>
}
#[derive(Debug, Deserialize, Serialize, Clone)]
pub struct NewNode {
pub statusCode: i32,
pub id: i32
}
#[derive(Debug, Deserialize, Serialize, Clone)]
pub struct NodeExists {
pub statusCode: i32,
pub id: i32,
pub exists: bool,
pub isFile: bool
}
#[derive(Debug, Deserialize, Serialize, Clone)]
pub struct DownloadBase64 {
pub statusCode: i32,
pub data: String
}
#[derive(Debug, Deserialize, Serialize, Clone)]
pub struct Type {
pub statusCode: i32,
#[serde(rename = "type")]
pub _type: String
}
#[derive(Debug, Deserialize, Serialize, Clone)]
pub struct CreateZipDone {
pub statusCode: i32,
pub done: bool,
pub progress: Option<u64>,
pub total: Option<u64>
}
#[derive(Debug, Deserialize, Serialize, Clone)]
pub struct GetPathSegment {
pub path: String,
pub node: Option<i32>
}
#[derive(Debug, Deserialize, Serialize, Clone)]
pub struct GetPath {
pub segments: Vec<GetPathSegment>
}
}
#[allow(non_snake_case)]
pub mod requests {
use serde::{self, Deserialize, Serialize};
#[derive(Debug, Deserialize, Serialize, Clone)]
pub struct Admin {
pub user: i32
}
#[derive(Debug, Deserialize, Serialize, Clone)]
pub struct AdminSetRole {
pub user: i32,
pub role: crate::db::UserRole
}
#[derive(Debug, Deserialize, Serialize, Clone)]
pub struct SignUp {
pub username: String,
pub password: String
}
#[derive(Debug, Deserialize, Serialize, Clone)]
pub struct Login {
pub username: String,
pub password: String,
pub otp: Option<String>
}
2022-10-14 01:15:57 +00:00
#[derive(Debug, Deserialize, Serialize, Clone)]
pub struct SendRecoveryKey {
pub username: String
}
#[derive(Debug, Deserialize, Serialize, Clone)]
pub struct ResetPassword {
pub key: String,
pub password: String
}
2022-10-10 21:07:40 +00:00
#[derive(Debug, Deserialize, Serialize, Clone)]
pub struct TfaSetup {
pub mail: bool
}
#[derive(Debug, Deserialize, Serialize, Clone)]
pub struct TfaComplete {
pub mail: bool,
pub code: String
}
#[derive(Debug, Deserialize, Serialize, Clone)]
pub struct ChangePassword {
pub oldPassword: String,
pub newPassword: String
}
#[derive(Debug, Deserialize, Serialize, Clone)]
pub struct CreateNode {
pub parent: i32,
pub name: String
}
#[derive(Debug, Deserialize, Serialize, Clone)]
pub struct CreateZip {
pub nodes: Vec<i32>
}
#[derive(Debug, Deserialize, Serialize, Clone)]
pub struct Download {
pub jwtToken: String,
pub id: i32
}
#[derive(Debug, Deserialize, Serialize, Clone)]
pub struct DownloadMulti {
pub jwtToken: String,
pub id: String
}
}