123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161 |
- <?xml version="1.0" encoding="UTF-8" ?>
- <!DOCTYPE mapper
- PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
- "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
- <mapper namespace="com.ruoyi.system.mapper.CommunityNewsMapper">
-
- <resultMap type="CommunityNews" id="CommunityNewsResult">
- <result property="communityId" column="community_id" />
- <result property="communityTitle" column="community_title" />
- <result property="communityType" column="community_type" />
- <result property="communityContent" column="community_content" />
- <result property="status" column="status" />
- <result property="publishTime" column="publish_time" />
- <result property="userId" column="user_id" />
- <result property="staffId" column="staff_id" />
- <result property="staffName" column="staff_name" />
- <result property="author" column="author" />
- <result property="source" column="source" />
- <result property="coverImage" column="cover_image" />
- <result property="viewCount" column="view_count" />
- <result property="isTop" column="is_top" />
- <result property="userComment" column="user_comment" />
- <result property="userLikes" column="user_likes" />
- <result property="userStars" column="user_stars" />
- <result property="createBy" column="create_by" />
- <result property="createTime" column="create_time" />
- <result property="updateBy" column="update_by" />
- <result property="updateTime" column="update_time" />
- <result property="remark" column="remark" />
- </resultMap>
- <sql id="selectCommunityNewsVo">
- select community_id, community_title, community_type, community_content, status, publish_time, user_id, staff_id, staff_name, author, source, cover_image, view_count, is_top, user_comment, user_likes, user_stars, create_by, create_time, update_by, update_time, remark from community_news
- </sql>
- <select id="selectCommunityNewsList" parameterType="CommunityNews" resultMap="CommunityNewsResult">
- <include refid="selectCommunityNewsVo"/>
- <where>
- <if test="communityTitle != null and communityTitle != ''"> and community_title like concat('%', #{communityTitle}, '%')</if>
- <if test="communityType != null and communityType != ''"> and community_type = #{communityType}</if>
- <if test="communityContent != null and communityContent != ''"> and community_content = #{communityContent}</if>
- <if test="status != null and status != ''"> and status = #{status}</if>
- <if test="publishTime != null "> and publish_time = #{publishTime}</if>
- <if test="userId != null "> and user_id = #{userId}</if>
- <if test="staffId != null "> and staff_id = #{staffId}</if>
- <if test="staffName != null and staffName != ''"> and staff_name like concat('%', #{staffName}, '%')</if>
- <if test="author != null and author != ''"> and author = #{author}</if>
- <if test="source != null and source != ''"> and source = #{source}</if>
- <if test="coverImage != null and coverImage != ''"> and cover_image = #{coverImage}</if>
- <if test="viewCount != null "> and view_count = #{viewCount}</if>
- <if test="isTop != null and isTop != ''"> and is_top = #{isTop}</if>
- <if test="userComment != null and userComment != ''"> and user_comment = #{userComment}</if>
- <if test="userLikes != null and userLikes != ''"> and user_likes = #{userLikes}</if>
- <if test="userStars != null and userStars != ''"> and user_stars = #{userStars}</if>
- </where>
- order by is_top DESC, publish_time DESC,create_time DESC
- </select>
-
- <select id="selectCommunityNewsByCommunityId" parameterType="Long" resultMap="CommunityNewsResult">
- <include refid="selectCommunityNewsVo"/>
- where community_id = #{communityId}
- </select>
- <insert id="insertCommunityNews" parameterType="CommunityNews" useGeneratedKeys="true" keyProperty="communityId">
- insert into community_news
- <trim prefix="(" suffix=")" suffixOverrides=",">
- <if test="communityTitle != null and communityTitle != ''">community_title,</if>
- <if test="communityType != null and communityType != ''">community_type,</if>
- <if test="communityContent != null">community_content,</if>
- <if test="status != null">status,</if>
- <if test="publishTime != null">publish_time,</if>
- <if test="userId != null">user_id,</if>
- <if test="staffId != null">staff_id,</if>
- <if test="staffName != null">staff_name,</if>
- <if test="author != null">author,</if>
- <if test="source != null">source,</if>
- <if test="coverImage != null">cover_image,</if>
- <if test="viewCount != null">view_count,</if>
- <if test="isTop != null">is_top,</if>
- <if test="userComment != null">user_comment,</if>
- <if test="userLikes != null">user_likes,</if>
- <if test="userStars != null">user_stars,</if>
- <if test="createBy != null">create_by,</if>
- <if test="createTime != null">create_time,</if>
- <if test="updateBy != null">update_by,</if>
- <if test="updateTime != null">update_time,</if>
- <if test="remark != null">remark,</if>
- </trim>
- <trim prefix="values (" suffix=")" suffixOverrides=",">
- <if test="communityTitle != null and communityTitle != ''">#{communityTitle},</if>
- <if test="communityType != null and communityType != ''">#{communityType},</if>
- <if test="communityContent != null">#{communityContent},</if>
- <if test="status != null">#{status},</if>
- <if test="publishTime != null">#{publishTime},</if>
- <if test="userId != null">#{userId},</if>
- <if test="staffId != null">#{staffId},</if>
- <if test="staffName != null">#{staffName},</if>
- <if test="author != null">#{author},</if>
- <if test="source != null">#{source},</if>
- <if test="coverImage != null">#{coverImage},</if>
- <if test="viewCount != null">#{viewCount},</if>
- <if test="isTop != null">#{isTop},</if>
- <if test="userComment != null">#{userComment},</if>
- <if test="userLikes != null">#{userLikes},</if>
- <if test="userStars != null">#{userStars},</if>
- <if test="createBy != null">#{createBy},</if>
- <if test="createTime != null">#{createTime},</if>
- <if test="updateBy != null">#{updateBy},</if>
- <if test="updateTime != null">#{updateTime},</if>
- <if test="remark != null">#{remark},</if>
- </trim>
- </insert>
- <update id="updateCommunityNews" parameterType="CommunityNews">
- update community_news
- <trim prefix="SET" suffixOverrides=",">
- <if test="communityTitle != null and communityTitle != ''">community_title = #{communityTitle},</if>
- <if test="communityType != null and communityType != ''">community_type = #{communityType},</if>
- <if test="communityContent != null">community_content = #{communityContent},</if>
- <if test="status != null">status = #{status},</if>
- <if test="publishTime != null">publish_time = #{publishTime},</if>
- <if test="userId != null">user_id = #{userId},</if>
- <if test="staffId != null">staff_id = #{staffId},</if>
- <if test="staffName != null">staff_name = #{staffName},</if>
- <if test="author != null">author = #{author},</if>
- <if test="source != null">source = #{source},</if>
- <if test="coverImage != null">cover_image = #{coverImage},</if>
- <if test="viewCount != null">view_count = #{viewCount},</if>
- <if test="isTop != null">is_top = #{isTop},</if>
- <if test="userComment != null">user_comment = #{userComment},</if>
- <if test="userLikes != null">user_likes = #{userLikes},</if>
- <if test="userStars != null">user_stars = #{userStars},</if>
- <if test="createBy != null">create_by = #{createBy},</if>
- <if test="createTime != null">create_time = #{createTime},</if>
- <if test="updateBy != null">update_by = #{updateBy},</if>
- <if test="updateTime != null">update_time = #{updateTime},</if>
- <if test="remark != null">remark = #{remark},</if>
- </trim>
- where community_id = #{communityId}
- </update>
- <update id="updateCommunityNewsStars" parameterType="CommunityNews">
- update community_news set user_stars = #{userStars} where community_id = #{communityId}
- </update>
- <update id="updateCommunityNewsStarsByCommunityId" parameterType="String">
- update community_news set status = '2' where community_id in
- <foreach item="communityId" collection="array" open="(" separator="," close=")">
- #{communityId}
- </foreach>
- </update>
- <delete id="deleteCommunityNewsByCommunityId" parameterType="Long">
- delete from community_news where community_id = #{communityId}
- </delete>
- <delete id="deleteCommunityNewsByCommunityIds" parameterType="String">
- delete from community_news where community_id in
- <foreach item="communityId" collection="array" open="(" separator="," close=")">
- #{communityId}
- </foreach>
- </delete>
- </mapper>
|