/*
 * @Author: wangyang 1147192855@qq.com
 * @Date: 2022-07-13 11:29:05
 * @LastEditors: wangyang 1147192855@qq.com
 * @LastEditTime: 2022-09-27 17:51:16
 * @FilePath: \marking_app\lib\config\RequestClient.dart
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */

import 'package:dio/dio.dart';
import 'package:marking_app/common/config/request_config.dart';
import 'package:marking_app/common/model/common/base_page_data.dart';
import 'package:marking_app/common/model/common/base_structure_result.dart';
import 'package:marking_app/common/model/common/upload_img_secret_key.dart';
import 'package:marking_app/common/model/job/job_collect_params.dart';
import 'package:marking_app/common/model/job/job_concerned_with_student.dart';
import 'package:marking_app/common/model/job/job_concerned_with_student_params.dart';
import 'package:marking_app/common/model/job/job_data_report.dart';
import 'package:marking_app/common/model/job/job_do_marking_status_info.dart';
import 'package:marking_app/common/model/job/job_fav_student.dart';
import 'package:marking_app/common/model/job/job_favorite_model.dart';
import 'package:marking_app/common/model/job/job_knowledge_detail_student.dart';
import 'package:marking_app/common/model/job/job_knowledge_points.dart';
import 'package:marking_app/common/model/job/job_knowledge_points_detail.dart';
import 'package:marking_app/common/model/job/job_level_set_params.dart';
import 'package:marking_app/common/model/job/job_note_taking_trajectory.dart';
import 'package:marking_app/common/model/job/job_page_tab.dart';
import 'package:marking_app/common/model/job/job_report_join_class.dart';
import 'package:marking_app/common/model/job/job_report_knowledge_model.dart';
import 'package:marking_app/common/model/job/job_report_model.dart';
import 'package:marking_app/common/model/job/job_report_question_deatil_model.dart';
import 'package:marking_app/common/model/job/job_review_submission.dart';
import 'package:marking_app/common/model/job/job_student_goups.dart';
import 'package:marking_app/common/model/job/job_student_history.dart';
import 'package:marking_app/common/model/job/job_student_level.dart';
import 'package:marking_app/common/model/job/job_task_item.dart';
import 'package:marking_app/common/model/job/marking_text_question_job.dart';
import 'package:marking_app/common/model/job/marking_text_question_job_tab_params.dart';
import 'package:marking_app/common/model/job/review_again_list_params.dart';
import 'package:marking_app/common/model/job/upload_file_interface_config.dart';
import 'package:marking_app/common/model/job/upload_file_interface_config_params.dart';
import 'package:marking_app/common/model/marking/marking_abnormal_res.dart';
import 'package:marking_app/common/model/marking/marking_item.dart';
import 'package:marking_app/common/model/marking/marking_list_params.dart';
import 'package:marking_app/common/model/marking/marking_statistics.dart';
import 'package:marking_app/common/model/marking/marking_tag_single_params.dart';
import 'package:marking_app/common/model/marking/marking_text_question.dart';
import 'package:marking_app/common/model/marking/marking_text_question_params.dart';
import 'package:marking_app/common/model/marking/marking_text_question_tab.dart';
import 'package:marking_app/common/model/marking/marking_text_question_tab_params.dart';
import 'package:marking_app/common/model/marking/marking_text_question_tab_step_size.dart';
import 'package:marking_app/common/model/marking/rating_progress_model.dart';
import 'package:marking_app/common/model/marking/review_records_item.dart';
import 'package:marking_app/common/model/marking/review_records_params.dart';
import 'package:marking_app/common/model/marking/submit_exam_abnormal_params.dart';
import 'package:marking_app/common/model/marking/submit_exam_params.dart';
import 'package:marking_app/common/model/progress/progress_item.dart';
import 'package:marking_app/common/model/progress/progress_page_params.dart';
import 'package:marking_app/common/model/progress/progress_statistics.dart';
import 'package:marking_app/common/model/review/review_item.dart';
import 'package:marking_app/common/model/review/review_page_params.dart';
import 'package:marking_app/common/model/review/review_tab.dart';
import 'package:marking_app/common/model/sys/system_version.dart';
import 'package:marking_app/common/model/user/user_info.dart';
import 'package:retrofit/retrofit.dart' as the_retrofit;
import 'package:marking_app/common/model/user/user_login_params.dart';

part 'rest_client.g.dart';

@the_retrofit.RestApi()
@the_retrofit.Headers(<String, dynamic>{"Content-Type": "application/json"})
abstract class RestClient {
  factory RestClient(Dio dio, {String baseUrl}) = _RestClient;

  // 最新版本
  @the_retrofit.GET("/api/version/latest?mobileTypeEnum={mobileTypeEnum}")
  Future<BaseStructureResult<SystemVersion>> getLatestVersion(
      @the_retrofit.Path("mobileTypeEnum") int mobileTypeEnum); // 1 安卓  2 ios

  // 用户登录         /auth/login/exam-marking/user-mobile
  @the_retrofit.POST("/auth/login/exam-marking/user")
  Future<BaseStructureResult<dynamic>> toLogin(@the_retrofit.Body() UserLoginParams params);

  //获取图片上传秘钥
  @the_retrofit.GET("/api/img-svr/minio-cfg")
  Future<BaseStructureResult<UploadImgSecretKey>> getImageUploadKey();

  // 获取用户信息
  @the_retrofit.GET("/auth/info/cur-user")
  Future<BaseStructureResult<UserInfo>> getUserInfo(@the_retrofit.Header("Authorization") String token);

  // 阅卷列表 => 分页获取
  @the_retrofit.GET("/api/marking/list")
  Future<BaseStructureResult<BasePageData<MarkingItem>>> getMarkingsByPage(
      @the_retrofit.Queries() MarkingListParams params);

  // /api/marking/list

  // 进度 => 进度详情 分页获取
  @the_retrofit.GET("/api/marking/teacher-overview")
  Future<BaseStructureResult<BasePageData<ProgressItem>>> getProgressByPage(
      @the_retrofit.Path("markingId") String id, @the_retrofit.Queries() ProgressPageParams params);

  // 进度 => 进度详情 统计数据
  @the_retrofit.GET("/api/marking/{examSubjectId}/overview")
  Future<BaseStructureResult<ProgressStatistics>> getProgressStatistics(@the_retrofit.Path("examSubjectId") String id);

  // 回评 => 获取tab
  @the_retrofit.GET("/api/marking/{markingUserId}/review/tab")
  Future<BaseStructureResult<List<ReviewTab>>> getReviewTab(
      @the_retrofit.Path("markingUserId") String id, @the_retrofit.Query("markingUserId") int markingUserId);

  // 回评 => 获取tab 下分页
  @the_retrofit.GET("/api/marking/{markingUserId}/review/paged")
  Future<BaseStructureResult<BasePageData<ReviewItem>>> getReviewPage(
      @the_retrofit.Path("markingUserId") String id, @the_retrofit.Queries() ReviewPageParams params);

  // 阅卷 => 获取考试试题
  @the_retrofit.GET("/api/marking/question")
  Future<BaseStructureResult<MarkingTextQuestion>> getTestQuestionsOfExam(
      @the_retrofit.Queries() MarkingTextQuestionParams params);

  // 阅卷 => 获取考试tab（试题批次）
  @the_retrofit.GET("/api/marking/{markingUserId}/tab")
  Future<BaseStructureResult<List<MarkingTextQuestionTab>>> getTestQuestionsOfTab(
      @the_retrofit.Path("markingUserId") int markingUserId);

  // 阅卷 => 单个试题Tag阅卷详情
  @the_retrofit.GET("/api/marking/{markingUserId}/progress")
  Future<BaseStructureResult<MarkingTextQuestionTab>> getMarkingTagSingleDetails(
      @the_retrofit.Path("markingUserId") int markingUserId, @the_retrofit.Queries() MarkingTagSingleParams params);

  // 阅卷 => 获取考试tabs 下所有步长
  @the_retrofit.GET("/api/marking/q/interval")
  Future<BaseStructureResult<List<MarkingTextQuestionTabStepSize>>> getTestQuestionsOfTabStepSize(
      @the_retrofit.Query("examSubjectId") int examSubjectId);

  // 阅卷 => 获取考试tab下某次试题
  @the_retrofit.GET("/api/marking/{markingUserId}/detail")
  Future<BaseStructureResult<MarkingTextQuestion>> getTabOfExam(@the_retrofit.Path("markingUserId") int markingUserId,
      @the_retrofit.Queries() MarkingTextQuestionTabParams params);

  // 阅卷 => 提交考试试题
  @the_retrofit.PUT("/api/marking")
  Future<BaseStructureResult<bool>> submitTestQuestionsOfExam(@the_retrofit.Body() SubmitExamParams params);

  @the_retrofit.PUT("/api/marking/error")
  Future<BaseStructureResult<bool>> submitTestQuestionsOfExamAbnormal(
      @the_retrofit.Body() SubmitExamAbnormalParams params);

  // 阅卷 => 提交考试试题
  @the_retrofit.PUT("/api/marking/review")
  Future<BaseStructureResult<bool>> submitTestQuestionsOfExamReview(@the_retrofit.Body() SubmitExamParams params);

  // 阅卷 => 结束阅卷
  @the_retrofit.PUT("/api/marking/{markingUserId}/end")
  Future<BaseStructureResult<bool?>> endMarkingTask(@the_retrofit.Path("markingUserId") String markingUserId);

  // 阅卷 => 结束阅卷
  @the_retrofit.GET("/api/marking/original-paper")
  Future<BaseStructureResult<List<String>>> getViewOriginalVolume(
      @the_retrofit.Query("markingUserDetailId") String markingUserDetailId);

  // 阅卷 => 查看答案
  @the_retrofit.GET("/api/marking/answer")
  Future<BaseStructureResult<String>> getStandardAnswer(
      @the_retrofit.Query("examSubjectId") int examSubjectId, @the_retrofit.Query("questionNum") String questionNum);

  // 阅卷 => 获取任务列表种类统计信息
  @the_retrofit.GET("/api/marking/list/count")
  Future<BaseStructureResult<List<MarkingStatistics>>> getMarkingStatistics();

  // 阅卷 => 获取异常类型集合
  @the_retrofit.GET("/api/marking/errortypes")
  Future<BaseStructureResult<MarkingAbnormalRes>> getAbnormalTypes();

  // 阅卷 => 获取异常类型集合
  @the_retrofit.GET("/api/marking/{markingUserId}/exit")
  Future<BaseStructureResult> exitMarking(@the_retrofit.Path("markingUserId") int markingUserId);

  // 阅卷 => 获取异常类型集合
  @the_retrofit.GET("/api/marking/{markingUserId}/records")
  Future<BaseStructureResult<BasePageData<ReviewRecordsItem>>> getMarkingRecords(
      @the_retrofit.Path("markingUserId") String markingUserId, @the_retrofit.Queries() ReviewRecordsParams params);

  // 阅卷 => 获取异常详细信息
  @the_retrofit.GET("/api/marking/error-info")
  Future<BaseStructureResult<ExceptionInfo>> getMarkingQuestionsErrorInfo(
      @the_retrofit.Query("markingUserDetailId") int id);

  // 阅卷 => 获取仲裁详细信息
  @the_retrofit.GET("/api/marking/history-score")
  Future<BaseStructureResult<List<HistoricalScoring>>> getArbitrateOfHistoryScore(
      @the_retrofit.Query("markingUserDetailId") int id);

  // 阅卷 => 获取仲裁详细信息
  @the_retrofit.GET("/api/marking/rating-info")
  Future<BaseStructureResult<List<RatingProgressModel>>> getMarkingRatingInfo(
      @the_retrofit.Query("markingUserId") int id);

  // ------------------------------------------     作业    ------------------------------------------

  // 作业 => 作业列表
  @the_retrofit.GET("${RequestConfig.hwProxyKeywords}/api/Task")
  Future<BaseStructureResult<BasePageData<JobTaskItem>>> getJobsByPage(
      @the_retrofit.Queries() MarkingListParams params);

  // 作业 => 批改获取tabs
  @the_retrofit.GET("${RequestConfig.hwProxyKeywords}/api/Task/tabs")
  Future<BaseStructureResult<List<JobPageTab>>> getJobOfTabs(@the_retrofit.Query("taskId") int taskId);

  // 作业 => 批改获取tabs
  @the_retrofit.GET("${RequestConfig.hwProxyKeywords}/api/Marking/students")
  Future<BaseStructureResult<List<JobConcernedWithStudent>>> getJobWithStudents(
      @the_retrofit.Queries() JobConcernedWithStudentParams params);

  // 作业 => 获取考试tab下某次试题
  @the_retrofit.GET("${RequestConfig.hwProxyKeywords}/api/Task/detail")
  Future<BaseStructureResult<MarkingTextQuestionJob>> getJobTabOfExam(
      @the_retrofit.Queries() MarkingTextQuestionJobTabParams params);

  // 作业 => 提交
  @the_retrofit.POST("${RequestConfig.hwProxyKeywords}/api/Task")
  Future<BaseStructureResult> toSubmitMarking(@the_retrofit.Body() JobReviewSubmission params);

  // 作业 => 结束作业任务
  @the_retrofit.PUT("${RequestConfig.hwProxyKeywords}/api/Task/end")
  Future<BaseStructureResult> toEndReviewJob(@the_retrofit.Query("taskIds") List<int> taskIds);

  // 作业 => 获取考试tab下某次试题
  @the_retrofit.GET("${RequestConfig.hwProxyKeywords}/api/Task/questions")
  Future<BaseStructureResult<BasePageData<ReviewItem>>> toGoreviewAgainPage(
      @the_retrofit.Queries() ReviewAgainListParams params);

  // 作业 => 获取参考答案
  @the_retrofit.GET("${RequestConfig.hwProxyKeywords}/api/Task/answer")
  Future<BaseStructureResult<String>> getAnswer(
    @the_retrofit.Query("taskId") int taskId,
    @the_retrofit.Query("questionNum") String questionNum,
  );

  // 作业 => 上传图片请求参数
  @the_retrofit.GET("${RequestConfig.hwProxyKeywords}/api/Upload")
  Future<BaseStructureResult<UploadFileInterfaceConfig>> getUploadFile(
      @the_retrofit.Queries() UploadFileInterfaceConfigParams params);

  // 作业 => 获取参考答案
  @the_retrofit.GET("${RequestConfig.hwProxyKeywords}/api/Dpc/studentAnswerHandwriting")
  Future<BaseStructureResult<JobNoteTakingTrajectory>> getNoteTakingTrajectory(
      @the_retrofit.Query("paperId") int paperId, @the_retrofit.Query("questionNo") String questionNo);

  // 作业 => 查询作业是否收藏
  @the_retrofit.GET("${RequestConfig.hwProxyKeywords}/api/Dpc/collect")
  Future<BaseStructureResult<bool>> getJobCollect(@the_retrofit.Query("taskId") int taskId,
      @the_retrofit.Query("studentId") int studentId, @the_retrofit.Query("paperId") int paperId);

  // 作业 => 作业优先批阅取消
  @the_retrofit.POST("/api/read/cancel-job-read-level")
  Future<BaseStructureResult<bool>> jobPriorityReviewCancel(
      @the_retrofit.Field("jobId") int jobId, @the_retrofit.Field("studentId") int studentId);

  // 作业 => 作业优先批阅加入
  @the_retrofit.POST("/api/read/join-read-level")
  Future<BaseStructureResult> jobPriorityReviewJoin(
      @the_retrofit.Field("jobId") int jobId, @the_retrofit.Field("studentId") int studentId);

// 作业 => 查询作业是否收藏
  @the_retrofit.POST("${RequestConfig.hwProxyKeywords}/api/Dpc/collect")
  Future<BaseStructureResult<bool>> toJobFavoriteCancel(@the_retrofit.Body() JobCollectParams params);

  // 作业 => 一键批阅
  @the_retrofit.POST("${RequestConfig.hwProxyKeywords}/api/Marking/auto")
  Future<BaseStructureResult<bool>> toJobOneClickReview(@the_retrofit.Field() int taskId);

  // 作业 => 获取作业报告
  @the_retrofit.GET("/api/jobs/job-report")
  Future<BaseStructureResult<JobReportModel>> getJobReport(@the_retrofit.Queries() Map<String, dynamic> params);

  // 作业 => 获取作业班级列表（参与班级）
  @the_retrofit.GET("/api/jobs/student-job-for-class")
  Future<BaseStructureResult<List<JobReportJoinClass>>> getJobReportJoinClasses(@the_retrofit.Query("jobId") int jobId);

  // 作业 => 或者作业在当前题型下批阅情况
  @the_retrofit.GET("${RequestConfig.hwProxyKeywords}/api/Marking/tab")
  Future<BaseStructureResult<JobDoMarkingStatusInfo>> getJobPageIndexInfo(
      @the_retrofit.Query("taskId") int taskld, @the_retrofit.Query("pageIndex") int pagelndex);

  // 作业 => 报告 ==> 获取知识点详情
  @the_retrofit.GET("/api/jobs/job-report-knowledge-detail")
  Future<BaseStructureResult<List<JobReportKnowledgeModel>>> getDetailKnowledge(
      @the_retrofit.Query("jobid") int jobId, @the_retrofit.Query("knowid") int knowid);

  // 作业 => 报告 ==> 获取知识点详情
  @the_retrofit.GET("/api/jobs/job-report-question-detail")
  Future<BaseStructureResult<List<JobReportQuestionDeatilModel>>> getJobReportQuestionDetail(
      @the_retrofit.Query("jobid") int jobId, @the_retrofit.Query("questionid") int questionid);

  // 作业 => 列表 ==> 参与班级列表
  @the_retrofit.GET("${RequestConfig.hwProxyKeywords}/api/Task/tasks")
  Future<BaseStructureResult<List<MarkingTasks>>> getJobListParticipateInClass(
      @the_retrofit.Query("markingId") int jobId);

  // 作业 => 作业收藏数量
  @the_retrofit.GET("/dpc-api/api/read/job-favorite-count-by-class")
  Future<BaseStructureResult<List<JobFavoriteModel>>> getListOfJobFavoriteNumber(
      @the_retrofit.Query("jobid") int jobId);

  // 作业 => 作业收藏列表
  @the_retrofit.GET("/api/jobs/fav-student-jobs")
  Future<BaseStructureResult<JobFavStudent>> getListOfJobFavorites(
    @the_retrofit.Query("JobId") int jobId,
    @the_retrofit.Query("JobName") String jobName,
    @the_retrofit.Query("className") String? className,
    @the_retrofit.Query("PageSize") int pageSize,
  );

  // 作业 => 作业收藏列表
  @the_retrofit.POST("${RequestConfig.hwProxyKeywords}/dpc-api/api/read/cancel-favorite")
  Future<BaseStructureResult<bool>> toJobCancelFavorite(
      @the_retrofit.Field() int jobId, @the_retrofit.Field() int studentId);

  // 作业 => 数据快查
  @the_retrofit.GET("/api/read/job-data-center-report")
  Future<BaseStructureResult<JobDataReport>> getJobDataCenterReport(
      @the_retrofit.Queries() Map<String, dynamic> params);

// 作业 => 数据快查--个人
  @the_retrofit.GET("/api/read/job-data-center-student-report")
  Future<BaseStructureResult<StudentDetails>> getJobPersonalReport(@the_retrofit.Queries() Map<String, dynamic> params);

  // 作业 => 优先批阅，学生分组列表
  @the_retrofit.GET("/api/read/job-read-level-student-groups")
  Future<BaseStructureResult<List<JobStudentGroups>>> getJobLevelStudentGroups(
      @the_retrofit.Query("account") String account);

  // 作业 => 优先批阅，优先批阅列表
  @the_retrofit.GET("/api/read/job-read-level")
  Future<BaseStructureResult<List<JobStudentLevel>>> getJobReadLevel(
      @the_retrofit.Query("GroupId") String groupId, @the_retrofit.Query("ReadLevel") int readLevel);

  // 作业 => 取消/设置优先
  @the_retrofit.POST("/api/read/jc-job-read-level")
  Future<BaseStructureResult> getSetJobReadLevel(@the_retrofit.Body() JobLevelSetParams params);

  // 作业 => 取消收藏
  @the_retrofit.POST("/api/jobs/de-fav-student-job")
  Future<BaseStructureResult> getJobDeFavorites(@the_retrofit.Field("jobId") int jobId,
      @the_retrofit.Field("studentId") int studentId, @the_retrofit.Field("questionPage") int questionPage);

  // 作业 => 学生作业详情历史
  @the_retrofit.GET("/api/read/student-job-history")
  Future<BaseStructureResult<JobStudentHistory>> getStudentJobHistory(
      @the_retrofit.Query("StudentId") int studentId,
      @the_retrofit.Query("IsPaper") bool isPaper,
      @the_retrofit.Query("DateStart") String? dateStart,
      @the_retrofit.Query("DateEnd") String? dateEnd,
      @the_retrofit.Query("Page") int page,
      @the_retrofit.Query("PageSize") int pageSize,
      );

  // 作业 => 知识点掌握
  @the_retrofit.GET("/api/jobs/knowledge-report")
  Future<BaseStructureResult<List<KnowledgePoints>>> getKnowledgeReport(
      @the_retrofit.Query("dateStart") String? dateStart,
      @the_retrofit.Query("dateEnd") String? dateEnd,
      @the_retrofit.Query("knowledgeName") String? knowledgeName,
      );

  // 作业 => 知识点掌握详情
  @the_retrofit.GET("/api/jobs/knowledge-detail-report")
  Future<BaseStructureResult<List<KnowledgePointsDetail>>> getKnowledgeReportDetail(
      @the_retrofit.Query("KnowledgeId") int knowledgeId,
      );

  // 作业 => 知识点掌握详情人员名单
  @the_retrofit.GET("/api/jobs/knowledge-question-detail/{questionid}")
  Future<BaseStructureResult<List<JobKnowledgeDetailStudent>>> getKnowledgeStudent(
      @the_retrofit.Path("questionid") int questionid,
      );

  // 作业 => 知识点掌握详情原卷图
  @the_retrofit.GET("/api/jobs/question-paper-img/{sectionid}/{questionno}")
  Future<BaseStructureResult<String>> getKnowledgeImg(
      @the_retrofit.Path("sectionid") int questionid,
      @the_retrofit.Path("questionno") String questionno,
      );
}
