106 lines
2.3 KiB
TypeScript
106 lines
2.3 KiB
TypeScript
import request from '@/utils/request';
|
|
import type { ApiResult, PageResult } from '@/api';
|
|
import type { Security, SecurityParam } from '@/api/tower/security/model';
|
|
/**
|
|
* 分页查询仓库
|
|
*/
|
|
export async function pageSecurity(params: SecurityParam) {
|
|
const res = await request.get<ApiResult<PageResult<Security>>>(
|
|
'/tower/tower-security/page',
|
|
{
|
|
params
|
|
}
|
|
);
|
|
if (res.data.code === 0) {
|
|
return res.data.data;
|
|
}
|
|
return Promise.reject(new Error(res.data.message));
|
|
}
|
|
|
|
/**
|
|
* 查询仓库列表
|
|
*/
|
|
export async function listSecurity(params?: SecurityParam) {
|
|
const res = await request.get<ApiResult<Security[]>>(
|
|
'/tower/tower-security',
|
|
{
|
|
params
|
|
}
|
|
);
|
|
if (res.data.code === 0 && res.data.data) {
|
|
return res.data.data;
|
|
}
|
|
return Promise.reject(new Error(res.data.message));
|
|
}
|
|
|
|
/**
|
|
* 添加仓库
|
|
*/
|
|
export async function addSecurity(data: Security) {
|
|
const res = await request.post<ApiResult<unknown>>(
|
|
'/tower/tower-security',
|
|
data
|
|
);
|
|
if (res.data.code === 0) {
|
|
return res.data.message;
|
|
}
|
|
return Promise.reject(new Error(res.data.message));
|
|
}
|
|
|
|
/**
|
|
* 修改仓库
|
|
*/
|
|
export async function updateSecurity(data: Security) {
|
|
const res = await request.put<ApiResult<unknown>>(
|
|
'/tower/tower-security',
|
|
data
|
|
);
|
|
if (res.data.code === 0) {
|
|
return res.data.message;
|
|
}
|
|
return Promise.reject(new Error(res.data.message));
|
|
}
|
|
|
|
/**
|
|
* 绑定仓库
|
|
*/
|
|
export async function bindSecurity(data: Security) {
|
|
const res = await request.put<ApiResult<unknown>>(
|
|
'/tower/tower-security/bind',
|
|
data
|
|
);
|
|
if (res.data.code === 0) {
|
|
return res.data.message;
|
|
}
|
|
return Promise.reject(new Error(res.data.message));
|
|
}
|
|
|
|
/**
|
|
* 删除仓库
|
|
*/
|
|
export async function removeSecurity(id?: number) {
|
|
const res = await request.delete<ApiResult<unknown>>(
|
|
'/tower/tower-security/' + id
|
|
);
|
|
if (res.data.code === 0) {
|
|
return res.data.message;
|
|
}
|
|
return Promise.reject(new Error(res.data.message));
|
|
}
|
|
|
|
/**
|
|
* 批量删除仓库
|
|
*/
|
|
export async function removeBatchSecurity(data: (number | undefined)[]) {
|
|
const res = await request.delete<ApiResult<unknown>>(
|
|
'/tower/tower-security/batch',
|
|
{
|
|
data
|
|
}
|
|
);
|
|
if (res.data.code === 0) {
|
|
return res.data.message;
|
|
}
|
|
return Promise.reject(new Error(res.data.message));
|
|
}
|