| <?xml version="1.0" encoding="UTF-8" ?> |
| <!DOCTYPE mapper |
| PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" |
| "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| <mapper namespace="com.ruoyi.torrent.mapper.BtTorrentMapper"> |
| |
| <resultMap type="BtTorrent" id="BtTorrentResult"> |
| <result property="torrentId" column="torrent_id" /> |
| <result property="infoHash" column="info_hash" /> |
| <result property="name" column="name" /> |
| <result property="length" column="length" /> |
| <result property="pieceLength" column="piece_length" /> |
| <result property="piecesCount" column="pieces_count" /> |
| <result property="createdBy" column="created_by" /> |
| <result property="torrentCreateTime" column="torrent_create_time" /> |
| <result property="uploaderId" column="uploader_id" /> |
| <result property="uploadTime" column="upload_time" /> |
| <result property="filePath" column="file_path" /> |
| </resultMap> |
| |
| <sql id="selectBtTorrentVo"> |
| 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 |
| </sql> |
| |
| <select id="selectBtTorrentList" parameterType="BtTorrent" resultMap="BtTorrentResult"> |
| <include refid="selectBtTorrentVo"/> |
| <where> |
| <if test="torrentId != null and torrentId != ''"> and torrent_id = #{torrentId}</if> |
| |
| <if test="infoHash != null and infoHash != ''"> and info_hash = #{infoHash}</if> |
| <if test="name != null and name != ''"> and name like concat('%', #{name}, '%')</if> |
| <if test="length != null "> and length = #{length}</if> |
| <if test="pieceLength != null "> and piece_length = #{pieceLength}</if> |
| <if test="piecesCount != null "> and pieces_count = #{piecesCount}</if> |
| <if test="createdBy != null and createdBy != ''"> and created_by = #{createdBy}</if> |
| <if test="torrentCreateTime != null "> and torrent_create_time = #{torrentCreateTime}</if> |
| <if test="uploaderId != null "> and uploader_id = #{uploaderId}</if> |
| <if test="uploadTime != null "> and upload_time = #{uploadTime}</if> |
| <if test="filePath != null and filePath != ''"> and file_path = #{filePath}</if> |
| </where> |
| </select> |
| |
| <select id="selectBtTorrentByTorrentId" parameterType="Long" resultMap="BtTorrentResult"> |
| <include refid="selectBtTorrentVo"/> |
| where torrent_id = #{torrentId} |
| </select> |
| |
| <select id="selectBtTorrentsByIdsOrdered" resultType="BtTorrent"> |
| SELECT * FROM bt_torrent |
| WHERE id IN |
| <foreach collection="list" item="id" open="(" separator="," close=")"> |
| #{id} |
| </foreach> |
| ORDER BY FIELD(id |
| <foreach collection="list" item="id" separator=","> |
| #{id} |
| </foreach> |
| ) |
| </select> |
| |
| <insert id="insertBtTorrent" parameterType="BtTorrent" useGeneratedKeys="true" keyProperty="torrentId"> |
| insert into bt_torrent |
| <trim prefix="(" suffix=")" suffixOverrides=","> |
| <if test="infoHash != null and infoHash != ''">info_hash,</if> |
| <if test="name != null and name != ''">name,</if> |
| <if test="length != null">length,</if> |
| <if test="pieceLength != null">piece_length,</if> |
| <if test="piecesCount != null">pieces_count,</if> |
| <if test="createdBy != null">created_by,</if> |
| <if test="torrentCreateTime != null">torrent_create_time,</if> |
| <if test="uploaderId != null">uploader_id,</if> |
| <if test="uploadTime != null">upload_time,</if> |
| <if test="filePath != null">file_path,</if> |
| </trim> |
| <trim prefix="values (" suffix=")" suffixOverrides=","> |
| <if test="infoHash != null and infoHash != ''">#{infoHash},</if> |
| <if test="name != null and name != ''">#{name},</if> |
| <if test="length != null">#{length},</if> |
| <if test="pieceLength != null">#{pieceLength},</if> |
| <if test="piecesCount != null">#{piecesCount},</if> |
| <if test="createdBy != null">#{createdBy},</if> |
| <if test="torrentCreateTime != null">#{torrentCreateTime},</if> |
| <if test="uploaderId != null">#{uploaderId},</if> |
| <if test="uploadTime != null">#{uploadTime},</if> |
| <if test="filePath != null">#{filePath},</if> |
| </trim> |
| </insert> |
| |
| <update id="updateBtTorrent" parameterType="BtTorrent"> |
| update bt_torrent |
| <trim prefix="SET" suffixOverrides=","> |
| <if test="infoHash != null and infoHash != ''">info_hash = #{infoHash},</if> |
| <if test="name != null and name != ''">name = #{name},</if> |
| <if test="length != null">length = #{length},</if> |
| <if test="pieceLength != null">piece_length = #{pieceLength},</if> |
| <if test="piecesCount != null">pieces_count = #{piecesCount},</if> |
| <if test="createdBy != null">created_by = #{createdBy},</if> |
| <if test="torrentCreateTime != null">torrent_create_time = #{torrentCreateTime},</if> |
| <if test="uploaderId != null">uploader_id = #{uploaderId},</if> |
| <if test="uploadTime != null">upload_time = #{uploadTime},</if> |
| <if test="filePath != null">file_path = #{filePath},</if> |
| </trim> |
| where torrent_id = #{torrentId} |
| </update> |
| |
| <delete id="deleteBtTorrentByTorrentId" parameterType="Long"> |
| delete from bt_torrent where torrent_id = #{torrentId} |
| </delete> |
| |
| <delete id="deleteBtTorrentByTorrentIds" parameterType="String"> |
| delete from bt_torrent where torrent_id in |
| <foreach item="torrentId" collection="array" open="(" separator="," close=")"> |
| #{torrentId} |
| </foreach> |
| </delete> |
| </mapper> |