Skip to content

Commit 47c3d51

Browse files
committed
add answer
1 parent 82160f9 commit 47c3d51

File tree

3 files changed

+51
-4
lines changed

3 files changed

+51
-4
lines changed

Diff for: 004-js-workshop/004005-view.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
```
4343
async mounted () {
4444

45-
let response = await fetch("http://localhost:3000/api/users/spooky/tasks");
45+
let response = await fetch("http://localhost:3000/api/users/hellojs/tasks");
4646
let result = await response.json();
4747

4848
result.tasks.forEach((task) => {
@@ -96,7 +96,7 @@
9696
completed: false
9797
}
9898

99-
let response = await fetch('http://localhost:3000/api/users/spooky/tasks/create', {
99+
let response = await fetch('http://localhost:3000/api/users/hellojs/tasks/create', {
100100
method: 'post',
101101
headers: {"Content-Type": "application/json"},
102102
body: JSON.stringify(data)

Diff for: 004-js-workshop/readme.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## Story
44

5-
為了提供使用者可以記錄各自的待做項目,需要提供後台可以新增使用者,必且讓使用者可以自行新增待做事項
5+
為了提供使用者可以記錄各自的待做項目,需要提供後台可以新增使用者,並且讓使用者可以自行新增待做事項
66

77
## 測試方式
88

Diff for: 005-js-practice/005001-task-completed.md renamed to 005-js-practice/005001-task-completed.md

+48-1
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,51 @@
66

77
## 步驟
88

9+
### 後端調整
10+
911
* model Task 新增 completed 欄位紀錄 Task 是否被完成
12+
13+
* migration 程序新增 model Task 欄位 completed
14+
15+
新增 migration 檔案指令
16+
17+
`node_modules/.bin/sequelize migration:create --name task-add-completed`
18+
19+
20+
```
21+
module.exports = {
22+
up: (queryInterface, Sequelize) => {
23+
queryInterface.addColumn(
24+
'Todo',
25+
'completed',
26+
Sequelize.BOOLEAN
27+
);
28+
},
29+
30+
down: (queryInterface, Sequelize) => {
31+
queryInterface.removeColumn(
32+
'Todo',
33+
'completed'
34+
);
35+
}
36+
};
37+
38+
```
39+
40+
執行下列指令更新 database
41+
42+
`node_modules/.bin/sequelize db:migrate`
43+
44+
1045
* 撰寫 test case 確認更新 model Task completed 成功
1146
* 新增 test 定義 task 更新 completed 之 API spec
1247
* 實作 Task completed 更新 API 並且透過 test 驗證 API
1348
* 調整後端頁面顯示 completed 的值
49+
50+
### 前端調整
51+
1452
* 調整前端針對 completed 的變動,呼叫完成的 API
15-
* 確認在前端調整的 completed 之變動,在後端看到的是相同的變動
53+
1654

1755

1856
## 測試方式
@@ -22,3 +60,12 @@
2260
3. 假設新增 task 成功,進入後台,可以看到該使用者的特定 Task 狀態為已完成
2361
4. 若再次在前台變更完成狀態為未完成,則可以在後台看到顯示該 Task 顯示為未完成
2462

63+
## 解答
64+
65+
### 後端
66+
67+
https://github.com/agileworks-tw/express-example/pull/1
68+
69+
### 前端
70+
71+
https://github.com/agileworks-tw/express-example-vue/pull/1

0 commit comments

Comments
 (0)