<?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.ruoyi.project.business.mapper.TbCurrencyMapper">

    <resultMap type="TbCurrency" id="TbCurrencyResult">
        <result property="currencyId" column="currency_id"/>
        <result property="currencyName" column="currency_name"/>
        <result property="exchangeRate" column="exchange_rate"/>
        <result property="effectiveDate" column="effective_date"/>
        <result property="expirationDate" column="expiration_date"/>
        <result property="delFlag" column="del_flag"/>
        <result property="createTime" column="create_time"/>
        <result property="createBy" column="create_by"/>
        <result property="updateTime" column="update_time"/>
        <result property="updateBy" column="update_by"/>
        <result property="remark" column="remark"/>
    </resultMap>
    <resultMap type="com.ruoyi.project.business.domain.vo.currency.CurrencyRes" id="TbCurrencyResultRes">
        <result property="currencyId" column="currency_id"/>
        <result property="currencyName" column="currency_name"/>
        <result property="exchangeRate" column="exchange_rate"/>
        <result property="effectiveDate" column="effective_date"/>
        <result property="expirationDate" column="expiration_date"/>
        <result property="delFlag" column="del_flag"/>
        <result property="createTime" column="create_time"/>
        <result property="createBy" column="create_by"/>
        <result property="updateTime" column="update_time"/>
        <result property="updateBy" column="update_by"/>
        <result property="remark" column="remark"/>
        <result property="createUserNick" column="createUserNick"/>
    </resultMap>

    <sql id="selectTbCurrencyVo">
        select t1.currency_id,
               t1.currency_name,
               t1.exchange_rate,
               t1.effective_date,
               t1.expiration_date,
               t1.del_flag,
               t1.create_time,
               t1.create_by,
               t1.update_time,
               t1.update_by,
               t1.remark,
               t2.nick_name as createUserNick
        from tb_currency t1
                 left join sys_user t2 on t1.create_by = t2.user_id
    </sql>

    <select id="selectTbCurrencyList" resultMap="TbCurrencyResultRes">
        <include refid="selectTbCurrencyVo"/>
        <where>
            and t1.del_flag = 0
            <if test="currencyName != null ">and t1.currency_name like concat('%', #{currencyName}, '%')</if>
            <if test="exchangeRate != null ">and t1.exchange_rate = #{exchangeRate}</if>
            <if test="beginTime != null and endTime != null">and t1.create_time between #{beginTime} and #{endTime}</if>
            <if test="createUserNick != null and createUserNick != ''">and t2.nick_name like concat('%',
                #{createUserNick}, '%')
            </if>
            <if test="remark != null and remark != ''">and t1.remark like concat('%', #{remark}, '%')</if>
        </where>
        order by t1.currency_id desc
    </select>
    <!--${ew.customSqlSegment}-->
    <select id="selectTbCurrencyList2" resultMap="TbCurrencyResultRes">
        <include refid="selectTbCurrencyVo"/>
        ${ew.sqlSegment}
    </select>

</mapper>