init
This commit is contained in:
67
src/data/box/box.requests.ts
Normal file
67
src/data/box/box.requests.ts
Normal file
@@ -0,0 +1,67 @@
|
||||
import { IBox, CreateBoxBodyType, UpdateBoxBodyType, IBoxDetail, BoxStatus } from '@/data/box/box.model';
|
||||
import { CommonResponseType, PageAble } from '@/helpers/types';
|
||||
import { request } from '@/services/request';
|
||||
import axios from 'axios';
|
||||
|
||||
export const box_requests = {
|
||||
async getAll(params?: {
|
||||
page?: number;
|
||||
sort?: string;
|
||||
direction?: string;
|
||||
cargoId?: string;
|
||||
partyId?: string | number;
|
||||
status?: BoxStatus;
|
||||
}) {
|
||||
return request.get<CommonResponseType<PageAble<IBox>>>('/packets/list', { params });
|
||||
},
|
||||
async changeStatus(params: { packetId: string | number; status: BoxStatus }) {
|
||||
return request.put('/packets/change', undefined, { params });
|
||||
},
|
||||
async create({ partyId, ...body }: CreateBoxBodyType) {
|
||||
return request.post<CommonResponseType>('/packets/create', body, {
|
||||
params: { partyId },
|
||||
});
|
||||
},
|
||||
async update({ packetId, ...body }: UpdateBoxBodyType) {
|
||||
return request.put<CommonResponseType>('/packets/update', body, {
|
||||
params: { packetId },
|
||||
});
|
||||
},
|
||||
async find(params: { packetId?: number | string }) {
|
||||
return request.get<CommonResponseType<IBoxDetail>>('/packets/find', { params });
|
||||
},
|
||||
async delete(params: { packetId: number | string }) {
|
||||
return request.delete<CommonResponseType>('/packets/delete', { params });
|
||||
},
|
||||
async downloadExcel(params: { packetId: number | string }) {
|
||||
return request.get<Blob>('/packets/download', { params, responseType: 'blob' });
|
||||
},
|
||||
async translateWithGoogleApi(params: { text: string }): Promise<string> {
|
||||
const response = await axios.post('https://translation.googleapis.com/language/translate/v2', undefined, {
|
||||
params: {
|
||||
q: params.text,
|
||||
target: 'ru',
|
||||
source: 'zh',
|
||||
key: 'AIzaSyA5uAPZyjF_yo1hYOWWJ2uP7XgcmohZc8o',
|
||||
},
|
||||
});
|
||||
|
||||
return response.data.data.translations?.[0]?.translatedText ?? '';
|
||||
},
|
||||
async translateWithMemoryApi(params: { text: string }): Promise<string> {
|
||||
const response = await axios.get<{
|
||||
responseData: {
|
||||
translatedText: string;
|
||||
match: number;
|
||||
};
|
||||
}>('https://api.mymemory.translated.net/get', {
|
||||
params: {
|
||||
q: params.text,
|
||||
langpair: 'zh|ru',
|
||||
// key: '7a4ac2e07cde1ff1e9de',
|
||||
},
|
||||
});
|
||||
|
||||
return response.data.responseData.translatedText;
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user