blob: e831504b9609cde48998a26604dc35689a7c371d [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">
22301071b5666622025-06-06 21:32:34 +08006
7 <insert id="insertTorrent">
wuchimedes8a576e02025-05-13 17:50:46 +08008 INSERT INTO torrents (user_id, torrent_name, file_path, info_hash, file_size)
22301071b5666622025-06-06 21:32:34 +08009 VALUES (#{userId}, #{torrentName}, #{filePath}, #{infoHash}, #{fileSize})
wuchimedesa0649c62025-04-05 15:53:39 +080010 </insert>
11
12 <select id="getTorrentByInfoHash" resultType="com.example.g8backend.entity.Torrent">
13 SELECT
22301071b5666622025-06-06 21:32:34 +080014 torrent_id,
15 user_id,
16 torrent_name,
17 file_path,
18 info_hash AS infoHash,
19 file_size
wuchimedesa0649c62025-04-05 15:53:39 +080020 FROM torrents
22301071b5666622025-06-06 21:32:34 +080021 WHERE info_hash = #{infoHash}
wuchimedesa0649c62025-04-05 15:53:39 +080022 </select>
23
24 <select id="getTorrentByTorrentId" resultType="com.example.g8backend.entity.Torrent">
25 SELECT
22301071b5666622025-06-06 21:32:34 +080026 torrent_id,
27 user_id,
28 torrent_name,
29 file_path,
30 info_hash AS infoHash,
31 file_size
wuchimedesa0649c62025-04-05 15:53:39 +080032 FROM torrents
33 WHERE torrent_id = #{torrentId}
34 </select>
223010717e8ebe42025-06-03 23:26:44 +080035
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,
22301071b5666622025-06-06 21:32:34 +080042 info_hash AS infoHash,
43 file_size,
44 upload_time
223010717e8ebe42025-06-03 23:26:44 +080045 FROM torrents
46 WHERE info_hash IN
47 <foreach collection="infoHashes" item="hash" open="(" separator="," close=")">
22301071b5666622025-06-06 21:32:34 +080048 #{hash}
223010717e8ebe42025-06-03 23:26:44 +080049 </foreach>
50 </select>
51
22301071b5666622025-06-06 21:32:34 +080052
223010717e8ebe42025-06-03 23:26:44 +080053 <update id="updateIsRareByInfoHash">
22301071b5666622025-06-06 21:32:34 +080054 UPDATE torrents
55 SET is_rare = #{israre}
223010717e8ebe42025-06-03 23:26:44 +080056 WHERE info_hash = #{infoHash}
57 </update>
58
22301071b5666622025-06-06 21:32:34 +080059</mapper>