chore: 优化站点ip检查

This commit is contained in:
xiaojunnuo
2025-05-28 15:49:48 +08:00
parent 41f4617e66
commit 45814ceb49
9 changed files with 71 additions and 11 deletions
@@ -62,7 +62,10 @@ export class SiteInfoController extends CrudController<SiteInfoService> {
async add(@Body(ALL) bean: any) {
bean.userId = this.getUserId();
const res = await this.service.add(bean);
this.service.check(res.id, true, 0);
const entity = await this.service.info(res.id);
if (entity.disabled) {
this.service.check(entity.id, true, 0);
}
return this.ok(res);
}
@@ -71,7 +74,10 @@ export class SiteInfoController extends CrudController<SiteInfoService> {
await this.service.checkUserId(bean.id, this.getUserId());
delete bean.userId;
await this.service.update(bean);
this.service.check(bean.id, true, 0);
const entity = await this.service.info(bean.id);
if (entity.disabled) {
this.service.check(entity.id, true, 0);
}
return this.ok();
}
@Post('/info', { summary: Constants.per.authOnly })
@@ -110,6 +116,16 @@ export class SiteInfoController extends CrudController<SiteInfoService> {
return this.ok();
}
@Post('/disabledChange', { summary: Constants.per.authOnly })
async disabledChange(@Body(ALL) bean: any) {
const userId = this.getUserId();
await this.service.checkUserId(bean.id, userId)
await this.service.disabledChange({
id: bean.id,
disabled: bean.disabled
});
return this.ok();
}
@Post("/setting/get", { summary: Constants.per.authOnly })
async get() {
@@ -45,8 +45,10 @@ export class SiteInfoController extends CrudController<SiteIpService> {
bean.from = "manual"
const res = await this.service.add(bean);
const siteEntity = await this.siteInfoService.info(bean.siteId);
const {domain, httpsPort} = siteEntity;
this.service.check(res.id,domain, httpsPort);
if(!siteEntity.disabled){
const {domain, httpsPort} = siteEntity;
this.service.check(res.id,domain, httpsPort);
}
return this.ok(res);
}
@@ -56,8 +58,10 @@ export class SiteInfoController extends CrudController<SiteIpService> {
delete bean.userId;
await this.service.update(bean);
const siteEntity = await this.siteInfoService.info(bean.siteId);
const {domain, httpsPort} = siteEntity;
this.service.check(bean.id,domain, httpsPort);
if(!siteEntity.disabled){
const {domain, httpsPort} = siteEntity;
this.service.check(siteEntity.id,domain, httpsPort);
}
return this.ok();
}
@Post('/info', { summary: Constants.per.authOnly })