From 17638f3d3a6be6d60c30ead51ed035967c3b6b88 Mon Sep 17 00:00:00 2001 From: xiaojunnuo <xiaojunnuo@qq.com> Date: Thu, 7 Nov 2024 00:17:35 +0800 Subject: [PATCH] chore: --- index.ts | 0 package.json | 5 ++- .../src/system/basic/service/plus-service.ts | 38 +++++-------------- packages/ui/certd-server/.env.localplus.yaml | 29 ++++++++++++++ packages/ui/certd-server/package.json | 1 + 5 files changed, 42 insertions(+), 31 deletions(-) create mode 100644 index.ts create mode 100644 packages/ui/certd-server/.env.localplus.yaml diff --git a/index.ts b/index.ts new file mode 100644 index 00000000..e69de29b diff --git a/package.json b/package.json index 5a65b030..58c4ebf5 100644 --- a/package.json +++ b/package.json @@ -34,9 +34,10 @@ "license": "AGPL-3.0", "dependencies": { "axios": "^1.7.7", - "lodash-es": "^4.17.21" + "lodash-es": "^4.17.21", + "typescript": "^5.4.2" }, "workspaces": [ "packages/**" ] -} \ No newline at end of file +} diff --git a/packages/libs/lib-server/src/system/basic/service/plus-service.ts b/packages/libs/lib-server/src/system/basic/service/plus-service.ts index 26a5cfd8..7c78696d 100644 --- a/packages/libs/lib-server/src/system/basic/service/plus-service.ts +++ b/packages/libs/lib-server/src/system/basic/service/plus-service.ts @@ -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('站点注册成功'); } } diff --git a/packages/ui/certd-server/.env.localplus.yaml b/packages/ui/certd-server/.env.localplus.yaml new file mode 100644 index 00000000..84423ee1 --- /dev/null +++ b/packages/ui/certd-server/.env.localplus.yaml @@ -0,0 +1,29 @@ +# key: ./data/ssl/cert.key +# cert: ./data/ssl/cert.crt +#plus: +# server: +# baseUrl: 'http://127.0.0.1:11007' + +#flyway: +# scriptDir: './db/migration-pg' + +#typeorm: +# dataSource: +# default: +# type: postgres +# host: localhost +# port: 5433 +# username: postgres +# password: root +# database: postgres + +typeorm: + dataSource: + default: + database: './data/db-plus-dev.sqlite' + +# plus server: 'http://127.0.0.1:11007' + +account: + server: + baseUrl: 'http://127.0.0.1:1017/subject' diff --git a/packages/ui/certd-server/package.json b/packages/ui/certd-server/package.json index 0ec75646..4e766a67 100644 --- a/packages/ui/certd-server/package.json +++ b/packages/ui/certd-server/package.json @@ -10,6 +10,7 @@ "commdev": "cross-env NODE_ENV=commdev mwtsc --watch --run @midwayjs/mock/app", "commpro": "cross-env NODE_ENV=commpro mwtsc --watch --run @midwayjs/mock/app", "pgdev": "cross-env NODE_ENV=pgdev mwtsc --watch --run @midwayjs/mock/app", + "local-plus": "cross-env NODE_ENV=localplus mwtsc --watch --run @midwayjs/mock/app", "pgpl": "cross-env NODE_ENV=pgpl mwtsc --watch --run @midwayjs/mock/app", "dev-new": "cross-env NODE_ENV=devnew mwtsc --watch --run @midwayjs/mock/app", "rm-db-new": "rimraf ./data/db-new.sqlite",