forked from kingwrcy/discussion
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtypes.ts
151 lines (142 loc) · 3.36 KB
/
types.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
import type { PointReason, UserRole, UserStatus } from "@prisma/client";
import { z } from "zod";
export const regRequestSchema = z
.object({
username: z.string().min(4, "用户名最少4个字符"),
password: z.string().min(6, "密码最少6个字符"),
repeatPassword: z.string().min(6, "密码最少6个字符"),
email: z.string().email("请填写正确的邮箱地址"),
})
.refine((data) => data.password === data.repeatPassword, {
message: "两次密码不一致",
path: ["repeatPassword"],
});
export const saveSettingsRequestSchema = z.object({
password: z.string().optional(),
email: z.string().email("请填写正确邮箱地址"),
css: z.string().optional().nullish(),
js: z.string().optional().nullish(),
signature: z.string().max(300,"最大不超过300个字符").optional().nullish(),
});
export const loginRequestSchema = z.object({
username: z.string().min(4, "用户名最少4个字符"),
password: z.string().min(6, "密码最少6个字符"),
});
export const createPostSchema = z.object({
title: z
.string()
.min(4, "标题不少于6个字符")
.max(120, "标题不能超过120个字符"),
content: z.string().min(6, "内容最少6个字符"),
tagId: z.number({ message: "标签是必选的" }),
pid: z.string().optional(),
});
export type JwtPayload = {
uid: string;
userId: number;
username: string;
};
export type UserDTO = {
createdAt: string;
uid: string;
username: string;
email: string;
avatarUrl: string | null;
point: number;
postCount: number;
commentCount: number;
role: UserRole;
status: UserStatus;
lastLogin: string;
level: number;
bannedEnd: string;
unRead: number;
css?: string;
js?: string;
signature?: string;
lastActive?: string;
_count: {
fav: number;
comments: number;
posts: number;
ReceiveMessage: number;
};
};
export type TagDTO = {
id: number;
name: string;
desc: string;
enName: string;
count: number;
};
export type CommentDTO = {
content: string;
cid: string;
createdAt: string;
mentioned: Array<string>;
author: UserDTO;
likeCount?: number;
dislikeCount?: number;
like?: boolean;
dislike?: boolean;
post?: PostDTO;
floor: number;
};
export type PointHistoryDTO = {
createdAt: string;
pid: string;
cid: string;
post: PostDTO;
comment: CommentDTO;
reason: PointReason;
};
export type PostDTO = {
title: string;
content: string;
pid: string;
uid: string;
createdAt: string;
viewCount: number;
replyCount: number;
likeCount: number;
disLikeCount: number;
minLevel: number;
author: UserDTO;
comments?: Array<CommentDTO>;
tagId: number;
tag: TagDTO;
support?: boolean;
_count: {
comments: number;
commentLike: number;
commentDisLike: number;
PostSupport: number;
};
fav?: boolean;
pinned: boolean;
lastCommentTime?: string;
lastCommentUid?: string;
lastCommentUser?: UserDTO;
point: number;
};
export type SysConfigDTO = {
websiteName: string;
pointPerPost: number;
pointPerPostByDay: number;
pointPerComment: number;
pointPerCommentByDay: number;
pointPerLikeOrDislike: number;
pointPerDaySignInMin: number;
pointPerDaySignInMax: number;
websiteAnnouncement: string;
css: string;
js: string;
};
export type MessageDTO = {
id: number;
from: UserDTO;
to: UserDTO;
content: string;
read: Boolean;
createdAt: string;
};