import { Injectable, Logger } from '@nestjs/common'; import { InjectRepository } from '@nestjs/typeorm'; import { Repository } from 'typeorm'; import { ConfigService } from '@nestjs/config'; import { BaseService } from '@wwjCommon/base/base.service'; import { CacheService } from '@wwjCommon/cache/cache.service'; import { LoggingService } from '@wwjCommon/logging/logging.service'; import { UploadService } from '@wwjVendor/upload/upload.service'; import { PayService } from '@wwjVendor/pay/pay.service'; import { SmsService } from '@wwjVendor/sms/sms.service'; import { NoticeService } from '@wwjVendor/notice/notice.service'; @Injectable() export class NiucloudService extends BaseService { private readonly logger = new Logger(NiucloudService.name); constructor( @InjectRepository(Object) protected readonly repository: Repository, private readonly cacheService: CacheService, private readonly configService: ConfigService, private readonly loggingService: LoggingService, private readonly uploadService: UploadService, private readonly payService: PayService, private readonly smsService: SmsService, private readonly noticeService: NoticeService, ) { super(repository); } /** * setAuthorize * 对应 PHP: NiucloudService_admin::setAuthorize() * 逻辑类型: undefined - undefined */ async setAuthorize(data: any) { // 基于PHP真实逻辑: setAuthorize // PHP原文: $data = [ 'auth_code' => $data['auth_code'], 'auth_secret' => $data['auth_secret'] ]; $service = (new CoreAuth... const data = [ auth_code: data.auth_code, auth_secret: data.auth_secret ]; const service = (new CoreAuthService(data.auth_code, data.auth_secret)]; const auth_info = service.getAuthInfo().data || []; if (!auth_info)) throw new BusinessException('AUTH_NOT_EXISTS']; service.clearAccessToken(]; return this.core_config_service.setConfig(0,ConfigKeyDict.NIUCLOUD_CONFIG, data]; } /** * 获取授权信息 * @return mixed|string[) */ async getAuthorize(){ const info = this.core_config_service.getConfig(0, ConfigKeyDict.NIUCLOUD_CONFIG); if(!info)) { const info = []; info.value = [ auth_code: '', auth_secret: '' ]; } /** * getAuthorize * 对应 PHP: NiucloudService_admin::getAuthorize() * 逻辑类型: undefined - undefined */ async getAuthorize() { // 基于PHP真实逻辑: getAuthorize // PHP原文: $info = $this->core_config_service->getConfig(0, ConfigKeyDict::NIUCLOUD_CONFIG); if(empty($info)) { $info = []; ... const info = this.core_config_service.getConfig(0, ConfigKeyDict.NIUCLOUD_CONFIG); if(!info)) { const info = []; info.value = [ auth_code: '', auth_secret: '' ]; } /** * getFrameworkLastVersion * 对应 PHP: NiucloudService_admin::getFrameworkLastVersion() * 逻辑类型: undefined - undefined */ async getFrameworkLastVersion() { // 基于PHP真实逻辑: getFrameworkLastVersion // PHP原文: return (new CoreModuleService())->getFrameworkLastVersion(); } /** * 获取框架版本更新记录 */ public function getFrameworkVersionList() { ... return this.coreModuleService.getFrameworkLastVersion(]; } /** * 获取框架版本更新记录 */ async getFrameworkVersionList() { return this.coreModuleService.getFrameworkVersionList(]; } /** * 获取应用/插件的版本更新记录 */ async getAppVersionList(app_key) { return this.coreModuleService.getAppVersionList(app_key); } /** * 设置 本地服务器地址 * @param data * @return \app\model\sys\SysConfig|bool|\think\Model */ async setLocalCloudCompileConfig(data){ const data = [ baseUri: data.url, isOpen: data.is_open, ]; return this.core_config_service.setConfig(0,'LOCAL_CLOUD_COMPILE_CONFIG', data); } /** * 获取 本地服务器地址 * @param data * @return \app\model\sys\SysConfig|bool|array|\think\Model */ async getLocalCloudCompileConfig(){ const config = this.core_config_service.getConfig(0,'LOCAL_CLOUD_COMPILE_CONFIG').value || []; return [ baseUri: config.baseUri || '', isOpen: config.isOpen || 0, ; } } /** * getFrameworkVersionList * 对应 PHP: NiucloudService_admin::getFrameworkVersionList() * 逻辑类型: undefined - undefined */ async getFrameworkVersionList() { // 基于PHP真实逻辑: getFrameworkVersionList // PHP原文: return (new CoreModuleService())->getFrameworkVersionList(); } /** * 获取应用/插件的版本更新记录 */ public function getAppVersionList($app_k... return this.coreModuleService.getFrameworkVersionList(]; } /** * 获取应用/插件的版本更新记录 */ async getAppVersionList(app_key) { return this.coreModuleService.getAppVersionList(app_key); } /** * 设置 本地服务器地址 * @param data * @return \app\model\sys\SysConfig|bool|\think\Model */ async setLocalCloudCompileConfig(data){ const data = [ baseUri: data.url, isOpen: data.is_open, ]; return this.core_config_service.setConfig(0,'LOCAL_CLOUD_COMPILE_CONFIG', data); } /** * 获取 本地服务器地址 * @param data * @return \app\model\sys\SysConfig|bool|array|\think\Model */ async getLocalCloudCompileConfig(){ const config = this.core_config_service.getConfig(0,'LOCAL_CLOUD_COMPILE_CONFIG').value || []; return [ baseUri: config.baseUri || '', isOpen: config.isOpen || 0, ; } } /** * getAppVersionList * 对应 PHP: NiucloudService_admin::getAppVersionList() * 逻辑类型: undefined - undefined */ async getAppVersionList(app_key: any) { // 基于PHP真实逻辑: getAppVersionList // PHP原文: return (new CoreModuleService())->getAppVersionList($app_key); } /** * 设置 本地服务器地址 * @param $data * @return \app\model\sys\SysC... return this.coreModuleService.getAppVersionList(app_key); } /** * 设置 本地服务器地址 * @param data * @return \app\model\sys\SysConfig|bool|\think\Model */ async setLocalCloudCompileConfig(data){ const data = [ baseUri: data.url, isOpen: data.is_open, ]; return this.core_config_service.setConfig(0,'LOCAL_CLOUD_COMPILE_CONFIG', data); } /** * 获取 本地服务器地址 * @param data * @return \app\model\sys\SysConfig|bool|array|\think\Model */ async getLocalCloudCompileConfig(){ const config = this.core_config_service.getConfig(0,'LOCAL_CLOUD_COMPILE_CONFIG').value || []; return [ baseUri: config.baseUri || '', isOpen: config.isOpen || 0, ; } } /** * setLocalCloudCompileConfig * 对应 PHP: NiucloudService_admin::setLocalCloudCompileConfig() * 逻辑类型: undefined - undefined */ async setLocalCloudCompileConfig(data: any) { // 基于PHP真实逻辑: setLocalCloudCompileConfig // PHP原文: $data = [ 'baseUri' => $data['url'], 'isOpen' => $data['is_open'], ]; return $this->core_config_service->setCo... const data = [ baseUri: data.url, isOpen: data.is_open, ]; return this.core_config_service.setConfig(0,'LOCAL_CLOUD_COMPILE_CONFIG', data); } /** * 获取 本地服务器地址 * @param data * @return \app\model\sys\SysConfig|bool|array|\think\Model */ async getLocalCloudCompileConfig(){ const config = this.core_config_service.getConfig(0,'LOCAL_CLOUD_COMPILE_CONFIG').value || []; return [ baseUri: config.baseUri || '', isOpen: config.isOpen || 0, ; } } /** * getLocalCloudCompileConfig * 对应 PHP: NiucloudService_admin::getLocalCloudCompileConfig() * 逻辑类型: undefined - undefined */ async getLocalCloudCompileConfig() { // 基于PHP真实逻辑: getLocalCloudCompileConfig // PHP原文: $config = $this->core_config_service->getConfig(0,'LOCAL_CLOUD_COMPILE_CONFIG')['value'] ?? []; return [ 'baseUri' => $config['bas... const config = this.core_config_service.getConfig(0,'LOCAL_CLOUD_COMPILE_CONFIG').value || []; return [ baseUri: config.baseUri || '', isOpen: config.isOpen || 0, ; } } }