From 813ed14076eafedc5a4c65db5be439091dd17300 Mon Sep 17 00:00:00 2001 From: huxin02 Date: Fri, 14 Feb 2025 16:43:51 +0800 Subject: [PATCH] =?UTF-8?q?=E7=B3=BB=E7=BB=9F=E5=9F=BA=E7=A1=80=E6=A1=86?= =?UTF-8?q?=E6=9E=B6API=E8=B7=AF=E7=94=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/src/api/BaseApi.js | 56 +++++++++++++++++++++++++++ client/src/api/system/Dict.js | 7 ++++ client/src/api/system/DictItems.js | 13 +++++++ client/src/api/system/Function.js | 7 ++++ client/src/api/system/GlobalParam.js | 19 +++++++++ client/src/api/system/Jurisdiction.js | 25 ++++++++++++ client/src/api/system/OperateLog.js | 7 ++++ 7 files changed, 134 insertions(+) create mode 100644 client/src/api/BaseApi.js create mode 100644 client/src/api/system/Dict.js create mode 100644 client/src/api/system/DictItems.js create mode 100644 client/src/api/system/Function.js create mode 100644 client/src/api/system/GlobalParam.js create mode 100644 client/src/api/system/Jurisdiction.js create mode 100644 client/src/api/system/OperateLog.js diff --git a/client/src/api/BaseApi.js b/client/src/api/BaseApi.js new file mode 100644 index 0000000..f9a4972 --- /dev/null +++ b/client/src/api/BaseApi.js @@ -0,0 +1,56 @@ +import { api } from '../utils/Request' +import { REQUEST_METHOD_TYPES } from '../utils/Constants' + +const commonApiMethods = url => { + return { + query (query) { + return api({ + url: url, + method: REQUEST_METHOD_TYPES.GET, + params: query + }) + }, + querylist (query) { + return api({ + url: url + '/list', + method: REQUEST_METHOD_TYPES.GET, + params: query + }) + }, + findOne (id) { + return api({ + url: url + '/' + id, + method: REQUEST_METHOD_TYPES.GET + }) + }, + modify (id, data) { + return api({ + url: url + '/' + id, + method: REQUEST_METHOD_TYPES.PUT, + data: data + }) + }, + add (data) { + return api({ + url: url, + method: REQUEST_METHOD_TYPES.POST, + data: data + }) + }, + remove (id) { + return api({ + url: url + '/' + id, + method: REQUEST_METHOD_TYPES.DELETE + }) + }, + removeAll (ids) { + return api({ + url: url, + method: REQUEST_METHOD_TYPES.DELETE, + data: ids + }) + } + } +} + +export default commonApiMethods diff --git a/client/src/api/system/Dict.js b/client/src/api/system/Dict.js new file mode 100644 index 0000000..55910d0 --- /dev/null +++ b/client/src/api/system/Dict.js @@ -0,0 +1,7 @@ +import crud from '../BaseApi' + +const url = '/api/dicts' + +export const dicts = crud(url) + +export default dicts diff --git a/client/src/api/system/DictItems.js b/client/src/api/system/DictItems.js new file mode 100644 index 0000000..dfa96cb --- /dev/null +++ b/client/src/api/system/DictItems.js @@ -0,0 +1,13 @@ +import crud from '../BaseApi' +import {api} from '@/utils/Request' + +const url = '/api/system/dictItems' +const gztUrl = `${import.meta.env.VITE_BASE_URL}/ht/system/dict/cache` + +export const dictItems = Object.assign({ + queryGzt: (params) => { + return api.post(`${gztUrl}/${params.dictCode}`, undefined, {params: params}) + } +}, crud(url)) + +export default dictItems diff --git a/client/src/api/system/Function.js b/client/src/api/system/Function.js new file mode 100644 index 0000000..3dab005 --- /dev/null +++ b/client/src/api/system/Function.js @@ -0,0 +1,7 @@ +import crud from '../BaseApi' + +const url = '/api/functions' + +export const functions = crud(url) + +export default functions diff --git a/client/src/api/system/GlobalParam.js b/client/src/api/system/GlobalParam.js new file mode 100644 index 0000000..73c752e --- /dev/null +++ b/client/src/api/system/GlobalParam.js @@ -0,0 +1,19 @@ +import { NO_AUTH_API_PREFIX, REQUEST_METHOD_TYPES } from '../../utils/Constants' +import { api } from '../../utils/Request' +import crud from '../BaseApi' + +const baseUri = '/system/globalParams' + +const url = `/api${baseUri}` + +export const globalParams = { + noNeedLogin () { + return api({ + url: `${NO_AUTH_API_PREFIX}${baseUri}`, + method: REQUEST_METHOD_TYPES.GET + }) + }, + ...crud(url) +} + +export default globalParams diff --git a/client/src/api/system/Jurisdiction.js b/client/src/api/system/Jurisdiction.js new file mode 100644 index 0000000..d475b6b --- /dev/null +++ b/client/src/api/system/Jurisdiction.js @@ -0,0 +1,25 @@ +import crud from '../BaseApi' +import { request } from '../../utils/Request' + +import { NO_AUTH_API_PREFIX, REQUEST_METHOD_TYPES } from '../../utils/Constants' + +const baseUri = '/jurisdictions' +const url = `/api${baseUri}` + +/** + * 不需要登录认证的路径 + * @type {string} + */ +const noAuthUrl = `${NO_AUTH_API_PREFIX}${baseUri}` + +export const jurisdictions = { + findAll () { + return request({ + url: `${noAuthUrl}/all`, + method: REQUEST_METHOD_TYPES.GET + }) + }, + ...crud(url) +} + +export default jurisdictions diff --git a/client/src/api/system/OperateLog.js b/client/src/api/system/OperateLog.js new file mode 100644 index 0000000..3afeb61 --- /dev/null +++ b/client/src/api/system/OperateLog.js @@ -0,0 +1,7 @@ +import crud from '../BaseApi' + +const url = '/api/operate-logs' + +export const operateLogs = crud(url) + +export default operateLogs