<?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.vctgo.file.mapper.FileShareMapper">

    <resultMap type="com.vctgo.file.domain.FileShare" id="FileShareResult">
        <result property="id" column="id"/>
        <result property="timeUnit" column="time_unit"/>
        <result property="totalShareTime" column="total_share_time"/>
        <result property="isShareExpired" column="is_share_expired"/>
        <result property="remark" column="remark"/>
        <result property="isDeleted" column="is_deleted"/>
        <result property="createById" column="create_by_id"/>
        <result property="createBy" column="create_by"/>
        <result property="createTime" column="create_time"/>
        <result property="updateById" column="update_by_id"/>
        <result property="updateBy" column="update_by"/>
        <result property="updateTime" column="update_time"/>
        <result property="tenantId" column="tenant_id"/>
    </resultMap>

    <sql id="selectFileShareVo">
        select id, time_unit, total_share_time, is_share_expired, remark, is_deleted, create_by_id, create_by, create_time, update_by_id, update_by, update_time, tenant_id from file_share
    </sql>

    <select id="selectFileShareList" resultMap="FileShareResult">
        <include refid="selectFileShareVo"/>
        <where>
            <if test="query.timeUnit != null  and query.timeUnit != ''">and time_unit = #{query.timeUnit}</if>
            <if test="query.totalShareTime != null  and query.totalShareTime != ''">and total_share_time =
                #{query.totalShareTime}
            </if>
            <if test="query.isShareExpired != null  and query.isShareExpired != ''">and is_share_expired =
                #{query.isShareExpired}
            </if>
            <if test="query.isDeleted != null  and query.isDeleted != ''">and is_deleted = #{query.isDeleted}</if>
            <if test="query.createById != null ">and create_by_id = #{query.createById}</if>
            <if test="query.updateById != null ">and update_by_id = #{query.updateById}</if>
            <if test="query.tenantId != null ">and tenant_id = #{query.tenantId}</if>
        </where>
    </select>

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