import 'package:dio/dio.dart' hide Headers;
import 'package:making_school_asignment_app/common/job/annotated_class.dart';
import 'package:making_school_asignment_app/common/job/app_version.dart';
import 'package:making_school_asignment_app/common/job/class_item.dart';
import 'package:making_school_asignment_app/common/job/common/app_version_model.dart';
import 'package:making_school_asignment_app/common/job/common/base_app_version.dart';
import 'package:making_school_asignment_app/common/job/common/base_page_data.dart';
import 'package:making_school_asignment_app/common/job/enum_subject.dart';
import 'package:making_school_asignment_app/common/job/homework_details.dart';
import 'package:making_school_asignment_app/common/job/knowledge_points_grasp.dart';
import 'package:making_school_asignment_app/common/job/knowledge_report_detail.dart';
import 'package:making_school_asignment_app/common/job/marking_models/do_paper_details_param.dart';
import 'package:making_school_asignment_app/common/job/marking_models/do_paper_details_result.dart';
import 'package:making_school_asignment_app/common/job/marking_models/favor_param.dart';
import 'package:making_school_asignment_app/common/job/marking_models/original_manuscript_handwriting_params.dart';
import 'package:making_school_asignment_app/common/job/marking_models/review_submission_params.dart';
import 'package:making_school_asignment_app/common/job/student_history.dart';
import 'package:making_school_asignment_app/common/job/student_history_params.dart';
import 'package:making_school_asignment_app/common/job/student_item.dart';
import 'package:making_school_asignment_app/common/job/student_personal_info.dart';
import 'package:making_school_asignment_app/common/job/user_info_detail.dart';
import 'package:making_school_asignment_app/common/job/user_register_params.dart';
import 'package:making_school_asignment_app/common/job/work_student.dart';
import 'package:making_school_asignment_app/common/job/work_student_params.dart';
import 'package:making_school_asignment_app/page/home_page/children/homework_review/components/job_handwriting.dart';
import 'package:retrofit/retrofit.dart';

part 'retrofit_client.g.dart';

@RestApi(parser: Parser.JsonSerializable)
@Headers(<String, dynamic>{"Content-Type": "application/json"})
abstract class RetrofitClient {
  factory RetrofitClient(Dio dio, {String? baseUrl}) = _RetrofitClient;

  /* start 系统系列接口 */
  @POST("/api/infra/AppVersion/GetList")
  Future<BasePageData<AppVersionModel>?> getAppVersions(@Body() BaseAppVersion appVersion);

  /* start 系统系列接口 */

  @POST("/api/rbac/Auth/DcLogin")
  Future toLogin(@Field() String account, @Field() String password);

  @POST("/api/rbac/Auth/Register")
  Future<String> toRegister(@Body() UserRegisterParams params);

  @DELETE("/api/rbac/User/Delete")
  Future<String> toUserLogout(@Field() int id);

  @GET("/api/rbac/User/GetUser")
  Future<UserInfoDetail?> getUser(@Query('userId') String userId);

  //未批阅，已批阅列表
  @GET("/api/hms/Homework/GetList")
  Future<WorkStudent> getWorkList(@Queries() WorkStudentParams params);

  //获取科目,年级
  @GET("/api/app/Common/GetEnumInfos")
  Future<Map<String, List<EnumSubject>>> getEnumSubjectList(@Query('enumNames') List enumNames);

  //学生班级
  @GET("/api/rbac/SchoolUser/GetTeacherClassSubject")
  Future<List<ClassItem>> getStudentClass();

  //获取优先批阅状态学生列表
  @GET("/api/rbac/Student/GetPriorityAnnotateStudents")
  Future<List<StudentItem>> getStudentList(@Query('ClassId') String classId, @Query('Subject') int? subject);

  //待批阅列表
  @GET("/api/hms/Annotate/GetUnAnnotateList")
  Future<WorkStudent> getUnAnnotateList(@Queries() WorkStudentParams params);

  //已批阅列表
  @GET("/api/hms/Annotate/GetAnnotatedList")
  Future<WorkStudent> getAnnotatedList(@Queries() WorkStudentParams params);

  //获取批阅班级
  @GET("/api/hms/Annotate/Get")
  Future<List<AnnotatedClass>> getAnnotatedClassList(@Query('homeworkId') String homeworkId);

  //作业明细
  @GET("/api/hms/HmsReport/GetHomeworkDtls")
  Future<HomeworkDetails> getHomeworkDetails(@Query('homeworkId') String homeworkId, @Query('classId') String classId);

  //学生历史作业
  @GET("/api/hms/HmsReport/GetStudentHistory")
  Future<StudentHistory> getStudentHistory(@Queries() StudentHistoryParams params);

  //修改学生优先批阅状态
  @POST("/api/rbac/Student/PriorityAnnotateStudent")
  Future getAnnotateStudent(
      @Field() String classId, @Field() int studentId, @Field() bool priorityAnnotate, @Field() int? subject);

  //学生作业信息
  @GET("/api/hms/HmsReport/GetStudentHomework")
  Future<StudentPersonalInfo> getStudentHomework(
      @Query('HomeworkId') String homeworkId, @Query('StudentId') int studentId);

  //知识点掌握
  @GET("/api/hms/HmsReport/GetKnowledgeReport")
  Future<List<KnowledgePointsGrasp>> getKnowledgeReport(
      @Query('DateStart') String dateStart,
      @Query('DateEnd') String dateEnd,
      @Query('KnowledgeName') String knowledgeName,
      @Query('ClassId') String classId,
      @Query('Subject') int? subject);

  //知识点掌握详情
  @GET("/api/hms/HmsReport/GetKnowledgeReportDetail")
  Future<List<KnowledgeReportDetail>> getKnowledgeReportDetail(
      @Query('DateStart') String dateStart, @Query('DateEnd') String dateEnd, @Query('KnowledgeId') int knowledgeId);

  //学生
  @GET("/api/hms/HmsReport/GetQuestionStudentState")
  Future<List<Students>> getQuestionStudentState(@Query('HomeworkId') String homeworkId,
      @Query('TemplateId') int templateId, @Query('QuestionNo') String questionNo);

  //收集订正
  @POST("/api/hms/Homework/Collect")
  Future getCollect(@Field() String homeworkId);

  // ---------------------------    批阅主页   ----------------------
  // 收藏作业
  @POST("/api/hms/FavStudent/FavStudent")
  Future toFavStudent(@Body() FavorParam param);

  // 批阅作业详情
  @GET("/api/hms/Annotate/GetForAnnotate")
  Future<DoPaperDetailsResult> getDoPaperDetails(@Queries() DoPaperDetailsParam param);

  //收藏夹列表
  @GET("/api/hms/FavStudent/GetList")
  Future<BasePageData<HomeworkFavs>> getFavList(
      @Query('HomeworkName') String homeworkName, @Query('ClassId') String classId);

  //一键批阅 (默认未批阅的题目全部正确)
  @POST("/api/hms/Annotate/AllCorrect")
  Future getAllCorrect(@Field() String homeworkId, @Field() String classId);

  // 结束提交
  @POST("/api/hms/Annotate/OverAnnotate")
  Future overAnnotate(@Field() String homeworkId, @Field() String classId);

  // 批阅提交
  @POST("/api/hms/Annotate/AnnotateSubmit")
  Future reviewSubmission(@Body() ReviewSubmissionParams param);

  // 获取原稿笔记
  @GET("/api/hms/HmsReport/GetStudentPaperHandwriting")
  Future<JobHandwriting> getOriginalManuscriptHandwriting(@Queries() OriginalManuscriptHandwritingParams param);

  // OSS 上传key
  @GET("/api/infra/Oss/GetPresignedUri")
  Future getOssPresignedUri(@Query('key') String key);

  // 获取APP 版本
  @GET("/api/infra/AppVersion/Get")
  Future<AppVersion?> getLastAppVersion(
      @Query('appName') String appName, @Query('ftuType') int ftuType); // ftuType 1安卓 2IOS 3windows
}
