Files
smart_grid_iot/server/src/controller/role.controller.ts
T
andyesfly 0a8103f33d refactor: 系统权限模块重构,迁移至PostgreSQL并对齐新设计
- 切换数据库为PostgreSQL,更新依赖与配置
- 重构权限体系,使用sys_user/sys_role/sys_menu等新实体替代旧模型
- 移除旧的用户角色/权限/系统设置相关代码与实体
- 新增字典、菜单管理模块与基础CRUD接口
- 优化鉴权逻辑,基于菜单权限标识进行接口校验
- 前端同步更新API、路由与权限控制逻辑
- 删除冗余的v-permission指令与相关代码
2026-08-19 14:11:34 +08:00

61 lines
1.4 KiB
TypeScript

import { Controller, Get, Post, Put, Del, Inject, Query, Body, Param } from "@midwayjs/core";
import { Context } from "@midwayjs/koa";
import { RoleService } from "../service/role.service";
@Controller("/api/roles")
export class RoleController {
@Inject()
ctx!: Context;
@Inject()
roleService!: RoleService;
@Get("/")
async list(@Query() query: { page?: number; pageSize?: number; keyword?: string }) {
const result = await this.roleService.list(query);
return result;
}
@Get("/all")
async getAllRoles() {
const result = await this.roleService.getAllRoles();
return result;
}
@Get("/:id")
async detail(@Param("id") id: string) {
const result = await this.roleService.detail(id);
return result;
}
@Post("/")
async create(@Body() body: any) {
const result = await this.roleService.create(body);
return result;
}
@Put("/:id")
async update(@Param("id") id: string, @Body() body: any) {
const result = await this.roleService.update(id, body);
return result;
}
@Del("/:id")
async delete(@Param("id") id: string) {
const result = await this.roleService.delete(id);
return result;
}
@Get("/:id/menus")
async getMenus(@Param("id") id: string) {
const result = await this.roleService.getMenus(Number(id));
return result;
}
@Put("/:id/menus")
async updateMenus(@Param("id") id: string, @Body() body: { menuIds: number[] }) {
const result = await this.roleService.updateMenus(Number(id), body.menuIds);
return result;
}
}