diff --git a/src/main/java/com/bao/dating/mapper/PostMapper.java b/src/main/java/com/bao/dating/mapper/PostMapper.java
index 4e31426..c4b47d5 100644
--- a/src/main/java/com/bao/dating/mapper/PostMapper.java
+++ b/src/main/java/com/bao/dating/mapper/PostMapper.java
@@ -2,6 +2,7 @@ package com.bao.dating.mapper;
import com.bao.dating.pojo.entity.Post;
import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
@Mapper
public interface PostMapper {
@@ -44,4 +45,34 @@ public interface PostMapper {
* @return 影响行数
*/
int decreaseLikeCount(Long postId);
+
+ /**
+ * 查询当前动态属于哪个用户id
+ * @param postId 动态id
+ * @return 用户id
+ */
+ Long selectUserIdByPostId(@Param("post_id") Long postId);
+
+ /**
+ * 查询点赞数
+ *
+ * @param postId
+ * @return
+ */
+ int selectFavoriteCount(Long postId);
+
+ /**
+ * 收藏数+1
+ *
+ * @param postId 动态ID
+ * @return 影响行数
+ */
+ int increaseFavoriteCount(Long postId);
+ /**
+ * 收藏数-1
+ *
+ * @param postId 动态ID
+ * @return 影响行数
+ */
+ int decreaseFavoriteCount(Long postId);
}
diff --git a/src/main/java/com/bao/dating/service/PostService.java b/src/main/java/com/bao/dating/service/PostService.java
index a60fff8..b74f9f6 100644
--- a/src/main/java/com/bao/dating/service/PostService.java
+++ b/src/main/java/com/bao/dating/service/PostService.java
@@ -27,4 +27,11 @@ public interface PostService {
* @return 删除的动态对象
*/
void deletePostById(Integer postId);
+
+ /**
+ * 查询
+ * @param postId 动态id
+ * @return 用户id
+ */
+ Long selectUserIdByPostId(Long postId);
}
\ No newline at end of file
diff --git a/src/main/java/com/bao/dating/service/impl/PostServiceImpl.java b/src/main/java/com/bao/dating/service/impl/PostServiceImpl.java
index 96d802d..5b7c3cb 100644
--- a/src/main/java/com/bao/dating/service/impl/PostServiceImpl.java
+++ b/src/main/java/com/bao/dating/service/impl/PostServiceImpl.java
@@ -147,4 +147,15 @@ public class PostServiceImpl implements PostService {
public void deletePostById(Integer postId) {
postMapper.deletePostById(postId);
}
+
+ /**
+ * 查询用户id
+ * @param postId 动态id
+ * @return
+ */
+
+ @Override
+ public Long selectUserIdByPostId(Long postId) {
+ return postMapper.selectUserIdByPostId(postId);
+ }
}
\ No newline at end of file
diff --git a/src/main/resources/com/bao/dating/mapper/PostMapper.xml b/src/main/resources/com/bao/dating/mapper/PostMapper.xml
index fcb9c1d..fb5630e 100644
--- a/src/main/resources/com/bao/dating/mapper/PostMapper.xml
+++ b/src/main/resources/com/bao/dating/mapper/PostMapper.xml
@@ -42,10 +42,26 @@
update dating.post set like_count= like_count - 1 where post.post_id = #{postId}
+
+
+ update post set favorite_count = favorite_count + 1 where post_id = #{post_id}
+
+
+
+ update post set favorite_count = favorite_count - 1 where post_id = #{post_id}
+
+
+
+
+
\ No newline at end of file