mirror of
https://github.com/aditama-labs/nest-autocrud.git
synced 2024-11-22 03:16: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 {
|
import { IPaginationEntity } from '@autocrud/skeleton/entities/pagination.entity';
|
||||||
create();
|
|
||||||
readSelected(id);
|
export interface ISkeletonCRUDController<T> {
|
||||||
readPagination();
|
create(): Promise<T>;
|
||||||
readEntire();
|
readSelected(id): Promise<T>;
|
||||||
updatePartial();
|
readPagination(): Promise<IPaginationEntity<T>>;
|
||||||
updatePartialBatch();
|
readEntire(): Promise<T[]>;
|
||||||
updateEntire();
|
updatePartial(): Promise<T>;
|
||||||
updateEntirePatch();
|
updatePartialBatch(): Promise<T[]>;
|
||||||
deleteSelected();
|
updateEntire(): Promise<T>;
|
||||||
deleteBatch();
|
updateEntireBatch(): Promise<T[]>;
|
||||||
|
deleteSelected(): Promise<T>;
|
||||||
|
deleteBatch(): Promise<T[]>;
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
export interface SkeletonProcess {
|
import { Observable } from 'rxjs';
|
||||||
initialization(): void;
|
|
||||||
before(): void;
|
|
||||||
begin(): void;
|
|
||||||
process(): void;
|
|
||||||
end(): void;
|
|
||||||
after(): void;
|
|
||||||
|
|
||||||
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 { Delete, Get, Param, Patch, Post, Put } from '@nestjs/common';
|
||||||
import { ISkeletonCRUDController } from './interfaces/controller/skeleton-crud.controller.interface';
|
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()
|
@Post()
|
||||||
create() {}
|
async create(): Promise<T> {
|
||||||
|
throw new Error('Method not implemented.');
|
||||||
|
}
|
||||||
|
|
||||||
@Get(':id')
|
@Get(':id')
|
||||||
readSelected(@Param('id') id) {}
|
async readSelected(@Param('id') id): Promise<T> {
|
||||||
|
throw new Error('Method not implemented.');
|
||||||
|
}
|
||||||
|
|
||||||
@Get()
|
@Get()
|
||||||
readPagination() {}
|
async readPagination(): Promise<IPaginationEntity<T>> {
|
||||||
|
throw new Error('Method not implemented.');
|
||||||
|
}
|
||||||
|
|
||||||
@Get('list')
|
@Get('list')
|
||||||
readEntire() {}
|
async readEntire(): Promise<T[]> {
|
||||||
|
throw new Error('Method not implemented.');
|
||||||
|
}
|
||||||
|
|
||||||
@Patch()
|
@Patch()
|
||||||
updatePartial() {}
|
async updatePartial(): Promise<T> {
|
||||||
|
throw new Error('Method not implemented.');
|
||||||
|
}
|
||||||
|
|
||||||
@Patch('batch')
|
@Patch('batch')
|
||||||
updatePartialBatch() {}
|
async updatePartialBatch(): Promise<T[]> {
|
||||||
|
throw new Error('Method not implemented.');
|
||||||
|
}
|
||||||
|
|
||||||
@Put()
|
@Put()
|
||||||
updateEntire() {}
|
async updateEntire(): Promise<T> {
|
||||||
|
throw new Error('Method not implemented.');
|
||||||
|
}
|
||||||
|
|
||||||
@Put('batch')
|
@Put('batch')
|
||||||
updateEntirePatch() {}
|
async updateEntireBatch(): Promise<T[]> {
|
||||||
|
throw new Error('Method not implemented.');
|
||||||
|
}
|
||||||
|
|
||||||
@Delete()
|
@Delete()
|
||||||
deleteSelected() {}
|
async deleteSelected(): Promise<T> {
|
||||||
|
throw new Error('Method not implemented.');
|
||||||
|
}
|
||||||
|
|
||||||
@Delete('batch')
|
@Delete('batch')
|
||||||
deleteBatch() {}
|
async deleteBatch(): Promise<T[]> {
|
||||||
|
throw new Error('Method not implemented.');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user