Перейти к содержанию

Контроллеры: различия между версиями

Материал из Химсофт Вики
Нет описания правки
Нет описания правки
Строка 3: Строка 3:
В контексте сервиса интеграций могут использоваться самостоятельно, а так же являются компонентами более высокоуровневого <code>API</code>, например:
В контексте сервиса интеграций могут использоваться самостоятельно, а так же являются компонентами более высокоуровневого <code>API</code>, например:


*JournalRecordManager,
*''JournalRecordManager'',
*JournalResultManager.
*''JournalResultManager''.


Для каждого контроллера написаны тесты на <code>jest</code>, проверяющие корректность запросов.
Для каждого контроллера написаны тесты на <code>jest</code>, проверяющие корректность запросов.
Строка 13: Строка 13:
==Контроллер записей ЛЖ==
==Контроллер записей ЛЖ==
<syntaxhighlight lang="typescript">
<syntaxhighlight lang="typescript">
interface IJournalRecordsController {
    getAll(searchParameters?: JournalRecordsSearchParameters): Promise<PagedModelCustomJournalRecordResponse>,
    getRecordById(id: number, include?: string[]): Promise<JournalRecordResponse>,
    getRecordsByStage(searchParameters?: JournalRecordsSearchParameters): Promise<PagedModelCustomJournalRecordResponse>,
    createRecord(record: JournalRecordRequest): Promise<JournalRecordResponse>,
    createRecordPack(records: RecordsGroupRequest): Promise<JournalRecordResponse[]>,
    updateRecord(id: number, record: JournalRecordRequest): Promise<JournalRecordResponse>,
    addMethodologies(id: number, methodologies: MethodologiesBindingRequest): Promise<JournalRecordIndicatorResponse>,
    addIndicators(id: number, indicators: JournalRecordIndicatorRequest[]): Promise<JournalRecordResponse>,
    addAttribute(id: number, attribute: AttributeRequest[]): Promise<JournalRecordResponse>,
    movementRecord(movement: RecordMovementRequest): Promise<any>,
    deleteRecord(id: number): Promise<void>,
}
</syntaxhighlight>
</syntaxhighlight>


==Контроллер этапов==
==Контроллер этапов==
<syntaxhighlight lang="typescript">
<syntaxhighlight lang="typescript">
interface IJournalStagesController {
    getAllStages(): Promise<JournalRecordStageResponse[]>,
    getStageByPathname(pathname: string): Promise<JournalRecordStageResponse>,
    getInitStages(): Promise<JournalRecordStatusInitInfo[]>,
    createStage(payload: JournalRecordStageRequest): Promise<JournalRecordStageResponse>,
    updateStage(id: number, payload: JournalRecordStageRequest): Promise<JournalRecordStageResponse>,
    deleteStage(id: number): Promise<void>
}
</syntaxhighlight>
</syntaxhighlight>


==Контроллер результатов анализа==
==Контроллер результатов анализа==
<syntaxhighlight lang="typescript">
<syntaxhighlight lang="typescript">
interface IJournalResultController {
    getAll(): Promise<JournalResultResponse[]>,
    getById(id: number): Promise<JournalResultResponse>,
    calculateSingular(payload: CalculateInfo): Promise<ParallelResponse>,
    updateParallels(id: number, payload: ParallelRequest[]): Promise<JournalResultResponse>,
    updateExecutors(id: number, payload: number[]): Promise<JournalResultResponse>,
    updateAttributes(id: number, payload: JournalResultAttributesDto): Promise<JournalResultResponse>,
    addParallel(id: number, payload: ParallelRequest): Promise<void>,
    calculateById(id: number, payload: CalculateInfo): Promise<CalculationsReportDto>,
}
</syntaxhighlight>
</syntaxhighlight>


==Контроллер маршрутов==
==Контроллер маршрутов==
<syntaxhighlight lang="typescript">
<syntaxhighlight lang="typescript">
interface IJournalsRouterController {
    getAllRoutes(): Promise<JournalRouteResponse[]>;
    getRouteById(id: number): Promise<JournalRouteResponse>;
    getRoutesByCompanyLevel(id: number): Promise<JournalRouteResponse>;
    getAvailableStages(queryParameters?: Record<string, any>): Promise<JournalRecordStageResponse[]>;
    createRoute(payload: JournalRouteRequest): Promise<JournalRouteResponse>;
    updateRoute(id: number, payload: JournalRouteRequest): Promise<JournalRouteResponse>;
    deleteRoute(id: number): Promise<void>;
}
</syntaxhighlight>
</syntaxhighlight>


==Контроллер атрибутов==
==Контроллер атрибутов==
<syntaxhighlight lang="typescript">
<syntaxhighlight lang="typescript">
interface IJournalAttributeFieldController {
    getAll(searchParameters?: Record<string, string>): Promise<JournalRecordAttributeFieldResponse[]>,
    getAttributesFieldsByStage(searchParameters: { stageId: string }): Promise<JournalRecordAttributeFieldWithEdit[]>,
    getShared(searchParameters?: Record<string, string>): Promise<JournalRecordAttributeFieldResponse[]>,
}
</syntaxhighlight>
</syntaxhighlight>


==Контроллер формул==
==Контроллер формул==
<syntaxhighlight lang="typescript">
<syntaxhighlight lang="typescript">
interface IFormulaController {
    getAllFormulas(): Promise<FormulaResponse[]>,
    getFormulaById(formulaId: number): Promise<FormulaResponse>,
    createFormula(data: FormulaRequest | any): Promise<FormulaResponse>,
    calculateByFormula(payload: CalculationRequest): Promise<CalculationResponse>,
    updateFormulaById(formulaId: number, payload: FormulaRequest): Promise<FormulaResponse>,
    deleteFormulaById(formulaId: number): Promise<void>,
}
</syntaxhighlight>
</syntaxhighlight>


==Контроллер утилит==
==Контроллер утилит==
<syntaxhighlight lang="typescript">
<syntaxhighlight lang="typescript">
interface IJournalsUtilController {
    getFormulaId(methodologyId: number, indicatorId: number, unitId: number): Promise<number>,
}
</syntaxhighlight>
</syntaxhighlight>


==Контроллер персонала==
==Контроллер персонала==
<syntaxhighlight lang="typescript">
<syntaxhighlight lang="typescript">
interface EmployeesController {
    getAll(): Promise<PagedModelCustomEmployeeResponse>,
    getAllTypedEmployees(employeeType: EmployeeType): Promise<EmployeeResponse[]>,
    getById(id: number): Promise<EmployeeResponse>,
    getByAccountId(accountId: number),
    create(payload: EmployeeRequest): Promise<EmployeeResponse>,
    update(id: number, payload: EmployeeRequest): Promise<EmployeeResponse>
    delete(id: number): Promise<void>
}
</syntaxhighlight>
</syntaxhighlight>


==Контроллер объектов анализа==
==Контроллер объектов анализа==
<syntaxhighlight lang="typescript">
<syntaxhighlight lang="typescript">
interface IAnalysisObjectController {
    getAll(): Promise<PagedModelCustomAnalysisObjectResponse>,
    getById(analysisObjectId: number): Promise<AnalysisObjectResponse>,
    create(payload: AnalysisObjectRequest | any): Promise<AnalysisObjectResponse>,
    update(analysisObjectId: number, payload: AnalysisObjectRequest): Promise<AnalysisObjectResponse>,
    delete(analysisObjectId: number): Promise<void>
}
</syntaxhighlight>
</syntaxhighlight>


==Контроллер методик==
==Контроллер методик==
<syntaxhighlight lang="typescript">
<syntaxhighlight lang="typescript">
interface IMethodologyController {
    getAll(): Promise<PagedModelCustomMethodologyResponse>,
    getById(id: number): Promise<MethodologyResponse>,
    create(payload: MethodologyRequest): Promise<MethodologyResponse>,
    update(id: number, payload: MethodologyRequest): Promise<MethodologyResponse>,
    delete(id: number): Promise<void>
}
</syntaxhighlight>
</syntaxhighlight>

Версия от 01:20, 13 мая 2026

Контроллеры - классы имплементирующие запросы REST API Веб-ЛИМС согласно документации Swagger.

В контексте сервиса интеграций могут использоваться самостоятельно, а так же являются компонентами более высокоуровневого API, например:

  • JournalRecordManager,
  • JournalResultManager.

Для каждого контроллера написаны тесты на jest, проверяющие корректность запросов.

Команда запуска тестов

npm run test

Контроллер записей ЛЖ

interface IJournalRecordsController {
    getAll(searchParameters?: JournalRecordsSearchParameters): Promise<PagedModelCustomJournalRecordResponse>,
    getRecordById(id: number, include?: string[]): Promise<JournalRecordResponse>,
    getRecordsByStage(searchParameters?: JournalRecordsSearchParameters): Promise<PagedModelCustomJournalRecordResponse>,
    createRecord(record: JournalRecordRequest): Promise<JournalRecordResponse>,
    createRecordPack(records: RecordsGroupRequest): Promise<JournalRecordResponse[]>,
    updateRecord(id: number, record: JournalRecordRequest): Promise<JournalRecordResponse>,
    addMethodologies(id: number, methodologies: MethodologiesBindingRequest): Promise<JournalRecordIndicatorResponse>,
    addIndicators(id: number, indicators: JournalRecordIndicatorRequest[]): Promise<JournalRecordResponse>,
    addAttribute(id: number, attribute: AttributeRequest[]): Promise<JournalRecordResponse>,
    movementRecord(movement: RecordMovementRequest): Promise<any>,
    deleteRecord(id: number): Promise<void>,
}

Контроллер этапов

interface IJournalStagesController {
    getAllStages(): Promise<JournalRecordStageResponse[]>,
    getStageByPathname(pathname: string): Promise<JournalRecordStageResponse>,
    getInitStages(): Promise<JournalRecordStatusInitInfo[]>,
    createStage(payload: JournalRecordStageRequest): Promise<JournalRecordStageResponse>,
    updateStage(id: number, payload: JournalRecordStageRequest): Promise<JournalRecordStageResponse>,
    deleteStage(id: number): Promise<void>
}

Контроллер результатов анализа

interface IJournalResultController {
    getAll(): Promise<JournalResultResponse[]>,
    getById(id: number): Promise<JournalResultResponse>,
    calculateSingular(payload: CalculateInfo): Promise<ParallelResponse>,
    updateParallels(id: number, payload: ParallelRequest[]): Promise<JournalResultResponse>,
    updateExecutors(id: number, payload: number[]): Promise<JournalResultResponse>,
    updateAttributes(id: number, payload: JournalResultAttributesDto): Promise<JournalResultResponse>,
    addParallel(id: number, payload: ParallelRequest): Promise<void>,
    calculateById(id: number, payload: CalculateInfo): Promise<CalculationsReportDto>,
}

Контроллер маршрутов

interface IJournalsRouterController {
    getAllRoutes(): Promise<JournalRouteResponse[]>;
    getRouteById(id: number): Promise<JournalRouteResponse>;
    getRoutesByCompanyLevel(id: number): Promise<JournalRouteResponse>;
    getAvailableStages(queryParameters?: Record<string, any>): Promise<JournalRecordStageResponse[]>;
    createRoute(payload: JournalRouteRequest): Promise<JournalRouteResponse>;
    updateRoute(id: number, payload: JournalRouteRequest): Promise<JournalRouteResponse>;
    deleteRoute(id: number): Promise<void>;
}

Контроллер атрибутов

interface IJournalAttributeFieldController {
    getAll(searchParameters?: Record<string, string>): Promise<JournalRecordAttributeFieldResponse[]>,
    getAttributesFieldsByStage(searchParameters: { stageId: string }): Promise<JournalRecordAttributeFieldWithEdit[]>,
    getShared(searchParameters?: Record<string, string>): Promise<JournalRecordAttributeFieldResponse[]>,
}

Контроллер формул

interface IFormulaController {
    getAllFormulas(): Promise<FormulaResponse[]>,
    getFormulaById(formulaId: number): Promise<FormulaResponse>,
    createFormula(data: FormulaRequest | any): Promise<FormulaResponse>,
    calculateByFormula(payload: CalculationRequest): Promise<CalculationResponse>,
    updateFormulaById(formulaId: number, payload: FormulaRequest): Promise<FormulaResponse>,
    deleteFormulaById(formulaId: number): Promise<void>,
}

Контроллер утилит

interface IJournalsUtilController {
    getFormulaId(methodologyId: number, indicatorId: number, unitId: number): Promise<number>,
}

Контроллер персонала

interface EmployeesController {
    getAll(): Promise<PagedModelCustomEmployeeResponse>,
    getAllTypedEmployees(employeeType: EmployeeType): Promise<EmployeeResponse[]>,
    getById(id: number): Promise<EmployeeResponse>,
    getByAccountId(accountId: number),
    create(payload: EmployeeRequest): Promise<EmployeeResponse>,
    update(id: number, payload: EmployeeRequest): Promise<EmployeeResponse>
    delete(id: number): Promise<void>
}

Контроллер объектов анализа

interface IAnalysisObjectController {
    getAll(): Promise<PagedModelCustomAnalysisObjectResponse>,
    getById(analysisObjectId: number): Promise<AnalysisObjectResponse>,
    create(payload: AnalysisObjectRequest | any): Promise<AnalysisObjectResponse>,
    update(analysisObjectId: number, payload: AnalysisObjectRequest): Promise<AnalysisObjectResponse>,
    delete(analysisObjectId: number): Promise<void>
}

Контроллер методик

interface IMethodologyController {
    getAll(): Promise<PagedModelCustomMethodologyResponse>,
    getById(id: number): Promise<MethodologyResponse>,
    create(payload: MethodologyRequest): Promise<MethodologyResponse>,
    update(id: number, payload: MethodologyRequest): Promise<MethodologyResponse>,
    delete(id: number): Promise<void>
}