Commit 11a661e7 authored by YangZhaoJun1's avatar YangZhaoJun1

修改查询练习接口

parent e6615292
...@@ -155,14 +155,14 @@ public class TQuestionController extends PaginationController<TQuestion> { ...@@ -155,14 +155,14 @@ public class TQuestionController extends PaginationController<TQuestion> {
@GetMapping(value = "/queryQuestionsByChap_IdAndQtype") @GetMapping(value = "/queryQuestionsByChap_IdAndQtype")
public Result queryBChapters(String chapterId) { public Result queryBChapters(String chapterId) {
Map<String, Object> map = new HashedMap(); Map<String, Object> map = new HashedMap();
String s = new String(); String num = "";
map.put("List1",tQuestionServiceImpl.queryQuestionsByChap_IdAndQtype(chapterId, "1")); map.put("List1",tQuestionServiceImpl.queryQuestionsByChap_IdAndQtype(chapterId, "1"));
map.put("List2",tQuestionServiceImpl.queryQuestionsByChap_IdAndQtype(chapterId, "2")); map.put("List2",tQuestionServiceImpl.queryQuestionsByChap_IdAndQtype(chapterId, "2"));
map.put("List3",tQuestionServiceImpl.queryQuestionsByChap_IdAndQtype(chapterId, "3")); map.put("List3",tQuestionServiceImpl.queryQuestionsByChap_IdAndQtype(chapterId, "3"));
s = "NumOf1 : "+tQuestionServiceImpl.queryNumByType("1")+ num = "NumOf1 : "+tQuestionServiceImpl.queryNumByType("1")+
"NumOf2 : "+tQuestionServiceImpl.queryNumByType("2")+ "NumOf2 : "+tQuestionServiceImpl.queryNumByType("2")+
"NumOf3 : "+tQuestionServiceImpl.queryNumByType("3"); "NumOf3 : "+tQuestionServiceImpl.queryNumByType("3");
map.put("Num",s); map.put("Num",num);
return Result.builder(new PersistModel(1), return Result.builder(new PersistModel(1),
MessageConstant.MESSAGE_ALERT_SUCCESS, MessageConstant.MESSAGE_ALERT_SUCCESS,
MessageConstant.MESSAGE_ALERT_ERROR, MessageConstant.MESSAGE_ALERT_ERROR,
......
...@@ -49,21 +49,19 @@ public interface TQuestionRepository extends BaseMapper<TQuestion> { ...@@ -49,21 +49,19 @@ public interface TQuestionRepository extends BaseMapper<TQuestion> {
"</foreach></script>") "</foreach></script>")
int insertOptionsList(List<TQuestionOptions> optionList); int insertOptionsList(List<TQuestionOptions> optionList);
@Select("<script>select q.qtitle,q.qdesc,qo.alias,qo.describe" @Select("<script>select q.business_id,q.qtitle,q.qdesc\n" +
+"from t_paper_chapter pc" "from t_paper_chapter pc \n" +
+"left join t_paper_chapter_section pcs on pcs.pc_id = pc.business_id" "left join t_paper p on p.pc_id = pc.business_id \n" +
+"left join t_paper p on p.pc_id = pc.business_id" "left join t_paper_detail pd on pd.p_id = p.business_id \n" +
+"left join t_paper_detail pd on pd.p_id = p.business_id" "left join t_paper_section ps on ps.business_id = pd.ps_id \n" +
+"left join t_paper_section ps on ps.business_id = pd.ps_id" "left join t_question q on q.business_id = pd.q_id "
+"left join t_question q on q.business_id = pd.q_id"
+"left join t_question_options qo on qo.qid = q.business_id"
+"where pc.chap_id = #{chapterId} and q.qtype = #{qtype}</script>" +"where pc.chap_id = #{chapterId} and q.qtype = #{qtype}</script>"
) )
@ResultMap(value = "BaseResultMap" ) @ResultMap(value = "BaseResultMap" )
List<TQuestion> queryQuestionsByChap_IdAndQtype( @Param("chapterId") String chapterId, @Param("qtype") String qtype); List<TQuestion> queryQuestionsByChap_IdAndQtype( @Param("chapterId") String chapterId, @Param("qtype") String qtype);
@Select("<script>select q_num from t_paper_chapter_section where q_type = #{qtype}<script>") @Select("<script>select q_num from t_paper_chapter_section where q_type = #{qtype}</script>")
String queryNumByType(String qtype); String queryNumByType(String qtype);
} }
...@@ -158,8 +158,14 @@ public class TQuestionServiceImpl implements TQuestionService { ...@@ -158,8 +158,14 @@ public class TQuestionServiceImpl implements TQuestionService {
@Override @Override
public List<TQuestion> queryQuestionsByChap_IdAndQtype(String chapterId, String qtype) { public List<TQuestion> queryQuestionsByChap_IdAndQtype(String chapterId, String qtype) {
return tQuestionRepository.queryQuestionsByChap_IdAndQtype(chapterId,qtype); List<TQuestion> tQuestions = tQuestionRepository.queryQuestionsByChap_IdAndQtype(chapterId,qtype);
for(TQuestion tQuestion : tQuestions){
if(!qtype.equals("3")){
List<TQuestionOptions> options = tQuestionOptionsRepository.queryTQuestionOptions(tQuestion.getBusinessId());
tQuestion.setOptions(options);
}
}
return tQuestions;
} }
@Override @Override
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment