SysNewsInformationMapper.xml 8.8 KB

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