PoNewsMapper.xml 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper
  3. PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5. <mapper namespace="com.ruoyi.system.mapper.PoNewsMapper">
  6. <resultMap type="PoNews" id="PoNewsResult">
  7. <result property="newsId" column="news_id" />
  8. <result property="newsTitle" column="news_title" />
  9. <result property="newsContent" column="news_content" />
  10. <result property="status" column="status" />
  11. <result property="createBy" column="create_by" />
  12. <result property="createTime" column="create_time" />
  13. <result property="updateBy" column="update_by" />
  14. <result property="updateTime" column="update_time" />
  15. <result property="remark" column="remark" />
  16. <result property="sort" column="sort" />
  17. <result property="publisherId" column="publisher_id" />
  18. <result property="delFlag" column="del_flag"/>
  19. <result property="image" column="image"/>
  20. <result property="newsTime" column="news_time"/>
  21. <result property="phonenumber" column="phonenumber"/>
  22. </resultMap>
  23. <!--查询po_news表所有-->
  24. <sql id="selectPoNewsVo">
  25. select news_id, news_title, news_content, status, create_by, create_time, update_by, update_time,
  26. remark, sort, publisher_id, del_flag ,image ,news_time ,phonenumber from po_news
  27. </sql>
  28. <!-- 分页查询-->
  29. <select id="selectPoNewsList" parameterType="PoNews" resultMap="PoNewsResult">
  30. <include refid="selectPoNewsVo"/>
  31. <where>
  32. <if test="newsTitle != null and newsTitle != ''"> and news_title = #{newsTitle}</if>
  33. <if test="newsContent != null and newsContent != ''"> and news_content = #{newsContent}</if>
  34. <if test="status != null and status != ''"> and status = #{status}</if>
  35. <if test="sort != null "> and sort = #{sort}</if>
  36. <if test="publisherId != null "> and publisher_id = #{publisherId}</if>
  37. <if test="delFlag != null and delFlag != ''">and del_flag = #{delFlag}</if>
  38. <if test="image != null and image != ''">and image = #{image}</if>
  39. <if test="newsTime != null ">and news_time = #{newsTime}</if>
  40. <if test="phonenumber != null ">and phonenumber = #{phonenumber}</if>
  41. </where>
  42. </select>
  43. <!-- 通过Id查询-->
  44. <select id="selectPoNewsByNewsId" parameterType="String" resultMap="PoNewsResult">
  45. <include refid="selectPoNewsVo"/>
  46. where news_id = #{newsId}
  47. </select>
  48. <!-- 增加-->
  49. <insert id="insertPoNews" parameterType="PoNews">
  50. insert into po_news
  51. <trim prefix="(" suffix=")" suffixOverrides=",">
  52. <if test="newsId != null">news_id,</if>
  53. <if test="newsTitle != null and newsTitle != ''">news_title,</if>
  54. <if test="newsContent != null and newsContent != ''">news_content,</if>
  55. <if test="status != null">status,</if>
  56. <if test="createBy != null">create_by,</if>
  57. <if test="createTime != null">create_time,</if>
  58. <if test="updateBy != null">update_by,</if>
  59. <if test="updateTime != null">update_time,</if>
  60. <if test="remark != null">remark,</if>
  61. <if test="sort != null">sort,</if>
  62. <if test="publisherId != null">publisher_id,</if>
  63. <if test="delFlag != null and delFlag != ''">del_flag,</if>
  64. <if test="image != null and image != ''">image,</if>
  65. <if test="newsTime != null">news_time,</if>
  66. <if test="phonenumber != null">phonenumber,</if>
  67. </trim>
  68. <trim prefix="values (" suffix=")" suffixOverrides=",">
  69. <if test="newsId != null">#{newsId},</if>
  70. <if test="newsTitle != null and newsTitle != ''">#{newsTitle},</if>
  71. <if test="newsContent != null and newsContent != ''">#{newsContent},</if>
  72. <if test="status != null">#{status},</if>
  73. <if test="createBy != null">#{createBy},</if>
  74. <if test="createTime != null">#{createTime},</if>
  75. <if test="updateBy != null">#{updateBy},</if>
  76. <if test="updateTime != null">#{updateTime},</if>
  77. <if test="remark != null">#{remark},</if>
  78. <if test="sort != null">#{sort},</if>
  79. <if test="publisherId != null">#{publisherId},</if>
  80. <if test="delFlag != null and delFlag != '' ">#{delFlag},</if>
  81. <if test="image != null and image != ''">#{image},</if>
  82. <if test="newsTime != null">#{newsTime},</if>
  83. <if test="phonenumber != null ">#{phonenumber},</if>
  84. </trim>
  85. </insert>
  86. <!-- 修改-->
  87. <update id="updatePoNews" parameterType="PoNews">
  88. update po_news
  89. <trim prefix="SET" suffixOverrides=",">
  90. <if test="newsTitle != null and newsTitle != ''">news_title = #{newsTitle},</if>
  91. <if test="newsContent != null and newsContent != ''">news_content = #{newsContent},</if>
  92. <if test="status != null">status = #{status},</if>
  93. <if test="createBy != null">create_by = #{createBy},</if>
  94. <if test="createTime != null">create_time = #{createTime},</if>
  95. <if test="updateBy != null">update_by = #{updateBy},</if>
  96. <if test="updateTime != null">update_time = #{updateTime},</if>
  97. <if test="remark != null">remark = #{remark},</if>
  98. <if test="sort != null">sort = #{sort},</if>
  99. <if test="publisherId != null">publisher_id = #{publisherId},</if>
  100. <if test="delFlag != null and delFlag != ''">del_flag = #{delFlag}</if>
  101. <if test="image != null and image != ''">image = #{image}</if>
  102. <if test="newsTime != null">news_time = #{newsTime}</if>
  103. <if test="phonenumber != null">phonenumber = #{phonenumber}</if>
  104. </trim>
  105. where news_id = #{newsId}
  106. </update>
  107. <!-- 删除-->
  108. <delete id="deletePoNewsByNewsId" parameterType="Long">
  109. delete from po_news where news_id = #{newsId}
  110. </delete>
  111. <!-- 批量删除-->
  112. <delete id="deletePoNewsByNewsIds" parameterType="String">
  113. delete from po_news where news_id in
  114. <foreach item="newsId" collection="array" open="(" separator="," close=")">
  115. #{newsId}
  116. </foreach>
  117. </delete>
  118. <!-- 标题时间都不为空-->
  119. <select id="selectPoNewsListByTitleAndNewsTimeStartAndNewsTimeEnd"
  120. resultType="PoNews" resultMap="PoNewsResult">
  121. <include refid="selectPoNewsVo"></include>
  122. <where>
  123. <if test="newsTitle != null and newsTitle != ''"> and news_title like concat('%', #{newsTitle}, '%')</if>
  124. <if test="newsTimeStart != null and newsTimeEnd != null "> and news_time between #{newsTimeStart} and #{newsTimeEnd}</if>
  125. </where>
  126. </select>
  127. <!-- 标题不为空时间为空-->
  128. <select id="selectPoNewsListByTitle" resultType="PoNews" resultMap="PoNewsResult">
  129. <include refid="selectPoNewsVo"></include>
  130. <where>
  131. <if test="newsTitle != null and newsTitle != ''">and news_title like concat('%', #{newsTitle}, '%')</if>
  132. </where>
  133. </select>
  134. <!-- 标题为空时间不为空-->
  135. <select id="selectPoNewsByTime" resultType="PoNews" resultMap="PoNewsResult">
  136. <include refid="selectPoNewsVo"></include>
  137. <where>
  138. <if test="newsTimeStart != null and newsTimeEnd != null "> and news_time between #{newsTimeStart} and #{newsTimeEnd}</if>
  139. </where>
  140. </select>
  141. <!-- 查询详细内容-->
  142. <select id="selectContentByNewsId" resultType="PoNews" resultMap="PoNewsResult">
  143. select news_content from po_news where news_id = #{newsId}
  144. </select>
  145. <!-- 校验标题是否重复-->
  146. <select id="checkPostNewsTitleUnique" resultType="String" resultMap="PoNewsResult">
  147. select news_id, news_title from po_news where news_title = #{newsTitle} and del_flag = '0' limit 1
  148. </select>
  149. <!-- 校验图片是否重复-->
  150. <select id="checkPostNewsImageUnique" resultType="String" resultMap="PoNewsResult">
  151. select news_id,image from po_news where image = #{image} and del_flag = '0' limit 1
  152. </select>
  153. <!-- 通过消息Id查询用户Id-->
  154. <select id="selectUserByNewsId" resultType="String">
  155. select u.phonenumber from po_news n LEFT JOIN po_user u ON n.phonenumber = u.phonenumber
  156. where n.news_id = #{newsId}
  157. </select>
  158. <!-- 校验时间是否相同-->
  159. <select id="checkPostNewsTimeUnique" resultType="String" resultMap="PoNewsResult">
  160. select news_id,create_time from po_news where create_time = #{createTime} and del_flag = '0' limit 1
  161. </select>
  162. </mapper>