TestNoteMapper.xml 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  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.note.mapper.TestNoteMapper">
  4. <sql id="testNoteColumns">
  5. a.id AS "id",
  6. a.create_by AS "createBy.id",
  7. a.create_date AS "createDate",
  8. a.update_by AS "updateBy.id",
  9. a.update_date AS "updateDate",
  10. a.remarks AS "remarks",
  11. a.del_flag AS "delFlag",
  12. a.title AS "title",
  13. a.contents AS "contents"
  14. </sql>
  15. <sql id="testNoteJoins">
  16. </sql>
  17. <resultMap type="TestNote" id="TestNoteResult" autoMapping="true">
  18. <result column="contents" property="contents" typeHandler="com.jeeplus.core.mapper.ConvertBlobTypeHandler"/>
  19. </resultMap>
  20. <select id="get" resultMap="TestNoteResult" >
  21. SELECT
  22. <include refid="testNoteColumns"/>
  23. FROM test_note a
  24. <include refid="testNoteJoins"/>
  25. WHERE a.id = #{id}
  26. </select>
  27. <select id="findList" resultMap="TestNoteResult" >
  28. SELECT
  29. <include refid="testNoteColumns"/>
  30. FROM test_note a
  31. <include refid="testNoteJoins"/>
  32. <where>
  33. a.del_flag = #{DEL_FLAG_NORMAL}
  34. ${dataScope}
  35. <if test="title != null and title != ''">
  36. AND a.title = #{title}
  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" resultMap="TestNoteResult" >
  49. SELECT
  50. <include refid="testNoteColumns"/>
  51. FROM test_note a
  52. <include refid="testNoteJoins"/>
  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_note(
  68. id,
  69. create_by,
  70. create_date,
  71. update_by,
  72. update_date,
  73. remarks,
  74. del_flag,
  75. title,
  76. contents
  77. ) VALUES (
  78. #{id},
  79. #{createBy.id},
  80. #{createDate},
  81. #{updateBy.id},
  82. #{updateDate},
  83. #{remarks},
  84. #{delFlag},
  85. #{title},
  86. #{contents}
  87. )
  88. </insert>
  89. <update id="update">
  90. UPDATE test_note SET
  91. update_by = #{updateBy.id},
  92. update_date = #{updateDate},
  93. remarks = #{remarks},
  94. title = #{title},
  95. contents = #{contents}
  96. WHERE id = #{id}
  97. </update>
  98. <!--物理删除-->
  99. <update id="delete">
  100. DELETE FROM test_note
  101. WHERE id = #{id}
  102. </update>
  103. <!--逻辑删除-->
  104. <update id="deleteByLogic">
  105. UPDATE test_note SET
  106. del_flag = #{DEL_FLAG_DELETE}
  107. WHERE id = #{id}
  108. </update>
  109. <!-- 根据实体名称和字段名称和字段值获取唯一记录 -->
  110. <select id="findUniqueByProperty" resultType="TestNote" statementType="STATEMENT">
  111. select * FROM test_note where ${propertyName} = '${value}'
  112. </select>
  113. </mapper>