TestCountryMapper.xml 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  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.jeeplus.modules.test.grid.mapper.TestCountryMapper">
  4. <sql id="testCountryColumns">
  5. a.id AS "id",
  6. a.name AS "name",
  7. a.sum AS "sum",
  8. a.continent_id AS "continent.id",
  9. a.create_by AS "createBy.id",
  10. a.create_date AS "createDate",
  11. a.update_by AS "updateBy.id",
  12. a.update_date AS "updateDate",
  13. a.remarks AS "remarks",
  14. a.del_flag AS "delFlag",
  15. continent.name AS "continent.name"
  16. </sql>
  17. <sql id="testCountryJoins">
  18. LEFT JOIN test_continent continent ON continent.id = a.continent_id
  19. </sql>
  20. <select id="get" resultType="TestCountry" >
  21. SELECT
  22. <include refid="testCountryColumns"/>
  23. FROM test_country a
  24. <include refid="testCountryJoins"/>
  25. WHERE a.id = #{id}
  26. </select>
  27. <select id="findList" resultType="TestCountry" >
  28. SELECT
  29. <include refid="testCountryColumns"/>
  30. FROM test_country a
  31. <include refid="testCountryJoins"/>
  32. <where>
  33. a.del_flag = #{DEL_FLAG_NORMAL}
  34. ${dataScope}
  35. <if test="continent != null and continent.id != null and continent.id != ''">
  36. AND a.continent_id = #{continent.id}
  37. </if>
  38. </where>
  39. <choose>
  40. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  41. ORDER BY ${page.orderBy}
  42. </when>
  43. <otherwise>
  44. ORDER BY a.update_date DESC
  45. </otherwise>
  46. </choose>
  47. </select>
  48. <select id="findAllList" resultType="TestCountry" >
  49. SELECT
  50. <include refid="testCountryColumns"/>
  51. FROM test_country a
  52. <include refid="testCountryJoins"/>
  53. <where>
  54. a.del_flag = #{DEL_FLAG_NORMAL}
  55. ${dataScope}
  56. </where>
  57. <choose>
  58. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  59. ORDER BY ${page.orderBy}
  60. </when>
  61. <otherwise>
  62. ORDER BY a.update_date DESC
  63. </otherwise>
  64. </choose>
  65. </select>
  66. <insert id="insert">
  67. INSERT INTO test_country(
  68. id,
  69. name,
  70. sum,
  71. continent_id,
  72. create_by,
  73. create_date,
  74. update_by,
  75. update_date,
  76. remarks,
  77. del_flag
  78. ) VALUES (
  79. #{id},
  80. #{name},
  81. #{sum},
  82. #{continent.id},
  83. #{createBy.id},
  84. #{createDate},
  85. #{updateBy.id},
  86. #{updateDate},
  87. #{remarks},
  88. #{delFlag}
  89. )
  90. </insert>
  91. <update id="update">
  92. UPDATE test_country SET
  93. name = #{name},
  94. sum = #{sum},
  95. continent_id = #{continent.id},
  96. update_by = #{updateBy.id},
  97. update_date = #{updateDate},
  98. remarks = #{remarks}
  99. WHERE id = #{id}
  100. </update>
  101. <!--物理删除-->
  102. <update id="delete">
  103. DELETE FROM test_country
  104. WHERE id = #{id}
  105. </update>
  106. <!--逻辑删除-->
  107. <update id="deleteByLogic">
  108. UPDATE test_country SET
  109. del_flag = #{DEL_FLAG_DELETE}
  110. WHERE id = #{id}
  111. </update>
  112. <!-- 根据实体名称和字段名称和字段值获取唯一记录 -->
  113. <select id="findUniqueByProperty" resultType="TestCountry" statementType="STATEMENT">
  114. select * FROM test_country where ${propertyName} = '${value}'
  115. </select>
  116. </mapper>