Files
certd/packages/ui/certd-server/src/controller/sys/authority/permission-controller.ts
T

74 lines
1.8 KiB
TypeScript
Raw Normal View History

2026-05-31 01:41:33 +08:00
import { ALL, Body, Controller, Inject, Post, Provide, Query } from "@midwayjs/core";
import { CrudController } from "@certd/lib-server";
import { PermissionService } from "../../../modules/sys/authority/service/permission-service.js";
2026-07-10 19:24:42 +08:00
import { AuditType, AuditAction } from "../../modules/sys/enterprise/service/audit-constants.js";
/**
* 权限资源
*/
@Provide()
2026-05-31 01:41:33 +08:00
@Controller("/api/sys/authority/permission")
export class PermissionController extends CrudController<PermissionService> {
@Inject()
service: PermissionService;
getService() {
return this.service;
}
2026-05-31 01:41:33 +08:00
@Post("/page", { description: "sys:auth:per:view" })
async page(
@Body(ALL)
body
) {
return await super.page(body);
}
2026-05-31 01:41:33 +08:00
@Post("/add", { description: "sys:auth:per:add" })
async add(
@Body(ALL)
bean
) {
2026-07-10 19:24:42 +08:00
const res = await super.add(bean);
await this.auditLog({
type: AuditType.permission,
action: AuditAction.add,
content: `新增了权限「${bean.name}」(ID:${res.data})`,
});
return res;
}
2026-05-31 01:41:33 +08:00
@Post("/update", { description: "sys:auth:per:edit" })
async update(
@Body(ALL)
bean
) {
2026-07-10 19:24:42 +08:00
const res = await super.update(bean);
await this.auditLog({
type: AuditType.permission,
action: AuditAction.update,
content: `修改了权限「${bean.name}」(ID:${bean.id})`,
});
return res;
}
2026-05-31 01:41:33 +08:00
@Post("/delete", { description: "sys:auth:per:remove" })
async delete(
2026-05-31 01:41:33 +08:00
@Query("id")
id: number
) {
2026-07-10 19:24:42 +08:00
const res = await super.delete(id);
await this.auditLog({
type: AuditType.permission,
action: AuditAction.delete,
content: `删除了权限(ID:${id})`,
});
return res;
}
2026-05-31 01:41:33 +08:00
@Post("/tree", { description: "sys:auth:per:view" })
async tree() {
const tree = await this.service.tree({});
return this.ok(tree);
}
}