update schema due to majority database change
This commit is contained in:
@@ -40,7 +40,9 @@ export class CategorySchema extends PothosSchema {
|
||||
return this.builder.prismaObject('SubCategory', {
|
||||
description: 'A subcategory of services.',
|
||||
fields: (t) => ({
|
||||
id: t.exposeID('id'),
|
||||
id: t.exposeID('id', {
|
||||
description: 'The unique identifier of the subcategory.',
|
||||
}),
|
||||
name: t.exposeString('name', {
|
||||
description: 'The name of the subcategory.',
|
||||
}),
|
||||
|
||||
@@ -8,6 +8,7 @@ import {
|
||||
import { Builder } from '../Graphql/graphql.builder';
|
||||
import { PrismaService } from '../Prisma/prisma.service';
|
||||
import { MinioService } from 'src/Minio/minio.service';
|
||||
import { CenterStatus } from '@prisma/client';
|
||||
|
||||
@Injectable()
|
||||
export class CenterSchema extends PothosSchema {
|
||||
@@ -30,6 +31,12 @@ export class CenterSchema extends PothosSchema {
|
||||
centerOwnerId: t.exposeID('centerOwnerId', {
|
||||
description: 'The ID of the center owner.',
|
||||
}),
|
||||
bank: t.exposeString('bank', {
|
||||
description: 'The bank of the center.',
|
||||
}),
|
||||
bankAccountNumber: t.exposeString('bankAccountNumber', {
|
||||
description: 'The bank account number of the center.',
|
||||
}),
|
||||
name: t.exposeString('name', {
|
||||
description: 'The name of the center.',
|
||||
}),
|
||||
@@ -75,6 +82,10 @@ export class CenterSchema extends PothosSchema {
|
||||
resume: t.relation('Resume', {
|
||||
description: 'The resume of the center.',
|
||||
}),
|
||||
centerStatus: t.expose('centerStatus', {
|
||||
type: CenterStatus,
|
||||
description: 'The status of the center.',
|
||||
}),
|
||||
uploadedFileId: t.exposeID('uploadedFileId', {
|
||||
description: 'The ID of the uploaded file.',
|
||||
}),
|
||||
|
||||
@@ -31,6 +31,15 @@ export class CenterStaffSchema extends PothosSchema {
|
||||
staff: t.relation('staff', {
|
||||
description: 'The staff member.',
|
||||
}),
|
||||
center: t.relation('center', {
|
||||
description: 'The center.',
|
||||
}),
|
||||
createdWorkshop: t.relation('createdWorkshop', {
|
||||
description: 'The workshops created by the center staff.',
|
||||
}),
|
||||
ManagedService: t.relation('ManagedService', {
|
||||
description: 'The managed services of the center staff.',
|
||||
}),
|
||||
}),
|
||||
});
|
||||
}
|
||||
|
||||
@@ -28,6 +28,8 @@ import { ScheduleModule } from '../Schedule/schedule.module';
|
||||
import { MessageModule } from '../Message/message.module';
|
||||
import { ServiceMeetingRoomModule } from '../ServiceMeetingRoom/servicemeetingroom.module';
|
||||
import { UploadedFileModule } from '../UploadedFile/uploadedfile.module';
|
||||
import { ManagedServiceModule } from '../ManagedService/managedservice.module';
|
||||
|
||||
@Global()
|
||||
@Module({
|
||||
imports: [
|
||||
@@ -52,6 +54,7 @@ import { UploadedFileModule } from '../UploadedFile/uploadedfile.module';
|
||||
MessageModule,
|
||||
ServiceMeetingRoomModule,
|
||||
UploadedFileModule,
|
||||
ManagedServiceModule,
|
||||
PothosModule.forRoot({
|
||||
builder: {
|
||||
inject: [PrismaService],
|
||||
|
||||
7
src/ManagedService/managedservice.module.ts
Normal file
7
src/ManagedService/managedservice.module.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { ManagedServiceSchema } from './managedservice.schema';
|
||||
|
||||
@Module({
|
||||
providers: [ManagedServiceSchema],
|
||||
})
|
||||
export class ManagedServiceModule {}
|
||||
83
src/ManagedService/managedservice.schema.ts
Normal file
83
src/ManagedService/managedservice.schema.ts
Normal file
@@ -0,0 +1,83 @@
|
||||
import { Inject, Injectable } from '@nestjs/common';
|
||||
import {
|
||||
Pothos,
|
||||
PothosRef,
|
||||
PothosSchema,
|
||||
SchemaBuilderToken,
|
||||
} from '@smatch-corp/nestjs-pothos';
|
||||
import { Builder } from '../Graphql/graphql.builder';
|
||||
import { PrismaService } from '../Prisma/prisma.service';
|
||||
|
||||
@Injectable()
|
||||
export class ManagedServiceSchema extends PothosSchema {
|
||||
constructor(
|
||||
@Inject(SchemaBuilderToken) private readonly builder: Builder,
|
||||
private readonly prisma: PrismaService,
|
||||
) {
|
||||
super();
|
||||
}
|
||||
|
||||
@PothosRef()
|
||||
managedService() {
|
||||
return this.builder.prismaObject('ManagedService', {
|
||||
description: 'A managed service',
|
||||
fields: (t) => ({
|
||||
staffId: t.exposeID('staffId', {
|
||||
description: 'The ID of the staff member.',
|
||||
}),
|
||||
serviceId: t.exposeID('serviceId', {
|
||||
description: 'The ID of the service.',
|
||||
}),
|
||||
staff: t.relation('staff'),
|
||||
service: t.relation('service'),
|
||||
}),
|
||||
});
|
||||
}
|
||||
|
||||
@Pothos()
|
||||
init(): void {
|
||||
this.builder.queryFields((t) => ({
|
||||
managedService: t.field({
|
||||
type: this.managedService(),
|
||||
args: this.builder.generator.findUniqueArgs('ManagedService'),
|
||||
resolve: async (parent, args, context) => {
|
||||
return this.prisma.managedService.findUnique({
|
||||
where: args.where,
|
||||
});
|
||||
},
|
||||
}),
|
||||
|
||||
managedServices: t.field({
|
||||
type: [this.managedService()],
|
||||
args: this.builder.generator.findManyArgs('ManagedService'),
|
||||
resolve: async (parent, args, context) => {
|
||||
return this.prisma.managedService.findMany({
|
||||
where: args.filter ?? undefined,
|
||||
orderBy: args.orderBy ?? undefined,
|
||||
cursor: args.cursor ?? undefined,
|
||||
take: args.take ?? 10,
|
||||
skip: args.skip ?? undefined,
|
||||
});
|
||||
},
|
||||
}),
|
||||
}));
|
||||
|
||||
this.builder.mutationFields((t) => ({
|
||||
createManagedService: t.field({
|
||||
type: this.managedService(),
|
||||
args: {
|
||||
input: t.arg({
|
||||
type: this.builder.generator.getCreateInput('ManagedService'),
|
||||
required: true,
|
||||
description: 'The data for the managed service.',
|
||||
}),
|
||||
},
|
||||
resolve: async (parent, args, context) => {
|
||||
return this.prisma.managedService.create({
|
||||
data: args.input,
|
||||
});
|
||||
},
|
||||
}),
|
||||
}));
|
||||
}
|
||||
}
|
||||
@@ -28,16 +28,24 @@ export class MilestoneSchema extends PothosSchema {
|
||||
name: t.exposeString('name', {
|
||||
description: 'The name of the milestone.',
|
||||
}),
|
||||
order: t.exposeInt('order', {
|
||||
milestoneOrder: t.exposeInt('milestoneOrder', {
|
||||
description: 'The order of the milestone.',
|
||||
}),
|
||||
description: t.exposeString('description', {
|
||||
description: 'The description of the milestone.',
|
||||
}),
|
||||
serviceId: t.exposeID('serviceId', {
|
||||
description: 'The ID of the service the milestone belongs to.',
|
||||
}),
|
||||
service: t.relation('service'),
|
||||
createdAt: t.expose('createdAt', {
|
||||
type: 'DateTime',
|
||||
description: 'The date and time the milestone was created.',
|
||||
}),
|
||||
updatedAt: t.expose('updatedAt', {
|
||||
type: 'DateTime',
|
||||
description: 'The date and time the milestone was last updated.',
|
||||
}),
|
||||
}),
|
||||
});
|
||||
}
|
||||
|
||||
@@ -37,7 +37,6 @@ export class OrderSchema extends PothosSchema {
|
||||
}),
|
||||
status: t.expose('status', {
|
||||
type: OrderStatus,
|
||||
nullable: false,
|
||||
description: 'The status of the order.',
|
||||
}),
|
||||
total: t.exposeInt('total', {
|
||||
@@ -54,7 +53,7 @@ export class OrderSchema extends PothosSchema {
|
||||
user: t.relation('user', {
|
||||
description: 'The user who made the order.',
|
||||
}),
|
||||
payment: t.relation('payment', {
|
||||
payment: t.relation('Payment', {
|
||||
description: 'The payment for the order.',
|
||||
}),
|
||||
service: t.relation('service', {
|
||||
|
||||
@@ -7,6 +7,7 @@ import {
|
||||
} from '@smatch-corp/nestjs-pothos';
|
||||
import { Builder } from '../Graphql/graphql.builder';
|
||||
import { PrismaService } from '../Prisma/prisma.service';
|
||||
import { ScheduleStatus } from '@prisma/client';
|
||||
|
||||
@Injectable()
|
||||
export class ScheduleSchema extends PothosSchema {
|
||||
@@ -23,10 +24,53 @@ export class ScheduleSchema extends PothosSchema {
|
||||
description: 'A schedule in the system.',
|
||||
fields: (t) => ({
|
||||
id: t.exposeID('id'),
|
||||
serviceId: t.exposeID('serviceId'),
|
||||
service: t.relation('service'),
|
||||
dates: t.expose('dates', { type: 'Json' as any }),
|
||||
status: t.exposeString('status'),
|
||||
serviceId: t.exposeID('serviceId', {
|
||||
description: 'The ID of the service the schedule belongs to.',
|
||||
nullable: false,
|
||||
}),
|
||||
service: t.relation('service', {
|
||||
description: 'The service the schedule belongs to.',
|
||||
nullable: false,
|
||||
}),
|
||||
scheduleStart: t.expose('ScheduleStart', {
|
||||
type: 'DateTime',
|
||||
nullable: false,
|
||||
}),
|
||||
scheduleEnd: t.expose('ScheduleEnd', {
|
||||
type: 'DateTime',
|
||||
nullable: false,
|
||||
}),
|
||||
dates: t.relation('dates'),
|
||||
status: t.expose('status', {
|
||||
type: ScheduleStatus,
|
||||
nullable: false,
|
||||
}),
|
||||
}),
|
||||
});
|
||||
}
|
||||
|
||||
@PothosRef()
|
||||
scheduleDate() {
|
||||
return this.builder.prismaObject('ScheduleDate', {
|
||||
description: 'A schedule date in the system.',
|
||||
fields: (t) => ({
|
||||
id: t.exposeID('id', {
|
||||
description: 'The ID of the schedule date.',
|
||||
}),
|
||||
scheduleId: t.exposeID('scheduleId', {
|
||||
description: 'The ID of the schedule the schedule date belongs to.',
|
||||
}),
|
||||
start: t.expose('start', {
|
||||
type: 'DateTime',
|
||||
nullable: false,
|
||||
}),
|
||||
end: t.expose('end', {
|
||||
type: 'DateTime',
|
||||
nullable: false,
|
||||
}),
|
||||
schedule: t.relation('Schedule', {
|
||||
description: 'The schedule the schedule date belongs to.',
|
||||
}),
|
||||
}),
|
||||
});
|
||||
}
|
||||
|
||||
@@ -32,6 +32,12 @@ export class ServiceSchema extends PothosSchema {
|
||||
description: t.exposeString('description', {
|
||||
description: 'The description of the service.',
|
||||
}),
|
||||
centerId: t.exposeID('centerId', {
|
||||
description: 'The ID of the center that offers the service.',
|
||||
}),
|
||||
userId: t.exposeID('userId', {
|
||||
description: 'The ID of the user who requested the service.',
|
||||
}),
|
||||
price: t.exposeFloat('price', {
|
||||
description: 'The price of the service.',
|
||||
}),
|
||||
@@ -67,12 +73,15 @@ export class ServiceSchema extends PothosSchema {
|
||||
nullable: true,
|
||||
description: 'The date and time the service was updated.',
|
||||
}),
|
||||
feedbacks: t.relation('feedbacks', {
|
||||
description: 'The feedbacks for the service.',
|
||||
}),
|
||||
order: t.relation('order', {
|
||||
description: 'The order for the service.',
|
||||
}),
|
||||
center: t.relation('center', {
|
||||
description: 'The center that offers the service.',
|
||||
}),
|
||||
centerId: t.exposeID('centerId', {
|
||||
description: 'The ID of the center that offers the service.',
|
||||
}),
|
||||
workshop: t.relation('workshop', {
|
||||
description: 'The workshop for the service.',
|
||||
}),
|
||||
@@ -91,8 +100,8 @@ export class ServiceSchema extends PothosSchema {
|
||||
user: t.relation('user', {
|
||||
description: 'The user who requested the service.',
|
||||
}),
|
||||
userId: t.exposeID('userId', {
|
||||
description: 'The ID of the user who requested the service.',
|
||||
managedService: t.relation('ManagedService', {
|
||||
description: 'The managed service for the service.',
|
||||
}),
|
||||
}),
|
||||
});
|
||||
@@ -113,6 +122,7 @@ export class ServiceSchema extends PothosSchema {
|
||||
orderBy: args.orderBy ?? undefined,
|
||||
skip: args.skip ?? undefined,
|
||||
take: args.take ?? 10,
|
||||
cursor: args.cursor ?? undefined,
|
||||
});
|
||||
},
|
||||
}),
|
||||
|
||||
@@ -35,10 +35,6 @@ export class UserSchema extends PothosSchema {
|
||||
phoneNumber: t.exposeString('phoneNumber', {
|
||||
description: 'The phone number of the user.',
|
||||
}),
|
||||
oauthToken: t.exposeString('oauthToken', {
|
||||
nullable: true,
|
||||
description: 'The OAuth token of the user.',
|
||||
}),
|
||||
role: t.exposeString('role', {
|
||||
description: 'The role of the user.',
|
||||
}),
|
||||
@@ -52,9 +48,33 @@ export class UserSchema extends PothosSchema {
|
||||
nullable: true,
|
||||
description: 'The date and time the user was updated.',
|
||||
}),
|
||||
orders: t.relation('orders', {
|
||||
description: 'The orders of the user.',
|
||||
}),
|
||||
serviceFeedbacks: t.relation('serviceFeedbacks', {
|
||||
description: 'The service feedbacks of the user.',
|
||||
}),
|
||||
files: t.relation('files', {
|
||||
description: 'The files of the user.',
|
||||
}),
|
||||
sendingMessage: t.relation('sendingMessage', {
|
||||
description: 'The sending message of the user.',
|
||||
}),
|
||||
center: t.relation('center', {
|
||||
description: 'The center of the user.',
|
||||
}),
|
||||
customerChatRoom: t.relation('customerChatRoom', {
|
||||
description: 'The customer chat room of the user.',
|
||||
}),
|
||||
centerStaffChatRoom: t.relation('centerStaffChatRoom', {
|
||||
description: 'The center staff chat room of the user.',
|
||||
}),
|
||||
CenterStaff: t.relation('CenterStaff', {
|
||||
description: 'The center staff of the user.',
|
||||
}),
|
||||
WorkshopSubscription: t.relation('WorkshopSubscription', {
|
||||
description: 'The workshop subscription of the user.',
|
||||
}),
|
||||
}),
|
||||
});
|
||||
}
|
||||
|
||||
@@ -77,10 +77,10 @@ export class WorkshopSchema extends PothosSchema {
|
||||
service: t.relation('service', {
|
||||
description: 'The service that the workshop is for.',
|
||||
}),
|
||||
workshopOrganization: t.relation('workshopOrganization', {
|
||||
organization: t.relation('organization', {
|
||||
description: 'The organization that the workshop is for.',
|
||||
}),
|
||||
workshopSubscription: t.relation('workshopSubscription', {
|
||||
subscription: t.relation('subscription', {
|
||||
description: 'The subscription that the workshop is for.',
|
||||
}),
|
||||
staff: t.relation('staff', {
|
||||
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user