Skip to content

Commit

Permalink
refactored TicketAssign -> Assignment
Browse files Browse the repository at this point in the history
  • Loading branch information
alxford45 committed Nov 28, 2020
1 parent e404ab8 commit 448eef3
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 35 deletions.
4 changes: 2 additions & 2 deletions api/src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { AppController } from './app.controller';
import { AppService } from './app.service';
import { TicketModule } from './ticket/ticket.module';
import { TicketWorkModule } from './work/ticketwork.module';
import { TicketAssignModule } from './assign/ticketassign.module';
import { AssignmentModule } from './assignment/assignment.module.';
import { UserModule } from './user/uer.module';

/**
Expand Down Expand Up @@ -41,7 +41,7 @@ const configImports = (modules: ModuleMetadata['imports']) => {
imports: configImports([
TicketModule,
TicketWorkModule,
TicketAssignModule,
AssignmentModule,
UserModule,
]),
controllers: [AppController],
Expand Down
11 changes: 0 additions & 11 deletions api/src/assign/ticketassign.module.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@ import {
Param,
Delete,
} from '@nestjs/common';
import { TicketAssignService } from './ticketassign.service';
import { CreateTicketAssignDto } from './dto/create-ticketassign.dto';
import { UpdateTicketAssignDto } from './dto/update-ticketassign.dto';
import { AssignmentService } from './assignment.service';
import { CreateAssignmentDTO } from './dto/create-assignment.dto';
import { UpdateAssignmentDTO } from './dto/update-assignment.dto';
import { ApiTags } from '@nestjs/swagger';

@ApiTags('ticket')
@Controller('/api/ticket/assign')
export class TicketAssignController {
constructor(private readonly ticketAssignService: TicketAssignService) {}
export class AssignmentController {
constructor(private readonly ticketAssignService: AssignmentService) {}
/* Working Implementation */
@Post()
async create(@Body() createTicketAssignDto: CreateTicketAssignDto) {
async create(@Body() createTicketAssignDto: CreateAssignmentDTO) {
return await this.ticketAssignService.create(createTicketAssignDto);
}
/* TODO */
Expand All @@ -35,7 +35,7 @@ export class TicketAssignController {
@Put(':id')
update(
@Param('id') id: string,
@Body() updateTicketAssignDto: UpdateTicketAssignDto,
@Body() updateTicketAssignDto: UpdateAssignmentDTO,
) {
return this.ticketAssignService.update(+id, updateTicketAssignDto);
}
Expand Down
11 changes: 11 additions & 0 deletions api/src/assignment/assignment.module..ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { Module } from '@nestjs/common';
import { AssignmentService } from './assignment.service';
import { AssignmentController } from './assignment.controller';
import { DbModule } from 'src/db/db.module';

@Module({
imports: [DbModule],
controllers: [AssignmentController],
providers: [AssignmentService],
})
export class AssignmentModule {}
Original file line number Diff line number Diff line change
@@ -1,25 +1,20 @@
import { HttpException, HttpStatus, Inject, Injectable } from '@nestjs/common';
import { Pool } from 'pg';
import { PG_CONNECTION } from 'src/connection';
import { CreateTicketAssignDto } from './dto/create-ticketassign.dto';
import { UpdateTicketAssignDto } from './dto/update-ticketassign.dto';
import { TicketAssign } from './entities/ticketassign.entity';
import { CreateAssignmentDTO } from './dto/create-assignment.dto';
import { UpdateAssignmentDTO } from './dto/update-assignment.dto';
import { AssignmentDTO } from './dto/assignment.dto';

/* TODO:
- Implement remaining methods
- Find solution to abstract SQL
*/
@Injectable()
export class TicketAssignService {
export class AssignmentService {
constructor(@Inject(PG_CONNECTION) private connection: Pool) {}

async create(createTicketAssignDto: CreateTicketAssignDto) {
const {
assignedby,
assignedto,
comment,
assigndate,
} = createTicketAssignDto;
async create(createAssignmentDTO: CreateAssignmentDTO) {
const { assignedby, assignedto, comment, assigndate } = createAssignmentDTO;

/* Insert new user into db
TODO: implement error handling for pg request
Expand Down Expand Up @@ -47,7 +42,7 @@ export class TicketAssignService {
return `This action returns a #${id} user`;
}
/* TODO */
update(id: number, updateTicketAssignDto: UpdateTicketAssignDto) {
update(id: number, updateAssignmentDTO: UpdateAssignmentDTO) {
return `This action updates a #${id} user`;
}
/* TODO */
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export class TicketAssign {
export class AssignmentDTO {
assignedby: string;
assignedto: string;
comment: string;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ApiProperty } from '@nestjs/swagger';

export class CreateTicketAssignDto {
export class CreateAssignmentDTO {
@ApiProperty({ minLength: 3 })
assignedby: string;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export class UpdateTicketAssignDto {
export class UpdateAssignmentDTO {
assignedby: string;
assignedto: string;
comment: string;
Expand Down

0 comments on commit 448eef3

Please sign in to comment.