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

99 lines
3.7 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.GiveLikeDao">
<resultMap id="UserResultMap" type="com.jacklei.poetry.entities.User">
<id property="userId" column="user_id" />
<result property="username" column="username"/>
<result property="password" column="password"/>
<result property="email" column="email"/>
</resultMap>
<resultMap id="GLPoemResultMap" type="com.jacklei.poetry.entities.GLPoem">
<id property="GiveLikeId" column="givelike_id"/>
<result property="userId" column="user_id"/>
<result property="poemId" column="poem_id"/>
<result property="time" column="time"/>
</resultMap>
<resultMap id="GLDynastyResultMap" type="com.jacklei.poetry.entities.GLPoem">
<id property="GiveLikeId" column="givelike_id"/>
<result property="userId" column="user_id"/>
<result property="DynastyId" column="dynasty_id"/>
<result property="time" column="time"/>
</resultMap>
<delete id="DeletePoemGive">
delete from t_givelike_poem where poem_id=#{poemId}
</delete>
<delete id="DeleteDynastyGive">
delete from t_givelike_dynasty where dynasty_id=#{dynastyId}
</delete>
<select id="SeeDynastyGiveLike" useCache="true" resultMap="GLPoemResultMap">
select
givelike_id,
username as user_id,
dynasty_name as dynasty_id,
t_givelike_dynasty.`time`
from
t_givelike_dynasty,t_user,t_dynasty
where(t_givelike_dynasty.dynasty_id = #{dynastyId})
and
(t_givelike_dynasty.user_id = t_user.user_id)
and
(t_givelike_dynasty.dynasty_id = t_dynasty.dynasty_id)
</select>
<select id="SeePoemGiveLike" useCache="true" resultMap="GLPoemResultMap">
select
givelike_id,
username as user_id,
poem_name as poem_id,
t_givelike_poem.`time`
from
t_givelike_poem,t_user,t_poem
where(t_givelike_poem.poem_id = #{poemId})
and
(t_givelike_poem.user_id = t_user.user_id)
and
(t_givelike_poem.poem_id = t_poem.poem_id)
</select>
<insert id="PoemGiveLike">
insert into t_givelike_poem (user_id,poem_id,`time`) values (#{userId},#{poemId},#{time});
</insert>
<insert id="DynastyGiveLike">
insert into t_givelike_dynasty (user_id,dynasty_id,`time`) values (#{userId},#{dynastyId},#{time});
</insert>
<delete id="PoemGiveLikeCancel">
delete from t_givelike_poem where givelike_id=#{giveLikeId};
</delete>
<delete id="DynastyGiveLikeCancel">
delete from t_givelike_dynasty where givelike_id=#{giveLikeId};
</delete>
<select id="publicSeePoemGiveLike" resultType="int">
select COUNT(*)
from t_givelike_poem
where user_id=#{userId} and poem_id=#{poemId}
</select>
<select id="publicSeeDynastyGiveLike" resultType="int">
select COUNT(*)
from t_givelike_dynasty
where user_id=#{userId} and dynasty_id=#{dynastyId}
</select>
<delete id="poemGiveLikeCancelByUserId">
delete from t_givelike_poem where user_id=#{userId} and poem_id=#{poemId};
</delete>
<delete id="dynastyGiveLikeCancelByUserId">
delete from t_givelike_dynasty where user_id=#{userId} and dynasty_id=#{dynastyId};
</delete>
<update id="changeDynastyGiveLikeNum">
update t_dynasty set givelike = #{size} where dynasty_id = #{dynastyId} ;
</update>
<update id="changePoemGiveLikeNum">
update t_poem set givelike = #{size} where poem_id = #{poemId} ;
</update>
</mapper>