HelpCenterContentMapper.xml 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  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.keao.edu.cms.dal.dao.HelpCenterContentDao">
  4. <resultMap id="HelpCenterContent" type="com.keao.edu.cms.dal.entity.HelpCenterContent">
  5. <id column="id_" property="id" jdbcType="INTEGER" />
  6. <result column="title_" property="title" jdbcType="VARCHAR" />
  7. <result column="create_on_" property="createOn" jdbcType="TIMESTAMP" />
  8. <result column="modify_on_" property="modifyOn" jdbcType="TIMESTAMP" />
  9. <result column="status_" property="status" jdbcType="INTEGER" />
  10. <result column="order_" property="order" jdbcType="INTEGER" />
  11. <result column="catalog_id_" property="catalogId" jdbcType="INTEGER" />
  12. <association property="catalog"
  13. javaType="com.keao.edu.cms.dal.entity.HelpCenterCatalog">
  14. <result column="catalog_id_" property="id" />
  15. <result column="name_" property="text" />
  16. <result column="parent_id_" property="parentId" />
  17. </association>
  18. </resultMap>
  19. <resultMap id="HelpCenterContentBlobs" type="com.keao.edu.cms.dal.entity.HelpCenterContent"
  20. extends="HelpCenterContent">
  21. <result column="content_" property="content" jdbcType="LONGVARCHAR" />
  22. </resultMap>
  23. <!-- 查询条件 -->
  24. <sql id="queryConditionUnion">
  25. <where>
  26. <if test="catalogIds != null">
  27. and content.catalog_id_ in (${catalogIds})
  28. </if>
  29. <if test="title!= null and title != ''">
  30. and content.title_ like '%' #{title} '%'
  31. </if>
  32. <if test="status!= null">
  33. and content.status_ = #{status}
  34. </if>
  35. </where>
  36. </sql>
  37. <sql id="Base_Column_List">
  38. id_, title_, catalog_id_, create_on_, modify_on_,status_,order_
  39. </sql>
  40. <sql id="Base_Column_List_union">
  41. content.id_, content.title_, content.catalog_id_,
  42. content.create_on_,
  43. content.modify_on_,content.status_,content.content_,content.order_,
  44. catalog.id_,
  45. catalog.name_, catalog.parent_id_
  46. </sql>
  47. <sql id="Blob_Column_List">
  48. content_
  49. </sql>
  50. <select id="get" resultMap="HelpCenterContentBlobs" parameterType="java.lang.Integer">
  51. select
  52. <include refid="Base_Column_List_union" />
  53. from help_center_content content left join help_center_catalog catalog on
  54. content.catalog_id_=catalog.id_
  55. where content.id_ =
  56. #{id,jdbcType=INTEGER}
  57. </select>
  58. <select id="queryPage" parameterType="map" resultMap="HelpCenterContentBlobs">
  59. select
  60. <include refid="Base_Column_List_union" />
  61. from help_center_content content left join help_center_catalog catalog on
  62. content.catalog_id_=catalog.id_
  63. <include refid="queryConditionUnion" />
  64. order by order_ asc
  65. <include refid="global.limit" />
  66. </select>
  67. <select id="queryCount" parameterType="map" resultType="int">
  68. select count(*) from help_center_content content left join help_center_catalog catalog on
  69. content.catalog_id_=catalog.id_
  70. <include refid="queryConditionUnion" />
  71. </select>
  72. <delete id="delete" parameterType="java.lang.Integer">
  73. delete from help_center_content
  74. where id_ = #{id,jdbcType=INTEGER}
  75. </delete>
  76. <delete id="deleteContentByCatalog" parameterType="java.lang.Integer">
  77. delete from help_center_content
  78. where catalog_id_ = #{catalogId,jdbcType=INTEGER}
  79. </delete>
  80. <insert id="insert" parameterType="com.keao.edu.cms.dal.entity.HelpCenterContent">
  81. insert into help_center_content
  82. (id_, title_, catalog_id_,
  83. create_on_, modify_on_, content_,status_,order_
  84. )
  85. values
  86. (#{id,jdbcType=INTEGER}, #{title,jdbcType=VARCHAR},
  87. #{catalogId,jdbcType=INTEGER},
  88. #{createOn,jdbcType=TIMESTAMP},
  89. #{modifyOn,jdbcType=TIMESTAMP}, #{content,jdbcType=LONGVARCHAR},#{status,jdbcType=INTEGER},#{order,jdbcType=INTEGER}
  90. )
  91. </insert>
  92. <update id="update" parameterType="com.keao.edu.cms.dal.entity.HelpCenterContent">
  93. update help_center_content
  94. <set>
  95. <if test="title != null">
  96. title_ = #{title,jdbcType=VARCHAR},
  97. </if>
  98. <if test="catalogId != null">
  99. catalog_id_ = #{catalogId,jdbcType=INTEGER},
  100. </if>
  101. <if test="createOn != null">
  102. create_on_ = #{createOn,jdbcType=TIMESTAMP},
  103. </if>
  104. <if test="modifyOn != null">
  105. modify_on_ = #{modifyOn,jdbcType=TIMESTAMP},
  106. </if>
  107. <if test="content != null">
  108. content_ = #{content,jdbcType=LONGVARCHAR},
  109. </if>
  110. <if test="status != null">
  111. status_ = #{status,jdbcType=INTEGER},
  112. </if>
  113. <if test="order != null">
  114. order_ = #{order,jdbcType=INTEGER},
  115. </if>
  116. </set>
  117. where id_ = #{id,jdbcType=INTEGER}
  118. </update>
  119. <update id="updateBlobs" parameterType="com.keao.edu.cms.dal.entity.HelpCenterContent">
  120. update help_center_content
  121. set title_ = #{title,jdbcType=VARCHAR},
  122. catalog_id_ =
  123. #{catalogId,jdbcType=INTEGER},
  124. create_on_ =
  125. #{createOn,jdbcType=TIMESTAMP},
  126. modify_on_ =
  127. #{modifyOn,jdbcType=TIMESTAMP},
  128. content_ =
  129. #{content,jdbcType=LONGVARCHAR},
  130. status_= #{status,jdbcType=INTEGER},
  131. order_= #{order,jdbcType=INTEGER}
  132. where id_ = #{id,jdbcType=INTEGER}
  133. </update>
  134. <update id="updateByKey" parameterType="com.keao.edu.cms.dal.entity.HelpCenterContent">
  135. update help_center_content
  136. set title_ = #{title,jdbcType=VARCHAR},
  137. catalog_id_ =
  138. #{catalogId,jdbcType=INTEGER},
  139. create_on_ =
  140. #{createOn,jdbcType=TIMESTAMP},
  141. modify_on_ =
  142. #{modifyOn,jdbcType=TIMESTAMP},
  143. status_ = #{status,jdbcType=INTEGER},
  144. order_ = #{order,jdbcType=INTEGER},
  145. where id_ = #{id,jdbcType=INTEGER}
  146. </update>
  147. <update id="updateContentByCatalog" parameterType="map">
  148. update help_center_content set status_=#{status} where catalog_id_=#{catalogId}
  149. </update>
  150. </mapper>