SysNewsInformationMapper.xml 11 KB

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