Initial commit: 风影 OA 全栈源码(API/Web/Flutter/IM)
含 Phase 1.1 IM seq 排序、断线重连、多端已读同步与微信式语音转文字 UI。 排除 node_modules、构建产物、安装包与 .env 密钥。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
import { PrismaClient } from '@prisma/client';
|
||||
|
||||
const prisma = new PrismaClient();
|
||||
|
||||
async function main() {
|
||||
const user = await prisma.user.findFirst({
|
||||
where: {
|
||||
status: 'ACTIVE',
|
||||
OR: [{ displayName: { contains: '孙春庆' } }, { employee: { name: { contains: '孙春庆' } } }],
|
||||
},
|
||||
include: { roles: true },
|
||||
});
|
||||
if (!user) throw new Error('没有找到孙春庆');
|
||||
|
||||
const role =
|
||||
(await prisma.role.findFirst({ where: { code: 'bid_screener' } })) ||
|
||||
(await prisma.role.create({
|
||||
data: { name: '项目筛选发起', code: 'bid_screener', dataScope: 'SELF' },
|
||||
}));
|
||||
|
||||
const perms = await prisma.permission.findMany({
|
||||
where: { code: { in: ['office', 'office:overview', 'bid', 'bid:screening'] } },
|
||||
});
|
||||
await prisma.rolePermission.createMany({
|
||||
data: perms.map((p) => ({ roleId: role.id, permissionId: p.id })),
|
||||
skipDuplicates: true,
|
||||
});
|
||||
await prisma.userRole.createMany({
|
||||
data: [{ userId: user.id, roleId: role.id }],
|
||||
skipDuplicates: true,
|
||||
});
|
||||
console.log(`granted bid screening to ${user.displayName} (${user.username})`);
|
||||
}
|
||||
|
||||
main()
|
||||
.then(async () => prisma.$disconnect())
|
||||
.catch(async (e) => {
|
||||
console.error(e);
|
||||
await prisma.$disconnect();
|
||||
process.exit(1);
|
||||
});
|
||||
Reference in New Issue
Block a user