新增客户用电回路表及相关数据库迁移、后端服务、控制器、DTO、实体类和权限配置;新增前端API封装,同时调整路由名称以匹配新业务模块,复用现有菜单权限避免403错误。
17 lines
1.2 KiB
TypeScript
17 lines
1.2 KiB
TypeScript
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); }
|
|
} |