<?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.CardGlobalCurrenciesFieldMapper">

    <delete id="deleteAll">
        delete from ucard_global_currencies_field
    </delete>
    <select id="findAllByCurrencies" resultType="com.crm.rely.backend.core.dto.wasabi.WasabiFieldDto" parameterType="com.crm.rely.backend.core.entity.ucard.GlobalCurrenciesFieldListEntity">
        select
        cf.`id`,
        cf.field_name,
        cf.field_title,
        cf.field_label,
        cf.field_type,
        cf.field_user_type,
        cf.field_description,
        cf.required,
        cf.fixed_value,
        cf.`min`,
        cf.`max`,
        cf.`regex`,
        cf.`sorting`
        from ucard_global_currencies_field cf
        left join ucard_global_currencies c on cf.payout_currency_id = c.id
        <where>
            <if test="payoutCurrency != null and payoutCurrency != ''">
                and c.payout_currency = #{payoutCurrency}
            </if>
            <if test="transferTypeId != null and transferTypeId != ''">
                and c.transfer_type_id = #{transferTypeId}
            </if>
            <if test="payoutMethodId != null and payoutMethodId != ''">
                and c.payout_method_id = #{payoutMethodId}
            </if>
            <if test="fieldType != null and fieldType != ''">
                and cf.field_type = #{fieldType}
            </if>
        </where>
    </select>

</mapper> 