package com.jwipc.sys.controller.pc;

import com.jwipc.page.PageView;
import com.jwipc.query.BasePageQuery;
import com.jwipc.sys.logic.ExchangeRateLogic;
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.math.BigDecimal;
import java.util.Date;

import static com.jwipc.sys.constant.ModuleConst.MODULE_ROOT;

@RequestMapping(MODULE_ROOT + "/exchangeRate/rest")
@RequiredArgsConstructor
@RestController
public class ExchangeRateRestController {
    private final ExchangeRateLogic exchangeRateLogic;

    @GetMapping("list")
    public PageView list(BasePageQuery pageQuery) {
        return exchangeRateLogic.list(pageQuery);
    }

    /**
     * 根据币种获取当月汇率
     * @param currencyCode 币种
     * @return 当月汇率
     */
    @GetMapping("getExchangeRate")
    public ResponseEntity<String> getExchangeRate(String currencyCode){
        return ResponseEntity.ok(exchangeRateLogic.getExchangeRate(currencyCode));

    }

    @GetMapping("sync")
    public ResponseEntity sync(BasePageQuery pageQuery) {
        return ResponseEntity.ok().build();
    }
}
