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

121 lines
4.2 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.CategoryDao">
<!--<resultMap id="UserResultMap" type="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="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>
<select id="SeePoemTypeExistence" useCache="true" resultType="Integer">
select seasons_id from t_poemtype where poem_id=#{poemId} and `type`=#{type}
</select>
<select id="SeeDynastyTypeExistence" useCache="true" resultType="Integer">
select seasons_id from t_dynastytype where dynasty_id=#{dynastyId} and `type`=#{type}
</select>
<insert id="AddPoemType" >
insert into t_poemtype (poem_id,`type`) values (#{poemId},#{type});
</insert>
<insert id="AddDynastyType">
insert into t_dynastytype (dynasty_id,`type`) values (#{dynastyId},#{type});
</insert>
<delete id="DeletePoemType">
delete from t_poemtype where poem_id=#{poemId}
</delete>
<delete id="DeleteDynastyType">
delete from t_dynastytype where dynasty_id=#{dynastyId}
</delete>
<select id="SeePoemType" useCache="true" resultType="Integer">
select `type` from t_poemtype where poem_id=#{poemId}
</select>
<select id="SeeDynastyType" useCache="true" resultType="Integer">
select `type` from t_dynastytype where dynasty_id=#{dynastyId}
</select>
<select id="fineDynastyType" useCache="true" parameterType="map" 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_dynastytype
where `type`=#{type} )
limit #{params.page},#{params.size} ;
</select>
<select id="dynastyCount" useCache="true" resultType="Long">
select
COUNT(*)
from t_dynasty
where dynasty_id in
(
select dynasty_id from t_dynastytype
where `type`=#{type} )
</select>
<select id="finePoemType" 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_poemtype
where `type`=#{type})
limit #{params.page},#{params.size} ;
</select>
<select id="poemCount" useCache="true" resultType="Long">
select
COUNT(*)
from t_poem
where poem_id in
(
select poem_id from t_poemtype
where `type`=#{type})
</select>
</mapper>