<?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.jxy.marketall.mapper.ETHRTMapper">

	<select id="selectETHTagsByPage" resultType="com.jxy.marketall.dto.TagDto">
		SELECT
			id,
			address,
			tag
		FROM
			ethtags e
		ORDER BY
			id
	</select>

	<select id="selectArh99ByTime" parameterType="com.jxy.marketall.vo.QueryVo" resultType="com.jxy.marketall.entity.Arh99">
		SELECT
			id,
			unixdt as date,
			price,
			arh99,
			arh99x
		FROM
			arh99
		<where>
			<if test="vo.start != null and vo.start != ''">
				and unixdt &gt;= "${vo.start}"
			</if>
			<if test="vo.end != null and vo.end != ''">
				and unixdt &lt;= "${vo.end}"
			</if>
		</where>
		ORDER BY
		unixdt
	</select>

	<select id="selectArh99Day" resultType="com.jxy.marketall.entity.Arh99Day">
		SELECT
			id,
			unixdt as date,
			price,
			arh99,
			arh99x
		FROM
			arh99day
		ORDER BY
			unixdt desc limit 1440
	</select>

	<select id="selectJzr60ByTime" parameterType="com.jxy.marketall.vo.QueryVo" resultType="com.jxy.marketall.entity.Jzr60">
		SELECT
		id,
		unixdt as date,
		price,
		jzr60,jzr7,jzr30,jzr90
		FROM
		jzr60v3a
		<where>
			<if test="vo.start != null and vo.start != ''">
				and unixdt &gt;= "${vo.start}"
			</if>
			<if test="vo.end != null and vo.end != ''">
				and unixdt &lt;= "${vo.end}"
			</if>
		</where>
		ORDER BY
		unixdt
	</select>

	<select id="selectJzr60Day" resultType="com.jxy.marketall.entity.Jzr60Day">
		SELECT
			id,
			unixdt as date,
			price,
			jzr60,jzr7,jzr30,jzr90
		FROM
			jzr60v3aday
		ORDER BY
			unixdt desc limit 1440
	</select>

	<select id="selectMa730ByTime" parameterType="com.jxy.marketall.vo.QueryVo" resultType="com.jxy.marketall.dto.Ma730Dto">
		SELECT
			id,
			unixdt as `date`,
			price,
			ma730,
			ma730x5,
			ma365,
			ma200
		FROM
		ma730v2a
		<where>
			<if test="vo.start != null and vo.start != ''">
				and unixdt &gt;= "${vo.start}"
			</if>
			<if test="vo.end != null and vo.end != ''">
				and unixdt &lt;= "${vo.end}"
			</if>
		</where>
		ORDER BY
		unixdt
	</select>

	<select id="selectMa730Day" resultType="com.jxy.marketall.dto.Ma730Dto">
		SELECT
			id,
			unixdt as `date`,
			price,
			ma730,
			ma730x5,
			ma365,
			ma200
		FROM
			ma730v2aday
		ORDER BY
			unixdt desc limit 1440
	</select>

	 <insert id="batchInsertCSUSDT" parameterType="list">
		insert into csusdt(unixdt,csupply) values
		<foreach collection="list" item="item" separator=",">
			(#{item.date},#{item.value})
		</foreach>
		 ON duplicate KEY UPDATE  unixdt= VALUES(unixdt), csupply=VALUES(csupply)
	 </insert>

	<insert id="batchInsertCSUSDC" parameterType="list">
		insert into csusdc(unixdt,csupply) values
		<foreach collection="list" item="item" separator=",">
			(#{item.date},#{item.value})
		</foreach>
		ON duplicate KEY UPDATE  unixdt= VALUES(unixdt), csupply=VALUES(csupply)
	</insert>

	<insert id="batchInsertCSBUSD" parameterType="list">
		insert into csbusd(unixdt,csupply) values
		<foreach collection="list" item="item" separator=",">
			(#{item.date},#{item.value})
		</foreach>
		ON duplicate KEY UPDATE  unixdt= VALUES(unixdt), csupply=VALUES(csupply)
	</insert>

	<select id="getCSUSDTList" parameterType="com.jxy.marketall.vo.QueryVo" resultType="com.jxy.marketall.dto.CirculatingSupplyDataDto">
		SELECT distinct
		unixdt as date,
		csupply as value
		FROM
		csusdt
		<where>
			<if test="vo.start != null and vo.start != ''">
				and unixdt &gt;= #{vo.start}
			</if>
			<if test="vo.end != null and vo.end != ''">
				and unixdt &lt;= #{vo.end}
			</if>
		</where>
		ORDER BY
		unixdt
	</select>

	<select id="getCSUSDCList" parameterType="com.jxy.marketall.vo.QueryVo" resultType="com.jxy.marketall.dto.CirculatingSupplyDataDto">
		SELECT distinct
		unixdt as date,
		csupply as value
		FROM
		csusdc
		<where>
			<if test="vo.start != null and vo.start != ''">
				and unixdt &gt;= #{vo.start}
			</if>
			<if test="vo.end != null and vo.end != ''">
				and unixdt &lt;= #{vo.end}
			</if>
		</where>
		ORDER BY
		unixdt
	</select>

	<select id="getCSBUSDList" parameterType="com.jxy.marketall.vo.QueryVo" resultType="com.jxy.marketall.dto.CirculatingSupplyDataDto">
		SELECT distinct
		unixdt as date,
		csupply as value
		FROM
		csbusd
		<where>
			<if test="vo.start != null and vo.start != ''">
				and unixdt &gt;= #{vo.start}
			</if>
			<if test="vo.end != null and vo.end != ''">
				and unixdt &lt;= #{vo.end}
			</if>
		</where>
		ORDER BY
		unixdt
	</select>

	<select id="getTotalCSList" parameterType="com.jxy.marketall.vo.QueryVo" resultType="com.jxy.marketall.dto.AllTypeCSDto">
		SELECT distinct
		b.unixdt as date,
		t.csupply as usdt,
		c.csupply as usdc,
		b.csupply as busd
		FROM
		csbusd b
		left join csusdt t on b.unixdt = t.unixdt
		left join csusdc c on b.unixdt = c.unixdt
		<where>
			<if test="vo.start != null and vo.start != ''">
				and b.unixdt &gt;= #{vo.start}
			</if>
			<if test="vo.end != null and vo.end != ''">
				and b.unixdt &lt;= #{vo.end}
			</if>
		</where>
		ORDER BY
		b.unixdt
	</select>

</mapper>
