QuestionInfoMapper.xml 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <mapper namespace="com.diagbot.mapper.QuestionInfoMapper">
  4. <!-- 通用查询映射结果 -->
  5. <resultMap id="BaseResultMap" type="com.diagbot.entity.QuestionInfo">
  6. <id column="id" property="id" />
  7. <result column="is_deleted" property="isDeleted" />
  8. <result column="gmt_create" property="gmtCreate" />
  9. <result column="gmt_modified" property="gmtModified" />
  10. <result column="creator" property="creator" />
  11. <result column="modifier" property="modifier" />
  12. <result column="tag_name" property="tagName" />
  13. <result column="name" property="name" />
  14. <result column="sex_type" property="sexType" />
  15. <result column="age_begin" property="ageBegin" />
  16. <result column="age_end" property="ageEnd" />
  17. <result column="tag_type" property="tagType" />
  18. <result column="control_type" property="controlType" />
  19. <result column="type" property="type" />
  20. <result column="sub_type" property="subType" />
  21. <result column="item_type" property="itemType" />
  22. <result column="label_prefix" property="labelPrefix" />
  23. <result column="label_suffix" property="labelSuffix" />
  24. <result column="min_value" property="minValue" />
  25. <result column="max_value" property="maxValue" />
  26. <result column="text_generate" property="textGenerate" />
  27. <result column="copy_type" property="copyType" />
  28. <result column="show_add" property="showAdd" />
  29. <result column="show_info" property="showInfo" />
  30. <result column="joint" property="joint" />
  31. <result column="remark" property="remark" />
  32. </resultMap>
  33. <delete id="deleteByIds" parameterType="java.util.Map">
  34. update `icss_question_info`
  35. set gmt_modified = #{gmtModified}, modifier = #{modifier}, is_deleted = #{delete}
  36. where is_deleted = 'N'
  37. and id in
  38. <foreach item="id" collection="ids" open="(" separator="," close=")" >
  39. #{id}
  40. </foreach>
  41. </delete>
  42. <select id="index" parameterType="java.util.Map" resultType="com.diagbot.entity.QuestionInfo">
  43. select * from `icss_question_info`
  44. where is_deleted = 'N'
  45. <if test="tagName != null and tagName != ''">
  46. and tag_name like concat("%", #{tagName}, "%")
  47. </if>
  48. <if test="existName != null and existName != ''">
  49. and tag_name = #{existName}
  50. </if>
  51. <if test="sexType != null and sexType != 3 and sexType != ''">
  52. and sex_type in (3, #{sexType})
  53. </if>
  54. <if test="age != null and age != ''">
  55. <![CDATA[ and age_begin <= #{age} ]]>
  56. <![CDATA[ and age_end >= #{age} ]]>
  57. </if>
  58. <if test="type != null and type != ''">
  59. and type = #{type}
  60. </if>
  61. <if test="controlType != null and controlType.size() > 0">
  62. and control_type in
  63. <foreach collection="controlType" item="controlType" open="(" separator="," close=")">
  64. #{controlType}
  65. </foreach>
  66. </if>
  67. <if test="tagType != null and tagType.size() > 0">
  68. and tag_type in
  69. <foreach collection="tagType" item="tagType" open="(" separator="," close=")">
  70. #{tagType}
  71. </foreach>
  72. </if>
  73. <if test="notTagType != null and notTagType.size() > 0">
  74. and tag_type not in
  75. <foreach collection="notTagType" item="notTagType" open="(" separator="," close=")">
  76. #{notTagType}
  77. </foreach>
  78. </if>
  79. <if test="notIds != null and notIds.size() > 0 ">
  80. and id not in
  81. <foreach collection="notIds" item="id" open="(" separator="," close=")">
  82. #{id}
  83. </foreach>
  84. </if>
  85. order by gmt_modified desc
  86. </select>
  87. <select id="getQuestiongInfoByName" resultType="com.diagbot.dto.GetQuestionInfoDTO">
  88. SELECT
  89. a.*
  90. FROM
  91. `icss_question_info` a
  92. WHERE
  93. a.is_deleted = 'N'
  94. AND a.sub_type = '0'
  95. AND a.type = #{type}
  96. <if test="deptId != null and deptId != ''">
  97. AND a.id NOT IN (
  98. SELECT
  99. b.question_id
  100. FROM
  101. `icss_question_usual` b
  102. WHERE
  103. b.is_deleted = 'N'
  104. AND b.dept_id = #{deptId}
  105. )
  106. </if>
  107. <if test="noIds != null and noIds.size != 0">
  108. AND a.id NOT IN
  109. <foreach collection="noIds" item="noId" open="(" separator="," close=")">
  110. #{noId}
  111. </foreach>
  112. </if>
  113. <if test="tagName != null and tagName != ''">
  114. AND a.tag_name like CONCAT('%', #{tagName}, '%')
  115. </if>
  116. </select>
  117. <select id="moduleGetQuestiongInfoByName" resultType="com.diagbot.dto.GetQuestionInfoDTO">
  118. SELECT
  119. a.*
  120. FROM
  121. `icss_question_info` a
  122. WHERE
  123. a.is_deleted = 'N'
  124. AND a.type = #{type}
  125. <if test="moduleId != null and moduleId != ''">
  126. AND a.id NOT IN (
  127. SELECT
  128. c.question_id
  129. FROM
  130. `icss_module_detail` c
  131. WHERE
  132. c.is_deleted = 'N'
  133. AND c.module_id = #{moduleId}
  134. AND c.question_id != ''
  135. )
  136. </if>
  137. <if test="noIds != null and noIds.size != 0">
  138. AND a.id NOT IN
  139. <foreach collection="noIds" item="noId" open="(" separator="," close=")">
  140. #{noId}
  141. </foreach>
  142. </if>
  143. <if test="tagName != null and tagName != ''">
  144. AND a.tag_name like CONCAT('%', #{tagName}, '%')
  145. </if>
  146. </select>
  147. <select id="getList" resultType="com.diagbot.dto.QuestionPageDTO">
  148. SELECT a.* FROM `icss_question_info` a WHERE a.is_deleted = 'N'
  149. <if test="type != null and type != ''">
  150. AND a.type = #{type}
  151. </if>
  152. <if test="tagName != null and tagName != ''">
  153. AND a.tag_name like concat ('%', #{tagName}, '%')
  154. </if>
  155. <if test="tagTypeList != null and tagTypeList.size() > 0 ">
  156. and a.tag_type in
  157. <foreach collection="tagTypeList" item="tagType" open="(" separator="," close=")">
  158. #{tagType}
  159. </foreach>
  160. </if>
  161. order by a.gmt_modified desc
  162. </select>
  163. <select id="getQuestionUsualsByDept" resultType="com.diagbot.dto.GetQuestionInfoDTO">
  164. SELECT a.* FROM `icss_question_info` a
  165. LEFT JOIN icss_question_usual b ON a.id = b.question_id
  166. WHERE b.dept_id = #{deptId} AND a.type = #{type}
  167. GROUP BY a.id
  168. </select>
  169. <select id="getSpecial" parameterType="java.util.Map" resultMap="BaseResultMap">
  170. SELECT DISTINCT t1.* FROM icss_question_info t1, `icss_question_detail` t2
  171. where t1.is_deleted = 'N' and t2.is_deleted = 'N' and
  172. t1.id = t2.question_id and t2.`code` in (1,2)
  173. <if test="sexType != null and sexType != ''">
  174. and t1.sex_type in (3, #{sexType})
  175. </if>
  176. <if test="age != null and age != ''">
  177. <![CDATA[ and t1.age_begin <= #{age} ]]>
  178. <![CDATA[ and t1.age_end >= #{age} ]]>
  179. </if>
  180. <if test="type != null and type != ''">
  181. and t1.type = #{type}
  182. </if>
  183. <if test="notIds != null and notIds.size() > 0 ">
  184. and t1.id not in
  185. <foreach collection="notIds" item="id" open="(" separator="," close=")">
  186. #{id}
  187. </foreach>
  188. </if>
  189. </select>
  190. <select id="getParent" resultMap="BaseResultMap">
  191. SELECT a.* FROM `icss_question_info` a, icss_question_mapping b
  192. where a.is_deleted = 'N' and b.is_deleted = 'N' and a.id = b.parent_question
  193. and b.son_question = #{id}
  194. </select>
  195. <select id="getByQuestionMapping" parameterType="java.util.Map" resultType="com.diagbot.entity.wrapper.QuestionInfoWrapper">
  196. select t.*, m.parent_question, m.position, m.form_position , m.exclusion_type, m.symptom_type from icss_question_info t, icss_question_mapping m
  197. where t.is_deleted = 'N' and m.is_deleted = 'N' and m.son_question = t.id
  198. <if test="id != null">
  199. and m.parent_question = #{id}
  200. </if>
  201. <if test="ids != null and ids.size > 0">
  202. <foreach item="myId" collection="ids" open="and(" separator="or" close=")" >
  203. m.parent_question = #{myId}
  204. </foreach>
  205. </if>
  206. <if test="sexType != null">
  207. and t.sex_type in (3, #{sexType})
  208. </if>
  209. <if test="age != null">
  210. <![CDATA[ and t.age_begin <= #{age} ]]>
  211. <![CDATA[ and t.age_end >= #{age} ]]>
  212. </if>
  213. <if test="id != null">
  214. order by m.order_no
  215. </if>
  216. <if test="ids != null and ids.size > 0">
  217. order by m.parent_question, m.order_no
  218. </if>
  219. </select>
  220. <select id="getByParam" parameterType="java.util.Map" resultMap="BaseResultMap">
  221. select * from icss_question_info where is_deleted = 'N'
  222. and id = #{id}
  223. <if test="sexType != null and sexType != ''">
  224. and sex_type in (3, #{sexType})
  225. </if>
  226. <if test="age != null and age != ''">
  227. <![CDATA[ and age_begin <= #{age} ]]>
  228. <![CDATA[ and age_end >= #{age} ]]>
  229. </if>
  230. </select>
  231. <select id="getQuestionByModuleId" resultType="com.diagbot.dto.GetQuestionInfoDTO">
  232. SELECT a.id,a.tag_name FROM `icss_question_info` a
  233. LEFT JOIN icss_module_detail b ON a.id = b.question_id
  234. WHERE a.is_deleted = 'N' AND b.is_deleted = 'N' AND b.module_id = #{moduleId}
  235. </select>
  236. </mapper>