refactor: 拆分后台工作区与API模块
This commit is contained in:
1 parent
12bc263d3b
commit
b23120477f
16 files changed
+415
-297
No files matched your search
@@ -1,195 +0,0 @@
|
|||||||
import { Body, Controller, Delete, Get, Param, Patch, Post, Req } from "@nestjs/common";
|
|
||||||
import type { FastifyRequest } from "fastify";
|
|
||||||
import {
|
|
||||||
InstallTemplateDto,
|
|
||||||
CreateOfferingDto,
|
|
||||||
UpdateOfferingDto,
|
|
||||||
CreateFieldDefinitionDto,
|
|
||||||
UpdateFieldDefinitionDto,
|
|
||||||
CreateInquiryFormDto,
|
|
||||||
UpdateInquiryFormDto,
|
|
||||||
UpdateInquirySubmissionDto,
|
|
||||||
UpdateCapabilityInstallationDto,
|
|
||||||
} from "./admin.dto.js";
|
|
||||||
import { TemplateWorkspaceService } from "./template-workspace.service.js";
|
|
||||||
import { AdminOfferingService } from "./modules/workspace/admin-offering.service.js";
|
|
||||||
import { AdminWorkspaceService } from "./modules/workspace/admin-workspace.service.js";
|
|
||||||
import { AdminWorkspaceCapabilitiesService } from "./modules/workspace/admin-workspace-capabilities.service.js";
|
|
||||||
import { AdminSampleContentService } from "./modules/workspace/admin-sample-content.service.js";
|
|
||||||
import { AdminInquiryService } from "./modules/workspace/admin-inquiry.service.js";
|
|
||||||
import { requireAdminIdentity } from "./modules/workspace/admin-access.identity.js";
|
|
||||||
|
|
||||||
@Controller("admin/workspace")
|
|
||||||
class AdminWorkspaceController {
|
|
||||||
constructor(
|
|
||||||
private readonly templateWorkspace: TemplateWorkspaceService,
|
|
||||||
private readonly offeringService: AdminOfferingService,
|
|
||||||
private readonly workspaceService: AdminWorkspaceService,
|
|
||||||
private readonly capabilitiesService: AdminWorkspaceCapabilitiesService,
|
|
||||||
private readonly sampleContentService: AdminSampleContentService,
|
|
||||||
private readonly inquiryService: AdminInquiryService,
|
|
||||||
) {}
|
|
||||||
|
|
||||||
@Get("offerings")
|
|
||||||
listOfferings(@Req() request: FastifyRequest): Promise<unknown> {
|
|
||||||
const brandId = requireAdminIdentity(request).brandId;
|
|
||||||
return this.offeringService.list(brandId);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Post("offerings")
|
|
||||||
createOffering(
|
|
||||||
@Req() request: FastifyRequest,
|
|
||||||
@Body() body: CreateOfferingDto,
|
|
||||||
): Promise<unknown> {
|
|
||||||
const brandId = requireAdminIdentity(request).brandId;
|
|
||||||
return this.offeringService.create(brandId, body);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Patch("offerings/:id")
|
|
||||||
async updateOffering(
|
|
||||||
@Req() request: FastifyRequest,
|
|
||||||
@Param("id") id: string,
|
|
||||||
@Body() body: UpdateOfferingDto,
|
|
||||||
): Promise<unknown> {
|
|
||||||
const brandId = requireAdminIdentity(request).brandId;
|
|
||||||
return this.offeringService.update(brandId, id, body);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Delete("offerings/:id")
|
|
||||||
async deleteOffering(@Req() request: FastifyRequest, @Param("id") id: string): Promise<unknown> {
|
|
||||||
const brandId = requireAdminIdentity(request).brandId;
|
|
||||||
return this.offeringService.delete(brandId, id);
|
|
||||||
}
|
|
||||||
@Get()
|
|
||||||
get(@Req() request: FastifyRequest): Promise<unknown> {
|
|
||||||
const brandId = requireAdminIdentity(request).brandId;
|
|
||||||
return this.workspaceService.get(brandId);
|
|
||||||
}
|
|
||||||
@Get("preview")
|
|
||||||
async getPreviewWorkspace(@Req() request: FastifyRequest): Promise<unknown> {
|
|
||||||
const { brandId } = requireAdminIdentity(request);
|
|
||||||
return this.workspaceService.getPreview(brandId);
|
|
||||||
}
|
|
||||||
@Post("install")
|
|
||||||
async install(
|
|
||||||
@Req() request: FastifyRequest,
|
|
||||||
@Body() body: InstallTemplateDto,
|
|
||||||
): Promise<unknown> {
|
|
||||||
const { brandId } = requireAdminIdentity(request);
|
|
||||||
return this.templateWorkspace.install(brandId, body.templateKey);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Get("capabilities")
|
|
||||||
async listCapabilities(@Req() request: FastifyRequest): Promise<unknown> {
|
|
||||||
const brandId = requireAdminIdentity(request).brandId;
|
|
||||||
return this.capabilitiesService.list(brandId);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Get("sample-content/preview")
|
|
||||||
async previewSampleContent(@Req() request: FastifyRequest): Promise<unknown> {
|
|
||||||
const brandId = requireAdminIdentity(request).brandId;
|
|
||||||
return this.sampleContentService.preview(brandId);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Post("sample-content/import")
|
|
||||||
async importSampleContent(@Req() request: FastifyRequest): Promise<unknown> {
|
|
||||||
const identity = requireAdminIdentity(request);
|
|
||||||
return this.sampleContentService.import(identity.brandId, identity.subject);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Patch("capabilities/:key")
|
|
||||||
async updateCapability(
|
|
||||||
@Req() request: FastifyRequest,
|
|
||||||
@Param("key") key: string,
|
|
||||||
@Body() body: UpdateCapabilityInstallationDto,
|
|
||||||
): Promise<unknown> {
|
|
||||||
const identity = requireAdminIdentity(request);
|
|
||||||
return this.capabilitiesService.update(identity.brandId, identity.subject, key, body);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Get("template/preview")
|
|
||||||
async previewTemplate(@Req() request: FastifyRequest): Promise<unknown> {
|
|
||||||
const { brandId } = requireAdminIdentity(request);
|
|
||||||
return this.templateWorkspace.preview(brandId);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Post("template/upgrade")
|
|
||||||
async upgradeTemplate(@Req() request: FastifyRequest): Promise<unknown> {
|
|
||||||
const { brandId } = requireAdminIdentity(request);
|
|
||||||
return this.templateWorkspace.upgrade(brandId);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Post("template/rollback")
|
|
||||||
async rollbackTemplate(@Req() request: FastifyRequest): Promise<unknown> {
|
|
||||||
const { brandId } = requireAdminIdentity(request);
|
|
||||||
return this.templateWorkspace.rollback(brandId);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Post("fields")
|
|
||||||
createField(
|
|
||||||
@Req() request: FastifyRequest,
|
|
||||||
@Body() body: CreateFieldDefinitionDto,
|
|
||||||
): Promise<unknown> {
|
|
||||||
const brandId = requireAdminIdentity(request).brandId;
|
|
||||||
return this.inquiryService.createField(brandId, body);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Patch("fields/:id")
|
|
||||||
async updateField(
|
|
||||||
@Req() request: FastifyRequest,
|
|
||||||
@Param("id") id: string,
|
|
||||||
@Body() body: UpdateFieldDefinitionDto,
|
|
||||||
): Promise<unknown> {
|
|
||||||
const brandId = requireAdminIdentity(request).brandId;
|
|
||||||
return this.inquiryService.updateField(brandId, id, body);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Delete("fields/:id")
|
|
||||||
async deleteField(@Req() request: FastifyRequest, @Param("id") id: string): Promise<unknown> {
|
|
||||||
const brandId = requireAdminIdentity(request).brandId;
|
|
||||||
return this.inquiryService.deleteField(brandId, id);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Get("forms")
|
|
||||||
listForms(@Req() request: FastifyRequest): Promise<unknown> {
|
|
||||||
const brandId = requireAdminIdentity(request).brandId;
|
|
||||||
return this.inquiryService.listForms(brandId);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Get("submissions")
|
|
||||||
listSubmissions(@Req() request: FastifyRequest): Promise<unknown> {
|
|
||||||
const brandId = requireAdminIdentity(request).brandId;
|
|
||||||
return this.inquiryService.listSubmissions(brandId);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Patch("submissions/:id")
|
|
||||||
async updateSubmission(
|
|
||||||
@Req() request: FastifyRequest,
|
|
||||||
@Param("id") id: string,
|
|
||||||
@Body() body: UpdateInquirySubmissionDto,
|
|
||||||
): Promise<unknown> {
|
|
||||||
const brandId = requireAdminIdentity(request).brandId;
|
|
||||||
return this.inquiryService.updateSubmission(brandId, id, body);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Post("forms")
|
|
||||||
async createForm(
|
|
||||||
@Req() request: FastifyRequest,
|
|
||||||
@Body() body: CreateInquiryFormDto,
|
|
||||||
): Promise<unknown> {
|
|
||||||
const brandId = requireAdminIdentity(request).brandId;
|
|
||||||
return this.inquiryService.createForm(brandId, body);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Patch("forms/:id")
|
|
||||||
async updateForm(
|
|
||||||
@Req() request: FastifyRequest,
|
|
||||||
@Param("id") id: string,
|
|
||||||
@Body() body: UpdateInquiryFormDto,
|
|
||||||
): Promise<unknown> {
|
|
||||||
const brandId = requireAdminIdentity(request).brandId;
|
|
||||||
return this.inquiryService.updateForm(brandId, id, body);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export { AdminWorkspaceController };
|
|
||||||
+19
-102
@@ -1,113 +1,30 @@
|
|||||||
import "reflect-metadata";
|
import "reflect-metadata";
|
||||||
import { Controller, Get, Module, ValidationPipe } from "@nestjs/common";
|
import { Module, ValidationPipe } from "@nestjs/common";
|
||||||
import { APP_GUARD } from "@nestjs/core";
|
import { APP_GUARD } from "@nestjs/core";
|
||||||
import type { NestFastifyApplication } from "@nestjs/platform-fastify";
|
import type { NestFastifyApplication } from "@nestjs/platform-fastify";
|
||||||
import { PrismaService } from "./prisma.service.js";
|
|
||||||
import { WechatAuthService } from "./wechat-auth.js";
|
|
||||||
import { BookingService } from "./booking.service.js";
|
|
||||||
import { AdminAuthService } from "./admin-auth.service.js";
|
|
||||||
import { ApiExceptionFilter, RequestIdMiddleware } from "./http.js";
|
import { ApiExceptionFilter, RequestIdMiddleware } from "./http.js";
|
||||||
import { AdminWorkspaceController } from "./admin-workspace.controller.js";
|
|
||||||
import { PublicWorkspaceController } from "./modules/public/public-workspace.controller.js";
|
|
||||||
import { PublicWorkspaceService } from "./modules/public/public-workspace.service.js";
|
|
||||||
import { PublicBrandContextService } from "./modules/public/public-brand-context.service.js";
|
|
||||||
import { AdminOfferingService } from "./modules/workspace/admin-offering.service.js";
|
|
||||||
import { AdminWorkspaceService } from "./modules/workspace/admin-workspace.service.js";
|
|
||||||
import { AdminWorkspaceCapabilitiesService } from "./modules/workspace/admin-workspace-capabilities.service.js";
|
|
||||||
import { AdminSampleContentService } from "./modules/workspace/admin-sample-content.service.js";
|
|
||||||
import { AdminInquiryService } from "./modules/workspace/admin-inquiry.service.js";
|
|
||||||
import { AdminConfigController } from "./modules/admin/admin-config.controller.js";
|
|
||||||
import { AdminBrandConfigService } from "./modules/admin/admin-brand-config.service.js";
|
|
||||||
import { AdminUploadController } from "./modules/admin/admin-upload.controller.js";
|
|
||||||
import { AdminLocalUploadController } from "./modules/admin/admin-local-upload.controller.js";
|
|
||||||
import { PublicOfferingController } from "./modules/public/public-offering.controller.js";
|
|
||||||
import { PublicInquiryFormController } from "./modules/public/public-inquiry-form.controller.js";
|
|
||||||
import { CustomerInquirySubmissionController } from "./modules/customer/customer-inquiry-submission.controller.js";
|
|
||||||
import { CustomerInquirySubmissionService } from "./modules/customer/customer-inquiry-submission.service.js";
|
|
||||||
import { TemplateWorkspaceService } from "./template-workspace.service.js";
|
|
||||||
import { AdminAccessService } from "./admin-access.service.js";
|
|
||||||
import { AdminMembershipGuard } from "./admin-membership.guard.js";
|
import { AdminMembershipGuard } from "./admin-membership.guard.js";
|
||||||
import { BrandReleaseService } from "./brand-release.service.js";
|
import { AdminModule } from "./modules/admin/admin.module.js";
|
||||||
import { BrandReleaseApiService } from "./brand-release-api.service.js";
|
import { CustomerModule } from "./modules/customer/customer.module.js";
|
||||||
import { AdminReleaseController } from "./modules/admin/admin-release.controller.js";
|
import { HealthModule } from "./modules/health.module.js";
|
||||||
import { AdminMiniAppReleaseController } from "./modules/admin/admin-miniapp-release.controller.js";
|
import { InfrastructureModule } from "./modules/infrastructure.module.js";
|
||||||
import { AdminMiniAppReleaseService } from "./modules/admin/admin-miniapp-release.service.js";
|
import { PublicModule } from "./modules/public/public.module.js";
|
||||||
import { AdminMiniAppBuildService } from "./modules/admin/admin-miniapp-build.service.js";
|
import { SessionModule } from "./modules/session/session.module.js";
|
||||||
import { AdminMiniAppSettingsService } from "./modules/admin/admin-miniapp-settings.service.js";
|
import { TenantModule } from "./modules/tenant/tenant.module.js";
|
||||||
import { AdminMiniAppUploadService } from "./modules/admin/admin-miniapp-upload.service.js";
|
import { WorkspaceModule } from "./modules/workspace/workspace.module.js";
|
||||||
import {
|
|
||||||
CustomerSessionController,
|
|
||||||
AdminSessionController,
|
|
||||||
} from "./modules/session/session.controller.js";
|
|
||||||
import { CustomerSessionService } from "./modules/session/customer-session.service.js";
|
|
||||||
import { AdminBookingController } from "./modules/admin/admin-booking.controller.js";
|
|
||||||
import { CustomerBookingController } from "./modules/customer/customer-booking.controller.js";
|
|
||||||
import { TenantController } from "./modules/tenant/tenant.controller.js";
|
|
||||||
import { TenantService } from "./modules/tenant/tenant.service.js";
|
|
||||||
import {
|
|
||||||
PublicController,
|
|
||||||
PublicTemplateController,
|
|
||||||
PublicTrustContentController,
|
|
||||||
} from "./modules/public/public.controller.js";
|
|
||||||
|
|
||||||
@Controller("health")
|
|
||||||
export class HealthController {
|
|
||||||
@Get()
|
|
||||||
check(): { status: string; service: string } {
|
|
||||||
return { status: "ok", service: "personal-brand-api" };
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
controllers: [
|
imports: [
|
||||||
HealthController,
|
InfrastructureModule,
|
||||||
PublicController,
|
PublicModule,
|
||||||
PublicTrustContentController,
|
CustomerModule,
|
||||||
PublicTemplateController,
|
SessionModule,
|
||||||
PublicWorkspaceController,
|
TenantModule,
|
||||||
PublicOfferingController,
|
WorkspaceModule,
|
||||||
PublicInquiryFormController,
|
AdminModule,
|
||||||
CustomerInquirySubmissionController,
|
HealthModule,
|
||||||
AdminWorkspaceController,
|
|
||||||
CustomerSessionController,
|
|
||||||
AdminSessionController,
|
|
||||||
CustomerBookingController,
|
|
||||||
TenantController,
|
|
||||||
AdminBookingController,
|
|
||||||
AdminConfigController,
|
|
||||||
AdminReleaseController,
|
|
||||||
AdminMiniAppReleaseController,
|
|
||||||
AdminUploadController,
|
|
||||||
AdminLocalUploadController,
|
|
||||||
],
|
],
|
||||||
providers: [
|
providers: [{ provide: APP_GUARD, useClass: AdminMembershipGuard }],
|
||||||
{ provide: APP_GUARD, useClass: AdminMembershipGuard },
|
|
||||||
PrismaService,
|
|
||||||
WechatAuthService,
|
|
||||||
BookingService,
|
|
||||||
AdminAuthService,
|
|
||||||
CustomerSessionService,
|
|
||||||
TemplateWorkspaceService,
|
|
||||||
AdminAccessService,
|
|
||||||
AdminMembershipGuard,
|
|
||||||
BrandReleaseService,
|
|
||||||
BrandReleaseApiService,
|
|
||||||
AdminMiniAppReleaseService,
|
|
||||||
AdminMiniAppBuildService,
|
|
||||||
AdminMiniAppSettingsService,
|
|
||||||
AdminMiniAppUploadService,
|
|
||||||
AdminBrandConfigService,
|
|
||||||
TenantService,
|
|
||||||
CustomerInquirySubmissionService,
|
|
||||||
PublicBrandContextService,
|
|
||||||
PublicWorkspaceService,
|
|
||||||
AdminOfferingService,
|
|
||||||
AdminWorkspaceService,
|
|
||||||
AdminWorkspaceCapabilitiesService,
|
|
||||||
AdminSampleContentService,
|
|
||||||
AdminInquiryService,
|
|
||||||
],
|
|
||||||
exports: [PrismaService, WechatAuthService],
|
|
||||||
})
|
})
|
||||||
export class AppModule {}
|
export class AppModule {}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,34 @@
|
|||||||
|
import { Module } from "@nestjs/common";
|
||||||
|
import { BookingModule } from "../booking.module.js";
|
||||||
|
import { InfrastructureModule } from "../infrastructure.module.js";
|
||||||
|
import { AdminBookingController } from "./admin-booking.controller.js";
|
||||||
|
import { AdminBrandConfigService } from "./admin-brand-config.service.js";
|
||||||
|
import { AdminConfigController } from "./admin-config.controller.js";
|
||||||
|
import { AdminLocalUploadController } from "./admin-local-upload.controller.js";
|
||||||
|
import { AdminMiniAppBuildService } from "./admin-miniapp-build.service.js";
|
||||||
|
import { AdminMiniAppReleaseController } from "./admin-miniapp-release.controller.js";
|
||||||
|
import { AdminMiniAppReleaseService } from "./admin-miniapp-release.service.js";
|
||||||
|
import { AdminMiniAppSettingsService } from "./admin-miniapp-settings.service.js";
|
||||||
|
import { AdminMiniAppUploadService } from "./admin-miniapp-upload.service.js";
|
||||||
|
import { AdminReleaseController } from "./admin-release.controller.js";
|
||||||
|
import { AdminUploadController } from "./admin-upload.controller.js";
|
||||||
|
|
||||||
|
@Module({
|
||||||
|
imports: [InfrastructureModule, BookingModule],
|
||||||
|
controllers: [
|
||||||
|
AdminConfigController,
|
||||||
|
AdminReleaseController,
|
||||||
|
AdminMiniAppReleaseController,
|
||||||
|
AdminUploadController,
|
||||||
|
AdminLocalUploadController,
|
||||||
|
AdminBookingController,
|
||||||
|
],
|
||||||
|
providers: [
|
||||||
|
AdminBrandConfigService,
|
||||||
|
AdminMiniAppReleaseService,
|
||||||
|
AdminMiniAppBuildService,
|
||||||
|
AdminMiniAppSettingsService,
|
||||||
|
AdminMiniAppUploadService,
|
||||||
|
],
|
||||||
|
})
|
||||||
|
export class AdminModule {}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
import { Module } from "@nestjs/common";
|
||||||
|
import { BookingService } from "../booking.service.js";
|
||||||
|
import { InfrastructureModule } from "./infrastructure.module.js";
|
||||||
|
|
||||||
|
@Module({
|
||||||
|
imports: [InfrastructureModule],
|
||||||
|
providers: [BookingService],
|
||||||
|
exports: [BookingService],
|
||||||
|
})
|
||||||
|
export class BookingModule {}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
import { Module } from "@nestjs/common";
|
||||||
|
import { BookingModule } from "../booking.module.js";
|
||||||
|
import { InfrastructureModule } from "../infrastructure.module.js";
|
||||||
|
import { PublicModule } from "../public/public.module.js";
|
||||||
|
import { CustomerBookingController } from "./customer-booking.controller.js";
|
||||||
|
import { CustomerInquirySubmissionController } from "./customer-inquiry-submission.controller.js";
|
||||||
|
import { CustomerInquirySubmissionService } from "./customer-inquiry-submission.service.js";
|
||||||
|
|
||||||
|
@Module({
|
||||||
|
imports: [InfrastructureModule, PublicModule, BookingModule],
|
||||||
|
controllers: [CustomerInquirySubmissionController, CustomerBookingController],
|
||||||
|
providers: [CustomerInquirySubmissionService],
|
||||||
|
})
|
||||||
|
export class CustomerModule {}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
import { Controller, Get, Module } from "@nestjs/common";
|
||||||
|
|
||||||
|
@Controller("health")
|
||||||
|
export class HealthController {
|
||||||
|
@Get()
|
||||||
|
check(): { status: string; service: string } {
|
||||||
|
return { status: "ok", service: "personal-brand-api" };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Module({
|
||||||
|
controllers: [HealthController],
|
||||||
|
})
|
||||||
|
export class HealthModule {}
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
import { Module } from "@nestjs/common";
|
||||||
|
import { AdminAccessService } from "../admin-access.service.js";
|
||||||
|
import { AdminMembershipGuard } from "../admin-membership.guard.js";
|
||||||
|
import { BrandReleaseApiService } from "../brand-release-api.service.js";
|
||||||
|
import { BrandReleaseService } from "../brand-release.service.js";
|
||||||
|
import { PrismaService } from "../prisma.service.js";
|
||||||
|
import { TemplateWorkspaceService } from "../template-workspace.service.js";
|
||||||
|
import { WechatAuthService } from "../wechat-auth.js";
|
||||||
|
|
||||||
|
@Module({
|
||||||
|
providers: [
|
||||||
|
PrismaService,
|
||||||
|
WechatAuthService,
|
||||||
|
AdminAccessService,
|
||||||
|
AdminMembershipGuard,
|
||||||
|
BrandReleaseService,
|
||||||
|
BrandReleaseApiService,
|
||||||
|
TemplateWorkspaceService,
|
||||||
|
],
|
||||||
|
exports: [
|
||||||
|
PrismaService,
|
||||||
|
WechatAuthService,
|
||||||
|
AdminAccessService,
|
||||||
|
AdminMembershipGuard,
|
||||||
|
BrandReleaseService,
|
||||||
|
BrandReleaseApiService,
|
||||||
|
TemplateWorkspaceService,
|
||||||
|
],
|
||||||
|
})
|
||||||
|
export class InfrastructureModule {}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
import { Module } from "@nestjs/common";
|
||||||
|
import { InfrastructureModule } from "../infrastructure.module.js";
|
||||||
|
import {
|
||||||
|
PublicController,
|
||||||
|
PublicTemplateController,
|
||||||
|
PublicTrustContentController,
|
||||||
|
} from "./public.controller.js";
|
||||||
|
import { PublicBrandContextService } from "./public-brand-context.service.js";
|
||||||
|
import { PublicInquiryFormController } from "./public-inquiry-form.controller.js";
|
||||||
|
import { PublicOfferingController } from "./public-offering.controller.js";
|
||||||
|
import { PublicWorkspaceController } from "./public-workspace.controller.js";
|
||||||
|
import { PublicWorkspaceService } from "./public-workspace.service.js";
|
||||||
|
|
||||||
|
@Module({
|
||||||
|
imports: [InfrastructureModule],
|
||||||
|
controllers: [
|
||||||
|
PublicController,
|
||||||
|
PublicTrustContentController,
|
||||||
|
PublicTemplateController,
|
||||||
|
PublicWorkspaceController,
|
||||||
|
PublicOfferingController,
|
||||||
|
PublicInquiryFormController,
|
||||||
|
],
|
||||||
|
providers: [PublicBrandContextService, PublicWorkspaceService],
|
||||||
|
exports: [PublicBrandContextService, PublicWorkspaceService],
|
||||||
|
})
|
||||||
|
export class PublicModule {}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
import { Module } from "@nestjs/common";
|
||||||
|
import { AdminAuthService } from "../../admin-auth.service.js";
|
||||||
|
import { InfrastructureModule } from "../infrastructure.module.js";
|
||||||
|
import { PublicModule } from "../public/public.module.js";
|
||||||
|
import { CustomerSessionService } from "./customer-session.service.js";
|
||||||
|
import { AdminSessionController, CustomerSessionController } from "./session.controller.js";
|
||||||
|
|
||||||
|
@Module({
|
||||||
|
imports: [InfrastructureModule, PublicModule],
|
||||||
|
controllers: [CustomerSessionController, AdminSessionController],
|
||||||
|
providers: [AdminAuthService, CustomerSessionService],
|
||||||
|
})
|
||||||
|
export class SessionModule {}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
import { Module } from "@nestjs/common";
|
||||||
|
import { InfrastructureModule } from "../infrastructure.module.js";
|
||||||
|
import { TenantController } from "./tenant.controller.js";
|
||||||
|
import { TenantService } from "./tenant.service.js";
|
||||||
|
|
||||||
|
@Module({
|
||||||
|
imports: [InfrastructureModule],
|
||||||
|
controllers: [TenantController],
|
||||||
|
providers: [TenantService],
|
||||||
|
})
|
||||||
|
export class TenantModule {}
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
import { Body, Controller, Get, Param, Patch, Post, Req } from "@nestjs/common";
|
||||||
|
import type { FastifyRequest } from "fastify";
|
||||||
|
import { UpdateCapabilityInstallationDto } from "../../admin.dto.js";
|
||||||
|
import { requireAdminIdentity } from "./admin-access.identity.js";
|
||||||
|
import { AdminSampleContentService } from "./admin-sample-content.service.js";
|
||||||
|
import { AdminWorkspaceCapabilitiesService } from "./admin-workspace-capabilities.service.js";
|
||||||
|
|
||||||
|
@Controller("admin/workspace")
|
||||||
|
class AdminCapabilityController {
|
||||||
|
constructor(
|
||||||
|
private readonly capabilitiesService: AdminWorkspaceCapabilitiesService,
|
||||||
|
private readonly sampleContentService: AdminSampleContentService,
|
||||||
|
) {}
|
||||||
|
|
||||||
|
@Get("capabilities")
|
||||||
|
list(@Req() request: FastifyRequest): Promise<unknown> {
|
||||||
|
return this.capabilitiesService.list(requireAdminIdentity(request).brandId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Get("sample-content/preview")
|
||||||
|
previewSampleContent(@Req() request: FastifyRequest): Promise<unknown> {
|
||||||
|
return this.sampleContentService.preview(requireAdminIdentity(request).brandId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Post("sample-content/import")
|
||||||
|
importSampleContent(@Req() request: FastifyRequest): Promise<unknown> {
|
||||||
|
const identity = requireAdminIdentity(request);
|
||||||
|
return this.sampleContentService.import(identity.brandId, identity.subject);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Patch("capabilities/:key")
|
||||||
|
update(
|
||||||
|
@Req() request: FastifyRequest,
|
||||||
|
@Param("key") key: string,
|
||||||
|
@Body() body: UpdateCapabilityInstallationDto,
|
||||||
|
): Promise<unknown> {
|
||||||
|
const identity = requireAdminIdentity(request);
|
||||||
|
return this.capabilitiesService.update(identity.brandId, identity.subject, key, body);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export { AdminCapabilityController };
|
||||||
@@ -0,0 +1,76 @@
|
|||||||
|
import { Body, Controller, Delete, Get, Param, Patch, Post, Req } from "@nestjs/common";
|
||||||
|
import type { FastifyRequest } from "fastify";
|
||||||
|
import {
|
||||||
|
CreateFieldDefinitionDto,
|
||||||
|
CreateInquiryFormDto,
|
||||||
|
UpdateFieldDefinitionDto,
|
||||||
|
UpdateInquiryFormDto,
|
||||||
|
UpdateInquirySubmissionDto,
|
||||||
|
} from "../../admin.dto.js";
|
||||||
|
import { requireAdminIdentity } from "./admin-access.identity.js";
|
||||||
|
import { AdminInquiryService } from "./admin-inquiry.service.js";
|
||||||
|
|
||||||
|
@Controller("admin/workspace")
|
||||||
|
class AdminInquiryController {
|
||||||
|
constructor(private readonly inquiryService: AdminInquiryService) {}
|
||||||
|
|
||||||
|
@Post("fields")
|
||||||
|
createField(
|
||||||
|
@Req() request: FastifyRequest,
|
||||||
|
@Body() body: CreateFieldDefinitionDto,
|
||||||
|
): Promise<unknown> {
|
||||||
|
return this.inquiryService.createField(requireAdminIdentity(request).brandId, body);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Patch("fields/:id")
|
||||||
|
async updateField(
|
||||||
|
@Req() request: FastifyRequest,
|
||||||
|
@Param("id") id: string,
|
||||||
|
@Body() body: UpdateFieldDefinitionDto,
|
||||||
|
): Promise<unknown> {
|
||||||
|
return this.inquiryService.updateField(requireAdminIdentity(request).brandId, id, body);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Delete("fields/:id")
|
||||||
|
async deleteField(@Req() request: FastifyRequest, @Param("id") id: string): Promise<unknown> {
|
||||||
|
return this.inquiryService.deleteField(requireAdminIdentity(request).brandId, id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Get("forms")
|
||||||
|
listForms(@Req() request: FastifyRequest): Promise<unknown> {
|
||||||
|
return this.inquiryService.listForms(requireAdminIdentity(request).brandId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Get("submissions")
|
||||||
|
listSubmissions(@Req() request: FastifyRequest): Promise<unknown> {
|
||||||
|
return this.inquiryService.listSubmissions(requireAdminIdentity(request).brandId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Patch("submissions/:id")
|
||||||
|
async updateSubmission(
|
||||||
|
@Req() request: FastifyRequest,
|
||||||
|
@Param("id") id: string,
|
||||||
|
@Body() body: UpdateInquirySubmissionDto,
|
||||||
|
): Promise<unknown> {
|
||||||
|
return this.inquiryService.updateSubmission(requireAdminIdentity(request).brandId, id, body);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Post("forms")
|
||||||
|
async createForm(
|
||||||
|
@Req() request: FastifyRequest,
|
||||||
|
@Body() body: CreateInquiryFormDto,
|
||||||
|
): Promise<unknown> {
|
||||||
|
return this.inquiryService.createForm(requireAdminIdentity(request).brandId, body);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Patch("forms/:id")
|
||||||
|
async updateForm(
|
||||||
|
@Req() request: FastifyRequest,
|
||||||
|
@Param("id") id: string,
|
||||||
|
@Body() body: UpdateInquiryFormDto,
|
||||||
|
): Promise<unknown> {
|
||||||
|
return this.inquiryService.updateForm(requireAdminIdentity(request).brandId, id, body);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export { AdminInquiryController };
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
import { Body, Controller, Delete, Get, Param, Patch, Post, Req } from "@nestjs/common";
|
||||||
|
import type { FastifyRequest } from "fastify";
|
||||||
|
import { CreateOfferingDto, UpdateOfferingDto } from "../../admin.dto.js";
|
||||||
|
import { requireAdminIdentity } from "./admin-access.identity.js";
|
||||||
|
import { AdminOfferingService } from "./admin-offering.service.js";
|
||||||
|
|
||||||
|
@Controller("admin/workspace")
|
||||||
|
class AdminOfferingController {
|
||||||
|
constructor(private readonly offeringService: AdminOfferingService) {}
|
||||||
|
|
||||||
|
@Get("offerings")
|
||||||
|
list(@Req() request: FastifyRequest): Promise<unknown> {
|
||||||
|
return this.offeringService.list(requireAdminIdentity(request).brandId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Post("offerings")
|
||||||
|
create(@Req() request: FastifyRequest, @Body() body: CreateOfferingDto): Promise<unknown> {
|
||||||
|
return this.offeringService.create(requireAdminIdentity(request).brandId, body);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Patch("offerings/:id")
|
||||||
|
async update(
|
||||||
|
@Req() request: FastifyRequest,
|
||||||
|
@Param("id") id: string,
|
||||||
|
@Body() body: UpdateOfferingDto,
|
||||||
|
): Promise<unknown> {
|
||||||
|
return this.offeringService.update(requireAdminIdentity(request).brandId, id, body);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Delete("offerings/:id")
|
||||||
|
async delete(@Req() request: FastifyRequest, @Param("id") id: string): Promise<unknown> {
|
||||||
|
return this.offeringService.delete(requireAdminIdentity(request).brandId, id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export { AdminOfferingController };
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
import { Controller, Get, Post, Req } from "@nestjs/common";
|
||||||
|
import type { FastifyRequest } from "fastify";
|
||||||
|
import { TemplateWorkspaceService } from "../../template-workspace.service.js";
|
||||||
|
import { requireAdminIdentity } from "./admin-access.identity.js";
|
||||||
|
|
||||||
|
@Controller("admin/workspace")
|
||||||
|
class AdminTemplateController {
|
||||||
|
constructor(private readonly templateWorkspace: TemplateWorkspaceService) {}
|
||||||
|
|
||||||
|
@Get("template/preview")
|
||||||
|
preview(@Req() request: FastifyRequest): Promise<unknown> {
|
||||||
|
return this.templateWorkspace.preview(requireAdminIdentity(request).brandId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Post("template/upgrade")
|
||||||
|
upgrade(@Req() request: FastifyRequest): Promise<unknown> {
|
||||||
|
return this.templateWorkspace.upgrade(requireAdminIdentity(request).brandId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Post("template/rollback")
|
||||||
|
rollback(@Req() request: FastifyRequest): Promise<unknown> {
|
||||||
|
return this.templateWorkspace.rollback(requireAdminIdentity(request).brandId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export { AdminTemplateController };
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
import { Controller, Get, Post, Body, Req } from "@nestjs/common";
|
||||||
|
import type { FastifyRequest } from "fastify";
|
||||||
|
import { InstallTemplateDto } from "../../admin.dto.js";
|
||||||
|
import { TemplateWorkspaceService } from "../../template-workspace.service.js";
|
||||||
|
import { requireAdminIdentity } from "./admin-access.identity.js";
|
||||||
|
import { AdminWorkspaceService } from "./admin-workspace.service.js";
|
||||||
|
|
||||||
|
@Controller("admin/workspace")
|
||||||
|
class AdminWorkspacePreviewController {
|
||||||
|
constructor(
|
||||||
|
private readonly workspaceService: AdminWorkspaceService,
|
||||||
|
private readonly templateWorkspace: TemplateWorkspaceService,
|
||||||
|
) {}
|
||||||
|
|
||||||
|
@Get()
|
||||||
|
get(@Req() request: FastifyRequest): Promise<unknown> {
|
||||||
|
return this.workspaceService.get(requireAdminIdentity(request).brandId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Get("preview")
|
||||||
|
getPreview(@Req() request: FastifyRequest): Promise<unknown> {
|
||||||
|
return this.workspaceService.getPreview(requireAdminIdentity(request).brandId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Post("install")
|
||||||
|
install(@Req() request: FastifyRequest, @Body() body: InstallTemplateDto): Promise<unknown> {
|
||||||
|
return this.templateWorkspace.install(requireAdminIdentity(request).brandId, body.templateKey);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export { AdminWorkspacePreviewController };
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
import { Module } from "@nestjs/common";
|
||||||
|
import { InfrastructureModule } from "../infrastructure.module.js";
|
||||||
|
import { PublicModule } from "../public/public.module.js";
|
||||||
|
import { AdminCapabilityController } from "./admin-capability.controller.js";
|
||||||
|
import { AdminInquiryController } from "./admin-inquiry.controller.js";
|
||||||
|
import { AdminInquiryService } from "./admin-inquiry.service.js";
|
||||||
|
import { AdminOfferingController } from "./admin-offering.controller.js";
|
||||||
|
import { AdminOfferingService } from "./admin-offering.service.js";
|
||||||
|
import { AdminSampleContentService } from "./admin-sample-content.service.js";
|
||||||
|
import { AdminTemplateController } from "./admin-template.controller.js";
|
||||||
|
import { AdminWorkspaceCapabilitiesService } from "./admin-workspace-capabilities.service.js";
|
||||||
|
import { AdminWorkspacePreviewController } from "./admin-workspace-preview.controller.js";
|
||||||
|
import { AdminWorkspaceService } from "./admin-workspace.service.js";
|
||||||
|
|
||||||
|
@Module({
|
||||||
|
imports: [InfrastructureModule, PublicModule],
|
||||||
|
controllers: [
|
||||||
|
AdminWorkspacePreviewController,
|
||||||
|
AdminTemplateController,
|
||||||
|
AdminCapabilityController,
|
||||||
|
AdminOfferingController,
|
||||||
|
AdminInquiryController,
|
||||||
|
],
|
||||||
|
providers: [
|
||||||
|
AdminOfferingService,
|
||||||
|
AdminWorkspaceService,
|
||||||
|
AdminWorkspaceCapabilitiesService,
|
||||||
|
AdminSampleContentService,
|
||||||
|
AdminInquiryService,
|
||||||
|
],
|
||||||
|
})
|
||||||
|
export class WorkspaceModule {}
|
||||||
Reference in new issue
Block a user