Revert "注册登录,用户等级,社交,动态,新手任务"
This reverts commit 1c359108ca33d46271920ee0cd57dddcb7012937.
Reason for revert: <冲突>
Change-Id: Ie586267169acac99130b1fadf4a5f433441c4b8c
diff --git a/src/main/resources/mapper/FavoriteMapper.xml b/src/main/resources/mapper/FavoriteMapper.xml
new file mode 100644
index 0000000..1048ec2
--- /dev/null
+++ b/src/main/resources/mapper/FavoriteMapper.xml
@@ -0,0 +1,6 @@
+<?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.FavoriteMapper">
+
+</mapper>
diff --git a/src/main/resources/mapper/PromotionMapper.xml b/src/main/resources/mapper/PromotionMapper.xml
new file mode 100644
index 0000000..72ffd95
--- /dev/null
+++ b/src/main/resources/mapper/PromotionMapper.xml
@@ -0,0 +1,14 @@
+<?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.PromotionMapper">
+
+ <insert id="insert" parameterType="com.example.myproject.entity.Promotion">
+ INSERT INTO promotion (
+ name, description, start_time, end_time, discount_percentage, applicable_torrent_ids
+ ) VALUES (
+ #{name}, #{description}, #{startTime}, #{endTime}, #{discountPercentage}, #{applicableTorrentIds}
+ )
+ </insert>
+
+</mapper>
diff --git a/src/main/resources/mapper/TorrentMapper.xml b/src/main/resources/mapper/TorrentMapper.xml
new file mode 100644
index 0000000..d5f018e
--- /dev/null
+++ b/src/main/resources/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
diff --git a/src/main/resources/mapper/UserMapper.xml b/src/main/resources/mapper/UserMapper.xml
new file mode 100644
index 0000000..f03ab0a
--- /dev/null
+++ b/src/main/resources/mapper/UserMapper.xml
@@ -0,0 +1,21 @@
+<?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.UserMapper">
+ <!-- 根据用户名查找用户 -->
+ <select id="selectByUsername" parameterType="string" resultType="com.example.myproject.entity.User">
+ SELECT * FROM user WHERE username = #{username}
+ </select>
+ <!-- 根据用户名和密码查找用户 -->
+ <select id="selectByUsernameAndPassword" parameterType="map" resultType="com.example.myproject.entity.User">
+ SELECT * FROM user WHERE username = #{username} AND password = #{password}
+ </select>
+ <!-- 根据邮箱查找用户 -->
+ <select id="selectByEmail" parameterType="string" resultType="com.example.myproject.entity.User">
+ SELECT * FROM user WHERE email = #{email}
+ </select>
+ <!-- 根据用户名包含查找用户 -->
+ <select id="selectByUsernameContaining" parameterType="string" resultType="com.example.myproject.entity.User">
+ SELECT * FROM user WHERE username LIKE CONCAT('%', #{name}, '%')
+ </select>
+</mapper>
diff --git a/src/main/resources/mapper/VerificationTokenMapper.xml b/src/main/resources/mapper/VerificationTokenMapper.xml
new file mode 100644
index 0000000..53b19a5
--- /dev/null
+++ b/src/main/resources/mapper/VerificationTokenMapper.xml
@@ -0,0 +1,10 @@
+<?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.VerificationTokenMapper">
+ <!-- 通过 token 和 email 查询 VerificationToken -->
+ <select id="findByTokenAndEmail" resultType="com.example.myproject.entity.VerificationToken">
+ SELECT * FROM verification_token
+ WHERE token = #{token} AND email = #{email}
+ </select>
+</mapper>