feat(TorrentComment):添加种子页面的评论功能,可以对评论进行增删查

Change-Id: I3744e2111bc0cc5c5de980710dc80e9c7a504427
diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysTorrentCommentController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysTorrentCommentController.java
new file mode 100644
index 0000000..44524a5
--- /dev/null
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysTorrentCommentController.java
@@ -0,0 +1,35 @@
+// 种子评论控制器
+package com.ruoyi.web.controller.system;
+
+import com.ruoyi.common.core.controller.BaseController;
+import com.ruoyi.common.core.domain.AjaxResult;
+import com.ruoyi.system.domain.SysTorrentComment;
+import com.ruoyi.system.service.ISysTorrentCommentService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.web.bind.annotation.*;
+
+@RestController
+@RequestMapping("/system/torrent/comment")
+public class SysTorrentCommentController extends BaseController {
+    @Autowired
+    private ISysTorrentCommentService commentService;
+
+    @PreAuthorize("@ss.hasPermi('system:torrent:comment:add')")
+    @PostMapping
+    public AjaxResult add(@RequestBody SysTorrentComment comment) {
+        comment.setUserId(getUserId());
+        return toAjax(commentService.addComment(comment));
+    }
+
+    @GetMapping("/{torrentId}")
+    public AjaxResult list(@PathVariable Long torrentId) {
+        return AjaxResult.success(commentService.getCommentList(torrentId));
+    }
+
+    @PreAuthorize("@ss.hasPermi('system:torrent:comment:remove')")
+    @DeleteMapping("/{commentId}")
+    public AjaxResult remove(@PathVariable Long commentId) {
+        return toAjax(commentService.deleteComment(commentId));
+    }
+}
diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysTorrentComment.java b/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysTorrentComment.java
new file mode 100644
index 0000000..940a358
--- /dev/null
+++ b/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysTorrentComment.java
@@ -0,0 +1,31 @@
+//种子评论
+package com.ruoyi.system.domain;
+
+import com.ruoyi.common.annotation.Excel;
+import com.ruoyi.common.core.domain.BaseEntity;
+import lombok.Data;
+import jakarta.validation.constraints.NotBlank;
+import jakarta.validation.constraints.NotNull;
+
+@Data
+public class SysTorrentComment extends BaseEntity {
+    private static final long serialVersionUID = 1L;
+
+    @Excel(name = "评论ID")
+    private Long commentId;
+
+    @Excel(name = "种子ID")
+    @NotNull(message = "种子ID不能为空")
+    private Long torrentId;
+
+    @Excel(name = "用户ID")
+    @NotNull(message = "用户ID不能为空")
+    private Long userId;
+
+    @Excel(name = "评论内容")
+    @NotBlank(message = "评论内容不能为空")
+    private String content;
+
+    @Excel(name = "父评论ID")
+    private Long parentId;
+}
\ No newline at end of file
diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysTorrentCommentMapper.java b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysTorrentCommentMapper.java
new file mode 100644
index 0000000..2f519d1
--- /dev/null
+++ b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysTorrentCommentMapper.java
@@ -0,0 +1,11 @@
+// 种子评论 Mapper
+package com.ruoyi.system.mapper;
+
+import com.ruoyi.system.domain.SysTorrentComment;
+import java.util.List;
+
+public interface SysTorrentCommentMapper {
+    int insertComment(SysTorrentComment comment);
+    List<SysTorrentComment> selectCommentListByTorrentId(Long torrentId);
+    int deleteCommentById(Long commentId);
+}
\ No newline at end of file
diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysTorrentCommentService.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysTorrentCommentService.java
new file mode 100644
index 0000000..49106cb
--- /dev/null
+++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysTorrentCommentService.java
@@ -0,0 +1,11 @@
+// 种子评论服务接口
+package com.ruoyi.system.service;
+
+import com.ruoyi.system.domain.SysTorrentComment;
+import java.util.List;
+
+public interface ISysTorrentCommentService {
+    int addComment(SysTorrentComment comment);
+    List<SysTorrentComment> getCommentList(Long torrentId);
+    int deleteComment(Long commentId);
+}
\ No newline at end of file
diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysTorrentCommentServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysTorrentCommentServiceImpl.java
new file mode 100644
index 0000000..28603d4
--- /dev/null
+++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysTorrentCommentServiceImpl.java
@@ -0,0 +1,30 @@
+// 种子评论服务实现 (SysTorrentCommentServiceImpl.java)
+package com.ruoyi.system.service.impl;
+
+import com.ruoyi.system.domain.SysTorrentComment;
+import com.ruoyi.system.mapper.SysTorrentCommentMapper;
+import com.ruoyi.system.service.ISysTorrentCommentService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import java.util.List;
+
+@Service
+public class SysTorrentCommentServiceImpl implements ISysTorrentCommentService {
+    @Autowired
+    private SysTorrentCommentMapper commentMapper;
+
+    @Override
+    public int addComment(SysTorrentComment comment) {
+        return commentMapper.insertComment(comment);
+    }
+
+    @Override
+    public List<SysTorrentComment> getCommentList(Long torrentId) {
+        return commentMapper.selectCommentListByTorrentId(torrentId);
+    }
+
+    @Override
+    public int deleteComment(Long commentId) {
+        return commentMapper.deleteCommentById(commentId);
+    }
+}
\ No newline at end of file
diff --git a/ruoyi-system/src/main/resources/mapper/system/SysTorrentCommentMapper.xml b/ruoyi-system/src/main/resources/mapper/system/SysTorrentCommentMapper.xml
new file mode 100644
index 0000000..139e0e1
--- /dev/null
+++ b/ruoyi-system/src/main/resources/mapper/system/SysTorrentCommentMapper.xml
@@ -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.ruoyi.system.mapper.SysTorrentCommentMapper">
+    <insert id="insertComment" parameterType="com.ruoyi.system.domain.SysTorrentComment">
+        insert into sys_torrent_comment (torrent_id, user_id, content, parent_id, create_time)
+        values (#{torrentId}, #{userId}, #{content}, #{parentId}, sysdate())
+    </insert>
+    <select id="selectCommentListByTorrentId" resultType="com.ruoyi.system.domain.SysTorrentComment">
+        select comment_id, torrent_id, user_id, content, parent_id, create_time
+        from sys_torrent_comment
+        where torrent_id = #{torrentId}
+        order by create_time desc
+    </select>
+    <delete id="deleteCommentById">
+        delete from sys_torrent_comment where comment_id = #{commentId}
+    </delete>
+</mapper>
\ No newline at end of file