RetrievalMapper.xml 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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.RetrievalMapper">
  4. <!-- 通用查询映射结果 -->
  5. <resultMap id="BaseResultMap" type="com.diagbot.entity.Retrieval">
  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="name" property="name" />
  13. <result column="spell" property="spell" />
  14. <result column="remark" property="remark" />
  15. </resultMap>
  16. <select id="getSymptopInfo" resultType="com.diagbot.dto.RetrievalDTO">
  17. SELECT a.`name` as retrieval_name,c.id as question_id,b.show_type FROM icss_retrieval a
  18. LEFT JOIN icss_retrieval_mapping b ON a.id = b.retrieval_id
  19. LEFT JOIN icss_question_info c ON b.question_id = c.id
  20. WHERE a.is_deleted = 'N' AND b.is_deleted = 'N' AND c.is_deleted = 'N'
  21. AND (a.spell = #{InputStr} or a.`name` = #{InputStr})
  22. AND c.type = #{type}
  23. <if test="age != null and age != ''">
  24. <![CDATA[ and c.age_begin <= #{age} ]]>
  25. <![CDATA[ and c.age_end >= #{age} ]]>
  26. </if>
  27. <if test="tagType != null and tagType != ''">
  28. <![CDATA[ and c.tag_type = #{tagType} ]]>
  29. </if>
  30. <if test="itemType != null">
  31. <![CDATA[ and c.item_type = #{itemType} ]]>
  32. </if>
  33. <if test="sexType == 3">
  34. and c.sex_type in ('1','2','3')
  35. </if>
  36. <if test="sexType != 3">
  37. and c.sex_type in ('3',#{sexType})
  38. </if>
  39. <if test="inputIds != null and inputIds.size > 0">
  40. and c.id not in
  41. <foreach item="id" collection="inputIds" open="(" separator="," close=")">
  42. #{id}
  43. </foreach>
  44. </if>
  45. UNION
  46. SELECT a.`name` as retrieval_name,c.id as question_id,b.show_type FROM icss_retrieval a
  47. LEFT JOIN icss_retrieval_mapping b ON a.id = b.retrieval_id
  48. LEFT JOIN icss_question_info c ON b.question_id = c.id
  49. WHERE a.is_deleted = 'N' AND b.is_deleted = 'N' AND c.is_deleted = 'N'
  50. AND (a.spell LIKE CONCAT(#{InputStr},'%') or a.`name` LIKE CONCAT(#{InputStr},'%'))
  51. AND c.type = #{type}
  52. <if test="age != null and age != ''">
  53. <![CDATA[ and c.age_begin <= #{age} ]]>
  54. <![CDATA[ and c.age_end >= #{age} ]]>
  55. </if>
  56. <if test="tagType != null and tagType != ''">
  57. <![CDATA[ and c.tag_type = #{tagType} ]]>
  58. </if>
  59. <if test="itemType != null">
  60. <![CDATA[ and c.item_type = #{itemType} ]]>
  61. </if>
  62. <if test="sexType == 3">
  63. and c.sex_type in ('1','2','3')
  64. </if>
  65. <if test="sexType != 3">
  66. and c.sex_type in ('3',#{sexType})
  67. </if>
  68. <if test="inputIds != null and inputIds.size > 0">
  69. and c.id not in
  70. <foreach item="id" collection="inputIds" open="(" separator="," close=")">
  71. #{id}
  72. </foreach>
  73. </if>
  74. UNION
  75. SELECT a.`name` as retrieval_name,c.id as question_id,b.show_type FROM icss_retrieval a
  76. LEFT JOIN icss_retrieval_mapping b ON a.id = b.retrieval_id
  77. LEFT JOIN icss_question_info c ON b.question_id = c.id
  78. WHERE a.is_deleted = 'N' AND b.is_deleted = 'N' AND c.is_deleted = 'N'
  79. AND (a.spell LIKE CONCAT('%',#{InputStr},'%') or a.`name` LIKE CONCAT('%',#{InputStr},'%'))
  80. AND c.type = #{type}
  81. <if test="age != null and age != ''">
  82. <![CDATA[ and c.age_begin <= #{age} ]]>
  83. <![CDATA[ and c.age_end >= #{age} ]]>
  84. </if>
  85. <if test="tagType != null and tagType != ''">
  86. <![CDATA[ and c.tag_type = #{tagType} ]]>
  87. </if>
  88. <if test="itemType != null">
  89. <![CDATA[ and c.item_type = #{itemType} ]]>
  90. </if>
  91. <if test="sexType == 3">
  92. and c.sex_type in ('1','2','3')
  93. </if>
  94. <if test="sexType != 3">
  95. and c.sex_type in ('3',#{sexType})
  96. </if>
  97. <if test="inputIds != null and inputIds.size > 0">
  98. and c.id not in
  99. <foreach item="id" collection="inputIds" open="(" separator="," close=")">
  100. #{id}
  101. </foreach>
  102. </if>
  103. </select>
  104. </mapper>