mirror of
https://github.com/aditama-labs/nest-autocrud.git
synced 2024-11-21 19:06:21 +00:00
wip: working with type safety
This commit is contained in:
parent
20aaf2a2d7
commit
ce6cc37650
13
libs/skeleton/src/entities/pagination.entity.ts
Normal file
13
libs/skeleton/src/entities/pagination.entity.ts
Normal file
@ -0,0 +1,13 @@
|
||||
export interface IPaginationEntity<T> {
|
||||
// Data related
|
||||
data: T[];
|
||||
totalData: number;
|
||||
|
||||
// Page related
|
||||
totalPage: number;
|
||||
currentPage: number;
|
||||
lastPage: number;
|
||||
perPage: number;
|
||||
nextPage: number | null;
|
||||
previousPage: number | null;
|
||||
}
|
@ -1,12 +1,14 @@
|
||||
export interface ISkeletonCRUDController {
|
||||
create();
|
||||
readSelected(id);
|
||||
readPagination();
|
||||
readEntire();
|
||||
updatePartial();
|
||||
updatePartialBatch();
|
||||
updateEntire();
|
||||
updateEntirePatch();
|
||||
deleteSelected();
|
||||
deleteBatch();
|
||||
import { IPaginationEntity } from '@autocrud/skeleton/entities/pagination.entity';
|
||||
|
||||
export interface ISkeletonCRUDController<T> {
|
||||
create(): Promise<T>;
|
||||
readSelected(id): Promise<T>;
|
||||
readPagination(): Promise<IPaginationEntity<T>>;
|
||||
readEntire(): Promise<T[]>;
|
||||
updatePartial(): Promise<T>;
|
||||
updatePartialBatch(): Promise<T[]>;
|
||||
updateEntire(): Promise<T>;
|
||||
updateEntireBatch(): Promise<T[]>;
|
||||
deleteSelected(): Promise<T>;
|
||||
deleteBatch(): Promise<T[]>;
|
||||
}
|
||||
|
@ -1,10 +1,10 @@
|
||||
export interface SkeletonProcess {
|
||||
initialization(): void;
|
||||
before(): void;
|
||||
begin(): void;
|
||||
process(): void;
|
||||
end(): void;
|
||||
after(): void;
|
||||
import { Observable } from 'rxjs';
|
||||
|
||||
result();
|
||||
export interface SkeletonProcess {
|
||||
initialization(): Observable<void>;
|
||||
before(): Observable<void>;
|
||||
begin(): Observable<void>;
|
||||
process(): Observable<void>;
|
||||
end(): Observable<void>;
|
||||
after(): Observable<void>;
|
||||
}
|
||||
|
@ -1,34 +1,55 @@
|
||||
import { Delete, Get, Param, Patch, Post, Put } from '@nestjs/common';
|
||||
import { ISkeletonCRUDController } from './interfaces/controller/skeleton-crud.controller.interface';
|
||||
import { IPaginationEntity } from './entities/pagination.entity';
|
||||
|
||||
export class SkeletonCRUDController implements ISkeletonCRUDController {
|
||||
export class SkeletonCRUDController<T> implements ISkeletonCRUDController<T> {
|
||||
@Post()
|
||||
create() {}
|
||||
async create(): Promise<T> {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
|
||||
@Get(':id')
|
||||
readSelected(@Param('id') id) {}
|
||||
async readSelected(@Param('id') id): Promise<T> {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
|
||||
@Get()
|
||||
readPagination() {}
|
||||
async readPagination(): Promise<IPaginationEntity<T>> {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
|
||||
@Get('list')
|
||||
readEntire() {}
|
||||
async readEntire(): Promise<T[]> {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
|
||||
@Patch()
|
||||
updatePartial() {}
|
||||
async updatePartial(): Promise<T> {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
|
||||
@Patch('batch')
|
||||
updatePartialBatch() {}
|
||||
async updatePartialBatch(): Promise<T[]> {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
|
||||
@Put()
|
||||
updateEntire() {}
|
||||
async updateEntire(): Promise<T> {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
|
||||
@Put('batch')
|
||||
updateEntirePatch() {}
|
||||
async updateEntireBatch(): Promise<T[]> {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
|
||||
@Delete()
|
||||
deleteSelected() {}
|
||||
async deleteSelected(): Promise<T> {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
|
||||
@Delete('batch')
|
||||
deleteBatch() {}
|
||||
async deleteBatch(): Promise<T[]> {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user