牧安云哨-前端
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
export * from './core';
|
||||
export * from './cv';
|
||||
export * from './iot';
|
||||
export * from './llm';
|
||||
export * from './manager';
|
||||
export * from './sentinel';
|
||||
|
||||
@@ -0,0 +1,80 @@
|
||||
import type { Recordable } from '@vben/types';
|
||||
|
||||
import { sha256 } from 'js-sha256';
|
||||
|
||||
import { pyRequestClient } from '#/api/request';
|
||||
|
||||
export namespace SystemDeviceApi {
|
||||
export interface SystemDevice {
|
||||
[key: string]: any;
|
||||
id: string;
|
||||
remark?: string;
|
||||
name: string;
|
||||
roles: string[];
|
||||
status: 0 | 1;
|
||||
is_superuser: 0 | 1;
|
||||
dept_id?: string;
|
||||
dept_name?: string;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取设备列表数据
|
||||
*/
|
||||
async function getDeviceList(params: Recordable<any>) {
|
||||
return pyRequestClient.get<Array<SystemDeviceApi.SystemDevice>>(
|
||||
'/iot/common/device/list',
|
||||
{ params },
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建设备
|
||||
* @param data 设备数据
|
||||
*/
|
||||
async function createDevice(data: Omit<SystemDeviceApi.SystemDevice, 'id'>) {
|
||||
data.password_hash = sha256(data.password?.toString() || '');
|
||||
delete data.password;
|
||||
return pyRequestClient.post('/iot/common/device', data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新设备
|
||||
*
|
||||
* @param id 设备 ID
|
||||
* @param data 设备数据
|
||||
*/
|
||||
async function updateDevice(
|
||||
id: string,
|
||||
data: Omit<SystemDeviceApi.SystemDevice, 'id'>,
|
||||
) {
|
||||
return pyRequestClient.put(`/iot/common/device/${id}`, data);
|
||||
}
|
||||
/**
|
||||
* 更新设备(部分更新)
|
||||
*
|
||||
* @param id 设备 ID
|
||||
* @param data 需要更新的字段(部分字段即可)
|
||||
*/
|
||||
async function updateDevicePatch(
|
||||
id: string,
|
||||
data: Partial<Omit<SystemDeviceApi.SystemDevice, 'id'>>,
|
||||
) {
|
||||
return pyRequestClient.patch(`/iot/common/device/${id}`, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除设备
|
||||
* @param id 设备 ID
|
||||
*/
|
||||
async function deleteDevice(id: string) {
|
||||
return pyRequestClient.delete(`/iot/common/device/${id}`);
|
||||
}
|
||||
|
||||
export {
|
||||
createDevice,
|
||||
deleteDevice,
|
||||
getDeviceList,
|
||||
updateDevice,
|
||||
updateDevicePatch,
|
||||
};
|
||||
@@ -0,0 +1 @@
|
||||
export * from './device';
|
||||
@@ -10,6 +10,16 @@ export namespace SystemDeptApi {
|
||||
}
|
||||
}
|
||||
|
||||
export namespace SystemDeptDetailApi {
|
||||
export interface SystemDept {
|
||||
[key: string]: any;
|
||||
children?: SystemDept[];
|
||||
id: string;
|
||||
name: string;
|
||||
comment?: string;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取部门列表数据
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,105 @@
|
||||
import { pyRequestClient } from '#/api/request';
|
||||
|
||||
export namespace SystemDictApi {
|
||||
export interface SystemDict {
|
||||
[key: string]: any;
|
||||
id: string;
|
||||
name: string;
|
||||
key: string;
|
||||
remark?: string;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取字典列表数据
|
||||
*/
|
||||
async function getDictList(name = '', page = 1, pageSize = 9) {
|
||||
return pyRequestClient.get<Array<SystemDictApi.SystemDict>>(
|
||||
'/system/dict/list',
|
||||
{ params: { name, page, page_size: pageSize } },
|
||||
);
|
||||
}
|
||||
/**
|
||||
* 创建字典
|
||||
* @param data 字典数据
|
||||
*/
|
||||
async function createDict(data: Omit<SystemDictApi.SystemDict, 'id'>) {
|
||||
return pyRequestClient.post('/system/dict', data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新字典
|
||||
*
|
||||
* @param id 字典 ID
|
||||
* @param data 字典数据
|
||||
*/
|
||||
async function updateDict(
|
||||
id: string,
|
||||
data: Omit<SystemDictApi.SystemDict, 'id'>,
|
||||
) {
|
||||
return pyRequestClient.put(`/system/dict/${id}`, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除字典
|
||||
* @param id 字典 ID
|
||||
*/
|
||||
async function deleteDict(id: string) {
|
||||
return pyRequestClient.delete(`/system/dict/${id}`);
|
||||
}
|
||||
export namespace SystemDictDetailApi {
|
||||
export interface DictDetail {
|
||||
id: string;
|
||||
value: string;
|
||||
sort?: number;
|
||||
pid?: null | string;
|
||||
dict_id: string;
|
||||
remark?: string;
|
||||
created_at?: string;
|
||||
updated_at?: string;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取字典详情列表(不分页)
|
||||
*/
|
||||
export async function getDictDetail(dictId: string) {
|
||||
return pyRequestClient.get<Array<SystemDictDetailApi.DictDetail>>(
|
||||
'/system/dict/detail/list',
|
||||
{ params: { dictId } },
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增字典详情
|
||||
*/
|
||||
export async function createDictDetail(
|
||||
data: Omit<
|
||||
SystemDictDetailApi.DictDetail,
|
||||
'created_at' | 'id' | 'updated_at'
|
||||
>,
|
||||
) {
|
||||
return pyRequestClient.post('/system/dict/detail', data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新字典详情
|
||||
*/
|
||||
export async function updateDictDetail(
|
||||
id: string,
|
||||
data: Partial<
|
||||
Omit<SystemDictDetailApi.DictDetail, 'created_at' | 'id' | 'updated_at'>
|
||||
>,
|
||||
) {
|
||||
return pyRequestClient.put(`/system/dict/detail/${id}`, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除字典详情
|
||||
*/
|
||||
export async function deleteDictDetail(id: string) {
|
||||
return pyRequestClient.delete(`/system/dict/detail/${id}`);
|
||||
}
|
||||
|
||||
|
||||
export { createDict, deleteDict, getDictList, updateDict };
|
||||
@@ -1,4 +1,6 @@
|
||||
export * from './dept';
|
||||
export * from './dict';
|
||||
export * from './menu';
|
||||
export * from './role';
|
||||
export * from './user';
|
||||
export * from './sys';
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
import { pyRequestClient } from '#/api/request';
|
||||
// system/dict.ts 或 system/dictDetail.ts
|
||||
|
||||
export namespace SystemDictApi {
|
||||
export interface DictDetail {
|
||||
id: string;
|
||||
value: string;
|
||||
label: string;
|
||||
sort: number;
|
||||
pid?: string | null;
|
||||
remark?: string;
|
||||
created_at?: string;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 根据字典 key 获取字典详情列表
|
||||
*/
|
||||
export async function getDictDetailList(key: string) {
|
||||
return pyRequestClient.get<Array<SystemDictApi.DictDetail>>(
|
||||
'/system/dict/getValue',
|
||||
{
|
||||
params: { key },
|
||||
},
|
||||
);
|
||||
}
|
||||
@@ -1,11 +1,14 @@
|
||||
import type { Recordable } from '@vben/types';
|
||||
|
||||
import { sha256 } from 'js-sha256';
|
||||
|
||||
import { SystemMenuApi } from '#/api';
|
||||
import { pyRequestClient } from '#/api/request';
|
||||
import { sha256 } from "js-sha256";
|
||||
|
||||
export namespace SystemUserApi {
|
||||
export interface SystemUser {
|
||||
[key: string]: any;
|
||||
|
||||
id: string;
|
||||
email?: string;
|
||||
name: string;
|
||||
@@ -37,18 +40,15 @@ async function createUser(data: Omit<SystemUserApi.SystemUser, 'id'>) {
|
||||
return pyRequestClient.post('/system/user', data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新用户
|
||||
*
|
||||
* @param id 用户 ID
|
||||
* @param data 用户数据
|
||||
*/
|
||||
async function updateUser(
|
||||
id: string,
|
||||
data: Omit<SystemUserApi.SystemUser, 'id'>,
|
||||
async function isUserNameExists(
|
||||
username: string,
|
||||
id?: SystemMenuApi.SystemMenu['id'],
|
||||
) {
|
||||
return pyRequestClient.put(`/system/user/${id}`, data);
|
||||
return pyRequestClient.get<boolean>('/system/user/name-exists', {
|
||||
params: { id, username },
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新用户(部分更新)
|
||||
*
|
||||
@@ -59,6 +59,14 @@ async function updateUserPatch(
|
||||
id: string,
|
||||
data: Partial<Omit<SystemUserApi.SystemUser, 'id'>>,
|
||||
) {
|
||||
if (
|
||||
data.password !== null &&
|
||||
data.password !== undefined &&
|
||||
data.password.trim() !== ''
|
||||
) {
|
||||
data.password_hash = sha256(data.password?.toString() || '');
|
||||
}
|
||||
delete data.password;
|
||||
return pyRequestClient.patch(`/system/user/${id}`, data);
|
||||
}
|
||||
|
||||
@@ -70,4 +78,10 @@ async function deleteUser(id: string) {
|
||||
return pyRequestClient.delete(`/system/user/${id}`);
|
||||
}
|
||||
|
||||
export { createUser, deleteUser, getUserList, updateUser,updateUserPatch };
|
||||
export {
|
||||
createUser,
|
||||
deleteUser,
|
||||
getUserList,
|
||||
isUserNameExists,
|
||||
updateUserPatch,
|
||||
};
|
||||
|
||||
@@ -0,0 +1,81 @@
|
||||
import type { Recordable } from '@vben/types';
|
||||
|
||||
import { pyRequestClient } from '#/api/request';
|
||||
|
||||
export namespace SentinelApi {
|
||||
export interface Record {
|
||||
id: string;
|
||||
name: string;
|
||||
is_inspected: 0 | 1;
|
||||
license_plate?: string;
|
||||
vehicle_type?: string;
|
||||
license_plate_image?: string;
|
||||
vehicle_image?: string;
|
||||
livestock_type?: string;
|
||||
livestock_source?: string;
|
||||
created_at?: string;
|
||||
updated_at?: string;
|
||||
remark?: string;
|
||||
dept_id?: string;
|
||||
dept_name?: string;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取记录列表数据
|
||||
*/
|
||||
async function getSentinelRecordList(params: Recordable<any>) {
|
||||
return pyRequestClient.get<Array<SentinelApi.Record>>(
|
||||
'/iot/sentinel/record/list',
|
||||
{ params },
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建记录
|
||||
* @param data 记录数据
|
||||
*/
|
||||
async function createSentinelRecord(data: Omit<SentinelApi.Record, 'id'>) {
|
||||
return pyRequestClient.post('/iot/sentinel/record', data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新记录
|
||||
*
|
||||
* @param id 记录 ID
|
||||
* @param data 记录数据
|
||||
*/
|
||||
async function updateSentinelRecord(
|
||||
id: string,
|
||||
data: Omit<SentinelApi.Record, 'id'>,
|
||||
) {
|
||||
return pyRequestClient.put(`/iot/sentinel/record/${id}`, data);
|
||||
}
|
||||
/**
|
||||
* 更新记录(部分更新)
|
||||
*
|
||||
* @param id 记录 ID
|
||||
* @param data 需要更新的字段(部分字段即可)
|
||||
*/
|
||||
async function updateSentinelRecordPatch(
|
||||
id: string,
|
||||
data: Partial<Omit<SentinelApi.Record, 'id'>>,
|
||||
) {
|
||||
return pyRequestClient.patch(`/iot/sentinel/record/${id}`, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除记录
|
||||
* @param id 记录 ID
|
||||
*/
|
||||
async function deleteSentinelRecord(id: string) {
|
||||
return pyRequestClient.delete(`/iot/sentinel/record/${id}`);
|
||||
}
|
||||
|
||||
export {
|
||||
createSentinelRecord,
|
||||
deleteSentinelRecord,
|
||||
getSentinelRecordList,
|
||||
updateSentinelRecord,
|
||||
updateSentinelRecordPatch,
|
||||
};
|
||||
@@ -0,0 +1 @@
|
||||
export * from './device';
|
||||
Reference in New Issue
Block a user