Skip to content

Commit

Permalink
coordinator crud operations modified
Browse files Browse the repository at this point in the history
  • Loading branch information
valentin-stamate committed May 17, 2022
1 parent 10bedef commit 1ad20c1
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 183 deletions.
125 changes: 17 additions & 108 deletions endpoints.json
Original file line number Diff line number Diff line change
Expand Up @@ -2461,61 +2461,6 @@
},
"response": []
},
{
"name": "Coordinator Scientific Activity",
"request": {
"method": "PUT",
"header": [
{
"key": "Authorization",
"value": "{{coordinator_token}}",
"type": "text"
}
],
"body": {
"mode": "formdata",
"formdata": [
{
"key": "fullName",
"value": "Demo name",
"type": "text"
},
{
"key": "publicationNumberWebOfScience",
"value": "",
"type": "text"
},
{
"key": "committees",
"value": "",
"type": "text"
},
{
"key": "conferences",
"value": "",
"type": "text"
},
{
"key": "reportYear",
"value": "",
"type": "text"
}
]
},
"url": {
"raw": "{{host}}/api/coordinator/scientific-activity",
"host": [
"{{host}}"
],
"path": [
"api",
"coordinator",
"scientific-activity"
]
}
},
"response": []
},
{
"name": "Coordinator Scientific Activity",
"request": {
Expand All @@ -2532,27 +2477,27 @@
"formdata": [
{
"key": "fullName",
"value": "",
"value": "Demo Name",
"type": "text"
},
{
"key": "publicationNumberWebOfScience",
"value": "",
"value": "323 I guess",
"type": "text"
},
{
"key": "committees",
"value": "",
"value": "One",
"type": "text"
},
{
"key": "conferences",
"value": "",
"value": "Conference",
"type": "text"
},
{
"key": "reportYear",
"value": "",
"value": "2012",
"type": "text"
}
]
Expand Down Expand Up @@ -2603,6 +2548,9 @@
"item": [
{
"name": "Coordinator Referential Activity",
"protocolProfileBehavior": {
"disableBodyPruning": true
},
"request": {
"method": "GET",
"header": [
Expand All @@ -2612,6 +2560,10 @@
"type": "text"
}
],
"body": {
"mode": "formdata",
"formdata": []
},
"url": {
"raw": "{{host}}/api/coordinator/scientific-activity",
"host": [
Expand All @@ -2629,7 +2581,7 @@
{
"name": "Coordinator Referential Activity",
"request": {
"method": "PUT",
"method": "PATCH",
"header": [
{
"key": "Authorization",
Expand All @@ -2642,22 +2594,22 @@
"formdata": [
{
"key": "fullName",
"value": "",
"value": "Full Name",
"type": "text"
},
{
"key": "thesisDomain",
"value": "",
"value": "Computer Science",
"type": "text"
},
{
"key": "thesisReference",
"value": "",
"value": "Reference",
"type": "text"
},
{
"key": "IOSUD",
"value": "",
"value": "ISOSU",
"type": "text"
}
]
Expand All @@ -2676,49 +2628,6 @@
},
"response": []
},
{
"name": "Coordinator Referential Activity",
"request": {
"method": "PATCH",
"header": [
{
"key": "Authorization",
"value": "{{coordinator_token}}",
"type": "text"
}
],
"url": {
"raw": "{{host}}/api/coordinator/scientific-activity?fullName&thesisDomain&thesisReference&IOSUD",
"host": [
"{{host}}"
],
"path": [
"api",
"coordinator",
"scientific-activity"
],
"query": [
{
"key": "fullName",
"value": null
},
{
"key": "thesisDomain",
"value": null
},
{
"key": "thesisReference",
"value": null
},
{
"key": "IOSUD",
"value": null
}
]
}
},
"response": []
},
{
"name": "Coordinator Referential Activity",
"request": {
Expand Down
43 changes: 4 additions & 39 deletions src/app/controller/coordinator.forms.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import {JwtService} from "../services/jwt.service";
import {Coordinator} from "../database/models";
import {CoordinatorFormsService} from "../service/coordinator.forms.service";
import {CoordinatorReferentialActivity, CoordinatorScientificActivity} from "../database/form.models";
import {StatusCode} from "../services/rest.util";

export class CoordinatorFormsController {

Expand All @@ -20,29 +19,13 @@ export class CoordinatorFormsController {
}
}

static async addCoordinatorScientificActivity(req: Request<any>, res: Response, next: NextFunction) {
try {
const token = req.get('Authorization') as string;
const coordinator = JwtService.verifyToken(token) as Coordinator;
const body = req.body as CoordinatorScientificActivity;

await CoordinatorFormsService.addCoordinatorScientificActivity(coordinator, body);

res.statusCode = StatusCode.CREATED;
res.end();
} catch (err) {
next(err);
}
}

static async updateCoordinatorScientificActivity(req: Request<any>, res: Response, next: NextFunction) {
try {
const token = req.get('Authorization') as string;
const coordinator = JwtService.verifyToken(token) as Coordinator;
const body = req.body as CoordinatorScientificActivity;
const formId = req.params.id;

await CoordinatorFormsService.updateCoordinatorScientificActivity(coordinator, formId, body);
await CoordinatorFormsService.updateCoordinatorScientificActivity(coordinator, body);
res.end();
} catch (err) {
next(err);
Expand All @@ -53,9 +36,8 @@ export class CoordinatorFormsController {
try {
const token = req.get('Authorization') as string;
const coordinator = JwtService.verifyToken(token) as Coordinator;
const id = req.params.id;

await CoordinatorFormsService.deleteCoordinatorScientificActivity(coordinator, id);
await CoordinatorFormsService.deleteCoordinatorScientificActivity(coordinator);
res.end();
} catch (err) {
next(err);
Expand All @@ -75,29 +57,13 @@ export class CoordinatorFormsController {
}
}

static async addCoordinatorReferentialActivity(req: Request<any>, res: Response, next: NextFunction) {
try {
const token = req.get('Authorization') as string;
const coordinator = JwtService.verifyToken(token) as Coordinator;
const body = req.body as CoordinatorReferentialActivity;

await CoordinatorFormsService.addCoordinatorReferentialActivity(coordinator, body);

res.statusCode = StatusCode.CREATED;
res.end();
} catch (err) {
next(err);
}
}

static async updateCoordinatorReferentialActivity(req: Request<any>, res: Response, next: NextFunction) {
try {
const token = req.get('Authorization') as string;
const coordinator = JwtService.verifyToken(token) as Coordinator;
const body = req.body as CoordinatorReferentialActivity;
const formId = req.params.id;

await CoordinatorFormsService.updateCoordinatorReferentialActivity(coordinator, formId, body);
await CoordinatorFormsService.updateCoordinatorReferentialActivity(coordinator, body);
res.end();
} catch (err) {
next(err);
Expand All @@ -108,9 +74,8 @@ export class CoordinatorFormsController {
try {
const token = req.get('Authorization') as string;
const coordinator = JwtService.verifyToken(token) as Coordinator;
const id = req.params.id;

await CoordinatorFormsService.deleteCoordinatorReferentialActivity(coordinator, id);
await CoordinatorFormsService.deleteCoordinatorReferentialActivity(coordinator);
res.end();
} catch (err) {
next(err);
Expand Down
2 changes: 0 additions & 2 deletions src/app/endpoints/coordinator.endpoints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,10 @@ export function registerCoordinatorEndpoints(app: Express) {
app.get(`${EndpointIdentifier.COORDINATOR_STUDENT_FORMS}/:identifier`, Middleware.coordinatorMiddleware, CoordinatorController.getStudentForms);

app.get(EndpointIdentifier.COORDINATOR_SCIENTIFIC_ACTIVITY, Middleware.coordinatorMiddleware, CoordinatorFormsController.getCoordinatorScientificActivity);
app.post(EndpointIdentifier.COORDINATOR_SCIENTIFIC_ACTIVITY, Middleware.coordinatorMiddleware, CoordinatorFormsController.addCoordinatorScientificActivity);
app.patch(EndpointIdentifier.COORDINATOR_SCIENTIFIC_ACTIVITY, Middleware.coordinatorMiddleware, CoordinatorFormsController.updateCoordinatorScientificActivity);
app.delete(EndpointIdentifier.COORDINATOR_SCIENTIFIC_ACTIVITY, Middleware.coordinatorMiddleware, CoordinatorFormsController.deleteCoordinatorScientificActivity);

app.get(EndpointIdentifier.COORDINATOR_REFERENTIAL_ACTIVITY, Middleware.coordinatorMiddleware, CoordinatorFormsController.getCoordinatorReferentialActivity);
app.post(EndpointIdentifier.COORDINATOR_REFERENTIAL_ACTIVITY, Middleware.coordinatorMiddleware, CoordinatorFormsController.addCoordinatorReferentialActivity);
app.patch(EndpointIdentifier.COORDINATOR_REFERENTIAL_ACTIVITY, Middleware.coordinatorMiddleware, CoordinatorFormsController.updateCoordinatorReferentialActivity);
app.delete(EndpointIdentifier.COORDINATOR_REFERENTIAL_ACTIVITY, Middleware.coordinatorMiddleware, CoordinatorFormsController.deleteCoordinatorReferentialActivity);

Expand Down
Loading

0 comments on commit 1ad20c1

Please sign in to comment.