<?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.FileAuthGroupMapper">

    <resultMap type="com.vctgo.file.domain.FileAuthGroup" id="FileAuthGroupResult">
        <result property="id" column="id"/>
        <result property="tenantId" column="tenant_id"/>
        <result property="groupType" column="group_type"/>
        <result property="isShow" column="is_show"/>
        <result property="groupCode" column="group_code"/>
        <result property="groupDesc" column="group_desc"/>
        <result property="groupContent" column="group_content"/>
        <result property="groupPermissions" column="group_permissions"/>
        <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"/>
    </resultMap>

    <sql id="selectFileAuthGroupVo">
        select id, tenant_id, group_type,is_show, group_code, group_desc, group_content, group_permissions, remark, is_deleted, create_by_id, create_by, create_time, update_by_id, update_by, update_time from file_auth_group
    </sql>

    <sql id="defaultDeleteCondition">
        is_deleted = '0'
    </sql>

    <select id="selectFileAuthGroupList" resultMap="FileAuthGroupResult">
        <include refid="selectFileAuthGroupVo"/>
        <where>
            <include refid="defaultDeleteCondition"/>
            <if test="query.tenantId != null  and query.tenantId != ''">and tenant_id = #{query.tenantId}</if>
            <if test="query.groupCode != null  and query.groupCode != ''">and group_code = #{query.groupCode}</if>
            <if test="query.groupDesc != null  and query.groupDesc != ''">and group_desc = #{query.groupDesc}</if>
            <if test="query.groupContent != null  and query.groupContent != ''">and group_content =
                #{query.groupContent}
            </if>
            <if test="query.groupPermissions != null  and query.groupPermissions != ''">and group_permissions =
                #{query.groupPermissions}
            </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>
        </where>
    </select>

    <update id="logicalDeleteFileAuthGroupByIds" parameterType="String">
        update file_auth_group set is_deleted = #{query.isDeleted},
        update_by_id = #{query.updateById}, update_by = #{query.updateBy},
        update_time = #{query.updateTime} where id in
        <foreach item="id" collection="ids" open="(" separator="," close=")">
            #{id}
        </foreach>
    </update>

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