import { Controller, Get, Post, Put, Del, Inject, Query, Body, Param } from "@midwayjs/core"; import { Context } from "@midwayjs/koa"; import { CustomerCircuitService } from "../service/customer_circuit.service"; @Controller("/api/customer-circuits") export class CustomerCircuitController { @Inject() ctx!: Context; @Inject() customerCircuitService!: CustomerCircuitService; @Get("/") async list(@Query() query: any) { return this.customerCircuitService.list(query, this.ctx); } // 注意:静态路径 /topology 必须声明在 /:id 之前,避免被参数路由捕获 @Get("/topology") async topology(@Query() query: any) { return this.customerCircuitService.topology(query, this.ctx); } @Get("/:id") async detail(@Param("id") id: string) { return this.customerCircuitService.detail(Number(id), this.ctx); } @Post("/") async create(@Body() body: any) { return this.customerCircuitService.create(body, this.ctx); } @Put("/:id") async update(@Param("id") id: string, @Body() body: any) { return this.customerCircuitService.update(Number(id), body, this.ctx); } @Del("/:id") async delete(@Param("id") id: string) { return this.customerCircuitService.delete(Number(id), this.ctx); } }