2026-07-30 17:59:43 +08:00
|
|
|
import { http, unwrapApiResponse, type ApiEnvelope } from '@/api/http'
|
|
|
|
|
|
|
|
|
|
export interface PlatformPermissionResource {
|
2026-07-30 21:23:39 +08:00
|
|
|
id: number | string
|
|
|
|
|
tenantId: number | string
|
2026-07-30 17:59:43 +08:00
|
|
|
appCode: 'PLATFORM'
|
|
|
|
|
permissionType: 'MENU' | 'BUTTON'
|
2026-07-30 21:23:39 +08:00
|
|
|
parentId: number | string
|
2026-07-30 17:59:43 +08:00
|
|
|
permissionCode: string
|
|
|
|
|
permissionName: string
|
|
|
|
|
routePath: string | null
|
|
|
|
|
httpMethod: string | null
|
|
|
|
|
sortNo: number
|
2026-08-01 12:17:33 +08:00
|
|
|
status: 'ACTIVE' | 'DISABLED' | 'INACTIVE'
|
|
|
|
|
builtIn?: boolean
|
2026-07-30 17:59:43 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface EnterpriseReview {
|
|
|
|
|
id: number
|
|
|
|
|
tenantId: number
|
|
|
|
|
status: 'PENDING' | 'APPROVED' | 'REJECTED'
|
|
|
|
|
tenantName?: string | null
|
|
|
|
|
tenantCode?: string | null
|
|
|
|
|
qualificationId?: number | null
|
|
|
|
|
qualificationType?: string | null
|
|
|
|
|
certificateNo?: string | null
|
|
|
|
|
documentUrl?: string | null
|
|
|
|
|
contactName?: string | null
|
|
|
|
|
contactPhone?: string | null
|
|
|
|
|
contactEmail?: string | null
|
|
|
|
|
submittedAt?: string | null
|
|
|
|
|
createdAt?: string | null
|
|
|
|
|
reviewComment?: string | null
|
|
|
|
|
[key: string]: unknown
|
|
|
|
|
}
|
|
|
|
|
|
2026-08-01 12:17:33 +08:00
|
|
|
export type PlatformTenantStatus = 'PENDING' | 'ACTIVE' | 'REJECTED' | 'INACTIVE' | string
|
|
|
|
|
|
|
|
|
|
export interface PlatformTenantResource {
|
|
|
|
|
id: number | string
|
|
|
|
|
tenantCode: string
|
|
|
|
|
tenantName: string
|
|
|
|
|
status: PlatformTenantStatus
|
|
|
|
|
legalName: string | null
|
|
|
|
|
unifiedSocialCreditCode: string | null
|
|
|
|
|
contactName: string | null
|
|
|
|
|
contactPhone: string | null
|
|
|
|
|
contactEmail: string | null
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface PlatformTenantPage {
|
|
|
|
|
records: PlatformTenantResource[]
|
|
|
|
|
page: number
|
|
|
|
|
size: number
|
|
|
|
|
total: number
|
|
|
|
|
pages: number
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface PlatformTenantQuery {
|
|
|
|
|
page: number
|
|
|
|
|
size: number
|
|
|
|
|
keyword?: string
|
|
|
|
|
status?: PlatformTenantStatus
|
|
|
|
|
}
|
|
|
|
|
|
2026-07-30 17:59:43 +08:00
|
|
|
export interface PlatformTenantQualification {
|
|
|
|
|
id: number | string
|
|
|
|
|
tenantId: number | string
|
|
|
|
|
qualificationType: 'BUSINESS_LICENSE' | string
|
|
|
|
|
certificateNo: string | null
|
|
|
|
|
documentUrl: string
|
|
|
|
|
status: 'PENDING' | 'APPROVED' | 'REJECTED'
|
|
|
|
|
reviewComment: string | null
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface PlatformRoleResource {
|
2026-07-31 13:43:16 +08:00
|
|
|
id: number | string
|
|
|
|
|
tenantId: number | string
|
2026-07-30 17:59:43 +08:00
|
|
|
appCode: 'PLATFORM'
|
|
|
|
|
roleCode: string
|
|
|
|
|
roleName: string
|
|
|
|
|
roleType: 'SYSTEM' | 'CUSTOM' | string
|
|
|
|
|
status: 'ACTIVE' | 'INACTIVE' | string
|
|
|
|
|
description: string | null
|
2026-07-31 13:43:16 +08:00
|
|
|
permissionIds?: Array<number | string>
|
2026-07-30 17:59:43 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface CreatePlatformRoleRequest {
|
|
|
|
|
roleCode: string
|
|
|
|
|
roleName: string
|
|
|
|
|
description: string
|
|
|
|
|
}
|
|
|
|
|
|
2026-07-31 13:43:16 +08:00
|
|
|
export interface UpdatePlatformRoleRequest {
|
|
|
|
|
roleName: string
|
|
|
|
|
description: string
|
|
|
|
|
}
|
|
|
|
|
|
2026-07-30 17:59:43 +08:00
|
|
|
export interface CreatePlatformPermissionRequest {
|
|
|
|
|
type: 'MENU' | 'BUTTON'
|
|
|
|
|
code: string
|
|
|
|
|
name: string
|
2026-07-30 21:23:39 +08:00
|
|
|
parentId: number | string
|
2026-07-30 17:59:43 +08:00
|
|
|
routePath: string | null
|
|
|
|
|
httpMethod: null
|
|
|
|
|
sortNo: number
|
|
|
|
|
}
|
|
|
|
|
|
2026-08-01 12:17:33 +08:00
|
|
|
export interface UpdatePlatformPermissionRequest {
|
|
|
|
|
name: string
|
|
|
|
|
parentId: number | string | null
|
|
|
|
|
routePath: string | null
|
|
|
|
|
httpMethod: string | null
|
|
|
|
|
sortNo: number
|
|
|
|
|
}
|
|
|
|
|
|
2026-07-31 15:34:35 +08:00
|
|
|
export interface PlatformInternalUser {
|
|
|
|
|
membershipId: number | string
|
|
|
|
|
userId: number | string
|
|
|
|
|
authUserId: number | string
|
|
|
|
|
username: string
|
|
|
|
|
displayName: string
|
2026-08-01 12:17:33 +08:00
|
|
|
phone: string | null
|
|
|
|
|
email: string | null
|
2026-07-31 15:34:35 +08:00
|
|
|
memberType: string
|
|
|
|
|
memberNo: string | null
|
|
|
|
|
status: 'ACTIVE' | 'DISABLED' | string
|
|
|
|
|
roleIds: Array<number | string>
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface CreatePlatformInternalUserRequest {
|
|
|
|
|
authUserId: number | string
|
|
|
|
|
userType: string
|
|
|
|
|
displayName: string
|
|
|
|
|
phone: string
|
|
|
|
|
email: string
|
2026-08-01 12:17:33 +08:00
|
|
|
memberNo?: string
|
|
|
|
|
roleIds?: Array<number | string>
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface UpdatePlatformInternalUserRequest {
|
|
|
|
|
displayName: string
|
|
|
|
|
phone: string
|
|
|
|
|
email: string
|
|
|
|
|
memberNo: string
|
|
|
|
|
roleIds: Array<number | string>
|
2026-07-31 15:34:35 +08:00
|
|
|
}
|
|
|
|
|
|
2026-07-30 17:59:43 +08:00
|
|
|
async function getData<T>(path: string): Promise<T> {
|
|
|
|
|
const response = await http.get<ApiEnvelope<T>, ApiEnvelope<T>>(path)
|
|
|
|
|
return unwrapApiResponse(response)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function postData<T>(path: string, body: unknown): Promise<T> {
|
|
|
|
|
const response = await http.post<ApiEnvelope<T>, ApiEnvelope<T>>(path, body)
|
|
|
|
|
return unwrapApiResponse(response)
|
|
|
|
|
}
|
|
|
|
|
|
2026-07-31 13:43:16 +08:00
|
|
|
async function putData<T>(path: string, body: unknown): Promise<T> {
|
|
|
|
|
const response = await http.put<ApiEnvelope<T>, ApiEnvelope<T>>(path, body)
|
|
|
|
|
return unwrapApiResponse(response)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function deleteData<T>(path: string): Promise<T> {
|
|
|
|
|
const response = await http.delete<ApiEnvelope<T>, ApiEnvelope<T>>(path)
|
|
|
|
|
return unwrapApiResponse(response)
|
|
|
|
|
}
|
|
|
|
|
|
2026-07-30 17:59:43 +08:00
|
|
|
export function listPlatformPermissions() {
|
|
|
|
|
return getData<PlatformPermissionResource[]>('/platform/v1/iam/permissions')
|
|
|
|
|
}
|
|
|
|
|
|
2026-07-31 13:43:16 +08:00
|
|
|
export function listCurrentPlatformPermissionCodes() {
|
|
|
|
|
return getData<string[]>('/platform/v1/iam/authorization/permissions')
|
|
|
|
|
}
|
|
|
|
|
|
2026-07-30 17:59:43 +08:00
|
|
|
export function listEnterpriseReviews() {
|
|
|
|
|
return getData<EnterpriseReview[]>('/platform/v1/iam/reviews')
|
|
|
|
|
}
|
|
|
|
|
|
2026-08-01 12:17:33 +08:00
|
|
|
export async function listPlatformTenants(query: PlatformTenantQuery) {
|
|
|
|
|
const response = await http.get<ApiEnvelope<PlatformTenantPage>, ApiEnvelope<PlatformTenantPage>>(
|
|
|
|
|
'/platform/v1/iam/tenants',
|
|
|
|
|
{
|
|
|
|
|
params: {
|
|
|
|
|
page: query.page,
|
|
|
|
|
size: query.size,
|
|
|
|
|
...(query.keyword ? { keyword: query.keyword } : {}),
|
|
|
|
|
...(query.status ? { status: query.status } : {}),
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
)
|
|
|
|
|
return unwrapApiResponse(response)
|
|
|
|
|
}
|
|
|
|
|
|
2026-07-30 17:59:43 +08:00
|
|
|
export function listTenantQualifications(tenantId: number | string) {
|
|
|
|
|
return getData<PlatformTenantQualification[]>(`/platform/v1/iam/tenants/${tenantId}/qualifications`)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function qualificationFileName(documentUrl: string) {
|
|
|
|
|
const path = documentUrl.split(/[?#]/, 1)[0]
|
|
|
|
|
const encodedName = path.split('/').filter(Boolean).at(-1)
|
|
|
|
|
if (!encodedName) throw new Error('资质文件地址无效')
|
|
|
|
|
let fileName: string
|
|
|
|
|
try {
|
|
|
|
|
fileName = decodeURIComponent(encodedName)
|
|
|
|
|
} catch {
|
|
|
|
|
throw new Error('资质文件地址无效')
|
|
|
|
|
}
|
|
|
|
|
if (!fileName || fileName === '.' || fileName === '..' || /[\\/]/.test(fileName)) {
|
|
|
|
|
throw new Error('资质文件地址无效')
|
|
|
|
|
}
|
|
|
|
|
return fileName
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function downloadTenantQualification(tenantId: number | string, documentUrl: string) {
|
|
|
|
|
const fileName = qualificationFileName(documentUrl)
|
|
|
|
|
return http.get<Blob, Blob>(`/platform/v1/files/qualifications/${tenantId}/${encodeURIComponent(fileName)}`, {
|
|
|
|
|
responseType: 'blob',
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function listPlatformRoles() {
|
|
|
|
|
return getData<PlatformRoleResource[]>('/platform/v1/iam/roles')
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function createPlatformRole(payload: CreatePlatformRoleRequest) {
|
|
|
|
|
return postData<PlatformRoleResource>('/platform/v1/iam/roles', payload)
|
|
|
|
|
}
|
|
|
|
|
|
2026-07-31 13:43:16 +08:00
|
|
|
export function updatePlatformRole(roleId: number | string, payload: UpdatePlatformRoleRequest) {
|
|
|
|
|
return putData<PlatformRoleResource>(`/platform/v1/iam/roles/${roleId}`, payload)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function changePlatformRoleStatus(roleId: number | string, status: 'ACTIVE' | 'DISABLED') {
|
|
|
|
|
return putData<PlatformRoleResource>(`/platform/v1/iam/roles/${roleId}/status`, { status })
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function deletePlatformRole(roleId: number | string) {
|
|
|
|
|
return deleteData<void>(`/platform/v1/iam/roles/${roleId}`)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function replacePlatformRolePermissions(roleId: number | string, permissionIds: Array<number | string>) {
|
|
|
|
|
return putData<void>('/platform/v1/iam/roles/permissions', { roleId, permissionIds })
|
|
|
|
|
}
|
|
|
|
|
|
2026-07-30 17:59:43 +08:00
|
|
|
export function createPlatformPermission(payload: CreatePlatformPermissionRequest) {
|
|
|
|
|
return postData<PlatformPermissionResource>('/platform/v1/iam/permissions', payload)
|
|
|
|
|
}
|
|
|
|
|
|
2026-08-01 12:17:33 +08:00
|
|
|
export function updatePlatformPermission(permissionId: number | string, payload: UpdatePlatformPermissionRequest) {
|
|
|
|
|
return putData<PlatformPermissionResource>(`/platform/v1/iam/permissions/${permissionId}`, payload)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function changePlatformPermissionStatus(permissionId: number | string, status: 'ACTIVE' | 'DISABLED') {
|
|
|
|
|
return putData<PlatformPermissionResource>(`/platform/v1/iam/permissions/${permissionId}/status`, { status })
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function deletePlatformPermission(permissionId: number | string) {
|
|
|
|
|
return deleteData<void>(`/platform/v1/iam/permissions/${permissionId}`)
|
|
|
|
|
}
|
|
|
|
|
|
2026-07-31 15:34:35 +08:00
|
|
|
export function listPlatformInternalUsers() {
|
|
|
|
|
return getData<PlatformInternalUser[]>('/platform/v1/iam/internal-users')
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function createPlatformInternalUser(payload: CreatePlatformInternalUserRequest) {
|
|
|
|
|
return postData<PlatformInternalUser>('/platform/v1/iam/internal-users', payload)
|
|
|
|
|
}
|
|
|
|
|
|
2026-08-01 12:17:33 +08:00
|
|
|
export function updatePlatformInternalUser(membershipId: number | string, payload: UpdatePlatformInternalUserRequest) {
|
|
|
|
|
return putData<PlatformInternalUser>(`/platform/v1/iam/internal-users/${membershipId}`, payload)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function changePlatformInternalUserStatus(membershipId: number | string, status: 'ACTIVE' | 'DISABLED') {
|
|
|
|
|
return putData<PlatformInternalUser>(`/platform/v1/iam/internal-users/${membershipId}/status`, { status })
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function resetPlatformInternalUserPassword(membershipId: number | string, newPassword: string) {
|
|
|
|
|
return putData<void>(`/platform/v1/iam/internal-users/${membershipId}/password`, { newPassword })
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function assignPlatformInternalUserRoles(membershipId: number | string, roleIds: Array<number | string>) {
|
|
|
|
|
return putData<PlatformInternalUser>(`/platform/v1/iam/internal-users/${membershipId}/roles`, { roleIds })
|
|
|
|
|
}
|
|
|
|
|
|
2026-07-30 17:59:43 +08:00
|
|
|
export function approveEnterpriseReview(reviewId: number, comment: string) {
|
|
|
|
|
return postData<unknown>(`/platform/v1/iam/reviews/${reviewId}/approve`, { comment })
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function rejectEnterpriseReview(reviewId: number, comment: string) {
|
|
|
|
|
return postData<unknown>(`/platform/v1/iam/reviews/${reviewId}/reject`, { comment })
|
|
|
|
|
}
|