Revert "注册登录,用户等级,社交,动态,新手任务"

This reverts commit 1c359108ca33d46271920ee0cd57dddcb7012937.

Reason for revert: <冲突>

Change-Id: Ie586267169acac99130b1fadf4a5f433441c4b8c
diff --git a/target/classes/mapper/TorrentMapper.xml b/target/classes/mapper/TorrentMapper.xml
new file mode 100644
index 0000000..d5f018e
--- /dev/null
+++ b/target/classes/mapper/TorrentMapper.xml
@@ -0,0 +1,104 @@
+<?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.myproject.mapper.TorrentMapper">
+    <resultMap id="BaseResultMap" type="com.example.myproject.entity.TorrentEntity">
+        <id column="info_hash" property="infoHash"/>
+        <result column="file_name" property="fileName"/>
+        <result column="uploader" property="uploader"/>
+        <result column="upload_time" property="uploadTime"/>
+        <result column="size" property="size"/>
+        <result column="title" property="title"/>
+        <result column="description" property="description"/>
+        <result column="category" property="category"/>
+        <result column="image_url" property="imageUrl"/>
+    </resultMap>
+
+    <select id="selectByInfoHash" resultMap="BaseResultMap">
+        SELECT * FROM torrent WHERE info_hash = #{infoHash}
+    </select>
+    <select id="selectBySeedId" resultMap="BaseResultMap">
+        SELECT * FROM torrent WHERE seed_id = #{seedId}
+    </select>
+
+
+
+
+    <update id="update" parameterType="com.example.myproject.entity.TorrentEntity">
+        UPDATE torrent
+        SET file_name = #{fileName},
+        uploader = #{uploader},
+        upload_time = #{uploadTime},
+        size = #{size},
+        title = #{title},
+        description = #{description},
+        category = #{category},
+        image_url = #{imageUrl}
+        WHERE info_hash = #{infoHash}
+    </update>
+    <select id="search" resultType="com.example.myproject.entity.TorrentEntity">
+        SELECT * FROM torrent
+        <where>
+            <if test="param.category != null">
+                AND category = #{param.category}
+            </if>
+
+            <!--        <if test="param.free != null and param.free != ''">-->
+            <!--            AND free = #{param.free}-->
+            <!--        </if>-->
+            <if test="param.free != null">
+            <choose>
+                <!-- 筛选“正在促销中”的种子 -->
+                <when test="param.free == true">
+                    AND EXISTS (
+                    SELECT 1 FROM promotion p
+                    WHERE
+                    JSON_CONTAINS(p.applicable_torrent_ids, JSON_ARRAY(t.id))
+                    AND NOW() BETWEEN p.start_time AND p.end_time
+                    AND p.is_deleted = 0
+                    )
+                </when>
+                <!-- 筛选“未在促销中”的种子 -->
+                <otherwise>
+                    AND NOT EXISTS (
+                    SELECT 1 FROM promotion p
+                    WHERE
+                    JSON_CONTAINS(p.applicable_torrent_ids, JSON_ARRAY(t.id))
+                    AND NOW() BETWEEN p.start_time AND p.end_time
+                    AND p.is_deleted = 0
+                    )
+                </otherwise>
+            </choose>
+            </if>
+
+            <if test="param.likeExpressions != null and param.likeExpressions.size > 0">
+                AND (
+                <foreach collection="param.likeExpressions" item="item" open="(" separator=" AND " close=")">
+
+                    ( title LIKE CONCAT('%', #{item}, '%') ) or ( description LIKE CONCAT('%', #{item}, '%') ) or ( tags LIKE CONCAT('%', #{item}, '%') )
+                </foreach>
+                )
+            </if>
+        </where>
+
+        <if test="param.prop != null and param.sort != null">
+            ORDER BY ${param.prop} ${param.sort}
+        </if>
+    </select>
+    <select id="checkFavorite" resultType="boolean">
+        SELECT COUNT(*) > 0
+        FROM favorite
+        WHERE seed_id = #{seedId} AND user_id = #{userId}
+    </select>
+    <insert id="addFavorite">
+        INSERT INTO favorite (seed_id, user_id)
+        VALUES (#{seedId}, #{userId})
+    </insert>
+    <delete id="removeFavorite">
+        DELETE FROM favorite
+        WHERE seed_id = #{seedId} AND user_id = #{userId}
+    </delete>
+
+
+</mapper>
\ No newline at end of file