wuchimedes | db9fe68 | 2025-04-22 19:24:11 +0800 | [diff] [blame] | 1 | <?xml version="1.0" encoding="UTF-8"?> |
| 2 | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" |
| 3 | "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| 4 | <mapper namespace="com.example.g8backend.mapper.PeerMapper"> |
| 5 | <select id="getPeerByPK"> |
| 6 | SELECT * FROM peers |
| 7 | WHERE peer_id = #{peerId} and info_hash = #{infoHash} and passkey = #{passkey} |
| 8 | </select> |
| 9 | <select id="getPeerByInfoHashAndPeerId"> |
| 10 | SELECT * FROM peers |
| 11 | WHERE info_hash = #{infoHash} and peer_id = #{peerId} |
| 12 | </select> |
22301071 | 7e8ebe4 | 2025-06-03 23:26:44 +0800 | [diff] [blame^] | 13 | <select id="selectAllInfoHashesWithPeers" resultType="String"> |
| 14 | SELECT DISTINCT info_hash FROM peers |
| 15 | </select> |
| 16 | |
| 17 | <select id="countRecentActivity" resultType="Long" parameterType="String"> |
| 18 | SELECT COUNT(*) FROM peers |
| 19 | WHERE info_hash = #{infoHash} |
| 20 | AND last_activity_time >= DATE_SUB(NOW(), INTERVAL 7 DAY) |
| 21 | </select> |
| 22 | <select id="selectByInfoHashList" parameterType="list" resultType="com.example.g8backend.entity.Torrent"> |
| 23 | SELECT * FROM torrents |
| 24 | WHERE info_hash IN |
| 25 | <foreach item="item" index="index" collection="infoHashes" open="(" separator="," close=")"> |
| 26 | #{item} |
| 27 | </foreach> |
| 28 | </select> |
wuchimedes | db9fe68 | 2025-04-22 19:24:11 +0800 | [diff] [blame] | 29 | <update id="updatePeer"> |
| 30 | UPDATE peers |
| 31 | SET uploaded = #{uploaded}, downloaded = #{downloaded} |
| 32 | WHERE peer_id = #{peerId} and info_hash = #{info_hash} and passkey = #{passkey} |
| 33 | </update> |
| 34 | </mapper> |