<?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.javaweb.cms.mapper.AlbumMapper">
|
|
<resultMap type="Album" id="AlbumResult">
|
<result property="albumId" column="album_id" />
|
<result property="albumName" column="album_name" />
|
<result property="userId" column="user_id" />
|
<result property="deptId" column="dept_id" />
|
<result property="albumType" column="album_type" />
|
<result property="description" column="description" />
|
<result property="createBy" column="create_by" />
|
<result property="createTime" column="create_time" />
|
<result property="auditState" column="audit_state" />
|
<result property="code" column="code" />
|
<result property="width" column="width" />
|
<result property="height" column="height" />
|
</resultMap>
|
|
<sql id="selectAlbumVo">
|
select a.album_id, a.album_name, a.user_id, a.dept_id, a.album_type,
|
a.description, a.create_by, a.create_time,
|
a.audit_state,a.code,a.width,a.height from cms_album a
|
</sql>
|
|
<select id="selectAlbumList" parameterType="Album" resultMap="AlbumResult">
|
<include refid="selectAlbumVo" />
|
<where>
|
<if test="albumName != null and albumName != ''"> and a.album_name like concat('%', #{albumName}, '%')
|
</if>
|
<if test="albumType != null and albumType != ''"> and a.album_type = #{albumType}</if>
|
<if test="code != null and code != ''"> and a.code = #{code}</if>
|
<if test="auditState != null "> and a.audit_state = #{auditState}</if>
|
${params.dataScope}
|
</where>
|
|
</select>
|
|
<select id="selectAlbumById" parameterType="String" resultMap="AlbumResult">
|
<include refid="selectAlbumVo" />
|
where a.album_id = #{albumId}
|
</select>
|
|
<select id="selectAlbumByCode" parameterType="String" resultMap="AlbumResult">
|
<include refid="selectAlbumVo" />
|
where a.code = #{code}
|
</select>
|
|
<insert id="insertAlbum" parameterType="Album">
|
insert into cms_album
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
<if test="albumId != null and albumId != ''">album_id,</if>
|
<if test="albumName != null and albumName != ''">album_name,</if>
|
<if test="userId != null and userId != ''">user_id,</if>
|
<if test="deptId != null and deptId != ''">dept_id,</if>
|
<if test="albumType != null and albumType != ''">album_type,</if>
|
|
<if test="description != null and description != ''">description,</if>
|
<if test="createBy != null and createBy != ''">create_by,</if>
|
<if test="createTime != null ">create_time,</if>
|
<if test="auditState != null ">audit_state,</if>
|
<if test="code != null and code != ''">code,</if>
|
<if test="width != null">width,</if>
|
<if test="height != null">height,</if>
|
</trim>
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
<if test="albumId != null and albumId != ''">#{albumId},</if>
|
<if test="albumName != null and albumName != ''">#{albumName},</if>
|
<if test="userId != null and userId != ''">#{userId},</if>
|
<if test="deptId != null and deptId != ''">#{deptId},</if>
|
<if test="albumType != null and albumType != ''">#{albumType},</if>
|
|
<if test="description != null and description != ''">#{description},</if>
|
<if test="createBy != null and createBy != ''">#{createBy},</if>
|
<if test="createTime != null ">#{createTime},</if>
|
<if test="auditState != null ">#{auditState},</if>
|
<if test="code != null and code != ''">#{code},</if>
|
<if test="width != null">#{width},</if>
|
<if test="height != null">#{height},</if>
|
</trim>
|
</insert>
|
|
<insert id="insertAlbumMaterial" useGeneratedKeys="true"
|
keyProperty="id" parameterType="AlbumMaterial">
|
insert into cms_album_material (id,album_id,material_id,link,sort)
|
values
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
null,
|
<if test="albumId != null and albumId != ''">#{albumId},</if>
|
<if test="materialId != null and materialId != ''">#{materialId},</if>
|
<if test="link != null and link != ''">#{link},</if>
|
<if test="sort != null and sort != ''">#{sort},</if>
|
</trim>
|
</insert>
|
|
<insert id="insertAlbumMaterialBatch" parameterType="AlbumMaterial">
|
insert into cms_album_material (id,album_id,material_id,link,sort)
|
values
|
<foreach collection="list" item="item" separator=",">
|
(null,#{item.albumId},#{item.materialId},#{item.link},#{item.sort})
|
</foreach>
|
</insert>
|
|
<resultMap type="AlbumMaterial" id="AlbumMaterialResult">
|
<result property="id" column="id" />
|
<result property="link" column="link" />
|
<result property="sort" column="sort" />
|
<result property="materialId" column="material_id" />
|
<result property="albumId" column="album_id" />
|
</resultMap>
|
|
|
<select id="selectAlbumMaterialByIds" parameterType="String"
|
resultMap="AlbumMaterialResult">
|
select * from cms_album_material where id in
|
<foreach item="id" collection="array" open="(" separator=","
|
close=")">
|
#{id}
|
</foreach>
|
|
</select>
|
<delete id="deleteAlbumMaterialByIds" parameterType="String">
|
delete from cms_album_material where id in
|
<foreach item="id" collection="array" open="(" separator=","
|
close=")">
|
#{id}
|
</foreach>
|
</delete>
|
<update id="updateAlbum" parameterType="Album">
|
update cms_album
|
<trim prefix="SET" suffixOverrides=",">
|
<if test="albumName != null and albumName != ''">album_name = #{albumName},</if>
|
<if test="userId != null and userId != ''">user_id = #{userId},</if>
|
<if test="deptId != null and deptId != ''">dept_id = #{deptId},</if>
|
<if test="albumType != null and albumType != ''">album_type = #{albumType},</if>
|
|
<if test="description != null and description != ''">description = #{description},</if>
|
<if test="createBy != null and createBy != ''">create_by = #{createBy},</if>
|
<if test="createTime != null ">create_time = #{createTime},</if>
|
<if test="auditState != null ">audit_state = #{auditState},</if>
|
<if test="code != null ">code = #{code},</if>
|
<if test="width != null ">width = #{width},</if>
|
<if test="height != null ">height = #{height},</if>
|
</trim>
|
where album_id = #{albumId}
|
</update>
|
|
<delete id="deleteAlbumById" parameterType="String">
|
delete from cms_album where album_id = #{albumId}
|
</delete>
|
|
<delete id="deleteAlbumByIds" parameterType="String">
|
delete from cms_album where album_id in
|
<foreach item="albumId" collection="array" open="(" separator=","
|
close=")">
|
#{albumId}
|
</foreach>
|
</delete>
|
|
</mapper>
|