SysNewsInformationMapper.xml 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  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. <!--
  4. 这个文件是自动生成的。
  5. 不要修改此文件。所有改动将在下次重新自动生成时丢失。
  6. -->
  7. <mapper namespace="com.ym.mec.cms.dal.dao.SysNewsInformationDao">
  8. <resultMap type="com.ym.mec.cms.dal.entity.SysNewsInformation" id="SysNewsInformation">
  9. <result column="id_" property="id" />
  10. <result column="title_" property="title" />
  11. <result column="content_" property="content" />
  12. <result column="cover_image_" property="coverImage" />
  13. <result column="link_url_" property="linkUrl"/>
  14. <result column="type_" property="type"/>
  15. <result column="status_" property="status" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler" />
  16. <result column="create_time_" property="createTime" />
  17. <result column="update_time_" property="updateTime" />
  18. <result column="del_flag_" property="delFlag" />
  19. <result column="href_target_" property="hrefTarget" />
  20. <result column="order_" property="order" />
  21. <result column="memo_" property="memo" />
  22. </resultMap>
  23. <sql id="queryCondition">
  24. <where>
  25. del_flag_=0
  26. <if test="type != null">
  27. and type_ = #{type}
  28. </if>
  29. <if test="status != null">
  30. and status_ = #{status, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  31. </if>
  32. <if test="title != null">
  33. and title_ like '%' #{title} '%'
  34. </if>
  35. <if test="search != null">
  36. and title_ like '%' #{search} '%'
  37. </if>
  38. </where>
  39. </sql>
  40. <!-- 根据主键查询一条记录 -->
  41. <select id="get" resultMap="SysNewsInformation" >
  42. SELECT * FROM sys_news_information WHERE id_ = #{id} AND del_flag_=0
  43. </select>
  44. <!-- 全查询 -->
  45. <select id="findAll" resultMap="SysNewsInformation">
  46. SELECT * FROM sys_news_information WHERE del_flag_=0 ORDER BY id_
  47. </select>
  48. <!-- 向数据库增加一条记录 -->
  49. <insert id="insert" parameterType="com.ym.mec.cms.dal.entity.SysNewsInformation" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
  50. INSERT INTO sys_news_information (id_,title_,content_,cover_image_,type_,status_,create_time_,update_time_,link_url_,href_target_,order_,del_flag_,memo_)
  51. VALUES(#{id},#{title},#{content},#{coverImage},#{type},#{status, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},now(),now(),#{linkUrl},#{hrefTarget},#{order},0,#{memo})
  52. </insert>
  53. <!-- 根据主键查询一条记录 -->
  54. <update id="update" parameterType="com.ym.mec.cms.dal.entity.SysNewsInformation">
  55. UPDATE sys_news_information
  56. <set>
  57. <if test="status != null">
  58. status_ = #{status, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  59. </if>
  60. <if test="title != null">
  61. title_ = #{title},
  62. </if>
  63. <if test="updateTime != null">
  64. update_time_ = NOW(),
  65. </if>
  66. <if test="content != null">
  67. content_ = #{content},
  68. </if>
  69. <if test="coverImage != null">
  70. cover_image_ = #{coverImage},
  71. </if>
  72. <if test="type != null">
  73. type_ = #{type},
  74. </if>
  75. <if test="linkUrl != null">
  76. link_url_ = #{linkUrl},
  77. </if>
  78. <if test="hrefTarget != null">
  79. href_target_ = #{hrefTarget},
  80. </if>
  81. <if test="order != null">
  82. order_ = #{order},
  83. </if>
  84. <if test="memo != null">
  85. memo_ = #{memo},
  86. </if>
  87. <if test="delFlag != null">
  88. del_flag_ = #{delFlag},
  89. </if>
  90. </set>
  91. WHERE id_ = #{id}
  92. </update>
  93. <!-- 根据主键删除一条记录 -->
  94. <delete id="delete" >
  95. DELETE FROM sys_news_information WHERE id_ = #{id}
  96. </delete>
  97. <!-- 分页查询 -->
  98. <select id="queryPage" resultMap="SysNewsInformation" parameterType="map">
  99. SELECT * FROM sys_news_information
  100. <include refid="queryCondition" />
  101. order by order_ desc,update_time_ desc
  102. <include refid="global.limit"/>
  103. </select>
  104. <!-- 查询当前表的总记录数 -->
  105. <select id="queryCount" resultType="int">
  106. SELECT COUNT(*) FROM sys_news_information
  107. <include refid="queryCondition" />
  108. </select>
  109. <select id="queryByType" resultMap="SysNewsInformation" parameterType="java.lang.Integer">
  110. SELECT * FROM sys_news_information
  111. <where>
  112. del_flag_=0
  113. <if test="type != null">
  114. and type_ = #{type}
  115. </if>
  116. </where>
  117. </select>
  118. <update id="deleteWithLogical">
  119. UPDATE sys_news_information SET del_flag_ = 1,update_time_ = NOW() WHERE id_ = #{id}
  120. </update>
  121. <!-- 分页查询 -->
  122. <select id="queryHomePage" resultMap="SysNewsInformation"
  123. parameterType="map">
  124. SELECT * FROM sys_news_information where del_flag_=0
  125. <if test="type != null">
  126. and type_ = #{type}
  127. </if>
  128. <if test="status != null">
  129. and status_ = #{status,
  130. typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  131. </if>
  132. <if test="title != null">
  133. and title_ like '%' #{title} '%'
  134. </if>
  135. <if test="search != null">
  136. and title_ like '%' #{search} '%'
  137. </if>
  138. <choose>
  139. <when test="memo != null and memo != ''">
  140. and memo_ = #{memo}
  141. </when>
  142. <otherwise>
  143. and memo_ is null
  144. </otherwise>
  145. </choose>
  146. order by order_ desc,update_time_ desc
  147. <include refid="global.limit" />
  148. </select>
  149. <!-- 查询当前表的总记录数 -->
  150. <select id="queryHomeCount" resultType="int">
  151. SELECT COUNT(*) FROM sys_news_information where del_flag_=0
  152. <if test="type != null">
  153. and type_ = #{type}
  154. </if>
  155. <if test="status != null">
  156. and status_ = #{status,
  157. typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  158. </if>
  159. <if test="title != null">
  160. and title_ like '%' #{title} '%'
  161. </if>
  162. <if test="search != null">
  163. and title_ like '%' #{search} '%'
  164. </if>
  165. <choose>
  166. <when test="memo != null and memo != ''">
  167. and memo_ = #{memo}
  168. </when>
  169. <otherwise>
  170. and memo_ is null
  171. </otherwise>
  172. </choose>
  173. </select>
  174. </mapper>