blob: 243fd92ebf9a38b48a41d3b6e3d244a36a8d7f50 [file] [log] [blame]
wuchimedesa0649c62025-04-05 15:53:39 +08001<?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" >
wuchimedes8a576e02025-05-13 17:50:46 +08007 INSERT INTO torrents (user_id, torrent_name, file_path, info_hash, file_size)
8 VALUES (#{userId}, #{torrentName}, #{filePath}, UNHEX(#{infoHash}), #{fileSize})
wuchimedesa0649c62025-04-05 15:53:39 +08009 </insert>
10
11 <select id="getTorrentByInfoHash" resultType="com.example.g8backend.entity.Torrent">
12 SELECT
13 torrent_id,
14 user_id,
15 torrent_name,
wuchimedes8a576e02025-05-13 17:50:46 +080016 file_path,
wuchimedesa0649c62025-04-05 15:53:39 +080017 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,
wuchimedes8a576e02025-05-13 17:50:46 +080028 file_path,
wuchimedesa0649c62025-04-05 15:53:39 +080029 HEX(info_hash) AS infoHash,
30 file_size
31 FROM torrents
32 WHERE torrent_id = #{torrentId}
33 </select>
34</mapper>