blob: 9b53d29b74889799c9b0d9519ae5556f2301e8d9 [file] [log] [blame] [edit]
<?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, info_hash, file_size)
VALUES (#{userId}, #{torrentName}, UNHEX(#{infoHash}), #{fileSize})
</insert>
<select id="getTorrentByInfoHash" resultType="com.example.g8backend.entity.Torrent">
SELECT
torrent_id,
user_id,
torrent_name,
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,
HEX(info_hash) AS infoHash,
file_size
FROM torrents
WHERE torrent_id = #{torrentId}
</select>
</mapper>