2025-09-10 08:04:28 +08:00
|
|
|
|
import { Injectable } from '@nestjs/common';
|
|
|
|
|
|
import { CoreRoleService } from '../core/CoreRoleService';
|
|
|
|
|
|
|
|
|
|
|
|
@Injectable()
|
|
|
|
|
|
export class RoleService {
|
|
|
|
|
|
constructor(private readonly coreRoleService: CoreRoleService) {}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2025-09-11 22:06:19 +08:00
|
|
|
|
* 用户组列表 - 控制器契约:getPage(siteId, query)
|
2025-09-10 08:04:28 +08:00
|
|
|
|
*/
|
2025-09-11 22:06:19 +08:00
|
|
|
|
async getPage(siteId: number, query: any) {
|
|
|
|
|
|
return this.coreRoleService.getPage({ ...query, site_id: siteId });
|
2025-09-10 08:04:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2025-09-11 22:06:19 +08:00
|
|
|
|
* 用户组详情
|
2025-09-10 08:04:28 +08:00
|
|
|
|
*/
|
2025-09-11 22:06:19 +08:00
|
|
|
|
async getInfo(role_id: number) {
|
|
|
|
|
|
return this.coreRoleService.getInfo(role_id);
|
2025-09-10 08:04:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2025-09-11 22:06:19 +08:00
|
|
|
|
* 删除用户组
|
2025-09-10 08:04:28 +08:00
|
|
|
|
*/
|
2025-09-11 22:06:19 +08:00
|
|
|
|
async delete(role_id: number) {
|
|
|
|
|
|
return this.coreRoleService.delete(role_id);
|
2025-09-10 08:04:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2025-09-11 22:06:19 +08:00
|
|
|
|
* 获取角色权限
|
2025-09-10 08:04:28 +08:00
|
|
|
|
*/
|
2025-09-11 22:06:19 +08:00
|
|
|
|
async getPermissions(role_id: number) {
|
|
|
|
|
|
return this.coreRoleService.getPermissions(role_id);
|
2025-09-10 08:04:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2025-09-11 22:06:19 +08:00
|
|
|
|
* 设置角色权限
|
2025-09-10 08:04:28 +08:00
|
|
|
|
*/
|
2025-09-11 22:06:19 +08:00
|
|
|
|
async setPermissions(role_id: number, menu_ids: number[]) {
|
|
|
|
|
|
return this.coreRoleService.setPermissions(role_id, menu_ids);
|
2025-09-10 08:04:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2025-09-11 22:06:19 +08:00
|
|
|
|
* 获取所有角色(与控制器对齐)
|
2025-09-10 08:04:28 +08:00
|
|
|
|
*/
|
2025-09-11 22:06:19 +08:00
|
|
|
|
async getAll(siteId: number, userRoleIds?: number[], isAdmin?: boolean) {
|
|
|
|
|
|
const isAdminNum = isAdmin ? 1 : 0;
|
|
|
|
|
|
return this.coreRoleService.getAll(siteId);
|
2025-09-10 08:04:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-09-11 22:06:19 +08:00
|
|
|
|
async getColumn(siteId: number) {
|
|
|
|
|
|
return this.coreRoleService.getColumn(siteId as any);
|
2025-09-10 08:04:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-09-11 22:06:19 +08:00
|
|
|
|
async modifyStatus(roleId: number, siteId: number, status: number) {
|
|
|
|
|
|
return this.coreRoleService.modifyStatus(roleId as any, siteId as any, status as any);
|
2025-09-10 08:04:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-09-11 22:06:19 +08:00
|
|
|
|
async del(roleId: number, siteId: number) {
|
|
|
|
|
|
return this.coreRoleService.del(roleId as any, siteId as any);
|
2025-09-10 08:04:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-09-11 22:06:19 +08:00
|
|
|
|
async getMenuIdsByRoleIds(siteId: number, roleIds: number[], allowMenuKeys?: string[]) {
|
|
|
|
|
|
return this.coreRoleService.getMenuIdsByRoleIds(siteId as any, roleIds as any);
|
2025-09-10 08:04:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-09-11 22:06:19 +08:00
|
|
|
|
// 控制器契约:add(siteId, appType, data)
|
|
|
|
|
|
async add(siteId: number, appType: string, data: any) {
|
|
|
|
|
|
return this.coreRoleService.add({ ...data, site_id: siteId, app_type: appType });
|
2025-09-10 08:04:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-09-11 22:06:19 +08:00
|
|
|
|
// 控制器契约:edit(roleId, siteId, data)
|
|
|
|
|
|
async edit(roleId: number, siteId: number, data: any) {
|
|
|
|
|
|
return this.coreRoleService.edit(roleId, siteId, { ...data, site_id: siteId });
|
2025-09-10 08:04:28 +08:00
|
|
|
|
}
|
2025-09-11 22:06:19 +08:00
|
|
|
|
}
|