1
0

CommonQuerySqlServerMapper.xml 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  3. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  4. <mapper namespace="com.izouma.awesomeadmin.dao.CommonQuerySqlServerMapper">
  5. <select id="getTableListByPage" resultType="java.util.Map">
  6. SELECT * FROM ${record.tableName}
  7. <where>
  8. <if test="record.advancedQuery != null and !&quot;&quot;.equals(record.advancedQuery)">
  9. <foreach item="item" index="index" collection="record.advancedQuery.split('_;')">
  10. <choose>
  11. <when test="item.indexOf('like') != -1">
  12. <foreach item="itemDetail" index="detailIndex" collection="item.split('_,')">
  13. <if test="detailIndex == 3">
  14. concat('%',#{itemDetail},'%')
  15. </if>
  16. <if test="detailIndex &lt; 3">
  17. ${itemDetail}
  18. </if>
  19. </foreach>
  20. </when>
  21. <otherwise>
  22. <foreach item="itemDetail" index="detailIndex" collection="item.split('_,')">
  23. <if test="detailIndex == 3">
  24. #{itemDetail}
  25. </if>
  26. <if test="detailIndex &lt; 3">
  27. ${itemDetail}
  28. </if>
  29. </foreach>
  30. </otherwise>
  31. </choose>
  32. </foreach>
  33. </if>
  34. <if test="record.searchKey != null and !&quot;&quot;.equals(record.searchKey)">
  35. <trim prefix="and (" suffix=")" prefixOverrides="OR">
  36. <foreach item="item" index="index" collection="record.searchColumn.split('_,')">
  37. OR ${item} LIKE concat('%',#{record.searchKey},'%')
  38. </foreach>
  39. </trim>
  40. </if>
  41. </where>
  42. <if test="record.orderByStr != null and !&quot;&quot;.equals(record.orderByStr)">
  43. order by
  44. <trim suffixOverrides=",">
  45. <foreach item="item" index="index" separator="," collection="record.orderByStr.split('_;')">
  46. <foreach item="itemDetail" index="detailIndex" collection="item.split('_,')">
  47. ${itemDetail}
  48. </foreach>
  49. </foreach>
  50. </trim>
  51. </if>
  52. </select>
  53. <select id="getTableListAll" resultType="java.util.Map">
  54. SELECT * FROM ${tableName}
  55. <where>
  56. <if test="advancedQuery != null and !&quot;&quot;.equals(advancedQuery)">
  57. <foreach item="item" index="index" collection="advancedQuery.split('_;')">
  58. <choose>
  59. <when test="item.indexOf('like') != -1">
  60. <foreach item="itemDetail" index="detailIndex" collection="item.split('_,')">
  61. <if test="detailIndex == 3">
  62. concat('%',#{itemDetail},'%')
  63. </if>
  64. <if test="detailIndex &lt; 3">
  65. ${itemDetail}
  66. </if>
  67. </foreach>
  68. </when>
  69. <otherwise>
  70. <foreach item="itemDetail" index="detailIndex" collection="item.split('_,')">
  71. <if test="detailIndex == 3">
  72. #{itemDetail}
  73. </if>
  74. <if test="detailIndex &lt; 3">
  75. ${itemDetail}
  76. </if>
  77. </foreach>
  78. </otherwise>
  79. </choose>
  80. </foreach>
  81. </if>
  82. <if test="searchKey != null and !&quot;&quot;.equals(searchKey)">
  83. <trim prefix="and (" suffix=")" prefixOverrides="OR">
  84. <foreach item="item" index="index" collection="searchColumn.split('_,')">
  85. OR ${item} LIKE concat('%',#{searchKey},'%')
  86. </foreach>
  87. </trim>
  88. </if>
  89. </where>
  90. <if test="orderByStr != null and !&quot;&quot;.equals(orderByStr)">
  91. order by
  92. <trim suffixOverrides=",">
  93. <foreach item="item" index="index" separator="," collection="orderByStr.split('_;')">
  94. <foreach item="itemDetail" index="detailIndex" collection="item.split('_,')">
  95. ${itemDetail}
  96. </foreach>
  97. </foreach>
  98. </trim>
  99. </if>
  100. </select>
  101. <select id="selectByPrimaryKey" resultType="java.util.Map" parameterType="java.util.Map">
  102. select
  103. *
  104. from ${tableName}
  105. where id = #{primaryKey,jdbcType=INTEGER}
  106. </select>
  107. <insert id="insertSelective" parameterType="java.util.Map" useGeneratedKeys="true"
  108. keyProperty="id">
  109. insert into ${tableName}
  110. <trim prefix="(" suffix=")" suffixOverrides=",">
  111. <foreach item="item" index="index" collection="formData.keys">
  112. <if test="formData[item]!= null">
  113. ${item},
  114. </if>
  115. </foreach>
  116. </trim>
  117. <trim prefix="values (" suffix=")" suffixOverrides=",">
  118. <foreach item="item" index="index" collection="formData.keys">
  119. <if test="formData[item]!= null">
  120. #{formData[${item}]},
  121. </if>
  122. </foreach>
  123. </trim>
  124. </insert>
  125. <update id="updateByPrimaryKeySelective" parameterType="java.util.Map">
  126. update ${tableName}
  127. <set>
  128. <foreach item="item" index="index" collection="formData.keys">
  129. <if test="formData[item]!= null">
  130. ${item} = #{formData[${item}]},
  131. </if>
  132. </foreach>
  133. </set>
  134. where id = #{primaryKey,jdbcType=INTEGER}
  135. </update>
  136. <delete id="delete">
  137. delete from ${tableName}
  138. where id = #{primaryKey,jdbcType=INTEGER}
  139. </delete>
  140. </mapper>