Skip to content

Jessica-Wang-CL/coinDesk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

# CoinDesk 匯率轉換與幣別維護系統

本專案為使用 Spring Boot 與 Maven 建置的 Java 專案,整合 [CoinDesk API](https://api.coindesk.com/v1/bpi/currentprice.json),提供比特幣匯率查詢、資料轉換、新 API 組裝與幣別維護等功能。

---

## 🔧 技術規格

- Java 17

- Spring Boot

- Maven

- Spring Data JPA / OpenJPA

- H2 In-Memory Database

- JUnit 5 (單元測試)

- Spring Scheduler

- Mocking API 故障處理

---

## 📌 功能說明

1. **呼叫 CoinDesk API 並解析資料**

  - 支援實際 API 呼叫與 Mocking 模式(API 當機時使用固定資料)

2. **資料轉換並組成新 API**

  - 回傳資料格式包含:

  - 更新時間(yyyy/MM/dd HH:mm:ss)

  - 幣別代碼

  - 幣別中文名稱

  - 匯率(小數格式)

3. **幣別資料維護(CRUD)**

  - 幣別代碼與對應中文名稱存放於 H2 資料庫

  - 提供新增、查詢、修改與刪除功能

  - 查詢結果依幣別代碼排序

4. **排程任務**

  - 每天凌晨 12:00 自動同步匯率資料並更新本地快取

5. **單元測試**

  - 所有主要功能包含單元測試,確保系統穩定性

---

## 🛠️ 安裝與執行

### 前置需求

- JDK 17+

- Maven 3.8+

### 建置與啟動

```bash

# 下載專案

cd coinDesk

# 執行 Spring Boot 應用程式

./mvnw spring-boot:run

```

---

## 🧪 測試

```bash

# 執行單元測試

./mvnw test

```

---

## 📄 幣別資料表 SQL

以下為建立幣別與中文名稱對照資料表的 SQL:

```sql

CREATE TABLE currency (

  code VARCHAR(10) PRIMARY KEY,

  name_zh VARCHAR(50) NOT NULL

);

```

---

## 🔄 Mocking 資料格式(當 CoinDesk API 無法連線時使用)

```json

{

  "time": {

  "updated": "Aug 3, 2022 20:25:00 UTC",

  "updatedISO": "2022-08-03T20:25:00+00:00",

  "updateduk": "Aug 3, 2022 at 21:25 BST"

  },

  "bpi": {

  "USD": {

  "code": "USD",

  "rate": "23,342.0112",

  "description": "US Dollar",

  "rate_float": 23342.0112

  },

  "GBP": {

  "code": "GBP",

  "rate": "19,504.3978",

  "description": "British Pound Sterling",

  "rate_float": 19504.3978

  },

  "EUR": {

  "code": "EUR",

  "rate": "22,738.5269",

  "description": "Euro",

  "rate_float": 22738.5269

  }

  }

}

```

---

## 📬 聯絡資訊

Jessica Wang

---

## 🪪 License

本專案使用 MIT 授權條款發佈。

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors