1use std::hash::Hash;
2
3use chrono::{DateTime, Utc};
4use serde::{Deserialize, Serialize};
5
6#[cfg(feature = "typescript")]
7use ts_rs::TS;
8
9use crate::{AuthorId, FileMetaId, PlatformId, PostId};
10
11#[cfg_attr(feature = "typescript", derive(TS))]
13#[cfg_attr(feature = "typescript", ts(export))]
14#[derive(Deserialize, Serialize, Debug, Clone, PartialEq, Eq, Hash)]
15pub struct Author {
16 pub id: AuthorId,
17 pub name: String,
18 pub thumb: Option<FileMetaId>,
19 pub updated: DateTime<Utc>,
20}
21
22#[cfg_attr(feature = "typescript", derive(TS))]
28#[cfg_attr(feature = "typescript", ts(export))]
29#[derive(Deserialize, Serialize, Debug, Clone, PartialEq, Eq, Hash)]
30pub struct Alias {
31 pub source: String,
42 pub platform: PlatformId,
44 pub target: AuthorId,
46 pub link: Option<String>,
48}
49
50#[cfg_attr(feature = "typescript", derive(TS))]
52#[cfg_attr(feature = "typescript", ts(export))]
53#[derive(Deserialize, Serialize, Debug, Clone, PartialEq, Eq, Hash)]
54pub struct AuthorPost {
55 pub author: AuthorId,
56 pub post: PostId,
57}
58
59#[cfg(feature = "utils")]
60mod definitions {
61 use crate::utils::macros::as_table;
62
63 use super::*;
64
65 as_table! {
66 "authors" => Author {
67 id: "id",
68 name: "name",
69 thumb: "thumb",
70 updated: "updated",
71 }
72
73 "author_posts" => AuthorPost {
74 author: "author",
75 post: "post",
76 }
77
78 "author_aliases" => Alias {
79 source: "source",
80 platform: "platform",
81 target: "target",
82 link: "link",
83 }
84 }
85}