QuestionMapper.xml 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper
  3. PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5. <mapper namespace="com.zhongzheng.modules.bank.mapper.QuestionMapper">
  6. <resultMap type="com.zhongzheng.modules.bank.domain.Question" id="QuestionResult">
  7. <result property="questionId" column="question_id"/>
  8. <result property="content" column="content"/>
  9. <result property="type" column="type"/>
  10. <result property="answerQuestion" column="answer_question"/>
  11. <result property="status" column="status"/>
  12. <result property="createTime" column="create_time"/>
  13. <result property="updateTime" column="update_time"/>
  14. <result property="analysisContent" column="analysis_content"/>
  15. <result property="imgUrl" column="img_url"/>
  16. <result property="jsonStr" column="json_str"/>
  17. <result property="prefixName" column="prefix_name"/>
  18. <result property="knowledgeIds" column="knowledge_ids"/>
  19. <result property="publishStatus" column="publish_status"/>
  20. <result property="code" column="code"/>
  21. </resultMap>
  22. <resultMap type="com.zhongzheng.modules.bank.vo.QuestionVo" id="QuestionResultVo">
  23. <result property="questionId" column="question_id"/>
  24. <result property="content" column="content"/>
  25. <result property="type" column="type"/>
  26. <result property="answerQuestion" column="answer_question"/>
  27. <result property="status" column="status"/>
  28. <result property="analysisContent" column="analysis_content"/>
  29. <result property="imgUrl" column="img_url"/>
  30. <result property="jsonStr" column="json_str"/>
  31. <result property="prefixName" column="prefix_name"/>
  32. <result property="knowledgeIds" column="knowledge_ids"/>
  33. <result property="publishStatus" column="publish_status"/>
  34. <result property="code" column="code"/>
  35. <collection property="businessList" column="question_id" select="findBusinessList" />
  36. <collection property="knowledgeList" column="knowledge_ids" select="findKnowledge"/>
  37. </resultMap>
  38. <select id="findKnowledge" resultMap="ExamKnowledge">
  39. SELECT
  40. ek.knowledge_name,
  41. ek.knowledge_id
  42. FROM
  43. exam_knowledge ek
  44. WHERE
  45. FIND_IN_SET( ek.knowledge_id, #{knowledge_ids} )
  46. </select>
  47. <select id="findBusinessList" resultMap="QuestionBusiness">
  48. SELECT
  49. qb.education_type_id,
  50. qb.business_id,
  51. qb.project_id,
  52. qb.subject_id,
  53. qb.type as business_type,
  54. cet.education_name,
  55. cpt.project_name,
  56. cb.business_name,
  57. cs.subject_name
  58. FROM
  59. question_business qb
  60. LEFT JOIN course_education_type cet ON qb.education_type_id = cet.id
  61. LEFT JOIN course_project_type cpt ON qb.project_id = cpt.id
  62. LEFT JOIN course_business cb ON qb.business_id = cb.id
  63. LEFT JOIN course_subject cs ON cs.id = qb.subject_id
  64. WHERE
  65. qb.major_id=#{question_id} and qb.type = 1
  66. </select>
  67. <resultMap type="com.zhongzheng.modules.bank.domain.QuestionBusiness" id="QuestionBusiness">
  68. <result property="id" column="id"/>
  69. <result property="subjectId" column="subject_id"/>
  70. <result property="educationTypeId" column="education_type_id"/>
  71. <result property="businessId" column="business_id"/>
  72. <result property="projectId" column="project_id"/>
  73. <result property="educationName" column="education_name"/>
  74. <result property="projectName" column="project_name"/>
  75. <result property="businessName" column="business_name"/>
  76. <result property="subjectName" column="subject_name"/>
  77. <result property="type" column="business_type"/>
  78. </resultMap>
  79. <resultMap type="com.zhongzheng.modules.exam.domain.ExamKnowledge" id="ExamKnowledge">
  80. <result property="knowledgeId" column="knowledge_id"/>
  81. <result property="knowledgeName" column="knowledge_name"/>
  82. </resultMap>
  83. <select id="selectList" parameterType="com.zhongzheng.modules.bank.bo.QuestionQueryBo" resultMap="QuestionResultVo">
  84. SELECT DISTINCT
  85. q.*
  86. FROM
  87. question q
  88. LEFT JOIN question_business qb ON q.question_id = qb.major_id
  89. AND qb.type = 1
  90. WHERE
  91. 1 = 1
  92. <if test="status != null and status.size()!=0 ">
  93. AND q.status in
  94. <foreach collection="status" item="item" index="index" open="(" close=")" separator=",">
  95. #{item}
  96. </foreach>
  97. </if>
  98. <if test="educationTypeId != null and educationTypeId != ''">
  99. AND qb.education_type_id = #{educationTypeId}
  100. </if>
  101. <if test="subjectId != null and subjectId != ''">
  102. AND qb.subject_id = #{subjectId}
  103. </if>
  104. <if test="businessId != null and businessId != ''">
  105. AND qb.business_id = #{businessId}
  106. </if>
  107. <if test="prefixName != null and prefixName != ''">
  108. AND q.prefix_name like concat('%', #{prefixName}, '%')
  109. </if>
  110. <if test="pageSizeSelf != null and pageSizeSelf != ''">
  111. LIMIT #{currIndex} , #{pageSizeSelf}
  112. </if>
  113. GROUP BY
  114. q.question_id
  115. ORDER BY q.question_id DESC
  116. </select>
  117. <select id="selectList_COUNT" resultType="Long">
  118. SELECT
  119. count(distinct q.question_id)
  120. FROM
  121. question q
  122. LEFT JOIN question_business qb ON q.question_id = qb.major_id and qb.type = 1
  123. WHERE
  124. 1 = 1
  125. <if test="status != null and status.size()!=0 ">
  126. AND q.status in
  127. <foreach collection="status" item="item" index="index" open="(" close=")" separator=",">
  128. #{item}
  129. </foreach>
  130. </if>
  131. <if test="educationTypeId != null and educationTypeId != ''">
  132. AND qb.education_type_id = #{educationTypeId}
  133. </if>
  134. <if test="subjectId != null and subjectId != ''">
  135. AND qb.subject_id = #{subjectId}
  136. </if>
  137. <if test="businessId != null and businessId != ''">
  138. AND qb.business_id = #{businessId}
  139. </if>
  140. <if test="prefixName != null and prefixName != ''">
  141. AND q.prefix_name like concat('%', #{prefixName}, '%')
  142. </if>
  143. </select>
  144. </mapper>