SysNewsInformationMapper.xml 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276
  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.yonge.cooleshow.cms.dal.dao.SysNewsInformationDao">
  8. <resultMap type="com.yonge.cooleshow.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="video_cover_image_" property="videoCoverImage" />
  14. <result column="link_url_" property="linkUrl"/>
  15. <result column="type_" property="type"/>
  16. <result column="online_time_" property="onlineTime"/>
  17. <result column="offline_time_" property="offlineTime"/>
  18. <result column="sub_type_" property="subType"/>
  19. <result column="status_" property="status" typeHandler="com.yonge.cooleshow.common.dal.CustomEnumTypeHandler" />
  20. <result column="create_time_" property="createTime" />
  21. <result column="update_time_" property="updateTime" />
  22. <result column="del_flag_" property="delFlag" />
  23. <result column="href_target_" property="hrefTarget" />
  24. <result column="order_" property="order" />
  25. <result column="memo_" property="memo" />
  26. <result column="attribute1_" property="attribute1" />
  27. <result column="attribute2_" property="attribute2" />
  28. <result column="show_time_" property="showTime" />
  29. <result column="update_by_" property="updateBy" />
  30. <result column="create_by_" property="createBy" />
  31. </resultMap>
  32. <resultMap type="com.yonge.cooleshow.cms.dto.SysNewsInformationDto" id="SysNewsInformationDto" extends="SysNewsInformation">
  33. <result column="updateName" property="updateName" />
  34. </resultMap>
  35. <sql id="queryCondition">
  36. <where>
  37. sni.del_flag_=0
  38. <if test="type != null">
  39. and sni.type_ = #{type}
  40. </if>
  41. <if test="subType != null and subType != ''">
  42. and sni.sub_type_ = #{subType}
  43. </if>
  44. <if test="status != null">
  45. and sni.status_ = #{status, typeHandler=com.yonge.cooleshow.common.dal.CustomEnumTypeHandler}
  46. </if>
  47. <if test="title != null">
  48. and (sni.title_ like '%' #{title} '%'
  49. or sni.id_ like concat('%',#{titile},'%')
  50. )
  51. </if>
  52. <if test="search != null">
  53. and sni.title_ like '%' #{search} '%'
  54. </if>
  55. <if test="subjectId != null">
  56. and find_in_set(#{subjectId},sni.subject_id_list_)
  57. </if>
  58. <if test="platformType != null and platformType != ''">
  59. <if test="platformType != 'ADMIN'" >
  60. and sni.status_ = 1
  61. <if test="type != 5">
  62. and sni.online_time_ &lt;= now()
  63. and if(sni.offline_time_ is not null,sni.offline_time_ &gt;= now(),1=1)
  64. </if>
  65. </if>
  66. </if>
  67. <if test="excludeIds!=null and excludeIds.size()>0">
  68. AND sni.id_ NOT IN
  69. <foreach collection="excludeIds" item="excludeId" open="(" close=")" separator=",">
  70. #{excludeId}
  71. </foreach>
  72. </if>
  73. <if test="version != null and version != ''">
  74. and sni.attribute1_ = #{version}
  75. </if>
  76. </where>
  77. </sql>
  78. <!-- 根据主键查询一条记录 -->
  79. <select id="get" resultMap="SysNewsInformation" >
  80. SELECT * FROM sys_news_information WHERE id_ = #{id} AND del_flag_=0
  81. </select>
  82. <!-- 全查询 -->
  83. <select id="findAll" resultMap="SysNewsInformation">
  84. SELECT * FROM sys_news_information WHERE del_flag_=0 ORDER BY id_
  85. </select>
  86. <!-- 向数据库增加一条记录 -->
  87. <insert id="insert" parameterType="com.yonge.cooleshow.cms.dal.entity.SysNewsInformation" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
  88. INSERT INTO sys_news_information (id_,title_,content_,cover_image_,video_cover_image_,type_,online_time_,offline_time_,sub_type_,status_,create_time_,update_time_,link_url_,href_target_,order_,del_flag_,memo_,attribute1_,attribute2_,subject_id_list_,create_by_,update_by_,show_time_)
  89. VALUES(#{id},#{title},#{content},#{coverImage},#{videoCoverImage},#{type},#{onlineTime},#{offlineTime},#{subType},#{status, typeHandler=com.yonge.cooleshow.common.dal.CustomEnumTypeHandler},now(),now(),#{linkUrl},#{hrefTarget},#{order},0,#{memo},#{attribute1},#{attribute2},#{subjectIdList},#{createBy},#{updateBy},#{showTime})
  90. </insert>
  91. <!-- 根据主键查询一条记录 -->
  92. <update id="update" parameterType="com.yonge.cooleshow.cms.dal.entity.SysNewsInformation">
  93. UPDATE sys_news_information
  94. <set>
  95. <if test="status != null">
  96. status_ = #{status, typeHandler=com.yonge.cooleshow.common.dal.CustomEnumTypeHandler},
  97. </if>
  98. <if test="title != null">
  99. title_ = #{title},
  100. </if>
  101. <if test="updateTime != null">
  102. update_time_ = NOW(),
  103. </if>
  104. <if test="content != null">
  105. content_ = #{content},
  106. </if>
  107. <if test="coverImage != null">
  108. cover_image_ = #{coverImage},
  109. </if>
  110. <if test="videoCoverImage != null">
  111. video_cover_image_ = #{videoCoverImage},
  112. </if>
  113. <if test="type != null">
  114. type_ = #{type},
  115. </if>
  116. online_time_ = #{onlineTime},
  117. offline_time_ = #{offlineTime},
  118. <if test="subType != null and subType != ''">
  119. sub_type_ = #{subType},
  120. </if>
  121. <if test="linkUrl != null">
  122. link_url_ = #{linkUrl},
  123. </if>
  124. <if test="hrefTarget != null">
  125. href_target_ = #{hrefTarget},
  126. </if>
  127. <if test="order != null">
  128. order_ = #{order},
  129. </if>
  130. <if test="memo != null">
  131. memo_ = #{memo},
  132. </if>
  133. <if test="delFlag != null">
  134. del_flag_ = #{delFlag},
  135. </if>
  136. <if test="attribute1 != null">
  137. attribute1_ = #{attribute1},
  138. </if>
  139. <if test="attribute2 != null">
  140. attribute2_ = #{attribute2},
  141. </if>
  142. <if test="subjectIdList != null">
  143. subject_id_list_ = #{subjectIdList},
  144. </if>
  145. <if test="updateBy != null">
  146. update_by_ = #{updateBy},
  147. </if>
  148. <if test="showTime != null">
  149. show_time_ = #{showTime}
  150. </if>
  151. </set>
  152. WHERE id_ = #{id}
  153. </update>
  154. <!-- 根据主键删除一条记录 -->
  155. <delete id="delete" >
  156. DELETE FROM sys_news_information WHERE id_ = #{id}
  157. </delete>
  158. <!-- 分页查询 -->
  159. <select id="selectPage" resultMap="SysNewsInformationDto" parameterType="map">
  160. SELECT sni.*
  161. , su.username_ as updateName
  162. FROM sys_news_information sni
  163. left join sys_user su on sni.update_by_ = su.id_
  164. <include refid="queryCondition" />
  165. order by sni.status_ desc,sni.order_ desc,sni.update_time_ desc
  166. <include refid="global.limit"/>
  167. </select>
  168. <!-- 查询当前表的总记录数 -->
  169. <select id="selectPageCount" resultType="int">
  170. SELECT COUNT(sni.id_) FROM sys_news_information sni
  171. <include refid="queryCondition" />
  172. </select>
  173. <select id="queryByType" resultMap="SysNewsInformation" parameterType="java.lang.Integer">
  174. SELECT * FROM sys_news_information
  175. <where>
  176. del_flag_=0
  177. <if test="type != null">
  178. and type_ = #{type}
  179. </if>
  180. </where>
  181. </select>
  182. <update id="deleteWithLogical">
  183. UPDATE sys_news_information SET del_flag_ = 1,update_time_ = NOW() WHERE id_ = #{id}
  184. </update>
  185. <!-- 分页查询 -->
  186. <select id="queryHomePage" resultMap="SysNewsInformation"
  187. parameterType="map">
  188. SELECT sni.*
  189. FROM sys_news_information sni
  190. where sni.del_flag_=0
  191. <if test="type != null">
  192. and sni.type_ = #{type}
  193. </if>
  194. <if test="subType != null and subType != ''">
  195. and sni.sub_type_ = #{subType}
  196. </if>
  197. <if test="status != null">
  198. and sni.status_ = #{status,
  199. typeHandler=com.yonge.cooleshow.common.dal.CustomEnumTypeHandler}
  200. </if>
  201. <if test="title != null">
  202. and sni.title_ like '%' #{title} '%'
  203. </if>
  204. <if test="search != null">
  205. and sni.title_ like '%' #{search} '%'
  206. </if>
  207. <if test="excludeIds!=null and excludeIds.size()>0">
  208. AND sni.id_ NOT IN
  209. <foreach collection="excludeIds" item="excludeId" open="(" close=")" separator=",">
  210. #{excludeId}
  211. </foreach>
  212. </if>
  213. <if test="subjectId != null">
  214. and find_in_set(#{subjectId},sni.subject_id_list_)
  215. </if>
  216. group by sni.id_
  217. order by sni.status_ desc,sni.order_ desc,sni.update_time_ desc
  218. <include refid="global.limit" />
  219. </select>
  220. <!-- 查询当前表的总记录数 -->
  221. <select id="queryHomeCount" resultType="int">
  222. SELECT COUNT(sni.id_) FROM sys_news_information sni where sni.del_flag_=0
  223. <if test="type != null">
  224. and sni.type_ = #{type}
  225. </if>
  226. <if test="subType != null">
  227. and sni.sub_type_ = #{subType}
  228. </if>
  229. <if test="status != null">
  230. and sni.status_ = #{status,
  231. typeHandler=com.yonge.cooleshow.common.dal.CustomEnumTypeHandler}
  232. </if>
  233. <if test="title != null">
  234. and sni.title_ like '%' #{title} '%'
  235. </if>
  236. <if test="search != null">
  237. and sni.title_ like '%' #{search} '%'
  238. </if>
  239. <if test="subjectId != null">
  240. and find_in_set(#{subjectId},sni.subject_id_list_)
  241. </if>
  242. </select>
  243. <select id="queryNeedUpdateStatusList" resultMap="SysNewsInformation" >
  244. SELECT * FROM sys_news_information WHERE del_flag_ = 0 and (
  245. (online_time_ is not null and now() between online_time_ and offline_time_ and status_ = 0)
  246. or (offline_time_ is not null and offline_time_ &lt;= now() and status_ = 1)
  247. or (online_time_ is not null and online_time_ &gt;= now() and status_ = 1)
  248. )
  249. </select>
  250. <select id="queryById" resultMap="SysNewsInformationDto" >
  251. SELECT sni.*,su.username_ as updateName
  252. FROM sys_news_information sni
  253. left join sys_user su on sni.update_by_ = su.id_
  254. where sni.id_ = #{id}
  255. </select>
  256. <update id="updateStatus">
  257. UPDATE sys_news_information SET status_ = if(status_ = 0,1,0),update_time_ = NOW() WHERE id_ = #{id}
  258. </update>
  259. </mapper>