/** 前后端共享类型定义（禁止 any） */

export type AdminRole = 'super_admin' | 'normal';

export interface AdminInfo {
  id: number;
  username: string;
  nickname: string;
  avatar: string;
  role: AdminRole;
}

export interface AdminUser {
  id: number;
  username: string;
  nickname: string;
  avatar: string;
  role: AdminRole;
  createdAt: string;
  updatedAt: string;
}

export interface LoginResult {
  token: string;
  admin: AdminInfo;
}

export interface Banner {
  id: number;
  title: string;
  image: string;
  link: string;
  sort: number;
  isShow: number;
  createdAt: string;
  updatedAt: string;
}

export interface ProductCategory {
  id: number;
  name: string;
  sort: number;
  isShow: number;
  createdAt: string;
  updatedAt: string;
}

export interface Product {
  id: number;
  categoryId: number;
  name: string;
  cover: string;
  desc: string | null;
  content: string | null;
  sort: number;
  isShow: number;
  category?: ProductCategory;
  createdAt: string;
  updatedAt: string;
}

export interface NewsCategory {
  id: number;
  name: string;
  sort: number;
  isShow: number;
  createdAt: string;
  updatedAt: string;
}

export interface News {
  id: number;
  categoryId: number;
  title: string;
  cover: string;
  intro: string;
  content: string;
  isTop: number;
  status: number;
  category?: NewsCategory;
  createdAt: string;
  updatedAt: string;
}

export interface Team {
  id: number;
  name: string;
  position: string;
  avatar: string;
  desc: string | null;
  sort: number;
  isShow: number;
  createdAt: string;
  updatedAt: string;
}

export interface Message {
  id: number;
  name: string;
  phone: string;
  email: string;
  content: string;
  isRead: number;
  createdAt: string;
}

export interface SiteConfig {
  id: number;
  siteName: string;
  logo: string;
  tel: string;
  address: string;
  email: string;
  copyright: string;
  icp: string;
  aboutTitle: string;
  aboutContent: string | null;
  createdAt: string;
  updatedAt: string;
}

/** 使用手册节点类型：0=目录节点 1=文档节点 */
export type ManualNodeType = 0 | 1;

/** 使用手册正文格式 */
export type ManualContentFormat = 'html' | 'markdown';

export interface Manual {
  id: number;
  parentId: number | null;
  title: string;
  /** 0=目录 1=文档 */
  type: ManualNodeType;
  content: string | null;
  /** 正文格式：html=富文本 markdown=Markdown（旧数据可能缺失，按 html 兜底） */
  contentFormat: ManualContentFormat;
  sort: number;
  isShow: number;
  createdAt: string;
  updatedAt: string;
}

/** 树形节点（不含正文，用于菜单） */
export interface ManualTreeNode {
  id: number;
  parentId: number | null;
  title: string;
  type: ManualNodeType;
  sort: number;
  isShow: number;
  children: ManualTreeNode[];
}
