ModuleDetailMapper.xml 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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.ModuleDetailMapper">
  4. <!-- 通用查询映射结果 -->
  5. <resultMap id="BaseResultMap" type="com.diagbot.entity.ModuleDetail">
  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="module_id" property="moduleId" />
  13. <result column="prefix" property="prefix" />
  14. <result column="suffix" property="suffix" />
  15. <result column="question_id" property="questionId" />
  16. <result column="flag" property="flag" />
  17. <result column="relation_module" property="relationModule" />
  18. <result column="order_no" property="orderNo" />
  19. <result column="remark" property="remark" />
  20. </resultMap>
  21. <select id="getDetailByModule" parameterType="java.util.Map" resultMap="BaseResultMap">
  22. select t3.* from
  23. (select DISTINCT t1.* from
  24. prec_module_detail t1 left join prec_question_info t2 on t1.question_id = t2.id
  25. where t1.is_deleted = 'N' and t2.is_deleted = 'N'
  26. and t1.module_id in
  27. <foreach item="id" collection="ids" open="(" separator="," close=")">
  28. #{id}
  29. </foreach>
  30. <if test="sexType != null and sexType != ''">
  31. and t2.sex_type in (3, #{sexType})
  32. </if>
  33. <if test="age != null and age != ''">
  34. <![CDATA[ and t2.age_begin <= #{age} ]]>
  35. <![CDATA[ and t2.age_end >= #{age} ]]>
  36. </if>
  37. union
  38. select DISTINCT t1.* from
  39. prec_module_detail t1 where t1.question_id is null and t1.is_deleted = 'N'
  40. and t1.module_id in
  41. <foreach item="id" collection="ids" open="(" separator="," close=")">
  42. #{id}
  43. </foreach>) t3
  44. order by t3.module_id, t3.order_no
  45. </select>
  46. </mapper>