diff --git a/api/src/app.module.ts b/api/src/app.module.ts index 49dab65..4d6ac3a 100644 --- a/api/src/app.module.ts +++ b/api/src/app.module.ts @@ -4,7 +4,7 @@ import { join } from 'path'; import { AppController } from './app.controller'; import { AppService } from './app.service'; import { TicketModule } from './ticket/ticket.module'; -import { TicketWorkModule } from './work/ticketwork.module'; +import { WorkModule } from './work/work.module'; import { AssignmentModule } from './assignment/assignment.module.'; import { UserModule } from './user/uer.module'; @@ -40,7 +40,7 @@ const configImports = (modules: ModuleMetadata['imports']) => { @Module({ imports: configImports([ TicketModule, - TicketWorkModule, + WorkModule, AssignmentModule, UserModule, ]), diff --git a/api/src/work/dto/create-ticketwork.dto.ts b/api/src/work/dto/create-ticketwork.dto.ts deleted file mode 100644 index 1644ef2..0000000 --- a/api/src/work/dto/create-ticketwork.dto.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { ApiProperty } from '@nestjs/swagger'; - -export class CreateTicketWorkDto { - @ApiProperty({ minLength: 3 }) - issue: string; - - @ApiProperty({ minLength: 3 }) - component: string; - - @ApiProperty({}) - description: number; - - @ApiProperty({}) - starttime: Date; - - @ApiProperty({}) - endtime: Date; -} diff --git a/api/src/work/dto/update-ticketwork.dto.ts b/api/src/work/dto/update-ticketwork.dto.ts deleted file mode 100644 index 86d1f9c..0000000 --- a/api/src/work/dto/update-ticketwork.dto.ts +++ /dev/null @@ -1,7 +0,0 @@ -export class UpdateTicketWorkDto { - issue: string; - component: string; - description: string; - starttime: Date; - endtime: Date; -} diff --git a/api/src/work/entities/ticketwork.entity.ts b/api/src/work/entities/ticketwork.entity.ts deleted file mode 100644 index 12679e2..0000000 --- a/api/src/work/entities/ticketwork.entity.ts +++ /dev/null @@ -1,7 +0,0 @@ -export class TicketWork { - issue: string; - component: string; - description: string; - starttime: Date; - endtime: Date; -} diff --git a/api/src/work/ticketwork.controller.ts b/api/src/work/ticketwork.controller.ts deleted file mode 100644 index 814418a..0000000 --- a/api/src/work/ticketwork.controller.ts +++ /dev/null @@ -1,44 +0,0 @@ -import { - Controller, - Get, - Post, - Body, - Put, - Param, - Delete, -} from '@nestjs/common'; -import { TicketWorkService } from './ticketwork.service'; -import { CreateTicketWorkDto } from './dto/create-ticketwork.dto'; -import { UpdateTicketWorkDto } from './dto/update-ticketwork.dto'; -import { ApiTags } from '@nestjs/swagger'; - -@ApiTags('ticket') -@Controller('/api/ticket/work') -export class TicketWorkController { - constructor(private readonly ticketWorkService: TicketWorkService) {} - /* Working Implementation */ - @Post() - async create(@Body() createTicketWorkDto: CreateTicketWorkDto) { - return await this.ticketWorkService.create(createTicketWorkDto); - } - /* TODO */ - @Get() - findAll() { - return this.ticketWorkService.findAll(); - } - /* TODO */ - @Get(':id') - findOne(@Param('id') id: string) { - return this.ticketWorkService.findOne(+id); - } - /* TODO */ - @Put(':id') - update(@Param('id') id: string, @Body() updateTicketWorkDto: UpdateTicketWorkDto) { - return this.ticketWorkService.update(+id, updateTicketWorkDto); - } - /* TODO */ - @Delete(':id') - remove(@Param('id') id: string) { - return this.ticketWorkService.remove(+id); - } -} diff --git a/api/src/work/ticketwork.module.ts b/api/src/work/ticketwork.module.ts deleted file mode 100644 index 8756668..0000000 --- a/api/src/work/ticketwork.module.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { Module } from '@nestjs/common'; -import { TicketWorkService } from './ticketwork.service'; -import { TicketWorkController } from './ticketwork.controller'; -import { DbModule } from 'src/db/db.module'; - -@Module({ - imports:[DbModule], - controllers: [TicketWorkController], - providers: [TicketWorkService] -}) -export class TicketWorkModule {} diff --git a/api/src/work/ticketwork.service.ts b/api/src/work/ticketwork.service.ts deleted file mode 100644 index 5d75ba7..0000000 --- a/api/src/work/ticketwork.service.ts +++ /dev/null @@ -1,58 +0,0 @@ -import { HttpException, HttpStatus, Inject, Injectable } from '@nestjs/common'; -import { Pool } from 'pg'; -import { PG_CONNECTION } from 'src/connection'; -import { CreateTicketWorkDto } from './dto/create-ticketwork.dto'; -import { UpdateTicketWorkDto } from './dto/update-ticketwork.dto'; -import { TicketWork } from './entities/ticketwork.entity'; - -/* TODO: - - Implement remaining methods - - Find solution to abstract SQL -*/ -@Injectable() -export class TicketWorkService { - constructor(@Inject(PG_CONNECTION) private connection: Pool) {} - - async create(createTicketWorkDto: CreateTicketWorkDto) { - const { - issue, - component, - description, - starttime, - endtime - } = createTicketWorkDto; - - /* Insert new user into db - TODO: implement error handling for pg request - */ - const text = - 'INSERT INTO ticketwork(issue, component, description, starttime, endtime) VALUES ($1, $2, $3, $4, $5) RETURNING *'; - const values = [issue, component, description, starttime, endtime]; - const res = (await this.connection.query(text, values)).rows[0]; - - /* Return user object without password */ - const ticketwork = new TicketWork(); - ticketwork.issue = res.issue; - ticketwork.component = res.component; - ticketwork.description = res.description; - ticketwork.starttime = res.starttime; - ticketwork.endtime = res.endtime; - return ticketwork; - } - /* TODO */ - findAll() { - return `This action returns all user`; - } - /* TODO */ - findOne(id: number) { - return `This action returns a #${id} user`; - } - /* TODO */ - update(id: number, updateTicketWorkDto: UpdateTicketWorkDto) { - return `This action updates a #${id} user`; - } - /* TODO */ - remove(id: number) { - return `This action removes a #${id} user`; - } -} diff --git a/api/src/work/work.module.ts b/api/src/work/work.module.ts new file mode 100644 index 0000000..518ecc1 --- /dev/null +++ b/api/src/work/work.module.ts @@ -0,0 +1,11 @@ +import { Module } from '@nestjs/common'; +import { WorkService } from './work.service'; +import { WorkController } from './work.controller'; +import { DbModule } from 'src/db/db.module'; + +@Module({ + imports: [DbModule], + controllers: [WorkController], + providers: [WorkService], +}) +export class WorkModule {}