// eslint-disable-next-line @typescript-eslint/no-unused-vars
import { number } from "echarts";

// 请求响应参数（不包含data）
export interface Result {
  code: string;
  msg: string;
}

// 请求响应参数（包含data）
export interface ResultData<T = any> extends Result {
  data: T;
}

// 分页响应参数
export interface ResPage<T> {
  records: T[];
  total: number;
}

// 列表公共参数
export interface ListCommon {
  createBy: string;
  createTime: string;
  updateTime?: string;
  updateBy?: string;
}

// 分页请求参数
export interface ReqPage {
  sortBy?: string;
  pageNum: number;
  pageSize: number;
}

// 文件上传模块
export namespace Upload {
  export interface ResFileUrl {
    fileUrl: string;
  }
}

// 登录模块
export namespace Login {
  export interface ReqLoginForm {
    username: string;
    password: string;
    code: string;
    uuid: string;
  }
  export interface ResLogin {
    access_token: string;
  }
  export interface ResCaptcha {
    captchaEnabled: boolean;
    img: string;
    uuid: string;
  }
  export interface ResAuthButtons {
    [key: string]: string[];
  }
}

// 公共模块
export namespace Common {
  export interface DictOptions {
    dictLabel: string;
    dictCode: number;
    dictSort: number;
  }
  export interface UserInfo {
    permissions: string[];
    roles: string[];
    user: {
      userName: string;
      nickName: string;
    };
  }
  export interface ClauseOptions {
    articleContent: string;
    firstArticleNo: number;
    publicationDate: number;
  }

  export interface ResOptions {
    id: number;
    name: string;
    parentId: number;
  }

  export interface ResTreeOptions extends ResOptions {
    children?: ResTreeOptions[];
  }
}

// 数据标注
export namespace DataAnno {
  export interface TagItem {
    id: number;
    tagName: string;
    parentId: number;
    parentName: string;
  }
  export interface LabelList {
    id: number;
    beginIndex: number;
    endIndex: number;
    keyword: string;
    colour: string;
    tagDetailList: TagItem[];
    maxId: number;
    parentStandardWordId: number | null;
    parentStandardWordName: string | null;
    synonymWordId: number | null;
    synonymWordName: string | null;
  }
  export interface LabelStrList {
    articleTagId: number;
    articleTagName: string;
    keyWordList: string[];
    keyWordStr: string;
  }
  export interface AttrItem {
    id: number;
    attributeId: number;
    attributeName: string;
  }
  export interface AttrList {
    parentId: number;
    parentName: string;
    detailRespList: AttrItem[];
    attributeNameStr: string;
  }
  export interface Detail {
    id: number;
    articleContent: string;
    annotationStatus: number;
    annotationName: string;
  }

  export interface ReqAnnoSaveParams {
    id?: number;
    articleId: number;
    beginIndex: number;
    endIndex: number;
    keyword: string;
    colour: string;
    tagIdList: number[];
  }
  export interface ResDetailLabel {
    tagList: LabelList[];
    tagStrList: LabelStrList[];
  }
}
// 词条
export namespace Clause {
  export interface ClauseInfo extends ListCommon {
    id: number;
    firstArticleNo: number; // 首见条文编号
    articleType: 1 | 2 | 3; // 条文分类
    articleContent: string; // 条文内容
    diseaseId: number; // 疾病ID
    diseaseName: string; // 疾病名称
    bookId: number; // 书ID
    bookName: string; // 书名
    chapter: string; // 卷篇
    version: string; // 版本信息
    author: string; // 作者
    dynastySort: string; // 朝代
    startDynastyName?: string; // 开始朝代名称
    startDynastySort?: number; // 开始朝代排序
    endDynastyName?: string; // 结束朝代名称
    endDynastySort?: number; // 结束朝代排序
    publicationDate: number; // 成书年代
    scopeIf: 0 | 1 | any; // 成书范围
    styleId: number; // 体裁ID
    styleName: string; // 体裁名称
    traceStatus: number; // 溯源状态
    traceBy: string; // 处理人
    annotationStatus: number; // 标注状态
    annotationSubmitStatus: number; // 标注提交状态
    annotationSubmitTime: string; // 标注提交时间
    manualFlag: 0 | 1; // 是否手动设置首见条文
    revokeFlag: boolean; // 是否已上传撤回条文
    annotationFlag: 0 | 1; // 是否标注过
    annotationBy: string; // 标注ID
    nickName: string; // 标注员名称
    assignTime: string; // 分工时间
    reviewedBy: string; // 审核人
    reviewedTime: string; // 审核时间
    refuseReason: string; // 审核退回原因
    delTime: string; // 删除时间
    delFlag: boolean; // 删除标识
    similarityValue?: number; // 相似度
  }
}

// 词表
export namespace WordLib {
  // 标准词
  export interface Standard extends ListCommon {
    id: number;
    parentId?: number;
    wordName: string;
    enableFlag: number; // 0-禁用 1-启用。默认1
    editableFlag: number;
  }

  // 同义词
  export interface Synonym extends ListCommon {
    id: number;
    standardWordId: number;
    synonymWordName: string;
    enableFlag: number; // 0-禁用 1-启用。默认1
    editableFlag: number;
  }
}

// 用户管理模块
export namespace User {
  export interface ReqUserParams extends ReqPage {
    userName: string;
    phonenumber: string;
    status: string;
    createTime?: [string, string];
    params?: {
      beginTime: string;
      endTime: string;
    };
  }

  export interface ResUserList extends ListCommon {
    admin: boolean;
    userId: number;
    userName: string;
    nickName: string;
    deptId?: number;
    roleIds: number[];
    postIds: number[];
    roleNameStr: string;
    dept?: {
      deptName: string;
      leader: string;
    };
    phonenumber: string;
    status: string;
  }

  export interface ResGender {
    genderLabel: string;
    genderValue: number;
  }

  export interface ResDepartment {
    id: string;
    name: string;
    children?: ResDepartment[];
  }

  export interface ResUserDetail extends ResUserList {
    posts: { postId: number; postName: string }[];
    roles: { roleId: number; roleName: string; status: string }[];
  }
}

// 角色管理模块
export namespace Role {
  export interface ReqRoleParams extends ReqPage {
    roleName: string;
    roleKey: string;
    status: string;
    createTime?: [string, string];
    params?: {
      beginTime: string;
      endTime: string;
    };
  }

  export interface ResRoleList extends ListCommon {
    admin: boolean;
    roleId: number;
    roleName: string;
    roleKey: string;
    remark: string;
    status: string;
    roleSort: number;
    menuIds?: number[];
  }
}

// 菜单管理模块
export namespace Menu {
  export interface ReqMenuParams extends ReqPage {
    menuName: string;
    status: string;
  }

  export interface ResMenuList extends ListCommon {
    menuId: number;
    parentId: number;
    menuName: string;
    perms: string;
    remark?: string;
    icon?: string;
    component?: string;
    path?: string;
    status: "1" | "0";
    orderNum: number;
    menuType: "M" | "C" | "F";
    isCache: "1" | "0";
    visible: "1" | "0";
    isFrame: "1" | "0";
  }

  export interface TreeMenu extends ResMenuList {
    children?: TreeMenu[];
  }

  export interface ResTreeMenu {
    id: number;
    label: string;
    children?: ResTreeMenu[];
  }

  export interface ResRoleCheckedKeys {
    checkedKeys: number[];
  }
}

// 部门管理模块
export namespace Dept {
  export interface ReqDeptParams extends ReqPage {
    deptName: string;
    status: string;
  }

  export interface ResDeptList extends ListCommon {
    deptId: number;
    deptName: string;
    orderNum: number;
    remark: string;
    parentId: number;
    leader: string;
    phone: string;
    email: string;
    status: string;
  }

  export interface TreeDept extends ResDeptList {
    children?: TreeDept[];
  }

  export interface ResTreeDept {
    id: number;
    label: string;
    children?: ResTreeDept[];
  }
}

// 岗位管理模块
export namespace Post {
  export interface ReqPostParams extends ReqPage {
    postCode: string;
    postName: string;
    status: string;
  }

  export interface ResPostList extends ListCommon {
    postId: number;
    postName: string;
    postCode: string;
    postSort: number;
    remark: string;
    status: string;
  }
}

// 字典管理模块
export namespace Dict {
  export interface ReqDictParams extends ReqPage {
    dictType: string;
    dictName: string;
    status: string;
    createTime?: [string, string];
    params?: {
      beginTime: string;
      endTime: string;
    };
  }

  export interface ResDictList extends ListCommon {
    dictId: string;
    dictType: string;
    dictName: string;
    remark: string;
    status: string;
  }

  export interface ReqDictDataParams extends ReqPage {
    dictType: string;
    dictLabel: string;
    status: string;
  }

  export interface ResDictDataList extends ListCommon {
    dictCode: number;
    dictLabel: string;
    dictValue: string;
    dictSort: number;
    dictType: string;
    isDefault: string;
    listClass: string;
    cssClass: string;
    remark: string;
    status: string;
  }
}

// 语料库-首见条文
export namespace FirstClause {
  export type ReqFirstClauseParams = Pick<
    Clause.ClauseInfo,
    | "firstArticleNo"
    | "articleContent"
    | "diseaseName"
    | "bookName"
    | "publicationDate"
    | "annotationStatus"
    | "styleId"
    | "dynastySort"
  > &
    ReqPage;
}

// 语料库-条文溯源
export namespace TraceOrigin {
  export interface ReqTraceOriginParams extends ReqPage {
    createTime: string;
    traceStatus: number;
  }
  export type ReqSimilarityParams = {
    id: number;
    similarityValue?: [string, string];
    similarityMin: string;
    similarityMax: string;
  } & Pick<
    Clause.ClauseInfo,
    "firstArticleNo" | "articleContent" | "diseaseName" | "bookName" | "publicationDate" | "dynastySort"
  > &
    ReqPage;
  export interface ResSimilarityDataList extends Clause.ClauseInfo, ListCommon {
    similarityValue: number; // 相似度
  }
}

// 语料库-条文回收站
export namespace ClauseTrash {
  export type ReqClauseTrashParams = ReqPage;

  export interface ReqSetArticleTypeParams {
    articleId: number;
    articleType?: number;
    firstArticleNo: number;
  }
}

// 标注-标注首页
export namespace AnnoHome {
  export type ReqAnnoHomeParams = Pick<
    Clause.ClauseInfo,
    | "firstArticleNo"
    | "articleContent"
    | "diseaseName"
    | "bookName"
    | "styleId"
    | "annotationBy"
    | "annotationStatus"
    | "dynastySort"
  > &
    ReqPage;
}

// 标注-标注分工
export namespace AnnoDivision {
  export type ReqAnnoDivisionParams = { allocationType: number } & Pick<
    Clause.ClauseInfo,
    "diseaseName" | "bookName" | "styleId"
  > &
    ReqPage;

  export interface ReqDivideArticleParams {
    articleIds: number[];
    annotationBy: number;
  }
}

// 标注-标注标注
export namespace AnnoLabeling {
  export interface ReqAnnoLabelingParams extends ReqPage {}
  export interface ReqPageNumInfoParams {
    id?: number;
    concurrent?: number;
  }

  export interface ResPageNumInfo {
    id: number;
    pageNum: number;
    total: number;
  }
}

// 标注-标注审核
export namespace AnnoAudit {
  export type ReqAnnoAuditParams = { allocationType: number } & Pick<
    Clause.ClauseInfo,
    "diseaseName" | "bookName" | "styleId" | "annotationBy"
  > &
    ReqPage;
  export interface ReqAuditProcessParams {
    articleIds: number[];
    auditStatus: number;
    refuseReason?: string;
  }
}

// 标注-标签管理
export namespace AnnoTag {
  export interface TagItem {
    id: number;
    name: string;
    parentId: number;
    editableFlag?: boolean; // 是否可编辑
    isNew?: boolean; // 前端定义
  }

  export interface ResTagTreeList extends TagItem {
    children: TagItem[];
  }
}

// 标注-词表库管理
export namespace AnnoLexicon {
  export type ReqStandardParams = Pick<WordLib.Standard, "wordName"> & ReqPage;

  export interface ResStandardList extends WordLib.Standard {}

  export interface ResStandardDetail extends WordLib.Standard {
    sortIndex: number; // 前端定义的
    children?: ResStandardDetail[];
  }

  export type ReqSynonymParams = Pick<WordLib.Synonym, "synonymWordName"> & ReqPage;

  export interface ResSynonymList extends WordLib.Synonym {}
}

// 检索
export namespace Retrieval {
  // 普通检索参数
  export interface CommonSearchParams {
    searchType: number; // 检索类型
    generalKeyword: string; // 普通检索关键词
    highBook?: number[]; // 高级检索-书名ID
    highDisease?: number[]; // 高级检索-疾病ID
  }

  // 高级检索条文内容参数
  export interface AdvancedContentParams {
    keyWord: string; // 高级检索关键词
    standardWordIdList: number[]; // 标准词ID
    synonymWordList: number[]; // 同义词ID
    tagIdList: number[]; // 标签ID
  }

  // 高级检索参数
  export interface AdvancedSearchParams {
    highFirstContent: AdvancedContentParams; // 高级检索-内容1
    highSecondContent: AdvancedContentParams; // 高级检索-内容2
    highThirdContent: AdvancedContentParams; // 高级检索-内容3
    highStyle: number[]; // 高级检索-体裁ID
    highBook: number[]; // 高级检索-书名ID
    highDisease: number[]; // 高级检索-疾病ID
    highDynastySort: number[]; // 高级检索-朝代ID
  }

  // 检索请求参数
  export interface ReqRetrievalParams extends AdvancedSearchParams, ReqPage {
    generalSearchReqList: CommonSearchParams[];
    articleAttributeList: number[]; // 分类检索-条文属性
    classifyDynastySortList: number[]; // 分类检索-朝代
  }

  //
  export interface ResKeywordCheckedList {
    standardWordList: Common.ResOptions[];
    synonymWordList: Common.ResOptions[];
    tagList: Common.ResOptions[];
  }
}

// 统计分析
export namespace StatsAnalysis {
  // 过滤参数
  export interface ReqSearchParam {
    pointId?: number;
    bookId?: number;
    diseaseId?: number;
  }

  // 统计导出请求参数
  export interface ReqExportParams extends ReqSearchParam {
    bookDiseaseId?: number;
  }

  //  柱状图数据
  export interface ResChartData {
    count: number;
    id: number;
    name: string;
  }
}

// 语义管理模块
export namespace Semantics {
  // 列表查询请求参数
  export interface ReqSemanticsParams extends ReqPage {
    semanticsName: string;
    updateTime: string;
    dataSources: string;
  }
  // 列表参数
  export interface ResSemanticsList extends ListCommon {
    [key: string]: any;
  }
}
// 语义关联管理模块
export namespace SemanticsAssociation {
  // 列表查询请求参数
  export interface ReqSemanticsAssociationParams extends ReqPage {
    semanticsName: string;
    updateTime: string;
    dataSources: string;
  }
  // 列表参数
  export interface ResSemanticsAssociationList extends ListCommon {
    [key: string]: any;
  }
}
