import { Controller, Get, Post, Inject, Query, Param } from "@midwayjs/core"; import { Context } from "@midwayjs/koa"; import { ElectricGatewayService } from "../service/electric_gateway.service"; import { IccGatewaySyncService } from "../service/icc_gateway_sync.service"; @Controller("/api/electric-gateways") export class ElectricGatewayController { @Inject() ctx!: Context; @Inject() electricGatewayService!: ElectricGatewayService; @Inject() iccGatewaySyncService!: IccGatewaySyncService; @Get("/") async list(@Query() query: any) { return this.electricGatewayService.list(query, this.ctx); } @Get("/:id") async detail(@Param("id") id: string) { return this.electricGatewayService.detail(Number(id), this.ctx); } @Post("/sync") async sync() { const result = await this.iccGatewaySyncService.syncFromIcc(this.ctx); return { code: 200, message: "网关设备同步完成", data: result }; } }