<?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.sf.file.mapper.SysOssMapper">
    
    <resultMap type="SysOss" id="SysOssResult">
        <result property="id"    column="id"    />
        <result property="tenantId"    column="tenant_id"    />
        <result property="fileName"    column="file_name"    />
        <result property="originalName"    column="original_name"    />
        <result property="fileSuffix"    column="file_suffix"    />
        <result property="url"    column="url"    />
        <result property="createDept"    column="create_dept"    />
        <result property="createTime"    column="create_time"    />
        <result property="createBy"    column="create_by"    />
        <result property="updateTime"    column="update_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="service"    column="service"    />
    </resultMap>

    <sql id="selectSysOssVo">
        select id, tenant_id, file_name, original_name, file_suffix, url, create_dept, create_time, create_by, update_time, update_by, service from Sys_oss
    </sql>

    <select id="selectSysOssList" parameterType="SysOss" resultMap="SysOssResult">
        <include refid="selectSysOssVo"/>
        <where>  
            <if test="tenantId != null  and tenantId != ''"> and tenant_id = #{tenantId}</if>
            <if test="fileName != null  and fileName != ''"> and file_name like concat('%', #{fileName}, '%')</if>
            <if test="originalName != null  and originalName != ''"> and original_name like concat('%', #{originalName}, '%')</if>
            <if test="fileSuffix != null  and fileSuffix != ''"> and file_suffix = #{fileSuffix}</if>
            <if test="url != null  and url != ''"> and url = #{url}</if>
            <if test="createDept != null "> and create_dept = #{createDept}</if>
            <if test="service != null  and service != ''"> and service = #{service}</if>
        </where>
    </select>
    
    <select id="selectSysOssById" parameterType="String" resultMap="SysOssResult">
        <include refid="selectSysOssVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertSysOss" parameterType="SysOss">
        insert into Sys_oss
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="tenantId != null">tenant_id,</if>
            <if test="fileName != null and fileName != ''">file_name,</if>
            <if test="originalName != null and originalName != ''">original_name,</if>
            <if test="fileSuffix != null and fileSuffix != ''">file_suffix,</if>
            <if test="url != null and url != ''">url,</if>
            <if test="createDept != null">create_dept,</if>
            <if test="createTime != null">create_time,</if>
            <if test="createBy != null">create_by,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="service != null and service != ''">service,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="tenantId != null">#{tenantId},</if>
            <if test="fileName != null and fileName != ''">#{fileName},</if>
            <if test="originalName != null and originalName != ''">#{originalName},</if>
            <if test="fileSuffix != null and fileSuffix != ''">#{fileSuffix},</if>
            <if test="url != null and url != ''">#{url},</if>
            <if test="createDept != null">#{createDept},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="service != null and service != ''">#{service},</if>
         </trim>
    </insert>

    <update id="updateSysOss" parameterType="SysOss">
        update Sys_oss
        <trim prefix="SET" suffixOverrides=",">
            <if test="tenantId != null">tenant_id = #{tenantId},</if>
            <if test="fileName != null and fileName != ''">file_name = #{fileName},</if>
            <if test="originalName != null and originalName != ''">original_name = #{originalName},</if>
            <if test="fileSuffix != null and fileSuffix != ''">file_suffix = #{fileSuffix},</if>
            <if test="url != null and url != ''">url = #{url},</if>
            <if test="createDept != null">create_dept = #{createDept},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="service != null and service != ''">service = #{service},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteSysOssById" parameterType="String">
        delete from Sys_oss where id = #{id}
    </delete>

    <delete id="deleteSysOssByIds" parameterType="String">
        delete from Sys_oss where id in 
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
</mapper>