点赞+取消点赞
This commit is contained in:
17
src/main/resources/com/bao/dating/mapper/PostLikeMapper.xml
Normal file
17
src/main/resources/com/bao/dating/mapper/PostLikeMapper.xml
Normal file
@@ -0,0 +1,17 @@
|
||||
<?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.bao.dating.mapper.PostLikeMapper">
|
||||
|
||||
<select id="findByPostAndUser" resultType="com.bao.dating.pojo.entity.PostLike">
|
||||
select * from dating.post_like where user_id = #{userId} and post_id = #{postId}
|
||||
</select>
|
||||
|
||||
<insert id="insert" useGeneratedKeys="true" keyProperty="likeId">
|
||||
INSERT INTO dating.post_like (post_id, user_id,created_at) VALUES (#{postId}, #{userId},NOW())
|
||||
</insert>
|
||||
|
||||
<delete id="deleteByPostIdAndUserId">
|
||||
delete from dating.post_like where post_id = #{postId} and user_id = #{userId}
|
||||
</delete>
|
||||
</mapper>
|
||||
@@ -26,6 +26,18 @@
|
||||
</if>
|
||||
#{isPublic}, 0, 0, #{createdAt}, #{updatedAt})
|
||||
</insert>
|
||||
<!--增加点赞数量-->
|
||||
<update id="increaseLikeCount">
|
||||
update dating.post set like_count = like_count + 1 where post.post_id = #{postId}
|
||||
</update>
|
||||
<update id="decreaseLikeCount">
|
||||
update dating.post set like_count= like_count - 1 where post.post_id = #{postId}
|
||||
</update>
|
||||
|
||||
<!--查询点赞当前数量-->
|
||||
<select id="selectLikeCount" resultType="java.lang.Integer">
|
||||
select dating.post.like_count from dating.post where post.post_id = #{postId}
|
||||
</select>
|
||||
|
||||
<delete id="deletePostById" parameterType="int">
|
||||
DELETE FROM post WHERE post_id = #{postId}
|
||||
|
||||
Reference in New Issue
Block a user