wuchimedes | a0649c6 | 2025-04-05 15:53:39 +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 | |
| 5 | <mapper namespace="com.example.g8backend.mapper.TorrentMapper"> |
22301071 | b566662 | 2025-06-06 21:32:34 +0800 | [diff] [blame] | 6 | |
| 7 | <insert id="insertTorrent"> |
wuchimedes | 8a576e0 | 2025-05-13 17:50:46 +0800 | [diff] [blame] | 8 | INSERT INTO torrents (user_id, torrent_name, file_path, info_hash, file_size) |
22301071 | b566662 | 2025-06-06 21:32:34 +0800 | [diff] [blame] | 9 | VALUES (#{userId}, #{torrentName}, #{filePath}, #{infoHash}, #{fileSize}) |
wuchimedes | a0649c6 | 2025-04-05 15:53:39 +0800 | [diff] [blame] | 10 | </insert> |
| 11 | |
| 12 | <select id="getTorrentByInfoHash" resultType="com.example.g8backend.entity.Torrent"> |
| 13 | SELECT |
22301071 | b566662 | 2025-06-06 21:32:34 +0800 | [diff] [blame] | 14 | torrent_id, |
| 15 | user_id, |
| 16 | torrent_name, |
| 17 | file_path, |
| 18 | info_hash AS infoHash, |
| 19 | file_size |
wuchimedes | a0649c6 | 2025-04-05 15:53:39 +0800 | [diff] [blame] | 20 | FROM torrents |
22301071 | b566662 | 2025-06-06 21:32:34 +0800 | [diff] [blame] | 21 | WHERE info_hash = #{infoHash} |
wuchimedes | a0649c6 | 2025-04-05 15:53:39 +0800 | [diff] [blame] | 22 | </select> |
| 23 | |
| 24 | <select id="getTorrentByTorrentId" resultType="com.example.g8backend.entity.Torrent"> |
| 25 | SELECT |
22301071 | b566662 | 2025-06-06 21:32:34 +0800 | [diff] [blame] | 26 | torrent_id, |
| 27 | user_id, |
| 28 | torrent_name, |
| 29 | file_path, |
| 30 | info_hash AS infoHash, |
| 31 | file_size |
wuchimedes | a0649c6 | 2025-04-05 15:53:39 +0800 | [diff] [blame] | 32 | FROM torrents |
| 33 | WHERE torrent_id = #{torrentId} |
| 34 | </select> |
22301071 | 7e8ebe4 | 2025-06-03 23:26:44 +0800 | [diff] [blame] | 35 | |
| 36 | <select id="selectByInfoHashList" resultType="com.example.g8backend.entity.Torrent" parameterType="list"> |
| 37 | SELECT |
| 38 | torrent_id, |
| 39 | user_id, |
| 40 | torrent_name, |
| 41 | file_path, |
22301071 | b566662 | 2025-06-06 21:32:34 +0800 | [diff] [blame] | 42 | info_hash AS infoHash, |
| 43 | file_size, |
| 44 | upload_time |
22301071 | 7e8ebe4 | 2025-06-03 23:26:44 +0800 | [diff] [blame] | 45 | FROM torrents |
| 46 | WHERE info_hash IN |
| 47 | <foreach collection="infoHashes" item="hash" open="(" separator="," close=")"> |
22301071 | b566662 | 2025-06-06 21:32:34 +0800 | [diff] [blame] | 48 | #{hash} |
22301071 | 7e8ebe4 | 2025-06-03 23:26:44 +0800 | [diff] [blame] | 49 | </foreach> |
| 50 | </select> |
| 51 | |
22301071 | b566662 | 2025-06-06 21:32:34 +0800 | [diff] [blame] | 52 | |
22301071 | 7e8ebe4 | 2025-06-03 23:26:44 +0800 | [diff] [blame] | 53 | <update id="updateIsRareByInfoHash"> |
22301071 | b566662 | 2025-06-06 21:32:34 +0800 | [diff] [blame] | 54 | UPDATE torrents |
| 55 | SET is_rare = #{israre} |
22301071 | 7e8ebe4 | 2025-06-03 23:26:44 +0800 | [diff] [blame] | 56 | WHERE info_hash = #{infoHash} |
| 57 | </update> |
| 58 | |
22301071 | b566662 | 2025-06-06 21:32:34 +0800 | [diff] [blame] | 59 | </mapper> |