You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
remotebelongstous/src/main/java/com/shanzhu/oe/serviceimpl/PaperServiceImpl.java

81 lines
2.1 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

package com.shanzhu.oe.serviceimpl;
import com.shanzhu.oe.entity.FillQuestion;
import com.shanzhu.oe.entity.JudgeQuestion;
import com.shanzhu.oe.entity.MultiQuestion;
import com.shanzhu.oe.entity.PaperManage;
import com.shanzhu.oe.mapper.PaperMapper;
import com.shanzhu.oe.service.PaperService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* 试卷 服务层实现类
*
* @author: ShanZhu
* @date: 2023-11-20
*/
@Service
@RequiredArgsConstructor
public class PaperServiceImpl implements PaperService {
private final PaperMapper paperMapper;
private final JudgeQuestionServiceImpl judgeQuestionService;
private final MultiQuestionServiceImpl multiQuestionService;
private final FillQuestionServiceImpl fillQuestionService;
/**
* 查询所有试卷
*
* @return 试卷
*/
@Override
public List<PaperManage> findAll() {
return paperMapper.findAll();
}
/**
* 添加试卷
*
* @param paperManage 试卷信息
* @return 结果
*/
@Override
public Integer add(PaperManage paperManage) {
return paperMapper.add(paperManage);
}
/**
* 获取试卷总分
*
* @param paperId 试卷id
* @return 分数
*/
@Override
public Integer getMaxScore(Integer paperId) {
List<MultiQuestion> multiQuestionRes = multiQuestionService.findByIdAndType(paperId); //选择题题库 1
List<FillQuestion> fillQuestionsRes = fillQuestionService.findByIdAndType(paperId); //填空题题库 2
List<JudgeQuestion> judgeQuestionRes = judgeQuestionService.findByIdAndType(paperId); //判断题题库 3
return 2 * (multiQuestionRes.size() + fillQuestionsRes.size() + judgeQuestionRes.size());
}
/**
* 删除试卷中的某条试题
*
* @param paperId 试卷id
* @param type 题目类型。1选择2填空3判断
* @param questionId 题目id
*/
@Override
public void delete(String paperId, String type, String questionId) {
paperMapper.delete(paperId, type, questionId);
}
}