| <?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.example.g8backend.mapper.TorrentMapper"> |
| <insert id="insertTorrent" > |
| INSERT INTO torrents (user_id, torrent_name, file_path, info_hash, file_size) |
| VALUES (#{userId}, #{torrentName}, #{filePath}, UNHEX(#{infoHash}), #{fileSize}) |
| </insert> |
| |
| <select id="getTorrentByInfoHash" resultType="com.example.g8backend.entity.Torrent"> |
| SELECT |
| torrent_id, |
| user_id, |
| torrent_name, |
| file_path, |
| HEX(info_hash) AS infoHash, |
| file_size |
| FROM torrents |
| WHERE info_hash = UNHEX(#{infoHash}) |
| </select> |
| |
| <select id="getTorrentByTorrentId" resultType="com.example.g8backend.entity.Torrent"> |
| SELECT |
| torrent_id, |
| user_id, |
| torrent_name, |
| file_path, |
| HEX(info_hash) AS infoHash, |
| file_size |
| FROM torrents |
| WHERE torrent_id = #{torrentId} |
| </select> |
| </mapper> |