From ff487064a27f0a50f128f9723e5e868e505646a2 Mon Sep 17 00:00:00 2001 From: zihluwang Date: Wed, 22 Apr 2026 16:52:09 +0800 Subject: [PATCH] refactor: split interfaces by module --- src/types/auth.ts | 11 +++++++ src/types/common.ts | 17 ++++++++++ src/types/firearm.ts | 24 ++++++++++++++ src/types/index.ts | 66 +++------------------------------------ src/types/modification.ts | 12 +++++++ 5 files changed, 68 insertions(+), 62 deletions(-) create mode 100644 src/types/auth.ts create mode 100644 src/types/common.ts create mode 100644 src/types/firearm.ts create mode 100644 src/types/modification.ts diff --git a/src/types/auth.ts b/src/types/auth.ts new file mode 100644 index 0000000..34c2b14 --- /dev/null +++ b/src/types/auth.ts @@ -0,0 +1,11 @@ +export interface LoginRequest { + principle: string + credential: string +} + +export interface User { + id: number + username: string + email: string +} + diff --git a/src/types/common.ts b/src/types/common.ts new file mode 100644 index 0000000..9f98731 --- /dev/null +++ b/src/types/common.ts @@ -0,0 +1,17 @@ +export type Direction = "ASC" | "DESC" + +export interface Page { + items: T[] + page: number + size: number + totalElements: number + totalPages: number +} + +export interface PageQueryParams { + page?: number + size?: number + sortBy?: string + direction?: Direction +} + diff --git a/src/types/firearm.ts b/src/types/firearm.ts new file mode 100644 index 0000000..596f02d --- /dev/null +++ b/src/types/firearm.ts @@ -0,0 +1,24 @@ +export type FirearmType = + | "RIFLE" + | "SUB_MACHINE_GUN" + | "SHOTGUN" + | "LIGHT_MACHINE_GUN" + | "DESIGNATED_MARKSMAN_RIFLE" + | "SNIPER_RIFLE" + | "PISTOL" + | "SPECIAL" + +export interface Firearm { + id: number + name: string + type: FirearmType + level: string + calibre: string + fireRate: number + armourDamage: number + bodyDamage: number + review: string | null +} + +export interface AddFirearmRequest extends Omit {} + diff --git a/src/types/index.ts b/src/types/index.ts index ae82bae..785c148 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -1,62 +1,4 @@ -export type Direction = "ASC" | "DESC" - -export type FirearmType = - | "RIFLE" - | "SUB_MACHINE_GUN" - | "SHOTGUN" - | "LIGHT_MACHINE_GUN" - | "DESIGNATED_MARKSMAN_RIFLE" - | "SNIPER_RIFLE" - | "PISTOL" - | "SPECIAL" - -export interface Page { - items: T[] - page: number - size: number - totalElements: number - totalPages: number -} - -export interface Firearm { - id: number - name: string - type: FirearmType - level: string - calibre: string - fireRate: number - armourDamage: number - bodyDamage: number - review: string | null -} - -export interface AddFirearmRequest extends Omit {} - -export interface Modification { - id: number - firearmId: number - name: string - code: string - tags: string[] - note: string - author: string - videoUrl: string -} - -export interface PageQueryParams { - page?: number - size?: number - sortBy?: string - direction?: Direction -} - -export interface LoginRequest { - principle: string - credential: string -} - -export interface User { - id: number - username: string - email: string -} +export * from "./common" +export * from "./firearm" +export * from "./modification" +export * from "./auth" diff --git a/src/types/modification.ts b/src/types/modification.ts new file mode 100644 index 0000000..f1286b9 --- /dev/null +++ b/src/types/modification.ts @@ -0,0 +1,12 @@ +export interface Modification { + id: number + firearmId: number + name: string + code: string + tags: string[] + note: string + author: string + videoUrl: string +} + +export interface ModificationRequest extends Omit {}