//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//

package com.luozhihui.project.mapper;

import com.luozhihui.project.entity.Reply;
import java.util.List;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

@Mapper
public interface ReplyMapper {
    @Select({"SELECT r.*, u.userName , u.avatar  FROM reply r LEFT JOIN user u ON r.userId = u.UserId WHERE r.postId = #{postId} AND r.status = 1 ORDER BY r.createTime"})
    List<Reply> selectRepliesByPostId(Long postId);

    @Insert({"INSERT INTO reply (content, postId, userId, parentId, status, createTime, updateTime) VALUES (#{content}, #{postId}, #{userId}, 1, #{status}, NOW(), NOW())"})
    int insertReply(Reply reply);

    @Update({"UPDATE reply SET content = #{content}, updateTime = NOW() WHERE id = #{id}"})
    int updateReply(Reply reply);

    @Delete({"DELETE FROM reply WHERE id = #{id}"})
    int deleteReply(@Param("id") Long id);
}
