<?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.copy.trade.dao.TraderDataMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.copy.trade.entity.po.TraderData">
    <result column="id" property="id" />
    <result column="created_time" property="createdTime" />
    <result column="updated_time" property="updatedTime" />
        <result column="trader_id" property="traderId" />
        <result column="day_yield_14" property="dayYield14" />
        <result column="day_yield_30" property="dayYield30" />
        <result column="win_rate_14" property="winRate14" />
        <result column="profit_amount" property="profitAmount" />
        <result column="follow_customer" property="followCustomer" />
        <result column="order_deal_14" property="orderDeal14" />
        <result column="retraction_rate_14" property="retractionRate14" />
        <result column="trading_days" property="tradingDays" />
        <result column="profit_days" property="profitDays" />
        <result column="current_month_follow" property="currentMonthFollow" />
        <result column="team_profit14" property="teamProfit14" />
    </resultMap>
    
    <resultMap id="traderDataMap" type="com.copy.trade.entity.vo.TraderDataVo">
        <result column="trader_id" property="traderId" />
        <result column="day_yield_14" property="dayYield14" />
        <result column="day_yield_30" property="dayYield30" />
        <result column="win_rate_14" property="winRate14" />
        <result column="profit_amount" property="profitAmount" />
        <result column="follow_customer" property="followCustomer" />
        <result column="order_deal_14" property="orderDeal14" />
        <result column="retraction_rate_14" property="retractionRate14" />
        <result column="trading_days" property="tradingDays" />
        <result column="profit_days" property="profitDays" />
        <result column="current_month_follow" property="currentMonthFollow" />
        <result column="team_profit14" property="teamProfit14" />
        <result column="nickname" property="nickname" />
    </resultMap>	
    
	<select id="traderDataList" resultMap="traderDataMap">
        	select t.trader_id,t.day_yield_14,t.day_yield_30,t.win_rate_14,t.profit_amount,t.follow_customer,
        	t.order_deal_14,t.retraction_rate_14,t.trading_days,t.profit_days,t.current_month_follow,t.team_profit14,c.nickname from trader_data t 
			LEFT JOIN customer c on c.id = t.trader_id
        <where>
            1 = 1 and c.trader = 20 and c.edit_data_switch =1
            <if test="traderDataQueryForm.traderId != null ">
               AND t.trader_id = #{traderDataQueryForm.traderId}
            </if>
            ORDER by t.id DESC
        </where>
    </select>

</mapper>
