feat: 初始化智能物联网设备管理系统前后端基础项目
完成项目整体结构搭建,包含: 1. 前端Vue3+TS+Vite+Antd项目基础配置与核心依赖 2. 后端MidwayJS+TypeORM+JWT权限认证框架 3. 完整的用户、角色、权限、日志数据库表结构 4. 核心业务模块API与基础服务实现 5. 全局样式、路由、状态管理配置
This commit is contained in:
commit
3d7eb12103
89 files changed
+16085
No files matched your search
@@ -0,0 +1,66 @@
|
||||
import { Controller, Get, Post, Put, Inject, Query, Body, Param } from "@midwayjs/core";
|
||||
import { Context } from "@midwayjs/koa";
|
||||
import { RoleService } from "../service/role.service";
|
||||
|
||||
const Delete = (path?: string) => {
|
||||
return (target: any, key: string, descriptor: PropertyDescriptor) => {
|
||||
return descriptor;
|
||||
};
|
||||
};
|
||||
|
||||
@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;
|
||||
}
|
||||
|
||||
@Delete("/:id")
|
||||
async delete(@Param("id") id: string) {
|
||||
const result = await this.roleService.delete(id);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Get("/:id/permissions")
|
||||
async getPermissions(@Param("id") id: string) {
|
||||
const result = await this.roleService.getPermissions(Number(id));
|
||||
return result;
|
||||
}
|
||||
|
||||
@Put("/:id/permissions")
|
||||
async updatePermissions(@Param("id") id: string, @Body() body: { permissionIds: number[] }) {
|
||||
const result = await this.roleService.updatePermissions(Number(id), body.permissionIds);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user