<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
        "https://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="link.at17.mid.tushare.dao.ThsListDao">

    <insert id="insertOrUpdateList" parameterType="list">
        INSERT INTO stock_ths_list
            (ts_code, list_date, count, exchange, name, type)
        VALUES
        <foreach collection="list" item="item" index="index" separator=",">
            (#{item.ts_code}, 
            TO_DATE(#{item.list_date}, 'YYYYMMDD'),
            #{item.count},
			#{item.exchange},
			#{item.name},
			#{item.type}
             )
        </foreach>
        ON CONFLICT (ts_code) DO UPDATE SET
			ts_code = EXCLUDED.ts_code,
			list_date = EXCLUDED.list_date,
			count = EXCLUDED.count,
			exchange = EXCLUDED.exchange,
			name = EXCLUDED.name,
			type = EXCLUDED.type
    </insert>
</mapper>
