- PUT /api/principals/{id} 不再接受 status 变更(变更时返回 403「主体的启用/停用只能由平台运维在数据库中维护」)
- POST /api/principals 状态固定为启用,创建时传 status=0 直接 403;其它非白名单字段忽略
- 集团设置页面状态改为只读展示并提示由平台运维维护(去掉启用/禁用开关)
- 前端 updatePrincipal 类型移除 status,接口契约说明同步更新
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
44 lines
1.2 KiB
TypeScript
44 lines
1.2 KiB
TypeScript
import { post, get, put } from '@/utils/request'
|
|
|
|
export interface PrincipalPayload {
|
|
name: string
|
|
type?: number
|
|
contact_name?: string
|
|
contact_phone?: string
|
|
remark?: string
|
|
}
|
|
|
|
export interface PrincipalItem {
|
|
id: number
|
|
name: string
|
|
type: number
|
|
contact_name: string | null
|
|
contact_phone: string | null
|
|
status: number
|
|
remark: string | null
|
|
created_at?: string
|
|
}
|
|
|
|
/** 创建主体(同时会将当前用户关联为默认主体用户) */
|
|
export function createPrincipal(data: PrincipalPayload) {
|
|
return post<{ id: number }>('/principals', data)
|
|
}
|
|
|
|
/** 主体详情(组织架构 → 集团设置读取当前主体) */
|
|
export function getPrincipal(id: number) {
|
|
return get<PrincipalItem & { remark?: string | null; updated_at?: string }>(`/principals/${id}`)
|
|
}
|
|
|
|
/** 更新主体(集团设置保存当前主体);主体状态不接受接口修改,只能由平台运维在数据库中维护 */
|
|
export function updatePrincipal(id: number, data: Partial<PrincipalPayload>) {
|
|
return put<{ id: number }>(`/principals/${id}`, data)
|
|
}
|
|
|
|
/** 主体列表 */
|
|
export function getPrincipals(params?: object) {
|
|
return get<{ list: PrincipalItem[]; total: number; page: number; pageSize: number }>(
|
|
'/principals',
|
|
params,
|
|
)
|
|
}
|