110 lines
2.4 KiB
TypeScript
110 lines
2.4 KiB
TypeScript
import request from '@/utils/request';
|
|
import type { ApiResult, PageResult } from '@/api';
|
|
import type {
|
|
SecurityPlant,
|
|
SecurityPlantParam
|
|
} from '@/api/tower/security-plant/model';
|
|
|
|
/**
|
|
* 分页查询仓库
|
|
*/
|
|
export async function pageSecurityPlant(params: SecurityPlantParam) {
|
|
const res = await request.get<ApiResult<PageResult<SecurityPlant>>>(
|
|
'/tower/tower-security-plant/page',
|
|
{
|
|
params
|
|
}
|
|
);
|
|
if (res.data.code === 0) {
|
|
return res.data.data;
|
|
}
|
|
return Promise.reject(new Error(res.data.message));
|
|
}
|
|
|
|
/**
|
|
* 查询仓库列表
|
|
*/
|
|
export async function listSecurityPlant(params?: SecurityPlantParam) {
|
|
const res = await request.get<ApiResult<SecurityPlant[]>>(
|
|
'/tower/tower-security-plant',
|
|
{
|
|
params
|
|
}
|
|
);
|
|
if (res.data.code === 0 && res.data.data) {
|
|
return res.data.data;
|
|
}
|
|
return Promise.reject(new Error(res.data.message));
|
|
}
|
|
|
|
/**
|
|
* 添加仓库
|
|
*/
|
|
export async function addSecurityPlant(data: SecurityPlant) {
|
|
const res = await request.post<ApiResult<unknown>>(
|
|
'/tower/tower-security-plant',
|
|
data
|
|
);
|
|
if (res.data.code === 0) {
|
|
return res.data.message;
|
|
}
|
|
return Promise.reject(new Error(res.data.message));
|
|
}
|
|
|
|
/**
|
|
* 修改仓库
|
|
*/
|
|
export async function updateSecurityPlant(data: SecurityPlant) {
|
|
const res = await request.put<ApiResult<unknown>>(
|
|
'/tower/tower-security-plant',
|
|
data
|
|
);
|
|
if (res.data.code === 0) {
|
|
return res.data.message;
|
|
}
|
|
return Promise.reject(new Error(res.data.message));
|
|
}
|
|
|
|
/**
|
|
* 绑定仓库
|
|
*/
|
|
export async function bindSecurityPlant(data: SecurityPlant) {
|
|
const res = await request.put<ApiResult<unknown>>(
|
|
'/tower/tower-security-plant/bind',
|
|
data
|
|
);
|
|
if (res.data.code === 0) {
|
|
return res.data.message;
|
|
}
|
|
return Promise.reject(new Error(res.data.message));
|
|
}
|
|
|
|
/**
|
|
* 删除仓库
|
|
*/
|
|
export async function removeSecurityPlant(id?: number) {
|
|
const res = await request.delete<ApiResult<unknown>>(
|
|
'/tower/tower-security-plant/' + id
|
|
);
|
|
if (res.data.code === 0) {
|
|
return res.data.message;
|
|
}
|
|
return Promise.reject(new Error(res.data.message));
|
|
}
|
|
|
|
/**
|
|
* 批量删除仓库
|
|
*/
|
|
export async function removeBatchSecurityPlant(data: (number | undefined)[]) {
|
|
const res = await request.delete<ApiResult<unknown>>(
|
|
'/tower/tower-security-plant/batch',
|
|
{
|
|
data
|
|
}
|
|
);
|
|
if (res.data.code === 0) {
|
|
return res.data.message;
|
|
}
|
|
return Promise.reject(new Error(res.data.message));
|
|
}
|