| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- package com.nju.edu.eval.thirdparty.thirdpartyImpl;
- import cn.seecoder.bok.client.SeecoderBokClient;
- import cn.seecoder.bok.common.vo.KnowledgeNodeVO;
- import cn.seecoder.bok.common.vo.QuestionVO;
- import com.nju.edu.eval.model.vo.question.CompleteQuestionVO;
- import com.nju.edu.eval.model.vo.question.QuestionStemListVO;
- import com.nju.edu.eval.model.vo.question.QuestionStemVO;
- import com.nju.edu.eval.thirdparty.QuestionThirdPartyService;
- import com.nju.edu.eval.util.BeanCopyUtil;
- import org.springframework.beans.BeanUtils;
- import org.springframework.beans.factory.annotation.Value;
- import org.springframework.data.domain.Page;
- import org.springframework.data.domain.Pageable;
- import org.springframework.stereotype.Component;
- import javax.annotation.PostConstruct;
- import java.util.ArrayList;
- import java.util.List;
- import java.util.Optional;
- /**
- * @author mars
- * 封装调用的题库的第三方服务
- */
- @Component
- public class QuestionThirdPartyServiceImpl implements QuestionThirdPartyService {
- @Value("${seec-bok-client.host}")
- private String host;
- private SeecoderBokClient client;
- @PostConstruct
- public void init() {
- //TODO
- client = new SeecoderBokClient(host);
- }
- @Override
- public Optional<CompleteQuestionVO> getQuestionById(String id) {
- Optional<QuestionVO> response = client.getQuestionById(id);
- CompleteQuestionVO res = new CompleteQuestionVO();
- response.ifPresent(questionVO -> BeanUtils.copyProperties(questionVO, res));
- return Optional.of(res);
- }
- @Override
- public List<CompleteQuestionVO> getRecommendQuestions(List<String> knowledgeList, int expectedDifficulty) {
- List<CompleteQuestionVO> questionVO = new ArrayList<>();
- return questionVO;
- }
- @Override
- public QuestionStemListVO getQuestionList(String stem, List<String> tags, List<String> knowledgeIds, Pageable pageable) {
- Page<QuestionVO> questionVOPageList = client.getQuestionList(stem, tags, knowledgeIds, pageable);
- return new QuestionStemListVO(BeanCopyUtil.copyListProperties(questionVOPageList.toList(), QuestionStemVO::new), (int) questionVOPageList.getTotalElements());
- }
- @Override
- public List<KnowledgeNodeVO> getKnowledgeNode(String name) {
- return client.getKnowledgeNode(name);
- }
- }
|