package com.bizzan.bitrade.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.bizzan.bitrade.util.MessageResult;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

import java.math.BigDecimal;

@Api(value = "ExchangeRateController" , tags = "汇率接口")
@RestController
@RequestMapping("/exchange-rate")
public class ExchangeRateController {

	@ApiOperation(value="获取美元和币种汇率", notes="获取美元和币种汇率")
	@RequestMapping("usd/{coin}")
    public MessageResult getUsdExchangeRate(@PathVariable String coin){
        MessageResult mr = new MessageResult(0,"success");
        mr.setData(1);
        return mr;
    }
    
	@ApiOperation(value="获取usdt和人民币汇率", notes="获取usdt和人民币汇率")
	@RequestMapping("usdtcny")
    public MessageResult getUsdtCnyRate(){
        MessageResult mr = new MessageResult(0,"success");
        mr.setData(6.42);
        return mr;
    }
    
	@ApiOperation(value="获取usdt和美元汇率", notes="获取usdt和美元汇率")
	@RequestMapping("usdtusd")
    public MessageResult getUsdtUsdRate(){
        MessageResult mr = new MessageResult(0,"success");
        mr.setData(1);
        return mr;
    }

	@ApiOperation(value="获取usd和货币汇率", notes="获取usd和货币汇率")
	@RequestMapping("usd-{unit}")
    public MessageResult getUsdCnyRate(@PathVariable String unit){
        MessageResult mr = new MessageResult(0,"success");
        if("CNY".equalsIgnoreCase(unit)) {
            mr.setData(6.42);
        }
        else if("JPY".equalsIgnoreCase(unit)) {
            mr.setData(1);
        }
        else if("HKD".equalsIgnoreCase(unit)) {
            mr.setData(1);
        }
        else {
            mr.setData(BigDecimal.ZERO);
        }
        return mr;
    }
}
