Productionize EventSphere platform
This commit is contained in:
40
apps/api/src/modules/settings/settings.service.ts
Normal file
40
apps/api/src/modules/settings/settings.service.ts
Normal file
@@ -0,0 +1,40 @@
|
||||
import { Injectable } from "@nestjs/common";
|
||||
import { PrismaService } from "../../prisma/prisma.service";
|
||||
import type { UpdateTenantSettingsDto } from "./dto";
|
||||
|
||||
@Injectable()
|
||||
export class SettingsService {
|
||||
constructor(private readonly prisma: PrismaService) {}
|
||||
|
||||
async get(tenantId: string) {
|
||||
const row = await this.prisma.tenantSetting.findUnique({ where: { tenantId } });
|
||||
return {
|
||||
appName: row?.appName ?? null,
|
||||
logoUrl: row?.logoUrl ?? null,
|
||||
modules: (row?.modules as any) ?? null
|
||||
};
|
||||
}
|
||||
|
||||
async update(tenantId: string, dto: UpdateTenantSettingsDto) {
|
||||
const row = await this.prisma.tenantSetting.upsert({
|
||||
where: { tenantId },
|
||||
create: { tenantId, appName: dto.appName, modules: dto.modules ?? undefined },
|
||||
update: { appName: dto.appName, modules: dto.modules ?? undefined }
|
||||
});
|
||||
return {
|
||||
appName: row.appName ?? null,
|
||||
logoUrl: row.logoUrl ?? null,
|
||||
modules: (row.modules as any) ?? null
|
||||
};
|
||||
}
|
||||
|
||||
async setLogo(tenantId: string, logoUrl: string) {
|
||||
const row = await this.prisma.tenantSetting.upsert({
|
||||
where: { tenantId },
|
||||
create: { tenantId, logoUrl },
|
||||
update: { logoUrl }
|
||||
});
|
||||
return { logoUrl: row.logoUrl ?? null };
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user