QuestionInfoMapper.xml 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  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="label_prefix" property="labelPrefix" />
  22. <result column="label_suffix" property="labelSuffix" />
  23. <result column="min_value" property="minValue" />
  24. <result column="max_value" property="maxValue" />
  25. <result column="text_generate" property="textGenerate" />
  26. <result column="copy_type" property="copyType" />
  27. <result column="show_add" property="showAdd" />
  28. <result column="show_info" property="showInfo" />
  29. <result column="joint" property="joint" />
  30. <result column="remark" property="remark" />
  31. </resultMap>
  32. <delete id="deleteByIds" parameterType="java.util.Map">
  33. update `icss_question_info`
  34. set gmt_modified = #{gmtModified}, modifier = #{modifier}, is_deleted = #{delete}
  35. where is_deleted = 'N'
  36. and id in
  37. <foreach item="id" collection="ids" open="(" separator="," close=")" >
  38. #{id}
  39. </foreach>
  40. </delete>
  41. <select id="index" parameterType="java.util.Map" resultType="com.diagbot.entity.QuestionInfo">
  42. select * from `icss_question_info`
  43. where is_deleted = 'N'
  44. <if test="tagName != null and tagName != ''">
  45. and tag_name like concat("%", #{tagName}, "%")
  46. </if>
  47. <if test="existName != null and existName != ''">
  48. and tag_name = #{existName}
  49. </if>
  50. <if test="sexType != null and sexType != ''">
  51. and sex_type in (3, #{sexType})
  52. </if>
  53. <if test="age != null and age != ''">
  54. <![CDATA[ and age_begin <= #{age} ]]>
  55. <![CDATA[ and age_end >= #{age} ]]>
  56. </if>
  57. <if test="type != null and type != ''">
  58. and type = #{type}
  59. </if>
  60. <if test="controlType != null and controlType != ''">
  61. and control_type = #{controlType}
  62. </if>
  63. <if test="tagType != null and tagType.size() > 0">
  64. and tag_type in
  65. <foreach collection="tagType" item="tagType" open="(" separator="," close=")">
  66. #{tagType}
  67. </foreach>
  68. </if>
  69. <if test="notIds != null and notIds.size() > 0 ">
  70. and id not in
  71. <foreach collection="notIds" item="id" open="(" separator="," close=")">
  72. #{id}
  73. </foreach>
  74. </if>
  75. order by gmt_modified desc
  76. </select>
  77. <select id="getQuestiongInfoByName" resultType="com.diagbot.dto.GetQuestionInfoDTO">
  78. SELECT
  79. a.*
  80. FROM
  81. `icss_question_info` a
  82. WHERE
  83. a.is_deleted = 'N'
  84. AND a.type = '1'
  85. AND a.sub_type = '0'
  86. <if test="deptId != null and deptId != ''">
  87. AND a.id NOT IN (
  88. SELECT
  89. b.question_id
  90. FROM
  91. `icss_question_usual` b
  92. WHERE
  93. b.is_deleted = 'N'
  94. AND b.dept_id = #{deptId}
  95. )
  96. </if>
  97. <if test="tagName != null and tagName != ''">
  98. AND a.tag_name like CONCAT('%', #{tagName}, '%')
  99. </if>
  100. </select>
  101. <select id="moduleGetQuestiongInfoByName" resultType="com.diagbot.dto.GetQuestionInfoDTO">
  102. SELECT
  103. a.*
  104. FROM
  105. `icss_question_info` a
  106. WHERE
  107. a.is_deleted = 'N'
  108. <if test="moduleId != null and moduleId != ''">
  109. AND a.id NOT IN (
  110. SELECT
  111. c.question_id
  112. FROM
  113. `icss_module_detail` c
  114. WHERE
  115. c.is_deleted = 'N'
  116. AND c.module_id = #{moduleId}
  117. )
  118. </if>
  119. <if test="tagName != null and tagName != ''">
  120. AND a.tag_name like CONCAT('%', #{tagName}, '%')
  121. </if>
  122. </select>
  123. <select id="getList" resultType="com.diagbot.dto.QuestionPageDTO">
  124. SELECT a.* FROM `icss_question_info` a WHERE a.is_deleted = 'N'
  125. <if test="type != null and type != ''">
  126. AND a.type = #{type}
  127. </if>
  128. <if test="tagName != null and tagName != ''">
  129. AND a.name like concat ('%', #{tagName}, '%')
  130. </if>
  131. <if test="tagTypeList != null and tagTypeList.size() > 0 ">
  132. and a.tag_type in
  133. <foreach collection="tagTypeList" item="tagType" open="(" separator="," close=")">
  134. #{tagType}
  135. </foreach>
  136. </if>
  137. order by a.gmt_modified desc
  138. </select>
  139. <select id="getQuestionUsualsByDept" resultType="com.diagbot.dto.GetQuestionInfoDTO">
  140. SELECT a.* FROM `icss_question_info` a
  141. LEFT JOIN icss_question_usual b ON a.id = b.question_id
  142. WHERE b.dept_id = #{deptId}
  143. GROUP BY a.id
  144. </select>
  145. <select id="getSpecial" parameterType="java.util.Map" resultMap="BaseResultMap">
  146. SELECT DISTINCT t1.* FROM icss_question_info t1, `icss_question_detail` t2
  147. where t1.is_deleted = 'N' and t2.is_deleted = 'N' and
  148. t1.id = t2.question_id and t2.`code` in (1,2)
  149. <if test="sexType != null and sexType != ''">
  150. and t1.sex_type in (3, #{sexType})
  151. </if>
  152. <if test="age != null and age != ''">
  153. <![CDATA[ and t1.age_begin <= #{age} ]]>
  154. <![CDATA[ and t1.age_end >= #{age} ]]>
  155. </if>
  156. <if test="type != null and type != ''">
  157. and t1.type = #{type}
  158. </if>
  159. <if test="notIds != null and notIds.size() > 0 ">
  160. and t1.id not in
  161. <foreach collection="notIds" item="id" open="(" separator="," close=")">
  162. #{id}
  163. </foreach>
  164. </if>
  165. </select>
  166. <select id="getParent" resultMap="BaseResultMap">
  167. SELECT a.* FROM `icss_question_info` a, icss_question_mapping b
  168. where a.is_deleted = 'N' and b.is_deleted = 'N' and a.id = b.parent_question
  169. and b.son_question = #{id}
  170. </select>
  171. <select id="getByQuestionMapping" parameterType="java.util.Map" resultType="com.diagbot.entity.wrapper.QuestionInfoWrapper">
  172. 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
  173. where t.is_deleted = 'N' and m.is_deleted = 'N' and m.son_question = t.id
  174. <if test="id != null">
  175. and m.parent_question = #{id}
  176. </if>
  177. <if test="ids != null and ids.size > 0">
  178. <foreach item="myId" collection="ids" open="and(" separator="or" close=")" >
  179. m.parent_question = #{myId}
  180. </foreach>
  181. </if>
  182. <if test="sexType != null">
  183. and t.sex_type in (3, #{sexType})
  184. </if>
  185. <if test="age != null">
  186. <![CDATA[ and t.age_begin <= #{age} ]]>
  187. <![CDATA[ and t.age_end >= #{age} ]]>
  188. </if>
  189. <if test="id != null">
  190. order by m.order_no
  191. </if>
  192. <if test="ids != null and ids.size > 0">
  193. order by m.parent_question, m.order_no
  194. </if>
  195. </select>
  196. <select id="getByParam" parameterType="java.util.Map" resultMap="BaseResultMap">
  197. select * from icss_question_info where is_deleted = 'N'
  198. and id = #{id}
  199. <if test="sexType != null and sexType != ''">
  200. and sex_type in (3, #{sexType})
  201. </if>
  202. <if test="age != null and age != ''">
  203. <![CDATA[ and age_begin <= #{age} ]]>
  204. <![CDATA[ and age_end >= #{age} ]]>
  205. </if>
  206. </select>
  207. <select id="getQuestionByModuleId" resultType="com.diagbot.dto.GetQuestionInfoDTO">
  208. SELECT a.id,a.tag_name FROM `icss_question_info` a
  209. LEFT JOIN icss_module_detail b ON a.id = b.question_id
  210. WHERE a.is_deleted = 'N' AND b.is_deleted = 'N' AND b.module_id = #{moduleId}
  211. </select>
  212. </mapper>