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,40 @@
|
||||
import { PrismaClient } from '@prisma/client';
|
||||
|
||||
const prisma = new PrismaClient();
|
||||
|
||||
async function main() {
|
||||
const admin = await prisma.role.findFirst({ where: { code: 'admin' } });
|
||||
if (!admin) throw new Error('缺少 admin 角色');
|
||||
await prisma.role.updateMany({ where: { code: 'rd_director' }, data: { dataScope: 'ALL' } });
|
||||
|
||||
const users = await prisma.user.findMany({
|
||||
where: {
|
||||
status: 'ACTIVE',
|
||||
OR: [
|
||||
{ displayName: { contains: '潘兴辉' } },
|
||||
{ employee: { name: { contains: '潘兴辉' } } },
|
||||
{ roles: { some: { role: { code: 'rd_director' } } } },
|
||||
],
|
||||
},
|
||||
select: { id: true, displayName: true, username: true },
|
||||
});
|
||||
if (!users.length) throw new Error('没有找到潘兴辉或研发总监账号');
|
||||
|
||||
const result = await prisma.userRole.createMany({
|
||||
data: users.map((u) => ({ userId: u.id, roleId: admin.id })),
|
||||
skipDuplicates: true,
|
||||
});
|
||||
console.log(
|
||||
`granted admin to: ${users.map((u) => u.displayName).join('、')} (new links ${result.count})`,
|
||||
);
|
||||
}
|
||||
|
||||
main()
|
||||
.then(async () => {
|
||||
await prisma.$disconnect();
|
||||
})
|
||||
.catch(async (e) => {
|
||||
console.error(e);
|
||||
await prisma.$disconnect();
|
||||
process.exit(1);
|
||||
});
|
||||
Reference in New Issue
Block a user