CreditExchangeRateMapper.xml 4.14 KB
<?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.lhcredit.project.business.creditExchangeRate.mapper.CreditExchangeRateMapper">
    
    <resultMap type="com.lhcredit.project.business.creditExchangeRate.domain.CreditExchangeRate" id="CreditExchangeRateResult">
        <result property="id"    column="id"    />
        <result property="currency"    column="currency"    />
        <result property="ratio"    column="ratio"    />
        <result property="status"    column="status"    />
        <result property="crateTime"    column="crateTime"    />
        <result property="updateTime"    column="updateTime"    />
    </resultMap>
	
	<sql id="selectCreditExchangeRateVo">
        select id, currency, ratio, status, crateTime, updateTime from credit_exchange_rate
    </sql>
	
    <select id="selectCreditExchangeRateList" parameterType="com.lhcredit.project.business.creditExchangeRate.domain.CreditExchangeRate" resultMap="CreditExchangeRateResult">
        <include refid="selectCreditExchangeRateVo"/>
        <where>  
            <if test="id != null "> and id = #{id}</if>
            <if test="currency != null  and currency != '' "> and currency = #{currency}</if>
            <if test="ratio != null "> and ratio = #{ratio}</if>
            <if test="status != null  and status != '' "> and status = #{status}</if>
            <if test="crateTime != null "> and crateTime = #{crateTime}</if>
            <if test="updateTime != null "> and updateTime = #{updateTime}</if>
        </where>
    </select>
    
    <select id="selectCreditExchangeRateByStatus" parameterType="String" resultMap="CreditExchangeRateResult">
        <include refid="selectCreditExchangeRateVo"/>
        where status = #{status} and  currency = #{currency}
    </select>

    <select id="selectCreditExchangeRateById" parameterType="Integer" resultMap="CreditExchangeRateResult">
        <include refid="selectCreditExchangeRateVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertCreditExchangeRate" parameterType="com.lhcredit.project.business.creditExchangeRate.domain.CreditExchangeRate" useGeneratedKeys="true" keyProperty="id">
        insert into credit_exchange_rate
		<trim prefix="(" suffix=")" suffixOverrides=",">
			<if test="currency != null  and currency != ''  ">currency,</if>
			<if test="ratio != null  ">ratio,</if>
			<if test="status != null  and status != ''  ">status,</if>
			<if test="crateTime != null  ">crateTime,</if>
			<if test="updateTime != null  ">updateTime,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
			<if test="currency != null  and currency != ''  ">#{currency},</if>
			<if test="ratio != null  ">#{ratio},</if>
			<if test="status != null  and status != ''  ">#{status},</if>
			<if test="crateTime != null  ">#{crateTime},</if>
			<if test="updateTime != null  ">#{updateTime},</if>
         </trim>
    </insert>
	 
    <update id="updateCreditExchangeRate" parameterType="com.lhcredit.project.business.creditExchangeRate.domain.CreditExchangeRate">
        update credit_exchange_rate
        <trim prefix="SET" suffixOverrides=",">
            <if test="currency != null  and currency != ''  ">currency = #{currency},</if>
        <if test="ratio != null  ">ratio = #{ratio},</if>
            <if test="status != null  and status != ''  ">status = #{status},</if>
            <if test="crateTime != null  ">crateTime = #{crateTime},</if>
            <if test="updateTime != null  ">updateTime = #{updateTime},</if>
        </trim>
        where id = #{id}
    </update>

    <update id="updateByCurrency">
        update credit_exchange_rate set status='1' where currency = #{currency}
    </update>

	<delete id="deleteCreditExchangeRateById" parameterType="Integer">
        delete from credit_exchange_rate where id = #{id}
    </delete>
	
    <delete id="deleteCreditExchangeRateByIds" parameterType="String">
        delete from credit_exchange_rate where id in 
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
    
</mapper>