export type RoleCode =
  | "ORG_ADMIN"
  | "SUPER_ADMIN"
  | "ROOT_ORG_ADMIN"
  | "COURSE_ADMIN";

export interface Role {
  roleId: number;
  roleCode: RoleCode;
  roleName: string;
}

export interface RoleOption {
  id: number;
  name: string;
  code: RoleCode;
}

export type Course_Type = "PUBLIC" | "MAJOR";

export type Privilege_Type = "COURSE" | "ORG";

export interface ServerPageResponse<T> {
  data: {
    content: T[];
    pageNo: number;
    pageSize: number;
    totalElements: number;
  };
}

// export type ServerResponse<T> = ServerResponseI<T>;
// HOW?
// I is optional, default any
// T is ServerResponse<T>
// type AxiosPostFuncInner<I = any,Y> = ;

export interface Course {
  code: string;
  createTime: string;
  createTimeStr: string;
  creator: string;
  enable: boolean;
  enableStr: string;
  id: number;
  name: string;
  rootOrgId: number; // 供编辑页显示
  rootOrgCode: string;
  rootOrgName: string;
  type: Course_Type;
  typeStr: string;
  updateTime: string;
  updateTimeStr: string;
  updater: string;
}

export interface ProjectCourse {
  courseCode: string;
  courseId: number;
  courseName: string;
  courseType: Course_Type;
  id: number;
  startScore: number;
  nationalScore: number;
  nationalTotalScore: number;
  projectId: number;
  projectName: string;
  retestScore: number;
  retestTotalScore: number;
  totalScoreLine: number;
}

// 科目成绩（总分）频率分布-科目成绩占初试总分权重
export interface SasCourse {
  courseCode: string;
  courseId: number;
  courseName: string;
  difficulty: number;
  id: number;
  projectId: number;
  projectName: string;
  rangeConfig: RangeConfig[];
  scoreRange: number[];
  totalCount: number;
  totalRangeConfig: string;
  totalScore: number;
  totalScoreRange: {
    countRate: number;
    avgTotalScore: number;
    avgScore: number;
    difficulty: number;
    scoreRate: number;
  }[];
  totalScoreRangeTitle: any; // {title}

  segements: number[][]; // 前端自用
  rangeSegements: (string | number | boolean)[][]; // 前端自用
  scoreRangeAcc: number[]; // 前端自用
  scoreRangeTotal: number; // 前端自用
}

export interface RangeConfig {
  type: keyof RANGE_POINT_TYPE;
  baseScore: number;
  adjustScore: number;
}

export interface RANGE_POINT_TYPE {
  ZERO: "零分";
  CUSTOM: "自定义";
  NATIONAL_SCORE: "国家单科线";
  RETEST_SCORE: "复试单科线";
  NATIONAL_TOTAL_SCORE: "国家总分线";
  RETEST_TOTAL_SCORE: "复试总分线";
  TOTAL_SCORE_LINE: "国家满分线";
}

export interface Paper {
  courseCode: string;
  courseName: string;
  id: number;
  paperName: string;
  paperType: string;
  totalCount: number;
}

// 整体分析-试卷特征量数
export interface SASPaper {
  [key: string]: string | number | any;
  allRange: number;
  avgScore: number;
  coefficient: number;
  courseCode: string;
  courseId: number;
  courseName: string;
  createTime: string;
  difficulityLevel: DifficulityLevel;
  difficulityRangeConfig: string;
  difficulty: number;
  discriminationLevel: DiscriminationLevel;
  id: number;
  maxScore: number;
  minScore: number;
  paperId: number;
  paperName: string;
  paperType: string;
  rootOrgName?: string;
  projectName?: string;
  projectId: number;
  questionCount: number;
  reliability1: number;
  reliability2: number;
  stdev: number;
  totalCount: number;
  totalScore: number;
  updateTime: string;
}

// 试卷分析-查询指定试卷全卷信息

export interface Project {
  changeInfo: {
    ITEM1: boolean;
    ITEM2: boolean;
    ITEM3: boolean;
    ITEM4: boolean;
    ITEM5: boolean;
    ITEM6: boolean;
  };
  createTime: string;
  creator: string;
  id: number;
  name: string;
  needCompute: boolean;
  rootOrgCode: string;
  rootOrgName: string;
  status: string;
  updateTime: string;
  updater: string;
}

interface LevelDetail {
  questionCount: number;
  fullScore: number;
  percent: number;
}
export interface DifficulityLevel {
  high: LevelDetail;
  middle: LevelDetail;
  low: LevelDetail;
}

// 查询指定试卷
export interface Paper {
  courseId: number;
  createTime: string;
  creatorId: number;
  difficulityRangeConfig: string;
  id: number;
  optionRangeConfig: string;
  paperName: string;
  paperType: string;
  projectId: number;
  rootOrgId: number;
  totalScore: number;
  updateTime: string;
  updaterId: number;
}

export interface DiscriminationLevel {
  excellent: LevelDetail;
  good: LevelDetail;
  general: LevelDetail;
  bad: LevelDetail;
}

// 试题题目编排,试卷特征量数,试题难度分组分布
export interface SASQuestion {
  answer: string;
  avgScore: number;
  coefficient: number;
  courseId: number;
  createTime: string;
  difficulityGroupLevel: number[];
  difficulityLevel: number[];
  difficulty: number;
  discrimination: number;
  effectiveCount: number;
  fullCount: number;
  id: number;
  mainNumber: number;
  maxScore: number;
  minScore: number;
  objective: boolean;
  optionLevel: string;
  options: string;
  paperId: number;
  projectId: number;
  questionName: string;
  stdev: number;
  subIndex: number;
  subNumber: number;
  totalScore: number;
  updateTime: string;
  zeroCount: number;
}

// 题型难度分布、题型区分度分布
export interface SASQuestionGroup {
  avgScore: number;
  coefficient: number;
  courseId: number;
  createTime: string;
  difficulityLevel: DifficulityLevel;
  difficulty: number;
  discrimination: number;
  discriminationLevel: DiscriminationLevel;
  fullCount: number;
  groupName: string;
  id: number;
  maxScore: number;
  minScore: number;
  objective: boolean;
  paperId: number;
  projectId: number;
  questionCount: number;
  realityCount: number;
  stdev: number;
  totalScore: number;
  type:
    | "TYPE1"
    | "TYPE2"
    | "TYPE3"
    | "CONTENT1"
    | "CONTENT2"
    | "CONTENT3"
    | "ABILITY1"
    | "ABILITY2"
    | "ABILITY3";
  updateTime: string;
  zeroCount: number;
}

export interface User {
  createTime: string;
  createTimeStr: string;
  creator: string;
  enable: boolean;
  enableStr: string;
  id: number;
  loginName: string;
  name: string;
  roleName: string;
  rootOrgCode: string;
  rootOrgName: string;
  updateTime: string;
  updateTimeStr: string;
  updater: string;

  rootOrgId: number; // FE add
  role: string; // FE add
  password: string; // FE add
}

export interface RootOrg {
  code: string;
  domainName: string;
  enable: boolean;
  id: number;
  name: string;
  updateTime: string;
}

export interface SubOrg {
  code: string;
  createTime: string;
  createTimeStr: string;
  creator: string;
  enable: boolean;
  enableStr: string;
  id: number;
  name: string;
  rootOrgCode: string;
  rootOrgId: number;
  rootOrgName: string;
  updateTime: string;
  updateTimeStr: string;
  updater: string;
}

export interface ImportResponse {
  data: {
    hasError: boolean;
    failRecords: { lineNum: number; msg: string }[];
  };
}

export interface TaskItem {
  id: number;
  filePath: string;
  spentTime: string;
  status: "WAITING" | "PROCESSING" | "FAILED" | "SUCCESS";
  statusMsg: string;
  statusName: string;
  taskTypeName: string;
}
