<?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="org.springblade.system.mapper.SysEncryTypeMapper">
    <insert id="add">
            INSERT INTO da_ky_sys_encrypt_set
            <trim prefix="(" suffix=")" suffixOverrides=",">
                <if test="encryptType != null and encryptType != ''">encrypt_type,</if>
                <if test="encryptName != null and encryptName != ''">encrypt_name,</if>
                <if test="encryptParams != null and encryptParams != ''">encrypt_params,</if>
                <if test="status != null">status,</if>
            </trim>
            VALUES
            <trim prefix="(" suffix=")" suffixOverrides=",">
                <if test="encryptType != null and encryptType != ''">#{encryptType},</if>
                <if test="encryptName != null and encryptName != ''">#{encryptName},</if>
                <if test="encryptParams != null and encryptParams != ''">#{encryptParams},</if>
                <if test="status != null">#{status},</if>
            </trim>
    </insert>
    <update id="edit">
        update da_ky_sys_encrypt_set
        <set>
            <if test="encryptType != null and encryptType != ''">
                encrypt_type = #{encryptType},
            </if>
            <if test="encryptName != null and encryptName != ''">
                encrypt_name = #{encryptName},
            </if>
            <if test="encryptParams != null and encryptParams != ''">
                encrypt_params = #{encryptParams},
            </if>
            <if test="status != null">
                status = #{status},
            </if>
        </set>
        WHERE id = #{id}
    </update>
    <delete id="del">
        delete from da_ky_sys_encrypt_set where id = #{id}
    </delete>

    <select id="selectSysEncryTypeList" resultType="org.springblade.common.core.domain.entity.SysEncryType">
        select id,
               encrypt_type as encryptType,
               encrypt_name as encryptName,
               encrypt_params as encryptParams,
               status
        from da_ky_sys_encrypt_set
        where 1=1
        <if test="encryptName != null and encryptName != ''">
            AND INSTR(encrypt_name, #{encryptName}) > 0
        </if>
    </select>
    <select id="selectSysEncryType" resultType="java.lang.Integer">
        SELECT COUNT(*)
        FROM da_ky_sys_encrypt_set
        WHERE encrypt_name = #{encryptName}
        <if test="id != null">
            and id != #{id}
        </if>
    </select>



    <insert id="addFile">
        INSERT INTO da_ky_sys_encrypt_file_set
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="encryptType != null and encryptType != ''">encrypt_type,</if>
            <if test="encryptName != null and encryptName != ''">encrypt_name,</if>
            <if test="encryptParams != null and encryptParams != ''">encrypt_params,</if>
            <if test="status != null">status,</if>
        </trim>
        VALUES
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="encryptType != null and encryptType != ''">#{encryptType},</if>
            <if test="encryptName != null and encryptName != ''">#{encryptName},</if>
            <if test="encryptParams != null and encryptParams != ''">#{encryptParams},</if>
            <if test="status != null">#{status},</if>
        </trim>
    </insert>
    <update id="editFile">
        update da_ky_sys_encrypt_file_set
        <set>
            <if test="encryptType != null and encryptType != ''">
                encrypt_type = #{encryptType},
            </if>
            <if test="encryptName != null and encryptName != ''">
                encrypt_name = #{encryptName},
            </if>
            <if test="encryptParams != null and encryptParams != ''">
                encrypt_params = #{encryptParams},
            </if>
            <if test="status != null">
                status = #{status},
            </if>
        </set>
        WHERE id = #{id}
    </update>
    <delete id="delFile">
        delete from da_ky_sys_encrypt_file_set where id = #{id}
    </delete>

    <select id="selectSysEncryTypeListFile" resultType="org.springblade.common.core.domain.entity.SysEncryType">
        select id,
        encrypt_type as encryptType,
        encrypt_name as encryptName,
        encrypt_params as encryptParams,
        status
        from da_ky_sys_encrypt_file_set
        where 1=1
        <if test="encryptName != null and encryptName != ''">
            AND INSTR(encrypt_name, #{encryptName}) > 0
        </if>
    </select>
    <select id="selectSysEncryTypeFile" resultType="java.lang.Integer">
        SELECT COUNT(*)
        FROM da_ky_sys_encrypt_file_set
        WHERE encrypt_name = #{encryptName}
        <if test="id != null">
            and id != #{id}
        </if>
    </select>
</mapper>
