QuestionInfoMapper.xml 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  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="item_type" property="itemType" />
  21. <result column="label_prefix" property="labelPrefix" />
  22. <result column="label_suffix" property="labelSuffix" />
  23. <result column="url" property="url" />
  24. <result column="spec_flag" property="specFlag" />
  25. <result column="exclusion_detail" property="exclusionDetail" />
  26. <result column="required" property="required" />
  27. <result column="explains" property="explains" />
  28. <result column="description" property="description" />
  29. <result column="flag" property="flag" />
  30. <result column="remark" property="remark" />
  31. </resultMap>
  32. <delete id="deleteByIds" parameterType="java.util.Map">
  33. update `prec_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 `prec_question_info`
  43. where is_deleted = 'N'
  44. <if test="tagName != null and tagName != ''">
  45. and UPPER(tag_name) like concat("%", UPPER(trim(#{tagName})), "%")
  46. </if>
  47. <if test="existName != null and existName != ''">
  48. and UPPER(tag_name) = UPPER(trim(#{existName}))
  49. </if>
  50. <if test="sexType != null and sexType != 3 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.size() > 0">
  61. and control_type in
  62. <foreach collection="controlType" item="controlType" open="(" separator="," close=")">
  63. #{controlType}
  64. </foreach>
  65. </if>
  66. <if test="tagType != null and tagType.size() > 0">
  67. and tag_type in
  68. <foreach collection="tagType" item="tagType" open="(" separator="," close=")">
  69. #{tagType}
  70. </foreach>
  71. </if>
  72. <if test="notTagType != null and notTagType.size() > 0">
  73. and tag_type not in
  74. <foreach collection="notTagType" item="notTagType" open="(" separator="," close=")">
  75. #{notTagType}
  76. </foreach>
  77. </if>
  78. <if test="notControlType != null and notControlType.size() > 0">
  79. and control_type not in
  80. <foreach collection="notControlType" item="notControlType" open="(" separator="," close=")">
  81. #{notControlType}
  82. </foreach>
  83. </if>
  84. <if test="notIds != null and notIds.size() > 0 ">
  85. and id not in
  86. <foreach collection="notIds" item="id" open="(" separator="," close=")">
  87. #{id}
  88. </foreach>
  89. </if>
  90. <if test=" ids != null and ids.size() > 0 ">
  91. and id in
  92. <foreach collection="ids" item="id" open="(" separator="," close=")">
  93. #{id}
  94. </foreach>
  95. </if>
  96. <if test="noSubQuestion !=null and noSubQuestion == 1">
  97. and id not in (select distinct question_id from prec_question_detail t where t.is_deleted = 'N' and t.sub_question != '')
  98. </if>
  99. order by gmt_modified desc
  100. </select>
  101. <select id="getList" resultType="com.diagbot.dto.QuestionPageDTO">
  102. <if test="callType != null and callType == 1">
  103. SELECT
  104. t1.id,
  105. t1.is_deleted,
  106. t1.gmt_create,
  107. t1.gmt_modified,
  108. t1.creator,
  109. t1.modifier,
  110. t1.tag_name,
  111. t1.`name`,
  112. t1.description,
  113. group_concat(t3.tag_name) as combinationName,
  114. t1.`sex_type`,
  115. t1.age_begin,
  116. t1.age_end,
  117. t1.tag_type,
  118. t1.control_type,
  119. t1.type,
  120. t1.item_type,
  121. t1.label_prefix,
  122. t1.label_suffix,
  123. t1.url,
  124. t1.spec_flag,
  125. t1.required,
  126. t1.explains,
  127. t1.remark
  128. FROM
  129. `prec_question_info` t1
  130. LEFT JOIN prec_question_mapping t2 on t1.id = t2.son_question and t2.is_deleted = 'N'
  131. LEFT JOIN `prec_question_info` t3 on t2.parent_question = t3.id and t3.is_deleted = 'N'
  132. WHERE t1.is_deleted = 'N'
  133. <if test="combinationName != null and combinationName != ''">
  134. and UPPER(t3.tag_name) like concat ('%', UPPER(trim(#{combinationName})), '%')
  135. </if>
  136. <if test="type != null and type != ''">
  137. AND t1.type = #{type}
  138. </if>
  139. <if test="name != null and name != ''">
  140. AND UPPER(t1.name) like concat ('%', UPPER(trim(#{name})), '%')
  141. </if>
  142. <if test="tagName != null and tagName != ''">
  143. AND UPPER(t1.tag_name) like concat ('%', UPPER(trim(#{tagName})), '%')
  144. </if>
  145. <if test="notTypeList != null and notTypeList.size() > 0 ">
  146. and t1.type not in
  147. <foreach collection="notTypeList" item="notType" open="(" separator="," close=")">
  148. #{notType}
  149. </foreach>
  150. </if>
  151. <if test="tagTypeList != null and tagTypeList.size() > 0 ">
  152. and t1.tag_type in
  153. <foreach collection="tagTypeList" item="tagType" open="(" separator="," close=")">
  154. #{tagType}
  155. </foreach>
  156. </if>
  157. <if test="controlTypeList != null and controlTypeList.size() > 0 ">
  158. and t1.control_type in
  159. <foreach collection="controlTypeList" item="controlType" open="(" separator="," close=")">
  160. #{controlType}
  161. </foreach>
  162. </if>
  163. group by t1.id
  164. ORDER BY t1.gmt_modified desc
  165. </if>
  166. <if test="callType != null and callType == 2">
  167. SELECT a.* FROM `prec_question_info` a
  168. WHERE a.is_deleted = 'N'
  169. <if test="type != null and type != ''">
  170. AND a.type = #{type}
  171. </if>
  172. <if test="tagName != null and tagName != ''">
  173. AND UPPER(a.tag_name) like concat ('%', UPPER(trim(#{tagName})), '%')
  174. </if>
  175. <if test="name != null and name != ''">
  176. AND UPPER(a.name) like concat ('%', UPPER(trim(#{name})), '%')
  177. </if>
  178. <if test="notTypeList != null and notTypeList.size() > 0 ">
  179. and a.type not in
  180. <foreach collection="notTypeList" item="notType" open="(" separator="," close=")">
  181. #{notType}
  182. </foreach>
  183. </if>
  184. <if test="tagTypeList != null and tagTypeList.size() > 0 ">
  185. and a.tag_type in
  186. <foreach collection="tagTypeList" item="tagType" open="(" separator="," close=")">
  187. #{tagType}
  188. </foreach>
  189. </if>
  190. <if test="controlTypeList != null and controlTypeList.size() > 0 ">
  191. and a.control_type in
  192. <foreach collection="controlTypeList" item="controlType" open="(" separator="," close=")">
  193. #{controlType}
  194. </foreach>
  195. </if>
  196. order by a.gmt_modified desc
  197. </if>
  198. </select>
  199. <select id="getParent" resultMap="BaseResultMap">
  200. SELECT a.* FROM `prec_question_info` a, prec_question_mapping b
  201. where a.is_deleted = 'N' and b.is_deleted = 'N' and a.id = b.parent_question
  202. and b.son_question = #{id}
  203. </select>
  204. <select id="getByQuestionMapping" parameterType="java.util.Map" resultType="com.diagbot.entity.wrapper.QuestionInfoWrapper">
  205. select t.*, m.parent_question , m.exclusion_type from prec_question_info t, prec_question_mapping m
  206. where t.is_deleted = 'N' and m.is_deleted = 'N' and m.son_question = t.id
  207. <if test="id != null">
  208. and m.parent_question = #{id}
  209. </if>
  210. <if test="ids != null and ids.size > 0">
  211. <foreach item="myId" collection="ids" open="and(" separator="or" close=")" >
  212. m.parent_question = #{myId}
  213. </foreach>
  214. </if>
  215. <if test="sexType != null and sexType != 3 and sexType != ''">
  216. and t.sex_type in (3, #{sexType})
  217. </if>
  218. <if test="age != null">
  219. <![CDATA[ and t.age_begin <= #{age} ]]>
  220. <![CDATA[ and t.age_end >= #{age} ]]>
  221. </if>
  222. <if test="id != null">
  223. order by m.order_no
  224. </if>
  225. <if test="ids != null and ids.size > 0">
  226. order by m.parent_question, m.order_no
  227. </if>
  228. </select>
  229. <select id="getByParam" parameterType="java.util.Map" resultMap="BaseResultMap">
  230. select * from prec_question_info where is_deleted = 'N'
  231. and id = #{id}
  232. <if test="sexType != null and sexType != 3 and sexType != ''">
  233. and sex_type in (3, #{sexType})
  234. </if>
  235. <if test="age != null and age != ''">
  236. <![CDATA[ and age_begin <= #{age} ]]>
  237. <![CDATA[ and age_end >= #{age} ]]>
  238. </if>
  239. </select>
  240. </mapper>