86133 | ec55c54 | 2025-04-21 11:51:32 +0800 | [diff] [blame] | 1 | <?xml version="1.0" encoding="UTF-8" ?> |
| 2 | <!DOCTYPE mapper |
| 3 | PUBLIC "-//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"/> |
BirdNETM | b0f7153 | 2025-05-26 17:37:33 +0800 | [diff] [blame^] | 27 | <where> |
| 28 | <if test="torrentId != null and torrentId != ''"> and torrent_id = #{torrentId}</if> |
| 29 | |
86133 | ec55c54 | 2025-04-21 11:51:32 +0800 | [diff] [blame] | 30 | <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 | |
| 48 | <insert id="insertBtTorrent" parameterType="BtTorrent" useGeneratedKeys="true" keyProperty="torrentId"> |
| 49 | insert into bt_torrent |
| 50 | <trim prefix="(" suffix=")" suffixOverrides=","> |
| 51 | <if test="infoHash != null and infoHash != ''">info_hash,</if> |
| 52 | <if test="name != null and name != ''">name,</if> |
| 53 | <if test="length != null">length,</if> |
| 54 | <if test="pieceLength != null">piece_length,</if> |
| 55 | <if test="piecesCount != null">pieces_count,</if> |
| 56 | <if test="createdBy != null">created_by,</if> |
| 57 | <if test="torrentCreateTime != null">torrent_create_time,</if> |
| 58 | <if test="uploaderId != null">uploader_id,</if> |
| 59 | <if test="uploadTime != null">upload_time,</if> |
| 60 | <if test="filePath != null">file_path,</if> |
| 61 | </trim> |
| 62 | <trim prefix="values (" suffix=")" suffixOverrides=","> |
| 63 | <if test="infoHash != null and infoHash != ''">#{infoHash},</if> |
| 64 | <if test="name != null and name != ''">#{name},</if> |
| 65 | <if test="length != null">#{length},</if> |
| 66 | <if test="pieceLength != null">#{pieceLength},</if> |
| 67 | <if test="piecesCount != null">#{piecesCount},</if> |
| 68 | <if test="createdBy != null">#{createdBy},</if> |
| 69 | <if test="torrentCreateTime != null">#{torrentCreateTime},</if> |
| 70 | <if test="uploaderId != null">#{uploaderId},</if> |
| 71 | <if test="uploadTime != null">#{uploadTime},</if> |
| 72 | <if test="filePath != null">#{filePath},</if> |
| 73 | </trim> |
| 74 | </insert> |
| 75 | |
| 76 | <update id="updateBtTorrent" parameterType="BtTorrent"> |
| 77 | update bt_torrent |
| 78 | <trim prefix="SET" suffixOverrides=","> |
| 79 | <if test="infoHash != null and infoHash != ''">info_hash = #{infoHash},</if> |
| 80 | <if test="name != null and name != ''">name = #{name},</if> |
| 81 | <if test="length != null">length = #{length},</if> |
| 82 | <if test="pieceLength != null">piece_length = #{pieceLength},</if> |
| 83 | <if test="piecesCount != null">pieces_count = #{piecesCount},</if> |
| 84 | <if test="createdBy != null">created_by = #{createdBy},</if> |
| 85 | <if test="torrentCreateTime != null">torrent_create_time = #{torrentCreateTime},</if> |
| 86 | <if test="uploaderId != null">uploader_id = #{uploaderId},</if> |
| 87 | <if test="uploadTime != null">upload_time = #{uploadTime},</if> |
| 88 | <if test="filePath != null">file_path = #{filePath},</if> |
| 89 | </trim> |
| 90 | where torrent_id = #{torrentId} |
| 91 | </update> |
| 92 | |
| 93 | <delete id="deleteBtTorrentByTorrentId" parameterType="Long"> |
| 94 | delete from bt_torrent where torrent_id = #{torrentId} |
| 95 | </delete> |
| 96 | |
| 97 | <delete id="deleteBtTorrentByTorrentIds" parameterType="String"> |
| 98 | delete from bt_torrent where torrent_id in |
| 99 | <foreach item="torrentId" collection="array" open="(" separator="," close=")"> |
| 100 | #{torrentId} |
| 101 | </foreach> |
| 102 | </delete> |
| 103 | </mapper> |