Skip to content

Commit

Permalink
Merge pull request #16 from cdalton713/backend
Browse files Browse the repository at this point in the history
Backend: fully implemented assign endpoints
  • Loading branch information
alxford45 authored Nov 29, 2020
2 parents a4272fd + c469f20 commit 40b7ea2
Show file tree
Hide file tree
Showing 17 changed files with 304 additions and 172 deletions.
38 changes: 36 additions & 2 deletions api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,43 @@ req: body: {UpdateUserDTO}
res: body: {UserDTO}
```

## Assign
## Assignment

TODO
Get all assignments

```
GET /api/assignment
res: body: {AssignmentDTO}
```

Get all assignments assigned to admin by lsu_id

```
GET /api/assignment/user/{lsu_id}
res: body: {AssignmentDTO[]}
```

Get all assignments assigned to ticket by ticket_id

```
GET /api/assignment/ticket/{ticket_id}
res: body: {AssignmentDTO[]}
```

Get one assignment by assignment_id

```
GET /api/assignment/{assignment_id}
res: body: {AssignmentDTO}
```

Post new assignment

```
POST /api/assignment
req: body: {CreateAssignmentDTO}
res: body: {AssignmentDTO}
```

## Work

Expand Down
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
15 changes: 0 additions & 15 deletions api/src/assign/dto/create-ticketassign.dto.ts

This file was deleted.

6 changes: 0 additions & 6 deletions api/src/assign/dto/update-ticketassign.dto.ts

This file was deleted.

6 changes: 0 additions & 6 deletions api/src/assign/entities/ticketassign.entity.ts

This file was deleted.

47 changes: 0 additions & 47 deletions api/src/assign/ticketassign.controller.ts

This file was deleted.

11 changes: 0 additions & 11 deletions api/src/assign/ticketassign.module.ts

This file was deleted.

57 changes: 0 additions & 57 deletions api/src/assign/ticketassign.service.ts

This file was deleted.

45 changes: 45 additions & 0 deletions api/src/assignment/assignment.controller.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import { Body, Controller, Get, Param, Post } from '@nestjs/common';
import { ApiTags } from '@nestjs/swagger';
import { AssignmentService } from './assignment.service';
import { AssignmentType } from './dto/assignment.dto';
import { CreateAssignmentDTO } from './dto/create-assignment.dto';

@ApiTags('assignment')
@Controller('/api/assign')
export class AssignmentController {
constructor(private readonly ticketAssignService: AssignmentService) {}

/* WORKING Implementation */
/* TODO: fix date formatting */
@Post()
async create(@Body() createAssignmentDTO: CreateAssignmentDTO) {
return await this.ticketAssignService.create(createAssignmentDTO);
}

/* WORKING Implementation */
@Get()
findAll() {
return this.ticketAssignService.findAll();
}

/* WORKING Implementation */
@Get('user/:lsu_id')
findAllByLsuId(@Param('lsu_id') lsu_id: number) {
return this.ticketAssignService.findAllById(AssignmentType.LSU_ID, lsu_id);
}

/* WORKING Implementation */
@Get('ticket/:ticket_id')
findAllByTicketId(@Param('ticket_id') ticket_id: number) {
return this.ticketAssignService.findAllById(
AssignmentType.TICKET_ID,
ticket_id,
);
}

/* WORKING Implementation */
@Get(':assignment_id')
findOne(@Param('assignment_id') assignment_id: string) {
return this.ticketAssignService.findOne(+assignment_id);
}
}
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 {}
Loading

0 comments on commit 40b7ea2

Please sign in to comment.