CommonQueryMapper.xml 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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.CommonQueryMapper">
  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. </where>
  35. <if test="record.orderByStr != null and !&quot;&quot;.equals(record.orderByStr)">
  36. order by
  37. <trim suffixOverrides=",">
  38. <foreach item="item" index="index" separator="," collection="record.orderByStr.split('_;')">
  39. <foreach item="itemDetail" index="detailIndex" collection="item.split('_,')">
  40. ${itemDetail}
  41. </foreach>
  42. </foreach>
  43. </trim>
  44. </if>
  45. </select>
  46. <select id="getTableListAll" resultType="java.util.Map">
  47. SELECT * FROM ${tableName}
  48. <where>
  49. <if test="advancedQuery != null and !&quot;&quot;.equals(advancedQuery)">
  50. <foreach item="item" index="index" collection="advancedQuery.split('_;')">
  51. <choose>
  52. <when test="item.indexOf('like') != -1">
  53. <foreach item="itemDetail" index="detailIndex" collection="item.split('_,')">
  54. <if test="detailIndex == 3">
  55. concat('%',#{itemDetail},'%')
  56. </if>
  57. <if test="detailIndex &lt; 3">
  58. ${itemDetail}
  59. </if>
  60. </foreach>
  61. </when>
  62. <otherwise>
  63. <foreach item="itemDetail" index="detailIndex" collection="item.split('_,')">
  64. <if test="detailIndex == 3">
  65. #{itemDetail}
  66. </if>
  67. <if test="detailIndex &lt; 3">
  68. ${itemDetail}
  69. </if>
  70. </foreach>
  71. </otherwise>
  72. </choose>
  73. </foreach>
  74. </if>
  75. </where>
  76. <if test="orderByStr != null and !&quot;&quot;.equals(orderByStr)">
  77. order by
  78. <trim suffixOverrides=",">
  79. <foreach item="item" index="index" separator="," collection="orderByStr.split('_;')">
  80. <foreach item="itemDetail" index="detailIndex" collection="item.split('_,')">
  81. ${itemDetail}
  82. </foreach>
  83. </foreach>
  84. </trim>
  85. </if>
  86. </select>
  87. </mapper>