feat(api): migrate TypeScript type definitions and API services
This commit is contained in:
parent
9600147586
commit
9b5198f87a
6
apps/web-ele/src/api/fengling/index.ts
Normal file
6
apps/web-ele/src/api/fengling/index.ts
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
export * from './log';
|
||||||
|
export * from './oauth';
|
||||||
|
export * from './role';
|
||||||
|
export * from './tenant';
|
||||||
|
export * from './user';
|
||||||
|
export * from './typings';
|
||||||
35
apps/web-ele/src/api/fengling/log.ts
Normal file
35
apps/web-ele/src/api/fengling/log.ts
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
import type { FenglingApi } from './typings';
|
||||||
|
|
||||||
|
import { requestClient } from '#/api/request';
|
||||||
|
|
||||||
|
export namespace LogApi {
|
||||||
|
export async function getAuditLogList(params: {
|
||||||
|
page?: number
|
||||||
|
pageSize?: number
|
||||||
|
userId?: number
|
||||||
|
action?: string
|
||||||
|
resourceType?: string
|
||||||
|
startDate?: string
|
||||||
|
endDate?: string
|
||||||
|
}) {
|
||||||
|
return requestClient.get<FenglingApi.PaginatedResponse<FenglingApi.Log.AuditLog>>(
|
||||||
|
'/logs/audit',
|
||||||
|
{ params }
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function getAccessLogList(params: {
|
||||||
|
page?: number
|
||||||
|
pageSize?: number
|
||||||
|
userId?: number
|
||||||
|
path?: string
|
||||||
|
statusCode?: number
|
||||||
|
startDate?: string
|
||||||
|
endDate?: string
|
||||||
|
}) {
|
||||||
|
return requestClient.get<FenglingApi.PaginatedResponse<FenglingApi.Log.AccessLog>>(
|
||||||
|
'/logs/access',
|
||||||
|
{ params }
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
45
apps/web-ele/src/api/fengling/oauth.ts
Normal file
45
apps/web-ele/src/api/fengling/oauth.ts
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
import type { FenglingApi } from './typings';
|
||||||
|
|
||||||
|
import { requestClient } from '#/api/request';
|
||||||
|
|
||||||
|
export namespace OAuthApi {
|
||||||
|
export async function getClientList(params: {
|
||||||
|
page?: number
|
||||||
|
pageSize?: number
|
||||||
|
keyword?: string
|
||||||
|
status?: string
|
||||||
|
}) {
|
||||||
|
return requestClient.get<FenglingApi.PaginatedResponse<FenglingApi.OAuth.OAuthClient>>(
|
||||||
|
'/oauth/clients',
|
||||||
|
{ params }
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function getClientById(id: number) {
|
||||||
|
return requestClient.get<FenglingApi.OAuth.OAuthClient>(`/oauth/clients/${id}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function createClient(data: FenglingApi.OAuth.CreateOAuthClientDto) {
|
||||||
|
return requestClient.post<FenglingApi.OAuth.OAuthClient>('/oauth/clients', data);
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function updateClient(id: number, data: FenglingApi.OAuth.UpdateOAuthClientDto) {
|
||||||
|
return requestClient.put<FenglingApi.OAuth.OAuthClient>(`/oauth/clients/${id}`, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function deleteClient(id: number) {
|
||||||
|
return requestClient.delete(`/oauth/clients/${id}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function regenerateClientSecret(id: number) {
|
||||||
|
return requestClient.post(`/oauth/clients/${id}/regenerate-secret`);
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function activateClient(id: number) {
|
||||||
|
return requestClient.post(`/oauth/clients/${id}/activate`);
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function deactivateClient(id: number) {
|
||||||
|
return requestClient.post(`/oauth/clients/${id}/deactivate`);
|
||||||
|
}
|
||||||
|
}
|
||||||
36
apps/web-ele/src/api/fengling/role.ts
Normal file
36
apps/web-ele/src/api/fengling/role.ts
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
import type { FenglingApi } from './typings';
|
||||||
|
|
||||||
|
import { requestClient } from '#/api/request';
|
||||||
|
|
||||||
|
export namespace RoleApi {
|
||||||
|
export async function getRoleList(params: {
|
||||||
|
page?: number
|
||||||
|
pageSize?: number
|
||||||
|
keyword?: string
|
||||||
|
}) {
|
||||||
|
return requestClient.get<FenglingApi.PaginatedResponse<FenglingApi.Role.Role>>(
|
||||||
|
'/roles',
|
||||||
|
{ params }
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function getRoleById(id: number) {
|
||||||
|
return requestClient.get<FenglingApi.Role.Role>(`/roles/${id}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function createRole(data: FenglingApi.Role.CreateRoleDto) {
|
||||||
|
return requestClient.post<FenglingApi.Role.Role>('/roles', data);
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function updateRole(id: number, data: FenglingApi.Role.UpdateRoleDto) {
|
||||||
|
return requestClient.put<FenglingApi.Role.Role>(`/roles/${id}`, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function deleteRole(id: number) {
|
||||||
|
return requestClient.delete(`/roles/${id}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function getAllRoles() {
|
||||||
|
return requestClient.get<FenglingApi.Role.Role[]>('/roles/all');
|
||||||
|
}
|
||||||
|
}
|
||||||
55
apps/web-ele/src/api/fengling/tenant.ts
Normal file
55
apps/web-ele/src/api/fengling/tenant.ts
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
import type { FenglingApi } from './typings';
|
||||||
|
|
||||||
|
import { requestClient } from '#/api/request';
|
||||||
|
|
||||||
|
export namespace TenantApi {
|
||||||
|
export async function getTenantList(params: {
|
||||||
|
page?: number
|
||||||
|
pageSize?: number
|
||||||
|
keyword?: string
|
||||||
|
status?: string
|
||||||
|
}) {
|
||||||
|
return requestClient.get<FenglingApi.PaginatedResponse<FenglingApi.Tenant.Tenant>>(
|
||||||
|
'/tenants',
|
||||||
|
{ params }
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function getTenantById(id: number) {
|
||||||
|
return requestClient.get<FenglingApi.Tenant.Tenant>(`/tenants/${id}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function createTenant(data: FenglingApi.Tenant.CreateTenantDto) {
|
||||||
|
return requestClient.post<FenglingApi.Tenant.Tenant>('/tenants', data);
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function updateTenant(id: number, data: FenglingApi.Tenant.UpdateTenantDto) {
|
||||||
|
return requestClient.put<FenglingApi.Tenant.Tenant>(`/tenants/${id}`, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function deleteTenant(id: number) {
|
||||||
|
return requestClient.delete(`/tenants/${id}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function activateTenant(id: number) {
|
||||||
|
return requestClient.post(`/tenants/${id}/activate`);
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function deactivateTenant(id: number) {
|
||||||
|
return requestClient.post(`/tenants/${id}/deactivate`);
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function extendTenantExpiry(id: number, expiresAt: string) {
|
||||||
|
return requestClient.post(`/tenants/${id}/extend`, { expiresAt });
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function getTenantUsers(id: number) {
|
||||||
|
return requestClient.get<FenglingApi.PaginatedResponse<FenglingApi.User.User>>(
|
||||||
|
`/tenants/${id}/users`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function getTenantStatistics(id: number) {
|
||||||
|
return requestClient.get(`/tenants/${id}/statistics`);
|
||||||
|
}
|
||||||
|
}
|
||||||
177
apps/web-ele/src/api/fengling/typings.d.ts
vendored
Normal file
177
apps/web-ele/src/api/fengling/typings.d.ts
vendored
Normal file
@ -0,0 +1,177 @@
|
|||||||
|
export namespace FenglingApi {
|
||||||
|
export namespace Tenant {
|
||||||
|
export interface Tenant {
|
||||||
|
id: number
|
||||||
|
tenantId: string
|
||||||
|
name: string
|
||||||
|
contactName: string
|
||||||
|
contactEmail: string
|
||||||
|
contactPhone: string
|
||||||
|
maxUsers?: number
|
||||||
|
userCount: number
|
||||||
|
status: 'active' | 'inactive' | 'expired'
|
||||||
|
expiresAt?: string
|
||||||
|
description?: string
|
||||||
|
createdAt: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface CreateTenantDto {
|
||||||
|
tenantId: string
|
||||||
|
name: string
|
||||||
|
contactName: string
|
||||||
|
contactEmail: string
|
||||||
|
contactPhone: string
|
||||||
|
maxUsers?: number
|
||||||
|
expiresAt?: string
|
||||||
|
status: 'active' | 'inactive'
|
||||||
|
description?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface UpdateTenantDto {
|
||||||
|
name?: string
|
||||||
|
contactName?: string
|
||||||
|
contactEmail?: string
|
||||||
|
contactPhone?: string
|
||||||
|
maxUsers?: number
|
||||||
|
expiresAt?: string
|
||||||
|
status?: 'active' | 'inactive'
|
||||||
|
description?: string
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export namespace User {
|
||||||
|
export interface User {
|
||||||
|
id: number
|
||||||
|
userName: string
|
||||||
|
email: string
|
||||||
|
realName?: string
|
||||||
|
tenantId?: string
|
||||||
|
roles: string[]
|
||||||
|
isActive: boolean
|
||||||
|
createdAt: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface CreateUserDto {
|
||||||
|
userName: string
|
||||||
|
email: string
|
||||||
|
realName?: string
|
||||||
|
password: string
|
||||||
|
tenantId?: string
|
||||||
|
roleIds: number[]
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface UpdateUserDto {
|
||||||
|
email?: string
|
||||||
|
realName?: string
|
||||||
|
isActive?: boolean
|
||||||
|
roleIds?: number[]
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ResetPasswordDto {
|
||||||
|
newPassword: string
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export namespace Role {
|
||||||
|
export interface Role {
|
||||||
|
id: number
|
||||||
|
name: string
|
||||||
|
displayName: string
|
||||||
|
description?: string
|
||||||
|
permissions: string[]
|
||||||
|
createdAt: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface CreateRoleDto {
|
||||||
|
name: string
|
||||||
|
displayName: string
|
||||||
|
description?: string
|
||||||
|
permissions: string[]
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface UpdateRoleDto {
|
||||||
|
displayName?: string
|
||||||
|
description?: string
|
||||||
|
permissions?: string[]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export namespace OAuth {
|
||||||
|
export interface OAuthClient {
|
||||||
|
id: number
|
||||||
|
clientId: string
|
||||||
|
displayName: string
|
||||||
|
redirectUris: string[]
|
||||||
|
postLogoutRedirectUris: string[]
|
||||||
|
scopes: string[]
|
||||||
|
grantTypes: string[]
|
||||||
|
clientType: 'confidential' | 'public'
|
||||||
|
consentType: 'explicit' | 'implicit' | 'external'
|
||||||
|
status: 'active' | 'inactive'
|
||||||
|
description?: string
|
||||||
|
createdAt: string
|
||||||
|
updatedAt: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface CreateOAuthClientDto {
|
||||||
|
clientId: string
|
||||||
|
displayName: string
|
||||||
|
clientSecret?: string
|
||||||
|
redirectUris: string[]
|
||||||
|
postLogoutRedirectUris: string[]
|
||||||
|
scopes: string[]
|
||||||
|
grantTypes: string[]
|
||||||
|
clientType?: 'confidential' | 'public'
|
||||||
|
consentType?: 'explicit' | 'implicit' | 'external'
|
||||||
|
status?: 'active' | 'inactive'
|
||||||
|
description?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface UpdateOAuthClientDto {
|
||||||
|
displayName: string
|
||||||
|
redirectUris: string[]
|
||||||
|
postLogoutRedirectUris: string[]
|
||||||
|
scopes: string[]
|
||||||
|
grantTypes: string[]
|
||||||
|
clientType: 'confidential' | 'public'
|
||||||
|
consentType: 'explicit' | 'implicit' | 'external'
|
||||||
|
status: 'active' | 'inactive'
|
||||||
|
description?: string
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export namespace Log {
|
||||||
|
export interface AuditLog {
|
||||||
|
id: number
|
||||||
|
userId?: number
|
||||||
|
userName?: string
|
||||||
|
action: string
|
||||||
|
resourceType: string
|
||||||
|
resourceId?: string
|
||||||
|
details?: string
|
||||||
|
ipAddress?: string
|
||||||
|
userAgent?: string
|
||||||
|
createdAt: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface AccessLog {
|
||||||
|
id: number
|
||||||
|
userId?: number
|
||||||
|
userName?: string
|
||||||
|
path: string
|
||||||
|
method: string
|
||||||
|
statusCode: number
|
||||||
|
duration: number
|
||||||
|
ipAddress?: string
|
||||||
|
userAgent?: string
|
||||||
|
createdAt: string
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface PaginatedResponse<T> {
|
||||||
|
items: T[]
|
||||||
|
totalCount: number
|
||||||
|
page: number
|
||||||
|
pageSize: number
|
||||||
|
}
|
||||||
|
}
|
||||||
38
apps/web-ele/src/api/fengling/user.ts
Normal file
38
apps/web-ele/src/api/fengling/user.ts
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
import type { FenglingApi } from './typings';
|
||||||
|
|
||||||
|
import { requestClient } from '#/api/request';
|
||||||
|
|
||||||
|
export namespace UserApi {
|
||||||
|
export async function getUserList(params: {
|
||||||
|
page?: number
|
||||||
|
pageSize?: number
|
||||||
|
keyword?: string
|
||||||
|
tenantId?: string
|
||||||
|
isActive?: boolean
|
||||||
|
}) {
|
||||||
|
return requestClient.get<FenglingApi.PaginatedResponse<FenglingApi.User.User>>(
|
||||||
|
'/users',
|
||||||
|
{ params }
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function getUserById(id: number) {
|
||||||
|
return requestClient.get<FenglingApi.User.User>(`/users/${id}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function createUser(data: FenglingApi.User.CreateUserDto) {
|
||||||
|
return requestClient.post<FenglingApi.User.User>('/users', data);
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function updateUser(id: number, data: FenglingApi.User.UpdateUserDto) {
|
||||||
|
return requestClient.put<FenglingApi.User.User>(`/users/${id}`, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function deleteUser(id: number) {
|
||||||
|
return requestClient.delete(`/users/${id}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function resetUserPassword(id: number, data: FenglingApi.User.ResetPasswordDto) {
|
||||||
|
return requestClient.post(`/users/${id}/reset-password`, data);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1 +1,2 @@
|
|||||||
export * from './core';
|
export * from './core';
|
||||||
|
export * from './fengling';
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user