SysNewsInformationMapper.xml 10 KB

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