TestPicMapper.xml 2.5 KB

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