add seeders
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -1,3 +1,2 @@
|
||||
node_modules
|
||||
.env
|
||||
seeders
|
||||
.env
|
||||
@@ -5,9 +5,9 @@
|
||||
"main": "index.ts",
|
||||
"type": "commonjs",
|
||||
"scripts": {
|
||||
"dev": "nodemon index.ts",
|
||||
"dev": "nodemon --exec ts-node index.ts",
|
||||
"build": "tsc",
|
||||
"start": "node index.ts",
|
||||
"start": "node dist/index.js",
|
||||
"type-check": "tsc --noEmit",
|
||||
"clean": "rm -rf dist"
|
||||
},
|
||||
|
||||
73
src/seeders/department.seed.ts
Normal file
73
src/seeders/department.seed.ts
Normal file
@@ -0,0 +1,73 @@
|
||||
import Department from "../models/Department";
|
||||
|
||||
export async function seedDepartments() {
|
||||
const departments = [
|
||||
{ slug: "ccu", displayName: "CCU" },
|
||||
{ slug: "cssd", displayName: "CSSD" },
|
||||
{ slug: "icu_e", displayName: "ICU E" },
|
||||
{ slug: "icu_oh", displayName: "ICU OH" },
|
||||
{ slug: "icu1", displayName: "ICU1" },
|
||||
{ slug: "icu3", displayName: "ICU3" },
|
||||
{ slug: "ipd", displayName: "IPD" },
|
||||
{ slug: "nicu", displayName: "NICU" },
|
||||
{ slug: "post_ccu", displayName: "POST CCU" },
|
||||
{ slug: "operation_general", displayName: "اتاق عمل جنرال" },
|
||||
{ slug: "operation_heart", displayName: "اتاق عمل قلب" },
|
||||
{ slug: "health_info_admission", displayName: "اطلاعات سلامت-پذیرش" },
|
||||
{ slug: "health_info_docs", displayName: "اطلاعات سلامت-مدارک پزشکی" },
|
||||
{ slug: "pharmacy", displayName: "امور داروئی و داروخانه" },
|
||||
{ slug: "warehouse", displayName: "انبار" },
|
||||
{ slug: "emergency", displayName: "اورژانس" },
|
||||
{ slug: "laboratory", displayName: "آزمایشگاه" },
|
||||
{ slug: "education", displayName: "آموزش و توسعه" },
|
||||
{ slug: "endoscopy", displayName: "آندوسکوپی" },
|
||||
{ slug: "angiography", displayName: "آنژیوگرافی" },
|
||||
{ slug: "delivery_block", displayName: "بلوک زایمان" },
|
||||
{ slug: "quality_improvement", displayName: "بهبود کیفیت و اعتباربخشی" },
|
||||
{ slug: "occupational_health", displayName: "بهداشت حرفهای" },
|
||||
{ slug: "environmental_health", displayName: "بهداشت محیط" },
|
||||
{ slug: "patient_affairs", displayName: "پیگیری امور بیماران" },
|
||||
{ slug: "medical_equipment", displayName: "تجهیزات پزشکی" },
|
||||
{ slug: "procurement", displayName: "تدارکات" },
|
||||
{ slug: "radiology", displayName: "تصویر برداری" },
|
||||
{ slug: "nutrition", displayName: "تغذیه و رستوران" },
|
||||
{ slug: "surgery2", displayName: "جراحی 2" },
|
||||
{ slug: "surgery1", displayName: "جراحی 1" },
|
||||
{ slug: "accounting", displayName: "حسابداری" },
|
||||
{ slug: "auditing", displayName: "حسابرسی" },
|
||||
{ slug: "security", displayName: "حفاظت فیزیکی و انتظامات" },
|
||||
{ slug: "public_services", displayName: "خدمات عمومی" },
|
||||
{ slug: "internal", displayName: "داخلی" },
|
||||
{ slug: "secretariat", displayName: "دبیرخانه" },
|
||||
{ slug: "income_docs", displayName: "درآمد-اسناد پزشکی" },
|
||||
{ slug: "income_discharge", displayName: "درآمد-ترخیص" },
|
||||
{ slug: "income_cashier", displayName: "درآمد-صندوق" },
|
||||
{ slug: "clinic", displayName: "درمانگاه" },
|
||||
{ slug: "nursing_office", displayName: "دفتر پرستاری" },
|
||||
{ slug: "presidency", displayName: "دفتر ریاست" },
|
||||
{ slug: "dialysis", displayName: "دیالیز" },
|
||||
{ slug: "public_relations", displayName: "روابط عمومی و امور بینالملل" },
|
||||
{ slug: "it", displayName: "فناوری اطلاعات و IT" },
|
||||
{ slug: "engineering", displayName: "فنی مهندسی" },
|
||||
{ slug: "protocol", displayName: "کاخداری و تشریفات" },
|
||||
{ slug: "protocol_phone", displayName: "کاخداری و تشریفات - مرکز تلفن" },
|
||||
{ slug: "protocol_transport", displayName: "کاخداری و تشریفات - نقلیه" },
|
||||
{ slug: "protocol_welcome", displayName: "کاخداری و تشریفات - ولکام" },
|
||||
{ slug: "hr", displayName: "کارگزینی" },
|
||||
{ slug: "kaspian", displayName: "کاسپین" },
|
||||
{ slug: "medical_group", displayName: "گروه پزشکی" },
|
||||
{ slug: "internal_management", displayName: "مدیریت داخلی" },
|
||||
{ slug: "human_resources", displayName: "مدیریت منابع انسانی" },
|
||||
{ slug: "treatment_management", displayName: "مدیریت درمان" },
|
||||
{ slug: "finance_management", displayName: "مدیریت مالی" },
|
||||
];
|
||||
|
||||
for (const dep of departments) {
|
||||
await Department.findOrCreate({
|
||||
where: { slug: dep.slug },
|
||||
defaults: dep,
|
||||
});
|
||||
}
|
||||
|
||||
console.log("Departments seeded ✅");
|
||||
}
|
||||
39
src/seeders/role.seed.ts
Normal file
39
src/seeders/role.seed.ts
Normal file
@@ -0,0 +1,39 @@
|
||||
import Role from "../models/Role";
|
||||
|
||||
export async function seedRoles() {
|
||||
const roles = [
|
||||
{
|
||||
name: "manager",
|
||||
description: "مدیر",
|
||||
},
|
||||
{
|
||||
name: "supervisor",
|
||||
description: "مسئول",
|
||||
},
|
||||
{
|
||||
name: "senior_expert",
|
||||
description: "کارشناس مسئول",
|
||||
},
|
||||
{
|
||||
name: "expert",
|
||||
description: "کارشناس",
|
||||
},
|
||||
{
|
||||
name: "technician",
|
||||
description: "کاردان",
|
||||
},
|
||||
{
|
||||
name: "user",
|
||||
description: "کاربر معمولی",
|
||||
},
|
||||
];
|
||||
|
||||
for (const role of roles) {
|
||||
await Role.findOrCreate({
|
||||
where: { name: role.name }, // چون unique است
|
||||
defaults: role,
|
||||
});
|
||||
}
|
||||
|
||||
console.log("Roles seeded ✅");
|
||||
}
|
||||
39
src/seeders/user.seed.ts
Normal file
39
src/seeders/user.seed.ts
Normal file
@@ -0,0 +1,39 @@
|
||||
import User from "../models/User";
|
||||
|
||||
export async function seedUsers() {
|
||||
const users = [
|
||||
{
|
||||
fullname: "جعفری",
|
||||
nationalCode: "0010000001",
|
||||
mobile: "09120000001",
|
||||
roleId: "48cb63ff-398f-4a9a-8cec-43540c8260b3",
|
||||
},
|
||||
{
|
||||
fullname: "حاجیان",
|
||||
nationalCode: "0010000002",
|
||||
mobile: "09120000002",
|
||||
roleId: "48cb63ff-398f-4a9a-8cec-43540c8260b3",
|
||||
},
|
||||
{
|
||||
fullname: "دبیری",
|
||||
nationalCode: "0010000003",
|
||||
mobile: "09120000003",
|
||||
roleId: "48cb63ff-398f-4a9a-8cec-43540c8260b3",
|
||||
},
|
||||
{
|
||||
fullname: "خورشیدکلاه",
|
||||
nationalCode: "0010000004",
|
||||
mobile: "09120000004",
|
||||
roleId: "48cb63ff-398f-4a9a-8cec-43540c8260b3",
|
||||
},
|
||||
];
|
||||
|
||||
for (const u of users) {
|
||||
await User.findOrCreate({
|
||||
where: { nationalCode: u.nationalCode }, // چون unique است
|
||||
defaults: u,
|
||||
});
|
||||
}
|
||||
|
||||
console.log("Users seeded ✅");
|
||||
}
|
||||
Reference in New Issue
Block a user