<?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.system.mapper.SysAdminManageMapper">

    <resultMap type="com.vctgo.system.domain.SysAdminManage" id="SysAdminManageResult">
        <result property="id"    column="id"    />
        <result property="roleKey"    column="role_key"    />
        <result property="menuIds"    column="menu_ids"    />
        <result property="isDeleted"    column="is_deleted"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
        <result property="remark"    column="remark"    />
        <result property="createById"    column="create_by_id"    />
        <result property="updateById"    column="update_by_id"    />
        <result property="tenantId"    column="tenant_id"    />
    </resultMap>

    <sql id="selectSysAdminManageVo">
        select id, role_key, menu_ids, is_deleted, create_by, create_time, update_by, update_time, remark, create_by_id, update_by_id, tenant_id from sys_admin_manage
    </sql>

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

    <select id="selectSysAdminManageList"   resultMap="SysAdminManageResult">
        <include refid="selectSysAdminManageVo"/>
        <where>
            <include refid="defaultDeleteCondition"/>
            <if test="query.roleKey != null  and query.roleKey != ''"> and role_key = #{query.roleKey}</if>
            <if test="query.menuIds != null  and query.menuIds != ''"> and menu_ids = #{query.menuIds}</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>

    <update id="logicalDeleteSysAdminManageByIds" parameterType="String">
        update sys_admin_manage 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="deleteSysAdminManageByIds" parameterType="String">
        delete from sys_admin_manage where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
</mapper>
