mirror of
https://github.com/certd/certd.git
synced 2026-05-17 05:37:30 +08:00
perf: cname 域名映射记录可读性优化
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
import { Provide, Scope, ScopeEnum } from '@midwayjs/core';
|
||||
import { InjectEntityModel } from '@midwayjs/typeorm';
|
||||
import { Repository } from 'typeorm';
|
||||
import { BaseService, ValidateException } from '@certd/lib-server';
|
||||
import { CnameProviderEntity } from '../entity/cname_provider.js';
|
||||
import { BaseService, ListReq, ValidateException } from '@certd/lib-server';
|
||||
import { CnameProviderEntity } from '../entity/cname-provider.js';
|
||||
import { CommonProviders } from './common-provider.js';
|
||||
|
||||
/**
|
||||
* 授权
|
||||
@@ -19,7 +20,7 @@ export class CnameProviderService extends BaseService<CnameProviderEntity> {
|
||||
}
|
||||
|
||||
async getDefault() {
|
||||
return await this.repository.findOne({ where: { isDefault: true } });
|
||||
return await this.repository.findOne({ where: { isDefault: true, disabled: false } });
|
||||
}
|
||||
/**
|
||||
* 新增
|
||||
@@ -80,10 +81,24 @@ export class CnameProviderService extends BaseService<CnameProviderEntity> {
|
||||
if (def) {
|
||||
return def;
|
||||
}
|
||||
const founds = await this.repository.find({ take: 1, order: { createTime: 'DESC' } });
|
||||
const founds = await this.repository.find({ take: 1, order: { createTime: 'DESC' }, where: { disabled: false } });
|
||||
if (founds && founds.length > 0) {
|
||||
return founds[0];
|
||||
}
|
||||
return null;
|
||||
return CommonProviders[0] as CnameProviderEntity;
|
||||
}
|
||||
|
||||
async list(req: ListReq): Promise<any[]> {
|
||||
const list = await super.list(req);
|
||||
|
||||
return [...list, ...CommonProviders];
|
||||
}
|
||||
|
||||
async info(id: any, infoIgnoreProperty?: any): Promise<any | null> {
|
||||
if (id < 0) {
|
||||
//使用公共provider
|
||||
return CommonProviders.find(p => p.id === id);
|
||||
}
|
||||
return await super.info(id, infoIgnoreProperty);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user