Server/project/src/controllers/NoteController.ts
TheSparta 418d9f2a8f Import path alias on the whole project (!157)
- Ability to use @spt-aki path alias on the whole project.
- Swapped all imports from relative paths, for imports using the path alias.

Reviewed-on: https://dev.sp-tarkov.com/SPT-AKI/Server/pulls/157
Co-authored-by: TheSparta <thesparta@noreply.dev.sp-tarkov.com>
Co-committed-by: TheSparta <thesparta@noreply.dev.sp-tarkov.com>
2023-10-19 17:21:17 +00:00

42 lines
1.5 KiB
TypeScript

import { inject, injectable } from "tsyringe";
import { IPmcData } from "@spt-aki/models/eft/common/IPmcData";
import { Note } from "@spt-aki/models/eft/common/tables/IBotBase";
import { IItemEventRouterResponse } from "@spt-aki/models/eft/itemEvent/IItemEventRouterResponse";
import { INoteActionData } from "@spt-aki/models/eft/notes/INoteActionData";
import { EventOutputHolder } from "@spt-aki/routers/EventOutputHolder";
@injectable()
export class NoteController
{
constructor(
@inject("EventOutputHolder") protected eventOutputHolder: EventOutputHolder
)
{ }
public addNote(pmcData: IPmcData, body: INoteActionData, sessionID: string): IItemEventRouterResponse
{
const newNote: Note = {
Time: body.note.Time,
Text: body.note.Text
};
pmcData.Notes.Notes.push(newNote);
return this.eventOutputHolder.getOutput(sessionID);
}
public editNote(pmcData: IPmcData, body: INoteActionData, sessionID: string): IItemEventRouterResponse
{
const noteToEdit: Note = pmcData.Notes.Notes[body.index];
noteToEdit.Time = body.note.Time;
noteToEdit.Text = body.note.Text;
return this.eventOutputHolder.getOutput(sessionID);
}
public deleteNote(pmcData: IPmcData, body: INoteActionData, sessionID: string): IItemEventRouterResponse
{
pmcData.Notes.Notes.splice(body.index, 1);
return this.eventOutputHolder.getOutput(sessionID);
}
}