import { Controller } from 'egg' ; import { route } from '../../../../../lib' ; interface RespModel { a : string ; b ? : { c : number ; } ; } interface RequestModel { a : string ; b : { c ? : number ; } ; } export class HomeController extends Controller { @ route ( '/api/normal' , { name : 'get' } ) getNormal ( ) { return 'ok' ; } @ route ( '/api/query' , { name : 'get with query: q' } ) getQuery ( q ) { return 'ok' ; } @ route ( '/api/query/:q' , { name : 'get with path: q' } ) getParam ( q ) { return 'ok' ; } @ route ( '/api/complex/:q' , { name : 'get complex' } ) getComplex ( q , p ) { return 'ok' ; } @ route ( 'POST /api/body' , { name : 'post with body: q' } ) post ( q ) { return 'ok' ; } @ route ( 'POST /api/complex' , { name : 'complex' } ) complex ( id , data ) { return { } as RespModel ; } }