webcomment/src/queries.rs

94 lines
1.8 KiB
Rust

use serde::Deserialize;
#[derive(Clone, Debug, Deserialize)]
pub struct AdminLoginQuery {
pub psw: String,
}
#[derive(Clone, Debug, Deserialize)]
pub struct AdminEditCommentQuery {
pub author: String,
pub id: String,
pub email: String,
pub text: String,
}
#[derive(Clone, Debug, Deserialize)]
pub struct AdminRmCommentQuery {
pub id: String,
}
#[derive(Clone, Debug, Deserialize)]
pub struct NewCommentQuery {
#[serde(flatten)]
pub comment: CommentForm,
}
#[derive(Clone, Debug, Deserialize)]
pub struct EditCommentQuery {
#[serde(flatten)]
pub comment: CommentForm,
pub id: String,
//pub token: String,
}
/*#[derive(Clone, Debug, Deserialize)]
pub struct RmCommentQuery {
pub id: String,
//pub token: String,
}*/
#[derive(Clone, Debug, Deserialize)]
#[serde(tag = "a")]
pub enum CommentQuery {
#[serde(rename = "new_comment")]
NewComment(NewCommentQuery),
#[serde(rename = "edit_comment")]
EditComment(EditCommentQuery),
/*#[serde(rename = "rm_comment")]
RmComment(RmCommentQuery),*/
}
#[derive(Clone, Debug, Deserialize)]
#[serde(tag = "a")]
pub enum AdminQuery {
#[serde(rename = "login")]
Login(AdminLoginQuery),
#[serde(rename = "edit_comment")]
EditComment(AdminEditCommentQuery),
#[serde(rename = "rm_comment")]
RmComment(AdminRmCommentQuery),
}
#[derive(Clone, Debug, Deserialize)]
pub struct ApproveQuery {
pub approve: String,
}
#[derive(Clone, Debug, Deserialize)]
pub struct ApproveEditQuery {
pub approve_edit: String,
}
#[derive(Clone, Debug, Deserialize)]
pub struct RemoveQuery {
pub remove: String,
}
#[derive(Clone, Debug, Deserialize)]
pub struct RemoveEditQuery {
pub remove_edit: String,
}
#[derive(Clone, Debug, Deserialize)]
pub struct EditQuery {
pub edit: String,
}
#[derive(Clone, Debug, Deserialize)]
pub struct CommentForm {
pub author: String,
pub email: String,
pub text: String,
}