100 lines
3.0 KiB
XML
100 lines
3.0 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.PoemDao">
|
|
|
|
<resultMap id="PoemResultMap" type="Poem">
|
|
<id property="poemId" column="poem_id" />
|
|
<result property="poemName" column="poem_name"/>
|
|
<result property="poemUserId" column="user_id"/>
|
|
<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>
|
|
<insert id="CreationPoem" >
|
|
insert into
|
|
t_poem (poem_name,poem_user,poem_information,givelike,collection,`explain`,`time`)
|
|
values (#{poemName},#{poemUser},#{poemInformation},0,0,#{explain},#{time});
|
|
</insert>
|
|
|
|
<update id="UpdatePoem">
|
|
update t_poem
|
|
set
|
|
poem_name=#{poemName},
|
|
poem_information=#{poemInformation},
|
|
`explain`=#{explain},
|
|
`time` = #{time}
|
|
where
|
|
poem_id = #{poemId};
|
|
</update>
|
|
|
|
<select id="finePoemByUserId" useCache="true" resultMap="PoemResultMap">
|
|
select
|
|
poem_id ,
|
|
poem_name ,
|
|
t_user.username as poem_user,
|
|
user_id,
|
|
poem_information ,
|
|
givelike ,
|
|
collection ,
|
|
`explain` ,
|
|
`time`
|
|
from t_poem left join t_user on t_poem.poem_user=t_user.user_id
|
|
where poem_user=#{userId}
|
|
|
|
</select>
|
|
|
|
<select id="fineDynastyByPoemId" useCache="true" resultMap="PoemResultMap">
|
|
select
|
|
poem_id ,
|
|
poem_name ,
|
|
t_user.username as poem_user,
|
|
user_id,
|
|
poem_information ,
|
|
givelike ,
|
|
collection ,
|
|
`explain` ,
|
|
`time`
|
|
from t_poem left join t_user on t_poem.poem_user=t_user.user_id
|
|
where poem_id = #{poemId}
|
|
</select>
|
|
|
|
<select id="fineDynastyByPoemName" useCache="true" resultMap="PoemResultMap">
|
|
select
|
|
poem_id ,
|
|
poem_name ,
|
|
t_user.username as poem_user,
|
|
user_id,
|
|
poem_information ,
|
|
givelike ,
|
|
collection ,
|
|
`explain` ,
|
|
`time`
|
|
from t_poem left join t_user on t_poem.poem_user=t_user.user_id
|
|
where poem_name=#{poemName}
|
|
</select>
|
|
|
|
<select id="finePoemByUserName" useCache="true" resultMap="PoemResultMap">
|
|
select
|
|
poem_id ,
|
|
poem_name ,
|
|
t_user.username as poem_user,
|
|
user_id,
|
|
poem_information ,
|
|
givelike ,
|
|
collection ,
|
|
`explain` ,
|
|
`time`
|
|
from t_poem left join t_user on t_poem.poem_user=t_user.user_id
|
|
where username=#{username}
|
|
</select>
|
|
|
|
<delete id="DeletePoem">
|
|
delete from t_poem where
|
|
poem_id = #{poemId}
|
|
</delete>
|
|
</mapper> |