<?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.xhpc.general.mapper.XhpcEtTokenMapper">


    <resultMap id="BaseResultToken" type="com.xhpc.general.domain.EtTokenEntity">
        <result property="id" column="id"/>
        <result property="operatorId" column="operator_id"  jdbcType="VARCHAR" />
        <result property="operatorId3irdpty" column="operator_id3irdpty" jdbcType="VARCHAR"/>
        <result property="secretTokenType" column="secret_token_type" jdbcType="VARCHAR"/>
        <result property="token" column="token"/>
        <result property="tokenExpiry" column="token_expiry"/>
        <result property="dataSecret" column="data_secret" jdbcType="VARCHAR"/>
        <result property="dataSecret" column="data_secretiv" jdbcType="VARCHAR"/>
        <result property="operatorSecret" column="operator_secret" jdbcType="VARCHAR"/>
        <result property="sigSecret" column="sig_secret" jdbcType="VARCHAR"/>
        <result property="encrypt" column="encrypt"/>
        <result property="urlPrefix" column="url_prefix" jdbcType="VARCHAR"/>
    </resultMap>


    <select id="selectBy" resultMap="BaseResultToken">

        select * from et_auth_sec_token
        <where>
            <if test=" operatorId!= null and operatorId != ''">
                AND operator_id like concat('%',#{operatorId},'%')
            </if>
            <if test="operatorId3irdpty != null and operatorId3irdpty != ''">
                AND operator_id3irdpty like concat('%',#{operatorId3irdpty},'%')
            </if>
        </where>
    </select>

    <delete id="deleteBy">
        delete from et_auth_sec_token
        where id = #{id}
    </delete>

    <select id="checkExistsBy" resultType="java.lang.Integer">

        select count(id) from et_auth_sec_token
        where operator_id = #{operatorId}
        and operator_id3irdpty = #{operatorId3irdpty}
        and secret_token_type = #{secretTokenType}
    </select>

    <insert id="insertBy">

        insert into et_auth_sec_token
        (operator_id,operator_id3irdpty,secret_token_type,data_secret,data_secretiv,operator_secret,sig_secret,encrypt,url_prefix)
        values (#{operatorId},#{operatorId3irdpty},#{secretTokenType},
        #{dataSecret},#{dataSecretiv},#{operatorSecret},#{sigSecret},#{encrypt},#{urlPrefix})
    </insert>
</mapper>