update api
This commit is contained in:
+2
-2
@@ -1,5 +1,5 @@
|
|||||||
import { axios } from "./BaseAPI";
|
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";
|
const BASE_URI = "/user/role";
|
||||||
|
|
||||||
@@ -36,7 +36,7 @@ async function authorizedList(userId: string, moduleCode?: ModuleCode): Promise<
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async function authorize(req: UserRoleAuthorizeReq): Promise<void> {
|
async function authorize(req: AuthorizeUserRole): Promise<void> {
|
||||||
return axios.post(`${BASE_URI}/authorized/create`, req);
|
return axios.post(`${BASE_URI}/authorized/create`, req);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+5
-2
@@ -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 {axios} from "./BaseAPI";
|
||||||
import CommonAPI from "./CommonAPI";
|
import CommonAPI from "./CommonAPI";
|
||||||
|
|
||||||
@@ -6,6 +6,9 @@ const BASE_URI = "/user";
|
|||||||
type UserAttachmentOwner = {
|
type UserAttachmentOwner = {
|
||||||
attachmentList?: readonly Attachment[];
|
attachmentList?: readonly Attachment[];
|
||||||
};
|
};
|
||||||
|
type UpdateCurrentRequest = Omit<Partial<User>, "gender"> & {
|
||||||
|
gender?: Gender | "";
|
||||||
|
};
|
||||||
|
|
||||||
async function register(req: CaptchaData<RegisterRequest>): Promise<LoginResponse> {
|
async function register(req: CaptchaData<RegisterRequest>): Promise<LoginResponse> {
|
||||||
return await axios.post(`${BASE_URI}/register`, req);
|
return await axios.post(`${BASE_URI}/register`, req);
|
||||||
@@ -34,7 +37,7 @@ async function logout(): Promise<void> {
|
|||||||
return await axios.post(`${BASE_URI}/logout`);
|
return await axios.post(`${BASE_URI}/logout`);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function updateCurrent(req: Partial<User>): Promise<LoginResponse> {
|
async function updateCurrent(req: UpdateCurrentRequest): Promise<LoginResponse> {
|
||||||
return await axios.post(`${BASE_URI}/current/update`, req);
|
return await axios.post(`${BASE_URI}/current/update`, req);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+5
-8
@@ -1,21 +1,19 @@
|
|||||||
import type { ModuleCode, Permission } from "./Permission";
|
import type { ModuleCode, Permission } from "./Permission";
|
||||||
|
import { Model } from "./Model";
|
||||||
|
|
||||||
export interface Role {
|
export type Role = {
|
||||||
id: string;
|
|
||||||
moduleCode: ModuleCode;
|
moduleCode: ModuleCode;
|
||||||
code: string;
|
code: string;
|
||||||
nameLangId?: string;
|
nameLangId?: string;
|
||||||
name?: string;
|
name?: string;
|
||||||
description?: string;
|
description?: string;
|
||||||
|
|
||||||
permissionList?: Permission[];
|
permissionList?: Permission[];
|
||||||
allPermissionList?: Permission[];
|
allPermissionList?: Permission[];
|
||||||
childRoleList?: Role[];
|
childRoleList?: Role[];
|
||||||
permissionIdList?: string[];
|
permissionIdList?: string[];
|
||||||
childRoleIdList?: string[];
|
childRoleIdList?: string[];
|
||||||
createdAt?: number;
|
} & Model;
|
||||||
updatedAt?: number;
|
|
||||||
deletedAt?: number;
|
|
||||||
}
|
|
||||||
|
|
||||||
export type RolePayload = Pick<Role, "moduleCode" | "code" | "nameLangId" | "name" | "description"> & {
|
export type RolePayload = Pick<Role, "moduleCode" | "code" | "nameLangId" | "name" | "description"> & {
|
||||||
id?: string;
|
id?: string;
|
||||||
@@ -23,9 +21,8 @@ export type RolePayload = Pick<Role, "moduleCode" | "code" | "nameLangId" | "nam
|
|||||||
childRoleIdList?: string[];
|
childRoleIdList?: string[];
|
||||||
};
|
};
|
||||||
|
|
||||||
export interface UserRoleAuthorizeReq {
|
export interface AuthorizeUserRole {
|
||||||
userId: string;
|
userId: string;
|
||||||
moduleCode?: ModuleCode;
|
moduleCode?: ModuleCode;
|
||||||
roleIdList?: string[];
|
roleIdList?: string[];
|
||||||
roleCodeList?: string[];
|
|
||||||
}
|
}
|
||||||
|
|||||||
+6
-1
@@ -1,6 +1,9 @@
|
|||||||
import { ImageType, Model } from "./Model";
|
import { ImageType, Model } from "./Model";
|
||||||
import { Attachment } from "./Attachment";
|
import { Attachment } from "./Attachment";
|
||||||
import type { Setting } from "./Setting";
|
import type { Setting } from "./Setting";
|
||||||
|
import { Role } from "./Role";
|
||||||
|
|
||||||
|
export type Gender = "MALE" | "FEMALE";
|
||||||
|
|
||||||
export type User = {
|
export type User = {
|
||||||
name: string;
|
name: string;
|
||||||
@@ -13,7 +16,7 @@ export type User = {
|
|||||||
wrapperType?: ImageType;
|
wrapperType?: ImageType;
|
||||||
avatarType?: ImageType;
|
avatarType?: ImageType;
|
||||||
exp?: number;
|
exp?: number;
|
||||||
sex?: number;
|
gender?: Gender;
|
||||||
birthdate?: number;
|
birthdate?: number;
|
||||||
qq?: string;
|
qq?: string;
|
||||||
description?: string;
|
description?: string;
|
||||||
@@ -21,7 +24,9 @@ export type User = {
|
|||||||
lastLoginAt?: number;
|
lastLoginAt?: number;
|
||||||
unmuteAt?: number;
|
unmuteAt?: number;
|
||||||
unbanAt?: number;
|
unbanAt?: number;
|
||||||
|
|
||||||
roleList?: string[];
|
roleList?: string[];
|
||||||
|
roleEntityList?: Role[];
|
||||||
permissionList?: string[];
|
permissionList?: string[];
|
||||||
attachmentList?: Attachment[];
|
attachmentList?: Attachment[];
|
||||||
settingList?: Setting[];
|
settingList?: Setting[];
|
||||||
|
|||||||
Reference in New Issue
Block a user