package com.qmth.distributed.print.business.bean.dto.report;

import com.google.gson.reflect.TypeToken;
import com.qmth.distributed.print.business.bean.result.FinalScoreResult;
import com.qmth.distributed.print.business.entity.TRExamStudent;
import com.qmth.teachcloud.common.util.GsonUtil;
import io.swagger.annotations.ApiModelProperty;

import java.io.Serializable;
import java.util.List;
import java.util.Objects;

/**
 * @Description: 报告课程考核成绩评价明细结果-考生dto
 * @Param:
 * @return:
 * @Author: wangliang
 * @Date: 2024/2/26
 */
public class ReportExamStudentDto implements Serializable {

    @ApiModelProperty(value = "考生姓名")
    private String name;

    @ApiModelProperty(value = "学号")
    private String studentCode;

    @ApiModelProperty(value = "行政班级")
    private String administrativeClass;

    @ApiModelProperty(value = "综合成绩")
    private Double score;

    @ApiModelProperty(value = "课程目标集合")
    private List<ReportExamStudentTargetDto> targetList;

    public ReportExamStudentDto() {

    }

    public ReportExamStudentDto(TRExamStudent trExamStudent) {
        this.name = trExamStudent.getName();
        this.studentCode = trExamStudent.getStudentCode();
        this.administrativeClass = trExamStudent.getAdministrativeClass();
        this.score = trExamStudent.getScore();
        this.targetList = GsonUtil.fromJson(trExamStudent.getResultDetail(), new TypeToken<List<ReportExamStudentTargetDto>>() {
        }.getType());
    }

    public ReportExamStudentDto(String name, String studentCode, String administrativeClass, Double score, List<ReportExamStudentTargetDto> targetList) {
        this.name = name;
        this.studentCode = studentCode;
        this.administrativeClass = administrativeClass;
        this.score = score;
        this.targetList = targetList;
    }

    public ReportExamStudentDto(FinalScoreResult finalScoreResult) {
        this.name = finalScoreResult.getName();
        this.studentCode = finalScoreResult.getStudentCode();
        this.administrativeClass = finalScoreResult.getAdministrativeClass();
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getStudentCode() {
        return studentCode;
    }

    public void setStudentCode(String studentCode) {
        this.studentCode = studentCode;
    }

    public String getAdministrativeClass() {
        return administrativeClass;
    }

    public void setAdministrativeClass(String administrativeClass) {
        this.administrativeClass = administrativeClass;
    }

    public Double getScore() {
        return Objects.isNull(score) ? 0.0d : score;
    }

    public void setScore(Double score) {
        this.score = score;
    }

    public List<ReportExamStudentTargetDto> getTargetList() {
        return targetList;
    }

    public void setTargetList(List<ReportExamStudentTargetDto> targetList) {
        this.targetList = targetList;
    }
}
