Use the @CoolController decorator to automatically generate standard CRUD endpoints for an entity. By specifying the api array and the entity, you can instantly create 6 endpoints: add, delete, update, info, list, and page.
Example endpoints for a controller at /app/demo/goods:
POST /app/demo/goods/add (Create)POST /app/demo/goods/delete (Delete)POST /app/demo/goods/update (Update)GET /app/demo/goods/info (Get single record)POST /app/demo/goods/list (List records)POST /app/demo/goods/page (Paginated query with fuzzy search)
import { CoolController, BaseController } from '@cool-midway/core';
import { DemoAppGoodsEntity } from '../../entity/goods';
/**
* Product Controller
*/
@CoolController({
api: ['add', 'delete', 'update', 'info', 'list', 'page'],
entity: DemoAppGoodsEntity,
})
export class DemoAppGoodsController extends BaseController {
/**
* Custom endpoint
*/
@Get('/other')
async other() {
return this.ok('hello, cool-admin!!!');
}
}