Files
certd/packages/ui/certd-server/src/modules/authority/controller/role-controller.ts
T

97 lines
1.9 KiB
TypeScript
Raw Normal View History

import {
ALL,
Body,
Controller,
Inject,
Post,
Provide,
Query,
2024-07-15 00:30:33 +08:00
} from '@midwayjs/core';
import { CrudController } from '../../../basic/crud-controller.js';
import { RoleService } from '../service/role-service.js';
/**
* 系统用户
*/
@Provide()
@Controller('/api/sys/authority/role')
export class RoleController extends CrudController<RoleService> {
@Inject()
service: RoleService;
getService() {
return this.service;
}
2023-06-27 09:29:43 +08:00
@Post('/page', { summary: 'sys:auth:role:view' })
async page(
@Body(ALL)
body
) {
return await super.page(body);
}
2023-06-27 09:29:43 +08:00
@Post('/list', { summary: 'sys:auth:role:view' })
async list() {
const ret = await this.service.find({});
return this.ok(ret);
}
2023-06-27 09:29:43 +08:00
@Post('/add', { summary: 'sys:auth:role:add' })
async add(
@Body(ALL)
bean
) {
return await super.add(bean);
}
2023-06-27 09:29:43 +08:00
@Post('/update', { summary: 'sys:auth:role:edit' })
async update(
@Body(ALL)
bean
) {
return await super.update(bean);
}
2023-06-27 09:29:43 +08:00
@Post('/delete', { summary: 'sys:auth:role:remove' })
async delete(
@Query('id')
id
) {
return await super.delete(id);
}
2023-06-27 09:29:43 +08:00
@Post('/getPermissionTree', { summary: 'sys:auth:role:view' })
async getPermissionTree(
@Query('id')
id
) {
const ret = await this.service.getPermissionTreeByRoleId(id);
return this.ok(ret);
}
2023-06-27 09:29:43 +08:00
@Post('/getPermissionIds', { summary: 'sys:auth:role:view' })
async getPermissionIds(
@Query('id')
id
) {
const ret = await this.service.getPermissionIdsByRoleId(id);
return this.ok(ret);
}
/**
* 给角色授予权限
2023-06-27 09:29:43 +08:00
* @param roleId
* @param permissionIds
*/
2023-06-27 09:29:43 +08:00
@Post('/authz', { summary: 'sys:auth:role:edit' })
async authz(
@Body('roleId')
roleId,
@Body('permissionIds')
permissionIds
) {
await this.service.authz(roleId, permissionIds);
return this.ok(null);
}
}