- Expand batch upload list area and optimize preview image layout - Improve upload speed tracking and display (server-side & client-side) - Reduce network detection log noise - Optimize Docker build process (caching, env validation) - Add shadow environment deployment support
88 lines
2.5 KiB
JavaScript
88 lines
2.5 KiB
JavaScript
/**
|
|
* 权限继承测试脚本
|
|
* 用于验证视觉六部是否能从视觉中心继承3D场景的下载权限
|
|
*/
|
|
|
|
const { PrismaClient } = require('@prisma/client')
|
|
|
|
const prisma = new PrismaClient()
|
|
|
|
async function testPermissionInheritance() {
|
|
console.log('=== 测试权限继承 ===\n')
|
|
|
|
// 1. 获取视觉六部的信息
|
|
const dept6 = await prisma.department.findFirst({
|
|
where: { name: '视觉六部' },
|
|
select: { id: true, name: true, parentId: true }
|
|
})
|
|
|
|
console.log('1. 视觉六部信息:')
|
|
console.log(' ID:', dept6.id)
|
|
console.log(' 名称:', dept6.name)
|
|
console.log(' 父部门ID:', dept6.parentId)
|
|
|
|
// 2. 获取父部门(视觉中心)的信息
|
|
const visionCenter = await prisma.department.findFirst({
|
|
where: { id: dept6.parentId },
|
|
select: { id: true, name: true }
|
|
})
|
|
|
|
console.log('\n2. 父部门信息:')
|
|
console.log(' ID:', visionCenter.id)
|
|
console.log(' 名称:', visionCenter.name)
|
|
|
|
// 3. 查询视觉中心的3D场景权限
|
|
const centerPermission = await prisma.departmentMaterialPermission.findUnique({
|
|
where: {
|
|
department_materialType: {
|
|
department: '视觉中心',
|
|
materialType: '3D场景'
|
|
}
|
|
}
|
|
})
|
|
|
|
console.log('\n3. 视觉中心的3D场景权限:')
|
|
if (centerPermission) {
|
|
console.log(' canView:', centerPermission.canView)
|
|
console.log(' canDownload:', centerPermission.canDownload)
|
|
console.log(' canShare:', centerPermission.canShare)
|
|
} else {
|
|
console.log(' 未找到权限配置')
|
|
}
|
|
|
|
// 4. 模拟权限继承逻辑
|
|
const departments = await prisma.department.findMany({
|
|
select: { id: true, name: true, parentId: true }
|
|
})
|
|
|
|
const deptMap = new Map()
|
|
departments.forEach(dept => {
|
|
deptMap.set(dept.name, dept)
|
|
})
|
|
|
|
const currentDept = deptMap.get('视觉六部')
|
|
const parentDept = departments.find(d => d.id === currentDept.parentId)
|
|
|
|
console.log('\n4. 模拟权限继承:')
|
|
console.log(' 当前部门:', currentDept.name)
|
|
console.log(' 找到父部门:', parentDept ? parentDept.name : '未找到')
|
|
|
|
if (parentDept && centerPermission) {
|
|
console.log(' 继承的权限:')
|
|
console.log(' canView:', centerPermission.canView)
|
|
console.log(' canDownload:', centerPermission.canDownload)
|
|
}
|
|
|
|
await prisma.$disconnect()
|
|
}
|
|
|
|
testPermissionInheritance()
|
|
.then(() => {
|
|
console.log('\n测试完成')
|
|
process.exit(0)
|
|
})
|
|
.catch(err => {
|
|
console.error('测试失败:', err)
|
|
process.exit(1)
|
|
})
|