blob: cec75eb6b1ade78e024fa58d45a7870e1efe5e90 [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>
223010719e7ca122025-06-03 23:26:44 +080034
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
wuchimedesa0649c62025-04-05 15:53:39 +080056</mapper>