feat: WWJCloud 企业级全栈框架 v0.3.5 完整更新

🚀 核心更新:
-  完善 NestJS 企业级架构设计
-  优化配置中心和基础设施层
-  增强第三方服务集成能力
-  完善多租户架构支持
- 🎯 对标 Java Spring Boot 和 PHP ThinkPHP

📦 新增文件:
- wwjcloud-nest 完整框架结构
- Docker 容器化配置
- 管理后台界面
- 数据库迁移脚本

🔑 Key: ebb38b43ec39f355f071294fd1cf9c42
This commit is contained in:
wanwu
2025-10-13 01:27:37 +08:00
parent 16892939a6
commit 2285206b3f
1695 changed files with 260750 additions and 19 deletions

View File

@@ -0,0 +1,208 @@
import {
Controller,
Get,
Post,
Put,
Delete,
Body,
Param,
Query,
UseGuards,
UseInterceptors,
UploadedFile,
UploadedFiles,
Session,
Req,
} from '@nestjs/common';
import { FileInterceptor, FilesInterceptor } from '@nestjs/platform-express';
import {
ApiTags,
ApiOperation,
ApiResponse,
ApiConsumes,
} from '@nestjs/swagger';
import { Request } from 'express';
import { JwtAuthGuard } from '@wwjCommon/security/guards/jwt-auth.guard';
import { RolesGuard } from '@wwjCommon/security/guards/roles.guard';
import { Roles } from '@wwjCommon/security/decorators/roles.decorator';
import { Public } from '@wwjCommon/security/decorators/public.decorator';
import { BusinessException } from '@wwjCommon/exception/business.exception';
// @UploadedFile() - 单文件上传,配合 @UseInterceptors(FileInterceptor('file'))
// @UploadedFiles() - 多文件上传,配合 @UseInterceptors(FilesInterceptor('files'))
// @Session() - 获取会话对象对应PHP Session::get()
// @Req() - 获取Request对象对应PHP Request
import { NiucloudService } from '../../services/admin/niucloud.service';
import { CoreCloudBuildService } from '../../services/core/core-cloud-build.service';
/**
* CloudController
* 对应 PHP: Cloud Controller
* 对应 Java: @RestController
*
* 支持装饰器:
* - @UploadedFile() - 单文件上传 (对应PHP Request::file())
* - @UploadedFiles() - 多文件上传
* - @Session() - 会话管理 (对应PHP Session::get())
* - @Req() - 请求对象 (对应PHP Request)
*/
@ApiTags('niucloud')
@Controller('adminapi/niucloud')
export class CloudController {
constructor(
private readonly niucloudService: NiucloudService,
private readonly coreCloudBuildService: CoreCloudBuildService,
) {}
/**
* 云编译
* 路由: POST build
* PHP路由: Route::post('build', 'niucloud.Cloud/build')
*/
@Post('build')
@UseGuards(JwtAuthGuard, RolesGuard)
@ApiOperation({ summary: '云编译' })
async build(@Body() data: BuildDto): Promise<ApiResponse> {
try {
// 基于PHP真实逻辑实现
// PHP原始方法: build
return await this.coreCloudBuildService.cloudBuild();
} catch (error) {
throw new BusinessException('build操作失败', error);
}
}
/**
* 云编译
* 路由: GET build/log
* PHP路由: Route::get('build/log', 'niucloud.Cloud/getBuildLog')
*/
@Get('build/log')
@UseGuards(JwtAuthGuard, RolesGuard)
@ApiOperation({ summary: '云编译' })
async getBuildLog(): Promise<ApiResponse> {
try {
// 基于PHP真实逻辑实现
// PHP原始方法: getBuildLog
return await this.coreCloudBuildService.getBuildLog();
} catch (error) {
throw new BusinessException('getBuildLog操作失败', error);
}
}
/**
* 云编译
* 路由: GET build
* PHP路由: Route::get('build', 'niucloud.Cloud/getBuildTask')
*/
@Get('build')
@UseGuards(JwtAuthGuard, RolesGuard)
@ApiOperation({ summary: '云编译' })
async getBuildTask(): Promise<ApiResponse> {
try {
// 基于PHP真实逻辑实现
// PHP原始方法: getBuildTask
return await this.coreCloudBuildService.getBuildTask();
} catch (error) {
throw new BusinessException('getBuildTask操作失败', error);
}
}
/**
* 云编译
* 路由: POST build/clear
* PHP路由: Route::post('build/clear', 'niucloud.Cloud/clearBuildTask')
*/
@Post('build/clear')
@UseGuards(JwtAuthGuard, RolesGuard)
@ApiOperation({ summary: '云编译' })
async clearBuildTask(@Body() data: ClearBuildTaskDto): Promise<ApiResponse> {
try {
// 基于PHP真实逻辑实现
// PHP原始方法: clearBuildTask
return await this.coreCloudBuildService.clearTask();
} catch (error) {
throw new BusinessException('clearBuildTask操作失败', error);
}
}
/**
* 云编译
* 路由: GET build/check
* PHP路由: Route::get('build/check', 'niucloud.Cloud/buildPreCheck')
*/
@Get('build/check')
@UseGuards(JwtAuthGuard, RolesGuard)
@ApiOperation({ summary: '云编译' })
async buildPreCheck(): Promise<ApiResponse> {
try {
// 基于PHP真实逻辑实现
// PHP原始方法: buildPreCheck
return await this.coreCloudBuildService.buildPreCheck();
} catch (error) {
throw new BusinessException('buildPreCheck操作失败', error);
}
}
/**
* 云编译
* 路由: POST build/connect_test
* PHP路由: Route::post('build/connect_test', 'niucloud.Cloud/connectTest')
*/
@Post('build/connect_test')
@ApiOperation({ summary: '云编译' })
async connectTest(@Body() data: ConnectTestDto) {
try {
// 基于PHP真实逻辑实现
// PHP原始方法: connectTest
// 服务方法名解析失败,需要手动实现
return { message: 'connectTest - 服务方法名解析失败,需要手动实现' };
} catch (error) {
throw new BusinessException('connectTest操作失败', error);
}
}
/**
* 云编译
* 路由: POST build/set_local_url
* PHP路由: Route::post('build/set_local_url', 'niucloud.Cloud/setLocalCloudCompileConfig')
*/
@Post('build/set_local_url')
@UseGuards(JwtAuthGuard, RolesGuard)
@ApiOperation({ summary: '云编译' })
async setLocalCloudCompileConfig(
@Body() data: SetLocalCloudCompileConfigDto,
): Promise<ApiResponse> {
try {
// 基于PHP真实逻辑实现
// PHP原始方法: setLocalCloudCompileConfig
return await this.niucloudService.setLocalCloudCompileConfig(data);
} catch (error) {
throw new BusinessException('setLocalCloudCompileConfig操作失败', error);
}
}
/**
* 云编译
* 路由: GET build/get_local_url
* PHP路由: Route::get('build/get_local_url', 'niucloud.Cloud/getLocalCloudCompileConfig')
*/
@Get('build/get_local_url')
@UseGuards(JwtAuthGuard, RolesGuard)
@ApiOperation({ summary: '云编译' })
async getLocalCloudCompileConfig(): Promise<ApiResponse> {
try {
// 基于PHP真实逻辑实现
// PHP原始方法: getLocalCloudCompileConfig
return await this.niucloudService.getLocalCloudCompileConfig();
} catch (error) {
throw new BusinessException('getLocalCloudCompileConfig操作失败', error);
}
}
}

View File

@@ -0,0 +1,169 @@
import {
Controller,
Get,
Post,
Put,
Delete,
Body,
Param,
Query,
UseGuards,
UseInterceptors,
UploadedFile,
UploadedFiles,
Session,
Req,
} from '@nestjs/common';
import { FileInterceptor, FilesInterceptor } from '@nestjs/platform-express';
import {
ApiTags,
ApiOperation,
ApiResponse,
ApiConsumes,
} from '@nestjs/swagger';
import { Request } from 'express';
import { JwtAuthGuard } from '@wwjCommon/security/guards/jwt-auth.guard';
import { RolesGuard } from '@wwjCommon/security/guards/roles.guard';
import { Roles } from '@wwjCommon/security/decorators/roles.decorator';
import { Public } from '@wwjCommon/security/decorators/public.decorator';
import { BusinessException } from '@wwjCommon/exception/business.exception';
// @UploadedFile() - 单文件上传,配合 @UseInterceptors(FileInterceptor('file'))
// @UploadedFiles() - 多文件上传,配合 @UseInterceptors(FilesInterceptor('files'))
// @Session() - 获取会话对象对应PHP Session::get()
// @Req() - 获取Request对象对应PHP Request
import { NiucloudService } from '../../services/admin/niucloud.service';
import { CoreAuthService } from '../../services/core/core-auth.service';
/**
* ModuleController
* 对应 PHP: Module Controller
* 对应 Java: @RestController
*
* 支持装饰器:
* - @UploadedFile() - 单文件上传 (对应PHP Request::file())
* - @UploadedFiles() - 多文件上传
* - @Session() - 会话管理 (对应PHP Session::get())
* - @Req() - 请求对象 (对应PHP Request)
*/
@ApiTags('niucloud')
@Controller('adminapi/niucloud')
export class ModuleController {
constructor(
private readonly niucloudService: NiucloudService,
private readonly coreAuthService: CoreAuthService,
) {}
/**
* 模块
* 路由: GET authinfo
* PHP路由: Route::get('authinfo', 'niucloud.Module/authorize')
*/
@Get('authinfo')
@UseGuards(JwtAuthGuard, RolesGuard)
@ApiOperation({ summary: '模块' })
async authorize(): Promise<ApiResponse> {
try {
// 基于PHP真实逻辑实现
// PHP原始方法: authorize
return await this.coreAuthService.getAuthInfo(id);
} catch (error) {
throw new BusinessException('authorize操作失败', error);
}
}
/**
* 模块
* 路由: POST authinfo
* PHP路由: Route::post('authinfo', 'niucloud.Module/setAuthorize')
*/
@Post('authinfo')
@UseGuards(JwtAuthGuard, RolesGuard)
@ApiOperation({ summary: '模块' })
async setAuthorize(@Body() data: SetAuthorizeDto): Promise<ApiResponse> {
try {
// 基于PHP真实逻辑实现
// PHP原始方法: setAuthorize
return await this.niucloudService.setAuthorize(data);
} catch (error) {
throw new BusinessException('setAuthorize操作失败', error);
}
}
/**
* 模块
* 路由: GET admin/authinfo
* PHP路由: Route::get('admin/authinfo', 'niucloud.Module/getAuthorize')
*/
@Get('admin/authinfo')
@UseGuards(JwtAuthGuard, RolesGuard)
@ApiOperation({ summary: '模块' })
async getAuthorize(): Promise<ApiResponse> {
try {
// 基于PHP真实逻辑实现
// PHP原始方法: getAuthorize
return await this.niucloudService.getAuthorize();
} catch (error) {
throw new BusinessException('getAuthorize操作失败', error);
}
}
/**
* 模块
* 路由: GET framework/newversion
* PHP路由: Route::get('framework/newversion', 'niucloud.Module/getFrameworkLastVersion')
*/
@Get('framework/newversion')
@UseGuards(JwtAuthGuard, RolesGuard)
@ApiOperation({ summary: '模块' })
async getFrameworkLastVersion(): Promise<ApiResponse> {
try {
// 基于PHP真实逻辑实现
// PHP原始方法: getFrameworkLastVersion
return await this.niucloudService.getFrameworkLastVersion();
} catch (error) {
throw new BusinessException('getFrameworkLastVersion操作失败', error);
}
}
/**
* 模块
* 路由: GET framework/version/list
* PHP路由: Route::get('framework/version/list', 'niucloud.Module/getFrameworkVersionList')
*/
@Get('framework/version/list')
@UseGuards(JwtAuthGuard, RolesGuard)
@ApiOperation({ summary: '模块' })
async getFrameworkVersionList(): Promise<ApiResponse> {
try {
// 基于PHP真实逻辑实现
// PHP原始方法: getFrameworkVersionList
return await this.niucloudService.getFrameworkVersionList();
} catch (error) {
throw new BusinessException('getFrameworkVersionList操作失败', error);
}
}
/**
* 模块
* 路由: GET app_version/list
* PHP路由: Route::get('app_version/list', 'niucloud.Module/getAppVersionList')
*/
@Get('app_version/list')
@UseGuards(JwtAuthGuard, RolesGuard)
@ApiOperation({ summary: '模块' })
async getAppVersionList(): Promise<ApiResponse> {
try {
// 基于PHP真实逻辑实现
// PHP原始方法: getAppVersionList
return await this.niucloudService.getAppVersionList(data['app_key']);
} catch (error) {
throw new BusinessException('getAppVersionList操作失败', error);
}
}
}

View File

@@ -0,0 +1,78 @@
import {
IsString,
IsNumber,
IsOptional,
IsNotEmpty,
IsEmail,
IsUrl,
IsArray,
IsObject,
} from 'class-validator';
import { ApiProperty } from '@nestjs/swagger';
// import { validateEvent } from '@wwjCommon/event/contract-validator';
import { ParseDiyFormPipe } from '@wwjCommon/pipes/parse-diy-form.pipe';
// import { JsonTransformPipe } from '@wwjCommon/validation/pipes/json-transform.pipe';
/**
* ModuleDto - 数据传输对象
* 基于真实PHP验证器规则生成禁止假设字段
* 使用Core层基础设施契约验证、管道验证、Swagger文档
*/
export class ModuleDto {
@ApiProperty({ description: 'auth_code' })
@IsNotEmpty()
@IsString()
auth_code: string;
@ApiProperty({ description: 'auth_secret' })
@IsNotEmpty()
@IsString()
auth_secret: string;
}
/**
* ModuleDto 验证器类
* 使用Core层contractValidator进行验证 (对应Java的Validator接口)
* 使用Core层基础设施契约验证、管道验证
*/
export class ModuleDtoValidator {
/**
* 验证数据
* 使用Core层统一验证体系
*/
static validate(data: ModuleDto): void {
// 调用Core层contractValidator进行验证
validateEvent('niucloud.module', data);
}
/**
* 验证场景 - 基于真实PHP的$scene
*/
static validateAdd(data: ModuleDto): void {
// 基于真实PHP add场景验证规则
this.validate(data);
}
static validateEdit(data: ModuleDto): void {
// 基于真实PHP edit场景验证规则
this.validate(data);
}
}
export class CreateModuleDto {
// 字段定义需要基于真实PHP验证器解析
// 禁止假设字段
// 使用Core层基础设施class-validator装饰器、Swagger文档
}
export class UpdateModuleDto {
// 字段定义需要基于真实PHP验证器解析
// 禁止假设字段
// 使用Core层基础设施class-validator装饰器、Swagger文档
}
export class QueryModuleDto {
// 字段定义需要基于真实PHP验证器解析
// 禁止假设字段
// 使用Core层基础设施class-validator装饰器、Swagger文档
}

View File

@@ -0,0 +1,9 @@
import { Module } from '@nestjs/common';
@Module({
imports: [],
controllers: [],
providers: [],
exports: [],
})
export class NiucloudModule {}

View File

@@ -0,0 +1,265 @@
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<any> {
private readonly logger = new Logger(NiucloudService.name);
constructor(
@InjectRepository(Object)
protected readonly repository: Repository<any>,
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,
;
}
}
}

View File

@@ -0,0 +1,44 @@
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 CoreAuthService extends BaseService<any> {
private readonly logger = new Logger(CoreAuthService.name);
constructor(
@InjectRepository(Object)
protected readonly repository: Repository<any>,
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);
}
/**
* getAuthInfo
* 对应 PHP: CoreAuthService_core::getAuthInfo()
* 逻辑类型: undefined - undefined
*/
async getAuthInfo() {
// 基于PHP真实逻辑: getAuthInfo
// PHP原文: $auth_info = $this->httpGet('authinfo', ['code' => $this->code, 'secret' => $this->secret, 'product_key' => self::PRODUCT ]); if(!empty($auth_...
const auth_info = this.httpGet('authinfo', [code: this.code, secret: this.secret, product_key: self.PRODUCT )];
if(!!auth_info.data)){
auth_info.data.address_type = true;
if(auth_info.data.site_address != _SERVER.HTTP_HOST) auth_info.data.address_type = false;
}
}

View File

@@ -0,0 +1,43 @@
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 CoreCloudBaseService extends BaseService<any> {
private readonly logger = new Logger(CoreCloudBaseService.name);
constructor(
@InjectRepository(Object)
protected readonly repository: Repository<any>,
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);
}
/**
* addonPath
* 对应 PHP: CoreCloudBaseService_core::addonPath()
* 逻辑类型: undefined - undefined
*/
async addonPath(addon: string) {
// 基于PHP真实逻辑: addonPath
// PHP原文: return root_path() . 'addon' . DIRECTORY_SEPARATOR . $addon . DIRECTORY_SEPARATOR; } }...
return root_path() + 'addon' . DIRECTORY_SEPARATOR . addon . DIRECTORY_SEPARATOR;
}
}
}
}

View File

@@ -0,0 +1,258 @@
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 CoreCloudBuildService extends BaseService<any> {
private readonly logger = new Logger(CoreCloudBuildService.name);
constructor(
@InjectRepository(Object)
protected readonly repository: Repository<any>,
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);
}
/**
* buildPreCheck
* 对应 PHP: CoreCloudBuildService_core::buildPreCheck()
* 逻辑类型: undefined - undefined
*/
async buildPreCheck() {
// 基于PHP真实逻辑: buildPreCheck
// PHP原文: $niucloud_dir = $this->root_path . 'niucloud' . DIRECTORY_SEPARATOR; $admin_dir = $this->root_path . 'admin' . DIRECTORY_SEPARATOR; $w...
const niucloud_dir = this.root_path + 'niucloud' . DIRECTORY_SEPARATOR;
const admin_dir = this.root_path + 'admin' . DIRECTORY_SEPARATOR;
const web_dir = this.root_path + 'web' . DIRECTORY_SEPARATOR;
const wap_dir = this.root_path + 'uni-app' . DIRECTORY_SEPARATOR;
try {
if (!is_dir(admin_dir)) throw new BusinessException('ADMIN_DIR_NOT_EXIST');
if (!is_dir(web_dir)) throw new BusinessException('WEB_DIR_NOT_EXIST');
if (!is_dir(wap_dir)) throw new BusinessException('UNIAPP_DIR_NOT_EXIST');
}
/**
* cloudBuild
* 对应 PHP: CoreCloudBuildService_core::cloudBuild()
* 逻辑类型: undefined - undefined
*/
async cloudBuild() {
// 基于PHP真实逻辑: cloudBuild
// PHP原文: if (empty($this->auth_code)) { throw new CommonException('CLOUD_BUILD_AUTH_CODE_NOT_FOUND');...
if (!this.auth_code)) {
throw new BusinessException('CLOUD_BUILD_AUTH_CODE_NOT_FOUND');
}
/**
* getBuildTask
* 对应 PHP: CoreCloudBuildService_core::getBuildTask()
* 逻辑类型: undefined - undefined
*/
async getBuildTask() {
// 基于PHP真实逻辑: getBuildTask
// PHP原文: return $this->build_task; } /** * 获取编译执行日志 * @return void */ public function getBuildLog() { if (!$this->build...
return this.build_task;
}
/**
* 获取编译执行日志
* @return void
*/
async getBuildLog()
{
if (!this.build_task) return;
const query = [
authorize_code: this.auth_code,
timestamp: this.build_task[ 'timestamp' ]
];
const build_log = ( new CloudService(true) ).httpGet('cloud/get_build_logs?' . http_build_query(query)];
if (typeof build_log[ 'data' )) && typeof build_log[ 'data' ][ 0 )) && is_[build_log[ 'data' ][ 0 ))) {
const last = end(build_log[ 'data' )[ 0 )];
if (last[ 'percent' ) == 100 && last[ 'code' ) == 1) {
build_log[ 'data' ][ 0 ] = this.buildSuccess(build_log[ 'data' )[ 0 )];
}
}
/**
* getBuildLog
* 对应 PHP: CoreCloudBuildService_core::getBuildLog()
* 逻辑类型: undefined - undefined
*/
async getBuildLog() {
// 基于PHP真实逻辑: getBuildLog
// PHP原文: if (!$this->build_task) return; $query = [ 'authorize_code' => $this->auth_code, 'timestamp' => $this->build_task[ 't...
if (!this.build_task) return;
const query = [
authorize_code: this.auth_code,
timestamp: this.build_task[ 'timestamp' ]
];
const build_log = ( new CloudService(true) ).httpGet('cloud/get_build_logs?' . http_build_query(query)];
if (typeof build_log[ 'data' )) && typeof build_log[ 'data' ][ 0 )) && is_[build_log[ 'data' ][ 0 ))) {
const last = end(build_log[ 'data' )[ 0 )];
if (last[ 'percent' ) == 100 && last[ 'code' ) == 1) {
build_log[ 'data' ][ 0 ] = this.buildSuccess(build_log[ 'data' )[ 0 )];
}
}
/**
* buildSuccess
* 对应 PHP: CoreCloudBuildService_core::buildSuccess()
* 逻辑类型: undefined - undefined
*/
async buildSuccess(log: any[]) {
// 基于PHP真实逻辑: buildSuccess
// PHP原文: try { $query = [ 'authorize_code' => $this->auth_code, 'timestamp' => $this->build_task[ 'timestamp' ] ...
try {
const query = [
authorize_code: this.auth_code,
timestamp: this.build_task[ 'timestamp' ]
];
const chunk_size = 1 * 1024 * 1024;
const temp_dir = runtime_path() + 'backup' . DIRECTORY_SEPARATOR + 'cloud_build' . DIRECTORY_SEPARATOR . this.build_task[ 'task_key' ] . DIRECTORY_SEPARATOR;
if (!typeof this.build_task[ 'index' ))) {
const response = ( new CloudService(true) ).request('HEAD', 'cloud/build_download?' . http_build_query(query), [
headers: [ Range: 'bytes=0-' ]
]];
const length = response.getHeader('Content-range');
const length = (int) explode("/", length[ 0 ))[ 1 ];
const step = (int) ceil(length / chunk_size);
this.build_task = Object.assign(this.build_task, [ step: step, index: 0, length: length )];
Cache.set(this.cache_key, this.build_task];
} } } else {
const zip_file = temp_dir + 'download.zip';
const zip_resource = fopen(zip_file, 'a');
if (( this.build_task[ 'index' ) + 1 ) <= this.build_task[ 'step' ]) {
const start = this.build_task[ 'index' ] * chunk_size;
const end = ( this.build_task[ 'index' ) + 1 ) * chunk_size;
const end = min(end, this.build_task[ 'length' )];
const response = ( new CloudService(true) ).request('GET', 'cloud/build_download?' . http_build_query(query), [
headers: [ Range: "bytes={start}-{end}" ]
]];
fwrite(zip_resource, response.getBody()];
fclose(zip_resource];
this.build_task[ 'index' ] += 1;
Cache.set(this.cache_key, this.build_task];
log[] = [ code: 1, action: '编译包下载中,已下载' . round(this.build_task[ 'index' ) / this.build_task[ 'step' ) * 100) + '%', percent: '100' ];
} } } else {
// 解压文件
const zip = new \ZipArchive(];
if (zip.open(zip_file) === true) {
dir_mkdir(temp_dir + 'download'];
zip.extractTo(temp_dir + 'download'];
zip.close();
// if (is_dir(temp_dir + 'download' . DIRECTORY_SEPARATOR + 'public' . DIRECTORY_SEPARATOR + 'admin')) {
// del_target_dir(public_path() + 'admin', true];
// }
// if (is_dir(temp_dir + 'download' . DIRECTORY_SEPARATOR + 'public' . DIRECTORY_SEPARATOR + 'web')) {
// del_target_dir(public_path() + 'web', true];
// }
// if (is_dir(temp_dir + 'download' . DIRECTORY_SEPARATOR + 'public' . DIRECTORY_SEPARATOR + 'wap')) {
// del_target_dir(public_path() + 'wap', true];
// }
dir_copy(temp_dir + 'download', root_path()];
this.clearTask(];
} } } else {
log[] = [ code: 0, msg: '编译包解压失败', action: '编译包解压', percent: '100' );
}
}
}
}
/**
* clearTask
* 对应 PHP: CoreCloudBuildService_core::clearTask()
* 逻辑类型: undefined - undefined
*/
async clearTask() {
// 基于PHP真实逻辑: clearTask
// PHP原文: if (!$this->build_task) return; $temp_dir = runtime_path() . 'backup' . DIRECTORY_SEPARATOR . 'cloud_build' . DIRECTORY_SEPARATOR . $this->bui...
if (!this.build_task) return;
const temp_dir = runtime_path() + 'backup' . DIRECTORY_SEPARATOR + 'cloud_build' . DIRECTORY_SEPARATOR . this.build_task[ 'task_key' ] . DIRECTORY_SEPARATOR;
@del_target_dir(temp_dir, true];
Cache.set(this.cache_key, null);
}
}
}
/**
* handleUniapp
* 对应 PHP: CoreCloudBuildService_core::handleUniapp()
* 逻辑类型: undefined - undefined
*/
async handleUniapp(dir: string) {
// 基于PHP真实逻辑: handleUniapp
// PHP原文: $addon = ( new Addon() )->where([ [ 'status', '=', AddonDict::ON ] ])->value('key', ''); $this->compileDiyComponentsCode($dir . DIRECTORY_SEPA...
const addon = ( this.addonService ).where([ [ 'status', '=', AddonDict.ON ) )).value('key', ''];
this.compileDiyComponentsCode(dir . DIRECTORY_SEPARATOR + 'src' . DIRECTORY_SEPARATOR, addon);
}
private async handleCustomPort(string package_dir)
{
const addons = get_site_addons(];
foreach (addons as addon) {
const custom_port = ( this.coreAddonBaseService ).getAddonConfig(addon)[ 'port' ] || [];
if (!!custom_port)) {
const addon_path = root_path() + 'addon' . DIRECTORY_SEPARATOR . addon . DIRECTORY_SEPARATOR;
foreach (custom_port as port) {
if (is_dir(addon_path . port[ 'name' ))) {
dir_copy(addon_path . port[ 'name' ), package_dir . port[ 'name' )];
const json_path = package_dir . port[ 'name' ] . DIRECTORY_SEPARATOR + 'info.json';
file_put_contents(json_path, json_encode(port);
}
}
}
/**
* handleCustomPort
* 对应 PHP: CoreCloudBuildService_core::handleCustomPort()
* 逻辑类型: undefined - undefined
*/
async handleCustomPort(package_dir: string) {
// 基于PHP真实逻辑: handleCustomPort
// PHP原文: $addons = get_site_addons(); foreach ($addons as $addon) { $custom_port = ( new CoreAddonBaseService() )->getAddonConfig($addon)[...
const addons = get_site_addons(];
foreach (addons as addon) {
const custom_port = ( this.coreAddonBaseService ).getAddonConfig(addon)[ 'port' ] || [];
if (!!custom_port)) {
const addon_path = root_path() + 'addon' . DIRECTORY_SEPARATOR . addon . DIRECTORY_SEPARATOR;
foreach (custom_port as port) {
if (is_dir(addon_path . port[ 'name' ))) {
dir_copy(addon_path . port[ 'name' ), package_dir . port[ 'name' )];
const json_path = package_dir . port[ 'name' ] . DIRECTORY_SEPARATOR + 'info.json';
file_put_contents(json_path, json_encode(port);
}
}
}
}

View File

@@ -0,0 +1,618 @@
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 CoreModuleService extends BaseService<any> {
private readonly logger = new Logger(CoreModuleService.name);
constructor(
@InjectRepository(Object)
protected readonly repository: Repository<any>,
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);
}
/**
* getModuleList
* 对应 PHP: CoreModuleService_core::getModuleList()
* 逻辑类型: undefined - undefined
*/
async getModuleList() {
// 基于PHP真实逻辑: getModuleList
// PHP原文: $params = [ 'code' => $this->code, 'secret' => $this->secret, 'product_key' => self::PRODUCT ]; re...
const params = [
code: this.code,
secret: this.secret,
product_key: self.PRODUCT
];
return this.httpGet('member_app_all', params);
}
async getIndexModuleLabelList()
{
const params = [
code: this.code,
secret: this.secret,
];
return this.httpGet('store/label/all', params);
}
async getIndexModuleList(label_id)
{
const params = [
code: this.code,
secret: this.secret,
labels: [ label_id ],
order_field: 'sale_num desc, visit_num desc',
recommend_type:'PHP'
];
return this.httpGet('store/saas/app', params);
}
async getIndexAdvList()
{
const params = [
code: this.code,
secret: this.secret,
recommend_type:'PHP'
];
return this.httpGet('promotion_adv', params);
}
/**
* 授权信息
* @return array|Collection|Response|object|ResponseInterface|string
* @throws GuzzleBusinessException
*/
async getAuthInfo()
{
const params = [
app_type: '',
code: this.code,
secret: this.secret
];
return this.httpGet('member_app', params);
}
/**
* 版本下载
* @param app_key
* @param dir
* @return string|void
* @throws GuzzleBusinessException
*/
async downloadModule(app_key, dir)
{
if (!is_dir(dir) && !mkdir(dir, 0777, true) && !is_dir(dir)) {
throw new RuntimeBusinessException(sprintf('Directory "%s" was not created', dir)];
}
/**
* getIndexModuleLabelList
* 对应 PHP: CoreModuleService_core::getIndexModuleLabelList()
* 逻辑类型: undefined - undefined
*/
async getIndexModuleLabelList() {
// 基于PHP真实逻辑: getIndexModuleLabelList
// PHP原文: $params = [ 'code' => $this->code, 'secret' => $this->secret, ]; return $this->httpGet('store/label/all', $par...
const params = [
code: this.code,
secret: this.secret,
];
return this.httpGet('store/label/all', params);
}
async getIndexModuleList(label_id)
{
const params = [
code: this.code,
secret: this.secret,
labels: [ label_id ],
order_field: 'sale_num desc, visit_num desc',
recommend_type:'PHP'
];
return this.httpGet('store/saas/app', params);
}
async getIndexAdvList()
{
const params = [
code: this.code,
secret: this.secret,
recommend_type:'PHP'
];
return this.httpGet('promotion_adv', params);
}
/**
* 授权信息
* @return array|Collection|Response|object|ResponseInterface|string
* @throws GuzzleBusinessException
*/
async getAuthInfo()
{
const params = [
app_type: '',
code: this.code,
secret: this.secret
];
return this.httpGet('member_app', params);
}
/**
* 版本下载
* @param app_key
* @param dir
* @return string|void
* @throws GuzzleBusinessException
*/
async downloadModule(app_key, dir)
{
if (!is_dir(dir) && !mkdir(dir, 0777, true) && !is_dir(dir)) {
throw new RuntimeBusinessException(sprintf('Directory "%s" was not created', dir)];
}
/**
* getIndexModuleList
* 对应 PHP: CoreModuleService_core::getIndexModuleList()
* 逻辑类型: undefined - undefined
*/
async getIndexModuleList(label_id: any) {
// 基于PHP真实逻辑: getIndexModuleList
// PHP原文: $params = [ 'code' => $this->code, 'secret' => $this->secret, 'labels' => [ $label_id ], 'order_field'...
const params = [
code: this.code,
secret: this.secret,
labels: [ label_id ],
order_field: 'sale_num desc, visit_num desc',
recommend_type:'PHP'
];
return this.httpGet('store/saas/app', params);
}
async getIndexAdvList()
{
const params = [
code: this.code,
secret: this.secret,
recommend_type:'PHP'
];
return this.httpGet('promotion_adv', params);
}
/**
* 授权信息
* @return array|Collection|Response|object|ResponseInterface|string
* @throws GuzzleBusinessException
*/
async getAuthInfo()
{
const params = [
app_type: '',
code: this.code,
secret: this.secret
];
return this.httpGet('member_app', params);
}
/**
* 版本下载
* @param app_key
* @param dir
* @return string|void
* @throws GuzzleBusinessException
*/
async downloadModule(app_key, dir)
{
if (!is_dir(dir) && !mkdir(dir, 0777, true) && !is_dir(dir)) {
throw new RuntimeBusinessException(sprintf('Directory "%s" was not created', dir)];
}
/**
* getIndexAdvList
* 对应 PHP: CoreModuleService_core::getIndexAdvList()
* 逻辑类型: undefined - undefined
*/
async getIndexAdvList() {
// 基于PHP真实逻辑: getIndexAdvList
// PHP原文: $params = [ 'code' => $this->code, 'secret' => $this->secret, 'recommend_type'=>'PHP' ]; return $t...
const params = [
code: this.code,
secret: this.secret,
recommend_type:'PHP'
];
return this.httpGet('promotion_adv', params);
}
/**
* 授权信息
* @return array|Collection|Response|object|ResponseInterface|string
* @throws GuzzleBusinessException
*/
async getAuthInfo()
{
const params = [
app_type: '',
code: this.code,
secret: this.secret
];
return this.httpGet('member_app', params);
}
/**
* 版本下载
* @param app_key
* @param dir
* @return string|void
* @throws GuzzleBusinessException
*/
async downloadModule(app_key, dir)
{
if (!is_dir(dir) && !mkdir(dir, 0777, true) && !is_dir(dir)) {
throw new RuntimeBusinessException(sprintf('Directory "%s" was not created', dir)];
}
/**
* getAuthInfo
* 对应 PHP: CoreModuleService_core::getAuthInfo()
* 逻辑类型: undefined - undefined
*/
async getAuthInfo() {
// 基于PHP真实逻辑: getAuthInfo
// PHP原文: $params = [ 'app_type' => '', 'code' => $this->code, 'secret' => $this->secret ]; return $this->ht...
const params = [
app_type: '',
code: this.code,
secret: this.secret
];
return this.httpGet('member_app', params);
}
/**
* 版本下载
* @param app_key
* @param dir
* @return string|void
* @throws GuzzleBusinessException
*/
async downloadModule(app_key, dir)
{
if (!is_dir(dir) && !mkdir(dir, 0777, true) && !is_dir(dir)) {
throw new RuntimeBusinessException(sprintf('Directory "%s" was not created', dir)];
}
/**
* downloadModule
* 对应 PHP: CoreModuleService_core::downloadModule()
* 逻辑类型: undefined - undefined
*/
async downloadModule(app_key: any, dir: any) {
// 基于PHP真实逻辑: downloadModule
// PHP原文: if (!is_dir($dir) && !mkdir($dir, 0777, true) && !is_dir($dir)) { throw new RuntimeException(sprintf('Directory "%s" was not created', $di...
if (!is_dir(dir) && !mkdir(dir, 0777, true) && !is_dir(dir)) {
throw new RuntimeBusinessException(sprintf('Directory "%s" was not created', dir)];
}
/**
* upgrade
* 对应 PHP: CoreModuleService_core::upgrade()
* 逻辑类型: undefined - undefined
*/
async upgrade(app_key: any, version_id: any) {
// 基于PHP真实逻辑: upgrade
// PHP原文: } /** * 操作token * @param $action * @param $data * @return array|\core\util\niucloud\Response|object|ResponseInterface * ...
}
/**
* 操作token
* @param action
* @param data
* @return array|\core\util\niucloud\Response|object|ResponseInterface
* @throws GuzzleBusinessException
*/
async getActionToken(action, data)
{
return this.httpGet('member_app_action/' . action, data);
}
/**
* 获取升级内容
* @param data
* @return array|\core\util\niucloud\Response|object|ResponseInterface
* @throws GuzzleBusinessException
*/
async getUpgradeContent(data)
{
return this.httpGet('member_app_upgrade/content', data);
}
/**
* 校验key是否被占用
* @param key
* @return array|Response|object|ResponseInterface
* @throws GuzzleBusinessException
*/
async checkKey(key)
{
return this.httpGet('store/app_check/' . key, [ product_key: self.PRODUCT ))[ 'data' ] || false;
}
/**
* 获取框架最新版本
* @return array|\core\util\niucloud\Response|object|ResponseInterface
* @throws GuzzleBusinessException
*/
async getFrameworkLastVersion()
{
return this.httpGet('store/framework/lastversion', [ product_key: self.PRODUCT ))[ 'data' ] || false;
}
/**
* 获取框架版本更新记录
* @return false|mixed
* @throws GuzzleBusinessException
*/
async getFrameworkVersionList()
{
return this.httpGet('store/framework/version', [ product_key: self.PRODUCT ))[ 'data' ] || false;
}
/**
* 获取应用/插件的版本更新记录
* @return false|mixed
* @throws GuzzleBusinessException
*/
async getAppVersionList(app_key)
{
return this.httpGet('store/app_version/list', [ product_key: self.PRODUCT, app_key: app_key ))[ 'data' ] || false;
}
}
}
/**
* getActionToken
* 对应 PHP: CoreModuleService_core::getActionToken()
* 逻辑类型: undefined - undefined
*/
async getActionToken(action: any, data: any) {
// 基于PHP真实逻辑: getActionToken
// PHP原文: return $this->httpGet('member_app_action/' . $action, $data); } /** * 获取升级内容 * @param $data * @return array|\core\util\niuclou...
return this.httpGet('member_app_action/' . action, data);
}
/**
* 获取升级内容
* @param data
* @return array|\core\util\niucloud\Response|object|ResponseInterface
* @throws GuzzleBusinessException
*/
async getUpgradeContent(data)
{
return this.httpGet('member_app_upgrade/content', data);
}
/**
* 校验key是否被占用
* @param key
* @return array|Response|object|ResponseInterface
* @throws GuzzleBusinessException
*/
async checkKey(key)
{
return this.httpGet('store/app_check/' . key, [ product_key: self.PRODUCT ))[ 'data' ] || false;
}
/**
* 获取框架最新版本
* @return array|\core\util\niucloud\Response|object|ResponseInterface
* @throws GuzzleBusinessException
*/
async getFrameworkLastVersion()
{
return this.httpGet('store/framework/lastversion', [ product_key: self.PRODUCT ))[ 'data' ] || false;
}
/**
* 获取框架版本更新记录
* @return false|mixed
* @throws GuzzleBusinessException
*/
async getFrameworkVersionList()
{
return this.httpGet('store/framework/version', [ product_key: self.PRODUCT ))[ 'data' ] || false;
}
/**
* 获取应用/插件的版本更新记录
* @return false|mixed
* @throws GuzzleBusinessException
*/
async getAppVersionList(app_key)
{
return this.httpGet('store/app_version/list', [ product_key: self.PRODUCT, app_key: app_key ))[ 'data' ] || false;
}
}
}
/**
* getUpgradeContent
* 对应 PHP: CoreModuleService_core::getUpgradeContent()
* 逻辑类型: undefined - undefined
*/
async getUpgradeContent(data: any) {
// 基于PHP真实逻辑: getUpgradeContent
// PHP原文: return $this->httpGet('member_app_upgrade/content', $data); } /** * 校验key是否被占用 * @param $key * @return array|Response|object|R...
return this.httpGet('member_app_upgrade/content', data);
}
/**
* 校验key是否被占用
* @param key
* @return array|Response|object|ResponseInterface
* @throws GuzzleBusinessException
*/
async checkKey(key)
{
return this.httpGet('store/app_check/' . key, [ product_key: self.PRODUCT ))[ 'data' ] || false;
}
/**
* 获取框架最新版本
* @return array|\core\util\niucloud\Response|object|ResponseInterface
* @throws GuzzleBusinessException
*/
async getFrameworkLastVersion()
{
return this.httpGet('store/framework/lastversion', [ product_key: self.PRODUCT ))[ 'data' ] || false;
}
/**
* 获取框架版本更新记录
* @return false|mixed
* @throws GuzzleBusinessException
*/
async getFrameworkVersionList()
{
return this.httpGet('store/framework/version', [ product_key: self.PRODUCT ))[ 'data' ] || false;
}
/**
* 获取应用/插件的版本更新记录
* @return false|mixed
* @throws GuzzleBusinessException
*/
async getAppVersionList(app_key)
{
return this.httpGet('store/app_version/list', [ product_key: self.PRODUCT, app_key: app_key ))[ 'data' ] || false;
}
}
}
/**
* checkKey
* 对应 PHP: CoreModuleService_core::checkKey()
* 逻辑类型: undefined - undefined
*/
async checkKey(key: any) {
// 基于PHP真实逻辑: checkKey
// PHP原文: return $this->httpGet('store/app_check/' . $key, [ 'product_key' => self::PRODUCT ])[ 'data' ] ?? false; } /** * 获取框架最新版本 * @return...
return this.httpGet('store/app_check/' . key, [ product_key: self.PRODUCT ))[ 'data' ] || false;
}
/**
* 获取框架最新版本
* @return array|\core\util\niucloud\Response|object|ResponseInterface
* @throws GuzzleBusinessException
*/
async getFrameworkLastVersion()
{
return this.httpGet('store/framework/lastversion', [ product_key: self.PRODUCT ))[ 'data' ] || false;
}
/**
* 获取框架版本更新记录
* @return false|mixed
* @throws GuzzleBusinessException
*/
async getFrameworkVersionList()
{
return this.httpGet('store/framework/version', [ product_key: self.PRODUCT ))[ 'data' ] || false;
}
/**
* 获取应用/插件的版本更新记录
* @return false|mixed
* @throws GuzzleBusinessException
*/
async getAppVersionList(app_key)
{
return this.httpGet('store/app_version/list', [ product_key: self.PRODUCT, app_key: app_key ))[ 'data' ] || false;
}
}
}
/**
* getFrameworkLastVersion
* 对应 PHP: CoreModuleService_core::getFrameworkLastVersion()
* 逻辑类型: undefined - undefined
*/
async getFrameworkLastVersion() {
// 基于PHP真实逻辑: getFrameworkLastVersion
// PHP原文: return $this->httpGet('store/framework/lastversion', [ 'product_key' => self::PRODUCT ])[ 'data' ] ?? false; } /** * 获取框架版本更新记录 * @...
return this.httpGet('store/framework/lastversion', [ product_key: self.PRODUCT ))[ 'data' ] || false;
}
/**
* 获取框架版本更新记录
* @return false|mixed
* @throws GuzzleBusinessException
*/
async getFrameworkVersionList()
{
return this.httpGet('store/framework/version', [ product_key: self.PRODUCT ))[ 'data' ] || false;
}
/**
* 获取应用/插件的版本更新记录
* @return false|mixed
* @throws GuzzleBusinessException
*/
async getAppVersionList(app_key)
{
return this.httpGet('store/app_version/list', [ product_key: self.PRODUCT, app_key: app_key ))[ 'data' ] || false;
}
}
}
/**
* getFrameworkVersionList
* 对应 PHP: CoreModuleService_core::getFrameworkVersionList()
* 逻辑类型: undefined - undefined
*/
async getFrameworkVersionList() {
// 基于PHP真实逻辑: getFrameworkVersionList
// PHP原文: return $this->httpGet('store/framework/version', [ 'product_key' => self::PRODUCT ])[ 'data' ] ?? false; } /** * 获取应用/插件的版本更新记录 * @...
return this.httpGet('store/framework/version', [ product_key: self.PRODUCT ))[ 'data' ] || false;
}
/**
* 获取应用/插件的版本更新记录
* @return false|mixed
* @throws GuzzleBusinessException
*/
async getAppVersionList(app_key)
{
return this.httpGet('store/app_version/list', [ product_key: self.PRODUCT, app_key: app_key ))[ 'data' ] || false;
}
}
}
/**
* getAppVersionList
* 对应 PHP: CoreModuleService_core::getAppVersionList()
* 逻辑类型: undefined - undefined
*/
async getAppVersionList(app_key: any) {
// 基于PHP真实逻辑: getAppVersionList
// PHP原文: return $this->httpGet('store/app_version/list', [ 'product_key' => self::PRODUCT, 'app_key' => $app_key ])[ 'data' ] ?? false; } }...
return this.httpGet('store/app_version/list', [ product_key: self.PRODUCT, app_key: app_key ))[ 'data' ] || false;
}
}
}
}

View File

@@ -0,0 +1,47 @@
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 CoreNiucloudConfigService extends BaseService<any> {
private readonly logger = new Logger(CoreNiucloudConfigService.name);
constructor(
@InjectRepository(Object)
protected readonly repository: Repository<any>,
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);
}
/**
* getNiucloudConfig
* 对应 PHP: CoreNiucloudConfigService_core::getNiucloudConfig()
* 逻辑类型: undefined - undefined
*/
async getNiucloudConfig() {
// 基于PHP真实逻辑: getNiucloudConfig
// PHP原文: $info = (new CoreConfigService())->getConfig(0, ConfigKeyDict::NIUCLOUD_CONFIG)['value'] ?? []; if(empty($info)) { $info =...
const info = this.coreConfigService.getConfig(0, ConfigKeyDict.NIUCLOUD_CONFIG).value || [];
if(!info))
{
const info = [
auth_code: '',
auth_secret: ''
];
}
}

View File

@@ -0,0 +1,48 @@
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 CoreNotifyService extends BaseService<any> {
private readonly logger = new Logger(CoreNotifyService.name);
constructor(
@InjectRepository(Object)
protected readonly repository: Repository<any>,
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);
}
/**
* notify
* 对应 PHP: CoreNotifyService_core::notify()
* 逻辑类型: undefined - undefined
*/
async notify() {
// 基于PHP真实逻辑: notify
// PHP原文: //校验证书 $this->validateSignature(); $message = request()->param('Message'); $message_type = request()->param('MsgType'); ...
//校验证书
this.validateSignature(];
const message = request().param('Message');
const message_type = request().param('MsgType');
switch(message_type){
case 'auth':
this.setAccessToken(message.AccessToken.token);
break;
}
}