35 lines
1.0 KiB
TypeScript
35 lines
1.0 KiB
TypeScript
import { Body, Controller, Get, Inject, Post } from '@nestjs/common';
|
|
import { ClientProxy } from '@nestjs/microservices';
|
|
import { firstValueFrom } from 'rxjs';
|
|
|
|
@Controller('admin')
|
|
export class AdminController {
|
|
constructor(@Inject('Client') private readonly client: ClientProxy) {}
|
|
|
|
@Get('find/annotator')
|
|
async findAnnotator() {
|
|
const { data } = await firstValueFrom(
|
|
this.client.send({ cmd: 'cert.user.find.annotator' }, {}),
|
|
);
|
|
return { data, code: 0 };
|
|
}
|
|
|
|
@Post('create/archiveTask')
|
|
async createArchiveTask(@Body() body) {
|
|
const { user, study } = body;
|
|
const { username } = user;
|
|
const { success, data, error } = await firstValueFrom(
|
|
this.client.send({ cmd: 'archive.task.create' }, { username, study }),
|
|
);
|
|
return success ? { code: 0, data } : { code: 1, msg: error.code };
|
|
}
|
|
|
|
@Get('find/dicom/all')
|
|
async findDicom() {
|
|
const { data } = await firstValueFrom(
|
|
this.client.send({ cmd: 'dicom.find.dicom' }, {}),
|
|
);
|
|
return { code: 0, data };
|
|
}
|
|
}
|