perf: 优化站点ip检查

This commit is contained in:
xiaojunnuo
2025-05-28 13:57:31 +08:00
parent 3a147141b1
commit a463711b03
11 changed files with 219 additions and 139 deletions

View File

@@ -4,6 +4,7 @@ import { AuthService } from "../../../modules/sys/authority/service/auth-service
import { SiteInfoService } from "../../../modules/monitor/service/site-info-service.js";
import { UserSiteMonitorSetting } from "../../../modules/mine/service/models.js";
import { merge } from "lodash-es";
import {SiteIpService} from "../../../modules/monitor/service/site-ip-service.js";
/**
*/
@@ -14,6 +15,8 @@ export class SiteInfoController extends CrudController<SiteInfoService> {
service: SiteInfoService;
@Inject()
authService: AuthService;
@Inject()
siteIpService: SiteIpService;
getService(): SiteInfoService {
return this.service;
@@ -96,7 +99,16 @@ export class SiteInfoController extends CrudController<SiteInfoService> {
await this.service.checkAllByUsers(userId);
return this.ok();
}
@Post('/ipCheckChange', { summary: Constants.per.authOnly })
async ipCheckChange(@Body(ALL) bean: any) {
const userId = this.getUserId();
await this.service.checkUserId(bean.id, userId)
await this.service.ipCheckChange({
id: bean.id,
ipCheck: bean.ipCheck
});
return this.ok();
}
@Post("/setting/get", { summary: Constants.per.authOnly })

View File

@@ -44,7 +44,9 @@ export class SiteInfoController extends CrudController<SiteIpService> {
bean.userId = this.getUserId();
bean.from = "manual"
const res = await this.service.add(bean);
this.service.check(res.id);
const siteEntity = await this.siteInfoService.info(bean.siteId);
const {domain, httpsPort} = siteEntity;
this.service.check(res.id,domain, httpsPort);
return this.ok(res);
}
@@ -53,7 +55,9 @@ export class SiteInfoController extends CrudController<SiteIpService> {
await this.service.checkUserId(bean.id, this.getUserId());
delete bean.userId;
await this.service.update(bean);
this.service.check(bean.id);
const siteEntity = await this.siteInfoService.info(bean.siteId);
const {domain, httpsPort} = siteEntity;
this.service.check(bean.id,domain, httpsPort);
return this.ok();
}
@Post('/info', { summary: Constants.per.authOnly })
@@ -71,7 +75,11 @@ export class SiteInfoController extends CrudController<SiteIpService> {
@Post('/check', { summary: Constants.per.authOnly })
async check(@Body('id') id: number) {
await this.service.checkUserId(id, this.getUserId());
this.service.check(id);
const entity = await this.service.info(id);
const siteEntity = await this.siteInfoService.info(entity.siteId);
const domain = siteEntity.domain;
const port = siteEntity.httpsPort;
this.service.check(id,domain,port);
return this.ok();
}
@@ -79,7 +87,8 @@ export class SiteInfoController extends CrudController<SiteIpService> {
async checkAll(@Body('siteId') siteId: number) {
const userId = this.getUserId();
await this.siteInfoService.checkUserId(siteId, userId);
await this.service.checkAll(siteId);
const siteEntity = await this.siteInfoService.info(siteId);
await this.service.checkAll(siteEntity);
return this.ok();
}
@@ -94,4 +103,5 @@ export class SiteInfoController extends CrudController<SiteIpService> {
return this.ok();
}
}