import 'package:json_annotation/json_annotation.dart';
import 'package:marking_app/common/model/enum/reportUserIdentity.dart';
import 'package:marking_app/common/model/report/marked_item.dart';

part 'user_info_report.g.dart';

@JsonSerializable()
class UserInfoReport extends Object {
  @JsonKey(name: 'Positions')
  List<Positions> positions;

  @JsonKey(name: 'positionIndex', defaultValue: 0)
  int positionIndex;

  @JsonKey(name: 'normal')
  bool normal;

  UserInfoReport({required this.positions, required this.positionIndex, this.normal = false});

  factory UserInfoReport.fromJson(Map<String, dynamic> srcJson) => _$UserInfoReportFromJson(srcJson);

  Map<String, dynamic> toJson() => _$UserInfoReportToJson(this);
}

@JsonSerializable()
class Positions extends Object {
  @JsonKey(name: 'Id')
  int id;

  @JsonKey(name: 'Name')
  String name;

  @JsonKey(name: 'SchoolId')
  int schoolId;

  @JsonKey(name: 'SchoolName')
  String schoolName;

  @JsonKey(name: 'GraduationYear')
  int graduationYear;

  @JsonKey(name: 'Grade')
  String grade;

  @JsonKey(name: 'ClassId')
  int classId;

  @JsonKey(name: 'ClassName')
  String? className;

  @JsonKey(name: 'SubjectId')
  int subjectId;

  @JsonKey(name: 'SubjectName')
  String? subjectName;

  @JsonKey(name: 'PositionType')
  int positionType;

  // {
  //       教委 = 1,
  //       校级 = 2,
  //       年级 = 3,
  //       班级 = 4,
  //       教师 = 5,
  //   }
  @JsonKey(name: 'PositionLevel')
  int positionLevel;

  @JsonKey(name: 'Status')
  int status;

  @JsonKey(name: 'markExams')
  List<MarkedItem>? markExams;

  @JsonKey(name: 'identityEnum')
  ReportUserIdentity identityEnum;

  Positions(this.id, this.name, this.schoolId, this.schoolName, this.graduationYear, this.grade, this.classId, this.className, this.subjectId, this.subjectName, this.positionType, this.positionLevel, this.status, {this.markExams, this.identityEnum = ReportUserIdentity.OCCUPY_POSITION}) {
    this.identityEnum = ReportUserIdentity.values[positionLevel];
  }

  factory Positions.fromJson(Map<String, dynamic> srcJson) => _$PositionsFromJson(srcJson);

  Map<String, dynamic> toJson() => _$PositionsToJson(this);
}
