perf: 站点证书监控支持模糊查询

pull/361/head
xiaojunnuo 2025-03-17 00:16:56 +08:00
parent b6fd38e293
commit 0069c0e399
2 changed files with 18 additions and 2 deletions

View File

@ -76,8 +76,7 @@ export default function (certPlugins: any[], formWrapperRef: any): CreateCrudOpt
dict: dict({ dict: dict({
data: [ data: [
{ value: "CertApply", label: "JS-ACME" }, { value: "CertApply", label: "JS-ACME" },
{ value: "CertApplyLego", label: "Lego-ACME" }, { value: "CertApplyLego", label: "Lego-ACME" }
{ value: "CertUpload", label: "上传自定义证书" }
] ]
}), }),
form: { form: {

View File

@ -21,10 +21,27 @@ export class SiteInfoController extends CrudController<SiteInfoService> {
async page(@Body(ALL) body: any) { async page(@Body(ALL) body: any) {
body.query = body.query ?? {}; body.query = body.query ?? {};
body.query.userId = this.getUserId(); body.query.userId = this.getUserId();
const certDomains = body.query.certDomains;
const domain = body.query.domain;
const name = body.query.name;
delete body.query.certDomains;
delete body.query.domain;
delete body.query.name;
const res = await this.service.page({ const res = await this.service.page({
query: body.query, query: body.query,
page: body.page, page: body.page,
sort: body.sort, sort: body.sort,
buildQuery: (bq) => {
if (domain) {
bq.andWhere('domain like :domain', { domain: `%${domain}%` });
}
if (certDomains) {
bq.andWhere('cert_domains like :cert_domains', { cert_domains: `%${certDomains}%` });
}
if (name) {
bq.andWhere('name like :name', { name: `%${name}%` });
}
}
}); });
return this.ok(res); return this.ok(res);
} }