EduNewsMapper.xml 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  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.base.mapper.EduNewsMapper">
  4. <sql id="eduNewsColumns">
  5. a.id AS "id",
  6. a.type_id AS "typeId",
  7. a.source AS "source",
  8. a.cover AS "cover",
  9. a.title AS "title",
  10. a.content AS "content",
  11. a.create_by AS "createBy.id",
  12. a.create_date AS "createDate",
  13. a.update_by AS "updateBy.id",
  14. a.update_date AS "updateDate",
  15. a.del_flag AS "delFlag",
  16. a.display AS "display"
  17. </sql>
  18. <sql id="eduNewsJoins">
  19. </sql>
  20. <resultMap type="EduNews" id="EduNewsResult" autoMapping="true">
  21. <result column="content" property="content" typeHandler="com.jeeplus.core.mapper.ConvertBlobTypeHandler"/>
  22. </resultMap>
  23. <select id="get" resultMap="EduNewsResult" >
  24. SELECT
  25. <include refid="eduNewsColumns"/>
  26. FROM edu_news a
  27. <include refid="eduNewsJoins"/>
  28. WHERE a.id = #{id}
  29. </select>
  30. <select id="findList" resultMap="EduNewsResult" >
  31. SELECT
  32. <include refid="eduNewsColumns"/>
  33. FROM edu_news a
  34. <include refid="eduNewsJoins"/>
  35. <where>
  36. a.del_flag = #{DEL_FLAG_NORMAL}
  37. ${dataScope}
  38. <if test="typeId != null and typeId != ''">
  39. AND a.type_id = #{typeId}
  40. </if>
  41. <if test="title != null and title != ''">
  42. AND a.title LIKE concat('%',#{title},'%')
  43. </if>
  44. </where>
  45. <choose>
  46. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  47. ORDER BY ${page.orderBy}
  48. </when>
  49. <otherwise>
  50. ORDER BY a.update_date DESC
  51. </otherwise>
  52. </choose>
  53. </select>
  54. <select id="findAllList" resultMap="EduNewsResult" >
  55. SELECT
  56. <include refid="eduNewsColumns"/>
  57. FROM edu_news a
  58. <include refid="eduNewsJoins"/>
  59. <where>
  60. a.del_flag = #{DEL_FLAG_NORMAL}
  61. ${dataScope}
  62. </where>
  63. <choose>
  64. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  65. ORDER BY ${page.orderBy}
  66. </when>
  67. <otherwise>
  68. ORDER BY a.update_date DESC
  69. </otherwise>
  70. </choose>
  71. </select>
  72. <insert id="insert">
  73. INSERT INTO edu_news(
  74. id,
  75. type_id,
  76. source,
  77. cover,
  78. title,
  79. content,
  80. create_by,
  81. create_date,
  82. update_by,
  83. update_date,
  84. del_flag,
  85. display
  86. ) VALUES (
  87. #{id},
  88. #{typeId},
  89. #{source},
  90. #{cover},
  91. #{title},
  92. #{content},
  93. #{createBy.id},
  94. #{createDate},
  95. #{updateBy.id},
  96. #{updateDate},
  97. #{delFlag},
  98. #{display}
  99. )
  100. </insert>
  101. <update id="update">
  102. UPDATE edu_news SET
  103. type_id = #{typeId},
  104. source = #{source},
  105. cover = #{cover},
  106. title = #{title},
  107. content = #{content},
  108. update_by = #{updateBy.id},
  109. update_date = #{updateDate},
  110. display = #{display}
  111. WHERE id = #{id}
  112. </update>
  113. <!--物理删除-->
  114. <update id="delete">
  115. DELETE FROM edu_news
  116. WHERE id = #{id}
  117. </update>
  118. <!--逻辑删除-->
  119. <update id="deleteByLogic">
  120. UPDATE edu_news SET
  121. del_flag = #{DEL_FLAG_DELETE}
  122. WHERE id = #{id}
  123. </update>
  124. <!-- 根据实体名称和字段名称和字段值获取唯一记录 -->
  125. <select id="findUniqueByProperty" resultType="EduNews" statementType="STATEMENT">
  126. select * FROM edu_news where ${propertyName} = '${value}'
  127. </select>
  128. </mapper>