mirror of
https://github.com/certd/certd.git
synced 2026-05-19 07:37:36 +08:00
chore: 商业版也支持企业模式
This commit is contained in:
@@ -56,6 +56,10 @@ export function findStep(pipeline: any, id: string) {
|
|||||||
|
|
||||||
export async function checkPipelineLimit() {
|
export async function checkPipelineLimit() {
|
||||||
const settingsStore = useSettingStore();
|
const settingsStore = useSettingStore();
|
||||||
|
if (settingsStore.isEnterprise) {
|
||||||
|
//企业模式不限制
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (settingsStore.isComm && settingsStore.suiteSetting.enabled) {
|
if (settingsStore.isComm && settingsStore.suiteSetting.enabled) {
|
||||||
//检查数量是否超限
|
//检查数量是否超限
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import {Inject, Provide, Scope, ScopeEnum} from "@midwayjs/core";
|
import {Inject, Provide, Scope, ScopeEnum} from "@midwayjs/core";
|
||||||
import {BaseService, Constants, NeedSuiteException, NeedVIPException, SysSettingsService} from "@certd/lib-server";
|
import {BaseService, Constants, isEnterprise, NeedSuiteException, NeedVIPException, SysSettingsService} from "@certd/lib-server";
|
||||||
import {InjectEntityModel} from "@midwayjs/typeorm";
|
import {InjectEntityModel} from "@midwayjs/typeorm";
|
||||||
import {In, Repository} from "typeorm";
|
import {In, Repository} from "typeorm";
|
||||||
import {SiteInfoEntity} from "../entity/site-info.js";
|
import {SiteInfoEntity} from "../entity/site-info.js";
|
||||||
@@ -59,25 +59,35 @@ export class SiteInfoService extends BaseService<SiteInfoEntity> {
|
|||||||
return this.repository;
|
return this.repository;
|
||||||
}
|
}
|
||||||
|
|
||||||
async add(data: SiteInfoEntity) {
|
async checkMonitorLimit(userId: number) {
|
||||||
if (data.userId == null) {
|
if (isEnterprise()) {
|
||||||
throw new Error("userId is required");
|
//企业模式不限制
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isComm()) {
|
if (isComm()) {
|
||||||
const suiteSetting = await this.userSuiteService.getSuiteSetting();
|
const suiteSetting = await this.userSuiteService.getSuiteSetting();
|
||||||
if (suiteSetting.enabled) {
|
if (suiteSetting.enabled) {
|
||||||
const userSuite = await this.userSuiteService.getMySuiteDetail(data.userId);
|
const userSuite = await this.userSuiteService.getMySuiteDetail(userId);
|
||||||
if (userSuite.monitorCount.max != -1 && userSuite.monitorCount.max <= userSuite.monitorCount.used) {
|
if (userSuite.monitorCount.max != -1 && userSuite.monitorCount.max <= userSuite.monitorCount.used) {
|
||||||
throw new NeedSuiteException("站点监控数量已达上限,请购买或升级套餐");
|
throw new NeedSuiteException("站点监控数量已达上限,请购买或升级套餐");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (!isPlus()) {
|
} else if (!isPlus()) {
|
||||||
const count = await this.getUserMonitorCount(data.userId);
|
const count = await this.getUserMonitorCount(userId);
|
||||||
if (count >= 1) {
|
if (count >= 1) {
|
||||||
throw new NeedVIPException("站点监控数量已达上限,请升级专业版");
|
throw new NeedVIPException("站点监控数量已达上限,请升级专业版");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async add(data: SiteInfoEntity) {
|
||||||
|
if (data.userId == null) {
|
||||||
|
throw new Error("userId is required");
|
||||||
|
}
|
||||||
|
|
||||||
|
await this.checkMonitorLimit(data.userId);
|
||||||
|
|
||||||
data.disabled = false;
|
data.disabled = false;
|
||||||
|
|
||||||
const found = await this.repository.findOne({
|
const found = await this.repository.findOne({
|
||||||
|
|||||||
Reference in New Issue
Block a user