Parcourir la source

Revert "Merge branch 'openapi'"

This reverts commit 9a6f0acdf04827330535cc6fcfcdb9200da98638, reversing
changes made to 08a81e433bbc5aeb4b9eddc62a24d73628a4af2d.
feige996 il y a 7 mois
Parent
commit
3b14ab942f

+ 1 - 1
openapi-ts-request.config.ts

@@ -2,7 +2,7 @@ import type { GenerateServiceProps } from 'openapi-ts-request'
 
 export default [
   {
-    schemaPath: 'https://ukw0y1.laf.run/unibest-opapi-test.json',
+    schemaPath: 'http://petstore.swagger.io/v2/swagger.json',
     serversPath: './src/service',
     requestLibPath: `import request from '@/http/vue-query';\n import { CustomRequestOptions } from '@/http/types';`,
     requestOptionsType: 'CustomRequestOptions',

+ 1 - 1
package.json

@@ -87,7 +87,7 @@
     "build:quickapp-webview-huawei": "uni build -p quickapp-webview-huawei",
     "build:quickapp-webview-union": "uni build -p quickapp-webview-union",
     "type-check": "vue-tsc --noEmit",
-    "openapi": "openapi-ts",
+    "openapi-ts-request": "openapi-ts",
     "prepare": "git init && husky && node ./scripts/create-base-files.js",
     "docker:prepare": "node ./scripts/create-base-files.js",
     "lint": "eslint",

+ 17 - 20
src/hooks/useRequest.ts

@@ -19,14 +19,14 @@ interface IUseRequestReturn<T, P = undefined> {
 
 /**
  * useRequest是一个定制化的请求钩子,用于处理异步请求和响应。
- * @param func 一个执行异步请求的函数,返回HttpRequestResult<T>或Promise<HttpRequestResult<T>>
+ * @param func 一个执行异步请求的函数,返回一个包含响应数据的Promise
  * @param options 包含请求选项的对象 {immediate, initialData}。
  * @param options.immediate 是否立即执行请求,默认为false。
  * @param options.initialData 初始化数据,默认为undefined。
  * @returns 返回一个对象{loading, error, data, run},包含请求的加载状态、错误信息、响应数据和手动触发请求的函数。
  */
 export default function useRequest<T, P = undefined>(
-  func: (args?: P) => HttpRequestResult<T> | Promise<HttpRequestResult<T>>,
+  func: (args?: P) => HttpRequestResult<T>,
   options: IUseRequestOptions<T> = { immediate: false },
 ): IUseRequestReturn<T, P> {
   const loading = ref(false)
@@ -36,24 +36,21 @@ export default function useRequest<T, P = undefined>(
 
   const run = async (args?: P) => {
     loading.value = true
-    try {
-      // 支持同步和异步函数
-      const result = await func(args)
-      const { promise, requestTask: task } = result
-      requestTask = task // Store the requestTask
-
-      const res = await promise
-      data.value = res
-      error.value = false
-      return data.value
-    }
-    catch (err) {
-      error.value = err instanceof Error ? err : new Error('Request failed')
-      throw err
-    }
-    finally {
-      loading.value = false
-    }
+    const { promise, requestTask: task } = func(args)
+    requestTask = task // Store the requestTask
+    return promise
+      .then((res) => {
+        data.value = res
+        error.value = false
+        return data.value
+      })
+      .catch((err) => {
+        error.value = err
+        throw err
+      })
+      .finally(() => {
+        loading.value = false
+      })
   }
 
   const cancel = () => {

+ 2 - 2
src/http/http.ts

@@ -1,5 +1,5 @@
 import type { IDoubleTokenRes } from '@/api/types/login'
-import type { CustomRequestOptions, HttpRequestResult, IResponse } from '@/http/types'
+import type { CustomRequestOptions, IResponse } from '@/http/types'
 import { nextTick } from 'vue'
 import { LOGIN_PAGE } from '@/router/config'
 import { useTokenStore } from '@/store/token'
@@ -10,7 +10,7 @@ import { ResultEnum } from './tools/enum'
 let refreshing = false // 防止重复刷新 token 标识
 let taskQueue: { resolve: (value: any) => void, reject: (reason?: any) => void, options: CustomRequestOptions }[] = [] as { resolve: (value: any) => void, reject: (reason?: any) => void, options: CustomRequestOptions }[] // 刷新 token 请求队列
 
-export function http<T>(options: CustomRequestOptions): HttpRequestResult<T> {
+export function http<T>(options: CustomRequestOptions) {
   let requestTask: UniApp.RequestTask | undefined
   const promise = new Promise<T>((resolve, reject) => {
     requestTask = uni.request({

+ 2 - 2
src/http/vue-query.ts

@@ -1,4 +1,4 @@
-import type { CustomRequestOptions, HttpRequestResult } from '@/http/types'
+import type { CustomRequestOptions } from '@/http/types'
 import { http } from './http'
 
 /*
@@ -10,7 +10,7 @@ export default function request<T = unknown>(
     params?: Record<string, unknown>
     headers?: Record<string, unknown>
   },
-): HttpRequestResult<T> {
+) {
   const requestOptions = {
     url,
     ...options,

+ 0 - 2
src/pages/about/about.vue

@@ -3,7 +3,6 @@ import { isApp, isAppAndroid, isAppHarmony, isAppIOS, isAppPlus, isH5, isMpWeixi
 import { LOGIN_PAGE } from '@/router/config'
 import { useTokenStore } from '@/store'
 import { tabbarStore } from '@/tabbar/store'
-import RequestCompOpenApi from './components/request-openapi.vue'
 import RequestComp from './components/request.vue'
 import VBindCss from './components/VBindCss.vue'
 
@@ -114,7 +113,6 @@ onShow(() => {
     </button>
     <RequestComp />
     <VBindCss />
-    <RequestCompOpenApi />
     <view class="mb-6 h-1px bg-#eee" />
     <view class="text-center">
       <button type="primary" size="mini" class="w-160px" @click="gotoAlova">

+ 0 - 67
src/pages/about/components/request-openapi.vue

@@ -1,67 +0,0 @@
-<script lang="ts" setup>
-import type { UserItem } from '@/service'
-import { ref } from 'vue'
-import useRequest from '@/hooks/useRequest'
-import { infoUsingGet } from '@/service/info'
-
-const loading = ref(false)
-const error = ref<Error | null>(null)
-const data = ref<UserItem>()
-
-async function getUserInfo() {
-  try {
-    loading.value = true
-    // 直接使用openapi生成的请求,需要解构获取promise
-    const { promise } = await infoUsingGet({})
-    const res = await promise
-    console.log(res)
-    data.value = res
-    error.value = null
-  }
-  catch (err) {
-    error.value = err as Error
-    data.value = null
-  }
-  finally {
-    loading.value = false
-  }
-}
-
-// 使用openapi + useRequest生成的请求
-const { data: data2, loading: loading2, run } = useRequest<UserItem>(() => infoUsingGet({}), {
-  immediate: false,
-})
-</script>
-
-<template>
-  <view class="p-6 text-center">
-    <view class="my-4 text-center">
-      1)直接使用 openapi 生成的请求
-    </view>
-    <view class="my-4 text-center">
-      <button type="primary" size="mini" class="w-160px" @click="getUserInfo">
-        发送请求
-      </button>
-      <view class="text-xl">
-        请求数据如下
-      </view>
-      <view class="text-green leading-8">
-        {{ JSON.stringify(data) }}
-      </view>
-    </view>
-    <view class="my-4 text-center">
-      2)直接使用 openapi + useRequest 生成的请求
-    </view>
-    <view class="my-4 text-center">
-      <button type="primary" size="mini" class="w-160px" @click="run">
-        发送请求
-      </button>
-      <view class="text-xl">
-        请求数据如下
-      </view>
-      <view class="text-green leading-8">
-        {{ JSON.stringify(data2) }}
-      </view>
-    </view>
-  </view>
-</template>

+ 13 - 0
src/service/displayEnumLabel.ts

@@ -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
+  ];
+}

+ 4 - 2
src/service/index.ts

@@ -1,6 +1,8 @@
 /* eslint-disable */
 // @ts-ignore
 export * from './types';
+export * from './displayEnumLabel';
 
-export * from './listAll';
-export * from './info';
+export * from './pet';
+export * from './store';
+export * from './user';

+ 0 - 18
src/service/info.ts

@@ -1,18 +0,0 @@
-/* eslint-disable */
-// @ts-ignore
-import request from '@/http/vue-query';
-import { CustomRequestOptions } from '@/http/types';
-
-import * as API from './types';
-
-/** 用户信息 GET /user/info */
-export async function infoUsingGet({
-  options,
-}: {
-  options?: CustomRequestOptions;
-}) {
-  return request<API.UserItem>('/user/info', {
-    method: 'GET',
-    ...(options || {}),
-  });
-}

+ 0 - 18
src/service/listAll.ts

@@ -1,18 +0,0 @@
-/* eslint-disable */
-// @ts-ignore
-import request from '@/http/vue-query';
-import { CustomRequestOptions } from '@/http/types';
-
-import * as API from './types';
-
-/** 用户列表 GET /user/listAll */
-export async function listAllUsingGet({
-  options,
-}: {
-  options?: CustomRequestOptions;
-}) {
-  return request<API.UserItem[]>('/user/listAll', {
-    method: 'GET',
-    ...(options || {}),
-  });
-}

+ 185 - 0
src/service/pet.ts

@@ -0,0 +1,185 @@
+/* eslint-disable */
+// @ts-ignore
+import request from '@/http/vue-query';
+import { 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 || {}),
+  });
+}

+ 72 - 0
src/service/store.ts

@@ -0,0 +1,72 @@
+/* eslint-disable */
+// @ts-ignore
+import request from '@/http/vue-query';
+import { 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 || {}),
+  });
+}

+ 337 - 16
src/service/types.ts

@@ -1,29 +1,350 @@
 /* eslint-disable */
 // @ts-ignore
 
-export type InfoUsingGetResponse = {
-  code: number;
-  msg: string;
-  data: UserItem;
+export type ApiResponse = {
+  code?: number;
+  type?: string;
+  message?: string;
 };
 
-export type InfoUsingGetResponses = {
-  200: InfoUsingGetResponse;
+export type Category = {
+  id?: number;
+  name?: string;
 };
 
-export type ListAllUsingGetResponse = {
-  code: number;
-  msg: string;
-  data: UserItem[];
+export type Order = {
+  id?: number;
+  petId?: number;
+  quantity?: number;
+  shipDate?: string;
+  /** Order Status */
+  status?: 'placed' | 'approved' | 'delivered';
+  complete?: boolean;
 };
 
-export type ListAllUsingGetResponses = {
-  200: ListAllUsingGetResponse;
+export type Pet = {
+  id?: number;
+  category?: Category;
+  name: string;
+  photoUrls: string[];
+  tags?: Tag[];
+  /** pet status in the store */
+  status?: 'available' | 'pending' | 'sold';
 };
 
-export type UserItem = {
-  userId: number;
+export type PetFindByStatusUsingGetParams = {
+  /** Status values that need to be considered for filter */
+  status: ('available' | 'pending' | 'sold')[];
+};
+
+export type PetFindByStatusUsingGetResponses = {
+  /**
+   * successful operation
+   */
+  200: Pet[];
+  /**
+   * Invalid status value
+   */
+  400: unknown;
+};
+
+export type PetFindByTagsUsingGetParams = {
+  /** Tags to filter by */
+  tags: string[];
+};
+
+export type PetFindByTagsUsingGetResponses = {
+  /**
+   * successful operation
+   */
+  200: Pet[];
+  /**
+   * Invalid tag value
+   */
+  400: unknown;
+};
+
+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 PetPetIdUploadImageUsingPostResponses = {
+  /**
+   * successful operation
+   */
+  200: ApiResponse;
+};
+
+export type PetPetIdUsingDeleteParams = {
+  /** Pet id to delete */
+  petId: number;
+};
+
+export type PetPetIdUsingDeleteResponses = {
+  /**
+   * Invalid ID supplied
+   */
+  400: unknown;
+  /**
+   * Pet not found
+   */
+  404: unknown;
+};
+
+export type PetPetIdUsingGetParams = {
+  /** ID of pet to return */
+  petId: number;
+};
+
+export type PetPetIdUsingGetResponses = {
+  /**
+   * successful operation
+   */
+  200: Pet;
+  /**
+   * Invalid ID supplied
+   */
+  400: unknown;
+  /**
+   * Pet not found
+   */
+  404: unknown;
+};
+
+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 type PetPetIdUsingPostResponses = {
+  /**
+   * Invalid input
+   */
+  405: unknown;
+};
+
+export type PetUsingPostResponses = {
+  /**
+   * Invalid input
+   */
+  405: unknown;
+};
+
+export type PetUsingPutResponses = {
+  /**
+   * Invalid ID supplied
+   */
+  400: unknown;
+  /**
+   * Pet not found
+   */
+  404: unknown;
+  /**
+   * Validation exception
+   */
+  405: unknown;
+};
+
+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 StoreInventoryUsingGetResponses = {
+  /**
+   * successful operation
+   */
+  200: Record<string, number>;
+};
+
+export type StoreOrderOrderIdUsingDeleteParams = {
+  /** ID of the order that needs to be deleted */
+  orderId: number;
+};
+
+export type StoreOrderOrderIdUsingDeleteResponses = {
+  /**
+   * Invalid ID supplied
+   */
+  400: unknown;
+  /**
+   * Order not found
+   */
+  404: unknown;
+};
+
+export type StoreOrderOrderIdUsingGetParams = {
+  /** ID of pet that needs to be fetched */
+  orderId: number;
+};
+
+export type StoreOrderOrderIdUsingGetResponses = {
+  /**
+   * successful operation
+   */
+  200: Order;
+  /**
+   * Invalid ID supplied
+   */
+  400: unknown;
+  /**
+   * Order not found
+   */
+  404: unknown;
+};
+
+export type StoreOrderUsingPostResponses = {
+  /**
+   * successful operation
+   */
+  200: Order;
+  /**
+   * Invalid Order
+   */
+  400: unknown;
+};
+
+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 UserCreateWithArrayUsingPostResponses = {
+  /**
+   * successful operation
+   */
+  default: unknown;
+};
+
+export type UserCreateWithListUsingPostBody = User[];
+
+export type UserCreateWithListUsingPostResponses = {
+  /**
+   * successful operation
+   */
+  default: unknown;
+};
+
+export type UserLoginUsingGetParams = {
+  /** The user name for login */
   username: string;
-  nickname: string;
-  avatar: string;
+  /** The password for login in clear text */
+  password: string;
+};
+
+export type UserLoginUsingGetResponses = {
+  /**
+   * successful operation
+   */
+  200: string;
+  /**
+   * Invalid username/password supplied
+   */
+  400: unknown;
+};
+
+export type UserLogoutUsingGetResponses = {
+  /**
+   * successful operation
+   */
+  default: unknown;
+};
+
+export type UserUsernameUsingDeleteParams = {
+  /** The name that needs to be deleted */
+  username: string;
+};
+
+export type UserUsernameUsingDeleteResponses = {
+  /**
+   * Invalid username supplied
+   */
+  400: unknown;
+  /**
+   * User not found
+   */
+  404: unknown;
+};
+
+export type UserUsernameUsingGetParams = {
+  /** The name that needs to be fetched. Use user1 for testing.  */
+  username: string;
+};
+
+export type UserUsernameUsingGetResponses = {
+  /**
+   * successful operation
+   */
+  200: User;
+  /**
+   * Invalid username supplied
+   */
+  400: unknown;
+  /**
+   * User not found
+   */
+  404: unknown;
+};
+
+export type UserUsernameUsingPutParams = {
+  /** name that need to be updated */
+  username: string;
+};
+
+export type UserUsernameUsingPutResponses = {
+  /**
+   * Invalid user supplied
+   */
+  400: unknown;
+  /**
+   * User not found
+   */
+  404: unknown;
+};
+
+export type UserUsingPostResponses = {
+  /**
+   * successful operation
+   */
+  default: unknown;
 };

+ 150 - 0
src/service/user.ts

@@ -0,0 +1,150 @@
+/* eslint-disable */
+// @ts-ignore
+import request from '@/http/vue-query';
+import { 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 || {}),
+  });
+}