测试本地

Change-Id: Ib3a541fac7efd46cccd608c351fcd5f3236f475f
diff --git a/src/main/resources/mapper/PeerMapper.xml b/src/main/resources/mapper/PeerMapper.xml
index 4c90eae..27814fd 100644
--- a/src/main/resources/mapper/PeerMapper.xml
+++ b/src/main/resources/mapper/PeerMapper.xml
@@ -2,33 +2,41 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.example.g8backend.mapper.PeerMapper">
-    <select id="getPeerByPK">
+
+    <select id="getPeerByPK" parameterType="map" resultType="com.example.g8backend.entity.Peer">
         SELECT * FROM peers
         WHERE peer_id = #{peerId} and info_hash = #{infoHash} and passkey = #{passkey}
     </select>
-    <select id="getPeerByInfoHashAndPeerId">
+
+    <select id="getPeerByInfoHashAndPeerId" parameterType="map" resultType="com.example.g8backend.entity.Peer">
         SELECT * FROM peers
         WHERE info_hash = #{infoHash} and peer_id = #{peerId}
     </select>
+
     <select id="selectAllInfoHashesWithPeers" resultType="String">
         SELECT DISTINCT info_hash FROM peers
     </select>
 
     <select id="countRecentActivity" resultType="Long" parameterType="String">
-        SELECT COUNT(*) FROM peers
+        SELECT COUNT(*) FROM torrents
         WHERE info_hash = #{infoHash}
-        AND last_activity_time >= DATE_SUB(NOW(), INTERVAL 7 DAY)
+        AND upload_time >= DATE_SUB(NOW(), INTERVAL 7 DAY)
     </select>
+
+
     <select id="selectByInfoHashList" parameterType="list" resultType="com.example.g8backend.entity.Torrent">
         SELECT * FROM torrents
         WHERE info_hash IN
-        <foreach item="item" index="index" collection="infoHashes" open="(" separator="," close=")">
+        <foreach collection="infoHashes" item="item" open="(" separator="," close=")">
             #{item}
         </foreach>
     </select>
-    <update id="updatePeer">
+
+
+    <update id="updatePeer" parameterType="map">
         UPDATE peers
         SET uploaded = #{uploaded}, downloaded = #{downloaded}
-        WHERE peer_id = #{peerId} and info_hash = #{info_hash} and passkey = #{passkey}
+        WHERE peer_id = #{peerId} and info_hash = #{infoHash} and passkey = #{passkey}
     </update>
+
 </mapper>
diff --git a/src/main/resources/mapper/TorrentMapper.xml b/src/main/resources/mapper/TorrentMapper.xml
index cec75eb..e831504 100644
--- a/src/main/resources/mapper/TorrentMapper.xml
+++ b/src/main/resources/mapper/TorrentMapper.xml
@@ -3,31 +3,32 @@
         "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 
 <mapper namespace="com.example.g8backend.mapper.TorrentMapper">
-    <insert id="insertTorrent" >
+
+    <insert id="insertTorrent">
         INSERT INTO torrents (user_id, torrent_name, file_path, info_hash, file_size)
-        VALUES (#{userId}, #{torrentName}, #{filePath}, UNHEX(#{infoHash}), #{fileSize})
+        VALUES (#{userId}, #{torrentName}, #{filePath}, #{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
+        torrent_id,
+        user_id,
+        torrent_name,
+        file_path,
+        info_hash AS infoHash,
+        file_size
         FROM torrents
-        WHERE info_hash = UNHEX(#{infoHash})
+        WHERE info_hash = #{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
+        torrent_id,
+        user_id,
+        torrent_name,
+        file_path,
+        info_hash AS infoHash,
+        file_size
         FROM torrents
         WHERE torrent_id = #{torrentId}
     </select>
@@ -38,19 +39,21 @@
         user_id,
         torrent_name,
         file_path,
-        HEX(info_hash) AS infoHash,
-        file_size
+        info_hash AS infoHash,
+        file_size,
+        upload_time
         FROM torrents
         WHERE info_hash IN
         <foreach collection="infoHashes" item="hash" open="(" separator="," close=")">
-            UNHEX(#{hash})
+            #{hash}
         </foreach>
     </select>
 
+
     <update id="updateIsRareByInfoHash">
-        UPDATE torrent
-        SET israre = #{israre}
+        UPDATE torrents
+        SET is_rare = #{israre}
         WHERE info_hash = #{infoHash}
     </update>
 
-</mapper>
\ No newline at end of file
+</mapper>