Group.vue 每个产品新增「API 与密钥」弹窗(激活/查看 ApiKey/重置密钥,密钥仅一次性展示可复制)与「订阅成员」弹窗(选消费者公司 + 部门员工选择器批量添加、列表移除);subscription.ts 增加凭据与成员接口及类型;entityPickerPresets 增加 DeptEmployee 预设;MultiEntityPicker 增加 company 过滤属性。
170 lines
6.5 KiB
TypeScript
170 lines
6.5 KiB
TypeScript
import { get, post } from './request'
|
||
|
||
/** 订阅组内的成员公司(提供者 / 消费者) */
|
||
export interface SubscriptionCompanyItem {
|
||
CompanyUUID: string
|
||
CompanyName: string
|
||
CompanyShort: string
|
||
/** 公司所属租户(跨租户管理员可见多租户公司) */
|
||
TenantUUID: string
|
||
TenantName: string
|
||
}
|
||
|
||
/** 订阅关系条目里的产品引用 */
|
||
export interface SubscriptionGroupRef {
|
||
SubscriptionGroupUUID: string
|
||
GroupName: string
|
||
GroupStatus: number
|
||
}
|
||
|
||
/** 订阅组 = 一个「产品」 */
|
||
export interface SubscriptionGroupItem {
|
||
SubscriptionGroupUUID: string
|
||
TenantUUID: string
|
||
GroupName: string
|
||
GroupDesc: string
|
||
GroupStatus: number
|
||
CreateTime: string | null
|
||
Providers: SubscriptionCompanyItem[]
|
||
Consumers: SubscriptionCompanyItem[]
|
||
}
|
||
|
||
/** 订阅关系:按公司汇总它作为提供者 / 消费者参与的产品 */
|
||
export interface SubscriptionRelationItem extends SubscriptionCompanyItem {
|
||
ProviderGroups: SubscriptionGroupRef[]
|
||
ConsumerGroups: SubscriptionGroupRef[]
|
||
}
|
||
|
||
/** 订阅组保存入参(公司名单整体重写) */
|
||
export interface SubscriptionGroupPayload {
|
||
SubscriptionGroupUUID?: string
|
||
GroupName: string
|
||
GroupDesc: string
|
||
GroupStatus: number
|
||
Providers: string[]
|
||
Consumers: string[]
|
||
}
|
||
|
||
/** 应用级订阅方(应用本身的两方公司,不分具体产品) */
|
||
export interface SubscriptionAppParties {
|
||
AppUUID: string
|
||
Providers: SubscriptionCompanyItem[]
|
||
Consumers: SubscriptionCompanyItem[]
|
||
}
|
||
|
||
/** 应用级订阅方保存入参(整体重写) */
|
||
export interface SubscriptionAppPartyPayload {
|
||
AppUUID: string
|
||
Providers: string[]
|
||
Consumers: string[]
|
||
}
|
||
|
||
/** 订阅软件接入凭据状态(不含密钥,密钥只存哈希无法还原) */
|
||
export interface SubscriptionCredentialState {
|
||
/** 0=未激活(首次不给 API Key)/ 1=已激活 */
|
||
Activated: number
|
||
ApiKey: string
|
||
CreateTime: string | null
|
||
ResetTime: string | null
|
||
}
|
||
|
||
/** 激活 / 重置后返回(Secret 明文仅此一次) */
|
||
export interface SubscriptionCredentialIssued extends SubscriptionCredentialState {
|
||
Secret: string
|
||
}
|
||
|
||
/** 订阅成员(某产品下的「部门-员工键」订阅记录) */
|
||
export interface SubscriptionMemberItem {
|
||
SubscriptionMemberUUID: string
|
||
SubscriptionGroupUUID: string
|
||
CompanyUUID: string
|
||
CompanyName: string
|
||
DeptUUID: string
|
||
DeptName: string
|
||
UserUUID: string
|
||
UserName: string
|
||
UserRoleDepartmentUUID: string
|
||
CreateTime: string | null
|
||
}
|
||
|
||
/** 订阅成员列表响应(含该产品的消费者公司清单,供页面选择) */
|
||
export interface SubscriptionMemberList {
|
||
GroupUUID: string
|
||
GroupName: string
|
||
Consumers: SubscriptionCompanyItem[]
|
||
list: SubscriptionMemberItem[]
|
||
total: number
|
||
}
|
||
|
||
/** 保存订阅成员的返回(逐条结果:成功 Added / 跳过 Skipped) */
|
||
export interface SubscriptionMemberSaveResult {
|
||
Added: SubscriptionMemberItem[]
|
||
Skipped: { Key: string; Reason: string }[]
|
||
total: number
|
||
}
|
||
|
||
/** 订阅式软件提供 API 客户端 */
|
||
export const subscriptionApi = {
|
||
/** 订阅组(产品)列表(含提供者/消费者公司) */
|
||
groups: (): Promise<{ list: SubscriptionGroupItem[]; total: number; Scope: string }> =>
|
||
get<{ list: SubscriptionGroupItem[]; total: number; Scope: string }>('/API/Subscription/Groups'),
|
||
|
||
/** 新建 / 更新订阅组 */
|
||
saveGroup: (data: SubscriptionGroupPayload): Promise<SubscriptionGroupItem> =>
|
||
post<SubscriptionGroupItem>('/API/Subscription/Group/Save', data),
|
||
|
||
/** 删除订阅组(连带成员公司名单) */
|
||
deleteGroup: (SubscriptionGroupUUID: string): Promise<void> =>
|
||
post<void>('/API/Subscription/Group/Delete', { SubscriptionGroupUUID }),
|
||
|
||
/** 订阅关系(按公司汇总) */
|
||
relations: (): Promise<{ list: SubscriptionRelationItem[]; total: number; Scope: string }> =>
|
||
get<{ list: SubscriptionRelationItem[]; total: number; Scope: string }>('/API/Subscription/Relations'),
|
||
|
||
/** 可选公司列表(当前管理员全部可管理公司,含所属租户名) */
|
||
companies: (): Promise<{ list: SubscriptionCompanyItem[]; total: number; Scope: string }> =>
|
||
get<{ list: SubscriptionCompanyItem[]; total: number; Scope: string }>('/API/Subscription/Companies'),
|
||
|
||
/** 应用级订阅方(应用配置页注入卡片:提供者/消费者公司,不分产品) */
|
||
appParties: (AppUUID: string): Promise<SubscriptionAppParties> =>
|
||
get<SubscriptionAppParties>('/API/Subscription/AppParties', { AppUUID }),
|
||
|
||
/** 保存应用级订阅方(整体重写) */
|
||
saveAppParties: (data: SubscriptionAppPartyPayload): Promise<SubscriptionAppParties> =>
|
||
post<SubscriptionAppParties>('/API/Subscription/AppParty/Save', data),
|
||
|
||
// ==================== 产品级接入凭据(提供者子服务器鉴权) ====================
|
||
|
||
/** 查看某软件的接入凭据状态(不含密钥) */
|
||
credential: (SubscriptionGroupUUID: string): Promise<SubscriptionCredentialState> =>
|
||
get<SubscriptionCredentialState>('/API/Subscription/Credential/Get', { SubscriptionGroupUUID }),
|
||
|
||
/** 首次激活:生成 API Key + 密钥(密钥明文仅此一次返回) */
|
||
activateCredential: (SubscriptionGroupUUID: string): Promise<SubscriptionCredentialIssued> =>
|
||
post<SubscriptionCredentialIssued>('/API/Subscription/Credential/Activate', { SubscriptionGroupUUID }),
|
||
|
||
/** 重置密钥(ApiKey 不变,新密钥明文仅此一次返回,旧密钥立即失效) */
|
||
resetCredentialSecret: (SubscriptionGroupUUID: string): Promise<SubscriptionCredentialIssued> =>
|
||
post<SubscriptionCredentialIssued>('/API/Subscription/Credential/ResetSecret', { SubscriptionGroupUUID }),
|
||
|
||
// ==================== 订阅成员(部门-员工键) ====================
|
||
|
||
/** 某软件的订阅成员列表(含该产品的消费者公司清单) */
|
||
members: (SubscriptionGroupUUID: string): Promise<SubscriptionMemberList> =>
|
||
get<SubscriptionMemberList>('/API/Subscription/Members', { SubscriptionGroupUUID }),
|
||
|
||
/** 新增订阅成员(部门-员工键,批量;部门必须归属该软件的消费者公司) */
|
||
saveMembers: (
|
||
SubscriptionGroupUUID: string,
|
||
UserRoleDepartmentUUIDs: string[],
|
||
): Promise<SubscriptionMemberSaveResult> =>
|
||
post<SubscriptionMemberSaveResult>('/API/Subscription/Member/Save', {
|
||
SubscriptionGroupUUID,
|
||
UserRoleDepartmentUUIDs,
|
||
}),
|
||
|
||
/** 删除一条订阅成员 */
|
||
deleteMember: (SubscriptionGroupUUID: string, SubscriptionMemberUUID: string): Promise<void> =>
|
||
post<void>('/API/Subscription/Member/Delete', { SubscriptionGroupUUID, SubscriptionMemberUUID }),
|
||
}
|