<?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.crm.ucard.dao.mapper.CardBlockchainConfigMapper">
    <insert id="insert">
        INSERT INTO `ucard_blockchain_config`
        (`alias`, `blockchain`,`whitelist`,`blacklist`, `enable_status`,`add_time`, `add_user`, `add_ip`, `modify_time`, `modify_user`, `modify_ip`, `note`)
        VALUES
            (#{alias}, #{blockchain},#{whitelist},#{blacklist},#{enableStatus},#{addTime}, #{addUser}, #{addIp}, #{modifyTime}, #{modifyUser}, #{modifyIp}, #{note})
            ON DUPLICATE KEY UPDATE
             `alias` = VALUES(`alias`),
             `whitelist` = VALUES(`whitelist`),
             `blacklist` = VALUES(`blacklist`),
             `enable_status` = VALUES(`enable_status`)
    </insert>

    <select id="countList" resultType="integer"
            parameterType="com.crm.rely.backend.core.entity.ucard.CardBlockchainConfigPageEntity">
        SELECT COUNT(*)
        FROM ucard_blockchain_config
        <where>
            <if test="alias != null and alias != ''">
                and `alias` = #{alias}
            </if>
            <if test="blockchain != null and blockchain != ''">
                and `blockchain` = #{blockchain}
            </if>
            <if test="enableStatus != null">
                and enable_status = #{enableStatus}
            </if>
        </where>
    </select>

    <select id="pageList" resultType="com.crm.rely.backend.core.dto.ucard.CardBlockchainConfigDto"
            parameterType="com.crm.rely.backend.core.entity.ucard.CardBlockchainConfigPageEntity">
        SELECT
        *
        FROM ucard_blockchain_config
        <where>
            <if test="alias != null and alias != ''">
                and `alias` = #{alias}
            </if>
            <if test="blockchain != null and blockchain != ''">
                and `blockchain` = #{blockchain}
            </if>
            <if test="enableStatus != null">
                and enable_status = #{enableStatus}
            </if>
        </where>
        ORDER BY id DESC
        <if test="page != null">
            limit #{page.offset},#{page.row}
        </if>
    </select>

</mapper>