种子,促销

Change-Id: I0ce919ce4228dcefec26ef636bacd3298c0dc77a
diff --git a/target/classes/application.properties b/target/classes/application.properties
index b753da7..0590333 100644
--- a/target/classes/application.properties
+++ b/target/classes/application.properties
@@ -19,3 +19,13 @@
 spring.jpa.enabled=false
 spring.jpa.hibernate.ddl-auto=none
 spring.jpa.open-in-view=false
+
+# tracker??
+pt.tracker.port=6969
+
+pt.tracker.torrent-dir=${user.dir}/data/torrents
+
+pt.tracker.allow-foreign=false
+pt.tracker.announce-url=/custom-announce
+
+mybatis-plus.mapper-locations=classpath:/mapper/**/*.xml
diff --git a/target/classes/com/example/myproject/MyProjectApplication.class b/target/classes/com/example/myproject/MyProjectApplication.class
index 1ebd349..a1281a9 100644
--- a/target/classes/com/example/myproject/MyProjectApplication.class
+++ b/target/classes/com/example/myproject/MyProjectApplication.class
Binary files differ
diff --git a/target/classes/com/example/myproject/common/CommonResultStatus.class b/target/classes/com/example/myproject/common/CommonResultStatus.class
new file mode 100644
index 0000000..a330e2c
--- /dev/null
+++ b/target/classes/com/example/myproject/common/CommonResultStatus.class
Binary files differ
diff --git a/target/classes/com/example/myproject/common/Constants$Announce.class b/target/classes/com/example/myproject/common/Constants$Announce.class
new file mode 100644
index 0000000..3e02afe
--- /dev/null
+++ b/target/classes/com/example/myproject/common/Constants$Announce.class
Binary files differ
diff --git a/target/classes/com/example/myproject/common/Constants$FinishStatus.class b/target/classes/com/example/myproject/common/Constants$FinishStatus.class
new file mode 100644
index 0000000..271898f
--- /dev/null
+++ b/target/classes/com/example/myproject/common/Constants$FinishStatus.class
Binary files differ
diff --git a/target/classes/com/example/myproject/common/Constants$Order.class b/target/classes/com/example/myproject/common/Constants$Order.class
new file mode 100644
index 0000000..a4b08ca
--- /dev/null
+++ b/target/classes/com/example/myproject/common/Constants$Order.class
Binary files differ
diff --git a/target/classes/com/example/myproject/common/Constants$Source.class b/target/classes/com/example/myproject/common/Constants$Source.class
new file mode 100644
index 0000000..afcbfed
--- /dev/null
+++ b/target/classes/com/example/myproject/common/Constants$Source.class
Binary files differ
diff --git a/target/classes/com/example/myproject/common/Constants.class b/target/classes/com/example/myproject/common/Constants.class
new file mode 100644
index 0000000..edce466
--- /dev/null
+++ b/target/classes/com/example/myproject/common/Constants.class
Binary files differ
diff --git a/target/classes/com/example/myproject/common/ResultStatus.class b/target/classes/com/example/myproject/common/ResultStatus.class
new file mode 100644
index 0000000..d3a6700
--- /dev/null
+++ b/target/classes/com/example/myproject/common/ResultStatus.class
Binary files differ
diff --git a/target/classes/com/example/myproject/common/base/I18nMessage.class b/target/classes/com/example/myproject/common/base/I18nMessage.class
new file mode 100644
index 0000000..c4ae319
--- /dev/null
+++ b/target/classes/com/example/myproject/common/base/I18nMessage.class
Binary files differ
diff --git a/target/classes/com/example/myproject/common/base/OrderPageParam.class b/target/classes/com/example/myproject/common/base/OrderPageParam.class
new file mode 100644
index 0000000..032ec40
--- /dev/null
+++ b/target/classes/com/example/myproject/common/base/OrderPageParam.class
Binary files differ
diff --git a/target/classes/com/example/myproject/common/base/PageParam.class b/target/classes/com/example/myproject/common/base/PageParam.class
new file mode 100644
index 0000000..2285fc1
--- /dev/null
+++ b/target/classes/com/example/myproject/common/base/PageParam.class
Binary files differ
diff --git a/target/classes/com/example/myproject/common/base/PageUtil.class b/target/classes/com/example/myproject/common/base/PageUtil.class
new file mode 100644
index 0000000..818080e
--- /dev/null
+++ b/target/classes/com/example/myproject/common/base/PageUtil.class
Binary files differ
diff --git a/target/classes/com/example/myproject/common/base/ResPage.class b/target/classes/com/example/myproject/common/base/ResPage.class
new file mode 100644
index 0000000..e208933
--- /dev/null
+++ b/target/classes/com/example/myproject/common/base/ResPage.class
Binary files differ
diff --git a/target/classes/com/example/myproject/common/base/Result.class b/target/classes/com/example/myproject/common/base/Result.class
new file mode 100644
index 0000000..8492dd1
--- /dev/null
+++ b/target/classes/com/example/myproject/common/base/Result.class
Binary files differ
diff --git a/target/classes/com/example/myproject/common/base/Status.class b/target/classes/com/example/myproject/common/base/Status.class
new file mode 100644
index 0000000..e7f372b
--- /dev/null
+++ b/target/classes/com/example/myproject/common/base/Status.class
Binary files differ
diff --git a/target/classes/com/example/myproject/common/exception/RocketPTException.class b/target/classes/com/example/myproject/common/exception/RocketPTException.class
new file mode 100644
index 0000000..89a4931
--- /dev/null
+++ b/target/classes/com/example/myproject/common/exception/RocketPTException.class
Binary files differ
diff --git a/target/classes/com/example/myproject/config/MyMetaObjectHandler.class b/target/classes/com/example/myproject/config/MyMetaObjectHandler.class
new file mode 100644
index 0000000..c213aff
--- /dev/null
+++ b/target/classes/com/example/myproject/config/MyMetaObjectHandler.class
Binary files differ
diff --git a/target/classes/com/example/myproject/config/TrackerConfig.class b/target/classes/com/example/myproject/config/TrackerConfig.class
new file mode 100644
index 0000000..774aa27
--- /dev/null
+++ b/target/classes/com/example/myproject/config/TrackerConfig.class
Binary files differ
diff --git a/target/classes/com/example/myproject/controller/TorrentController.class b/target/classes/com/example/myproject/controller/TorrentController.class
new file mode 100644
index 0000000..130ba3f
--- /dev/null
+++ b/target/classes/com/example/myproject/controller/TorrentController.class
Binary files differ
diff --git a/target/classes/com/example/myproject/controller/UserController$EmailRequest.class b/target/classes/com/example/myproject/controller/UserController$EmailRequest.class
index d12dede..04ffd85 100644
--- a/target/classes/com/example/myproject/controller/UserController$EmailRequest.class
+++ b/target/classes/com/example/myproject/controller/UserController$EmailRequest.class
Binary files differ
diff --git a/target/classes/com/example/myproject/controller/UserController$VerificationRequest.class b/target/classes/com/example/myproject/controller/UserController$VerificationRequest.class
index aa1371e..272505e 100644
--- a/target/classes/com/example/myproject/controller/UserController$VerificationRequest.class
+++ b/target/classes/com/example/myproject/controller/UserController$VerificationRequest.class
Binary files differ
diff --git a/target/classes/com/example/myproject/controller/UserController.class b/target/classes/com/example/myproject/controller/UserController.class
index d1d685c..cd1ab13 100644
--- a/target/classes/com/example/myproject/controller/UserController.class
+++ b/target/classes/com/example/myproject/controller/UserController.class
Binary files differ
diff --git a/target/classes/com/example/myproject/dto/PromotionCreateDTO.class b/target/classes/com/example/myproject/dto/PromotionCreateDTO.class
new file mode 100644
index 0000000..3087d39
--- /dev/null
+++ b/target/classes/com/example/myproject/dto/PromotionCreateDTO.class
Binary files differ
diff --git a/target/classes/com/example/myproject/dto/TorrentUpdateDTO.class b/target/classes/com/example/myproject/dto/TorrentUpdateDTO.class
new file mode 100644
index 0000000..7285868
--- /dev/null
+++ b/target/classes/com/example/myproject/dto/TorrentUpdateDTO.class
Binary files differ
diff --git a/target/classes/com/example/myproject/dto/param/TorrentParam.class b/target/classes/com/example/myproject/dto/param/TorrentParam.class
new file mode 100644
index 0000000..ad8a2c5
--- /dev/null
+++ b/target/classes/com/example/myproject/dto/param/TorrentParam.class
Binary files differ
diff --git a/target/classes/com/example/myproject/dto/param/TorrentUploadParam.class b/target/classes/com/example/myproject/dto/param/TorrentUploadParam.class
new file mode 100644
index 0000000..49bbc09
--- /dev/null
+++ b/target/classes/com/example/myproject/dto/param/TorrentUploadParam.class
Binary files differ
diff --git a/target/classes/com/example/myproject/dto/vo/TorrentVO.class b/target/classes/com/example/myproject/dto/vo/TorrentVO.class
new file mode 100644
index 0000000..fa2124e
--- /dev/null
+++ b/target/classes/com/example/myproject/dto/vo/TorrentVO.class
Binary files differ
diff --git a/target/classes/com/example/myproject/entity/EntityBase.class b/target/classes/com/example/myproject/entity/EntityBase.class
new file mode 100644
index 0000000..a16c52a
--- /dev/null
+++ b/target/classes/com/example/myproject/entity/EntityBase.class
Binary files differ
diff --git a/target/classes/com/example/myproject/entity/FavoriteEntity.class b/target/classes/com/example/myproject/entity/FavoriteEntity.class
new file mode 100644
index 0000000..a0acd8b
--- /dev/null
+++ b/target/classes/com/example/myproject/entity/FavoriteEntity.class
Binary files differ
diff --git a/target/classes/com/example/myproject/entity/Promotion.class b/target/classes/com/example/myproject/entity/Promotion.class
new file mode 100644
index 0000000..e5df6dd
--- /dev/null
+++ b/target/classes/com/example/myproject/entity/Promotion.class
Binary files differ
diff --git a/target/classes/com/example/myproject/entity/TorrentEntity.class b/target/classes/com/example/myproject/entity/TorrentEntity.class
new file mode 100644
index 0000000..cdf20da
--- /dev/null
+++ b/target/classes/com/example/myproject/entity/TorrentEntity.class
Binary files differ
diff --git a/target/classes/com/example/myproject/entity/User.class b/target/classes/com/example/myproject/entity/User.class
index 62eb5a1..3ee8ffe 100644
--- a/target/classes/com/example/myproject/entity/User.class
+++ b/target/classes/com/example/myproject/entity/User.class
Binary files differ
diff --git a/target/classes/com/example/myproject/mapper/FavoriteMapper.class b/target/classes/com/example/myproject/mapper/FavoriteMapper.class
new file mode 100644
index 0000000..dc075c9
--- /dev/null
+++ b/target/classes/com/example/myproject/mapper/FavoriteMapper.class
Binary files differ
diff --git a/target/classes/com/example/myproject/mapper/PromotionMapper.class b/target/classes/com/example/myproject/mapper/PromotionMapper.class
new file mode 100644
index 0000000..074c856
--- /dev/null
+++ b/target/classes/com/example/myproject/mapper/PromotionMapper.class
Binary files differ
diff --git a/target/classes/com/example/myproject/mapper/TorrentMapper.class b/target/classes/com/example/myproject/mapper/TorrentMapper.class
new file mode 100644
index 0000000..5080dfd
--- /dev/null
+++ b/target/classes/com/example/myproject/mapper/TorrentMapper.class
Binary files differ
diff --git a/target/classes/com/example/myproject/mapper/UserMapper.class b/target/classes/com/example/myproject/mapper/UserMapper.class
index 7b80316..10a9ec1 100644
--- a/target/classes/com/example/myproject/mapper/UserMapper.class
+++ b/target/classes/com/example/myproject/mapper/UserMapper.class
Binary files differ
diff --git a/target/classes/com/example/myproject/service/PromotionService.class b/target/classes/com/example/myproject/service/PromotionService.class
new file mode 100644
index 0000000..6f0963b
--- /dev/null
+++ b/target/classes/com/example/myproject/service/PromotionService.class
Binary files differ
diff --git a/target/classes/com/example/myproject/service/TorrentService.class b/target/classes/com/example/myproject/service/TorrentService.class
new file mode 100644
index 0000000..c0cfeed
--- /dev/null
+++ b/target/classes/com/example/myproject/service/TorrentService.class
Binary files differ
diff --git a/target/classes/com/example/myproject/service/serviceImpl/PromotionServiceImpl.class b/target/classes/com/example/myproject/service/serviceImpl/PromotionServiceImpl.class
new file mode 100644
index 0000000..6984839
--- /dev/null
+++ b/target/classes/com/example/myproject/service/serviceImpl/PromotionServiceImpl.class
Binary files differ
diff --git a/target/classes/com/example/myproject/service/serviceImpl/TorrentServiceImpl.class b/target/classes/com/example/myproject/service/serviceImpl/TorrentServiceImpl.class
new file mode 100644
index 0000000..dc9600d
--- /dev/null
+++ b/target/classes/com/example/myproject/service/serviceImpl/TorrentServiceImpl.class
Binary files differ
diff --git a/target/classes/com/example/myproject/utils/Result.class b/target/classes/com/example/myproject/utils/Result.class
deleted file mode 100644
index 0a8e59e..0000000
--- a/target/classes/com/example/myproject/utils/Result.class
+++ /dev/null
Binary files differ
diff --git a/target/classes/files/files.torrent b/target/classes/files/files.torrent
new file mode 100644
index 0000000..e04974f
--- /dev/null
+++ b/target/classes/files/files.torrent
@@ -0,0 +1 @@
+d8:announce22:https://tracker.byr.pt10:created by21:qBittorrent v4.5.3.1013:creation datei1747717901e4:infod5:filesld6:lengthi173e4:pathl13:valid.torrenteee4:name5:files12:piece lengthi16384e6:pieces20:/ñíèEô5ã<òûìՄŸQ¡–ûee
\ No newline at end of file
diff --git a/target/classes/mapper/FavoriteMapper.xml b/target/classes/mapper/FavoriteMapper.xml
new file mode 100644
index 0000000..1048ec2
--- /dev/null
+++ b/target/classes/mapper/FavoriteMapper.xml
@@ -0,0 +1,6 @@
+<?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.example.myproject.mapper.FavoriteMapper">
+ 
+</mapper>
diff --git a/target/classes/mapper/PromotionMapper.xml b/target/classes/mapper/PromotionMapper.xml
new file mode 100644
index 0000000..72ffd95
--- /dev/null
+++ b/target/classes/mapper/PromotionMapper.xml
@@ -0,0 +1,14 @@
+<?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.example.myproject.mapper.PromotionMapper">
+
+    <insert id="insert" parameterType="com.example.myproject.entity.Promotion">
+        INSERT INTO promotion (
+        name, description, start_time, end_time, discount_percentage, applicable_torrent_ids
+        ) VALUES (
+        #{name}, #{description}, #{startTime}, #{endTime}, #{discountPercentage}, #{applicableTorrentIds}
+        )
+    </insert>
+
+</mapper>
diff --git a/target/classes/mapper/TorrentMapper.xml b/target/classes/mapper/TorrentMapper.xml
new file mode 100644
index 0000000..d5f018e
--- /dev/null
+++ b/target/classes/mapper/TorrentMapper.xml
@@ -0,0 +1,104 @@
+<?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.example.myproject.mapper.TorrentMapper">
+    <resultMap id="BaseResultMap" type="com.example.myproject.entity.TorrentEntity">
+        <id column="info_hash" property="infoHash"/>
+        <result column="file_name" property="fileName"/>
+        <result column="uploader" property="uploader"/>
+        <result column="upload_time" property="uploadTime"/>
+        <result column="size" property="size"/>
+        <result column="title" property="title"/>
+        <result column="description" property="description"/>
+        <result column="category" property="category"/>
+        <result column="image_url" property="imageUrl"/>
+    </resultMap>
+
+    <select id="selectByInfoHash" resultMap="BaseResultMap">
+        SELECT * FROM torrent WHERE info_hash = #{infoHash}
+    </select>
+    <select id="selectBySeedId" resultMap="BaseResultMap">
+        SELECT * FROM torrent WHERE seed_id = #{seedId}
+    </select>
+
+
+
+
+    <update id="update" parameterType="com.example.myproject.entity.TorrentEntity">
+        UPDATE torrent
+        SET file_name = #{fileName},
+        uploader = #{uploader},
+        upload_time = #{uploadTime},
+        size = #{size},
+        title = #{title},
+        description = #{description},
+        category = #{category},
+        image_url = #{imageUrl}
+        WHERE info_hash = #{infoHash}
+    </update>
+    <select id="search" resultType="com.example.myproject.entity.TorrentEntity">
+        SELECT * FROM torrent
+        <where>
+            <if test="param.category != null">
+                AND category = #{param.category}
+            </if>
+
+            <!--        <if test="param.free != null and param.free != ''">-->
+            <!--            AND free = #{param.free}-->
+            <!--        </if>-->
+            <if test="param.free != null">
+            <choose>
+                <!-- 筛选“正在促销中”的种子 -->
+                <when test="param.free == true">
+                    AND EXISTS (
+                    SELECT 1 FROM promotion p
+                    WHERE
+                    JSON_CONTAINS(p.applicable_torrent_ids, JSON_ARRAY(t.id))
+                    AND NOW() BETWEEN p.start_time AND p.end_time
+                    AND p.is_deleted = 0
+                    )
+                </when>
+                <!-- 筛选“未在促销中”的种子 -->
+                <otherwise>
+                    AND NOT EXISTS (
+                    SELECT 1 FROM promotion p
+                    WHERE
+                    JSON_CONTAINS(p.applicable_torrent_ids, JSON_ARRAY(t.id))
+                    AND NOW() BETWEEN p.start_time AND p.end_time
+                    AND p.is_deleted = 0
+                    )
+                </otherwise>
+            </choose>
+            </if>
+
+            <if test="param.likeExpressions != null and param.likeExpressions.size > 0">
+                AND (
+                <foreach collection="param.likeExpressions" item="item" open="(" separator=" AND " close=")">
+
+                    ( title LIKE CONCAT('%', #{item}, '%') ) or ( description LIKE CONCAT('%', #{item}, '%') ) or ( tags LIKE CONCAT('%', #{item}, '%') )
+                </foreach>
+                )
+            </if>
+        </where>
+
+        <if test="param.prop != null and param.sort != null">
+            ORDER BY ${param.prop} ${param.sort}
+        </if>
+    </select>
+    <select id="checkFavorite" resultType="boolean">
+        SELECT COUNT(*) > 0
+        FROM favorite
+        WHERE seed_id = #{seedId} AND user_id = #{userId}
+    </select>
+    <insert id="addFavorite">
+        INSERT INTO favorite (seed_id, user_id)
+        VALUES (#{seedId}, #{userId})
+    </insert>
+    <delete id="removeFavorite">
+        DELETE FROM favorite
+        WHERE seed_id = #{seedId} AND user_id = #{userId}
+    </delete>
+
+
+</mapper>
\ No newline at end of file
diff --git a/target/classes/mapper/UserMapper.xml b/target/classes/mapper/UserMapper.xml
new file mode 100644
index 0000000..f03ab0a
--- /dev/null
+++ b/target/classes/mapper/UserMapper.xml
@@ -0,0 +1,21 @@
+<?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.example.myproject.mapper.UserMapper">
+    <!-- 根据用户名查找用户 -->
+    <select id="selectByUsername" parameterType="string" resultType="com.example.myproject.entity.User">
+        SELECT * FROM user WHERE username = #{username}
+    </select>
+    <!-- 根据用户名和密码查找用户 -->
+    <select id="selectByUsernameAndPassword" parameterType="map" resultType="com.example.myproject.entity.User">
+        SELECT * FROM user WHERE username = #{username} AND password = #{password}
+    </select>
+    <!-- 根据邮箱查找用户 -->
+    <select id="selectByEmail" parameterType="string" resultType="com.example.myproject.entity.User">
+        SELECT * FROM user WHERE email = #{email}
+    </select>
+    <!-- 根据用户名包含查找用户 -->
+    <select id="selectByUsernameContaining" parameterType="string" resultType="com.example.myproject.entity.User">
+        SELECT * FROM user WHERE username LIKE CONCAT('%', #{name}, '%')
+    </select>
+</mapper>
diff --git a/target/classes/mapper/VerificationTokenMapper.xml b/target/classes/mapper/VerificationTokenMapper.xml
new file mode 100644
index 0000000..53b19a5
--- /dev/null
+++ b/target/classes/mapper/VerificationTokenMapper.xml
@@ -0,0 +1,10 @@
+<?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.example.myproject.mapper.VerificationTokenMapper">
+    <!-- 通过 token 和 email 查询 VerificationToken -->
+    <select id="findByTokenAndEmail" resultType="com.example.myproject.entity.VerificationToken">
+        SELECT * FROM verification_token
+        WHERE token = #{token} AND email = #{email}
+    </select>
+</mapper>
diff --git a/target/classes/output/valid.torrent b/target/classes/output/valid.torrent
new file mode 100644
index 0000000..6a90e52
--- /dev/null
+++ b/target/classes/output/valid.torrent
@@ -0,0 +1 @@
+d10:created by18:qBittorrent v5.1.013:creation datei1745948995e4:infod6:lengthi22e4:name15:example.torrent12:piece lengthi16384e6:pieces20:Fnð¶)ú<Ç	ŽæÂh£tl7:privatei1eee
\ No newline at end of file