Files
Tbed/src/main/resources/mapper/AlbumMapper.xml
T
2022-04-15 19:14:15 +08:00

80 lines
2.3 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="cn.hellohao.dao.AlbumMapper">
<select id="selectAlbum" parameterType="cn.hellohao.pojo.Album" resultType="cn.hellohao.pojo.Album">
SELECT
*
FROM
`album`
<where>
<if test="albumkey != null">
`albumkey` = #{albumkey}
</if>
<if test="userid != null">
`userid` = #{userid}
</if>
</where>
</select>
<insert id="addAlbum" parameterType="cn.hellohao.pojo.Album">
insert into `album` (albumkey,albumtitle,createdate,`password`,userid)
values (#{albumkey},#{albumtitle},#{createdate},#{password},#{userid})
</insert>
<delete id="deleteAlbum" parameterType="string">
delete from album where albumkey=#{albumkey}
</delete>
<select id="selectAlbumURLList" parameterType="cn.hellohao.pojo.Album" resultType="cn.hellohao.pojo.Album">
SELECT
a.albumkey,
a.albumtitle,
a.createdate,
a.`password`,
a.userid,
u.username
FROM `album` a LEFT JOIN user u on a.userid = u.id
<where>
<if test="albumkey != null">
`albumkey` like '%${albumkey}%'
</if>
<if test="username != null">
`username` like '%${username}%'
</if>
<if test="userid != null">
a.userid = #{userid}
</if>
</where>
order by a.createdate
</select>
<select id="selectAlbumCount" parameterType="integer" resultType="integer">
SELECT
count(albumkey)
FROM
`album`
<where>
<if test="userid != null">
`userid` = #{userid}
</if>
</where>
</select>
<update id="updateAlbum" parameterType="cn.hellohao.pojo.Album">
UPDATE `album`
<set>
<if test="albumtitle != null">
albumtitle = #{albumtitle},
</if>
<if test="password != null">
password = #{password},
</if>
</set>
WHERE
albumkey = #{albumkey}
</update>
</mapper>