Quellcode durchsuchen

# api:用户管理模块的api(通过orval生成)

yang yi vor 1 Woche
Ursprung
Commit
ba7bec7a3f

+ 10 - 0
src/api/models/deleteByIdParams.ts

@@ -0,0 +1,10 @@
+/**
+ * Generated by orval v7.0.1 🍺
+ * Do not edit manually.
+ * OpenAPI definition
+ * OpenAPI spec version: v0
+ */
+
+export type DeleteByIdParams = {
+  ids: string[];
+};

+ 17 - 0
src/api/models/fieldError.ts

@@ -0,0 +1,17 @@
+/**
+ * Generated by orval v7.0.1 🍺
+ * Do not edit manually.
+ * OpenAPI definition
+ * OpenAPI spec version: v0
+ */
+
+export interface FieldError {
+  arguments?: unknown[];
+  bindingFailure?: boolean;
+  code?: string;
+  codes?: string[];
+  defaultMessage?: string;
+  field?: string;
+  objectName?: string;
+  rejectedValue?: unknown;
+}

+ 21 - 0
src/api/models/index.ts

@@ -0,0 +1,21 @@
+/**
+ * Generated by orval v7.0.1 🍺
+ * Do not edit manually.
+ * OpenAPI definition
+ * OpenAPI spec version: v0
+ */
+
+export * from "./deleteByIdParams";
+export * from "./fieldError";
+export * from "./pageVoListUserVo";
+export * from "./queryByPageParams";
+export * from "./response";
+export * from "./responseBoolean";
+export * from "./responseListFieldError";
+export * from "./responsePageVoListUserVo";
+export * from "./responseUserVo";
+export * from "./updateUserAvatarDto";
+export * from "./updateUserPasswordDto";
+export * from "./updateUserStatusDto";
+export * from "./userDto";
+export * from "./userVo";

+ 17 - 0
src/api/models/pageVoListUserVo.ts

@@ -0,0 +1,17 @@
+/**
+ * Generated by orval v7.0.1 🍺
+ * Do not edit manually.
+ * OpenAPI definition
+ * OpenAPI spec version: v0
+ */
+import type { UserVo } from "./userVo";
+
+/**
+ * 分页数据对象
+ */
+export interface PageVoListUserVo {
+  /** 当前页的数据 */
+  data?: UserVo[];
+  /** 总数据条数 */
+  total?: number;
+}

+ 15 - 0
src/api/models/queryByPageParams.ts

@@ -0,0 +1,15 @@
+/**
+ * Generated by orval v7.0.1 🍺
+ * Do not edit manually.
+ * OpenAPI definition
+ * OpenAPI spec version: v0
+ */
+
+export type QueryByPageParams = {
+  account: string;
+  username: string;
+  role: string;
+  enable?: number;
+  pageNum?: number;
+  pageSize?: number;
+};

+ 18 - 0
src/api/models/response.ts

@@ -0,0 +1,18 @@
+/**
+ * Generated by orval v7.0.1 🍺
+ * Do not edit manually.
+ * OpenAPI definition
+ * OpenAPI spec version: v0
+ */
+
+/**
+ * 后端统一的响应实体
+ */
+export interface Response {
+  /** 状态码;200:成功 */
+  code?: number;
+  /** 响应的具体数据 */
+  data?: unknown;
+  /** 响应附加信息 */
+  message?: string;
+}

+ 18 - 0
src/api/models/responseBoolean.ts

@@ -0,0 +1,18 @@
+/**
+ * Generated by orval v7.0.1 🍺
+ * Do not edit manually.
+ * OpenAPI definition
+ * OpenAPI spec version: v0
+ */
+
+/**
+ * 后端统一的响应实体
+ */
+export interface ResponseBoolean {
+  /** 状态码;200:成功 */
+  code?: number;
+  /** 响应的具体数据 */
+  data?: boolean;
+  /** 响应附加信息 */
+  message?: string;
+}

+ 19 - 0
src/api/models/responseListFieldError.ts

@@ -0,0 +1,19 @@
+/**
+ * Generated by orval v7.0.1 🍺
+ * Do not edit manually.
+ * OpenAPI definition
+ * OpenAPI spec version: v0
+ */
+import type { FieldError } from "./fieldError";
+
+/**
+ * 后端统一的响应实体
+ */
+export interface ResponseListFieldError {
+  /** 状态码;200:成功 */
+  code?: number;
+  /** 响应的具体数据 */
+  data?: FieldError[];
+  /** 响应附加信息 */
+  message?: string;
+}

+ 19 - 0
src/api/models/responsePageVoListUserVo.ts

@@ -0,0 +1,19 @@
+/**
+ * Generated by orval v7.0.1 🍺
+ * Do not edit manually.
+ * OpenAPI definition
+ * OpenAPI spec version: v0
+ */
+import type { PageVoListUserVo } from "./pageVoListUserVo";
+
+/**
+ * 后端统一的响应实体
+ */
+export interface ResponsePageVoListUserVo {
+  /** 状态码;200:成功 */
+  code?: number;
+  /** 响应的具体数据 */
+  data?: PageVoListUserVo;
+  /** 响应附加信息 */
+  message?: string;
+}

+ 19 - 0
src/api/models/responseUserVo.ts

@@ -0,0 +1,19 @@
+/**
+ * Generated by orval v7.0.1 🍺
+ * Do not edit manually.
+ * OpenAPI definition
+ * OpenAPI spec version: v0
+ */
+import type { UserVo } from "./userVo";
+
+/**
+ * 后端统一的响应实体
+ */
+export interface ResponseUserVo {
+  /** 状态码;200:成功 */
+  code?: number;
+  /** 响应的具体数据 */
+  data?: UserVo;
+  /** 响应附加信息 */
+  message?: string;
+}

+ 23 - 0
src/api/models/updateUserAvatarDto.ts

@@ -0,0 +1,23 @@
+/**
+ * Generated by orval v7.0.1 🍺
+ * Do not edit manually.
+ * OpenAPI definition
+ * OpenAPI spec version: v0
+ */
+
+/**
+ * 更新用户头像的实体DTO
+ */
+export interface UpdateUserAvatarDto {
+  /**
+   * 头像地址的链接
+   * @minLength 1
+   * @pattern ^(https?)://[^\s/$.?#].[^\s]*$
+   */
+  avatar: string;
+  /**
+   * 用户的ID
+   * @minLength 1
+   */
+  id: string;
+}

+ 29 - 0
src/api/models/updateUserPasswordDto.ts

@@ -0,0 +1,29 @@
+/**
+ * Generated by orval v7.0.1 🍺
+ * Do not edit manually.
+ * OpenAPI definition
+ * OpenAPI spec version: v0
+ */
+
+/**
+ * 用户密码修改使用的DTO
+ */
+export interface UpdateUserPasswordDto {
+  /**
+   * 用户ID
+   * @minLength 1
+   */
+  id: string;
+  /**
+   * 用户的新密码
+   * @minLength 4
+   * @maxLength 20
+   */
+  oldPassword: string;
+  /**
+   * 用户的当前密码
+   * @minLength 4
+   * @maxLength 20
+   */
+  password: string;
+}

+ 23 - 0
src/api/models/updateUserStatusDto.ts

@@ -0,0 +1,23 @@
+/**
+ * Generated by orval v7.0.1 🍺
+ * Do not edit manually.
+ * OpenAPI definition
+ * OpenAPI spec version: v0
+ */
+
+/**
+ * 用户状态更新使用的DTO
+ */
+export interface UpdateUserStatusDto {
+  /**
+   * 更新后的状态;1:启用,0:禁用
+   * @minimum 0
+   * @maximum 1
+   */
+  enable: number;
+  /**
+   * 用户ID
+   * @minLength 1
+   */
+  id: string;
+}

+ 38 - 0
src/api/models/userDto.ts

@@ -0,0 +1,38 @@
+/**
+ * Generated by orval v7.0.1 🍺
+ * Do not edit manually.
+ * OpenAPI definition
+ * OpenAPI spec version: v0
+ */
+
+/**
+ * 用户新增和修改使用的DTO
+ */
+export interface UserDto {
+  /**
+   * 用户账号
+   * @minLength 4
+   * @maxLength 20
+   */
+  account: string;
+  /** 用户ID */
+  id?: string;
+  /**
+   * 用户密码
+   * @minLength 4
+   * @maxLength 20
+   */
+  password: string;
+  /**
+   * 用户角色
+   * @minLength 4
+   * @maxLength 32
+   */
+  role: string;
+  /**
+   * 用户名称
+   * @minLength 2
+   * @maxLength 32
+   */
+  username: string;
+}

+ 24 - 0
src/api/models/userVo.ts

@@ -0,0 +1,24 @@
+/**
+ * Generated by orval v7.0.1 🍺
+ * Do not edit manually.
+ * OpenAPI definition
+ * OpenAPI spec version: v0
+ */
+
+/**
+ * 用户响应展示对象
+ */
+export interface UserVo {
+  /** 用户账号 */
+  account?: string;
+  /** 用户头像地址 */
+  avatar?: string;
+  /** 用户状态;0:禁用,1:启用 */
+  enable?: number;
+  /** 用户ID */
+  id?: string;
+  /** 用户角色 */
+  role?: string;
+  /** 用户名称 */
+  username?: string;
+}

+ 116 - 0
src/api/user-controller.ts

@@ -0,0 +1,116 @@
+/**
+ * Generated by orval v7.0.1 🍺
+ * Do not edit manually.
+ * OpenAPI definition
+ * OpenAPI spec version: v0
+ */
+import type {
+  DeleteByIdParams,
+  QueryByPageParams,
+  Response,
+  ResponseBoolean,
+  ResponsePageVoListUserVo,
+  ResponseUserVo,
+  UpdateUserAvatarDto,
+  UpdateUserPasswordDto,
+  UpdateUserStatusDto,
+  UserDto,
+} from "./models";
+import { customAxiosInstance } from "../util/axios-instance";
+
+export const getUserController = () => {
+  const queryByPage = (params: QueryByPageParams) => {
+    return customAxiosInstance<ResponsePageVoListUserVo>({
+      url: `/user`,
+      method: "GET",
+      params,
+    });
+  };
+  const edit = (userDto: UserDto) => {
+    return customAxiosInstance<ResponseBoolean>({
+      url: `/user`,
+      method: "PUT",
+      headers: { "Content-Type": "application/json" },
+      data: userDto,
+    });
+  };
+  const add = (userDto: UserDto) => {
+    return customAxiosInstance<ResponseBoolean>({
+      url: `/user`,
+      method: "POST",
+      headers: { "Content-Type": "application/json" },
+      data: userDto,
+    });
+  };
+  const deleteById = (params: DeleteByIdParams) => {
+    return customAxiosInstance<ResponseBoolean>({
+      url: `/user`,
+      method: "DELETE",
+      params,
+    });
+  };
+  const updateUserStatus = (updateUserStatusDto: UpdateUserStatusDto) => {
+    return customAxiosInstance<Response>({
+      url: `/user/updateStatus`,
+      method: "PUT",
+      headers: { "Content-Type": "application/json" },
+      data: updateUserStatusDto,
+    });
+  };
+  const updatePassword = (updateUserPasswordDto: UpdateUserPasswordDto) => {
+    return customAxiosInstance<Response>({
+      url: `/user/updatePassword`,
+      method: "PUT",
+      headers: { "Content-Type": "application/json" },
+      data: updateUserPasswordDto,
+    });
+  };
+  const updateUserAvatar = (updateUserAvatarDto: UpdateUserAvatarDto) => {
+    return customAxiosInstance<Response>({
+      url: `/user/updateAvatar`,
+      method: "PUT",
+      headers: { "Content-Type": "application/json" },
+      data: updateUserAvatarDto,
+    });
+  };
+  const queryById = (id: string) => {
+    return customAxiosInstance<ResponseUserVo>({
+      url: `/user/${id}`,
+      method: "GET",
+    });
+  };
+  return {
+    queryByPage,
+    edit,
+    add,
+    deleteById,
+    updateUserStatus,
+    updatePassword,
+    updateUserAvatar,
+    queryById,
+  };
+};
+export type QueryByPageResult = NonNullable<
+  Awaited<ReturnType<ReturnType<typeof getUserController>["queryByPage"]>>
+>;
+export type EditResult = NonNullable<
+  Awaited<ReturnType<ReturnType<typeof getUserController>["edit"]>>
+>;
+export type AddResult = NonNullable<
+  Awaited<ReturnType<ReturnType<typeof getUserController>["add"]>>
+>;
+export type DeleteByIdResult = NonNullable<
+  Awaited<ReturnType<ReturnType<typeof getUserController>["deleteById"]>>
+>;
+export type UpdateUserStatusResult = NonNullable<
+  Awaited<ReturnType<ReturnType<typeof getUserController>["updateUserStatus"]>>
+>;
+export type UpdatePasswordResult = NonNullable<
+  Awaited<ReturnType<ReturnType<typeof getUserController>["updatePassword"]>>
+>;
+export type UpdateUserAvatarResult = NonNullable<
+  Awaited<ReturnType<ReturnType<typeof getUserController>["updateUserAvatar"]>>
+>;
+export type QueryByIdResult = NonNullable<
+  Awaited<ReturnType<ReturnType<typeof getUserController>["queryById"]>>
+>;