SysNewsInformationMapper.xml 9.5 KB

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