Ver código fonte

优化类型定义

Michael Wang 3 anos atrás
pai
commit
d75903f8c2

+ 2 - 2
src/api/courseManagementPage.ts

@@ -1,7 +1,7 @@
 import { httpApp } from "@/plugins/axiosApp";
 import { responseToFile } from "@/utils/utils";
 import qs from "qs";
-import { CourseResponse } from "@/types";
+import { CourseResponse, ImportResponse } from "@/types";
 
 /** 科目分页查询 */
 export function getCourseList(params: {
@@ -44,7 +44,7 @@ export function importCourses(rootOrgId: number, file: File) {
   const f = new FormData();
   f.append("rootOrgId", rootOrgId + "");
   f.append("file", file);
-  return httpApp.post(`/api/ess/course/import`, f);
+  return httpApp.post<any, ImportResponse>(`/api/ess/course/import`, f);
 }
 
 /** 导出科目 */

+ 11 - 2
src/api/paperAnalysisPage.ts

@@ -1,5 +1,11 @@
 import { httpApp } from "@/plugins/axiosApp";
-import { SASQuestion, SASPaper, Paper, SASQuestionGroup } from "@/types";
+import {
+  SASQuestion,
+  SASPaper,
+  Paper,
+  SASQuestionGroup,
+  ImportResponse,
+} from "@/types";
 
 /** 试卷查询 */
 export function getPaper(id: number) {
@@ -48,5 +54,8 @@ export function importQuestionGroups(projectId: number, file: File) {
   const f = new FormData();
   f.append("projectId", projectId + "");
   f.append("file", file);
-  return httpApp.post(`/api/ess/sasQuestionGroup/import`, f);
+  return httpApp.post<any, ImportResponse>(
+    `/api/ess/sasQuestionGroup/import`,
+    f
+  );
 }

+ 2 - 2
src/api/projectParamsManagementPage.ts

@@ -1,6 +1,6 @@
 import { httpApp } from "@/plugins/axiosApp";
 import { responseToFile } from "@/utils/utils";
-import { ProjectCourseResponse } from "@/types";
+import { ProjectCourseResponse, ImportResponse } from "@/types";
 
 /** 科目分页查询 */
 export function getProjectCourseList(params: {
@@ -21,7 +21,7 @@ export function importProjectParams(projectId: number, file: File) {
   const f = new FormData();
   f.append("projectId", projectId + "");
   f.append("file", file);
-  return httpApp.post(`/api/ess/projectCourse/import`, f);
+  return httpApp.post<any, ImportResponse>(`/api/ess/projectCourse/import`, f);
 }
 
 /** 导出项目参数配置 */

+ 2 - 2
src/api/rootOrgPage.ts

@@ -1,5 +1,5 @@
 import { httpApp } from "@/plugins/axiosApp";
-import { OrgResponse } from "@/types";
+import { RootOrgResponse } from "@/types";
 
 /** 顶级机构分页查询 */
 export function getRootOrgList(params: {
@@ -9,7 +9,7 @@ export function getRootOrgList(params: {
   pageNo?: number;
   pageSize?: number;
 }) {
-  return httpApp.post<any, { data: OrgResponse }>(
+  return httpApp.post<any, { data: RootOrgResponse }>(
     "/api/ess/root/org/page",
     params
   );

+ 2 - 2
src/api/subOrgPage.ts

@@ -1,7 +1,7 @@
 import { httpApp } from "@/plugins/axiosApp";
 import { responseToFile } from "@/utils/utils";
 import QueryString from "qs";
-import { SubOrgResponse } from "@/types";
+import { SubOrgResponse, ImportResponse } from "@/types";
 
 /** 机构分页查询 */
 export function getSubOrgList(params: {
@@ -50,7 +50,7 @@ export function importOrgs(rootOrgId: number, file: File) {
   const f = new FormData();
   f.append("rootOrgId", rootOrgId + "");
   f.append("file", file);
-  return httpApp.post(`/api/ess/org/import`, f);
+  return httpApp.post<any, ImportResponse>(`/api/ess/org/import`, f);
 }
 
 /** 导出机构 */

+ 2 - 2
src/api/userManagementPage.ts

@@ -2,7 +2,7 @@ import { httpApp } from "@/plugins/axiosApp";
 import { Course_Type, Privilege_Type } from "@/types";
 import { responseToFile } from "@/utils/utils";
 import QueryString from "qs";
-import { UserResponse } from "@/types";
+import { UserResponse, ImportResponse } from "@/types";
 
 /** 用户分页查询 */
 export function getUserList(params: {
@@ -68,7 +68,7 @@ export function importUsers(rootOrgId: number, file: File) {
   const f = new FormData();
   f.append("rootOrgId", rootOrgId + "");
   f.append("file", file);
-  return httpApp.post(`/api/ess/user/import`, f);
+  return httpApp.post<any, ImportResponse>(`/api/ess/user/import`, f);
 }
 
 /** 导出用户 */

+ 1 - 1
src/features/courseManagement/CourseManagement.vue

@@ -314,7 +314,7 @@ async function handleImport() {
     await clickSearch();
   } else {
     // eslint-disable-next-line
-    const msg = res.data.failRecords.map((v: any) =>
+    const msg = res.data.failRecords.map((v) =>
       h("div", `行号:${v.lineNum}, 错误:${v.msg}`)
     );
     void message.error({

+ 1 - 1
src/features/paperAnalysis/QuestionTypeDifficulty.vue

@@ -215,7 +215,7 @@ async function handleImport() {
     void message.success({ content: "导入成功" });
   } else {
     // eslint-disable-next-line
-    const msg = res.data.failRecords.map((v: any) =>
+    const msg = res.data.failRecords.map((v) =>
       h("div", `行号:${v.lineNum}, 错误:${v.msg}`)
     );
     void message.error({

+ 1 - 1
src/features/paperAnalysis/QuestionTypeDiscrimination.vue

@@ -215,7 +215,7 @@ async function handleImport() {
     void message.success({ content: "导入成功" });
   } else {
     // eslint-disable-next-line
-    const msg = res.data.failRecords.map((v: any) =>
+    const msg = res.data.failRecords.map((v) =>
       h("div", `行号:${v.lineNum}, 错误:${v.msg}`)
     );
     void message.error({

+ 1 - 1
src/features/projectParamsManagement/ProjectParamsManagement.vue

@@ -235,7 +235,7 @@ async function handleImport() {
     await clickSearch();
   } else {
     // eslint-disable-next-line
-    const msg = res.data.failRecords.map((v: any) =>
+    const msg = res.data.failRecords.map((v) =>
       h("div", `行号:${v.lineNum}, 错误:${v.msg}`)
     );
     void message.error({

+ 3 - 3
src/features/rootOrg/RootOrg.vue

@@ -84,7 +84,7 @@
 import { getRootOrgList, syncRootOrg, updateRootOrg } from "@/api/rootOrgPage";
 import router from "@/router";
 import { useMainStore } from "@/store";
-import { Org } from "@/types";
+import { RootOrg } from "@/types";
 import { message } from "ant-design-vue";
 import { ref, onMounted, reactive } from "vue";
 
@@ -95,7 +95,7 @@ let code = $ref("");
 let name = $ref("");
 let enable = $ref(undefined as undefined | boolean);
 
-let data = $ref<Org[]>([]);
+let data = $ref<RootOrg[]>([]);
 let pageSize = $ref(10);
 let pageNo = $ref(1);
 let totalElements = $ref(0);
@@ -151,7 +151,7 @@ onMounted(async () => {
 
 const visible = ref<boolean>(false);
 
-const showModal = (record: Org) => {
+const showModal = (record: RootOrg) => {
   Object.assign(rootOrgObj, record);
   visible.value = true;
 };

+ 1 - 1
src/features/subOrg/SubOrg.vue

@@ -306,7 +306,7 @@ async function handleImport() {
     void message.success({ content: "导入成功" });
   } else {
     // eslint-disable-next-line
-    const msg = res.data.failRecords.map((v: any) =>
+    const msg = res.data.failRecords.map((v) =>
       h("div", `行号:${v.lineNum}, 错误:${v.msg}`)
     );
     void message.error({

+ 1 - 1
src/features/userManagement/UserManagement.vue

@@ -360,7 +360,7 @@ async function handleImport() {
     await clickSearch();
   } else {
     // eslint-disable-next-line
-    const msg = res.data.failRecords.map((v: any) =>
+    const msg = res.data.failRecords.map((v) =>
       h("div", `行号:${v.lineNum}, 错误:${v.msg}`)
     );
     void message.error({

+ 133 - 128
src/types/index.ts

@@ -1,3 +1,9 @@
+export interface Pagination {
+  pageNo: number;
+  pageSize: number;
+  totalElements: number;
+}
+
 export interface Role {
   roleId: number;
   roleCode: "ORG_ADMIN" | "SUPER_ADMIN" | "ROOT_ORG_ADMIN" | "COURSE_ADMIN";
@@ -8,7 +14,28 @@ export type Course_Type = "PUBLIC" | "MAJOR";
 
 export type Privilege_Type = "COURSE" | "ORG";
 
-// Generated by https://quicktype.io
+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 CourseResponse extends Pagination {
+  content: Course[];
+}
 
 export interface ProjectCourse {
   courseCode: string;
@@ -57,29 +84,6 @@ export interface SasCourse {
   scoreRangeTotal: number; // 前端自用
 }
 
-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 CourseResponse extends Pagination {
-  content: Course[];
-}
-
 export interface RangeConfig {
   type: keyof RANGE_POINT_TYPE;
   baseScore: number;
@@ -96,6 +100,19 @@ export interface RANGE_POINT_TYPE {
   TOTAL_SCORE_LINE: "国家满分线";
 }
 
+export interface Paper {
+  courseCode: string;
+  courseName: string;
+  id: number;
+  paperName: string;
+  paperType: string;
+  totalCount: number;
+}
+
+export interface PaperResponse extends Pagination {
+  content: Paper[];
+}
+
 // 整体分析-试卷特征量数
 export interface SASPaper {
   allRange: number;
@@ -118,62 +135,6 @@ export interface SASPaper {
   totalScore: number;
 }
 
-export interface Paper {
-  courseCode: string;
-  courseName: string;
-  id: number;
-  paperName: string;
-  paperType: string;
-  totalCount: number;
-}
-
-export interface PaperResponse extends Pagination {
-  content: Paper[];
-}
-
-export interface Org {
-  code: string;
-  domainName: string;
-  enable: boolean;
-  id: number;
-  name: string;
-  updateTime: string;
-}
-
-export interface OrgResponse extends Pagination {
-  content: Org[];
-}
-
-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 SubOrgResponse extends Pagination {
-  content: SubOrg[];
-}
-
-export interface Pagination {
-  pageNo: number;
-  pageSize: number;
-  totalElements: number;
-}
-
-export interface SASPaperResponse extends Pagination {
-  content: SASPaper[];
-}
-
 export interface Project {
   changeInfo: {
     ITEM1: boolean;
@@ -199,37 +160,6 @@ export interface ProjectResponse extends Pagination {
   content: Project[];
 }
 
-// 试题题目编排,试卷特征量数,试题难度分组分布
-export interface SASQuestion {
-  answer: string;
-  avgScore: number;
-  coefficient: number;
-  courseId: number;
-  createTime: string;
-  difficulityGroupLevel: number[];
-  difficulityLevel: DifficulityLevel;
-  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;
-}
-
 interface LevelDetail {
   questionCount: number;
   fullScore: number;
@@ -241,6 +171,23 @@ export interface DifficulityLevel {
   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 SASPaper {
   allRange: number;
@@ -273,6 +220,37 @@ export interface DiscriminationLevel {
   bad: LevelDetail;
 }
 
+// 试题题目编排,试卷特征量数,试题难度分组分布
+export interface SASQuestion {
+  answer: string;
+  avgScore: number;
+  coefficient: number;
+  courseId: number;
+  createTime: string;
+  difficulityGroupLevel: number[];
+  difficulityLevel: DifficulityLevel;
+  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;
@@ -309,23 +287,6 @@ export interface SASQuestionGroup {
   zeroCount: number;
 }
 
-// 查询指定试卷
-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 User {
   createTime: string;
   createTimeStr: string;
@@ -350,3 +311,47 @@ export interface User {
 export interface UserResponse extends Pagination {
   content: User[];
 }
+
+export interface RootOrg {
+  code: string;
+  domainName: string;
+  enable: boolean;
+  id: number;
+  name: string;
+  updateTime: string;
+}
+
+export interface RootOrgResponse extends Pagination {
+  content: RootOrg[];
+}
+
+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 SubOrgResponse extends Pagination {
+  content: SubOrg[];
+}
+
+export interface SASPaperResponse extends Pagination {
+  content: SASPaper[];
+}
+
+export interface ImportResponse {
+  data: {
+    hasError: boolean;
+    failRecords: { lineNum: number; msg: string }[];
+  };
+}