blob: 243fd92ebf9a38b48a41d3b6e3d244a36a8d7f50 [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, 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>