- 重构sys模块架构,严格按admin/api/core分层 - 对齐所有sys实体与数据库表结构 - 实现完整的adminapi控制器,匹配PHP/Java契约 - 修复依赖注入问题,确保服务正确注册 - 添加自动迁移工具和契约验证 - 完善多租户支持和审计功能 - 统一命名规范,与PHP业务逻辑保持一致
24 lines
784 B
TypeScript
24 lines
784 B
TypeScript
import { Injectable, NotFoundException } from '@nestjs/common';
|
|
import { InjectRepository } from '@nestjs/typeorm';
|
|
import { Repository, FindOptionsOrder } from 'typeorm';
|
|
import { SysRole } from '../../entity/sysRole.entity';
|
|
|
|
@Injectable()
|
|
export class SysRoleService {
|
|
constructor(
|
|
@InjectRepository(SysRole)
|
|
private readonly roleRepo: Repository<SysRole>,
|
|
) {}
|
|
|
|
async list(siteId: number): Promise<SysRole[]> {
|
|
const order: FindOptionsOrder<SysRole> = { role_id: 'ASC' };
|
|
return this.roleRepo.find({ where: { site_id: siteId }, order });
|
|
}
|
|
|
|
async detail(roleId: number): Promise<SysRole> {
|
|
const role = await this.roleRepo.findOne({ where: { role_id: roleId } });
|
|
if (!role) throw new NotFoundException('角色不存在');
|
|
return role;
|
|
}
|
|
}
|