SysNewsInformationMapper.xml 9.7 KB

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