// ---- Generic API result wrapper ----
export interface ApiResult<T> {
  code: number
  message: string
  data: T | null
}

// ---- Auth ----
export interface UserLoginDto {
  username: string
  password: string
}

export interface LoginVo {
  token: string
  username: string
  role: string
}

export type ApiResultLoginVo = ApiResult<LoginVo>

// ---- Book ----
export interface Book {
  id: number | null
  name: string
  author: string
  stock: number
}

export type ApiResultBook = ApiResult<Book>
export type ApiResultListBook = ApiResult<Book[]>

export interface BookAddDto {
  name: string
  author: string
  stock: number
}

export interface BookUpdateDto {
  name: string
  author: string
}

// ---- Borrow / MyBorrow ----
export interface BookBorrowVo {
  id: number
  name: string
  author: string
}

export interface MyBorrowVo {
  id: number
  bookBorrowVo: BookBorrowVo
  borrowTime: string
  returnTime: string | null
  status: string
}

export type ApiResultMyBorrowVo = ApiResult<MyBorrowVo>
export type ApiResultListMyBorrowVo = ApiResult<MyBorrowVo[]>

// ---- Admin Borrow ----
export interface UserBorrowVo {
  id: number
  username: string
  role: string
}

export interface BorrowInfoVo {
  id: number
  bookBorrowVo: BookBorrowVo
  userBorrowVo: UserBorrowVo
  borrowTime: string
  returnTime: string | null
  status: string
}

export type ApiResultBorrowInfoVo = ApiResult<BorrowInfoVo>
export type ApiResultListBorrowInfoVo = ApiResult<BorrowInfoVo[]>

// ---- Utils ----
export type ApiResultString = ApiResult<string | null>
