ZHANG ZENGXUAN 3e52ba13db init git
2025-05-19 21:57:31 +08:00

110 lines
4.4 KiB
XML

<?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.jacklei.poetry.mapper.CollectionDao">
<resultMap id="PoemResultMap" type="com.jacklei.poetry.entities.Poem">
<id property="poemId" column="poem_id" />
<result property="poemName" column="poem_name"/>
<result property="poemUser" column="poem_user"/>
<result property="poemInformation" column="poem_information"/>
<result property="giveLike" column="givelike"/>
<result property="collection" column="collection"/>
<result property="explain" column="explain"/>
<result property="time" column="time"/>
</resultMap>
<resultMap id="DynastyResultMap" type="com.jacklei.poetry.entities.Dynasty">
<id property="dynastyId" column="dynasty_id" />
<result property="dynastyName" column="dynasty_name"/>
<result property="dynastyUser" column="dynasty_user"/>
<result property="dynastyInformation" column="dynasty_information"/>
<result property="giveLike" column="givelike"/>
<result property="collection" column="collection"/>
<result property="explain" column="explain"/>
<result property="time" column="time"/>
</resultMap>
<delete id="DeletePoemCollection">
delete from t_collection_poem where poem_id=#{poemId}
</delete>
<delete id="DeleteDynastyCollection">
delete from t_collection_dynasty where dynasty_id=#{dynastyId}
</delete>
<select id="SeeCollectionPoemExistence" resultType="int">
select COUNT(*) from t_collection_poem where user_id=#{userId} and poem_id=#{poemId}
</select>
<insert id="CollectionPoem">
insert into t_collection_poem (user_id,poem_id,`time`) values (#{userId},#{poemId},#{time});
</insert>
<select id="SeeCollectionDynastyExistence" resultType="int">
select COUNT(*) from t_collection_dynasty where user_id=#{userId} and dynasty_id=#{dynastyId}
</select>
<insert id="CollectionDynasty">
insert into t_collection_dynasty (user_id,dynasty_id,`time`) values (#{userId},#{dynastyId},#{time});
</insert>
<select id="SeeCollectionPoem" useCache="true" resultMap="PoemResultMap">
select
poem_id,
poem_name,
username as poem_user,
poem_information,
givelike,
collection,
`explain`,
`time`
from t_poem left join t_user on poem_user = user_id
where poem_id in
(
select poem_id from t_collection_poem
where user_id=#{userId}
)
</select>
<select id="SeeCollectionDynasty" useCache="true" resultMap="DynastyResultMap">
select
dynasty_id,
dynasty_name,
username as dynasty_user,
dynasty_information,
givelike,
collection,
`explain`,
`time`
from t_dynasty left join t_user on dynasty_user = user_id
where dynasty_id in
(
select dynasty_id from t_collection_dynasty
where user_id=#{userId}
);
</select>
<select id="SeeCollectionPoemNum" useCache="true" resultType="int">
select COUNT(*) from t_collection_poem
where poem_id=#{poemId};
</select>
<select id="SeeCollectionDynastyNum" resultType="int">
select COUNT(*) from t_collection_dynasty
where dynasty_id=#{dynastyId};
</select>
<select id="publicSeePoemCollection" resultType="int">
select COUNT(*) from t_collection_poem
where poem_id=#{poemId} and user_id=#{userId};
</select>
<select id="publicSeeDynastyCollection" resultType="int">
select COUNT(*) from t_collection_dynasty
where dynasty_id=#{dynastyId} and user_id=#{userId};
</select>
<delete id="poemCollectionCancel">
delete from t_collection_poem where poem_id=#{poemId} and user_id=#{userId}
</delete>
<delete id="dynastyCollectionCancel">
delete from t_collection_dynasty where dynasty_id=#{dynastyId} and user_id=#{userId}
</delete>
<update id="changeCollectionPoemNum">
update t_poem set collection = #{result} where poem_id = #{poemId};
</update>
<update id="changeCollectionDynastyNum">
update t_dynasty set collection = #{result} where dynasty_id = #{dynastyId};
</update>
</mapper>