QuestionInfoMapper.xml 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  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="description" property="description" />
  25. <result column="remark" property="remark" />
  26. </resultMap>
  27. <delete id="deleteByIds" parameterType="java.util.Map">
  28. update `prec_question_info`
  29. set gmt_modified = #{gmtModified}, modifier = #{modifier}, is_deleted = #{delete}
  30. where is_deleted = 'N'
  31. and id in
  32. <foreach item="id" collection="ids" open="(" separator="," close=")" >
  33. #{id}
  34. </foreach>
  35. </delete>
  36. <select id="index" parameterType="java.util.Map" resultType="com.diagbot.entity.QuestionInfo">
  37. select * from `prec_question_info`
  38. where is_deleted = 'N'
  39. <if test="tagName != null and tagName != ''">
  40. and tag_name like concat("%", #{tagName}, "%")
  41. </if>
  42. <if test="existName != null and existName != ''">
  43. and tag_name = #{existName}
  44. </if>
  45. <if test="sexType != null and sexType != 3 and sexType != ''">
  46. and sex_type in (3, #{sexType})
  47. </if>
  48. <if test="age != null and age != ''">
  49. <![CDATA[ and age_begin <= #{age} ]]>
  50. <![CDATA[ and age_end >= #{age} ]]>
  51. </if>
  52. <if test="type != null and type != ''">
  53. and type = #{type}
  54. </if>
  55. <if test="controlType != null and controlType.size() > 0">
  56. and control_type in
  57. <foreach collection="controlType" item="controlType" open="(" separator="," close=")">
  58. #{controlType}
  59. </foreach>
  60. </if>
  61. <if test="tagType != null and tagType.size() > 0">
  62. and tag_type in
  63. <foreach collection="tagType" item="tagType" open="(" separator="," close=")">
  64. #{tagType}
  65. </foreach>
  66. </if>
  67. <if test="notTagType != null and notTagType.size() > 0">
  68. and tag_type not in
  69. <foreach collection="notTagType" item="notTagType" open="(" separator="," close=")">
  70. #{notTagType}
  71. </foreach>
  72. </if>
  73. <if test="notControlType != null and notControlType.size() > 0">
  74. and control_type not in
  75. <foreach collection="notControlType" item="notControlType" open="(" separator="," close=")">
  76. #{notControlType}
  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. <if test=" ids != null and ids.size() > 0 ">
  86. and id in
  87. <foreach collection="ids" item="id" open="(" separator="," close=")">
  88. #{id}
  89. </foreach>
  90. </if>
  91. order by gmt_modified desc
  92. </select>
  93. <select id="getList" resultType="com.diagbot.dto.QuestionPageDTO">
  94. SELECT a.* FROM `prec_question_info` a
  95. WHERE a.is_deleted = 'N'
  96. <if test="type != null and type != ''">
  97. AND a.type = #{type}
  98. </if>
  99. <if test="tagName != null and tagName != ''">
  100. AND a.tag_name like concat ('%', #{tagName}, '%')
  101. </if>
  102. <if test="notTypeList != null and notTypeList.size() > 0 ">
  103. and a.type not in
  104. <foreach collection="notTypeList" item="notType" open="(" separator="," close=")">
  105. #{notType}
  106. </foreach>
  107. </if>
  108. <if test="tagTypeList != null and tagTypeList.size() > 0 ">
  109. and a.tag_type in
  110. <foreach collection="tagTypeList" item="tagType" open="(" separator="," close=")">
  111. #{tagType}
  112. </foreach>
  113. </if>
  114. <if test="controlTypeList != null and controlTypeList.size() > 0 ">
  115. and a.control_type in
  116. <foreach collection="controlTypeList" item="controlType" open="(" separator="," close=")">
  117. #{controlType}
  118. </foreach>
  119. </if>
  120. order by a.gmt_modified desc
  121. </select>
  122. <select id="getParent" resultMap="BaseResultMap">
  123. SELECT a.* FROM `prec_question_info` a, prec_question_mapping b
  124. where a.is_deleted = 'N' and b.is_deleted = 'N' and a.id = b.parent_question
  125. and b.son_question = #{id}
  126. </select>
  127. <select id="getByQuestionMapping" parameterType="java.util.Map" resultType="com.diagbot.entity.wrapper.QuestionInfoWrapper">
  128. select t.*, m.parent_question, m.position, m.form_position , m.exclusion_type, m.symptom_type from prec_question_info t, prec_question_mapping m
  129. where t.is_deleted = 'N' and m.is_deleted = 'N' and m.son_question = t.id
  130. <if test="id != null">
  131. and m.parent_question = #{id}
  132. </if>
  133. <if test="ids != null and ids.size > 0">
  134. <foreach item="myId" collection="ids" open="and(" separator="or" close=")" >
  135. m.parent_question = #{myId}
  136. </foreach>
  137. </if>
  138. <if test="sexType != null and sexType != 3 and sexType != ''">
  139. and t.sex_type in (3, #{sexType})
  140. </if>
  141. <if test="age != null">
  142. <![CDATA[ and t.age_begin <= #{age} ]]>
  143. <![CDATA[ and t.age_end >= #{age} ]]>
  144. </if>
  145. <if test="id != null">
  146. order by m.order_no
  147. </if>
  148. <if test="ids != null and ids.size > 0">
  149. order by m.parent_question, m.order_no
  150. </if>
  151. </select>
  152. <select id="getByParam" parameterType="java.util.Map" resultMap="BaseResultMap">
  153. select * from prec_question_info where is_deleted = 'N'
  154. and id = #{id}
  155. <if test="sexType != null and sexType != 3 and sexType != ''">
  156. and sex_type in (3, #{sexType})
  157. </if>
  158. <if test="age != null and age != ''">
  159. <![CDATA[ and age_begin <= #{age} ]]>
  160. <![CDATA[ and age_end >= #{age} ]]>
  161. </if>
  162. </select>
  163. </mapper>