mirror of
https://github.com/certd/certd.git
synced 2026-04-24 04:17:25 +08:00
perf: 站点证书监控增加通知设置
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
import { ALL, Body, Controller, Inject, Post, Provide, Query } from '@midwayjs/core';
|
||||
import { Constants, CrudController } from '@certd/lib-server';
|
||||
import { AuthService } from '../../../modules/sys/authority/service/auth-service.js';
|
||||
import { SiteInfoService } from '../../../modules/monitor/service/site-info-service.js';
|
||||
import { ALL, Body, Controller, Inject, Post, Provide, Query } from "@midwayjs/core";
|
||||
import { Constants, CrudController } from "@certd/lib-server";
|
||||
import { AuthService } from "../../../modules/sys/authority/service/auth-service.js";
|
||||
import { SiteInfoService } from "../../../modules/monitor/service/site-info-service.js";
|
||||
import { UserSiteMonitorSetting } from "../../../modules/mine/service/models.js";
|
||||
import { merge } from "lodash-es";
|
||||
|
||||
/**
|
||||
*/
|
||||
@@ -94,4 +96,23 @@ export class SiteInfoController extends CrudController<SiteInfoService> {
|
||||
await this.service.checkAllByUsers(userId);
|
||||
return this.ok();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Post("/setting/get", { summary: Constants.per.authOnly })
|
||||
async get() {
|
||||
const userId = this.getUserId();
|
||||
const setting = await this.service.getSetting(userId)
|
||||
return this.ok(setting);
|
||||
}
|
||||
|
||||
@Post("/setting/save", { summary: Constants.per.authOnly })
|
||||
async save(@Body(ALL) bean: any) {
|
||||
const userId = this.getUserId();
|
||||
const setting = new UserSiteMonitorSetting();
|
||||
merge(setting, bean);
|
||||
|
||||
await this.service.saveSetting(userId, setting);
|
||||
return this.ok({});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,3 +19,10 @@ export class UserTwoFactorSetting extends BaseSettings {
|
||||
}
|
||||
|
||||
|
||||
|
||||
export class UserSiteMonitorSetting extends BaseSettings {
|
||||
static __title__ = "站点监控设置";
|
||||
static __key__ = "user.site.monitor";
|
||||
|
||||
notificationId?:number= 0;
|
||||
}
|
||||
|
||||
@@ -10,6 +10,8 @@ import { PeerCertificate } from 'tls';
|
||||
import { NotificationService } from '../../pipeline/service/notification-service.js';
|
||||
import { isComm, isPlus } from '@certd/plus-core';
|
||||
import { UserSuiteService } from '@certd/commercial-core';
|
||||
import { UserSettingsService } from "../../mine/service/user-settings-service.js";
|
||||
import { UserSiteMonitorSetting } from "../../mine/service/models.js";
|
||||
|
||||
@Provide()
|
||||
@Scope(ScopeEnum.Request, { allowDowngrade: true })
|
||||
@@ -26,6 +28,10 @@ export class SiteInfoService extends BaseService<SiteInfoEntity> {
|
||||
@Inject()
|
||||
userSuiteService: UserSuiteService;
|
||||
|
||||
@Inject()
|
||||
userSettingsService: UserSettingsService;
|
||||
|
||||
|
||||
//@ts-ignore
|
||||
getRepository() {
|
||||
return this.repository;
|
||||
@@ -236,4 +242,12 @@ export class SiteInfoService extends BaseService<SiteInfoEntity> {
|
||||
await utils.sleep(200);
|
||||
}
|
||||
}
|
||||
|
||||
async getSetting(userId: number){
|
||||
return await this.userSettingsService.getSetting<UserSiteMonitorSetting>(userId, UserSiteMonitorSetting);
|
||||
}
|
||||
|
||||
async saveSetting(userId: number, bean: UserSiteMonitorSetting) {
|
||||
await this.userSettingsService.saveSetting(userId, bean);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user