chore: user setting module
This commit is contained in:
@@ -2,6 +2,7 @@ import { Logger } from "@nestjs/common";
|
||||
|
||||
import { connectionSource } from "./connection";
|
||||
import { seedAdmin } from "./seeders/admin.seeder";
|
||||
import { seedNotifSettings } from "./seeders/notif-settting.seeder";
|
||||
import { seedRole } from "./seeders/role.seeder";
|
||||
|
||||
const logger = new Logger("Seeder");
|
||||
@@ -11,6 +12,7 @@ export const runSeeder = async () => {
|
||||
logger.log("start seeding database");
|
||||
await seedRole(connectionSource, logger);
|
||||
await seedAdmin(connectionSource, logger);
|
||||
await seedNotifSettings(connectionSource, logger);
|
||||
|
||||
logger.log("seeding completed");
|
||||
process.exit(0);
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
import { Logger } from "@nestjs/common";
|
||||
import { DataSource } from "typeorm";
|
||||
|
||||
import { NotifSetting } from "../../src/modules/settings/entities/notif-setting.entity";
|
||||
import { FarsiNotifSettingsEnum, NotifSettingsEnum } from "../../src/modules/settings/enums/notif-settings.enum";
|
||||
|
||||
const notifSettings = [
|
||||
{ title: NotifSettingsEnum.ANNOUNCE_NOTIF, title_fa: FarsiNotifSettingsEnum.ANNOUNCE_NOTIF },
|
||||
{ title: NotifSettingsEnum.ANSWER_TICKET, title_fa: FarsiNotifSettingsEnum.ANSWER_TICKET },
|
||||
{ title: NotifSettingsEnum.BILL_PAYMENT, title_fa: FarsiNotifSettingsEnum.BILL_PAYMENT },
|
||||
{ title: NotifSettingsEnum.BILL_PAYMENT_REMINDER, title_fa: FarsiNotifSettingsEnum.BILL_PAYMENT_REMINDER },
|
||||
{ title: NotifSettingsEnum.BLOCKING_SERVICE, title_fa: FarsiNotifSettingsEnum.BLOCKING_SERVICE },
|
||||
{ title: NotifSettingsEnum.CREATE_INVOICE, title_fa: FarsiNotifSettingsEnum.CREATE_INVOICE },
|
||||
{ title: NotifSettingsEnum.CREATE_TICKET, title_fa: FarsiNotifSettingsEnum.CREATE_TICKET },
|
||||
{ title: NotifSettingsEnum.UNBLOCKING_SERVICE, title_fa: FarsiNotifSettingsEnum.UNBLOCKING_SERVICE },
|
||||
{ title: NotifSettingsEnum.CREATE_SERIVCE, title_fa: FarsiNotifSettingsEnum.CREATE_SERIVCE },
|
||||
];
|
||||
|
||||
export const seedNotifSettings = async (dataSource: DataSource, logger: Logger) => {
|
||||
try {
|
||||
const notifSettingRepo = dataSource.getRepository(NotifSetting);
|
||||
for (const setting of notifSettings) {
|
||||
const newSetting = notifSettingRepo.create(setting);
|
||||
await notifSettingRepo.save(newSetting);
|
||||
}
|
||||
logger.log("Notif Settings Successfully");
|
||||
} catch (error) {
|
||||
logger.error("Error in seeding settings", error);
|
||||
process.exit(1);
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user