mirror of
https://github.com/certd/certd.git
synced 2026-04-23 19:57:27 +08:00
feat: 支持vip转移
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
import { ALL, Body, Controller, Inject, Post, Provide } from '@midwayjs/core';
|
||||
import { SysSettingsService } from '../service/sys-settings-service.js';
|
||||
import { BaseController } from '../../../basic/base-controller.js';
|
||||
import { AppKey, verify } from '@certd/pipeline';
|
||||
import { SysInstallInfo, SysLicenseInfo } from '../service/models.js';
|
||||
import { AppKey } from '@certd/pipeline';
|
||||
import { SysInstallInfo } from '../service/models.js';
|
||||
import { logger } from '../../../utils/logger.js';
|
||||
import { PlusService } from '../../basic/service/plus-service.js';
|
||||
|
||||
@@ -21,10 +21,11 @@ export class SysPlusController extends BaseController {
|
||||
async active(@Body(ALL) body) {
|
||||
const { code } = body;
|
||||
const installInfo: SysInstallInfo = await this.sysSettingsService.getSetting(SysInstallInfo);
|
||||
const siteId = installInfo.siteId;
|
||||
const formData = {
|
||||
appKey: AppKey,
|
||||
code,
|
||||
subjectId: installInfo.siteId,
|
||||
subjectId: siteId,
|
||||
};
|
||||
|
||||
const res: any = await this.plusService.active(formData);
|
||||
@@ -33,26 +34,10 @@ export class SysPlusController extends BaseController {
|
||||
logger.error('激活失败', res.message);
|
||||
return this.fail(res.message, 1);
|
||||
}
|
||||
|
||||
const license = res.data.license;
|
||||
|
||||
let licenseInfo: SysLicenseInfo = await this.sysSettingsService.getSetting(SysLicenseInfo);
|
||||
if (!licenseInfo) {
|
||||
licenseInfo = new SysLicenseInfo();
|
||||
}
|
||||
licenseInfo.license = license;
|
||||
await this.sysSettingsService.saveSetting(licenseInfo);
|
||||
await this.plusService.updateLicense(siteId, license);
|
||||
|
||||
const verifyRes = await verify({
|
||||
subjectId: installInfo.siteId,
|
||||
license,
|
||||
});
|
||||
|
||||
if (!verifyRes.isPlus) {
|
||||
const message = verifyRes.message || '授权码校验失败';
|
||||
logger.error(message);
|
||||
return this.fail(message, 1);
|
||||
}
|
||||
return this.ok(res.data);
|
||||
return this.ok(true);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user