blob: 4f5cf3f400cc48374d4e5600ee47cd75f28b64a7 [file] [log] [blame]
86133ec55c542025-04-21 11:51:32 +08001<?xml version="1.0" encoding="UTF-8" ?>
2<!DOCTYPE mapper
3PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
4"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
5<mapper namespace="com.ruoyi.torrent.mapper.BtTorrentMapper">
6
7 <resultMap type="BtTorrent" id="BtTorrentResult">
8 <result property="torrentId" column="torrent_id" />
9 <result property="infoHash" column="info_hash" />
10 <result property="name" column="name" />
11 <result property="length" column="length" />
12 <result property="pieceLength" column="piece_length" />
13 <result property="piecesCount" column="pieces_count" />
14 <result property="createdBy" column="created_by" />
15 <result property="torrentCreateTime" column="torrent_create_time" />
16 <result property="uploaderId" column="uploader_id" />
17 <result property="uploadTime" column="upload_time" />
18 <result property="filePath" column="file_path" />
19 </resultMap>
20
21 <sql id="selectBtTorrentVo">
22 select torrent_id, info_hash, name, length, piece_length, pieces_count, created_by, torrent_create_time, uploader_id, upload_time, file_path from bt_torrent
23 </sql>
24
25 <select id="selectBtTorrentList" parameterType="BtTorrent" resultMap="BtTorrentResult">
26 <include refid="selectBtTorrentVo"/>
BirdNETMb0f71532025-05-26 17:37:33 +080027 <where>
28 <if test="torrentId != null and torrentId != ''"> and torrent_id = #{torrentId}</if>
29
86133ec55c542025-04-21 11:51:32 +080030 <if test="infoHash != null and infoHash != ''"> and info_hash = #{infoHash}</if>
31 <if test="name != null and name != ''"> and name like concat('%', #{name}, '%')</if>
32 <if test="length != null "> and length = #{length}</if>
33 <if test="pieceLength != null "> and piece_length = #{pieceLength}</if>
34 <if test="piecesCount != null "> and pieces_count = #{piecesCount}</if>
35 <if test="createdBy != null and createdBy != ''"> and created_by = #{createdBy}</if>
36 <if test="torrentCreateTime != null "> and torrent_create_time = #{torrentCreateTime}</if>
37 <if test="uploaderId != null "> and uploader_id = #{uploaderId}</if>
38 <if test="uploadTime != null "> and upload_time = #{uploadTime}</if>
39 <if test="filePath != null and filePath != ''"> and file_path = #{filePath}</if>
40 </where>
41 </select>
42
43 <select id="selectBtTorrentByTorrentId" parameterType="Long" resultMap="BtTorrentResult">
44 <include refid="selectBtTorrentVo"/>
45 where torrent_id = #{torrentId}
46 </select>
47
Atopos0524acda6de2025-06-05 17:43:13 +080048 <select id="selectBtTorrentsByIdsOrdered" resultType="BtTorrent">
49 SELECT * FROM bt_torrent
50 WHERE id IN
51 <foreach collection="list" item="id" open="(" separator="," close=")">
52 #{id}
53 </foreach>
54 ORDER BY FIELD(id
55 <foreach collection="list" item="id" separator=",">
56 #{id}
57 </foreach>
58 )
59 </select>
60
86133ec55c542025-04-21 11:51:32 +080061 <insert id="insertBtTorrent" parameterType="BtTorrent" useGeneratedKeys="true" keyProperty="torrentId">
62 insert into bt_torrent
63 <trim prefix="(" suffix=")" suffixOverrides=",">
64 <if test="infoHash != null and infoHash != ''">info_hash,</if>
65 <if test="name != null and name != ''">name,</if>
66 <if test="length != null">length,</if>
67 <if test="pieceLength != null">piece_length,</if>
68 <if test="piecesCount != null">pieces_count,</if>
69 <if test="createdBy != null">created_by,</if>
70 <if test="torrentCreateTime != null">torrent_create_time,</if>
71 <if test="uploaderId != null">uploader_id,</if>
72 <if test="uploadTime != null">upload_time,</if>
73 <if test="filePath != null">file_path,</if>
74 </trim>
75 <trim prefix="values (" suffix=")" suffixOverrides=",">
76 <if test="infoHash != null and infoHash != ''">#{infoHash},</if>
77 <if test="name != null and name != ''">#{name},</if>
78 <if test="length != null">#{length},</if>
79 <if test="pieceLength != null">#{pieceLength},</if>
80 <if test="piecesCount != null">#{piecesCount},</if>
81 <if test="createdBy != null">#{createdBy},</if>
82 <if test="torrentCreateTime != null">#{torrentCreateTime},</if>
83 <if test="uploaderId != null">#{uploaderId},</if>
84 <if test="uploadTime != null">#{uploadTime},</if>
85 <if test="filePath != null">#{filePath},</if>
86 </trim>
87 </insert>
88
89 <update id="updateBtTorrent" parameterType="BtTorrent">
90 update bt_torrent
91 <trim prefix="SET" suffixOverrides=",">
92 <if test="infoHash != null and infoHash != ''">info_hash = #{infoHash},</if>
93 <if test="name != null and name != ''">name = #{name},</if>
94 <if test="length != null">length = #{length},</if>
95 <if test="pieceLength != null">piece_length = #{pieceLength},</if>
96 <if test="piecesCount != null">pieces_count = #{piecesCount},</if>
97 <if test="createdBy != null">created_by = #{createdBy},</if>
98 <if test="torrentCreateTime != null">torrent_create_time = #{torrentCreateTime},</if>
99 <if test="uploaderId != null">uploader_id = #{uploaderId},</if>
100 <if test="uploadTime != null">upload_time = #{uploadTime},</if>
101 <if test="filePath != null">file_path = #{filePath},</if>
102 </trim>
103 where torrent_id = #{torrentId}
104 </update>
105
106 <delete id="deleteBtTorrentByTorrentId" parameterType="Long">
107 delete from bt_torrent where torrent_id = #{torrentId}
108 </delete>
109
110 <delete id="deleteBtTorrentByTorrentIds" parameterType="String">
111 delete from bt_torrent where torrent_id in
112 <foreach item="torrentId" collection="array" open="(" separator="," close=")">
113 #{torrentId}
114 </foreach>
115 </delete>
116</mapper>