<?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.lz.modules.flow.dao.RecordRoleAuthMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.lz.modules.flow.entity.RecordRoleAuth">
        <id column="id" property="id"/>
        <result column="is_delete" property="isDelete"/>
        <result column="gmt_create" property="gmtCreate"/>
        <result column="gmt_modified" property="gmtModified"/>
        <result column="role_id" property="roleId"/>
        <result column="auth_id" property="authId"/>
    </resultMap>


    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        id AS id, is_delete AS isDelete, gmt_create AS gmtCreate, gmt_modified AS gmtModified, role_id AS roleId, auth_id AS authId
    </sql>


    <select id="selectRecordRoleAuthById" resultType="RecordRoleAuth" >
        select * from lz_record_role_auth  where id=#{id} and is_delete = 0 limit 1 
    </select>


    <insert id="insertRecordRoleAuth" parameterType="RecordRoleAuth" useGeneratedKeys="true" keyProperty="id" >
        insert into lz_record_role_auth(
            <if test="roleId != null">role_id, </if>
            <if test="authId != null">auth_id, </if>
            is_delete,
            gmt_create,
            gmt_modified
        )values(
            <if test="roleId != null">#{ roleId}, </if>
            <if test="authId != null">#{ authId}, </if>
            0,
            now(),
            now()
        )
    </insert>


    <update id="updateRecordRoleAuthById" parameterType="RecordRoleAuth" >
        update
            lz_record_role_auth
        <trim prefix="set" suffixOverrides=",">
            <if test="isDelete != null">is_delete = #{isDelete},</if>
            <if test="gmtCreate != null">gmt_create = #{gmtCreate},</if>
            <if test="roleId != null">role_id = #{roleId},</if>
            <if test="authId != null">auth_id = #{authId}</if>                
        </trim>
        ,gmt_modified = now()
        where id = #{id}
    </update>


    <update id="updateCoverRecordRoleAuthById" parameterType="RecordRoleAuth" >
        update
            lz_record_role_auth    
        set     
            is_delete = #{isDelete},
            gmt_create = #{gmtCreate},
            role_id = #{roleId},
            auth_id = #{authId}                
        ,gmt_modified = now()
        where id = #{id}
    </update>


    <update id="deleteRecordRoleAuthById" parameterType="java.lang.Long">
        update lz_record_role_auth set is_delete = 1 where id=#{id} limit 1  
    </update>

    <select id="queryMenuIdList" resultType="java.lang.Long">
       select auth_id from lz_record_role_auth where role_id = #{roleId}
    </select>

    <select id="selectByRoleId" resultType="com.lz.modules.flow.entity.RecordRoleAuth">
        select * from lz_record_role_auth where role_id = #{roleId}
    </select>


    <delete id="deleteRecordRoleAuth">
        delete from lz_record_role_auth where id = #{id}
    </delete>


</mapper>

