wad-lab 1.1.6 → 1.1.8

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.
Files changed (93) hide show
  1. package/package.json +1 -1
  2. package/templates/fullstack-springboot-vue/backend/src/main/java/com/example/company/controller/CompanyController.java +88 -74
  3. package/templates/fullstack-springboot-vue/backend/src/main/java/com/example/company/model/Employee.java +73 -73
  4. package/templates/fullstack-springboot-vue/backend/src/main/java/com/example/company/service/CompanyService.java +90 -60
  5. package/templates/fullstack-springboot-vue/frontend/vue-axios-basic/src/App.vue +429 -405
  6. package/templates/fullstack-springboot-vue/frontend/vue-axios-interceptor/src/App.vue +177 -159
  7. package/templates/fullstack-springboot-vue/frontend/vue-axios-pinia/src/App.vue +441 -427
  8. package/templates/fullstack-springboot-vue/frontend/vue-axios-pinia/src/stores/companyStore.js +126 -96
  9. package/templates/fullstack-springboot-vue/frontend/vue-axios-pinia-props/src/App.vue +84 -69
  10. package/templates/fullstack-springboot-vue/frontend/vue-axios-pinia-props/src/components/DepartmentSection.vue +164 -152
  11. package/templates/fullstack-springboot-vue/frontend/vue-axios-pinia-props/src/components/EmployeeSection.vue +193 -181
  12. package/templates/fullstack-springboot-vue/frontend/vue-axios-pinia-props/src/stores/companyStore.js +126 -35
  13. package/templates/fullstack-springboot-vue/frontend/vue-axios-props-emits/src/App.vue +191 -167
  14. package/templates/fullstack-springboot-vue/frontend/vue-axios-props-emits/src/components/DepartmentForm.vue +98 -98
  15. package/templates/fullstack-springboot-vue/frontend/vue-axios-props-emits/src/components/DepartmentList.vue +92 -91
  16. package/templates/fullstack-springboot-vue/frontend/vue-axios-props-emits/src/components/EmployeeForm.vue +128 -128
  17. package/templates/fullstack-springboot-vue/frontend/vue-axios-props-emits/src/components/EmployeeList.vue +95 -94
  18. package/templates/fullstack-springboot-vue/frontend/vue-axios-router/src/App.vue +90 -90
  19. package/templates/fullstack-springboot-vue/frontend/vue-axios-router/src/views/AddEmployeeView.vue +247 -247
  20. package/templates/fullstack-springboot-vue/frontend/vue-axios-router/src/views/DepartmentView.vue +296 -273
  21. package/templates/fullstack-springboot-vue/frontend/vue-axios-router/src/views/EmployeeView.vue +219 -196
  22. package/templates/fullstack-springboot-vue/frontend/vue-axios-router/src/views/HomeDashboardView.vue +263 -263
  23. package/templates/fullstack-springboot-vue/frontend/vue-axios-router-children/src/views/DepartmentListView.vue +250 -231
  24. package/templates/fullstack-springboot-vue/frontend/vue-axios-router-children/src/views/EmployeeDetailView.vue +181 -159
  25. package/templates/fullstack-springboot-vue/frontend/vue-axios-router-children/src/views/EmployeeListView.vue +315 -295
  26. package/templates/fullstack-springboot-vue/frontend/vue-axios-router-pinia/src/stores/companyStore.js +137 -70
  27. package/templates/fullstack-springboot-vue/frontend/vue-axios-router-pinia/src/views/DepartmentView.vue +229 -209
  28. package/templates/fullstack-springboot-vue/frontend/vue-axios-router-pinia/src/views/EmployeeView.vue +257 -237
  29. package/templates/fullstack-springboot-vue/frontend/vue-axios-router-pinia-props/src/components/EntityTable.vue +106 -92
  30. package/templates/fullstack-springboot-vue/frontend/vue-axios-router-pinia-props/src/stores/companyStore.js +139 -84
  31. package/templates/fullstack-springboot-vue/frontend/vue-axios-router-pinia-props/src/views/ManageDepartmentsView.vue +73 -64
  32. package/templates/fullstack-springboot-vue/frontend/vue-axios-router-pinia-props/src/views/ManageEmployeesView.vue +76 -67
  33. package/templates/fullstack-springboot-vue/frontend/vue-axios-router-props/src/App.vue +59 -59
  34. package/templates/fullstack-springboot-vue/frontend/vue-axios-router-props/src/components/DataCard.vue +72 -53
  35. package/templates/fullstack-springboot-vue/frontend/vue-axios-router-props/src/views/DepartmentPage.vue +89 -77
  36. package/templates/fullstack-springboot-vue/frontend/vue-axios-router-props/src/views/EmployeePage.vue +128 -116
  37. package/templates/springboot-2model-1controller-api/src/main/java/com/example/company/controller/CompanyController.java +88 -74
  38. package/templates/springboot-2model-1controller-api/src/main/java/com/example/company/model/Employee.java +73 -73
  39. package/templates/springboot-2model-1controller-api/src/main/java/com/example/company/service/CompanyService.java +90 -60
  40. package/templates/springboot-course-registration/src/main/java/com/example/coursereg/controller/CourseController.java +46 -42
  41. package/templates/springboot-course-registration/src/main/java/com/example/coursereg/service/CourseService.java +70 -60
  42. package/templates/springboot-hospital-api/src/main/java/com/example/hospital/controller/HospitalController.java +54 -50
  43. package/templates/springboot-hospital-api/src/main/java/com/example/hospital/service/HospitalService.java +65 -54
  44. package/templates/springboot-library-api/src/main/java/com/example/library/controller/LibraryController.java +57 -51
  45. package/templates/springboot-library-api/src/main/java/com/example/library/service/LibraryService.java +70 -60
  46. package/templates/springboot-mockmvc/src/main/java/com/example/mockmvc/controller/ItemController.java +45 -41
  47. package/templates/springboot-mockmvc/src/main/java/com/example/mockmvc/service/ItemService.java +48 -38
  48. package/templates/springboot-mongo-aggregation/src/main/java/com/example/aggregation/controller/ItemController.java +45 -41
  49. package/templates/springboot-mongo-aggregation/src/main/java/com/example/aggregation/service/ItemService.java +48 -38
  50. package/templates/springboot-mongo-aggregation-mockmvc/src/main/java/com/example/aggmockmvc/controller/ItemController.java +45 -41
  51. package/templates/springboot-mongo-aggregation-mockmvc/src/main/java/com/example/aggmockmvc/service/ItemService.java +48 -38
  52. package/templates/springboot-mongo-crud/src/main/java/com/example/crud/controller/ItemController.java +45 -41
  53. package/templates/springboot-mongo-crud/src/main/java/com/example/crud/service/ItemService.java +48 -38
  54. package/templates/vue-axios/src/App.vue +264 -243
  55. package/templates/vue-axios/src/services/ItemService.js +27 -21
  56. package/templates/vue-axios-basic/src/App.vue +24 -0
  57. package/templates/vue-axios-interceptor/src/App.vue +177 -159
  58. package/templates/vue-axios-pinia/src/App.vue +14 -0
  59. package/templates/vue-axios-pinia/src/stores/companyStore.js +126 -96
  60. package/templates/vue-axios-pinia-props/src/App.vue +84 -69
  61. package/templates/vue-axios-pinia-props/src/components/DepartmentSection.vue +164 -152
  62. package/templates/vue-axios-pinia-props/src/components/EmployeeSection.vue +193 -181
  63. package/templates/vue-axios-pinia-props/src/stores/companyStore.js +126 -35
  64. package/templates/vue-axios-props-emits/src/App.vue +24 -0
  65. package/templates/vue-axios-props-emits/src/components/DepartmentList.vue +2 -1
  66. package/templates/vue-axios-props-emits/src/components/EmployeeList.vue +2 -1
  67. package/templates/vue-axios-router/src/views/DepartmentView.vue +23 -0
  68. package/templates/vue-axios-router/src/views/EmployeeView.vue +23 -0
  69. package/templates/vue-axios-router-children/src/views/DepartmentListView.vue +250 -231
  70. package/templates/vue-axios-router-children/src/views/EmployeeDetailView.vue +181 -159
  71. package/templates/vue-axios-router-children/src/views/EmployeeListView.vue +315 -295
  72. package/templates/vue-axios-router-pinia/src/stores/companyStore.js +137 -70
  73. package/templates/vue-axios-router-pinia/src/views/DepartmentView.vue +229 -209
  74. package/templates/vue-axios-router-pinia/src/views/EmployeeView.vue +257 -237
  75. package/templates/vue-axios-router-pinia-props/src/components/EntityTable.vue +106 -92
  76. package/templates/vue-axios-router-pinia-props/src/stores/companyStore.js +139 -84
  77. package/templates/vue-axios-router-pinia-props/src/views/ManageDepartmentsView.vue +73 -64
  78. package/templates/vue-axios-router-pinia-props/src/views/ManageEmployeesView.vue +76 -67
  79. package/templates/vue-axios-router-props/src/components/DataCard.vue +72 -53
  80. package/templates/vue-axios-router-props/src/views/DepartmentPage.vue +89 -77
  81. package/templates/vue-axios-router-props/src/views/EmployeePage.vue +128 -116
  82. package/templates/vue-fetch/src/App.vue +285 -259
  83. package/templates/vue-router-pinia-springboot/backend/src/main/java/com/example/crud/controller/ItemController.java +45 -41
  84. package/templates/vue-router-pinia-springboot/backend/src/main/java/com/example/crud/service/ItemService.java +45 -35
  85. package/templates/vue-router-pinia-springboot/frontend/src/services/ItemService.js +24 -21
  86. package/templates/vue-router-pinia-springboot/frontend/src/stores/itemStore.js +42 -37
  87. package/templates/vue-router-pinia-springboot/frontend/src/views/ListView.vue +76 -67
  88. package/templates/vue-springboot-mongo-aggregation/backend/src/main/java/com/example/aggregation/controller/ItemController.java +45 -41
  89. package/templates/vue-springboot-mongo-aggregation/backend/src/main/java/com/example/aggregation/service/ItemService.java +45 -35
  90. package/templates/vue-springboot-mongo-crud/backend/src/main/java/com/example/crud/controller/ItemController.java +45 -41
  91. package/templates/vue-springboot-mongo-crud/backend/src/main/java/com/example/crud/service/ItemService.java +45 -35
  92. package/templates/vue-springboot-mongo-crud/frontend/src/App.vue +158 -149
  93. package/templates/vue-springboot-mongo-crud/frontend/src/services/ItemService.js +24 -21
@@ -1,196 +1,219 @@
1
- <script setup>
2
- import { ref, onMounted } from 'vue'
3
- import api from '../services/api'
4
-
5
- const employees = ref([])
6
- const departments = ref([])
7
- const loading = ref(false)
8
- const errorMessage = ref('')
9
-
10
- async function fetchData() {
11
- loading.value = true
12
- errorMessage.value = ''
13
- try {
14
- const [empRes, deptRes] = await Promise.all([
15
- api.get('/employees'),
16
- api.get('/departments').catch(() => ({ data: [] }))
17
- ])
18
- employees.value = empRes.data
19
- departments.value = deptRes.data
20
- } catch (err) {
21
- errorMessage.value = err.message || 'Failed to fetch employees'
22
- } finally {
23
- loading.value = false
24
- }
25
- }
26
-
27
- function getDepartmentName(deptId) {
28
- if (!deptId) return 'N/A'
29
- const dept = departments.value.find(d => d.id === deptId)
30
- return dept ? `${dept.name} (${dept.code})` : deptId
31
- }
32
-
33
- async function handleDeleteEmployee(id) {
34
- if (!confirm('Are you sure you want to delete this employee?')) return
35
- loading.value = true
36
- errorMessage.value = ''
37
- try {
38
- await api.delete(`/employees/${id}`)
39
- await fetchData()
40
- } catch (err) {
41
- errorMessage.value = err.message || 'Failed to delete employee'
42
- } finally {
43
- loading.value = false
44
- }
45
- }
46
-
47
- onMounted(() => {
48
- fetchData()
49
- })
50
- </script>
51
-
52
- <template>
53
- <div class="employee-view">
54
- <div class="view-header">
55
- <h2>Employees</h2>
56
- <router-link to="/add-employee" class="btn primary">+ Add Employee</router-link>
57
- </div>
58
-
59
- <div v-if="loading" class="state-msg">Loading...</div>
60
- <div v-if="errorMessage" class="state-msg error">{{ errorMessage }}</div>
61
-
62
- <div class="card">
63
- <table v-if="employees.length > 0" class="data-table">
64
- <thead>
65
- <tr>
66
- <th>ID</th>
67
- <th>Name</th>
68
- <th>Email</th>
69
- <th>Department</th>
70
- <th>Salary</th>
71
- <th>Actions</th>
72
- </tr>
73
- </thead>
74
- <tbody>
75
- <tr v-for="emp in employees" :key="emp.id">
76
- <td>{{ emp.id }}</td>
77
- <td><strong>{{ emp.name }}</strong></td>
78
- <td>{{ emp.email }}</td>
79
- <td>{{ getDepartmentName(emp.departmentId) }}</td>
80
- <td>${{ Number(emp.salary || 0).toLocaleString() }}</td>
81
- <td>
82
- <button
83
- @click="handleDeleteEmployee(emp.id)"
84
- class="btn danger"
85
- :disabled="loading"
86
- >
87
- Delete
88
- </button>
89
- </td>
90
- </tr>
91
- </tbody>
92
- </table>
93
- <p v-else class="empty-text">No employees found.</p>
94
- </div>
95
- </div>
96
- </template>
97
-
98
- <style scoped>
99
- .employee-view {
100
- display: flex;
101
- flex-direction: column;
102
- gap: 20px;
103
- }
104
-
105
- .view-header {
106
- display: flex;
107
- justify-content: space-between;
108
- align-items: center;
109
- }
110
-
111
- h2 {
112
- margin: 0;
113
- color: #2c3e50;
114
- }
115
-
116
- .card {
117
- background: #ffffff;
118
- border: 1px solid #ddd;
119
- border-radius: 6px;
120
- padding: 18px;
121
- }
122
-
123
- .btn {
124
- padding: 8px 16px;
125
- border: none;
126
- border-radius: 4px;
127
- font-size: 14px;
128
- text-decoration: none;
129
- cursor: pointer;
130
- font-weight: bold;
131
- display: inline-block;
132
- }
133
-
134
- .btn:disabled {
135
- opacity: 0.6;
136
- cursor: not-allowed;
137
- }
138
-
139
- .btn.primary {
140
- background: #27ae60;
141
- color: #fff;
142
- }
143
-
144
- .btn.primary:hover:not(:disabled) {
145
- background: #219150;
146
- }
147
-
148
- .btn.danger {
149
- background: #e74c3c;
150
- color: #fff;
151
- padding: 5px 10px;
152
- font-size: 12px;
153
- }
154
-
155
- .btn.danger:hover:not(:disabled) {
156
- background: #c0392b;
157
- }
158
-
159
- .data-table {
160
- width: 100%;
161
- border-collapse: collapse;
162
- }
163
-
164
- .data-table th,
165
- .data-table td {
166
- padding: 10px 12px;
167
- text-align: left;
168
- border-bottom: 1px solid #eee;
169
- font-size: 14px;
170
- }
171
-
172
- .data-table th {
173
- background: #f8f9fa;
174
- color: #555;
175
- font-weight: 600;
176
- }
177
-
178
- .state-msg {
179
- padding: 10px;
180
- background-color: #f8f9fa;
181
- border: 1px solid #ddd;
182
- border-radius: 4px;
183
- }
184
-
185
- .state-msg.error {
186
- background-color: #fde8e8;
187
- color: #c0392b;
188
- border-color: #f5c6cb;
189
- }
190
-
191
- .empty-text {
192
- color: #7f8c8d;
193
- font-size: 14px;
194
- margin: 0;
195
- }
196
- </style>
1
+ <script setup>
2
+ import { ref, onMounted } from 'vue'
3
+ import api from '../services/api'
4
+
5
+ const employees = ref([])
6
+ const departments = ref([])
7
+ const loading = ref(false)
8
+ const errorMessage = ref('')
9
+
10
+ async function fetchData() {
11
+ loading.value = true
12
+ errorMessage.value = ''
13
+ try {
14
+ const [empRes, deptRes] = await Promise.all([
15
+ api.get('/employees'),
16
+ api.get('/departments').catch(() => ({ data: [] }))
17
+ ])
18
+ employees.value = empRes.data
19
+ departments.value = deptRes.data
20
+ } catch (err) {
21
+ errorMessage.value = err.message || 'Failed to fetch employees'
22
+ } finally {
23
+ loading.value = false
24
+ }
25
+ }
26
+
27
+ function getDepartmentName(deptId) {
28
+ if (!deptId) return 'N/A'
29
+ const dept = departments.value.find(d => d.id === deptId)
30
+ return dept ? `${dept.name} (${dept.code})` : deptId
31
+ }
32
+
33
+ async function handlePatchEmployee(id, currentSalary) {
34
+ const salary = prompt('Enter new salary:', currentSalary)
35
+ if (!salary || Number(salary) === Number(currentSalary)) return
36
+ loading.value = true
37
+ errorMessage.value = ''
38
+ try {
39
+ await api.patch(`/employees/${id}`, { salary: Number(salary) })
40
+ await fetchData()
41
+ } catch (err) {
42
+ errorMessage.value = err.message || 'Failed to patch employee'
43
+ } finally {
44
+ loading.value = false
45
+ }
46
+ }
47
+
48
+ async function handleDeleteEmployee(id) {
49
+ if (!confirm('Are you sure you want to delete this employee?')) return
50
+ loading.value = true
51
+ errorMessage.value = ''
52
+ try {
53
+ await api.delete(`/employees/${id}`)
54
+ await fetchData()
55
+ } catch (err) {
56
+ errorMessage.value = err.message || 'Failed to delete employee'
57
+ } finally {
58
+ loading.value = false
59
+ }
60
+ }
61
+
62
+ onMounted(() => {
63
+ fetchData()
64
+ })
65
+ </script>
66
+
67
+ <template>
68
+ <div class="employee-view">
69
+ <div class="view-header">
70
+ <h2>Employees</h2>
71
+ <router-link to="/add-employee" class="btn primary">+ Add Employee</router-link>
72
+ </div>
73
+
74
+ <div v-if="loading" class="state-msg">Loading...</div>
75
+ <div v-if="errorMessage" class="state-msg error">{{ errorMessage }}</div>
76
+
77
+ <div class="card">
78
+ <table v-if="employees.length > 0" class="data-table">
79
+ <thead>
80
+ <tr>
81
+ <th>ID</th>
82
+ <th>Name</th>
83
+ <th>Email</th>
84
+ <th>Department</th>
85
+ <th>Salary</th>
86
+ <th>Actions</th>
87
+ </tr>
88
+ </thead>
89
+ <tbody>
90
+ <tr v-for="emp in employees" :key="emp.id">
91
+ <td>{{ emp.id }}</td>
92
+ <td><strong>{{ emp.name }}</strong></td>
93
+ <td>{{ emp.email }}</td>
94
+ <td>{{ getDepartmentName(emp.departmentId) }}</td>
95
+ <td>${{ Number(emp.salary || 0).toLocaleString() }}</td>
96
+ <td>
97
+ <button
98
+ @click="handlePatchEmployee(emp.id, emp.salary)"
99
+ class="btn"
100
+ :disabled="loading"
101
+ >
102
+ Patch
103
+ </button>
104
+ &nbsp;
105
+ <button
106
+ @click="handleDeleteEmployee(emp.id)"
107
+ class="btn danger"
108
+ :disabled="loading"
109
+ >
110
+ Delete
111
+ </button>
112
+ </td>
113
+ </tr>
114
+ </tbody>
115
+ </table>
116
+ <p v-else class="empty-text">No employees found.</p>
117
+ </div>
118
+ </div>
119
+ </template>
120
+
121
+ <style scoped>
122
+ .employee-view {
123
+ display: flex;
124
+ flex-direction: column;
125
+ gap: 20px;
126
+ }
127
+
128
+ .view-header {
129
+ display: flex;
130
+ justify-content: space-between;
131
+ align-items: center;
132
+ }
133
+
134
+ h2 {
135
+ margin: 0;
136
+ color: #2c3e50;
137
+ }
138
+
139
+ .card {
140
+ background: #ffffff;
141
+ border: 1px solid #ddd;
142
+ border-radius: 6px;
143
+ padding: 18px;
144
+ }
145
+
146
+ .btn {
147
+ padding: 8px 16px;
148
+ border: none;
149
+ border-radius: 4px;
150
+ font-size: 14px;
151
+ text-decoration: none;
152
+ cursor: pointer;
153
+ font-weight: bold;
154
+ display: inline-block;
155
+ }
156
+
157
+ .btn:disabled {
158
+ opacity: 0.6;
159
+ cursor: not-allowed;
160
+ }
161
+
162
+ .btn.primary {
163
+ background: #27ae60;
164
+ color: #fff;
165
+ }
166
+
167
+ .btn.primary:hover:not(:disabled) {
168
+ background: #219150;
169
+ }
170
+
171
+ .btn.danger {
172
+ background: #e74c3c;
173
+ color: #fff;
174
+ padding: 5px 10px;
175
+ font-size: 12px;
176
+ }
177
+
178
+ .btn.danger:hover:not(:disabled) {
179
+ background: #c0392b;
180
+ }
181
+
182
+ .data-table {
183
+ width: 100%;
184
+ border-collapse: collapse;
185
+ }
186
+
187
+ .data-table th,
188
+ .data-table td {
189
+ padding: 10px 12px;
190
+ text-align: left;
191
+ border-bottom: 1px solid #eee;
192
+ font-size: 14px;
193
+ }
194
+
195
+ .data-table th {
196
+ background: #f8f9fa;
197
+ color: #555;
198
+ font-weight: 600;
199
+ }
200
+
201
+ .state-msg {
202
+ padding: 10px;
203
+ background-color: #f8f9fa;
204
+ border: 1px solid #ddd;
205
+ border-radius: 4px;
206
+ }
207
+
208
+ .state-msg.error {
209
+ background-color: #fde8e8;
210
+ color: #c0392b;
211
+ border-color: #f5c6cb;
212
+ }
213
+
214
+ .empty-text {
215
+ color: #7f8c8d;
216
+ font-size: 14px;
217
+ margin: 0;
218
+ }
219
+ </style>