blob: c1dbda736a84d66a70d70ca0ad64e9f605ded607 [file] [log] [blame]
223010711f457dc2025-04-15 17:35:55 +08001.xml
wuchimedese5722e32025-04-13 17:38:50 +08002<?xml version="1.0" encoding="UTF-8"?>
3<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
4 "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
5
6<mapper namespace="com.example.g8backend.mapper.PostMapper">
7 <select id="getPostsByUserId" resultType="com.example.g8backend.entity.Post">
8 SELECT * FROM posts WHERE user_id = #{userId}
9 </select>
223010711f457dc2025-04-15 17:35:55 +080010
11 <select id="getPostLikeCount" resultType="java.lang.Long">
12 SELECT COUNT(*) FROM post_likes WHERE post_id = #{postId}
13 </select>
14
15 <insert id="likePost">
16 INSERT INTO post_likes (user_id, post_id)
17 VALUES (#{userId}, #{postId})
18 </insert>
19
20 <delete id="unlikePost">
21 DELETE FROM post_likes
22 WHERE user_id = #{userId} AND post_id = #{postId}
23 </delete>
wuchimedese5722e32025-04-13 17:38:50 +080024</mapper>