冷门种子推荐,冷门种子下载不计入下载量,冷门种子自动化判断
Change-Id: Iba4d232d8408195c5af01d2f1686d171e3d5eeac
diff --git a/src/main/resources/mapper/PeerMapper.xml b/src/main/resources/mapper/PeerMapper.xml
index b3d4780..4c90eae 100644
--- a/src/main/resources/mapper/PeerMapper.xml
+++ b/src/main/resources/mapper/PeerMapper.xml
@@ -10,6 +10,22 @@
SELECT * FROM peers
WHERE info_hash = #{infoHash} and peer_id = #{peerId}
</select>
+ <select id="selectAllInfoHashesWithPeers" resultType="String">
+ SELECT DISTINCT info_hash FROM peers
+ </select>
+
+ <select id="countRecentActivity" resultType="Long" parameterType="String">
+ SELECT COUNT(*) FROM peers
+ WHERE info_hash = #{infoHash}
+ AND last_activity_time >= DATE_SUB(NOW(), INTERVAL 7 DAY)
+ </select>
+ <select id="selectByInfoHashList" parameterType="list" resultType="com.example.g8backend.entity.Torrent">
+ SELECT * FROM torrents
+ WHERE info_hash IN
+ <foreach item="item" index="index" collection="infoHashes" open="(" separator="," close=")">
+ #{item}
+ </foreach>
+ </select>
<update id="updatePeer">
UPDATE peers
SET uploaded = #{uploaded}, downloaded = #{downloaded}
diff --git a/src/main/resources/mapper/TorrentMapper.xml b/src/main/resources/mapper/TorrentMapper.xml
index 243fd92..cec75eb 100644
--- a/src/main/resources/mapper/TorrentMapper.xml
+++ b/src/main/resources/mapper/TorrentMapper.xml
@@ -31,4 +31,26 @@
FROM torrents
WHERE torrent_id = #{torrentId}
</select>
+
+ <select id="selectByInfoHashList" resultType="com.example.g8backend.entity.Torrent" parameterType="list">
+ SELECT
+ torrent_id,
+ user_id,
+ torrent_name,
+ file_path,
+ HEX(info_hash) AS infoHash,
+ file_size
+ FROM torrents
+ WHERE info_hash IN
+ <foreach collection="infoHashes" item="hash" open="(" separator="," close=")">
+ UNHEX(#{hash})
+ </foreach>
+ </select>
+
+ <update id="updateIsRareByInfoHash">
+ UPDATE torrent
+ SET israre = #{israre}
+ WHERE info_hash = #{infoHash}
+ </update>
+
</mapper>
\ No newline at end of file