删除库存和旧回调管理
This commit is contained in:
@@ -7,7 +7,6 @@ import {
|
||||
getAdminUserById,
|
||||
getAdminUserByUsername,
|
||||
listAdminUsers,
|
||||
replaceAdminUserInventoryGroupBindings,
|
||||
updateAdminUser,
|
||||
} from '../../repositories/admin-user-repo.js'
|
||||
import { addHours, nowIso } from '../../utils/time.js'
|
||||
@@ -23,7 +22,6 @@ export type AdminSession = {
|
||||
userId: number
|
||||
username: string
|
||||
role: AdminRole
|
||||
allowedInventoryGroups: string[]
|
||||
expiresAt: string
|
||||
}
|
||||
|
||||
@@ -144,7 +142,6 @@ export async function verifyAdminSessionToken(token: unknown): Promise<AdminSess
|
||||
userId: Number(user.id),
|
||||
username: String(user.username || ''),
|
||||
role: normalizeAdminRole(user.role),
|
||||
allowedInventoryGroups: normalizeInventoryGroupCodes(user.inventory_group_codes),
|
||||
expiresAt,
|
||||
}
|
||||
}
|
||||
@@ -159,7 +156,6 @@ export async function getAdminSessionSummary(token: unknown): Promise<JsonObject
|
||||
userId: session.userId,
|
||||
username: session.username,
|
||||
role: session.role,
|
||||
inventoryGroupCodes: session.allowedInventoryGroups,
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -235,22 +231,6 @@ export async function createManagedAdminUser(payload: JsonObject = {}): Promise<
|
||||
}
|
||||
}
|
||||
|
||||
export async function updateManagedAdminUserInventoryGroups(
|
||||
userId: number | string,
|
||||
payload: JsonObject = {},
|
||||
session: AdminSession,
|
||||
): Promise<JsonObject> {
|
||||
const user = await getRequiredAdminUser(userId)
|
||||
const inventoryGroupCodes = normalizeInventoryGroupCodes(payload.inventoryGroupCodes)
|
||||
|
||||
await ensureAdminUserChangeAllowed(user, {}, session)
|
||||
const updated = await replaceAdminUserInventoryGroupBindings(user.id, inventoryGroupCodes, nowIso())
|
||||
|
||||
return {
|
||||
user: mapAdminUser(updated),
|
||||
}
|
||||
}
|
||||
|
||||
export async function updateManagedAdminUserRole(
|
||||
userId: number | string,
|
||||
payload: JsonObject = {},
|
||||
@@ -358,7 +338,6 @@ function createAdminSession(user: AdminUserRow): JsonObject {
|
||||
userId: Number(user.id),
|
||||
username: String(user.username || ''),
|
||||
role: normalizeAdminRole(user.role),
|
||||
inventoryGroupCodes: normalizeInventoryGroupCodes(user.inventory_group_codes),
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -493,14 +472,7 @@ function mapAdminUser(user: AdminUserRow | null): JsonObject {
|
||||
username: String(user.username || ''),
|
||||
role: normalizeAdminRole(user.role),
|
||||
status: normalizeAdminUserStatus(user.status),
|
||||
inventoryGroupCodes: normalizeInventoryGroupCodes(user.inventory_group_codes),
|
||||
createdAt: user.created_at,
|
||||
updatedAt: user.updated_at,
|
||||
}
|
||||
}
|
||||
|
||||
function normalizeInventoryGroupCodes(values: unknown): string[] {
|
||||
return Array.from(new Set((Array.isArray(values) ? values : [])
|
||||
.map((value) => String(value || '').trim())
|
||||
.filter(Boolean)))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user