Files
smart_grid_iot/server/src/controller/customer.controller.ts
T
andyesfly 1c80a24d1d feat: 新增客户管理全模块功能
实现客户信息、客户部门、客户账号三个子模块的完整CRUD,包含:
1. 数据库实体、DTO、控制器、服务层代码
2. RBAC权限映射与菜单种子数据扩展
3. 前端路由与API封装
4. 数据权限隔离与鉴权逻辑
5. 配套工具脚本与测试验证清单
2026-08-23 19:15:54 +08:00

55 lines
1.4 KiB
TypeScript

import { Controller, Get, Post, Put, Del, Inject, Query, Body, Param } from "@midwayjs/core";
import { Context } from "@midwayjs/koa";
import { CustomerService } from "../service/customer.service";
@Controller("/api/customers")
export class CustomerController {
@Inject()
ctx!: Context;
@Inject()
customerService!: CustomerService;
@Get("/")
async list(@Query() query: any) {
const result = await this.customerService.list(query, this.ctx);
return result;
}
@Get("/options/all")
async getSimpleList() {
const result = await this.customerService.getSimpleList(this.ctx);
return result;
}
@Get("/:id")
async detail(@Param("id") id: string) {
const result = await this.customerService.detail(Number(id), this.ctx);
return result;
}
@Post("/")
async create(@Body() body: any) {
const result = await this.customerService.create(body, this.ctx);
return result;
}
@Put("/:id")
async update(@Param("id") id: string, @Body() body: any) {
const result = await this.customerService.update(Number(id), body, this.ctx);
return result;
}
@Del("/:id")
async delete(@Param("id") id: string) {
const result = await this.customerService.delete(Number(id), this.ctx);
return result;
}
@Put("/:id/status")
async updateStatus(@Param("id") id: string, @Body() body: { status: number }) {
const result = await this.customerService.updateStatus(Number(id), body.status, this.ctx);
return result;
}
}