107 lines
2.4 KiB
TypeScript
107 lines
2.4 KiB
TypeScript
import request from '@/utils/request';
|
|
import type { ApiResult, PageResult } from '@/api';
|
|
import type { LawOrg, LawOrgParam } from './model';
|
|
import { MODULES_API_URL } from '@/config/setting';
|
|
|
|
/**
|
|
* 分页查询机构
|
|
*/
|
|
export async function pageLawOrg(params: LawOrgParam) {
|
|
const res = await request.get<ApiResult<PageResult<LawOrg>>>(
|
|
MODULES_API_URL + '/law/law-org/page',
|
|
{
|
|
params
|
|
}
|
|
);
|
|
if (res.data.code === 0) {
|
|
return res.data.data;
|
|
}
|
|
return Promise.reject(new Error(res.data.message));
|
|
}
|
|
|
|
/**
|
|
* 查询机构列表
|
|
*/
|
|
export async function listLawOrg(params?: LawOrgParam) {
|
|
const res = await request.get<ApiResult<LawOrg[]>>(
|
|
MODULES_API_URL + '/law/law-org',
|
|
{
|
|
params
|
|
}
|
|
);
|
|
if (res.data.code === 0 && res.data.data) {
|
|
return res.data.data;
|
|
}
|
|
return Promise.reject(new Error(res.data.message));
|
|
}
|
|
|
|
/**
|
|
* 添加机构
|
|
*/
|
|
export async function addLawOrg(data: LawOrg) {
|
|
const res = await request.post<ApiResult<unknown>>(
|
|
MODULES_API_URL + '/law/law-org',
|
|
data
|
|
);
|
|
if (res.data.code === 0) {
|
|
return res.data.message;
|
|
}
|
|
return Promise.reject(new Error(res.data.message));
|
|
}
|
|
|
|
/**
|
|
* 修改机构
|
|
*/
|
|
export async function updateLawOrg(data: LawOrg) {
|
|
const res = await request.put<ApiResult<unknown>>(
|
|
MODULES_API_URL + '/law/law-org',
|
|
data
|
|
);
|
|
if (res.data.code === 0) {
|
|
return res.data.message;
|
|
}
|
|
return Promise.reject(new Error(res.data.message));
|
|
}
|
|
|
|
/**
|
|
* 删除机构
|
|
*/
|
|
export async function removeLawOrg(id?: number) {
|
|
const res = await request.delete<ApiResult<unknown>>(
|
|
MODULES_API_URL + '/law/law-org/' + id
|
|
);
|
|
if (res.data.code === 0) {
|
|
return res.data.message;
|
|
}
|
|
return Promise.reject(new Error(res.data.message));
|
|
}
|
|
|
|
/**
|
|
* 批量删除机构
|
|
*/
|
|
export async function removeBatchLawOrg(data: (number | undefined)[]) {
|
|
const res = await request.delete<ApiResult<unknown>>(
|
|
MODULES_API_URL + '/law/law-org/batch',
|
|
{
|
|
data
|
|
}
|
|
);
|
|
if (res.data.code === 0) {
|
|
return res.data.message;
|
|
}
|
|
return Promise.reject(new Error(res.data.message));
|
|
}
|
|
|
|
/**
|
|
* 根据id查询机构
|
|
*/
|
|
export async function getLawOrg(id: number) {
|
|
const res = await request.get<ApiResult<LawOrg>>(
|
|
MODULES_API_URL + '/law/law-org/' + id
|
|
);
|
|
if (res.data.code === 0 && res.data.data) {
|
|
return res.data.data;
|
|
}
|
|
return Promise.reject(new Error(res.data.message));
|
|
}
|