wad-lab 1.1.6 → 1.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/templates/fullstack-springboot-vue/backend/src/main/java/com/example/company/controller/CompanyController.java +88 -74
- package/templates/fullstack-springboot-vue/backend/src/main/java/com/example/company/model/Employee.java +73 -73
- package/templates/fullstack-springboot-vue/backend/src/main/java/com/example/company/service/CompanyService.java +90 -60
- package/templates/fullstack-springboot-vue/frontend/vue-axios-basic/src/App.vue +429 -405
- package/templates/fullstack-springboot-vue/frontend/vue-axios-interceptor/src/App.vue +177 -159
- package/templates/fullstack-springboot-vue/frontend/vue-axios-pinia/src/App.vue +441 -427
- package/templates/fullstack-springboot-vue/frontend/vue-axios-pinia/src/stores/companyStore.js +126 -96
- package/templates/fullstack-springboot-vue/frontend/vue-axios-pinia-props/src/App.vue +84 -69
- package/templates/fullstack-springboot-vue/frontend/vue-axios-pinia-props/src/components/DepartmentSection.vue +164 -152
- package/templates/fullstack-springboot-vue/frontend/vue-axios-pinia-props/src/components/EmployeeSection.vue +193 -181
- package/templates/fullstack-springboot-vue/frontend/vue-axios-pinia-props/src/stores/companyStore.js +126 -35
- package/templates/fullstack-springboot-vue/frontend/vue-axios-props-emits/src/App.vue +191 -167
- package/templates/fullstack-springboot-vue/frontend/vue-axios-props-emits/src/components/DepartmentForm.vue +98 -98
- package/templates/fullstack-springboot-vue/frontend/vue-axios-props-emits/src/components/DepartmentList.vue +92 -91
- package/templates/fullstack-springboot-vue/frontend/vue-axios-props-emits/src/components/EmployeeForm.vue +128 -128
- package/templates/fullstack-springboot-vue/frontend/vue-axios-props-emits/src/components/EmployeeList.vue +95 -94
- package/templates/fullstack-springboot-vue/frontend/vue-axios-router/src/App.vue +90 -90
- package/templates/fullstack-springboot-vue/frontend/vue-axios-router/src/views/AddEmployeeView.vue +247 -247
- package/templates/fullstack-springboot-vue/frontend/vue-axios-router/src/views/DepartmentView.vue +296 -273
- package/templates/fullstack-springboot-vue/frontend/vue-axios-router/src/views/EmployeeView.vue +219 -196
- package/templates/fullstack-springboot-vue/frontend/vue-axios-router/src/views/HomeDashboardView.vue +263 -263
- package/templates/fullstack-springboot-vue/frontend/vue-axios-router-children/src/views/DepartmentListView.vue +250 -231
- package/templates/fullstack-springboot-vue/frontend/vue-axios-router-children/src/views/EmployeeDetailView.vue +181 -159
- package/templates/fullstack-springboot-vue/frontend/vue-axios-router-children/src/views/EmployeeListView.vue +315 -295
- package/templates/fullstack-springboot-vue/frontend/vue-axios-router-pinia/src/stores/companyStore.js +137 -70
- package/templates/fullstack-springboot-vue/frontend/vue-axios-router-pinia/src/views/DepartmentView.vue +229 -209
- package/templates/fullstack-springboot-vue/frontend/vue-axios-router-pinia/src/views/EmployeeView.vue +257 -237
- package/templates/fullstack-springboot-vue/frontend/vue-axios-router-pinia-props/src/components/EntityTable.vue +106 -92
- package/templates/fullstack-springboot-vue/frontend/vue-axios-router-pinia-props/src/stores/companyStore.js +139 -84
- package/templates/fullstack-springboot-vue/frontend/vue-axios-router-pinia-props/src/views/ManageDepartmentsView.vue +73 -64
- package/templates/fullstack-springboot-vue/frontend/vue-axios-router-pinia-props/src/views/ManageEmployeesView.vue +76 -67
- package/templates/fullstack-springboot-vue/frontend/vue-axios-router-props/src/App.vue +59 -59
- package/templates/fullstack-springboot-vue/frontend/vue-axios-router-props/src/components/DataCard.vue +72 -53
- package/templates/fullstack-springboot-vue/frontend/vue-axios-router-props/src/views/DepartmentPage.vue +89 -77
- package/templates/fullstack-springboot-vue/frontend/vue-axios-router-props/src/views/EmployeePage.vue +128 -116
- package/templates/springboot-2model-1controller-api/src/main/java/com/example/company/controller/CompanyController.java +88 -74
- package/templates/springboot-2model-1controller-api/src/main/java/com/example/company/model/Employee.java +73 -73
- package/templates/springboot-2model-1controller-api/src/main/java/com/example/company/service/CompanyService.java +90 -60
- package/templates/springboot-course-registration/src/main/java/com/example/coursereg/controller/CourseController.java +46 -42
- package/templates/springboot-course-registration/src/main/java/com/example/coursereg/service/CourseService.java +70 -60
- package/templates/springboot-hospital-api/src/main/java/com/example/hospital/controller/HospitalController.java +54 -50
- package/templates/springboot-hospital-api/src/main/java/com/example/hospital/service/HospitalService.java +65 -54
- package/templates/springboot-library-api/src/main/java/com/example/library/controller/LibraryController.java +57 -51
- package/templates/springboot-library-api/src/main/java/com/example/library/service/LibraryService.java +70 -60
- package/templates/springboot-mockmvc/src/main/java/com/example/mockmvc/controller/ItemController.java +45 -41
- package/templates/springboot-mockmvc/src/main/java/com/example/mockmvc/service/ItemService.java +48 -38
- package/templates/springboot-mongo-aggregation/src/main/java/com/example/aggregation/controller/ItemController.java +45 -41
- package/templates/springboot-mongo-aggregation/src/main/java/com/example/aggregation/service/ItemService.java +48 -38
- package/templates/springboot-mongo-aggregation-mockmvc/src/main/java/com/example/aggmockmvc/controller/ItemController.java +45 -41
- package/templates/springboot-mongo-aggregation-mockmvc/src/main/java/com/example/aggmockmvc/service/ItemService.java +48 -38
- package/templates/springboot-mongo-crud/src/main/java/com/example/crud/controller/ItemController.java +45 -41
- package/templates/springboot-mongo-crud/src/main/java/com/example/crud/service/ItemService.java +48 -38
- package/templates/vue-axios/src/App.vue +264 -243
- package/templates/vue-axios/src/services/ItemService.js +27 -21
- package/templates/vue-axios-basic/src/App.vue +24 -0
- package/templates/vue-axios-interceptor/src/App.vue +177 -159
- package/templates/vue-axios-pinia/src/App.vue +14 -0
- package/templates/vue-axios-pinia/src/stores/companyStore.js +126 -96
- package/templates/vue-axios-pinia-props/src/App.vue +84 -69
- package/templates/vue-axios-pinia-props/src/components/DepartmentSection.vue +164 -152
- package/templates/vue-axios-pinia-props/src/components/EmployeeSection.vue +193 -181
- package/templates/vue-axios-pinia-props/src/stores/companyStore.js +126 -35
- package/templates/vue-axios-props-emits/src/App.vue +24 -0
- package/templates/vue-axios-props-emits/src/components/DepartmentList.vue +2 -1
- package/templates/vue-axios-props-emits/src/components/EmployeeList.vue +2 -1
- package/templates/vue-axios-router/src/views/DepartmentView.vue +23 -0
- package/templates/vue-axios-router/src/views/EmployeeView.vue +23 -0
- package/templates/vue-axios-router-children/src/views/DepartmentListView.vue +250 -231
- package/templates/vue-axios-router-children/src/views/EmployeeDetailView.vue +181 -159
- package/templates/vue-axios-router-children/src/views/EmployeeListView.vue +315 -295
- package/templates/vue-axios-router-pinia/src/stores/companyStore.js +137 -70
- package/templates/vue-axios-router-pinia/src/views/DepartmentView.vue +229 -209
- package/templates/vue-axios-router-pinia/src/views/EmployeeView.vue +257 -237
- package/templates/vue-axios-router-pinia-props/src/components/EntityTable.vue +106 -92
- package/templates/vue-axios-router-pinia-props/src/stores/companyStore.js +139 -84
- package/templates/vue-axios-router-pinia-props/src/views/ManageDepartmentsView.vue +73 -64
- package/templates/vue-axios-router-pinia-props/src/views/ManageEmployeesView.vue +76 -67
- package/templates/vue-axios-router-props/src/components/DataCard.vue +72 -53
- package/templates/vue-axios-router-props/src/views/DepartmentPage.vue +89 -77
- package/templates/vue-axios-router-props/src/views/EmployeePage.vue +128 -116
- package/templates/vue-fetch/src/App.vue +285 -259
- package/templates/vue-router-pinia-springboot/backend/src/main/java/com/example/crud/controller/ItemController.java +45 -41
- package/templates/vue-router-pinia-springboot/backend/src/main/java/com/example/crud/service/ItemService.java +45 -35
- package/templates/vue-router-pinia-springboot/frontend/src/services/ItemService.js +24 -21
- package/templates/vue-router-pinia-springboot/frontend/src/stores/itemStore.js +42 -37
- package/templates/vue-router-pinia-springboot/frontend/src/views/ListView.vue +76 -67
- package/templates/vue-springboot-mongo-aggregation/backend/src/main/java/com/example/aggregation/controller/ItemController.java +45 -41
- package/templates/vue-springboot-mongo-aggregation/backend/src/main/java/com/example/aggregation/service/ItemService.java +45 -35
- package/templates/vue-springboot-mongo-crud/backend/src/main/java/com/example/crud/controller/ItemController.java +45 -41
- package/templates/vue-springboot-mongo-crud/backend/src/main/java/com/example/crud/service/ItemService.java +45 -35
- package/templates/vue-springboot-mongo-crud/frontend/src/App.vue +158 -149
- package/templates/vue-springboot-mongo-crud/frontend/src/services/ItemService.js +24 -21
|
@@ -1,35 +1,45 @@
|
|
|
1
|
-
package com.example.crud.service;
|
|
2
|
-
|
|
3
|
-
import com.example.crud.model.Item;
|
|
4
|
-
import com.example.crud.repository.ItemRepository;
|
|
5
|
-
import org.springframework.beans.factory.annotation.Autowired;
|
|
6
|
-
import org.springframework.stereotype.Service;
|
|
7
|
-
|
|
8
|
-
import java.util.List;
|
|
9
|
-
|
|
10
|
-
@Service
|
|
11
|
-
public class ItemService {
|
|
12
|
-
@Autowired
|
|
13
|
-
private ItemRepository repo;
|
|
14
|
-
|
|
15
|
-
public List<Item> getAll() {
|
|
16
|
-
return repo.findAll();
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
public Item getById(String id) {
|
|
20
|
-
return repo.findById(id).orElse(null);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
public Item create(Item item) {
|
|
24
|
-
return repo.save(item);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
public Item update(String id, Item item) {
|
|
28
|
-
item.setId(id);
|
|
29
|
-
return repo.save(item);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
public void delete(String id) {
|
|
33
|
-
repo.deleteById(id);
|
|
34
|
-
}
|
|
35
|
-
|
|
1
|
+
package com.example.crud.service;
|
|
2
|
+
|
|
3
|
+
import com.example.crud.model.Item;
|
|
4
|
+
import com.example.crud.repository.ItemRepository;
|
|
5
|
+
import org.springframework.beans.factory.annotation.Autowired;
|
|
6
|
+
import org.springframework.stereotype.Service;
|
|
7
|
+
|
|
8
|
+
import java.util.List;
|
|
9
|
+
|
|
10
|
+
@Service
|
|
11
|
+
public class ItemService {
|
|
12
|
+
@Autowired
|
|
13
|
+
private ItemRepository repo;
|
|
14
|
+
|
|
15
|
+
public List<Item> getAll() {
|
|
16
|
+
return repo.findAll();
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
public Item getById(String id) {
|
|
20
|
+
return repo.findById(id).orElse(null);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
public Item create(Item item) {
|
|
24
|
+
return repo.save(item);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
public Item update(String id, Item item) {
|
|
28
|
+
item.setId(id);
|
|
29
|
+
return repo.save(item);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
public void delete(String id) {
|
|
33
|
+
repo.deleteById(id);
|
|
34
|
+
}
|
|
35
|
+
public Item patch(String id, Item partial) {
|
|
36
|
+
Item existing = getOne(id);
|
|
37
|
+
if (existing != null) {
|
|
38
|
+
if (partial.getName() != null) existing.setName(partial.getName());
|
|
39
|
+
if (partial.getDescription() != null) existing.setDescription(partial.getDescription());
|
|
40
|
+
if (partial.getPrice() != 0) existing.setPrice(partial.getPrice());
|
|
41
|
+
return repo.save(existing);
|
|
42
|
+
}
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -1,149 +1,158 @@
|
|
|
1
|
-
<script setup>
|
|
2
|
-
import { ref, onMounted } from 'vue';
|
|
3
|
-
import ItemService from './services/ItemService';
|
|
4
|
-
|
|
5
|
-
const items = ref([]);
|
|
6
|
-
const isEditing = ref(false);
|
|
7
|
-
const form = ref({
|
|
8
|
-
id: '',
|
|
9
|
-
name: '',
|
|
10
|
-
description: '',
|
|
11
|
-
price: 0
|
|
12
|
-
});
|
|
13
|
-
const searchId = ref('');
|
|
14
|
-
const selectedItem = ref(null);
|
|
15
|
-
|
|
16
|
-
const loadItems = async () => {
|
|
17
|
-
const res = await ItemService.getAll();
|
|
18
|
-
items.value = res.data;
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
const saveItem = async () => {
|
|
22
|
-
if (isEditing.value) {
|
|
23
|
-
await ItemService.update(form.value.id, {
|
|
24
|
-
id: form.value.id,
|
|
25
|
-
name: form.value.name,
|
|
26
|
-
description: form.value.description,
|
|
27
|
-
price: form.value.price
|
|
28
|
-
});
|
|
29
|
-
} else {
|
|
30
|
-
await ItemService.create({
|
|
31
|
-
id: form.value.id,
|
|
32
|
-
name: form.value.name,
|
|
33
|
-
description: form.value.description,
|
|
34
|
-
price: form.value.price
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
resetForm();
|
|
38
|
-
loadItems();
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
const editItem = (item) => {
|
|
42
|
-
isEditing.value = true;
|
|
43
|
-
form.value = { ...item };
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
const resetForm = () => {
|
|
47
|
-
isEditing.value = false;
|
|
48
|
-
form.value = { id: '', name: '', description: '', price: 0 };
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
const deleteItem = async (id) => {
|
|
52
|
-
await ItemService.delete(id);
|
|
53
|
-
if (selectedItem.value && selectedItem.value.id === id) {
|
|
54
|
-
selectedItem.value = null;
|
|
55
|
-
}
|
|
56
|
-
loadItems();
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
const
|
|
60
|
-
const
|
|
61
|
-
if (
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
<
|
|
83
|
-
|
|
84
|
-
<
|
|
85
|
-
<br>
|
|
86
|
-
|
|
87
|
-
<
|
|
88
|
-
|
|
89
|
-
<
|
|
90
|
-
<br>
|
|
91
|
-
|
|
92
|
-
<
|
|
93
|
-
|
|
94
|
-
<
|
|
95
|
-
<
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
<br>
|
|
114
|
-
|
|
115
|
-
<br>
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
<
|
|
138
|
-
<
|
|
139
|
-
<
|
|
140
|
-
<
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
</td>
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
1
|
+
<script setup>
|
|
2
|
+
import { ref, onMounted } from 'vue';
|
|
3
|
+
import ItemService from './services/ItemService';
|
|
4
|
+
|
|
5
|
+
const items = ref([]);
|
|
6
|
+
const isEditing = ref(false);
|
|
7
|
+
const form = ref({
|
|
8
|
+
id: '',
|
|
9
|
+
name: '',
|
|
10
|
+
description: '',
|
|
11
|
+
price: 0
|
|
12
|
+
});
|
|
13
|
+
const searchId = ref('');
|
|
14
|
+
const selectedItem = ref(null);
|
|
15
|
+
|
|
16
|
+
const loadItems = async () => {
|
|
17
|
+
const res = await ItemService.getAll();
|
|
18
|
+
items.value = res.data;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const saveItem = async () => {
|
|
22
|
+
if (isEditing.value) {
|
|
23
|
+
await ItemService.update(form.value.id, {
|
|
24
|
+
id: form.value.id,
|
|
25
|
+
name: form.value.name,
|
|
26
|
+
description: form.value.description,
|
|
27
|
+
price: form.value.price
|
|
28
|
+
});
|
|
29
|
+
} else {
|
|
30
|
+
await ItemService.create({
|
|
31
|
+
id: form.value.id,
|
|
32
|
+
name: form.value.name,
|
|
33
|
+
description: form.value.description,
|
|
34
|
+
price: form.value.price
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
resetForm();
|
|
38
|
+
loadItems();
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
const editItem = (item) => {
|
|
42
|
+
isEditing.value = true;
|
|
43
|
+
form.value = { ...item };
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
const resetForm = () => {
|
|
47
|
+
isEditing.value = false;
|
|
48
|
+
form.value = { id: '', name: '', description: '', price: 0 };
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
const deleteItem = async (id) => {
|
|
52
|
+
await ItemService.delete(id);
|
|
53
|
+
if (selectedItem.value && selectedItem.value.id === id) {
|
|
54
|
+
selectedItem.value = null;
|
|
55
|
+
}
|
|
56
|
+
loadItems();
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
const patchItem = async (item) => {
|
|
60
|
+
const price = prompt('Enter new price:');
|
|
61
|
+
if (price !== null && price !== '') {
|
|
62
|
+
await ItemService.patch(item.id, { price: Number(price) });
|
|
63
|
+
loadItems();
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
const fetchSingleItem = async (id) => {
|
|
68
|
+
const targetId = id || searchId.value;
|
|
69
|
+
if (!targetId) return;
|
|
70
|
+
const res = await ItemService.getById(targetId);
|
|
71
|
+
selectedItem.value = res.data;
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
onMounted(loadItems);
|
|
75
|
+
</script>
|
|
76
|
+
|
|
77
|
+
<template>
|
|
78
|
+
<h2>Item Management</h2>
|
|
79
|
+
|
|
80
|
+
<h3>{{ isEditing ? 'Edit Item' : 'Add New Item' }}</h3>
|
|
81
|
+
<form @submit.prevent="saveItem">
|
|
82
|
+
<label>Custom ID (Optional):</label>
|
|
83
|
+
<br>
|
|
84
|
+
<input v-model="form.id" placeholder="ID (e.g. 101 or leave blank for auto)" :disabled="isEditing" />
|
|
85
|
+
<br><br>
|
|
86
|
+
|
|
87
|
+
<label>Name:</label>
|
|
88
|
+
<br>
|
|
89
|
+
<input v-model="form.name" placeholder="Name" required />
|
|
90
|
+
<br><br>
|
|
91
|
+
|
|
92
|
+
<label>Description:</label>
|
|
93
|
+
<br>
|
|
94
|
+
<input v-model="form.description" placeholder="Description" required />
|
|
95
|
+
<br><br>
|
|
96
|
+
|
|
97
|
+
<label>Price:</label>
|
|
98
|
+
<br>
|
|
99
|
+
<input v-model.number="form.price" type="number" step="0.01" placeholder="Price" required />
|
|
100
|
+
<br><br>
|
|
101
|
+
|
|
102
|
+
<button type="submit">{{ isEditing ? 'Update Item (PUT)' : 'Create Item (POST)' }}</button>
|
|
103
|
+
<button type="button" v-if="isEditing" @click="resetForm">Cancel</button>
|
|
104
|
+
</form>
|
|
105
|
+
|
|
106
|
+
<hr>
|
|
107
|
+
|
|
108
|
+
<h3>Fetch Single Item By ID (GET /api/items/:id)</h3>
|
|
109
|
+
<input v-model="searchId" placeholder="Enter Item ID" />
|
|
110
|
+
<button type="button" @click="fetchSingleItem(searchId)">Fetch Detail</button>
|
|
111
|
+
|
|
112
|
+
<div v-if="selectedItem">
|
|
113
|
+
<br>
|
|
114
|
+
<b>Item Details:</b>
|
|
115
|
+
<br>
|
|
116
|
+
ID: {{ selectedItem.id }}
|
|
117
|
+
<br>
|
|
118
|
+
Name: {{ selectedItem.name }}
|
|
119
|
+
<br>
|
|
120
|
+
Description: {{ selectedItem.description }}
|
|
121
|
+
<br>
|
|
122
|
+
Price: {{ selectedItem.price }}
|
|
123
|
+
<br>
|
|
124
|
+
<button type="button" @click="selectedItem = null">Close Details</button>
|
|
125
|
+
</div>
|
|
126
|
+
|
|
127
|
+
<hr>
|
|
128
|
+
|
|
129
|
+
<h3>Item List (GET /api/items)</h3>
|
|
130
|
+
<button type="button" @click="loadItems">Refresh List</button>
|
|
131
|
+
<br><br>
|
|
132
|
+
|
|
133
|
+
<table>
|
|
134
|
+
<thead>
|
|
135
|
+
<tr>
|
|
136
|
+
<th>ID</th>
|
|
137
|
+
<th>Name</th>
|
|
138
|
+
<th>Description</th>
|
|
139
|
+
<th>Price</th>
|
|
140
|
+
<th>Actions</th>
|
|
141
|
+
</tr>
|
|
142
|
+
</thead>
|
|
143
|
+
<tbody>
|
|
144
|
+
<tr v-for="item in items" :key="item.id">
|
|
145
|
+
<td>{{ item.id }}</td>
|
|
146
|
+
<td>{{ item.name }}</td>
|
|
147
|
+
<td>{{ item.description }}</td>
|
|
148
|
+
<td>{{ item.price }}</td>
|
|
149
|
+
<td>
|
|
150
|
+
<button type="button" @click="fetchSingleItem(item.id)">View</button>
|
|
151
|
+
<button type="button" @click="editItem(item)">Edit</button>
|
|
152
|
+
<button type="button" @click="deleteItem(item.id)">Delete</button>
|
|
153
|
+
<button type="button" @click="patchItem(item)">Patch</button>
|
|
154
|
+
</td>
|
|
155
|
+
</tr>
|
|
156
|
+
</tbody>
|
|
157
|
+
</table>
|
|
158
|
+
</template>
|
|
@@ -1,21 +1,24 @@
|
|
|
1
|
-
import axios from 'axios';
|
|
2
|
-
|
|
3
|
-
const API_URL = 'http://localhost:8080/api/items';
|
|
4
|
-
|
|
5
|
-
export default {
|
|
6
|
-
getAll() {
|
|
7
|
-
return axios.get(API_URL);
|
|
8
|
-
},
|
|
9
|
-
getById(id) {
|
|
10
|
-
return axios.get(`${API_URL}/${id}`);
|
|
11
|
-
},
|
|
12
|
-
create(data) {
|
|
13
|
-
return axios.post(API_URL, data);
|
|
14
|
-
},
|
|
15
|
-
update(id, data) {
|
|
16
|
-
return axios.put(`${API_URL}/${id}`, data);
|
|
17
|
-
},
|
|
18
|
-
delete(id) {
|
|
19
|
-
return axios.delete(`${API_URL}/${id}`);
|
|
20
|
-
}
|
|
21
|
-
|
|
1
|
+
import axios from 'axios';
|
|
2
|
+
|
|
3
|
+
const API_URL = 'http://localhost:8080/api/items';
|
|
4
|
+
|
|
5
|
+
export default {
|
|
6
|
+
getAll() {
|
|
7
|
+
return axios.get(API_URL);
|
|
8
|
+
},
|
|
9
|
+
getById(id) {
|
|
10
|
+
return axios.get(`${API_URL}/${id}`);
|
|
11
|
+
},
|
|
12
|
+
create(data) {
|
|
13
|
+
return axios.post(API_URL, data);
|
|
14
|
+
},
|
|
15
|
+
update(id, data) {
|
|
16
|
+
return axios.put(`${API_URL}/${id}`, data);
|
|
17
|
+
},
|
|
18
|
+
delete(id) {
|
|
19
|
+
return axios.delete(`${API_URL}/${id}`);
|
|
20
|
+
},
|
|
21
|
+
patch(id, data) {
|
|
22
|
+
return axios.patch(`${API_URL}/${id}`, data);
|
|
23
|
+
}
|
|
24
|
+
};
|