QuestionInfoMapper.xml 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  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.QuestionInfoMapper">
  4. <!-- 通用查询映射结果 -->
  5. <resultMap id="BaseResultMap" type="com.diagbot.entity.QuestionInfo">
  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="tag_name" property="tagName" />
  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="tag_type" property="tagType" />
  18. <result column="control_type" property="controlType" />
  19. <result column="type" property="type" />
  20. <result column="sub_type" property="subType" />
  21. <result column="label_prefix" property="labelPrefix" />
  22. <result column="label_suffix" property="labelSuffix" />
  23. <result column="min_value" property="minValue" />
  24. <result column="max_value" property="maxValue" />
  25. <result column="judge_type" property="judgeType" />
  26. <result column="text_generate" property="textGenerate" />
  27. <result column="copy_type" property="copyType" />
  28. <result column="show_add" property="showAdd" />
  29. <result column="show_info" property="showInfo" />
  30. <result column="joint" property="joint" />
  31. <result column="remark" property="remark" />
  32. </resultMap>
  33. <delete id="deleteByIds" parameterType="java.util.Map">
  34. update `icss_question_info`
  35. set gmt_modified = #{gmtModified}, modifier = #{modifier}, is_deleted = #{delete}
  36. where is_deleted = 'N'
  37. and id in
  38. <foreach item="id" collection="ids" open="(" separator="," close=")" >
  39. #{id}
  40. </foreach>
  41. </delete>
  42. <select id="index" parameterType="java.util.Map" resultType="com.diagbot.entity.QuestionInfo">
  43. select * from `icss_question_info`
  44. where is_deleted = 'N'
  45. <if test="tagName != null and tagName != ''">
  46. and tag_name like concat("%", #{tagName}, "%")
  47. </if>
  48. <if test="sexType != null and sexType != ''">
  49. and sex_type in (3, #{sexType})
  50. </if>
  51. <if test="age != null and age != ''">
  52. <![CDATA[ and age_begin <= #{age} ]]>
  53. <![CDATA[ and age_end >= #{age} ]]>
  54. </if>
  55. <if test="type != null and type != ''">
  56. and type = #{type}
  57. </if>
  58. <if test="controlType != null and controlType != ''">
  59. and control_type = #{controlType}
  60. </if>
  61. <if test="notIds != null and notIds.size() > 0 ">
  62. and id not in
  63. <foreach collection="notIds" item="id" open="(" separator="," close=")">
  64. #{id}
  65. </foreach>
  66. </if>
  67. order by gmt_modified desc
  68. </select>
  69. <select id="getQuestiongInfoByName" resultType="com.diagbot.dto.GetQuestionInfoDTO">
  70. SELECT
  71. a.*
  72. FROM
  73. `icss_question_info` a
  74. WHERE
  75. a.is_deleted = 'N'
  76. AND a.type = '1'
  77. AND a.sub_type = '0'
  78. <if test="deptId != null and deptId != ''">
  79. AND a.id NOT IN (
  80. SELECT
  81. b.question_id
  82. FROM
  83. `icss_question_usual` b
  84. WHERE
  85. b.is_deleted = 'N'
  86. AND b.dept_id = #{deptId}
  87. )
  88. </if>
  89. <if test="tagName != null and tagName != ''">
  90. AND a.tag_name like CONCAT('%', #{tagName}, '%')
  91. </if>
  92. </select>
  93. <select id="getList" resultType="com.diagbot.dto.QuestionPageDTO">
  94. SELECT a.* FROM `icss_question_info` a WHERE a.is_deleted = 'N'
  95. <if test="type != null">
  96. AND a.type = #{type}
  97. </if>
  98. <if test="tagName != null and tagName != ''">
  99. AND a.name like concat ('%', #{tagName}, '%')
  100. </if>
  101. <if test="tagTypeList != null and tagTypeList.size() > 0 ">
  102. and a.tag_type in
  103. <foreach collection="tagTypeList" item="tagType" open="(" separator="," close=")">
  104. #{tagType}
  105. </foreach>
  106. </if>
  107. order by a.gmt_create desc
  108. </select>
  109. <select id="getQuestionUsualsByDept" resultType="com.diagbot.dto.GetQuestionInfoDTO">
  110. SELECT a.* FROM `icss_question_info` a
  111. LEFT JOIN icss_question_usual b ON a.id = b.question_id
  112. WHERE b.dept_id = #{deptId}
  113. GROUP BY a.id
  114. </select>
  115. <select id="getSpecial" parameterType="java.util.Map" resultMap="BaseResultMap">
  116. SELECT DISTINCT t1.* FROM icss_question_info t1, `icss_question_detail` t2
  117. where t1.is_deleted = 'N' and t2.is_deleted = 'N' and
  118. t1.id = t2.question_id and t2.`code` in (1,2)
  119. <if test="sexType != null and sexType != ''">
  120. and t1.sex_type in (3, #{sexType})
  121. </if>
  122. <if test="age != null and age != ''">
  123. <![CDATA[ and t1.age_begin <= #{age} ]]>
  124. <![CDATA[ and t1.age_end >= #{age} ]]>
  125. </if>
  126. <if test="type != null and type != ''">
  127. and t1.type = #{type}
  128. </if>
  129. <if test="notIds != null and notIds.size() > 0 ">
  130. and t1.id not in
  131. <foreach collection="notIds" item="id" open="(" separator="," close=")">
  132. #{id}
  133. </foreach>
  134. </if>
  135. </select>
  136. </mapper>