package com.contract.controller;

import com.contract.entity.CoinExt;
import com.contract.entity.resp.MessageResult;
import com.contract.service.CoinExtService;
import com.contract.util.RequestUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping("/coin-ext")
public class CoinExtController {

    @Autowired
    private CoinExtService coinExtService;

    @GetMapping("/detail")
    public MessageResult detail(@RequestParam String symbol, HttpServletRequest request) {
        String lang = RequestUtils.getLangFromHeader(request);
        CoinExt coinExt = coinExtService.getBySymbol(symbol);
        return MessageResult.successLang(lang, coinExt);
    }
}
