SymptomMapper.xml 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  3. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  4. <mapper namespace="com.diagbot.mapper.SymptomMapper">
  5. <!-- 通用查询映射结果 -->
  6. <resultMap id="BaseResultMap" type="com.diagbot.entity.Symptom">
  7. <id column="id" property="id"/>
  8. <result column="is_deleted" property="isDeleted"/>
  9. <result column="gmt_create" property="gmtCreate"/>
  10. <result column="gmt_modified" property="gmtModified"/>
  11. <result column="creator" property="creator"/>
  12. <result column="modifier" property="modifier"/>
  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="remark" property="remark"/>
  18. </resultMap>
  19. <select id="getByPartIds" parameterType="java.util.Map" resultType="com.diagbot.entity.SymptomWrapper">
  20. SELECT a.*, b.part_id FROM `triage_symptom` a, triage_part_symptom b where a.is_deleted = 'N' and b.is_deleted = 'N'
  21. and b.symptom_id = a.id
  22. and b.part_id in
  23. <foreach collection="ids" item="id" open="(" separator="," close=")">
  24. #{id}
  25. </foreach>
  26. and a.sex_type in (3, #{sexType})
  27. <if test="age != null">
  28. <![CDATA[ and a.age_begin <= #{age} ]]>
  29. <![CDATA[ and a.age_end >= #{age} ]]>
  30. </if>
  31. order by b.part_id, b.order_no
  32. </select>
  33. <select id="getUsual" parameterType="java.util.Map" resultMap="BaseResultMap">
  34. SELECT a.* FROM `triage_symptom` a, triage_symptom_usual b where a.is_deleted = 'N' and b.is_deleted = 'N'
  35. and b.symptom_id = a.id
  36. and a.sex_type in (3, #{sexType})
  37. <if test="age != null">
  38. <![CDATA[ and a.age_begin <= #{age} ]]>
  39. <![CDATA[ and a.age_end >= #{age} ]]>
  40. </if>
  41. order by b.order_no
  42. </select>
  43. <select id="search" parameterType="java.util.Map" resultType="com.diagbot.dto.SymptomSearchDTO">
  44. select c.*,b.show_type,if(show_type=1, '本体', '同义词') show_type_cn,a.name search_name
  45. from triage_retrieval a, triage_retrieval_mapping b, triage_symptom c
  46. where a.is_deleted = 'N' and b.is_deleted = 'N' and c.is_deleted = 'N'
  47. and a.id = b.retrieval_id and b.item_id = c.id
  48. and (a.`name` = #{name} or a.spell = #{name})
  49. and c.sex_type in (3, #{sexType})
  50. <if test="age != null">
  51. <![CDATA[ and c.age_begin <= #{age} ]]>
  52. <![CDATA[ and c.age_end >= #{age} ]]>
  53. </if>
  54. union
  55. select c.*,b.show_type,if(show_type=1, '本体', '同义词') show_type_cn, a.name search_name from triage_retrieval a, triage_retrieval_mapping b, triage_symptom c
  56. where a.is_deleted = 'N' and b.is_deleted = 'N' and c.is_deleted = 'N'
  57. and a.id = b.retrieval_id and b.item_id = c.id
  58. and (a.`name` like concat('%',#{name} , '%') or a.spell like concat('%',#{name} , '%'))
  59. and c.sex_type in (3, #{sexType})
  60. <if test="age != null">
  61. <![CDATA[ and c.age_begin <= #{age} ]]>
  62. <![CDATA[ and c.age_end >= #{age} ]]>
  63. </if>
  64. </select>
  65. </mapper>