package com.ssj.service.kmt.service;


import com.ssj.bean.kmt.kmt.domain.KmtExerciseBook;
import com.ssj.bean.kmt.kmt.domain.KmtExerciseQuestion;
import com.ssj.framework.core.security.exception.CommonException;
import com.ssj.framework.core.util.ResponseEntity;
import com.ssj.service.conch.common.request.PageReq;
import com.ssj.service.kmt.dto.ExerciseBookCourseDTO;
import com.ssj.service.kmt.dto.ExerciseQuetionDto;
import com.ssj.service.kmt.exercise.request.SubmitAnswerProofreadResultReq;
import com.ssj.service.kmt.request.*;

import java.util.List;
import java.util.Map;

public interface KmtExerciseService {

    /**
     * 修改题目
     * @return
     */
    ResponseEntity updateQuestion(QuestionUpdateRequest request);

    /**
     * 打回题目，审核打回给加工人员重加工，加工打回给ai
     * @param userId 审核人
     */
    ResponseEntity questionRollback(String userId, QuestionRollbackRequest request) throws CommonException;

    /**
     * kmt题目打回
     * @param userId
     * @param request
     * @return
     */
    ResponseEntity kmtQuestionRollback(String userId, KmtQuestionRollbackRequest request);

    /**
     * 发布题目
     * @param request 题目id
     * @param userId 审核人
     */
    ResponseEntity publishQuestion(QuestionPublishRequest request, String userId) throws CommonException;

    /**
     * 发布kmt题目
     * @param request
     * @param userId
     * @return
     */
    ResponseEntity publishKmtQuestion(KmtQuestionPublishRequest request, String userId);

    /**
     * 提交审核
     * @param questionIdList 题目id
     * @param detailIds 知识点列表
     * @param userId 加工人
     */
    void submit2Auditing(List<String> questionIdList, List<HowDetailPointsRequest> detailIds, String userId) throws CommonException;


    /**
     * 提交审核
     * @param request
     * @param userId 加工人
     */
    ResponseEntity submit2AuditingV1(AuditingV1Request request, String userId);

    /**
     * 分配题目，根据条件选择题目，条件优先级为：课时id->单元id->练习册id
     */
    void distributeQuestions(QuestionDistributeRequest request);

    /**
     * 根据条件查询练习册课时列表
     * @param request
     */
    List<ExerciseBookCourseDTO> getBookExerciseList(QuestionDistributeRequest request);

    /**
     * 保存提交审核
     * @param request
     */
    ResponseEntity submitKmtQuestions2Auditing (AuditingRequest request, String userId);

    /**
     * 添加es记录
     * @param questions
     */
    void updateEsKmtExerciseQuestionKnow(List<KmtExerciseQuestion> questions);

    /**
     * 删除题目
     * @param questionId
     */
    void deleteKmtQuestion (String questionId, String userId);

    /**
     * 答案校对提交结果
     * @param req
     * @return
     */
    ResponseEntity submitAnswerProofreadResult (SubmitAnswerProofreadResultReq req);

    /**
     * 答案校对提交答案
     * @param request 入参
     */
    ResponseEntity answerProofreadSubmitAnswer(AnswerProofreadSubmitAnswerRequest request);

    /**
     * 查询答案校对本数
     * @param userId
     * @return
     */
    ResponseEntity teacherAnswerProofreadDetail(String userId);


    /**
     * 题目报错
     * @param userId
     * @param request
     * @return
     */
    ResponseEntity questionsError(String userId, QuestionRollbackRequest request);

    /**
     * 查询报错题目列表
     * @param req
     * @param userId
     * @return
     */
    Map<String, Object> findExerciseErrorQuestions(PageReq req, String userId);

    /**
     * 查询题目的信息
     * @param kmtExerciseQuestions
     */
    void appendQuestionDataFromJSONFile (List<KmtExerciseQuestion> kmtExerciseQuestions);

    /**
     * 查询题目信息
     * @param kmtExerciseQuestions
     */
    void appendQuestionDtoDataFromJSONFile(List<ExerciseQuetionDto> kmtExerciseQuestions);

    /**
     * 往know查询出来的题目里加入题目信息
     * @param questions
     */
    void appendQuestionMapFromJSONFile (List<Map<String, Object>> questions);

    /**
     * 保存题目信息
     * @param kmtExerciseQuestions
     */
    void saveQuestionData2JSONFile (List<KmtExerciseQuestion> kmtExerciseQuestions);

    /**
     * 生成练习册json文件相对路径
     * @param exerciseBook
     * @param id
     * @return
     */
    String getQuestionJSONPath (KmtExerciseBook exerciseBook, String id);

    /**
     * 生成kmtjson文件相对路径
     * @param courseName
     * @param id
     * @return
     */
    String getKmtQuestionJSONPath (String courseName, String id);

    ResponseEntity updateRollbackUserId();
}
