ReportDao.xml 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  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.ims.eval.dao.ReportDao">
  4. <sql id="reportColumns">
  5. a.id AS "id",
  6. a.report_title AS "reportTitle",
  7. a.des AS "des",
  8. a.publish_time AS "publishTime",
  9. a.report_path AS "reportPath",
  10. a.dept_id AS "deptId",
  11. a.create_time AS "createTime",
  12. a.create_by AS "createBy",
  13. a.update_time AS "updateTime",
  14. a.update_by AS "updateBy"
  15. </sql>
  16. <sql id="whereStr">
  17. 1=1
  18. <!-- 快速定位 -->
  19. <if test="sqlMap.key != null and sqlMap.key != ''">
  20. AND (
  21. )
  22. </if>
  23. <!-- 高级查询dataFilter -->
  24. <if test="sqlMap.df != null and sqlMap.df != ''">
  25. AND ( ${sqlMap.df} )
  26. </if>
  27. <!-- 默认查询baseFilter -->
  28. <if test="sqlMap.bf != null and sqlMap.bf != ''">
  29. AND ( ${sqlMap.bf} )
  30. </if>
  31. <!-- 基本Query查询 -->
  32. <if test="sqlMap.baseQuery != null and sqlMap.baseQuery != ''">
  33. AND ( ${sqlMap.baseQuery} )
  34. </if>
  35. <!-- 特定Query查询 -->
  36. <if test="sqlMap.specQuery != null and sqlMap.specQuery != ''">
  37. AND ( ${sqlMap.specQuery} )
  38. </if>
  39. <if test="sqlMap.dsf != null and sqlMap.dsf != ''">
  40. AND (${sqlMap.dsf})
  41. </if>
  42. </sql>
  43. <select id="get" resultType="Report">
  44. SELECT
  45. <include refid="reportColumns"/>
  46. FROM public.{table.name} a
  47. WHERE a.id = #{id}
  48. </select>
  49. <select id="findList" resultType="Report">
  50. SELECT
  51. <include refid="reportColumns"/>
  52. FROM public.report a
  53. <where>
  54. <include refid="whereStr"/>
  55. </where>
  56. <choose>
  57. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  58. ORDER BY ${page.orderBy}
  59. </when>
  60. <otherwise>
  61. </otherwise>
  62. </choose>
  63. </select>
  64. <select id="findAllList" resultType="Report">
  65. SELECT
  66. <include refid="reportColumns"/>
  67. FROM public.report a
  68. <where>
  69. <include refid="whereStr"/>
  70. </where>
  71. <choose>
  72. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  73. ORDER BY ${page.orderBy}
  74. </when>
  75. <otherwise>
  76. </otherwise>
  77. </choose>
  78. </select>
  79. <sql id="insertColumns">
  80. id,
  81. report_title,
  82. des,
  83. publish_time,
  84. report_path,
  85. dept_id,
  86. create_time,
  87. update_time
  88. </sql>
  89. <insert id="insert">
  90. <selectKey keyProperty="id" resultType="String" order="BEFORE">
  91. <choose>
  92. <when test="id == null or id == ''">
  93. select get_next_id('report','') from dual
  94. </when>
  95. <otherwise>
  96. select #{id} from dual
  97. </otherwise>
  98. </choose>
  99. </selectKey>
  100. INSERT INTO report(
  101. <include refid="insertColumns"/>
  102. ) VALUES (
  103. #{id
  104. , jdbcType=VARCHAR
  105. },
  106. #{reportTitle
  107. , jdbcType=VARCHAR
  108. },
  109. #{des
  110. , jdbcType=VARCHAR
  111. },
  112. #{publishTime
  113. },
  114. #{reportPath
  115. , jdbcType=VARCHAR
  116. },
  117. #{deptId
  118. , jdbcType=VARCHAR
  119. },
  120. #{createTime
  121. },
  122. #{updateTime
  123. }
  124. )
  125. </insert>
  126. <insert id="insertList">
  127. INSERT INTO report(
  128. <include refid="insertColumns"/>
  129. ) select FFF.* from (
  130. <foreach collection="list" item="item" index="index" separator="UNION ALL" >
  131. select
  132. #{item.id, jdbcType=VARCHAR} as "id",
  133. #{item.reportTitle, jdbcType=VARCHAR} as "reportTitle",
  134. #{item.des, jdbcType=VARCHAR} as "des",
  135. #{item.publishTime} as "publishTime",
  136. #{item.reportPath, jdbcType=VARCHAR} as "reportPath",
  137. #{item.deptId, jdbcType=VARCHAR} as "deptId",
  138. #{item.createTime} as "createTime",
  139. #{item.updateTime} as "updateTime"
  140. from dual
  141. </foreach>
  142. ) FFF
  143. </insert>
  144. <update id="update">
  145. UPDATE report SET
  146. id = #{id},
  147. report_title = #{reportTitle},
  148. des = #{des},
  149. publish_time = #{publishTime},
  150. report_path = #{reportPath},
  151. dept_id = #{deptId},
  152. create_time = #{createTime},
  153. update_time = #{updateTime},
  154. update_by = #{updateBy}
  155. WHERE id = #{id, jdbcType=VARCHAR}
  156. </update>
  157. <update id="delete">
  158. DELETE FROM public.report
  159. WHERE
  160. <choose>
  161. <when test="id != null and id != ''">
  162. id = #{id, jdbcType=VARCHAR}
  163. </when>
  164. <otherwise>
  165. </otherwise>
  166. </choose>
  167. </update>
  168. </mapper>