FileMapper.xml 2.31 KB
<?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.bootdo.common.dao.FileDao">

	<select id="get" resultType="com.bootdo.common.domain.FileDO">
		select `id`,`type`,`url`,`create_date` from sys_file where id = #{value}
	</select>

	<select id="list" resultType="com.bootdo.common.domain.FileDO">
		select `id`,`type`,`url`,`create_date` from sys_file
        <where>  
		  		  <if test="id != null and id != ''"> and id = #{id} </if>
		  		  <if test="type != null and type != ''"> and type = #{type} </if>
		  		  <if test="url != null and url != ''"> and url = #{url} </if>
		  		  <if test="createDate != null and createDate != ''"> and create_date = #{createDate} </if>
		  		</where>
        <choose>
            <when test="sort != null and sort.trim() != ''">
                order by ${sort} ${order}
            </when>
			<otherwise>
                order by id desc
			</otherwise>
        </choose>
		<if test="offset != null and limit != null">
			limit #{offset}, #{limit}
		</if>
	</select>
	
 	<select id="count" resultType="int">
		select count(*) from sys_file
		 <where>  
		  		  <if test="id != null and id != ''"> and id = #{id} </if>
		  		  <if test="type != null and type != ''"> and type = #{type} </if>
		  		  <if test="url != null and url != ''"> and url = #{url} </if>
		  		  <if test="createDate != null and createDate != ''"> and create_date = #{createDate} </if>
		  		</where>
	</select>
	 
	<insert id="save" parameterType="com.bootdo.common.domain.FileDO" useGeneratedKeys="true" keyProperty="id">
		insert into sys_file
		(
			`type`, 
			`url`, 
			`create_date`
		)
		values
		(
			#{type}, 
			#{url}, 
			#{createDate}
		)
	</insert>
	 
	<update id="update" parameterType="com.bootdo.common.domain.FileDO">
		update sys_file 
		<set>
			<if test="type != null">`type` = #{type}, </if>
			<if test="url != null">`url` = #{url}, </if>
			<if test="createDate != null">`create_date` = #{createDate}</if>
		</set>
		where id = #{id}
	</update>
	
	<delete id="remove">
		delete from sys_file where id = #{value}
	</delete>
	
	<delete id="batchRemove">
		delete from sys_file where id in 
		<foreach item="id" collection="array" open="(" separator="," close=")">
			#{id}
		</foreach>
	</delete>

</mapper>