端口修改

Change-Id: I895d874b4805916e9dc4386bb6e212b3277acfff
diff --git a/src/main/java/com/example/myproject/controller/TorrentLikesController.java b/src/main/java/com/example/myproject/controller/TorrentLikesController.java
new file mode 100644
index 0000000..7419faf
--- /dev/null
+++ b/src/main/java/com/example/myproject/controller/TorrentLikesController.java
@@ -0,0 +1,32 @@
+//package com.example.myproject.controller;
+//
+//import com.example.myproject.service.TorrentLikesService;
+//import org.springframework.web.bind.annotation.*;
+//
+//import java.util.Map;
+//
+//@RestController
+//@RequestMapping("/echo/torrent")
+//public class TorrentLikesController {
+//
+//    private final TorrentLikesService service;
+//
+//    public TorrentLikesController(TorrentLikesService service) {
+//        this.service = service;
+//    }
+//
+//    /**
+//     * 点赞接口
+//     * @param userId   用户ID(请求参数:user_id)
+//     * @param torrentId 种子ID(请求参数:torrent_id)
+//     * @return         操作结果:{"status": 1/0}
+//     */
+//    @PostMapping("/{userId}/{torrentId}")
+//    public Map<String, Object> toggleLike(
+//            @PathVariable Integer userId,
+//            @PathVariable Long torrentId) {
+//        return service.toggleLike(userId, torrentId);
+//    }
+//
+//
+//}
\ No newline at end of file
diff --git a/src/main/java/com/example/myproject/entity/TorrentLikes.java b/src/main/java/com/example/myproject/entity/TorrentLikes.java
new file mode 100644
index 0000000..e66ecd8
--- /dev/null
+++ b/src/main/java/com/example/myproject/entity/TorrentLikes.java
@@ -0,0 +1,55 @@
+//package com.example.myproject.entity;
+//
+//import javax.persistence.*;
+//
+//@Entity
+//@Table(name = "torrent_likes")
+//public class TorrentLikes {
+//
+//    @Id
+//    @GeneratedValue(strategy = GenerationType.IDENTITY)
+//    @Column(name = "like_id")
+//    private Long likeId;
+//
+//    @Column(name = "user_id")
+//    private Integer userId;
+//
+//    @Column(name = "torrent_id")
+//    private Long torrentId;
+//
+//    @Column(name = "is_liked", columnDefinition = "TINYINT(1) DEFAULT 0")
+//    private Integer isLiked;
+//
+//    // Getters and Setters
+//    public Long getLikeId() {
+//        return likeId;
+//    }
+//
+//    public void setLikeId(Long likeId) {
+//        this.likeId = likeId;
+//    }
+//
+//    public Integer getUserId() {
+//        return userId;
+//    }
+//
+//    public void setUserId(Integer userId) {
+//        this.userId = userId;
+//    }
+//
+//    public Long getTorrentId() {
+//        return torrentId;
+//    }
+//
+//    public void setTorrentId(Long torrentId) {
+//        this.torrentId = torrentId;
+//    }
+//
+//    public Integer getIsLiked() {
+//        return isLiked;
+//    }
+//
+//    public void setIsLiked(Integer isLiked) {
+//        this.isLiked = isLiked;
+//    }
+//}
\ No newline at end of file
diff --git a/src/main/java/com/example/myproject/repository/TorrentLikesRepository.java b/src/main/java/com/example/myproject/repository/TorrentLikesRepository.java
new file mode 100644
index 0000000..2a4e712
--- /dev/null
+++ b/src/main/java/com/example/myproject/repository/TorrentLikesRepository.java
@@ -0,0 +1,24 @@
+//package com.example.myproject.repository;
+//
+//import com.example.myproject.entity.TorrentLikes;
+//import org.springframework.data.jpa.repository.JpaRepository;
+//import org.springframework.data.jpa.repository.Modifying;
+//import org.springframework.data.jpa.repository.Query;
+//import org.springframework.data.repository.query.Param;
+//import org.springframework.transaction.annotation.Transactional;
+//
+//import java.util.Optional;
+//
+//public interface TorrentLikesRepository extends JpaRepository<TorrentLikes, Long> {
+//
+//    // 根据用户ID和种子ID查询记录
+//    Optional<TorrentLikes> findByUserIdAndTorrentId(Integer userId, Long torrentId);
+//
+//    // 更新点赞状态(基于用户ID和种子ID)
+//    @Modifying
+//    @Transactional
+//    @Query("UPDATE TorrentLikes t SET t.isLiked = :isLiked WHERE t.userId = :userId AND t.torrentId = :torrentId")
+//    int updateIsLikedByUserIdAndTorrentId(@Param("userId") Integer userId,
+//                                          @Param("torrentId") Long torrentId,
+//                                          @Param("isLiked") Integer isLiked);
+//}
\ No newline at end of file
diff --git a/src/main/java/com/example/myproject/service/TorrentLikesService.java b/src/main/java/com/example/myproject/service/TorrentLikesService.java
new file mode 100644
index 0000000..4b96310
--- /dev/null
+++ b/src/main/java/com/example/myproject/service/TorrentLikesService.java
@@ -0,0 +1,61 @@
+//package com.example.myproject.service;
+//
+//import com.example.myproject.entity.TorrentLikes;
+//import com.example.myproject.repository.TorrentLikesRepository;
+//import org.springframework.stereotype.Service;
+//import org.springframework.transaction.annotation.Transactional;
+//
+//import java.util.HashMap;
+//import java.util.Map;
+//import java.util.Optional;
+//
+//@Service
+//public class TorrentLikesService {
+//
+//    private final TorrentLikesRepository repository;
+//
+//
+//    public TorrentLikesService(TorrentLikesRepository repository) {
+//        this.repository = repository;
+//
+//    }
+//
+//    /**
+//     * 点赞接口核心逻辑
+//     * @param userId   用户ID
+//     * @param torrentId 种子ID
+//     * @return         最终点赞状态(1=已点赞,0=未点赞)
+//     */
+//    @Transactional
+//    public Map<String, Object> toggleLike(Integer userId, Long torrentId) {
+//        // 校验torrentId是否存在
+//        if (!repository.existsById(torrentId)) {
+//            throw new IllegalArgumentException("无效的torrentId: " + torrentId);
+//        }
+//
+//        Optional<TorrentLikes> existingLike = repository.findByUserIdAndTorrentId(userId, torrentId);
+//        Integer newStatus;
+//
+//        if (existingLike.isPresent()) {
+//            TorrentLikes likes = existingLike.get();
+//            Integer currentStatus = likes.getIsLiked();
+//            newStatus = currentStatus == 1 ? 0 : 1;
+//            repository.updateIsLikedByUserIdAndTorrentId(userId, torrentId, newStatus);
+//        } else {
+//            TorrentLikes newLike = new TorrentLikes();
+//            newLike.setUserId(userId);
+//            newLike.setTorrentId(torrentId);
+//            newLike.setIsLiked(1);
+//            repository.save(newLike);
+//            newStatus = 1;
+//        }
+//
+//        // 构建返回结果
+//        Map<String, Object> result = new HashMap<>();
+//        result.put("status", newStatus);
+//        result.put("message", newStatus == 1 ? "点赞成功" : "取消点赞成功");
+//        result.put("userId", userId);
+//        result.put("torrentId", torrentId);
+//        return result;
+//    }
+//}
\ No newline at end of file
diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties
index b21068f..9612287 100644
--- a/src/main/resources/application.properties
+++ b/src/main/resources/application.properties
@@ -1,4 +1,4 @@
-server.port=8080
+server.port=5011
 spring.datasource.url=jdbc:mysql://202.205.102.121:3306/echodevelop
 spring.datasource.username=team11
 spring.datasource.password=Team11000#