初始化游戏运营后台

This commit is contained in:
qq143838
2026-08-28 05:24:30 +08:00
commit aafc6bcf03
124 changed files with 27876 additions and 0 deletions
+91
View File
@@ -0,0 +1,91 @@
import { z } from 'zod';
export const GameAnnouncementStatusSchema = z.enum([
'draft',
'scheduled',
'active',
'ended',
'offline',
]);
export const GameAnnouncementChannelSchema = z.enum(['login', 'banner', 'marquee']);
export const GameAnnouncementScopeSchema = z.enum(['all', 'servers']);
export const GameAnnouncementSchema = z
.object({
id: z.string().min(1),
title: z.string().min(1),
content: z.string().min(1),
channel: GameAnnouncementChannelSchema,
status: GameAnnouncementStatusSchema,
scope: GameAnnouncementScopeSchema,
serverIds: z.array(z.string().min(1)),
serverNames: z.array(z.string().min(1)),
priority: z.number().int().min(1).max(100),
startAt: z.string().nullable(),
endAt: z.string().nullable(),
createdAt: z.string().min(1),
updatedAt: z.string().min(1),
createdBy: z.string().min(1),
publishedAt: z.string().nullable(),
viewCount: z.number().int().nonnegative(),
clickCount: z.number().int().nonnegative(),
})
.strict();
export const GameAnnouncementSummarySchema = z
.object({
total: z.number().int().nonnegative(),
active: z.number().int().nonnegative(),
scheduled: z.number().int().nonnegative(),
draft: z.number().int().nonnegative(),
inactive: z.number().int().nonnegative(),
})
.strict();
export const GameAnnouncementOptionSchema = z
.object({
value: z.string().min(1),
label: z.string().min(1),
})
.strict();
export const GameAnnouncementListSchema = z
.object({
items: z.array(GameAnnouncementSchema),
total: z.number().int().nonnegative(),
page: z.number().int().positive(),
pageSize: z.number().int().positive(),
summary: GameAnnouncementSummarySchema,
serverOptions: z.array(GameAnnouncementOptionSchema),
})
.strict();
export const GameAnnouncementUpsertInputSchema = z
.object({
title: z.string().trim().min(1).max(80),
content: z.string().trim().min(1).max(5000),
channel: GameAnnouncementChannelSchema,
serverIds: z.array(z.string().min(1)).max(100),
priority: z.number().int().min(1).max(100),
startAt: z.string().nullable(),
endAt: z.string().nullable(),
mode: z.enum(['draft', 'publish']),
})
.strict()
.refine(
(value) => !value.startAt || !value.endAt || value.startAt < value.endAt,
'Announcement end time must be later than the start time',
);
export const GameAnnouncementStatusInputSchema = z
.object({ action: z.enum(['publish', 'offline']) })
.strict();
export type GameAnnouncementStatus = z.infer<typeof GameAnnouncementStatusSchema>;
export type GameAnnouncementChannel = z.infer<typeof GameAnnouncementChannelSchema>;
export type GameAnnouncementScope = z.infer<typeof GameAnnouncementScopeSchema>;
export type GameAnnouncement = z.infer<typeof GameAnnouncementSchema>;
export type GameAnnouncementSummary = z.infer<typeof GameAnnouncementSummarySchema>;
export type GameAnnouncementList = z.infer<typeof GameAnnouncementListSchema>;
export type GameAnnouncementUpsertInput = z.infer<typeof GameAnnouncementUpsertInputSchema>;
export type GameAnnouncementStatusInput = z.infer<typeof GameAnnouncementStatusInputSchema>;