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