初始化游戏运营后台
This commit is contained in:
@@ -0,0 +1,101 @@
|
||||
import { z } from 'zod';
|
||||
|
||||
export const GameCdkStatusSchema = z.enum(['unused', 'used', 'expired', 'disabled']);
|
||||
export const GameCdkScopeSchema = z.enum(['all', 'server']);
|
||||
|
||||
export const GameCdkRewardSchema = z
|
||||
.object({
|
||||
itemId: z.string().trim().min(1).max(64),
|
||||
itemName: z.string().trim().min(1).max(40),
|
||||
quantity: z.number().int().positive(),
|
||||
})
|
||||
.strict();
|
||||
|
||||
export const GameCdkSchema = z
|
||||
.object({
|
||||
id: z.string().min(1),
|
||||
code: z.string().min(1),
|
||||
batchId: z.string().min(1),
|
||||
batchName: z.string().min(1),
|
||||
status: GameCdkStatusSchema,
|
||||
rewardName: z.string().min(1),
|
||||
rewards: z.array(GameCdkRewardSchema).min(1),
|
||||
scope: GameCdkScopeSchema,
|
||||
serverId: z.string().nullable(),
|
||||
serverName: z.string().nullable(),
|
||||
createdAt: z.string().min(1),
|
||||
expiresAt: z.string().nullable(),
|
||||
usedByPlayerId: z.string().nullable(),
|
||||
usedByPlayerName: z.string().nullable(),
|
||||
usedAt: z.string().nullable(),
|
||||
createdBy: z.string().min(1),
|
||||
})
|
||||
.strict();
|
||||
|
||||
export const GameCdkSummarySchema = z
|
||||
.object({
|
||||
total: z.number().int().nonnegative(),
|
||||
unused: z.number().int().nonnegative(),
|
||||
used: z.number().int().nonnegative(),
|
||||
expired: z.number().int().nonnegative(),
|
||||
disabled: z.number().int().nonnegative(),
|
||||
})
|
||||
.strict();
|
||||
|
||||
export const GameCdkOptionSchema = z
|
||||
.object({
|
||||
value: z.string().min(1),
|
||||
label: z.string().min(1),
|
||||
})
|
||||
.strict();
|
||||
|
||||
export const GameCdkListSchema = z
|
||||
.object({
|
||||
items: z.array(GameCdkSchema),
|
||||
total: z.number().int().nonnegative(),
|
||||
page: z.number().int().positive(),
|
||||
pageSize: z.number().int().positive(),
|
||||
summary: GameCdkSummarySchema,
|
||||
batchOptions: z.array(GameCdkOptionSchema),
|
||||
serverOptions: z.array(GameCdkOptionSchema),
|
||||
})
|
||||
.strict();
|
||||
|
||||
export const GameCdkBatchCreateInputSchema = z
|
||||
.object({
|
||||
batchName: z.string().trim().min(1).max(40),
|
||||
prefix: z
|
||||
.string()
|
||||
.trim()
|
||||
.min(2)
|
||||
.max(12)
|
||||
.regex(/^[A-Za-z0-9]+$/),
|
||||
quantity: z.number().int().min(1).max(1000),
|
||||
rewardName: z.string().trim().min(1).max(40),
|
||||
rewards: z.array(GameCdkRewardSchema).min(1).max(10),
|
||||
serverId: z.string().nullable(),
|
||||
expiresAt: z.string().nullable(),
|
||||
})
|
||||
.strict();
|
||||
|
||||
export const GameCdkBatchCreateResultSchema = z
|
||||
.object({
|
||||
batchId: z.string().min(1),
|
||||
batchName: z.string().min(1),
|
||||
createdCount: z.number().int().positive(),
|
||||
})
|
||||
.strict();
|
||||
|
||||
export const GameCdkStatusInputSchema = z
|
||||
.object({ status: z.enum(['unused', 'disabled']) })
|
||||
.strict();
|
||||
|
||||
export type GameCdkStatus = z.infer<typeof GameCdkStatusSchema>;
|
||||
export type GameCdkScope = z.infer<typeof GameCdkScopeSchema>;
|
||||
export type GameCdkReward = z.infer<typeof GameCdkRewardSchema>;
|
||||
export type GameCdk = z.infer<typeof GameCdkSchema>;
|
||||
export type GameCdkSummary = z.infer<typeof GameCdkSummarySchema>;
|
||||
export type GameCdkList = z.infer<typeof GameCdkListSchema>;
|
||||
export type GameCdkBatchCreateInput = z.infer<typeof GameCdkBatchCreateInputSchema>;
|
||||
export type GameCdkBatchCreateResult = z.infer<typeof GameCdkBatchCreateResultSchema>;
|
||||
export type GameCdkStatusInput = z.infer<typeof GameCdkStatusInputSchema>;
|
||||
Reference in New Issue
Block a user