1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- <?xml version="1.0" encoding="UTF-8"?>
- <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
- <mapper namespace="com.diagbot.mapper.ModuleDetailMapper">
- <!-- 通用查询映射结果 -->
- <resultMap id="BaseResultMap" type="com.diagbot.entity.ModuleDetail">
- <id column="id" property="id" />
- <result column="is_deleted" property="isDeleted" />
- <result column="gmt_create" property="gmtCreate" />
- <result column="gmt_modified" property="gmtModified" />
- <result column="creator" property="creator" />
- <result column="modifier" property="modifier" />
- <result column="module_id" property="moduleId" />
- <result column="prefix" property="prefix" />
- <result column="suffix" property="suffix" />
- <result column="question_id" property="questionId" />
- <result column="flag" property="flag" />
- <result column="relation_module" property="relationModule" />
- <result column="order_no" property="orderNo" />
- <result column="remark" property="remark" />
- </resultMap>
- <select id="getDetailByModule" parameterType="java.util.Map" resultMap="BaseResultMap">
- select t3.* from
- (select DISTINCT t1.* from
- prec_module_detail t1 left join prec_question_info t2 on t1.question_id = t2.id
- where t1.is_deleted = 'N' and t2.is_deleted = 'N'
- and t1.module_id in
- <foreach item="id" collection="ids" open="(" separator="," close=")">
- #{id}
- </foreach>
- <if test="sexType != null and sexType != ''">
- and t2.sex_type in (3, #{sexType})
- </if>
- <if test="age != null and age != ''">
- <![CDATA[ and t2.age_begin <= #{age} ]]>
- <![CDATA[ and t2.age_end >= #{age} ]]>
- </if>
- union
- select DISTINCT t1.* from
- prec_module_detail t1 where t1.question_id is null and t1.is_deleted = 'N'
- and t1.module_id in
- <foreach item="id" collection="ids" open="(" separator="," close=")">
- #{id}
- </foreach>) t3
- order by t3.module_id, t3.order_no
- </select>
- </mapper>
|