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 | d2dda83 | 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 | d2dda83 | 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 | d2dda83 | 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> |
| 34 | </mapper> |