初始化仓库
This commit is contained in:
13
src/service/displayEnumLabel.ts
Normal file
13
src/service/displayEnumLabel.ts
Normal file
@ -0,0 +1,13 @@
|
||||
/* eslint-disable */
|
||||
// @ts-ignore
|
||||
import * as API from './types';
|
||||
|
||||
export function displayStatusEnum(field: API.StatusEnum) {
|
||||
return { available: 'available', pending: 'pending', sold: 'sold' }[field];
|
||||
}
|
||||
|
||||
export function displayStatusEnum2(field: API.StatusEnum2) {
|
||||
return { placed: 'placed', approved: 'approved', delivered: 'delivered' }[
|
||||
field
|
||||
];
|
||||
}
|
||||
11
src/service/index.ts
Normal file
11
src/service/index.ts
Normal file
@ -0,0 +1,11 @@
|
||||
/* eslint-disable */
|
||||
// @ts-ignore
|
||||
export * from './types';
|
||||
export * from './displayEnumLabel';
|
||||
|
||||
export * from './pet';
|
||||
export * from './pet.vuequery';
|
||||
export * from './store';
|
||||
export * from './store.vuequery';
|
||||
export * from './user';
|
||||
export * from './user.vuequery';
|
||||
185
src/service/pet.ts
Normal file
185
src/service/pet.ts
Normal file
@ -0,0 +1,185 @@
|
||||
/* eslint-disable */
|
||||
// @ts-ignore
|
||||
import request from '@/http/vue-query';
|
||||
import type { CustomRequestOptions } from '@/http/types';
|
||||
|
||||
import * as API from './types';
|
||||
|
||||
/** Update an existing pet PUT /pet */
|
||||
export async function petUsingPut({
|
||||
body,
|
||||
options,
|
||||
}: {
|
||||
body: API.Pet;
|
||||
options?: CustomRequestOptions;
|
||||
}) {
|
||||
return request<unknown>('/pet', {
|
||||
method: 'PUT',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
data: body,
|
||||
...(options || {}),
|
||||
});
|
||||
}
|
||||
|
||||
/** Add a new pet to the store POST /pet */
|
||||
export async function petUsingPost({
|
||||
body,
|
||||
options,
|
||||
}: {
|
||||
body: API.Pet;
|
||||
options?: CustomRequestOptions;
|
||||
}) {
|
||||
return request<unknown>('/pet', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
data: body,
|
||||
...(options || {}),
|
||||
});
|
||||
}
|
||||
|
||||
/** Find pet by ID Returns a single pet GET /pet/${param0} */
|
||||
export async function petPetIdUsingGet({
|
||||
params,
|
||||
options,
|
||||
}: {
|
||||
// 叠加生成的Param类型 (非body参数openapi默认没有生成对象)
|
||||
params: API.petPetIdUsingGetParams;
|
||||
options?: CustomRequestOptions;
|
||||
}) {
|
||||
const { petId: param0, ...queryParams } = params;
|
||||
|
||||
return request<API.Pet>(`/pet/${param0}`, {
|
||||
method: 'GET',
|
||||
params: { ...queryParams },
|
||||
...(options || {}),
|
||||
});
|
||||
}
|
||||
|
||||
/** Updates a pet in the store with form data POST /pet/${param0} */
|
||||
export async function petPetIdUsingPost({
|
||||
params,
|
||||
body,
|
||||
options,
|
||||
}: {
|
||||
// 叠加生成的Param类型 (非body参数openapi默认没有生成对象)
|
||||
params: API.petPetIdUsingPostParams;
|
||||
body: API.PetPetIdUsingPostBody;
|
||||
options?: CustomRequestOptions;
|
||||
}) {
|
||||
const { petId: param0, ...queryParams } = params;
|
||||
|
||||
return request<unknown>(`/pet/${param0}`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
},
|
||||
params: { ...queryParams },
|
||||
data: body,
|
||||
...(options || {}),
|
||||
});
|
||||
}
|
||||
|
||||
/** Deletes a pet DELETE /pet/${param0} */
|
||||
export async function petPetIdUsingDelete({
|
||||
params,
|
||||
options,
|
||||
}: {
|
||||
// 叠加生成的Param类型 (非body参数openapi默认没有生成对象)
|
||||
params: API.petPetIdUsingDeleteParams;
|
||||
options?: CustomRequestOptions;
|
||||
}) {
|
||||
const { petId: param0, ...queryParams } = params;
|
||||
|
||||
return request<unknown>(`/pet/${param0}`, {
|
||||
method: 'DELETE',
|
||||
params: { ...queryParams },
|
||||
...(options || {}),
|
||||
});
|
||||
}
|
||||
|
||||
/** uploads an image POST /pet/${param0}/uploadImage */
|
||||
export async function petPetIdUploadImageUsingPost({
|
||||
params,
|
||||
body,
|
||||
file,
|
||||
options,
|
||||
}: {
|
||||
// 叠加生成的Param类型 (非body参数openapi默认没有生成对象)
|
||||
params: API.petPetIdUploadImageUsingPostParams;
|
||||
body: API.PetPetIdUploadImageUsingPostBody;
|
||||
file?: File;
|
||||
options?: CustomRequestOptions;
|
||||
}) {
|
||||
const { petId: param0, ...queryParams } = params;
|
||||
const formData = new FormData();
|
||||
|
||||
if (file) {
|
||||
formData.append('file', file);
|
||||
}
|
||||
|
||||
Object.keys(body).forEach((ele) => {
|
||||
const item = (body as { [key: string]: any })[ele];
|
||||
|
||||
if (item !== undefined && item !== null) {
|
||||
if (typeof item === 'object' && !(item instanceof File)) {
|
||||
if (item instanceof Array) {
|
||||
item.forEach((f) => formData.append(ele, f || ''));
|
||||
} else {
|
||||
formData.append(ele, JSON.stringify(item));
|
||||
}
|
||||
} else {
|
||||
formData.append(ele, item);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return request<API.ApiResponse>(`/pet/${param0}/uploadImage`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'multipart/form-data',
|
||||
},
|
||||
params: { ...queryParams },
|
||||
data: formData,
|
||||
...(options || {}),
|
||||
});
|
||||
}
|
||||
|
||||
/** Finds Pets by status Multiple status values can be provided with comma separated strings GET /pet/findByStatus */
|
||||
export async function petFindByStatusUsingGet({
|
||||
params,
|
||||
options,
|
||||
}: {
|
||||
// 叠加生成的Param类型 (非body参数openapi默认没有生成对象)
|
||||
params: API.petFindByStatusUsingGetParams;
|
||||
options?: CustomRequestOptions;
|
||||
}) {
|
||||
return request<API.Pet[]>('/pet/findByStatus', {
|
||||
method: 'GET',
|
||||
params: {
|
||||
...params,
|
||||
},
|
||||
...(options || {}),
|
||||
});
|
||||
}
|
||||
|
||||
/** Finds Pets by tags Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. GET /pet/findByTags */
|
||||
export async function petFindByTagsUsingGet({
|
||||
params,
|
||||
options,
|
||||
}: {
|
||||
// 叠加生成的Param类型 (非body参数openapi默认没有生成对象)
|
||||
params: API.petFindByTagsUsingGetParams;
|
||||
options?: CustomRequestOptions;
|
||||
}) {
|
||||
return request<API.Pet[]>('/pet/findByTags', {
|
||||
method: 'GET',
|
||||
params: {
|
||||
...params,
|
||||
},
|
||||
...(options || {}),
|
||||
});
|
||||
}
|
||||
151
src/service/pet.vuequery.ts
Normal file
151
src/service/pet.vuequery.ts
Normal file
@ -0,0 +1,151 @@
|
||||
/* eslint-disable */
|
||||
// @ts-ignore
|
||||
import { queryOptions, useMutation } from '@tanstack/vue-query';
|
||||
import type { DefaultError } from '@tanstack/vue-query';
|
||||
import request from '@/http/vue-query';
|
||||
import type { CustomRequestOptions } from '@/http/types';
|
||||
|
||||
import * as apis from './pet';
|
||||
import * as API from './types';
|
||||
|
||||
/** Update an existing pet PUT /pet */
|
||||
export function usePetUsingPutMutation(options?: {
|
||||
onSuccess?: (value?: unknown) => void;
|
||||
onError?: (error?: DefaultError) => void;
|
||||
}) {
|
||||
const { onSuccess, onError } = options || {};
|
||||
|
||||
const response = useMutation({
|
||||
mutationFn: apis.petUsingPut,
|
||||
onSuccess(data: unknown) {
|
||||
onSuccess?.(data);
|
||||
},
|
||||
onError(error) {
|
||||
onError?.(error);
|
||||
},
|
||||
});
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
/** Add a new pet to the store POST /pet */
|
||||
export function usePetUsingPostMutation(options?: {
|
||||
onSuccess?: (value?: unknown) => void;
|
||||
onError?: (error?: DefaultError) => void;
|
||||
}) {
|
||||
const { onSuccess, onError } = options || {};
|
||||
|
||||
const response = useMutation({
|
||||
mutationFn: apis.petUsingPost,
|
||||
onSuccess(data: unknown) {
|
||||
onSuccess?.(data);
|
||||
},
|
||||
onError(error) {
|
||||
onError?.(error);
|
||||
},
|
||||
});
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
/** Find pet by ID Returns a single pet GET /pet/${param0} */
|
||||
export function petPetIdUsingGetQueryOptions(options: {
|
||||
// 叠加生成的Param类型 (非body参数openapi默认没有生成对象)
|
||||
params: API.petPetIdUsingGetParams;
|
||||
options?: CustomRequestOptions;
|
||||
}) {
|
||||
return queryOptions({
|
||||
queryFn: async ({ queryKey }) => {
|
||||
return apis.petPetIdUsingGet(queryKey[1] as typeof options);
|
||||
},
|
||||
queryKey: ['petPetIdUsingGet', options],
|
||||
});
|
||||
}
|
||||
|
||||
/** Updates a pet in the store with form data POST /pet/${param0} */
|
||||
export function usePetPetIdUsingPostMutation(options?: {
|
||||
onSuccess?: (value?: unknown) => void;
|
||||
onError?: (error?: DefaultError) => void;
|
||||
}) {
|
||||
const { onSuccess, onError } = options || {};
|
||||
|
||||
const response = useMutation({
|
||||
mutationFn: apis.petPetIdUsingPost,
|
||||
onSuccess(data: unknown) {
|
||||
onSuccess?.(data);
|
||||
},
|
||||
onError(error) {
|
||||
onError?.(error);
|
||||
},
|
||||
});
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
/** Deletes a pet DELETE /pet/${param0} */
|
||||
export function usePetPetIdUsingDeleteMutation(options?: {
|
||||
onSuccess?: (value?: unknown) => void;
|
||||
onError?: (error?: DefaultError) => void;
|
||||
}) {
|
||||
const { onSuccess, onError } = options || {};
|
||||
|
||||
const response = useMutation({
|
||||
mutationFn: apis.petPetIdUsingDelete,
|
||||
onSuccess(data: unknown) {
|
||||
onSuccess?.(data);
|
||||
},
|
||||
onError(error) {
|
||||
onError?.(error);
|
||||
},
|
||||
});
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
/** uploads an image POST /pet/${param0}/uploadImage */
|
||||
export function usePetPetIdUploadImageUsingPostMutation(options?: {
|
||||
onSuccess?: (value?: API.ApiResponse) => void;
|
||||
onError?: (error?: DefaultError) => void;
|
||||
}) {
|
||||
const { onSuccess, onError } = options || {};
|
||||
|
||||
const response = useMutation({
|
||||
mutationFn: apis.petPetIdUploadImageUsingPost,
|
||||
onSuccess(data: API.ApiResponse) {
|
||||
onSuccess?.(data);
|
||||
},
|
||||
onError(error) {
|
||||
onError?.(error);
|
||||
},
|
||||
});
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
/** Finds Pets by status Multiple status values can be provided with comma separated strings GET /pet/findByStatus */
|
||||
export function petFindByStatusUsingGetQueryOptions(options: {
|
||||
// 叠加生成的Param类型 (非body参数openapi默认没有生成对象)
|
||||
params: API.petFindByStatusUsingGetParams;
|
||||
options?: CustomRequestOptions;
|
||||
}) {
|
||||
return queryOptions({
|
||||
queryFn: async ({ queryKey }) => {
|
||||
return apis.petFindByStatusUsingGet(queryKey[1] as typeof options);
|
||||
},
|
||||
queryKey: ['petFindByStatusUsingGet', options],
|
||||
});
|
||||
}
|
||||
|
||||
/** Finds Pets by tags Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. GET /pet/findByTags */
|
||||
export function petFindByTagsUsingGetQueryOptions(options: {
|
||||
// 叠加生成的Param类型 (非body参数openapi默认没有生成对象)
|
||||
params: API.petFindByTagsUsingGetParams;
|
||||
options?: CustomRequestOptions;
|
||||
}) {
|
||||
return queryOptions({
|
||||
queryFn: async ({ queryKey }) => {
|
||||
return apis.petFindByTagsUsingGet(queryKey[1] as typeof options);
|
||||
},
|
||||
queryKey: ['petFindByTagsUsingGet', options],
|
||||
});
|
||||
}
|
||||
72
src/service/store.ts
Normal file
72
src/service/store.ts
Normal file
@ -0,0 +1,72 @@
|
||||
/* eslint-disable */
|
||||
// @ts-ignore
|
||||
import request from '@/http/vue-query';
|
||||
import type { CustomRequestOptions } from '@/http/types';
|
||||
|
||||
import * as API from './types';
|
||||
|
||||
/** Returns pet inventories by status Returns a map of status codes to quantities GET /store/inventory */
|
||||
export async function storeInventoryUsingGet({
|
||||
options,
|
||||
}: {
|
||||
options?: CustomRequestOptions;
|
||||
}) {
|
||||
return request<Record<string, number>>('/store/inventory', {
|
||||
method: 'GET',
|
||||
...(options || {}),
|
||||
});
|
||||
}
|
||||
|
||||
/** Place an order for a pet POST /store/order */
|
||||
export async function storeOrderUsingPost({
|
||||
body,
|
||||
options,
|
||||
}: {
|
||||
body: API.Order;
|
||||
options?: CustomRequestOptions;
|
||||
}) {
|
||||
return request<API.Order>('/store/order', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
data: body,
|
||||
...(options || {}),
|
||||
});
|
||||
}
|
||||
|
||||
/** Find purchase order by ID For valid response try integer IDs with value >= 1 and <= 10. Other values will generated exceptions GET /store/order/${param0} */
|
||||
export async function storeOrderOrderIdUsingGet({
|
||||
params,
|
||||
options,
|
||||
}: {
|
||||
// 叠加生成的Param类型 (非body参数openapi默认没有生成对象)
|
||||
params: API.storeOrderOrderIdUsingGetParams;
|
||||
options?: CustomRequestOptions;
|
||||
}) {
|
||||
const { orderId: param0, ...queryParams } = params;
|
||||
|
||||
return request<API.Order>(`/store/order/${param0}`, {
|
||||
method: 'GET',
|
||||
params: { ...queryParams },
|
||||
...(options || {}),
|
||||
});
|
||||
}
|
||||
|
||||
/** Delete purchase order by ID For valid response try integer IDs with positive integer value. Negative or non-integer values will generate API errors DELETE /store/order/${param0} */
|
||||
export async function storeOrderOrderIdUsingDelete({
|
||||
params,
|
||||
options,
|
||||
}: {
|
||||
// 叠加生成的Param类型 (非body参数openapi默认没有生成对象)
|
||||
params: API.storeOrderOrderIdUsingDeleteParams;
|
||||
options?: CustomRequestOptions;
|
||||
}) {
|
||||
const { orderId: param0, ...queryParams } = params;
|
||||
|
||||
return request<unknown>(`/store/order/${param0}`, {
|
||||
method: 'DELETE',
|
||||
params: { ...queryParams },
|
||||
...(options || {}),
|
||||
});
|
||||
}
|
||||
75
src/service/store.vuequery.ts
Normal file
75
src/service/store.vuequery.ts
Normal file
@ -0,0 +1,75 @@
|
||||
/* eslint-disable */
|
||||
// @ts-ignore
|
||||
import { queryOptions, useMutation } from '@tanstack/vue-query';
|
||||
import type { DefaultError } from '@tanstack/vue-query';
|
||||
import request from '@/http/vue-query';
|
||||
import type { CustomRequestOptions } from '@/http/types';
|
||||
|
||||
import * as apis from './store';
|
||||
import * as API from './types';
|
||||
|
||||
/** Returns pet inventories by status Returns a map of status codes to quantities GET /store/inventory */
|
||||
export function storeInventoryUsingGetQueryOptions(options: {
|
||||
options?: CustomRequestOptions;
|
||||
}) {
|
||||
return queryOptions({
|
||||
queryFn: async ({ queryKey }) => {
|
||||
return apis.storeInventoryUsingGet(queryKey[1] as typeof options);
|
||||
},
|
||||
queryKey: ['storeInventoryUsingGet', options],
|
||||
});
|
||||
}
|
||||
|
||||
/** Place an order for a pet POST /store/order */
|
||||
export function useStoreOrderUsingPostMutation(options?: {
|
||||
onSuccess?: (value?: API.Order) => void;
|
||||
onError?: (error?: DefaultError) => void;
|
||||
}) {
|
||||
const { onSuccess, onError } = options || {};
|
||||
|
||||
const response = useMutation({
|
||||
mutationFn: apis.storeOrderUsingPost,
|
||||
onSuccess(data: API.Order) {
|
||||
onSuccess?.(data);
|
||||
},
|
||||
onError(error) {
|
||||
onError?.(error);
|
||||
},
|
||||
});
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
/** Find purchase order by ID For valid response try integer IDs with value >= 1 and <= 10. Other values will generated exceptions GET /store/order/${param0} */
|
||||
export function storeOrderOrderIdUsingGetQueryOptions(options: {
|
||||
// 叠加生成的Param类型 (非body参数openapi默认没有生成对象)
|
||||
params: API.storeOrderOrderIdUsingGetParams;
|
||||
options?: CustomRequestOptions;
|
||||
}) {
|
||||
return queryOptions({
|
||||
queryFn: async ({ queryKey }) => {
|
||||
return apis.storeOrderOrderIdUsingGet(queryKey[1] as typeof options);
|
||||
},
|
||||
queryKey: ['storeOrderOrderIdUsingGet', options],
|
||||
});
|
||||
}
|
||||
|
||||
/** Delete purchase order by ID For valid response try integer IDs with positive integer value. Negative or non-integer values will generate API errors DELETE /store/order/${param0} */
|
||||
export function useStoreOrderOrderIdUsingDeleteMutation(options?: {
|
||||
onSuccess?: (value?: unknown) => void;
|
||||
onError?: (error?: DefaultError) => void;
|
||||
}) {
|
||||
const { onSuccess, onError } = options || {};
|
||||
|
||||
const response = useMutation({
|
||||
mutationFn: apis.storeOrderOrderIdUsingDelete,
|
||||
onSuccess(data: unknown) {
|
||||
onSuccess?.(data);
|
||||
},
|
||||
onError(error) {
|
||||
onError?.(error);
|
||||
},
|
||||
});
|
||||
|
||||
return response;
|
||||
}
|
||||
146
src/service/types.ts
Normal file
146
src/service/types.ts
Normal file
@ -0,0 +1,146 @@
|
||||
/* eslint-disable */
|
||||
// @ts-ignore
|
||||
|
||||
export type ApiResponse = {
|
||||
code?: number;
|
||||
type?: string;
|
||||
message?: string;
|
||||
};
|
||||
|
||||
export type Category = {
|
||||
id?: number;
|
||||
name?: string;
|
||||
};
|
||||
|
||||
export type Order = {
|
||||
id?: number;
|
||||
petId?: number;
|
||||
quantity?: number;
|
||||
shipDate?: string;
|
||||
/** Order Status */
|
||||
status?: 'placed' | 'approved' | 'delivered';
|
||||
complete?: boolean;
|
||||
};
|
||||
|
||||
export type Pet = {
|
||||
id?: number;
|
||||
category?: Category;
|
||||
name: string;
|
||||
photoUrls: string[];
|
||||
tags?: Tag[];
|
||||
/** pet status in the store */
|
||||
status?: 'available' | 'pending' | 'sold';
|
||||
};
|
||||
|
||||
export type petFindByStatusUsingGetParams = {
|
||||
/** Status values that need to be considered for filter */
|
||||
status: ('available' | 'pending' | 'sold')[];
|
||||
};
|
||||
|
||||
export type petFindByTagsUsingGetParams = {
|
||||
/** Tags to filter by */
|
||||
tags: string[];
|
||||
};
|
||||
|
||||
export type PetPetIdUploadImageUsingPostBody = {
|
||||
/** Additional data to pass to server */
|
||||
additionalMetadata?: string;
|
||||
/** file to upload */
|
||||
file?: string;
|
||||
};
|
||||
|
||||
export type petPetIdUploadImageUsingPostParams = {
|
||||
/** ID of pet to update */
|
||||
petId: number;
|
||||
};
|
||||
|
||||
export type petPetIdUsingDeleteParams = {
|
||||
/** Pet id to delete */
|
||||
petId: number;
|
||||
};
|
||||
|
||||
export type petPetIdUsingGetParams = {
|
||||
/** ID of pet to return */
|
||||
petId: number;
|
||||
};
|
||||
|
||||
export type PetPetIdUsingPostBody = {
|
||||
/** Updated name of the pet */
|
||||
name?: string;
|
||||
/** Updated status of the pet */
|
||||
status?: string;
|
||||
};
|
||||
|
||||
export type petPetIdUsingPostParams = {
|
||||
/** ID of pet that needs to be updated */
|
||||
petId: number;
|
||||
};
|
||||
|
||||
export enum StatusEnum {
|
||||
'available' = 'available',
|
||||
'pending' = 'pending',
|
||||
'sold' = 'sold',
|
||||
}
|
||||
|
||||
export type IStatusEnum = keyof typeof StatusEnum;
|
||||
|
||||
export enum StatusEnum2 {
|
||||
'placed' = 'placed',
|
||||
'approved' = 'approved',
|
||||
'delivered' = 'delivered',
|
||||
}
|
||||
|
||||
export type IStatusEnum2 = keyof typeof StatusEnum2;
|
||||
|
||||
export type storeOrderOrderIdUsingDeleteParams = {
|
||||
/** ID of the order that needs to be deleted */
|
||||
orderId: number;
|
||||
};
|
||||
|
||||
export type storeOrderOrderIdUsingGetParams = {
|
||||
/** ID of pet that needs to be fetched */
|
||||
orderId: number;
|
||||
};
|
||||
|
||||
export type Tag = {
|
||||
id?: number;
|
||||
name?: string;
|
||||
};
|
||||
|
||||
export type User = {
|
||||
id?: number;
|
||||
username?: string;
|
||||
firstName?: string;
|
||||
lastName?: string;
|
||||
email?: string;
|
||||
password?: string;
|
||||
phone?: string;
|
||||
/** User Status */
|
||||
userStatus?: number;
|
||||
};
|
||||
|
||||
export type UserCreateWithArrayUsingPostBody = User[];
|
||||
|
||||
export type UserCreateWithListUsingPostBody = User[];
|
||||
|
||||
export type userLoginUsingGetParams = {
|
||||
/** The user name for login */
|
||||
username: string;
|
||||
/** The password for login in clear text */
|
||||
password: string;
|
||||
};
|
||||
|
||||
export type userUsernameUsingDeleteParams = {
|
||||
/** The name that needs to be deleted */
|
||||
username: string;
|
||||
};
|
||||
|
||||
export type userUsernameUsingGetParams = {
|
||||
/** The name that needs to be fetched. Use user1 for testing. */
|
||||
username: string;
|
||||
};
|
||||
|
||||
export type userUsernameUsingPutParams = {
|
||||
/** name that need to be updated */
|
||||
username: string;
|
||||
};
|
||||
150
src/service/user.ts
Normal file
150
src/service/user.ts
Normal file
@ -0,0 +1,150 @@
|
||||
/* eslint-disable */
|
||||
// @ts-ignore
|
||||
import request from '@/http/vue-query';
|
||||
import type { CustomRequestOptions } from '@/http/types';
|
||||
|
||||
import * as API from './types';
|
||||
|
||||
/** Create user This can only be done by the logged in user. 返回值: successful operation POST /user */
|
||||
export async function userUsingPost({
|
||||
body,
|
||||
options,
|
||||
}: {
|
||||
body: API.User;
|
||||
options?: CustomRequestOptions;
|
||||
}) {
|
||||
return request<unknown>('/user', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
data: body,
|
||||
...(options || {}),
|
||||
});
|
||||
}
|
||||
|
||||
/** Get user by user name GET /user/${param0} */
|
||||
export async function userUsernameUsingGet({
|
||||
params,
|
||||
options,
|
||||
}: {
|
||||
// 叠加生成的Param类型 (非body参数openapi默认没有生成对象)
|
||||
params: API.userUsernameUsingGetParams;
|
||||
options?: CustomRequestOptions;
|
||||
}) {
|
||||
const { username: param0, ...queryParams } = params;
|
||||
|
||||
return request<API.User>(`/user/${param0}`, {
|
||||
method: 'GET',
|
||||
params: { ...queryParams },
|
||||
...(options || {}),
|
||||
});
|
||||
}
|
||||
|
||||
/** Updated user This can only be done by the logged in user. PUT /user/${param0} */
|
||||
export async function userUsernameUsingPut({
|
||||
params,
|
||||
body,
|
||||
options,
|
||||
}: {
|
||||
// 叠加生成的Param类型 (非body参数openapi默认没有生成对象)
|
||||
params: API.userUsernameUsingPutParams;
|
||||
body: API.User;
|
||||
options?: CustomRequestOptions;
|
||||
}) {
|
||||
const { username: param0, ...queryParams } = params;
|
||||
|
||||
return request<unknown>(`/user/${param0}`, {
|
||||
method: 'PUT',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
params: { ...queryParams },
|
||||
data: body,
|
||||
...(options || {}),
|
||||
});
|
||||
}
|
||||
|
||||
/** Delete user This can only be done by the logged in user. DELETE /user/${param0} */
|
||||
export async function userUsernameUsingDelete({
|
||||
params,
|
||||
options,
|
||||
}: {
|
||||
// 叠加生成的Param类型 (非body参数openapi默认没有生成对象)
|
||||
params: API.userUsernameUsingDeleteParams;
|
||||
options?: CustomRequestOptions;
|
||||
}) {
|
||||
const { username: param0, ...queryParams } = params;
|
||||
|
||||
return request<unknown>(`/user/${param0}`, {
|
||||
method: 'DELETE',
|
||||
params: { ...queryParams },
|
||||
...(options || {}),
|
||||
});
|
||||
}
|
||||
|
||||
/** Creates list of users with given input array 返回值: successful operation POST /user/createWithArray */
|
||||
export async function userCreateWithArrayUsingPost({
|
||||
body,
|
||||
options,
|
||||
}: {
|
||||
body: API.UserCreateWithArrayUsingPostBody;
|
||||
options?: CustomRequestOptions;
|
||||
}) {
|
||||
return request<unknown>('/user/createWithArray', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
data: body,
|
||||
...(options || {}),
|
||||
});
|
||||
}
|
||||
|
||||
/** Creates list of users with given input array 返回值: successful operation POST /user/createWithList */
|
||||
export async function userCreateWithListUsingPost({
|
||||
body,
|
||||
options,
|
||||
}: {
|
||||
body: API.UserCreateWithListUsingPostBody;
|
||||
options?: CustomRequestOptions;
|
||||
}) {
|
||||
return request<unknown>('/user/createWithList', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
data: body,
|
||||
...(options || {}),
|
||||
});
|
||||
}
|
||||
|
||||
/** Logs user into the system GET /user/login */
|
||||
export async function userLoginUsingGet({
|
||||
params,
|
||||
options,
|
||||
}: {
|
||||
// 叠加生成的Param类型 (非body参数openapi默认没有生成对象)
|
||||
params: API.userLoginUsingGetParams;
|
||||
options?: CustomRequestOptions;
|
||||
}) {
|
||||
return request<string>('/user/login', {
|
||||
method: 'GET',
|
||||
params: {
|
||||
...params,
|
||||
},
|
||||
...(options || {}),
|
||||
});
|
||||
}
|
||||
|
||||
/** Logs out current logged in user session 返回值: successful operation GET /user/logout */
|
||||
export async function userLogoutUsingGet({
|
||||
options,
|
||||
}: {
|
||||
options?: CustomRequestOptions;
|
||||
}) {
|
||||
return request<unknown>('/user/logout', {
|
||||
method: 'GET',
|
||||
...(options || {}),
|
||||
});
|
||||
}
|
||||
149
src/service/user.vuequery.ts
Normal file
149
src/service/user.vuequery.ts
Normal file
@ -0,0 +1,149 @@
|
||||
/* eslint-disable */
|
||||
// @ts-ignore
|
||||
import { queryOptions, useMutation } from '@tanstack/vue-query';
|
||||
import type { DefaultError } from '@tanstack/vue-query';
|
||||
import request from '@/http/vue-query';
|
||||
import type { CustomRequestOptions } from '@/http/types';
|
||||
|
||||
import * as apis from './user';
|
||||
import * as API from './types';
|
||||
|
||||
/** Create user This can only be done by the logged in user. 返回值: successful operation POST /user */
|
||||
export function useUserUsingPostMutation(options?: {
|
||||
onSuccess?: (value?: unknown) => void;
|
||||
onError?: (error?: DefaultError) => void;
|
||||
}) {
|
||||
const { onSuccess, onError } = options || {};
|
||||
|
||||
const response = useMutation({
|
||||
mutationFn: apis.userUsingPost,
|
||||
onSuccess(data: unknown) {
|
||||
onSuccess?.(data);
|
||||
},
|
||||
onError(error) {
|
||||
onError?.(error);
|
||||
},
|
||||
});
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
/** Get user by user name GET /user/${param0} */
|
||||
export function userUsernameUsingGetQueryOptions(options: {
|
||||
// 叠加生成的Param类型 (非body参数openapi默认没有生成对象)
|
||||
params: API.userUsernameUsingGetParams;
|
||||
options?: CustomRequestOptions;
|
||||
}) {
|
||||
return queryOptions({
|
||||
queryFn: async ({ queryKey }) => {
|
||||
return apis.userUsernameUsingGet(queryKey[1] as typeof options);
|
||||
},
|
||||
queryKey: ['userUsernameUsingGet', options],
|
||||
});
|
||||
}
|
||||
|
||||
/** Updated user This can only be done by the logged in user. PUT /user/${param0} */
|
||||
export function useUserUsernameUsingPutMutation(options?: {
|
||||
onSuccess?: (value?: unknown) => void;
|
||||
onError?: (error?: DefaultError) => void;
|
||||
}) {
|
||||
const { onSuccess, onError } = options || {};
|
||||
|
||||
const response = useMutation({
|
||||
mutationFn: apis.userUsernameUsingPut,
|
||||
onSuccess(data: unknown) {
|
||||
onSuccess?.(data);
|
||||
},
|
||||
onError(error) {
|
||||
onError?.(error);
|
||||
},
|
||||
});
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
/** Delete user This can only be done by the logged in user. DELETE /user/${param0} */
|
||||
export function useUserUsernameUsingDeleteMutation(options?: {
|
||||
onSuccess?: (value?: unknown) => void;
|
||||
onError?: (error?: DefaultError) => void;
|
||||
}) {
|
||||
const { onSuccess, onError } = options || {};
|
||||
|
||||
const response = useMutation({
|
||||
mutationFn: apis.userUsernameUsingDelete,
|
||||
onSuccess(data: unknown) {
|
||||
onSuccess?.(data);
|
||||
},
|
||||
onError(error) {
|
||||
onError?.(error);
|
||||
},
|
||||
});
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
/** Creates list of users with given input array 返回值: successful operation POST /user/createWithArray */
|
||||
export function useUserCreateWithArrayUsingPostMutation(options?: {
|
||||
onSuccess?: (value?: unknown) => void;
|
||||
onError?: (error?: DefaultError) => void;
|
||||
}) {
|
||||
const { onSuccess, onError } = options || {};
|
||||
|
||||
const response = useMutation({
|
||||
mutationFn: apis.userCreateWithArrayUsingPost,
|
||||
onSuccess(data: unknown) {
|
||||
onSuccess?.(data);
|
||||
},
|
||||
onError(error) {
|
||||
onError?.(error);
|
||||
},
|
||||
});
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
/** Creates list of users with given input array 返回值: successful operation POST /user/createWithList */
|
||||
export function useUserCreateWithListUsingPostMutation(options?: {
|
||||
onSuccess?: (value?: unknown) => void;
|
||||
onError?: (error?: DefaultError) => void;
|
||||
}) {
|
||||
const { onSuccess, onError } = options || {};
|
||||
|
||||
const response = useMutation({
|
||||
mutationFn: apis.userCreateWithListUsingPost,
|
||||
onSuccess(data: unknown) {
|
||||
onSuccess?.(data);
|
||||
},
|
||||
onError(error) {
|
||||
onError?.(error);
|
||||
},
|
||||
});
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
/** Logs user into the system GET /user/login */
|
||||
export function userLoginUsingGetQueryOptions(options: {
|
||||
// 叠加生成的Param类型 (非body参数openapi默认没有生成对象)
|
||||
params: API.userLoginUsingGetParams;
|
||||
options?: CustomRequestOptions;
|
||||
}) {
|
||||
return queryOptions({
|
||||
queryFn: async ({ queryKey }) => {
|
||||
return apis.userLoginUsingGet(queryKey[1] as typeof options);
|
||||
},
|
||||
queryKey: ['userLoginUsingGet', options],
|
||||
});
|
||||
}
|
||||
|
||||
/** Logs out current logged in user session 返回值: successful operation GET /user/logout */
|
||||
export function userLogoutUsingGetQueryOptions(options: {
|
||||
options?: CustomRequestOptions;
|
||||
}) {
|
||||
return queryOptions({
|
||||
queryFn: async ({ queryKey }) => {
|
||||
return apis.userLogoutUsingGet(queryKey[1] as typeof options);
|
||||
},
|
||||
queryKey: ['userLogoutUsingGet', options],
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user