From e5473eb49982672b47ec3ad4a61122c3375a2b43 Mon Sep 17 00:00:00 2001 From: Timi Date: Fri, 7 Aug 2026 19:44:42 +0800 Subject: [PATCH] update api --- src/api/RoleAPI.ts | 4 ++-- src/api/UserAPI.ts | 7 +++++-- src/types/Role.ts | 13 +++++-------- src/types/User.ts | 7 ++++++- 4 files changed, 18 insertions(+), 13 deletions(-) diff --git a/src/api/RoleAPI.ts b/src/api/RoleAPI.ts index bab927c..5d7e667 100644 --- a/src/api/RoleAPI.ts +++ b/src/api/RoleAPI.ts @@ -1,5 +1,5 @@ import { axios } from "./BaseAPI"; -import type { ModuleCode, Page, PageResult, Permission, Role, RolePayload, UserRoleAuthorizeReq } from "../types"; +import type { ModuleCode, Page, PageResult, Permission, Role, RolePayload, AuthorizeUserRole } from "../types"; const BASE_URI = "/user/role"; @@ -36,7 +36,7 @@ async function authorizedList(userId: string, moduleCode?: ModuleCode): Promise< }); } -async function authorize(req: UserRoleAuthorizeReq): Promise { +async function authorize(req: AuthorizeUserRole): Promise { return axios.post(`${BASE_URI}/authorized/create`, req); } diff --git a/src/api/UserAPI.ts b/src/api/UserAPI.ts index d710ab6..72b0a12 100644 --- a/src/api/UserAPI.ts +++ b/src/api/UserAPI.ts @@ -1,4 +1,4 @@ -import type {Attachment, CaptchaData, LoginRequest, LoginResponse, RegisterRequest, UpdatePasswordRequest, User, UserAttachType} from "../types"; +import type {Attachment, CaptchaData, Gender, LoginRequest, LoginResponse, RegisterRequest, UpdatePasswordRequest, User, UserAttachType} from "../types"; import {axios} from "./BaseAPI"; import CommonAPI from "./CommonAPI"; @@ -6,6 +6,9 @@ const BASE_URI = "/user"; type UserAttachmentOwner = { attachmentList?: readonly Attachment[]; }; +type UpdateCurrentRequest = Omit, "gender"> & { + gender?: Gender | ""; +}; async function register(req: CaptchaData): Promise { return await axios.post(`${BASE_URI}/register`, req); @@ -34,7 +37,7 @@ async function logout(): Promise { return await axios.post(`${BASE_URI}/logout`); } -async function updateCurrent(req: Partial): Promise { +async function updateCurrent(req: UpdateCurrentRequest): Promise { return await axios.post(`${BASE_URI}/current/update`, req); } diff --git a/src/types/Role.ts b/src/types/Role.ts index 6f99c23..690f226 100644 --- a/src/types/Role.ts +++ b/src/types/Role.ts @@ -1,21 +1,19 @@ import type { ModuleCode, Permission } from "./Permission"; +import { Model } from "./Model"; -export interface Role { - id: string; +export type Role = { moduleCode: ModuleCode; code: string; nameLangId?: string; name?: string; description?: string; + permissionList?: Permission[]; allPermissionList?: Permission[]; childRoleList?: Role[]; permissionIdList?: string[]; childRoleIdList?: string[]; - createdAt?: number; - updatedAt?: number; - deletedAt?: number; -} +} & Model; export type RolePayload = Pick & { id?: string; @@ -23,9 +21,8 @@ export type RolePayload = Pick