TestInterfaceMapper.xml 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  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.tools.mapper.TestInterfaceMapper">
  4. <sql id="testInterfaceColumns">
  5. a.id AS "id",
  6. a.name AS "name",
  7. a.type AS "type",
  8. a.url AS "url",
  9. a.body AS "body",
  10. a.successmsg AS "successmsg",
  11. a.errormsg AS "errormsg",
  12. a.remarks AS "remarks",
  13. a.del_flag AS "delFlag"
  14. </sql>
  15. <sql id="testInterfaceJoins">
  16. </sql>
  17. <select id="get" resultType="TestInterface">
  18. SELECT
  19. <include refid="testInterfaceColumns"/>
  20. FROM test_interface a
  21. <include refid="testInterfaceJoins"/>
  22. WHERE a.id = #{id}
  23. </select>
  24. <select id="findList" resultType="TestInterface">
  25. SELECT
  26. <include refid="testInterfaceColumns"/>
  27. FROM test_interface a
  28. <include refid="testInterfaceJoins"/>
  29. <where>
  30. a.del_flag = #{DEL_FLAG_NORMAL}
  31. <if test="name != null and name != ''">
  32. AND a.name LIKE
  33. <if test="dbName == 'oracle'">'%'||#{name}||'%'</if>
  34. <if test="dbName == 'mssql'">'%'+#{name}+'%'</if>
  35. <if test="dbName == 'mysql'">concat('%',#{name},'%')</if>
  36. </if>
  37. <if test="type != null and type != ''">
  38. AND a.type = #{type}
  39. </if>
  40. </where>
  41. <choose>
  42. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  43. ORDER BY ${page.orderBy}
  44. </when>
  45. <otherwise>
  46. </otherwise>
  47. </choose>
  48. </select>
  49. <select id="findAllList" resultType="TestInterface">
  50. SELECT
  51. <include refid="testInterfaceColumns"/>
  52. FROM test_interface a
  53. <include refid="testInterfaceJoins"/>
  54. <where>
  55. a.del_flag = #{DEL_FLAG_NORMAL}
  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. </otherwise>
  63. </choose>
  64. </select>
  65. <insert id="insert">
  66. INSERT INTO test_interface(
  67. id,
  68. name,
  69. type,
  70. url,
  71. body,
  72. successmsg,
  73. errormsg,
  74. remarks,
  75. del_flag
  76. ) VALUES (
  77. #{id},
  78. #{name},
  79. #{type},
  80. #{url},
  81. #{body},
  82. #{successmsg},
  83. #{errormsg},
  84. #{remarks},
  85. #{delFlag}
  86. )
  87. </insert>
  88. <update id="update">
  89. UPDATE test_interface SET
  90. name = #{name},
  91. type = #{type},
  92. url = #{url},
  93. body = #{body},
  94. successmsg = #{successmsg},
  95. errormsg = #{errormsg},
  96. remarks = #{remarks}
  97. WHERE id = #{id}
  98. </update>
  99. <!--物理删除-->
  100. <update id="delete">
  101. DELETE FROM test_interface
  102. WHERE id = #{id}
  103. </update>
  104. <!--逻辑删除-->
  105. <update id="deleteByLogic">
  106. UPDATE test_interface SET
  107. del_flag = #{DEL_FLAG_DELETE}
  108. WHERE id = #{id}
  109. </update>
  110. <!-- 根据实体名称和字段名称和字段值获取唯一记录 -->
  111. <select id="findUniqueByProperty" resultType="TestInterface" statementType="STATEMENT">
  112. select * FROM test_interface where ${propertyName} = '${value}'
  113. </select>
  114. </mapper>