端口修改
Change-Id: I895d874b4805916e9dc4386bb6e212b3277acfff
diff --git a/.idea/dataSources.local.xml b/.idea/dataSources.local.xml
index 370f64a..2550a70 100644
--- a/.idea/dataSources.local.xml
+++ b/.idea/dataSources.local.xml
@@ -1,37 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="dataSourceStorageLocal" created-in="IU-243.21565.193">
- <data-source name="ptProject@localhost" uuid="6689f15a-5cd0-40b0-970c-713db3e7bac2">
- <database-info product="MySQL" version="8.0.40" jdbc-version="4.2" driver-name="MySQL Connector/J" driver-version="mysql-connector-j-8.2.0 (Revision: 06a1f724497fd81c6a659131fda822c9e5085b6c)" dbms="MYSQL" exact-version="8.0.40" exact-driver-version="8.2">
- <extra-name-characters>#@</extra-name-characters>
- <identifier-quote-string>`</identifier-quote-string>
- </database-info>
- <case-sensitivity plain-identifiers="lower" quoted-identifiers="lower" />
- <user-name>root</user-name>
- <schema-mapping>
- <introspection-scope>
- <node kind="schema" qname="@" />
- </introspection-scope>
- </schema-mapping>
- </data-source>
- <data-source name="Aurora MySQL (AWS Wrapper)" uuid="bd626494-98ff-4826-9446-415666456eab">
- <database-info product="MySQL" version="8.4.5" jdbc-version="4.2" driver-name="Amazon Web Services (AWS) Advanced JDBC Wrapper" driver-version="Amazon Web Services (AWS) Advanced JDBC Wrapper 2.3.7 ( Revision: 7591851e8da4e1c705ba232a8bd07824a5cfd276 )" dbms="MYSQL" exact-version="8.4.5" exact-driver-version="2.3">
- <extra-name-characters>#@</extra-name-characters>
- <identifier-quote-string>`</identifier-quote-string>
- </database-info>
- <case-sensitivity plain-identifiers="exact" quoted-identifiers="exact" />
- <secret-storage>master_key</secret-storage>
- <user-name>team11</user-name>
- <schema-mapping>
- <introspection-scope>
- <node kind="schema" qname="@" />
- </introspection-scope>
- </schema-mapping>
- </data-source>
<data-source name="echodevelop@202.205.102.121" uuid="6d2a7063-ae4c-471f-ae05-e32dede5d0ec">
<database-info product="MySQL" version="8.4.5" jdbc-version="4.2" driver-name="MySQL Connector/J" driver-version="mysql-connector-j-8.2.0 (Revision: 06a1f724497fd81c6a659131fda822c9e5085b6c)" dbms="MYSQL" exact-version="8.4.5" exact-driver-version="8.2">
<extra-name-characters>#@</extra-name-characters>
<identifier-quote-string>`</identifier-quote-string>
+ <jdbc-catalog-is-schema>true</jdbc-catalog-is-schema>
</database-info>
<case-sensitivity plain-identifiers="exact" quoted-identifiers="exact" />
<user-name>team11</user-name>
diff --git a/.idea/dataSources.xml b/.idea/dataSources.xml
index 0de76d7..23f66bf 100644
--- a/.idea/dataSources.xml
+++ b/.idea/dataSources.xml
@@ -1,32 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="DataSourceManagerImpl" format="xml" multifile-model="true">
- <data-source source="LOCAL" name="ptProject@localhost" uuid="6689f15a-5cd0-40b0-970c-713db3e7bac2">
- <driver-ref>mysql.8</driver-ref>
- <synchronize>true</synchronize>
- <imported>true</imported>
- <jdbc-driver>com.mysql.cj.jdbc.Driver</jdbc-driver>
- <jdbc-url>jdbc:mysql://localhost:3306/ptProject</jdbc-url>
- <jdbc-additional-properties>
- <property name="com.intellij.clouds.kubernetes.db.host.port" />
- <property name="com.intellij.clouds.kubernetes.db.enabled" value="false" />
- <property name="com.intellij.clouds.kubernetes.db.resource.type" value="Deployment" />
- <property name="com.intellij.clouds.kubernetes.db.container.port" />
- </jdbc-additional-properties>
- <working-dir>$ProjectFileDir$</working-dir>
- </data-source>
- <data-source source="LOCAL" name="Aurora MySQL (AWS Wrapper)" uuid="bd626494-98ff-4826-9446-415666456eab">
- <driver-ref>mysql_aurora.aws_wrapper</driver-ref>
- <synchronize>true</synchronize>
- <jdbc-driver>software.amazon.jdbc.Driver</jdbc-driver>
- <jdbc-url>jdbc:aws-wrapper:mysql://202.205.102.121 :3306/echodevelop</jdbc-url>
- <jdbc-additional-properties>
- <property name="com.intellij.clouds.kubernetes.db.host.port" />
- <property name="com.intellij.clouds.kubernetes.db.enabled" value="false" />
- <property name="com.intellij.clouds.kubernetes.db.container.port" />
- </jdbc-additional-properties>
- <working-dir>$ProjectFileDir$</working-dir>
- </data-source>
<data-source source="LOCAL" name="echodevelop@202.205.102.121" uuid="6d2a7063-ae4c-471f-ae05-e32dede5d0ec">
<driver-ref>mysql.8</driver-ref>
<synchronize>true</synchronize>
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index f6ecb62..d12ee37 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -5,10 +5,14 @@
</component>
<component name="ChangeListManager">
<list default="true" id="f008fe30-0711-42e2-bb33-17dcfdbad387" name="Changes" comment="pom">
- <change afterPath="$PROJECT_DIR$/src/main/java/com/example/myproject/config/WebConfig.java" afterDir="false" />
+ <change afterPath="$PROJECT_DIR$/src/main/java/com/example/myproject/controller/TorrentLikesController.java" afterDir="false" />
+ <change afterPath="$PROJECT_DIR$/src/main/java/com/example/myproject/entity/TorrentLikes.java" afterDir="false" />
+ <change afterPath="$PROJECT_DIR$/src/main/java/com/example/myproject/repository/TorrentLikesRepository.java" afterDir="false" />
+ <change afterPath="$PROJECT_DIR$/src/main/java/com/example/myproject/service/TorrentLikesService.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/dataSources.local.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/dataSources.local.xml" afterDir="false" />
+ <change beforePath="$PROJECT_DIR$/.idea/dataSources.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/dataSources.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
- <change beforePath="$PROJECT_DIR$/src/main/java/com/example/myproject/service/PostService.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/example/myproject/service/PostService.java" afterDir="false" />
+ <change beforePath="$PROJECT_DIR$/echo-backend.iml" beforeDir="false" afterPath="$PROJECT_DIR$/echo-backend.iml" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
@@ -26,6 +30,10 @@
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
<option name="ROOT_SYNC" value="SYNC" />
</component>
+ <component name="HighlightingSettingsPerFile">
+ <setting file="file://$PROJECT_DIR$/src/main/java/com/example/myproject/config/WebConfig.java" root0="FORCE_HIGHLIGHTING" />
+ <setting file="file://$PROJECT_DIR$/src/main/java/com/example/myproject/service/PostService.java" root0="FORCE_HIGHLIGHTING" />
+ </component>
<component name="MarkdownSettingsMigration">
<option name="stateVersion" value="1" />
</component>
@@ -41,36 +49,36 @@
<option name="hideEmptyMiddlePackages" value="true" />
<option name="showLibraryContents" value="true" />
</component>
- <component name="PropertiesComponent"><![CDATA[{
- "keyToString": {
- "JUnit.UserControllerTest.executor": "Run",
- "JUnit.UserControllerTest.testUpdateUserAvatar.executor": "Run",
- "JUnit.UserControllerTest.testUploadUserAvatar.executor": "Run",
- "RequestMappingsPanelOrder0": "0",
- "RequestMappingsPanelOrder1": "1",
- "RequestMappingsPanelWidth0": "75",
- "RequestMappingsPanelWidth1": "75",
- "RunOnceActivity.OpenProjectViewOnStart": "true",
- "RunOnceActivity.ShowReadmeOnStart": "true",
- "RunOnceActivity.git.unshallow": "true",
- "Spring Boot.MyProjectApplication.executor": "Run",
- "git-widget-placeholder": "my-branch",
- "kotlin-language-version-configured": "true",
- "last_opened_file_path": "D:/PT/echo-backend/src/main/java/com/example/myproject/config",
- "node.js.detected.package.eslint": "true",
- "node.js.selected.package.eslint": "(autodetect)",
- "node.js.selected.package.tslint": "(autodetect)",
- "nodejs_package_manager_path": "npm",
- "settings.editor.selected.configurable": "project.propVCSSupport.DirectoryMappings",
- "vue.rearranger.settings.migration": "true",
- "应用程序.MyProjectApplication.executor": "Run"
+ <component name="PropertiesComponent">{
+ "keyToString": {
+ "JUnit.UserControllerTest.executor": "Run",
+ "JUnit.UserControllerTest.testUpdateUserAvatar.executor": "Run",
+ "JUnit.UserControllerTest.testUploadUserAvatar.executor": "Run",
+ "RequestMappingsPanelOrder0": "0",
+ "RequestMappingsPanelOrder1": "1",
+ "RequestMappingsPanelWidth0": "75",
+ "RequestMappingsPanelWidth1": "75",
+ "RunOnceActivity.OpenProjectViewOnStart": "true",
+ "RunOnceActivity.ShowReadmeOnStart": "true",
+ "RunOnceActivity.git.unshallow": "true",
+ "Spring Boot.MyProjectApplication.executor": "Run",
+ "git-widget-placeholder": "my-branch",
+ "kotlin-language-version-configured": "true",
+ "last_opened_file_path": "D:/PT/echo-backend/src/main/java/com/example/myproject/config",
+ "node.js.detected.package.eslint": "true",
+ "node.js.selected.package.eslint": "(autodetect)",
+ "node.js.selected.package.tslint": "(autodetect)",
+ "nodejs_package_manager_path": "npm",
+ "settings.editor.selected.configurable": "project.propVCSSupport.DirectoryMappings",
+ "vue.rearranger.settings.migration": "true",
+ "应用程序.MyProjectApplication.executor": "Run"
},
- "keyToStringList": {
- "DatabaseDriversLRU": [
- "mysql_aurora"
+ "keyToStringList": {
+ "DatabaseDriversLRU": [
+ "mysql_aurora"
]
}
-}]]></component>
+}</component>
<component name="RecentsManager">
<key name="CopyFile.RECENT_KEYS">
<recent name="D:\PT\echo-backend\src\main\java\com\example\myproject\config" />
@@ -206,7 +214,7 @@
<workItem from="1749007243227" duration="1245000" />
<workItem from="1749033374884" duration="7535000" />
<workItem from="1749048857906" duration="4388000" />
- <workItem from="1749109821491" duration="697000" />
+ <workItem from="1749109821491" duration="5517000" />
</task>
<task id="LOCAL-00001" summary="pom">
<option name="closed" value="true" />
diff --git a/echo-backend.iml b/echo-backend.iml
index e8ce722..4c33cf8 100644
--- a/echo-backend.iml
+++ b/echo-backend.iml
@@ -5,4 +5,13 @@
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
</content>
</component>
+ <component name="FacetManager">
+ <facet type="jpa" name="JPA">
+ <configuration>
+ <setting name="validation-enabled" value="true" />
+ <datasource-mapping />
+ <naming-strategy-map />
+ </configuration>
+ </facet>
+ </component>
</module>
\ No newline at end of file
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#
diff --git a/target/classes/application.properties b/target/classes/application.properties
index b21068f..9612287 100644
--- a/target/classes/application.properties
+++ b/target/classes/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#