112 lines
2.1 KiB
Plaintext
112 lines
2.1 KiB
Plaintext
import { request } from "@utils";
|
|
|
|
const API_PATH = "/bre/site";
|
|
|
|
const SiteAPI = {
|
|
getSiteList(query: SitePageQuery) {
|
|
return request<ApiResponse<PageResult<SiteTable>>>({
|
|
url: `${API_PATH}/list`,
|
|
method: "get",
|
|
params: query,
|
|
});
|
|
},
|
|
|
|
getSiteDetail(query: number) {
|
|
return request<ApiResponse<SiteTable>>({
|
|
url: `${API_PATH}/detail/${query}`,
|
|
method: "get",
|
|
});
|
|
},
|
|
|
|
getSiteOptions() {
|
|
return request<ApiResponse<SiteOption[]>>({
|
|
url: `${API_PATH}/options`,
|
|
method: "get",
|
|
});
|
|
},
|
|
|
|
createSite(body: SiteForm) {
|
|
return request<ApiResponse>({
|
|
url: `${API_PATH}/create`,
|
|
method: "post",
|
|
data: body,
|
|
});
|
|
},
|
|
|
|
updateSite(id: number, body: SiteForm) {
|
|
return request<ApiResponse>({
|
|
url: `${API_PATH}/update/${id}`,
|
|
method: "put",
|
|
data: body,
|
|
});
|
|
},
|
|
|
|
deleteSite(body: number[]) {
|
|
return request<ApiResponse>({
|
|
url: `${API_PATH}/delete`,
|
|
method: "delete",
|
|
data: body,
|
|
});
|
|
},
|
|
|
|
exportSite(body: SitePageQuery) {
|
|
return request<Blob>({
|
|
url: `${API_PATH}/export`,
|
|
method: "post",
|
|
data: body,
|
|
responseType: "blob",
|
|
});
|
|
},
|
|
|
|
downloadTemplateSite() {
|
|
return request<Blob>({
|
|
url: `${API_PATH}/download/template`,
|
|
method: "post",
|
|
responseType: "blob",
|
|
});
|
|
},
|
|
|
|
importSite(body: FormData) {
|
|
return request<ApiResponse>({
|
|
url: `${API_PATH}/import`,
|
|
method: "post",
|
|
data: body,
|
|
headers: {
|
|
"Content-Type": "multipart/form-data",
|
|
},
|
|
});
|
|
},
|
|
};
|
|
|
|
export default SiteAPI;
|
|
|
|
export interface SitePageQuery extends PageQuery, UserByQueryParams {
|
|
site_name?: string;
|
|
eco_type?: string;
|
|
}
|
|
|
|
export interface SiteOption {
|
|
value: number;
|
|
label: string;
|
|
}
|
|
|
|
export interface SiteTable extends BaseType {
|
|
site_name?: string;
|
|
address?: string;
|
|
area?: number;
|
|
longitude?: number;
|
|
latitude?: number;
|
|
eco_type?: string;
|
|
remark?: string;
|
|
}
|
|
|
|
export interface SiteForm extends BaseFormType {
|
|
site_name?: string;
|
|
address?: string;
|
|
area?: number;
|
|
longitude?: number;
|
|
latitude?: number;
|
|
eco_type?: string;
|
|
remark?: string;
|
|
}
|