生产管理系统前端 - openapi - fetch生成器开发
This commit is contained in:
132
crop-x/src/lib/api/sdk.gen.ts
Normal file
132
crop-x/src/lib/api/sdk.gen.ts
Normal file
@@ -0,0 +1,132 @@
|
||||
// This file is auto-generated by @hey-api/openapi-ts
|
||||
|
||||
import type { Client, Options as Options2, TDataShape } from './client';
|
||||
import { client } from './client.gen';
|
||||
import type { GetAllUsersApiV1AuthUsersGetData, GetAllUsersApiV1AuthUsersGetResponses, GetCurrentUserApiV1AuthMeGetData, GetCurrentUserApiV1AuthMeGetResponses, HealthCheckHealthGetData, HealthCheckHealthGetResponses, LoginApiV1AuthLoginPostData, LoginApiV1AuthLoginPostErrors, LoginApiV1AuthLoginPostResponses, LogoutApiV1AuthLogoutPostData, LogoutApiV1AuthLogoutPostResponses, RegisterApiV1AuthRegisterPostData, RegisterApiV1AuthRegisterPostErrors, RegisterApiV1AuthRegisterPostResponses, RootGetData, RootGetResponses } from './types.gen';
|
||||
|
||||
export type Options<TData extends TDataShape = TDataShape, ThrowOnError extends boolean = boolean> = Options2<TData, ThrowOnError> & {
|
||||
/**
|
||||
* You can provide a client instance returned by `createClient()` instead of
|
||||
* individual options. This might be also useful if you want to implement a
|
||||
* custom client.
|
||||
*/
|
||||
client?: Client;
|
||||
/**
|
||||
* You can pass arbitrary values through the `meta` object. This can be
|
||||
* used to access values that aren't defined as part of the SDK function.
|
||||
*/
|
||||
meta?: Record<string, unknown>;
|
||||
};
|
||||
|
||||
/**
|
||||
* 用户登录
|
||||
*
|
||||
* 用户登录接口
|
||||
*
|
||||
* - **username**: 用户名
|
||||
* - **password**: 密码
|
||||
*
|
||||
* 返回JWT访问令牌
|
||||
*/
|
||||
export const loginApiV1AuthLoginPost = <ThrowOnError extends boolean = false>(options: Options<LoginApiV1AuthLoginPostData, ThrowOnError>) => {
|
||||
return (options.client ?? client).post<LoginApiV1AuthLoginPostResponses, LoginApiV1AuthLoginPostErrors, ThrowOnError>({
|
||||
url: '/api/v1/auth/login',
|
||||
...options,
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
...options.headers
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* 用户注册
|
||||
*
|
||||
* 用户注册接口
|
||||
*
|
||||
* - **username**: 用户名 (必须唯一)
|
||||
* - **password**: 密码
|
||||
*
|
||||
* 注意:这是一个演示版本,实际生产环境需要更严格的验证
|
||||
*/
|
||||
export const registerApiV1AuthRegisterPost = <ThrowOnError extends boolean = false>(options: Options<RegisterApiV1AuthRegisterPostData, ThrowOnError>) => {
|
||||
return (options.client ?? client).post<RegisterApiV1AuthRegisterPostResponses, RegisterApiV1AuthRegisterPostErrors, ThrowOnError>({
|
||||
url: '/api/v1/auth/register',
|
||||
...options,
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
...options.headers
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* 获取当前用户信息
|
||||
*
|
||||
* 获取当前登录用户的信息
|
||||
*/
|
||||
export const getCurrentUserApiV1AuthMeGet = <ThrowOnError extends boolean = false>(options?: Options<GetCurrentUserApiV1AuthMeGetData, ThrowOnError>) => {
|
||||
return (options?.client ?? client).get<GetCurrentUserApiV1AuthMeGetResponses, unknown, ThrowOnError>({
|
||||
security: [
|
||||
{
|
||||
scheme: 'bearer',
|
||||
type: 'http'
|
||||
}
|
||||
],
|
||||
url: '/api/v1/auth/me',
|
||||
...options
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* 用户登出
|
||||
*
|
||||
* 用户登出接口
|
||||
*
|
||||
* 注意:由于JWT是无状态的,实际登出需要客户端删除token
|
||||
* 这里只是验证token并返回成功消息
|
||||
*/
|
||||
export const logoutApiV1AuthLogoutPost = <ThrowOnError extends boolean = false>(options?: Options<LogoutApiV1AuthLogoutPostData, ThrowOnError>) => {
|
||||
return (options?.client ?? client).post<LogoutApiV1AuthLogoutPostResponses, unknown, ThrowOnError>({
|
||||
security: [
|
||||
{
|
||||
scheme: 'bearer',
|
||||
type: 'http'
|
||||
}
|
||||
],
|
||||
url: '/api/v1/auth/logout',
|
||||
...options
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* 获取所有用户列表
|
||||
*
|
||||
* 获取系统中所有用户的列表 (仅用于演示)
|
||||
*/
|
||||
export const getAllUsersApiV1AuthUsersGet = <ThrowOnError extends boolean = false>(options?: Options<GetAllUsersApiV1AuthUsersGetData, ThrowOnError>) => {
|
||||
return (options?.client ?? client).get<GetAllUsersApiV1AuthUsersGetResponses, unknown, ThrowOnError>({
|
||||
url: '/api/v1/auth/users',
|
||||
...options
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Root
|
||||
*/
|
||||
export const rootGet = <ThrowOnError extends boolean = false>(options?: Options<RootGetData, ThrowOnError>) => {
|
||||
return (options?.client ?? client).get<RootGetResponses, unknown, ThrowOnError>({
|
||||
url: '/',
|
||||
...options
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Health Check
|
||||
*/
|
||||
export const healthCheckHealthGet = <ThrowOnError extends boolean = false>(options?: Options<HealthCheckHealthGetData, ThrowOnError>) => {
|
||||
return (options?.client ?? client).get<HealthCheckHealthGetResponses, unknown, ThrowOnError>({
|
||||
url: '/health',
|
||||
...options
|
||||
});
|
||||
};
|
||||
Reference in New Issue
Block a user