123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255 |
- <?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.QuestionInfoMapper">
- <!-- 通用查询映射结果 -->
- <resultMap id="BaseResultMap" type="com.diagbot.entity.QuestionInfo">
- <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="tag_name" property="tagName" />
- <result column="name" property="name" />
- <result column="sex_type" property="sexType" />
- <result column="age_begin" property="ageBegin" />
- <result column="age_end" property="ageEnd" />
- <result column="tag_type" property="tagType" />
- <result column="control_type" property="controlType" />
- <result column="type" property="type" />
- <result column="item_type" property="itemType" />
- <result column="label_prefix" property="labelPrefix" />
- <result column="label_suffix" property="labelSuffix" />
- <result column="url" property="url" />
- <result column="spec_flag" property="specFlag" />
- <result column="exclusion_detail" property="exclusionDetail" />
- <result column="required" property="required" />
- <result column="explains" property="explains" />
- <result column="description" property="description" />
- <result column="flag" property="flag" />
- <result column="remark" property="remark" />
- </resultMap>
- <delete id="deleteByIds" parameterType="java.util.Map">
- update `prec_question_info`
- set gmt_modified = #{gmtModified}, modifier = #{modifier}, is_deleted = #{delete}
- where is_deleted = 'N'
- and id in
- <foreach item="id" collection="ids" open="(" separator="," close=")" >
- #{id}
- </foreach>
- </delete>
- <select id="index" parameterType="java.util.Map" resultType="com.diagbot.entity.QuestionInfo">
- select * from `prec_question_info`
- where is_deleted = 'N'
- <if test="tagName != null and tagName != ''">
- and UPPER(tag_name) like concat("%", UPPER(trim(#{tagName})), "%")
- </if>
- <if test="existName != null and existName != ''">
- and UPPER(tag_name) = UPPER(trim(#{existName}))
- </if>
- <if test="sexType != null and sexType != 3 and sexType != ''">
- and sex_type in (3, #{sexType})
- </if>
- <if test="age != null and age != ''">
- <![CDATA[ and age_begin <= #{age} ]]>
- <![CDATA[ and age_end >= #{age} ]]>
- </if>
- <if test="type != null and type != ''">
- and type = #{type}
- </if>
- <if test="controlType != null and controlType.size() > 0">
- and control_type in
- <foreach collection="controlType" item="controlType" open="(" separator="," close=")">
- #{controlType}
- </foreach>
- </if>
- <if test="tagType != null and tagType.size() > 0">
- and tag_type in
- <foreach collection="tagType" item="tagType" open="(" separator="," close=")">
- #{tagType}
- </foreach>
- </if>
- <if test="notTagType != null and notTagType.size() > 0">
- and tag_type not in
- <foreach collection="notTagType" item="notTagType" open="(" separator="," close=")">
- #{notTagType}
- </foreach>
- </if>
- <if test="notControlType != null and notControlType.size() > 0">
- and control_type not in
- <foreach collection="notControlType" item="notControlType" open="(" separator="," close=")">
- #{notControlType}
- </foreach>
- </if>
- <if test="notIds != null and notIds.size() > 0 ">
- and id not in
- <foreach collection="notIds" item="id" open="(" separator="," close=")">
- #{id}
- </foreach>
- </if>
- <if test=" ids != null and ids.size() > 0 ">
- and id in
- <foreach collection="ids" item="id" open="(" separator="," close=")">
- #{id}
- </foreach>
- </if>
- <if test="noSubQuestion !=null and noSubQuestion == 1">
- and id not in (select distinct question_id from prec_question_detail t where t.is_deleted = 'N' and t.sub_question != '')
- </if>
- order by gmt_modified desc
- </select>
- <select id="getList" resultType="com.diagbot.dto.QuestionPageDTO">
- <if test="callType != null and callType == 1">
- SELECT
- t1.id,
- t1.is_deleted,
- t1.gmt_create,
- t1.gmt_modified,
- t1.creator,
- t1.modifier,
- t1.tag_name,
- t1.`name`,
- t1.description,
- group_concat(t3.tag_name) as combinationName,
- t1.`sex_type`,
- t1.age_begin,
- t1.age_end,
- t1.tag_type,
- t1.control_type,
- t1.type,
- t1.item_type,
- t1.label_prefix,
- t1.label_suffix,
- t1.url,
- t1.spec_flag,
- t1.required,
- t1.explains,
- t1.remark
- FROM
- `prec_question_info` t1
- LEFT JOIN prec_question_mapping t2 on t1.id = t2.son_question and t2.is_deleted = 'N'
- LEFT JOIN `prec_question_info` t3 on t2.parent_question = t3.id and t3.is_deleted = 'N'
- WHERE t1.is_deleted = 'N'
- <if test="combinationName != null and combinationName != ''">
- and UPPER(t3.tag_name) like concat ('%', UPPER(trim(#{combinationName})), '%')
- </if>
- <if test="type != null and type != ''">
- AND t1.type = #{type}
- </if>
- <if test="name != null and name != ''">
- AND UPPER(t1.name) like concat ('%', UPPER(trim(#{name})), '%')
- </if>
- <if test="tagName != null and tagName != ''">
- AND UPPER(t1.tag_name) like concat ('%', UPPER(trim(#{tagName})), '%')
- </if>
- <if test="notTypeList != null and notTypeList.size() > 0 ">
- and t1.type not in
- <foreach collection="notTypeList" item="notType" open="(" separator="," close=")">
- #{notType}
- </foreach>
- </if>
- <if test="tagTypeList != null and tagTypeList.size() > 0 ">
- and t1.tag_type in
- <foreach collection="tagTypeList" item="tagType" open="(" separator="," close=")">
- #{tagType}
- </foreach>
- </if>
- <if test="controlTypeList != null and controlTypeList.size() > 0 ">
- and t1.control_type in
- <foreach collection="controlTypeList" item="controlType" open="(" separator="," close=")">
- #{controlType}
- </foreach>
- </if>
- group by t1.id
- ORDER BY t1.gmt_modified desc
- </if>
- <if test="callType != null and callType == 2">
- SELECT a.* FROM `prec_question_info` a
- WHERE a.is_deleted = 'N'
- <if test="type != null and type != ''">
- AND a.type = #{type}
- </if>
- <if test="tagName != null and tagName != ''">
- AND UPPER(a.tag_name) like concat ('%', UPPER(trim(#{tagName})), '%')
- </if>
- <if test="name != null and name != ''">
- AND UPPER(a.name) like concat ('%', UPPER(trim(#{name})), '%')
- </if>
- <if test="notTypeList != null and notTypeList.size() > 0 ">
- and a.type not in
- <foreach collection="notTypeList" item="notType" open="(" separator="," close=")">
- #{notType}
- </foreach>
- </if>
- <if test="tagTypeList != null and tagTypeList.size() > 0 ">
- and a.tag_type in
- <foreach collection="tagTypeList" item="tagType" open="(" separator="," close=")">
- #{tagType}
- </foreach>
- </if>
- <if test="controlTypeList != null and controlTypeList.size() > 0 ">
- and a.control_type in
- <foreach collection="controlTypeList" item="controlType" open="(" separator="," close=")">
- #{controlType}
- </foreach>
- </if>
- order by a.gmt_modified desc
- </if>
- </select>
- <select id="getParent" resultMap="BaseResultMap">
- SELECT a.* FROM `prec_question_info` a, prec_question_mapping b
- where a.is_deleted = 'N' and b.is_deleted = 'N' and a.id = b.parent_question
- and b.son_question = #{id}
- </select>
- <select id="getByQuestionMapping" parameterType="java.util.Map" resultType="com.diagbot.entity.wrapper.QuestionInfoWrapper">
- select t.*, m.parent_question , m.exclusion_type from prec_question_info t, prec_question_mapping m
- where t.is_deleted = 'N' and m.is_deleted = 'N' and m.son_question = t.id
- <if test="id != null">
- and m.parent_question = #{id}
- </if>
- <if test="ids != null and ids.size > 0">
- <foreach item="myId" collection="ids" open="and(" separator="or" close=")" >
- m.parent_question = #{myId}
- </foreach>
- </if>
- <if test="sexType != null and sexType != 3 and sexType != ''">
- and t.sex_type in (3, #{sexType})
- </if>
- <if test="age != null">
- <![CDATA[ and t.age_begin <= #{age} ]]>
- <![CDATA[ and t.age_end >= #{age} ]]>
- </if>
- <if test="id != null">
- order by m.order_no
- </if>
- <if test="ids != null and ids.size > 0">
- order by m.parent_question, m.order_no
- </if>
- </select>
- <select id="getByParam" parameterType="java.util.Map" resultMap="BaseResultMap">
- select * from prec_question_info where is_deleted = 'N'
- and id = #{id}
- <if test="sexType != null and sexType != 3 and sexType != ''">
- and sex_type in (3, #{sexType})
- </if>
- <if test="age != null and age != ''">
- <![CDATA[ and age_begin <= #{age} ]]>
- <![CDATA[ and age_end >= #{age} ]]>
- </if>
- </select>
- </mapper>
|