import { Controller, Get, Post, Put, Del, Inject, Query, Body, Param } from "@midwayjs/core"; import { Context } from "@midwayjs/koa"; import { SurveyOrderService } from "../service/survey_order.service"; @Controller("/api/survey-orders") export class SurveyOrderController { @Inject() ctx!: Context; @Inject() surveyOrderService!: SurveyOrderService; @Get("/") async list(@Query() query: any) { return this.surveyOrderService.list(query, this.ctx); } // 以下静态路径必须声明在 /:id 之前,否则会被动态路由吞掉 @Get("/stats") async stats() { return this.surveyOrderService.stats(this.ctx); } @Get("/quote") async quote(@Query("loopCount") loopCount: string) { return this.surveyOrderService.quote(loopCount); } // 批量指派 @Post("/batch-assign") async batchAssign(@Body() body: any) { return this.surveyOrderService.batchAssign(body, this.ctx); } @Get("/:id") async detail(@Param("id") id: string) { return this.surveyOrderService.detail(Number(id), this.ctx); } @Post("/") async create(@Body() body: any) { return this.surveyOrderService.create(body, this.ctx); } @Put("/:id") async update(@Param("id") id: string, @Body() body: any) { return this.surveyOrderService.update(Number(id), body, this.ctx); } // 勘察明细:全量替换(新增/编辑/删除统一走此接口) @Put("/:id/details") async saveDetails(@Param("id") id: string, @Body() body: any) { return this.surveyOrderService.saveDetails(Number(id), body, this.ctx); } // 指派 / 改派共享电工 @Put("/:id/assign") async assign(@Param("id") id: string, @Body() body: any) { return this.surveyOrderService.assign(Number(id), body, this.ctx); } // 技术复核:pass 归档 / reject 退回现场 @Put("/:id/review") async review(@Param("id") id: string, @Body() body: any) { return this.surveyOrderService.review(Number(id), body, this.ctx); } // 催办 @Post("/:id/urge") async urge(@Param("id") id: string) { return this.surveyOrderService.urge(Number(id), this.ctx); } // 取消工单 @Put("/:id/cancel") async cancel(@Param("id") id: string, @Body() body: any) { return this.surveyOrderService.cancel(Number(id), body, this.ctx); } @Del("/:id") async delete(@Param("id") id: string) { return this.surveyOrderService.delete(Number(id), this.ctx); } }