Skip to content

Commit

Permalink
Merge pull request #14 from cdalton713/backend
Browse files Browse the repository at this point in the history
Backend
  • Loading branch information
alxford45 authored Nov 28, 2020
2 parents 4986a1a + 8162ebb commit 47c5fec
Show file tree
Hide file tree
Showing 9 changed files with 327 additions and 111 deletions.
99 changes: 55 additions & 44 deletions api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,96 +65,107 @@ client handles all routing on https://lsu-it-support-demo.herokuapp.com excludin

# API Routes

## technician
Check https://lsu-it-support-demo.herokuapp.com/api/docs for schema DTO definitions

```
POST /api​/tech
```
## Ticket

```
GET /api​/tech
```
Create new user, ticket, and device

```
GET /api​/tech​/{id}
```
POST /api​/ticket
req: body: {createCombinedDTO}
res: body: {CombinedDTO}
```
PUT /api​/tech​/{id}
```

Get all tickets with user/ticket/device info

```
DELETE /api​/tech​/{id}
GET /api​/ticket
req: none
res: body: {CombinedDTO[]}
```

## ticket
Get all opened tickets with user/ticket/device info

```
POST /api​/ticket
GET /api​/ticket/opened
req: none
res: body: {CombinedDTO[]}
```

Get all closed tickets with user/ticket/device info

```
GET /api​/ticket
GET /api​/ticket/closed
req: none
res: body: {CombinedDTO[]}
```

Get one ticket by ticket_id with user/ticket/device info

```
GET /api​/ticket​/{id}
GET /api​/ticket​/{ticket_id}
req: none
res: body: {CombineDTO}
```

Update ticket

```
/* NOT WORKING */
PUT /api​/ticket​/{id}
```

```
POST /api​/ticket​/work
```
## User

```
GET /api​/ticket​/work
```
Create new user

```
GET /api​/ticket​/work​/{id}
POST /api​/user
req: body: {CreateUserDTO}
res: body: {UserDTO}
```

```
PUT /api​/ticket​/work​/{id}
```
Get all users

```
DELETE /api​/ticket​/work​/{id}
GET /api​/user
res: body: {UserDTO[]}
```

```
POST /api​/ticket​/assign
```
Get all users who are admins

```
GET /api​/ticket​/assign
GET /api​/user/admin
res: body: {UserDTO[]}
```

```
GET /api​/ticket​/assign​/{id}
```
Get all users who are not admins

```
PUT /api​/ticket​/assign​/{id}
GET /api​/user/student
res: body: {UserDTO[]}
```

Get user by lsu_id

```
DELETE /api​/ticket​/assign​/{id}
GET /api​/user/{lsu_id}
res: body: {UserDTO}
```

## Customer
Update user

```
POST /api​/customer
/* NOT WORKING */
PUT /api/user/{lsu_id}
```

```
GET /api​/customer
```
## Assign

```
GET /api​/customer​/{id}
```
TODO

## Work

TODO
8 changes: 8 additions & 0 deletions api/src/ticket/dto/combined.dto.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { IntersectionType } from '@nestjs/swagger';
import { Ticket } from './ticket.dto';
import { User } from 'src/user/dto/user.dto';
import { Device } from './device.dto';

class TicketAndDevice extends IntersectionType(Ticket, Device) {}

export class Combined extends IntersectionType(TicketAndDevice, User) {}
14 changes: 14 additions & 0 deletions api/src/ticket/dto/create-combined.dto.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { IntersectionType, OmitType as Omit } from '@nestjs/swagger';
import { CreateUser } from 'src/user/dto/create-user.dto';
import { CreateTicket } from './create-ticket.dto';
import { CreateDevice } from './create-device.dto';

class createTicketAndDevice extends IntersectionType(
CreateTicket,
Omit(CreateDevice, ['ticket_id']),
) {}

export class CreateCombined extends IntersectionType(
createTicketAndDevice,
Omit(CreateUser, ['admin']),
) {}
4 changes: 4 additions & 0 deletions api/src/ticket/dto/create-device.dto.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { OmitType as Omit } from '@nestjs/swagger';
import { Device } from './device.dto';

export class CreateDevice extends Omit(Device, ['device_id']) {}
6 changes: 1 addition & 5 deletions api/src/ticket/dto/create-ticket.dto.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
import { Ticket } from './ticket.dto';
import { OmitType as Omit } from '@nestjs/swagger';

export class CreateTicket extends Omit(Ticket, [
'ticket_id',
'priority',
'status',
]) {}
export class CreateTicket extends Omit(Ticket, ['ticket_id', 'status']) {}
36 changes: 36 additions & 0 deletions api/src/ticket/dto/device.dto.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { ApiProperty } from '@nestjs/swagger';

export class Device {
@ApiProperty({ description: 'id of device', example: 1 })
device_id: number;

@ApiProperty({ description: 'id of associated ticket', example: 1 })
ticket_id: number;

@ApiProperty({
minLength: 1,
description: 'model of device',
example: '15',
})
model: string;

@ApiProperty({
description: 'physical hardware part that is damaged',
example: 'screen',
nullable: true,
})
component: string;

@ApiProperty({ description: 'manufacturer of device', example: 'dell' })
manufacturer: string;

@ApiProperty({
minLength: 1,
description: 'operating system',
example: 'windows',
})
operating_system: string;

@ApiProperty({ description: 'operating system version', example: 'version1' })
operating_system_version: string;
}
20 changes: 0 additions & 20 deletions api/src/ticket/dto/ticket.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,23 +50,3 @@ export class Ticket {
})
submission_date: string;
}
// @ApiProperty({ description: 'manufacturer of device', example: 'dell' })
// manufacturer: string;

// @ApiProperty({
// minLength: 1,
// description: 'model of device',
// example: '15',
// })
// model: number;

// @ApiProperty({
// minLength: 1,
// description: 'operating system',
// example: 'windows',
// })
// os: string;

// // Not sure of example data for os version
// @ApiProperty({ description: 'operating system version', example: 'version1' })
// version: string;
20 changes: 10 additions & 10 deletions api/src/ticket/ticket.controller.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import {
Body,
Controller,
Get,
Logger,
Param,
Post,
Body,
Put,
Param,
Logger,
} from '@nestjs/common';
import { TicketService } from './ticket.service';
import { CreateTicket } from './dto/create-ticket.dto';
import { UpdateTicketDto } from './dto/update-ticket.dto';
import { ApiTags } from '@nestjs/swagger';
import { Ticket, TicketType } from './dto/ticket.dto';
import { CreateCombined } from './dto/create-combined.dto';
import { TicketType } from './dto/ticket.dto';
import { UpdateTicketDto } from './dto/update-ticket.dto';
import { TicketService } from './ticket.service';

@ApiTags('ticket')
@Controller('/api/ticket')
Expand All @@ -20,19 +20,19 @@ export class TicketController {

/* TODO: test implementation */
@Post()
create(@Body() createTicketDto: CreateTicket) {
create(@Body() createCombined: CreateCombined) {
Logger.log(
{
req: {
http: 'POST /api/ticket',
params: 'none',
body: createTicketDto,
body: createCombined,
},
},
'TicketController.create',
false,
);
return this.ticketService.create(createTicketDto);
return this.ticketService.create(createCombined);
}

/* Working implementation */
Expand Down
Loading

0 comments on commit 47c5fec

Please sign in to comment.