feat: 接入权限接口
This commit is contained in:
@@ -14,12 +14,11 @@ import type {
|
||||
UserImportCommitRequest,
|
||||
UserImportJobResponseDto,
|
||||
UserImportPreviewResponseDto,
|
||||
UserManagementUpdateRequest,
|
||||
UserListResponse,
|
||||
UserQuery,
|
||||
UserRecord,
|
||||
UserResponseDto,
|
||||
UserRolesResponseDto,
|
||||
UserRoleSummaryDto,
|
||||
UserRolesUpdateRequest,
|
||||
} from './types'
|
||||
|
||||
@@ -106,7 +105,6 @@ function mapUser(dto: UserResponseDto): UserRecord {
|
||||
departmentName: dto.departmentName ?? undefined,
|
||||
roleNames,
|
||||
roleIds: roles.map((role) => role.id),
|
||||
dataScope: dto.dataScope ?? '—',
|
||||
version: dto.version ?? undefined,
|
||||
passwordChangeRequired: dto.passwordChangeRequired,
|
||||
}
|
||||
@@ -224,31 +222,12 @@ export function updateUser(id: string, payload: UpdateUserRequest): Promise<User
|
||||
.then(mapUser)
|
||||
}
|
||||
|
||||
export function updateUserManagement(
|
||||
id: string,
|
||||
payload: UserManagementUpdateRequest,
|
||||
): Promise<UserRecord> {
|
||||
export async function getUserRoles(userId: string): Promise<UserRoleSummaryDto[]> {
|
||||
if (useMockData) {
|
||||
return Promise.reject(new Error('Mock 模式不执行用户写操作'))
|
||||
return []
|
||||
}
|
||||
|
||||
return request
|
||||
.put<ApiResponse<UserResponseDto>>(`/v1/users/${encodeURIComponent(id)}/management`, payload)
|
||||
.then(unwrapApiResponse)
|
||||
.then(mapUser)
|
||||
}
|
||||
|
||||
export async function getUserRoles(userId: string): Promise<UserRolesResponseDto> {
|
||||
if (useMockData) {
|
||||
return {
|
||||
userId,
|
||||
roles: [],
|
||||
version: 0,
|
||||
updatedAt: '',
|
||||
}
|
||||
}
|
||||
|
||||
const response = await request.get<ApiResponse<UserRolesResponseDto>>(
|
||||
const response = await request.get<ApiResponse<UserRoleSummaryDto[]>>(
|
||||
`/v1/users/${encodeURIComponent(userId)}/roles`,
|
||||
)
|
||||
return unwrapApiResponse(response)
|
||||
@@ -257,16 +236,16 @@ export async function getUserRoles(userId: string): Promise<UserRolesResponseDto
|
||||
export async function updateUserRoles(
|
||||
userId: string,
|
||||
payload: UserRolesUpdateRequest,
|
||||
): Promise<UserRolesResponseDto> {
|
||||
): Promise<void> {
|
||||
if (useMockData) {
|
||||
return Promise.reject(new Error('Mock 模式不执行用户角色写操作'))
|
||||
}
|
||||
|
||||
const response = await request.put<ApiResponse<UserRolesResponseDto>>(
|
||||
const response = await request.put<ApiResponse<null>>(
|
||||
`/v1/users/${encodeURIComponent(userId)}/roles`,
|
||||
payload,
|
||||
)
|
||||
return unwrapApiResponse(response)
|
||||
unwrapNullableApiResponse(response)
|
||||
}
|
||||
|
||||
export async function resetUserPassword(
|
||||
|
||||
Reference in New Issue
Block a user