修改部分接口,方便前后端链接
Change-Id: I698294efbd4c21e53f7895dafd3302f5f29eee72
diff --git a/src/main/java/com/pt/service/CommentService.java b/src/main/java/com/pt/service/CommentService.java
index 3d8b7dd..1ac817e 100644
--- a/src/main/java/com/pt/service/CommentService.java
+++ b/src/main/java/com/pt/service/CommentService.java
@@ -17,11 +17,16 @@
this.commentRepository = commentRepository;
}
- public void addComment(String content, String username, int postId) {
+ public void addComment(String content, String username, int postId, Integer reviewer) {
+ System.out.println("Adding comment: " + content + " by " + username + " on post ID: " + postId + " with reviewer ID: " + reviewer);
Comment comment = new Comment();
comment.setContent(content);
comment.setWriter(username);
comment.setParentPost(postId);
+ if(reviewer != null) {
+ System.out.println("Setting reviewer ID: " + reviewer);
+ comment.setReviewer(reviewer);
+ }
commentRepository.save(comment);
}
@@ -37,4 +42,8 @@
);
return comments;
}
+
+ public Comment getCommentById(int commentId) {
+ return commentRepository.findById(commentId).orElse(null);
+ }
}
diff --git a/src/main/java/com/pt/service/TorrentService.java b/src/main/java/com/pt/service/TorrentService.java
index 1fdb700..ad38622 100644
--- a/src/main/java/com/pt/service/TorrentService.java
+++ b/src/main/java/com/pt/service/TorrentService.java
@@ -18,6 +18,10 @@
private TorrentMetaRepository torrentMetaRepository;
public TorrentMeta parseAndSaveTorrent(byte[] torrentBytes) throws Exception {
+ System.out.println("111");
+ for (byte b : torrentBytes) {
+ System.out.println(b);
+ }
Map<String, Object> torrentDict = (Map<String, Object>) BencodeCodec.decode(torrentBytes);
if (!torrentDict.containsKey("info")) {
throw new IllegalArgumentException("Invalid torrent file: missing 'info' dictionary");
@@ -25,12 +29,14 @@
Map<String, Object> infoDict = (Map<String, Object>) torrentDict.get("info");
+ System.out.println(222);
// 计算 info_hash
byte[] infoEncoded = BencodeCodec.encode(infoDict);
MessageDigest sha1 = MessageDigest.getInstance("SHA-1");
byte[] infoHashBytes = sha1.digest(infoEncoded);
String infoHash = bytesToHex(infoHashBytes);
+ System.out.println(333);
// 获取文件名,大小等
String name = (String) infoDict.get("name");
long length = 0;