feat(core): Execution curation (#10342)

Co-authored-by: oleg <me@olegivaniv.com>
This commit is contained in:
Eugene
2024-09-02 15:20:08 +02:00
committed by GitHub
parent 8603946e23
commit 022ddcbef9
75 changed files with 2733 additions and 713 deletions

View File

@@ -0,0 +1,45 @@
import { Delete, Get, Patch, Post, RestController, GlobalScope } from '@/decorators';
import { AnnotationTagService } from '@/services/annotation-tag.service';
import { AnnotationTagsRequest } from '@/requests';
@RestController('/annotation-tags')
export class AnnotationTagsController {
constructor(private readonly annotationTagService: AnnotationTagService) {}
@Get('/')
@GlobalScope('annotationTag:list')
async getAll(req: AnnotationTagsRequest.GetAll) {
return await this.annotationTagService.getAll({
withUsageCount: req.query.withUsageCount === 'true',
});
}
@Post('/')
@GlobalScope('annotationTag:create')
async createTag(req: AnnotationTagsRequest.Create) {
const tag = this.annotationTagService.toEntity({ name: req.body.name });
return await this.annotationTagService.save(tag);
}
@Patch('/:id(\\w+)')
@GlobalScope('annotationTag:update')
async updateTag(req: AnnotationTagsRequest.Update) {
const newTag = this.annotationTagService.toEntity({
id: req.params.id,
name: req.body.name.trim(),
});
return await this.annotationTagService.save(newTag);
}
@Delete('/:id(\\w+)')
@GlobalScope('annotationTag:delete')
async deleteTag(req: AnnotationTagsRequest.Delete) {
const { id } = req.params;
await this.annotationTagService.delete(id);
return true;
}
}