mirror of
https://github.com/certd/certd.git
synced 2025-11-25 09:10:11 +08:00
chore:
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { Config, Inject, Provide, Scope, ScopeEnum } from '@midwayjs/core';
|
||||
import { Inject, Provide, Scope, ScopeEnum } from '@midwayjs/core';
|
||||
import { AppKey, PlusRequestService, verify } from '@certd/plus-core';
|
||||
import { logger } from '@certd/basic';
|
||||
import { SysInstallInfo, SysLicenseInfo, SysSettingsService } from '../../settings/index.js';
|
||||
@@ -8,15 +8,10 @@ import { SysInstallInfo, SysLicenseInfo, SysSettingsService } from '../../settin
|
||||
export class PlusService {
|
||||
@Inject()
|
||||
sysSettingsService: SysSettingsService;
|
||||
@Config('plus.server.baseUrls')
|
||||
plusServerBaseUrls: string[];
|
||||
|
||||
async getPlusRequestService() {
|
||||
const subjectId = await this.getSubjectId();
|
||||
return new PlusRequestService({
|
||||
plusServerBaseUrls: this.plusServerBaseUrls,
|
||||
subjectId,
|
||||
});
|
||||
return new PlusRequestService({ subjectId });
|
||||
}
|
||||
|
||||
async getSubjectId() {
|
||||
@@ -60,26 +55,16 @@ export class PlusService {
|
||||
const licenseInfo: SysLicenseInfo = await this.sysSettingsService.getSetting(SysLicenseInfo);
|
||||
const installInfo: SysInstallInfo = await this.sysSettingsService.getSetting(SysInstallInfo);
|
||||
|
||||
const plusRequestService = await this.getPlusRequestService();
|
||||
|
||||
return await verify({
|
||||
subjectId: plusRequestService.subjectId,
|
||||
subjectId: installInfo.siteId,
|
||||
license: licenseInfo.license,
|
||||
plusRequestService: plusRequestService,
|
||||
bindUrl: installInfo?.bindUrl,
|
||||
});
|
||||
}
|
||||
|
||||
async bindUrl(subjectId: string, url: string) {
|
||||
async bindUrl(url: string) {
|
||||
const plusRequestService = await this.getPlusRequestService();
|
||||
return await plusRequestService.request({
|
||||
url: '/activation/subject/urlBind',
|
||||
data: {
|
||||
subjectId,
|
||||
appKey: AppKey,
|
||||
url,
|
||||
},
|
||||
});
|
||||
return await plusRequestService.bindUrl(url);
|
||||
}
|
||||
|
||||
async register() {
|
||||
@@ -88,16 +73,11 @@ export class PlusService {
|
||||
const installInfo: SysInstallInfo = await this.sysSettingsService.getSetting(SysInstallInfo);
|
||||
if (!licenseInfo?.license) {
|
||||
//还没有license,注册一个
|
||||
const res = await plusRequestService.requestWithoutSign({
|
||||
url: '/activation/subject/register',
|
||||
data: {
|
||||
appKey: AppKey,
|
||||
subjectId: installInfo.siteId,
|
||||
installTime: installInfo.installTime,
|
||||
},
|
||||
const license = await plusRequestService.register({
|
||||
installTime: installInfo.installTime,
|
||||
});
|
||||
if (res.license) {
|
||||
await this.updateLicense(res.license);
|
||||
if (license) {
|
||||
await this.updateLicense(license);
|
||||
logger.info('站点注册成功');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user