diff --git a/app/Http/Controllers/System/Admin/Dictionary.php b/app/Http/Controllers/System/Admin/Dictionary.php
index 794f5ee..76f3e46 100644
--- a/app/Http/Controllers/System/Admin/Dictionary.php
+++ b/app/Http/Controllers/System/Admin/Dictionary.php
@@ -140,6 +140,16 @@ class Dictionary extends Controller
]);
}
+ public function getAllItems()
+ {
+ $items = $this->dictionaryService->getAllItems();
+ return response()->json([
+ 'code' => 200,
+ 'message' => 'success',
+ 'data' => $items
+ ]);
+ }
+
public function storeItem(Request $request)
{
try {
diff --git a/app/Http/Controllers/System/Api/Dictionary.php b/app/Http/Controllers/System/Api/Dictionary.php
index 28a3182..503e7ad 100644
--- a/app/Http/Controllers/System/Api/Dictionary.php
+++ b/app/Http/Controllers/System/Api/Dictionary.php
@@ -25,6 +25,28 @@ class Dictionary extends Controller
]);
}
+ /**
+ * 获取所有字典数据(包含字典项)
+ * 用于前端登录后缓存所有字典数据
+ */
+ public function all()
+ {
+ $dictionaries = $this->dictionaryService->getAll();
+
+ // 为每个字典添加 items 字段
+ $result = array_map(function($dictionary) {
+ $items = $this->dictionaryService->getItemsByCode($dictionary['code']);
+ $dictionary['items'] = $items;
+ return $dictionary;
+ }, $dictionaries);
+
+ return response()->json([
+ 'code' => 200,
+ 'message' => 'success',
+ 'data' => $result
+ ]);
+ }
+
public function getByCode(Request $request)
{
$code = $request->input('code');
diff --git a/app/Services/Auth/AuthService.php b/app/Services/Auth/AuthService.php
index 71f99c6..40854a7 100644
--- a/app/Services/Auth/AuthService.php
+++ b/app/Services/Auth/AuthService.php
@@ -210,7 +210,7 @@ class AuthService
'path' => $permission->path,
'name' => $permission->name,
'title' => $permission->title,
- 'meta' => $permission->meta ? json_decode($permission->meta, true) : [],
+ 'meta' => $permission->meta ?: [],
];
// 添加组件路径
diff --git a/app/Services/System/DictionaryService.php b/app/Services/System/DictionaryService.php
index 0dea17d..2a5ef42 100644
--- a/app/Services/System/DictionaryService.php
+++ b/app/Services/System/DictionaryService.php
@@ -43,6 +43,7 @@ class DictionaryService
if ($dictionaries === null) {
$dictionaries = Dictionary::where('status', true)
+ ->with(['activeItems'])
->orderBy('sort')
->get()
->toArray();
@@ -52,7 +53,7 @@ class DictionaryService
return $dictionaries;
}
- public function getById(int $id): ?Dictionary
+ public function getById(int $id): ?array
{
$cacheKey = 'system:dictionaries:' . $id;
$dictionary = Cache::get($cacheKey);
@@ -60,22 +61,26 @@ class DictionaryService
if ($dictionary === null) {
$dictionary = Dictionary::with('items')->find($id);
if ($dictionary) {
- Cache::put($cacheKey, $dictionary->toArray(), 3600);
+ $dictionary = $dictionary->toArray();
+ Cache::put($cacheKey, $dictionary, 3600);
}
}
- return $dictionary ? $dictionary : null;
+ return $dictionary ?? null;
}
- public function getByCode(string $code): ?Dictionary
+ public function getByCode(string $code): ?array
{
$cacheKey = 'system:dictionaries:code:' . $code;
$dictionary = Cache::get($cacheKey);
if ($dictionary === null) {
- $dictionary = Dictionary::where('code', $code)->first();
- if ($dictionary) {
- Cache::put($cacheKey, $dictionary->toArray(), 3600);
+ $dictionaryModel = Dictionary::where('code', $code)->first();
+ if ($dictionaryModel) {
+ $dictionary = $dictionaryModel->toArray();
+ Cache::put($cacheKey, $dictionary, 3600);
+ } else {
+ $dictionary = null;
}
}
@@ -269,4 +274,36 @@ class DictionaryService
return true;
}
+
+ /**
+ * 获取所有字典项(按字典分类)
+ * @return array 按字典code分类的字典项数据
+ */
+ public function getAllItems(): array
+ {
+ $cacheKey = 'system:dictionary-items:all';
+ $allItems = Cache::get($cacheKey);
+
+ if ($allItems === null) {
+ // 获取所有启用的字典
+ $dictionaries = Dictionary::where('status', true)
+ ->orderBy('sort')
+ ->get();
+
+ $result = [];
+ foreach ($dictionaries as $dictionary) {
+ $result[] = [
+ 'code' => $dictionary->code,
+ 'name' => $dictionary->name,
+ 'description' => $dictionary->description,
+ 'items' => $dictionary->activeItems->toArray()
+ ];
+ }
+
+ $allItems = $result;
+ Cache::put($cacheKey, $allItems, 3600);
+ }
+
+ return $allItems;
+ }
}
diff --git a/resources/admin/src/api/auth.js b/resources/admin/src/api/auth.js
index 793f0c9..e352454 100644
--- a/resources/admin/src/api/auth.js
+++ b/resources/admin/src/api/auth.js
@@ -28,7 +28,7 @@ export default {
post: async function (file) {
const formData = new FormData()
formData.append('file', file)
- return await request.post('upload', formData, {
+ return await request.post('system/upload', formData, {
headers: { 'Content-Type': 'multipart/form-data' }
})
},
@@ -38,64 +38,64 @@ export default {
users: {
list: {
get: async function (params) {
- return await request.get('users', { params })
+ return await request.get('auth/users', { params })
},
},
detail: {
get: async function (id) {
- return await request.get(`users/${id}`)
+ return await request.get(`auth/users/${id}`)
},
},
add: {
post: async function (params) {
- return await request.post('users', params)
+ return await request.post('auth/users', params)
},
},
edit: {
put: async function (id, params) {
- return await request.put(`users/${id}`, params)
+ return await request.put(`auth/users/${id}`, params)
},
},
delete: {
delete: async function (id) {
- return await request.delete(`users/${id}`)
+ return await request.delete(`auth/users/${id}`)
},
},
batchDelete: {
post: async function (params) {
- return await request.post('users/batch-delete', params)
+ return await request.post('auth/users/batch-delete', params)
},
},
batchStatus: {
post: async function (params) {
- return await request.post('users/batch-status', params)
+ return await request.post('auth/users/batch-status', params)
},
},
batchDepartment: {
post: async function (params) {
- return await request.post('users/batch-department', params)
+ return await request.post('auth/users/batch-department', params)
},
},
batchRoles: {
post: async function (params) {
- return await request.post('users/batch-roles', params)
+ return await request.post('auth/users/batch-roles', params)
},
},
export: {
post: async function (params) {
- return await request.post('users/export', params, { responseType: 'blob' })
+ return await request.post('auth/users/export', params, { responseType: 'blob' })
},
},
import: {
post: async function (formData) {
- return await request.post('users/import', formData, {
+ return await request.post('auth/users/import', formData, {
headers: { 'Content-Type': 'multipart/form-data' }
})
},
},
downloadTemplate: {
get: async function () {
- return await request.get('users/download-template', { responseType: 'blob' })
+ return await request.get('auth/users/download-template', { responseType: 'blob' })
},
},
},
@@ -104,27 +104,27 @@ export default {
onlineUsers: {
count: {
get: async function () {
- return await request.get('online-users/count')
+ return await request.get('auth/online-users/count')
},
},
list: {
get: async function (params) {
- return await request.get('online-users', { params })
+ return await request.get('auth/online-users', { params })
},
},
sessions: {
get: async function (userId) {
- return await request.get(`online-users/${userId}/sessions`)
+ return await request.get(`auth/online-users/${userId}/sessions`)
},
},
offline: {
post: async function (userId, params) {
- return await request.post(`online-users/${userId}/offline`, params)
+ return await request.post(`auth/online-users/${userId}/offline`, params)
},
},
offlineAll: {
post: async function (userId) {
- return await request.post(`online-users/${userId}/offline-all`)
+ return await request.post(`auth/online-users/${userId}/offline-all`)
},
},
},
@@ -133,77 +133,77 @@ export default {
roles: {
list: {
get: async function (params) {
- return await request.get('roles', { params })
+ return await request.get('auth/roles', { params })
},
},
all: {
get: async function () {
- return await request.get('roles/all')
+ return await request.get('auth/roles/all')
},
},
detail: {
get: async function (id) {
- return await request.get(`roles/${id}`)
+ return await request.get(`auth/roles/${id}`)
},
},
add: {
post: async function (params) {
- return await request.post('roles', params)
+ return await request.post('auth/roles', params)
},
},
edit: {
put: async function (id, params) {
- return await request.put(`roles/${id}`, params)
+ return await request.put(`auth/roles/${id}`, params)
},
},
delete: {
delete: async function (id) {
- return await request.delete(`roles/${id}`)
+ return await request.delete(`auth/roles/${id}`)
},
},
batchDelete: {
post: async function (params) {
- return await request.post('roles/batch-delete', params)
+ return await request.post('auth/roles/batch-delete', params)
},
},
batchStatus: {
post: async function (params) {
- return await request.post('roles/batch-status', params)
+ return await request.post('auth/roles/batch-status', params)
},
},
permissions: {
get: async function (id) {
- return await request.get(`roles/${id}/permissions`)
+ return await request.get(`auth/roles/${id}/permissions`)
},
post: async function (id, params) {
- return await request.post(`roles/${id}/permissions`, params)
+ return await request.post(`auth/roles/${id}/permissions`, params)
},
},
copy: {
post: async function (id, params) {
- return await request.post(`roles/${id}/copy`, params)
+ return await request.post(`auth/roles/${id}/copy`, params)
},
},
batchCopy: {
post: async function (params) {
- return await request.post('roles/batch-copy', params)
+ return await request.post('auth/roles/batch-copy', params)
},
},
export: {
post: async function (params) {
- return await request.post('roles/export', params, { responseType: 'blob' })
+ return await request.post('auth/roles/export', params, { responseType: 'blob' })
},
},
import: {
post: async function (formData) {
- return await request.post('roles/import', formData, {
+ return await request.post('auth/roles/import', formData, {
headers: { 'Content-Type': 'multipart/form-data' }
})
},
},
downloadTemplate: {
get: async function () {
- return await request.get('roles/download-template', { responseType: 'blob' })
+ return await request.get('auth/roles/download-template', { responseType: 'blob' })
},
},
},
@@ -212,64 +212,64 @@ export default {
permissions: {
list: {
get: async function (params) {
- return await request.get('permissions', { params })
+ return await request.get('auth/permissions', { params })
},
},
tree: {
get: async function () {
- return await request.get('permissions/tree')
+ return await request.get('auth/permissions/tree')
},
},
menu: {
get: async function () {
- return await request.get('permissions/menu')
+ return await request.get('auth/permissions/menu')
},
},
detail: {
get: async function (id) {
- return await request.get(`permissions/${id}`)
+ return await request.get(`auth/permissions/${id}`)
},
},
add: {
post: async function (params) {
- return await request.post('permissions', params)
+ return await request.post('auth/permissions', params)
},
},
edit: {
put: async function (id, params) {
- return await request.put(`permissions/${id}`, params)
+ return await request.put(`auth/permissions/${id}`, params)
},
},
delete: {
delete: async function (id) {
- return await request.delete(`permissions/${id}`)
+ return await request.delete(`auth/permissions/${id}`)
},
},
batchDelete: {
post: async function (params) {
- return await request.post('permissions/batch-delete', params)
+ return await request.post('auth/permissions/batch-delete', params)
},
},
batchStatus: {
post: async function (params) {
- return await request.post('permissions/batch-status', params)
+ return await request.post('auth/permissions/batch-status', params)
},
},
export: {
post: async function (params) {
- return await request.post('permissions/export', params, { responseType: 'blob' })
+ return await request.post('auth/permissions/export', params, { responseType: 'blob' })
},
},
import: {
post: async function (formData) {
- return await request.post('permissions/import', formData, {
+ return await request.post('auth/permissions/import', formData, {
headers: { 'Content-Type': 'multipart/form-data' }
})
},
},
downloadTemplate: {
get: async function () {
- return await request.get('permissions/download-template', { responseType: 'blob' })
+ return await request.get('auth/permissions/download-template', { responseType: 'blob' })
},
},
},
@@ -278,64 +278,64 @@ export default {
departments: {
list: {
get: async function (params) {
- return await request.get('departments', { params })
+ return await request.get('auth/departments', { params })
},
},
tree: {
get: async function (params) {
- return await request.get('departments/tree', { params })
+ return await request.get('auth/departments/tree', { params })
},
},
all: {
get: async function () {
- return await request.get('departments/all')
+ return await request.get('auth/departments/all')
},
},
detail: {
get: async function (id) {
- return await request.get(`departments/${id}`)
+ return await request.get(`auth/departments/${id}`)
},
},
add: {
post: async function (params) {
- return await request.post('departments', params)
+ return await request.post('auth/departments', params)
},
},
edit: {
put: async function (id, params) {
- return await request.put(`departments/${id}`, params)
+ return await request.put(`auth/departments/${id}`, params)
},
},
delete: {
delete: async function (id) {
- return await request.delete(`departments/${id}`)
+ return await request.delete(`auth/departments/${id}`)
},
},
batchDelete: {
post: async function (params) {
- return await request.post('departments/batch-delete', params)
+ return await request.post('auth/departments/batch-delete', params)
},
},
batchStatus: {
post: async function (params) {
- return await request.post('departments/batch-status', params)
+ return await request.post('auth/departments/batch-status', params)
},
},
export: {
post: async function (params) {
- return await request.post('departments/export', params, { responseType: 'blob' })
+ return await request.post('auth/departments/export', params, { responseType: 'blob' })
},
},
import: {
post: async function (formData) {
- return await request.post('departments/import', formData, {
+ return await request.post('auth/departments/import', formData, {
headers: { 'Content-Type': 'multipart/form-data' }
})
},
},
downloadTemplate: {
get: async function () {
- return await request.get('departments/download-template', { responseType: 'blob' })
+ return await request.get('auth/departments/download-template', { responseType: 'blob' })
},
},
},
diff --git a/resources/admin/src/api/system.js b/resources/admin/src/api/system.js
index 602c1f4..ec99c69 100644
--- a/resources/admin/src/api/system.js
+++ b/resources/admin/src/api/system.js
@@ -5,47 +5,47 @@ export default {
configs: {
list: {
get: async function (params) {
- return await request.get('configs', { params })
+ return await request.get('system/configs', { params })
},
},
groups: {
get: async function () {
- return await request.get('configs/groups')
+ return await request.get('system/configs/groups')
},
},
all: {
get: async function (params) {
- return await request.get('configs/all', { params })
+ return await request.get('system/configs/all', { params })
},
},
detail: {
get: async function (id) {
- return await request.get(`configs/${id}`)
+ return await request.get(`system/configs/${id}`)
},
},
add: {
post: async function (params) {
- return await request.post('configs', params)
+ return await request.post('system/configs', params)
},
},
edit: {
put: async function (id, params) {
- return await request.put(`configs/${id}`, params)
+ return await request.put(`system/configs/${id}`, params)
},
},
delete: {
delete: async function (id) {
- return await request.delete(`configs/${id}`)
+ return await request.delete(`system/configs/${id}`)
},
},
batchDelete: {
post: async function (params) {
- return await request.post('configs/batch-delete', params)
+ return await request.post('system/configs/batch-delete', params)
},
},
batchStatus: {
post: async function (params) {
- return await request.post('configs/batch-status', params)
+ return await request.post('system/configs/batch-status', params)
},
},
},
@@ -54,32 +54,32 @@ export default {
logs: {
list: {
get: async function (params) {
- return await request.get('logs', { params })
+ return await request.get('system/logs', { params })
},
},
detail: {
get: async function (id) {
- return await request.get(`logs/${id}`)
+ return await request.get(`system/logs/${id}`)
},
},
delete: {
delete: async function (id) {
- return await request.delete(`logs/${id}`)
+ return await request.delete(`system/logs/${id}`)
},
},
batchDelete: {
post: async function (params) {
- return await request.post('logs/batch-delete', params)
+ return await request.post('system/logs/batch-delete', params)
},
},
clear: {
post: async function (params) {
- return await request.post('logs/clear', params)
+ return await request.post('system/logs/clear', params)
},
},
export: {
get: async function (params) {
- return await request.get('logs/export', {
+ return await request.get('system/logs/export', {
params,
responseType: 'blob'
})
@@ -87,90 +87,102 @@ export default {
},
statistics: {
get: async function (params) {
- return await request.get('logs/statistics', { params })
+ return await request.get('system/logs/statistics', { params })
},
},
},
- // 数据字典管理
- dictionaries: {
- list: {
- get: async function (params) {
- return await request.get('dictionaries', { params })
+ // 数据字典管理
+ dictionaries: {
+ list: {
+ get: async function (params) {
+ return await request.get('system/dictionaries', { params })
+ },
+ },
+ all: {
+ get: async function () {
+ return await request.get('system/dictionaries/all')
+ },
+ },
+ detail: {
+ get: async function (id) {
+ return await request.get(`system/dictionaries/${id}`)
+ },
+ },
+ add: {
+ post: async function (params) {
+ return await request.post('system/dictionaries', params)
+ },
+ },
+ edit: {
+ put: async function (id, params) {
+ return await request.put(`system/dictionaries/${id}`, params)
+ },
+ },
+ delete: {
+ delete: async function (id) {
+ return await request.delete(`system/dictionaries/${id}`)
+ },
+ },
+ batchDelete: {
+ post: async function (params) {
+ return await request.post('system/dictionaries/batch-delete', params)
+ },
+ },
+ batchStatus: {
+ post: async function (params) {
+ return await request.post('system/dictionaries/batch-status', params)
+ },
+ },
+ items: {
+ all: {
+ get: async function (code) {
+ return await request.get(`system/dictionaries/code`, { params: { code } })
+ },
+ },
},
},
- all: {
- get: async function () {
- return await request.get('dictionaries/all')
- },
- },
- detail: {
- get: async function (id) {
- return await request.get(`dictionaries/${id}`)
- },
- },
- add: {
- post: async function (params) {
- return await request.post('dictionaries', params)
- },
- },
- edit: {
- put: async function (id, params) {
- return await request.put(`dictionaries/${id}`, params)
- },
- },
- delete: {
- delete: async function (id) {
- return await request.delete(`dictionaries/${id}`)
- },
- },
- batchDelete: {
- post: async function (params) {
- return await request.post('dictionaries/batch-delete', params)
- },
- },
- batchStatus: {
- post: async function (params) {
- return await request.post('dictionaries/batch-status', params)
- },
- },
- },
// 数据字典项管理
dictionaryItems: {
list: {
get: async function (params) {
- return await request.get('dictionary-items', { params })
+ return await request.get('system/dictionary-items', { params })
+ },
+ },
+ all: {
+ get: async function () {
+ return await request.get('system/dictionary-items/all')
},
},
detail: {
get: async function (id) {
- return await request.get(`dictionary-items/${id}`)
+ return await request.get(`system/dictionary-items/${id}`)
},
},
add: {
post: async function (params) {
- return await request.post('dictionary-items', params)
+ return await request.post('system/dictionary-items', params)
},
},
edit: {
put: async function (id, params) {
- return await request.put(`dictionary-items/${id}`, params)
+ return await request.put(`system/dictionary-items/${id}`, params)
},
},
delete: {
delete: async function (id) {
- return await request.delete(`dictionary-items/${id}`)
+ return await request.delete(`system/dictionary-items/${id}`)
},
},
batchDelete: {
post: async function (params) {
- return await request.post('dictionary-items/batch-delete', params)
+ return await request.post('system/dictionary-items/batch-delete', params)
},
},
batchStatus: {
post: async function (params) {
- return await request.post('dictionary-items/batch-status', params)
+ return await request.post('system/dictionary-items/batch-status', params)
},
},
},
@@ -179,52 +191,52 @@ export default {
tasks: {
list: {
get: async function (params) {
- return await request.get('tasks', { params })
+ return await request.get('system/tasks', { params })
},
},
all: {
get: async function () {
- return await request.get('tasks/all')
+ return await request.get('system/tasks/all')
},
},
detail: {
get: async function (id) {
- return await request.get(`tasks/${id}`)
+ return await request.get(`system/tasks/${id}`)
},
},
add: {
post: async function (params) {
- return await request.post('tasks', params)
+ return await request.post('system/tasks', params)
},
},
edit: {
put: async function (id, params) {
- return await request.put(`tasks/${id}`, params)
+ return await request.put(`system/tasks/${id}`, params)
},
},
delete: {
delete: async function (id) {
- return await request.delete(`tasks/${id}`)
+ return await request.delete(`system/tasks/${id}`)
},
},
batchDelete: {
post: async function (params) {
- return await request.post('tasks/batch-delete', params)
+ return await request.post('system/tasks/batch-delete', params)
},
},
batchStatus: {
post: async function (params) {
- return await request.post('tasks/batch-status', params)
+ return await request.post('system/tasks/batch-status', params)
},
},
run: {
post: async function (id) {
- return await request.post(`tasks/${id}/run`)
+ return await request.post(`system/tasks/${id}/run`)
},
},
statistics: {
get: async function () {
- return await request.get('tasks/statistics')
+ return await request.get('system/tasks/statistics')
},
},
},
@@ -233,62 +245,62 @@ export default {
cities: {
list: {
get: async function (params) {
- return await request.get('cities', { params })
+ return await request.get('system/cities', { params })
},
},
tree: {
get: async function () {
- return await request.get('cities/tree')
+ return await request.get('system/cities/tree')
},
},
detail: {
get: async function (id) {
- return await request.get(`cities/${id}`)
+ return await request.get(`system/cities/${id}`)
},
},
children: {
get: async function (id) {
- return await request.get(`cities/${id}/children`)
+ return await request.get(`system/cities/${id}/children`)
},
},
provinces: {
get: async function () {
- return await request.get('cities/provinces')
+ return await request.get('system/cities/provinces')
},
},
cities: {
get: async function (provinceId) {
- return await request.get(`cities/${provinceId}/cities`)
+ return await request.get(`system/cities/${provinceId}/cities`)
},
},
districts: {
get: async function (cityId) {
- return await request.get(`cities/${cityId}/districts`)
+ return await request.get(`system/cities/${cityId}/districts`)
},
},
add: {
post: async function (params) {
- return await request.post('cities', params)
+ return await request.post('system/cities', params)
},
},
edit: {
put: async function (id, params) {
- return await request.put(`cities/${id}`, params)
+ return await request.put(`system/cities/${id}`, params)
},
},
delete: {
delete: async function (id) {
- return await request.delete(`cities/${id}`)
+ return await request.delete(`system/cities/${id}`)
},
},
batchDelete: {
post: async function (params) {
- return await request.post('cities/batch-delete', params)
+ return await request.post('system/cities/batch-delete', params)
},
},
batchStatus: {
post: async function (params) {
- return await request.post('cities/batch-status', params)
+ return await request.post('system/cities/batch-status', params)
},
},
},
@@ -297,31 +309,31 @@ export default {
upload: {
single: {
post: async function (formData) {
- return await request.post('upload', formData, {
+ return await request.post('system/upload', formData, {
headers: { 'Content-Type': 'multipart/form-data' }
})
},
},
multiple: {
post: async function (formData) {
- return await request.post('upload/multiple', formData, {
+ return await request.post('system/upload/multiple', formData, {
headers: { 'Content-Type': 'multipart/form-data' }
})
},
},
base64: {
post: async function (params) {
- return await request.post('upload/base64', params)
+ return await request.post('system/upload/base64', params)
},
},
delete: {
post: async function (params) {
- return await request.post('upload/delete', params)
+ return await request.post('system/upload/delete', params)
},
},
batchDelete: {
post: async function (params) {
- return await request.post('upload/batch-delete', params)
+ return await request.post('system/upload/batch-delete', params)
},
},
},
diff --git a/resources/admin/src/components/HelloWorld.vue b/resources/admin/src/components/HelloWorld.vue
deleted file mode 100644
index 546ebbc..0000000
--- a/resources/admin/src/components/HelloWorld.vue
+++ /dev/null
@@ -1,43 +0,0 @@
-
-
-
-
- Edit
-
- Check out
- create-vue, the official Vue + Vite starter
-
- Learn more about IDE Support for Vue in the
- Vue Docs Scaling up Guide.
- Click on the Vite and Vue logos to learn more{{ msg }}
-
- components/HelloWorld.vue to test HMR
-