2024-03-22 00:50:02 +08:00
|
|
|
import { Provide, Scope, ScopeEnum } from '@midwayjs/decorator';
|
2023-01-29 13:44:19 +08:00
|
|
|
import { InjectEntityModel } from '@midwayjs/typeorm';
|
|
|
|
|
import { Repository } from 'typeorm';
|
|
|
|
|
import { BaseService } from '../../../basic/base-service';
|
|
|
|
|
import { AccessEntity } from '../entity/access';
|
2024-03-22 00:50:02 +08:00
|
|
|
import { accessRegistry, IAccessService } from '@certd/pipeline';
|
2023-01-29 13:44:19 +08:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 授权
|
|
|
|
|
*/
|
|
|
|
|
@Provide()
|
|
|
|
|
@Scope(ScopeEnum.Singleton)
|
|
|
|
|
export class AccessService
|
|
|
|
|
extends BaseService<AccessEntity>
|
|
|
|
|
implements IAccessService
|
|
|
|
|
{
|
|
|
|
|
@InjectEntityModel(AccessEntity)
|
|
|
|
|
repository: Repository<AccessEntity>;
|
|
|
|
|
|
|
|
|
|
getRepository() {
|
|
|
|
|
return this.repository;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async getById(id: any): Promise<any> {
|
|
|
|
|
const entity = await this.info(id);
|
|
|
|
|
// const access = accessRegistry.get(entity.type);
|
|
|
|
|
const setting = JSON.parse(entity.setting);
|
|
|
|
|
return {
|
|
|
|
|
id: entity.id,
|
|
|
|
|
...setting,
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
getDefineList() {
|
|
|
|
|
return accessRegistry.getDefineList();
|
|
|
|
|
}
|
|
|
|
|
|
2024-03-22 00:50:02 +08:00
|
|
|
getDefineByType(type: string) {
|
2023-01-29 13:44:19 +08:00
|
|
|
return accessRegistry.getDefine(type);
|
|
|
|
|
}
|
2024-03-22 00:50:02 +08:00
|
|
|
|
2023-01-29 13:44:19 +08:00
|
|
|
}
|