feat: 增强Service Generator和Converter
✅ Service Generator: - 自动分析方法体,识别需要的imports - 按需导入NestJS异常(BadRequestException等) - 按需导入Node.js模块(fs, path) - 按需导入Boot服务(ConfigService等) - 自动注入ConfigService到构造函数 ✅ Service Method Converter: - 新增FileUtils工具类转换 - 新增异常处理转换(catch、getMessage) - 新增.getPath()方法转换 🎯 效果: - Service文件自动包含所需imports - ConfigService自动注入 - 减少编译错误
This commit is contained in:
@@ -135,11 +135,20 @@ class ServiceMethodConverter {
|
|||||||
// 【文件操作】Java File API → Node.js fs/path
|
// 【文件操作】Java File API → Node.js fs/path
|
||||||
// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
||||||
|
|
||||||
|
// FileUtils工具类
|
||||||
|
tsBody = tsBody.replace(/FileUtils\.cleanDirectory\(([^)]+)\)/g, 'fs.rmSync($1, { recursive: true, force: true })');
|
||||||
|
tsBody = tsBody.replace(/FileUtils\.copyFile\(([^,]+),\s*([^)]+)\)/g, 'fs.copyFileSync($1, $2)');
|
||||||
|
tsBody = tsBody.replace(/FileUtils\.deleteDirectory\(([^)]+)\)/g, 'fs.rmSync($1, { recursive: true, force: true })');
|
||||||
|
tsBody = tsBody.replace(/FileUtils\.readFileToString\(([^)]+)\)/g, 'fs.readFileSync($1, \'utf-8\')');
|
||||||
|
tsBody = tsBody.replace(/FileUtils\.writeStringToFile\(([^,]+),\s*([^)]+)\)/g, 'fs.writeFileSync($1, $2, \'utf-8\')');
|
||||||
|
|
||||||
|
// File API
|
||||||
tsBody = tsBody.replace(/new\s+File\(([^)]+)\)/g, '$1');
|
tsBody = tsBody.replace(/new\s+File\(([^)]+)\)/g, '$1');
|
||||||
tsBody = tsBody.replace(/(\w+)\.exists\(\)/g, 'fs.existsSync($1)');
|
tsBody = tsBody.replace(/(\w+)\.exists\(\)/g, 'fs.existsSync($1)');
|
||||||
tsBody = tsBody.replace(/(\w+)\.isDirectory\(\)/g, 'fs.lstatSync($1).isDirectory()');
|
tsBody = tsBody.replace(/(\w+)\.isDirectory\(\)/g, 'fs.lstatSync($1).isDirectory()');
|
||||||
tsBody = tsBody.replace(/(\w+)\.getName\(\)/g, 'path.basename($1)');
|
tsBody = tsBody.replace(/(\w+)\.getName\(\)/g, 'path.basename($1)');
|
||||||
tsBody = tsBody.replace(/(\w+)\.listFiles\(\)/g, 'fs.readdirSync($1)');
|
tsBody = tsBody.replace(/(\w+)\.listFiles\(\)/g, 'fs.readdirSync($1)');
|
||||||
|
tsBody = tsBody.replace(/(\w+)\.getPath\(\)/g, '$1');
|
||||||
|
|
||||||
// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
||||||
// 【字符串方法】
|
// 【字符串方法】
|
||||||
@@ -174,6 +183,13 @@ class ServiceMethodConverter {
|
|||||||
// 【异常处理】
|
// 【异常处理】
|
||||||
// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
||||||
|
|
||||||
|
// try-catch语句:catch (Exception e) → catch (error)
|
||||||
|
tsBody = tsBody.replace(/catch\s*\(\s*(?:Exception|RuntimeException|Throwable)\s+(\w+)\s*\)/g, 'catch ($1)');
|
||||||
|
|
||||||
|
// 异常方法调用:e.getMessage() → e.message
|
||||||
|
tsBody = tsBody.replace(/(\w+)\.getMessage\(\)/g, '$1.message');
|
||||||
|
|
||||||
|
// 异常抛出
|
||||||
tsBody = tsBody.replace(/throw\s+new\s+CommonException\(/g, 'throw new BadRequestException(');
|
tsBody = tsBody.replace(/throw\s+new\s+CommonException\(/g, 'throw new BadRequestException(');
|
||||||
tsBody = tsBody.replace(/throw\s+new\s+AuthException\(/g, 'throw new UnauthorizedException(');
|
tsBody = tsBody.replace(/throw\s+new\s+AuthException\(/g, 'throw new UnauthorizedException(');
|
||||||
tsBody = tsBody.replace(/throw\s+new\s+RuntimeException\(/g, 'throw new Error(');
|
tsBody = tsBody.replace(/throw\s+new\s+RuntimeException\(/g, 'throw new Error(');
|
||||||
|
|||||||
@@ -140,13 +140,20 @@ class ServiceGenerator {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 生成服务内容
|
* 生成服务内容
|
||||||
|
*
|
||||||
|
* ✅ 增强:自动分析方法体,添加需要的imports
|
||||||
*/
|
*/
|
||||||
generateServiceContent(javaService, serviceName) {
|
generateServiceContent(javaService, serviceName) {
|
||||||
const imports = this.generateImports(javaService);
|
// 先生成方法,以便分析需要哪些imports
|
||||||
const decorators = this.generateDecorators();
|
|
||||||
const constructor = this.generateConstructor(javaService);
|
|
||||||
const methods = this.generateMethods(javaService);
|
const methods = this.generateMethods(javaService);
|
||||||
|
|
||||||
|
// 分析方法体,获取需要的imports
|
||||||
|
const additionalImports = this.analyzeAdditionalImports(methods);
|
||||||
|
|
||||||
|
const imports = this.generateImports(javaService, additionalImports);
|
||||||
|
const decorators = this.generateDecorators();
|
||||||
|
const constructor = this.generateConstructor(javaService, additionalImports);
|
||||||
|
|
||||||
return `${imports}
|
return `${imports}
|
||||||
|
|
||||||
${decorators}
|
${decorators}
|
||||||
@@ -158,17 +165,92 @@ ${methods}
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 生成导入语句
|
* 分析方法体,识别需要的额外imports
|
||||||
*/
|
*/
|
||||||
generateImports(javaService) {
|
analyzeAdditionalImports(methodsCode) {
|
||||||
|
const imports = {
|
||||||
|
nestjs: new Set(),
|
||||||
|
nodeModules: new Set(),
|
||||||
|
boot: new Set()
|
||||||
|
};
|
||||||
|
|
||||||
|
// NestJS异常
|
||||||
|
if (methodsCode.includes('BadRequestException')) {
|
||||||
|
imports.nestjs.add('BadRequestException');
|
||||||
|
}
|
||||||
|
if (methodsCode.includes('UnauthorizedException')) {
|
||||||
|
imports.nestjs.add('UnauthorizedException');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Node.js模块
|
||||||
|
if (methodsCode.includes('fs.')) {
|
||||||
|
imports.nodeModules.add('fs');
|
||||||
|
}
|
||||||
|
if (methodsCode.includes('path.')) {
|
||||||
|
imports.nodeModules.add('path');
|
||||||
|
}
|
||||||
|
|
||||||
|
// ConfigService
|
||||||
|
if (methodsCode.includes('this.config.')) {
|
||||||
|
imports.boot.add('ConfigService');
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
nestjs: Array.from(imports.nestjs),
|
||||||
|
nodeModules: Array.from(imports.nodeModules),
|
||||||
|
boot: Array.from(imports.boot)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生成导入语句
|
||||||
|
*
|
||||||
|
* ✅ 增强:接收额外的imports(NestJS异常、Node.js模块、Boot服务)
|
||||||
|
*/
|
||||||
|
generateImports(javaService, additionalImports = {}) {
|
||||||
const imports = [
|
const imports = [
|
||||||
"import { Injectable } from '@nestjs/common';",
|
"import { Injectable } from '@nestjs/common';"
|
||||||
"import { InjectRepository } from '@nestjs/typeorm';",
|
|
||||||
"import { Repository } from 'typeorm';",
|
|
||||||
"import { QueueService, EventBus } from '@wwjBoot';",
|
|
||||||
"import { Result } from '@wwjBoot';"
|
|
||||||
];
|
];
|
||||||
|
|
||||||
|
// ✅ NestJS异常(按需导入)
|
||||||
|
const nestjsImports = ['Injectable'];
|
||||||
|
if (additionalImports.nestjs && additionalImports.nestjs.length > 0) {
|
||||||
|
additionalImports.nestjs.forEach(item => {
|
||||||
|
if (!nestjsImports.includes(item)) {
|
||||||
|
nestjsImports.push(item);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (nestjsImports.length > 1) {
|
||||||
|
imports[0] = `import { ${nestjsImports.join(', ')} } from '@nestjs/common';`;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TypeORM
|
||||||
|
imports.push("import { InjectRepository } from '@nestjs/typeorm';");
|
||||||
|
imports.push("import { Repository } from 'typeorm';");
|
||||||
|
|
||||||
|
// ✅ Boot层(按需导入)
|
||||||
|
const bootImports = ['QueueService', 'EventBus', 'Result'];
|
||||||
|
if (additionalImports.boot && additionalImports.boot.length > 0) {
|
||||||
|
additionalImports.boot.forEach(item => {
|
||||||
|
if (!bootImports.includes(item)) {
|
||||||
|
bootImports.push(item);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
imports.push(`import { ${bootImports.join(', ')} } from '@wwjBoot';`);
|
||||||
|
|
||||||
|
// ✅ Node.js模块(按需导入)
|
||||||
|
if (additionalImports.nodeModules && additionalImports.nodeModules.length > 0) {
|
||||||
|
additionalImports.nodeModules.forEach(module => {
|
||||||
|
if (module === 'fs') {
|
||||||
|
imports.push(`import * as fs from 'fs';`);
|
||||||
|
} else if (module === 'path') {
|
||||||
|
imports.push(`import * as path from 'path';`);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// 计算到entities目录的相对路径
|
// 计算到entities目录的相对路径
|
||||||
const entityRelativePath = this.calculateEntityPath(javaService.filePath);
|
const entityRelativePath = this.calculateEntityPath(javaService.filePath);
|
||||||
|
|
||||||
@@ -229,10 +311,17 @@ ${methods}
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 生成构造函数
|
* 生成构造函数
|
||||||
|
*
|
||||||
|
* ✅ 增强:根据additionalImports注入ConfigService
|
||||||
*/
|
*/
|
||||||
generateConstructor(javaService) {
|
generateConstructor(javaService, additionalImports = {}) {
|
||||||
const injections = [];
|
const injections = [];
|
||||||
|
|
||||||
|
// ✅ 添加ConfigService注入(如果需要)
|
||||||
|
if (additionalImports.boot && additionalImports.boot.includes('ConfigService')) {
|
||||||
|
injections.push(' private readonly config: ConfigService,');
|
||||||
|
}
|
||||||
|
|
||||||
// 添加框架服务注入
|
// 添加框架服务注入
|
||||||
injections.push(' private readonly eventBus: EventBus,');
|
injections.push(' private readonly eventBus: EventBus,');
|
||||||
injections.push(' private readonly queueService: QueueService,');
|
injections.push(' private readonly queueService: QueueService,');
|
||||||
|
|||||||
@@ -89,58 +89,4 @@ export class EventMediatorContextListener {
|
|||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* ClassPathScanningCandidateComponentProvider
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
// @ts-ignore - TypeScript装饰器类型推断问题
|
|
||||||
@OnEvent('default.event')
|
|
||||||
async classPathScanningCandidateComponentProvider(event: any): Promise<void> {
|
|
||||||
this.logger.log('收到事件: ClassPathScanningCandidateComponentProvider', event);
|
|
||||||
|
|
||||||
try {
|
|
||||||
// 验证事件数据
|
|
||||||
if (!event || !event.data) {
|
|
||||||
this.logger.warn('事件数据为空,跳过处理');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 处理事件业务逻辑
|
|
||||||
const eventId = event.data.id;
|
|
||||||
this.logger.debug(`处理事件,ID: ${eventId}`);
|
|
||||||
|
|
||||||
this.logger.log('事件处理完成: ClassPathScanningCandidateComponentProvider');
|
|
||||||
} catch (error) {
|
|
||||||
this.logger.error('事件处理失败: ClassPathScanningCandidateComponentProvider', error.stack);
|
|
||||||
throw error;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* isCandidateComponent
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
// @ts-ignore - TypeScript装饰器类型推断问题
|
|
||||||
@OnEvent('default.event')
|
|
||||||
async isCandidateComponent(event: any): Promise<void> {
|
|
||||||
this.logger.log('收到事件: isCandidateComponent', event);
|
|
||||||
|
|
||||||
try {
|
|
||||||
// 验证事件数据
|
|
||||||
if (!event || !event.data) {
|
|
||||||
this.logger.warn('事件数据为空,跳过处理');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 处理事件业务逻辑
|
|
||||||
const eventId = event.data.id;
|
|
||||||
this.logger.debug(`处理事件,ID: ${eventId}`);
|
|
||||||
|
|
||||||
this.logger.log('事件处理完成: isCandidateComponent');
|
|
||||||
} catch (error) {
|
|
||||||
this.logger.error('事件处理失败: isCandidateComponent', error.stack);
|
|
||||||
throw error;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,6 +36,33 @@ export class MethodCallStackAspectListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* aroundMethod
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
// @ts-ignore - TypeScript装饰器类型推断问题
|
||||||
|
@OnEvent('default.event')
|
||||||
|
async aroundMethod(event: any): Promise<void> {
|
||||||
|
this.logger.log('收到事件: aroundMethod', event);
|
||||||
|
|
||||||
|
try {
|
||||||
|
// 验证事件数据
|
||||||
|
if (!event || !event.data) {
|
||||||
|
this.logger.warn('事件数据为空,跳过处理');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 处理事件业务逻辑
|
||||||
|
const eventId = event.data.id;
|
||||||
|
this.logger.debug(`处理事件,ID: ${eventId}`);
|
||||||
|
|
||||||
|
this.logger.log('事件处理完成: aroundMethod');
|
||||||
|
} catch (error) {
|
||||||
|
this.logger.error('事件处理失败: aroundMethod', error.stack);
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* serviceMethods
|
* serviceMethods
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -35,4 +35,58 @@ export class QuartzConfigListener {
|
|||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* createJobInstance
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
// @ts-ignore - TypeScript装饰器类型推断问题
|
||||||
|
@OnEvent('default.event')
|
||||||
|
async createJobInstance(event: any): Promise<void> {
|
||||||
|
this.logger.log('收到事件: createJobInstance', event);
|
||||||
|
|
||||||
|
try {
|
||||||
|
// 验证事件数据
|
||||||
|
if (!event || !event.data) {
|
||||||
|
this.logger.warn('事件数据为空,跳过处理');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 处理事件业务逻辑
|
||||||
|
const eventId = event.data.id;
|
||||||
|
this.logger.debug(`处理事件,ID: ${eventId}`);
|
||||||
|
|
||||||
|
this.logger.log('事件处理完成: createJobInstance');
|
||||||
|
} catch (error) {
|
||||||
|
this.logger.error('事件处理失败: createJobInstance', error.stack);
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* scheduler
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
// @ts-ignore - TypeScript装饰器类型推断问题
|
||||||
|
@OnEvent('default.event')
|
||||||
|
async scheduler(event: any): Promise<void> {
|
||||||
|
this.logger.log('收到事件: scheduler', event);
|
||||||
|
|
||||||
|
try {
|
||||||
|
// 验证事件数据
|
||||||
|
if (!event || !event.data) {
|
||||||
|
this.logger.warn('事件数据为空,跳过处理');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 处理事件业务逻辑
|
||||||
|
const eventId = event.data.id;
|
||||||
|
this.logger.debug(`处理事件,ID: ${eventId}`);
|
||||||
|
|
||||||
|
this.logger.log('事件处理完成: scheduler');
|
||||||
|
} catch (error) {
|
||||||
|
this.logger.error('事件处理失败: scheduler', error.stack);
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -845,85 +845,4 @@ export class RequestUtilsListener {
|
|||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* getRequestMethod
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
// @ts-ignore - TypeScript装饰器类型推断问题
|
|
||||||
@OnEvent('default.event')
|
|
||||||
async getRequestMethod(event: any): Promise<void> {
|
|
||||||
this.logger.log('收到事件: getRequestMethod', event);
|
|
||||||
|
|
||||||
try {
|
|
||||||
// 验证事件数据
|
|
||||||
if (!event || !event.data) {
|
|
||||||
this.logger.warn('事件数据为空,跳过处理');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 处理事件业务逻辑
|
|
||||||
const eventId = event.data.id;
|
|
||||||
this.logger.debug(`处理事件,ID: ${eventId}`);
|
|
||||||
|
|
||||||
this.logger.log('事件处理完成: getRequestMethod');
|
|
||||||
} catch (error) {
|
|
||||||
this.logger.error('事件处理失败: getRequestMethod', error.stack);
|
|
||||||
throw error;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* handler
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
// @ts-ignore - TypeScript装饰器类型推断问题
|
|
||||||
@OnEvent('default.event')
|
|
||||||
async handler(event: any): Promise<void> {
|
|
||||||
this.logger.log('收到事件: handler', event);
|
|
||||||
|
|
||||||
try {
|
|
||||||
// 验证事件数据
|
|
||||||
if (!event || !event.data) {
|
|
||||||
this.logger.warn('事件数据为空,跳过处理');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 处理事件业务逻辑
|
|
||||||
const eventId = event.data.id;
|
|
||||||
this.logger.debug(`处理事件,ID: ${eventId}`);
|
|
||||||
|
|
||||||
this.logger.log('事件处理完成: handler');
|
|
||||||
} catch (error) {
|
|
||||||
this.logger.error('事件处理失败: handler', error.stack);
|
|
||||||
throw error;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* getDomain
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
// @ts-ignore - TypeScript装饰器类型推断问题
|
|
||||||
@OnEvent('default.event')
|
|
||||||
async getDomain(event: any): Promise<void> {
|
|
||||||
this.logger.log('收到事件: getDomain', event);
|
|
||||||
|
|
||||||
try {
|
|
||||||
// 验证事件数据
|
|
||||||
if (!event || !event.data) {
|
|
||||||
this.logger.warn('事件数据为空,跳过处理');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 处理事件业务逻辑
|
|
||||||
const eventId = event.data.id;
|
|
||||||
this.logger.debug(`处理事件,ID: ${eventId}`);
|
|
||||||
|
|
||||||
this.logger.log('事件处理完成: getDomain');
|
|
||||||
} catch (error) {
|
|
||||||
this.logger.error('事件处理失败: getDomain', error.stack);
|
|
||||||
throw error;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,5 +9,30 @@ export class SaTokenAdminInterceptorListener {
|
|||||||
constructor(
|
constructor(
|
||||||
private readonly eventBus: EventBus
|
private readonly eventBus: EventBus
|
||||||
) {}
|
) {}
|
||||||
// 无方法
|
/**
|
||||||
|
* preHandle
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
// @ts-ignore - TypeScript装饰器类型推断问题
|
||||||
|
@OnEvent('default.event')
|
||||||
|
async preHandle(event: any): Promise<void> {
|
||||||
|
this.logger.log('收到事件: preHandle', event);
|
||||||
|
|
||||||
|
try {
|
||||||
|
// 验证事件数据
|
||||||
|
if (!event || !event.data) {
|
||||||
|
this.logger.warn('事件数据为空,跳过处理');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 处理事件业务逻辑
|
||||||
|
const eventId = event.data.id;
|
||||||
|
this.logger.debug(`处理事件,ID: ${eventId}`);
|
||||||
|
|
||||||
|
this.logger.log('事件处理完成: preHandle');
|
||||||
|
} catch (error) {
|
||||||
|
this.logger.error('事件处理失败: preHandle', error.stack);
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,5 +9,30 @@ export class SaTokenApiInterceptorListener {
|
|||||||
constructor(
|
constructor(
|
||||||
private readonly eventBus: EventBus
|
private readonly eventBus: EventBus
|
||||||
) {}
|
) {}
|
||||||
// 无方法
|
/**
|
||||||
|
* preHandle
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
// @ts-ignore - TypeScript装饰器类型推断问题
|
||||||
|
@OnEvent('default.event')
|
||||||
|
async preHandle(event: any): Promise<void> {
|
||||||
|
this.logger.log('收到事件: preHandle', event);
|
||||||
|
|
||||||
|
try {
|
||||||
|
// 验证事件数据
|
||||||
|
if (!event || !event.data) {
|
||||||
|
this.logger.warn('事件数据为空,跳过处理');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 处理事件业务逻辑
|
||||||
|
const eventId = event.data.id;
|
||||||
|
this.logger.debug(`处理事件,ID: ${eventId}`);
|
||||||
|
|
||||||
|
this.logger.log('事件处理完成: preHandle');
|
||||||
|
} catch (error) {
|
||||||
|
this.logger.error('事件处理失败: preHandle', error.stack);
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,5 +9,30 @@ export class SaTokenInterceptorListener {
|
|||||||
constructor(
|
constructor(
|
||||||
private readonly eventBus: EventBus
|
private readonly eventBus: EventBus
|
||||||
) {}
|
) {}
|
||||||
// 无方法
|
/**
|
||||||
|
* preHandle
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
// @ts-ignore - TypeScript装饰器类型推断问题
|
||||||
|
@OnEvent('default.event')
|
||||||
|
async preHandle(event: any): Promise<void> {
|
||||||
|
this.logger.log('收到事件: preHandle', event);
|
||||||
|
|
||||||
|
try {
|
||||||
|
// 验证事件数据
|
||||||
|
if (!event || !event.data) {
|
||||||
|
this.logger.warn('事件数据为空,跳过处理');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 处理事件业务逻辑
|
||||||
|
const eventId = event.data.id;
|
||||||
|
this.logger.debug(`处理事件,ID: ${eventId}`);
|
||||||
|
|
||||||
|
this.logger.log('事件处理完成: preHandle');
|
||||||
|
} catch (error) {
|
||||||
|
this.logger.error('事件处理失败: preHandle', error.stack);
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -197,139 +197,4 @@ export class ShowMarketingEnumListener {
|
|||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* parseJsonArrayToCategory
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
// @ts-ignore - TypeScript装饰器类型推断问题
|
|
||||||
@OnEvent('default.event')
|
|
||||||
async parseJsonArrayToCategory(event: any): Promise<void> {
|
|
||||||
this.logger.log('收到事件: parseJsonArrayToCategory', event);
|
|
||||||
|
|
||||||
try {
|
|
||||||
// 验证事件数据
|
|
||||||
if (!event || !event.data) {
|
|
||||||
this.logger.warn('事件数据为空,跳过处理');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 处理事件业务逻辑
|
|
||||||
const eventId = event.data.id;
|
|
||||||
this.logger.debug(`处理事件,ID: ${eventId}`);
|
|
||||||
|
|
||||||
this.logger.log('事件处理完成: parseJsonArrayToCategory');
|
|
||||||
} catch (error) {
|
|
||||||
this.logger.error('事件处理失败: parseJsonArrayToCategory', error.stack);
|
|
||||||
throw error;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* parseMarketingToolsFromModules
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
// @ts-ignore - TypeScript装饰器类型推断问题
|
|
||||||
@OnEvent('default.event')
|
|
||||||
async parseMarketingToolsFromModules(event: any): Promise<void> {
|
|
||||||
this.logger.log('收到事件: parseMarketingToolsFromModules', event);
|
|
||||||
|
|
||||||
try {
|
|
||||||
// 验证事件数据
|
|
||||||
if (!event || !event.data) {
|
|
||||||
this.logger.warn('事件数据为空,跳过处理');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 处理事件业务逻辑
|
|
||||||
const eventId = event.data.id;
|
|
||||||
this.logger.debug(`处理事件,ID: ${eventId}`);
|
|
||||||
|
|
||||||
this.logger.log('事件处理完成: parseMarketingToolsFromModules');
|
|
||||||
} catch (error) {
|
|
||||||
this.logger.error('事件处理失败: parseMarketingToolsFromModules', error.stack);
|
|
||||||
throw error;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* parseMarketingJson
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
// @ts-ignore - TypeScript装饰器类型推断问题
|
|
||||||
@OnEvent('default.event')
|
|
||||||
async parseMarketingJson(event: any): Promise<void> {
|
|
||||||
this.logger.log('收到事件: parseMarketingJson', event);
|
|
||||||
|
|
||||||
try {
|
|
||||||
// 验证事件数据
|
|
||||||
if (!event || !event.data) {
|
|
||||||
this.logger.warn('事件数据为空,跳过处理');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 处理事件业务逻辑
|
|
||||||
const eventId = event.data.id;
|
|
||||||
this.logger.debug(`处理事件,ID: ${eventId}`);
|
|
||||||
|
|
||||||
this.logger.log('事件处理完成: parseMarketingJson');
|
|
||||||
} catch (error) {
|
|
||||||
this.logger.error('事件处理失败: parseMarketingJson', error.stack);
|
|
||||||
throw error;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* createShowMarketingVo
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
// @ts-ignore - TypeScript装饰器类型推断问题
|
|
||||||
@OnEvent('default.event')
|
|
||||||
async createShowMarketingVo(event: any): Promise<void> {
|
|
||||||
this.logger.log('收到事件: createShowMarketingVo', event);
|
|
||||||
|
|
||||||
try {
|
|
||||||
// 验证事件数据
|
|
||||||
if (!event || !event.data) {
|
|
||||||
this.logger.warn('事件数据为空,跳过处理');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 处理事件业务逻辑
|
|
||||||
const eventId = event.data.id;
|
|
||||||
this.logger.debug(`处理事件,ID: ${eventId}`);
|
|
||||||
|
|
||||||
this.logger.log('事件处理完成: createShowMarketingVo');
|
|
||||||
} catch (error) {
|
|
||||||
this.logger.error('事件处理失败: createShowMarketingVo', error.stack);
|
|
||||||
throw error;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* getSiteAddonModules
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
// @ts-ignore - TypeScript装饰器类型推断问题
|
|
||||||
@OnEvent('site.addAfter')
|
|
||||||
async getSiteAddonModules(event: any): Promise<void> {
|
|
||||||
this.logger.log('收到事件: getSiteAddonModules', event);
|
|
||||||
|
|
||||||
try {
|
|
||||||
// 验证事件数据
|
|
||||||
if (!event || !event.data) {
|
|
||||||
this.logger.warn('事件数据为空,跳过处理');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 处理事件业务逻辑
|
|
||||||
const eventId = event.data.id;
|
|
||||||
this.logger.debug(`处理事件,ID: ${eventId}`);
|
|
||||||
|
|
||||||
this.logger.log('事件处理完成: getSiteAddonModules');
|
|
||||||
} catch (error) {
|
|
||||||
this.logger.error('事件处理失败: getSiteAddonModules', error.stack);
|
|
||||||
throw error;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,5 +9,30 @@ export class SystemRestartListenerListener {
|
|||||||
constructor(
|
constructor(
|
||||||
private readonly eventBus: EventBus
|
private readonly eventBus: EventBus
|
||||||
) {}
|
) {}
|
||||||
// 无方法
|
/**
|
||||||
|
* init
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
// @ts-ignore - TypeScript装饰器类型推断问题
|
||||||
|
@OnEvent('default.event')
|
||||||
|
async init(event: any): Promise<void> {
|
||||||
|
this.logger.log('收到事件: init', event);
|
||||||
|
|
||||||
|
try {
|
||||||
|
// 验证事件数据
|
||||||
|
if (!event || !event.data) {
|
||||||
|
this.logger.warn('事件数据为空,跳过处理');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 处理事件业务逻辑
|
||||||
|
const eventId = event.data.id;
|
||||||
|
this.logger.debug(`处理事件,ID: ${eventId}`);
|
||||||
|
|
||||||
|
this.logger.log('事件处理完成: init');
|
||||||
|
} catch (error) {
|
||||||
|
this.logger.error('事件处理失败: init', error.stack);
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,5 +9,30 @@ export class TestListenerListener {
|
|||||||
constructor(
|
constructor(
|
||||||
private readonly eventBus: EventBus
|
private readonly eventBus: EventBus
|
||||||
) {}
|
) {}
|
||||||
// 无方法
|
/**
|
||||||
|
* handleEvent
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
// @ts-ignore - TypeScript装饰器类型推断问题
|
||||||
|
@OnEvent('test')
|
||||||
|
async handleEvent(event: any): Promise<void> {
|
||||||
|
this.logger.log('收到事件: handleEvent', event);
|
||||||
|
|
||||||
|
try {
|
||||||
|
// 验证事件数据
|
||||||
|
if (!event || !event.data) {
|
||||||
|
this.logger.warn('事件数据为空,跳过处理');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 处理事件业务逻辑
|
||||||
|
const eventId = event.data.id;
|
||||||
|
this.logger.debug(`处理事件,ID: ${eventId}`);
|
||||||
|
|
||||||
|
this.logger.log('事件处理完成: handleEvent');
|
||||||
|
} catch (error) {
|
||||||
|
this.logger.error('事件处理失败: handleEvent', error.stack);
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -567,6 +567,33 @@ export class WechatpayListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* getRequestBody
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
// @ts-ignore - TypeScript装饰器类型推断问题
|
||||||
|
@OnEvent('default.event')
|
||||||
|
async getRequestBody(event: any): Promise<void> {
|
||||||
|
this.logger.log('收到事件: getRequestBody', event);
|
||||||
|
|
||||||
|
try {
|
||||||
|
// 验证事件数据
|
||||||
|
if (!event || !event.data) {
|
||||||
|
this.logger.warn('事件数据为空,跳过处理');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 处理事件业务逻辑
|
||||||
|
const eventId = event.data.id;
|
||||||
|
this.logger.debug(`处理事件,ID: ${eventId}`);
|
||||||
|
|
||||||
|
this.logger.log('事件处理完成: getRequestBody');
|
||||||
|
} catch (error) {
|
||||||
|
this.logger.error('事件处理失败: getRequestBody', error.stack);
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* getRequestHeader
|
* getRequestHeader
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -14,15 +14,44 @@ export class AddonDevelopBuildServiceImplService {
|
|||||||
* build
|
* build
|
||||||
*/
|
*/
|
||||||
async build(...args: any[]): Promise<any> {
|
async build(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
if (!this.config.get('runActive') === "dev") throw new BadRequestException("只有在开发环境下才可以进行打包操作");
|
||||||
return null;
|
|
||||||
|
if (!this.config.get('projectNiucloudAddon' + addon).exists()) throw new BadRequestException("插件不存在");
|
||||||
|
const infoFile: string = this.config.get('projectNiucloudAddon' + addon + "/src/main/resources/info.json");
|
||||||
|
if (!fs.existsSync(infoFile)) throw new BadRequestException("插件不存在");
|
||||||
|
|
||||||
|
this.addon = addon;
|
||||||
|
this.addonPath = this.config.get('webRootDownAddon') + addon + "/";
|
||||||
|
|
||||||
|
try {
|
||||||
|
for (const child of this.fs.readdirSync(addonPath)) {
|
||||||
|
if (fs.lstatSync(child).isDirectory() && !path.basename(child) === "sql") FileUtils.cleanDirectory(child);
|
||||||
|
}
|
||||||
|
FileUtils.copyFile(infoFile, this.addonPath + "info.json");
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new BadRequestException(e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
this.admin();
|
||||||
|
this.web();
|
||||||
|
this.uniapp();
|
||||||
|
this.java();
|
||||||
|
this.jar();
|
||||||
|
this.resource();
|
||||||
|
this.buildUniappLangJson();
|
||||||
|
this.buildUniappPagesJson();
|
||||||
|
this.menu("site");
|
||||||
|
this.menu("admin");
|
||||||
|
// 生成压缩包
|
||||||
|
this.compressor();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* download
|
* download
|
||||||
*/
|
*/
|
||||||
async download(...args: any[]): Promise<any> {
|
async download(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const file: string = this.config.get('webRootDownResource' + "temp/" + key + ".zip");
|
||||||
return null;
|
if (!fs.existsSync(file)) throw new BadRequestException("请先打包插件");
|
||||||
|
return file.getPath().replace(this.config.get('projectRoot'), "");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,39 +14,100 @@ export class AddonDevelopServiceImplService {
|
|||||||
* list
|
* list
|
||||||
*/
|
*/
|
||||||
async list(...args: any[]): Promise<any[]> {
|
async list(...args: any[]): Promise<any[]> {
|
||||||
// TODO: 实现业务逻辑
|
const list: AddonDevelopListVo[] = [];
|
||||||
return [];
|
|
||||||
|
try {
|
||||||
|
// 获取已安装的插件
|
||||||
|
const installAddonList: Record<string, any> = coreAddonService.getInstallAddonList();
|
||||||
|
|
||||||
|
// 获取本地所有的插件
|
||||||
|
const localAddons: string[] = Files.list(Paths.get(this.config.get('webRootDownAddon')))
|
||||||
|
.map(path => path.toFile())
|
||||||
|
.filter(file => fs.lstatSync(file).isDirectory())
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
|
for (const file of localAddons) {
|
||||||
|
if (file, "info.json".exists()) {
|
||||||
|
const info: Record<string, any> = JSONUtil.parseObj(JsonLoadUtils.loadJsonString(file, "info.json"));
|
||||||
|
const addon: string = info.getStr("key");
|
||||||
|
const addonDevelopListVo: AddonDevelopListVo = JSONUtil.toBean(info, AddonDevelopListVo.class);
|
||||||
|
if (installAddonList.get(addon) != null) addonDevelopListVo.setInstallInfo(installAddonList.get(addon));
|
||||||
|
addonDevelopListVo.setIcon(ImageUtils.imageToBase64(file + "/resource/icon.png"));
|
||||||
|
addonDevelopListVo.setCover(ImageUtils.imageToBase64(file + "/resource/cover.png"));
|
||||||
|
list.add(addonDevelopListVo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ObjectUtil.isNotEmpty(searchParam.getSearch()) && list.size() > 0) {
|
||||||
|
list = list.stream().filter(addonDevelopListVo => addonDevelopListVo.getTitle().includes(searchParam.getSearch())).toList();
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* info
|
* info
|
||||||
*/
|
*/
|
||||||
async info(...args: any[]): Promise<any> {
|
async info(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const infoFile: string = this.config.get('webRootDownAddon' + key + "/info.json");
|
||||||
return null;
|
if (!fs.existsSync(infoFile)) return null;
|
||||||
|
|
||||||
|
const info: Record<string, any> = JSONUtil.parseObj(JsonLoadUtils.loadJsonString(infoFile));
|
||||||
|
const addonDevelopInfoVo: AddonDevelopInfoVo = JSONUtil.toBean(info, AddonDevelopInfoVo.class);
|
||||||
|
|
||||||
|
return addonDevelopInfoVo;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* add
|
* add
|
||||||
*/
|
*/
|
||||||
async add(...args: any[]): Promise<any> {
|
async add(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const infoFile: string = this.config.get('webRootDownAddon' + param.getKey() + "/info.json");
|
||||||
return null;
|
if (fs.existsSync(infoFile)) throw new BadRequestException("已存在相同插件标识的应用");
|
||||||
|
|
||||||
|
this.generateFile(param);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* edit
|
* edit
|
||||||
*/
|
*/
|
||||||
async edit(...args: any[]): Promise<any> {
|
async edit(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const infoFile: string = this.config.get('webRootDownAddon' + param.getKey() + "/info.json");
|
||||||
return null;
|
if (!fs.existsSync(infoFile)) throw new BadRequestException("插件不存在");
|
||||||
|
|
||||||
|
this.generateFile(param);
|
||||||
|
|
||||||
|
const addon: Addon = coreAddonService.getInfoByKey(param.getKey());
|
||||||
|
if (addon != null) {
|
||||||
|
const model: Addon = new Addon();
|
||||||
|
model.setTitle(param.getTitle());
|
||||||
|
model.setVersion(param.getVersion());
|
||||||
|
model.setDesc(param.getDesc());
|
||||||
|
model.setIcon(param.getIcon());
|
||||||
|
model.setKey(param.getKey());
|
||||||
|
model.setType(param.getType());
|
||||||
|
model.setSupportApp(param.getSupportApp());
|
||||||
|
coreAddonService.set(model);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* del
|
* del
|
||||||
*/
|
*/
|
||||||
async del(...args: any[]): Promise<any> {
|
async del(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const infoFile: string = this.config.get('webRootDownAddon' + key + "/info.json");
|
||||||
return null;
|
if (!fs.existsSync(infoFile)) throw new BadRequestException("插件不存在");
|
||||||
|
|
||||||
|
const addon: Addon = coreAddonService.getInfoByKey(key);
|
||||||
|
if (addon != null) throw new BadRequestException("已安装的插件不允许删除");
|
||||||
|
|
||||||
|
try {
|
||||||
|
FileUtils.deleteDirectory(this.config.get('webRootDownAddon' + key));
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,31 +14,63 @@ export class AddonLogServiceImplService {
|
|||||||
* list
|
* list
|
||||||
*/
|
*/
|
||||||
async list(...args: any[]): Promise<any[]> {
|
async list(...args: any[]): Promise<any[]> {
|
||||||
// TODO: 实现业务逻辑
|
const page: number = pageParam.getPage();
|
||||||
return [];
|
const limit: number = pageParam.getLimit();
|
||||||
|
|
||||||
|
const queryWrapper: QueryWrapper<AddonLog> = new QueryWrapper<>();
|
||||||
|
queryWrapper.orderByDesc("id");
|
||||||
|
|
||||||
|
const iPage: IPage<AddonLog> = addonLogMapper.selectPage(new Page<AddonLog>(page, limit), queryWrapper);
|
||||||
|
|
||||||
|
const list: AddonLogListVo[] = [];
|
||||||
|
for (const item of iPage.getRecords()) {
|
||||||
|
const vo: AddonLogListVo = new AddonLogListVo();
|
||||||
|
BeanUtils.copyProperties(item, vo);
|
||||||
|
list.add(vo);
|
||||||
|
}
|
||||||
|
return PageResult.build(page,limit, iPage.getTotal()).setData(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* detail
|
* detail
|
||||||
*/
|
*/
|
||||||
async detail(...args: any[]): Promise<any> {
|
async detail(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const model: AddonLog = addonLogMapper.selectOne(
|
||||||
return null;
|
new QueryWrapper<AddonLog>()
|
||||||
|
.eq("id", id)
|
||||||
|
.last("limit 1"));
|
||||||
|
|
||||||
|
Assert.notNull(model, "数据不存在");
|
||||||
|
|
||||||
|
const vo: AddonLogInfoVo = new AddonLogInfoVo();
|
||||||
|
BeanUtils.copyProperties(model, vo);
|
||||||
|
return vo;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* add
|
* add
|
||||||
*/
|
*/
|
||||||
async add(...args: any[]): Promise<any> {
|
async add(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const model: AddonLog = new AddonLog();
|
||||||
return null;
|
model.setAction(AddonLogParam.getAction());
|
||||||
|
model.setKey(AddonLogParam.getKey());
|
||||||
|
model.setFromVersion(AddonLogParam.getFromVersion());
|
||||||
|
model.setToVersion(AddonLogParam.getToVersion());
|
||||||
|
model.setCreateTime(System.currentTimeMillis() / 1000);
|
||||||
|
addonLogMapper.insert(model);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* del
|
* del
|
||||||
*/
|
*/
|
||||||
async del(...args: any[]): Promise<any> {
|
async del(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const model: AddonLog = addonLogMapper.selectOne(
|
||||||
return null;
|
new QueryWrapper<AddonLog>()
|
||||||
|
.eq("id", id)
|
||||||
|
.last("limit 1"));
|
||||||
|
|
||||||
|
Assert.notNull(model, "数据不存在!");
|
||||||
|
|
||||||
|
addonLogMapper.delete(new QueryWrapper<AddonLog>().eq("id", id));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,127 +14,266 @@ export class AddonServiceImplService {
|
|||||||
* getLocalAddonList
|
* getLocalAddonList
|
||||||
*/
|
*/
|
||||||
async getLocalAddonList(...args: any[]): Promise<any> {
|
async getLocalAddonList(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const vo: LocalAddonListVo = new LocalAddonListVo();
|
||||||
return null;
|
|
||||||
|
const list: Record<string, any> = {};
|
||||||
|
|
||||||
|
// 获取已安装的插件
|
||||||
|
const installAddonList: Record<string, any> = iCoreAddonService.getInstallAddonList();
|
||||||
|
|
||||||
|
try {
|
||||||
|
const moduleList: ModuleListVo[] = niucloudService.getModuleList();
|
||||||
|
|
||||||
|
for (const item of moduleList) {
|
||||||
|
ModuleListVo.const app: App = item.getApp();
|
||||||
|
const addonInfoVo: LocalAddonInfoVo = new LocalAddonInfoVo();
|
||||||
|
addonInfoVo.setTitle(app.getAppName());
|
||||||
|
addonInfoVo.setDesc(app.getAppDesc());
|
||||||
|
addonInfoVo.setKey(app.getAppKey());
|
||||||
|
addonInfoVo.setAuthor(item.getSiteName());
|
||||||
|
addonInfoVo.setVersion(item.getVersion());
|
||||||
|
addonInfoVo.setIsLocal(false);
|
||||||
|
addonInfoVo.setIsDownload(false);
|
||||||
|
addonInfoVo.setType(app.getAppType());
|
||||||
|
addonInfoVo.setIcon(app.getAppLogo());
|
||||||
|
addonInfoVo.setCover(app.getWindowLogo()[0]);
|
||||||
|
list.put(app.getAppKey(), addonInfoVo);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取本地所有的插件
|
||||||
|
const localAddons: string[] = Files.list(Paths.get(this.config.get('webRootDownAddon')))
|
||||||
|
.map(path => path.toFile())
|
||||||
|
.filter(file => fs.lstatSync(file).isDirectory())
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
|
for (const file of localAddons) {
|
||||||
|
if (file, "info.json".exists()) {
|
||||||
|
const info: Record<string, any> = JSONUtil.parseObj(JsonLoadUtils.loadJsonString(file, "info.json"));
|
||||||
|
const addon: string = info.getStr("key");
|
||||||
|
if (list.get(addon) != null) {
|
||||||
|
const addonInfoVo: LocalAddonInfoVo = list.get(addon);
|
||||||
|
addonInfoVo.setIsDownload(true);
|
||||||
|
addonInfoVo.setIsLocal(false);
|
||||||
|
if (installAddonList.get(addon) != null) {
|
||||||
|
addonInfoVo.setInstallInfo(installAddonList.get(addon));
|
||||||
|
}
|
||||||
|
list.put(addon, addonInfoVo);
|
||||||
|
} else {
|
||||||
|
const localAddonInfoVo: LocalAddonInfoVo = JSONUtil.toBean(info, LocalAddonInfoVo.class);
|
||||||
|
localAddonInfoVo.setIsLocal(true);
|
||||||
|
localAddonInfoVo.setIsDownload(true);
|
||||||
|
if (installAddonList.get(addon) != null)
|
||||||
|
localAddonInfoVo.setInstallInfo(installAddonList.get(addon));
|
||||||
|
localAddonInfoVo.setIcon(ImageUtils.imageToBase64(file + "/resource/icon.png"));
|
||||||
|
localAddonInfoVo.setCover(ImageUtils.imageToBase64(file + "/resource/cover.png"));
|
||||||
|
list.put(addon, localAddonInfoVo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
vo.setError(e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
vo.setList(list);
|
||||||
|
return vo;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* list
|
* list
|
||||||
*/
|
*/
|
||||||
async list(...args: any[]): Promise<any[]> {
|
async list(...args: any[]): Promise<any[]> {
|
||||||
// TODO: 实现业务逻辑
|
const page: number = pageParam.getPage();
|
||||||
return [];
|
const limit: number = pageParam.getLimit();
|
||||||
|
|
||||||
|
const queryWrapper: QueryWrapper<Addon> = new QueryWrapper<>();
|
||||||
|
queryWrapper.orderByDesc("id");
|
||||||
|
const iPage: IPage<Addon> = addonMapper.selectPage(new Page<Addon>(page, limit), queryWrapper);
|
||||||
|
const list: AddonListVo[] = [];
|
||||||
|
for (const item of iPage.getRecords()) {
|
||||||
|
const vo: AddonListVo = new AddonListVo();
|
||||||
|
BeanUtils.copyProperties(item, vo);
|
||||||
|
list.add(vo);
|
||||||
|
}
|
||||||
|
return PageResult.build(page, limit, iPage.getTotal()).setData(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* info
|
* info
|
||||||
*/
|
*/
|
||||||
async info(...args: any[]): Promise<any> {
|
async info(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const model: Addon = addonMapper.selectOne(
|
||||||
return null;
|
new QueryWrapper<Addon>()
|
||||||
|
.eq("id", id)
|
||||||
|
.last("limit 1"));
|
||||||
|
|
||||||
|
Assert.notNull(model, "数据不存在");
|
||||||
|
|
||||||
|
const vo: AddonInfoVo = new AddonInfoVo();
|
||||||
|
BeanUtils.copyProperties(model, vo);
|
||||||
|
return vo;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* add
|
* add
|
||||||
*/
|
*/
|
||||||
async add(...args: any[]): Promise<any> {
|
async add(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const model: Addon = new Addon();
|
||||||
return null;
|
|
||||||
|
model.setCreateTime(System.currentTimeMillis() / 1000);
|
||||||
|
model.setInstallTime(addonParam.getInstallTime());
|
||||||
|
model.setUpdateTime(System.currentTimeMillis() / 1000);
|
||||||
|
model.setCover(addonParam.getCover());
|
||||||
|
model.setType(addonParam.getType());
|
||||||
|
model.setSupportApp(addonParam.getSupportApp());
|
||||||
|
model.setIsStar(addonParam.getIsStar());
|
||||||
|
model.setCompile(String.join(",", addonParam.getCompile()));
|
||||||
|
// BeanUtil.copyProperties(sysPositionEditParam, sysPosition);
|
||||||
|
addonMapper.insert(model);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* del
|
* del
|
||||||
*/
|
*/
|
||||||
async del(...args: any[]): Promise<any> {
|
async del(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
addonMapper.delete(new QueryWrapper<Addon>().eq("id", id));
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* install
|
* install
|
||||||
*/
|
*/
|
||||||
async install(...args: any[]): Promise<any> {
|
async install(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
return iCoreAddonInstallService.install(addon, mode);
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* getInstallTask
|
* getInstallTask
|
||||||
*/
|
*/
|
||||||
async getInstallTask(...args: any[]): Promise<any> {
|
async getInstallTask(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
return iCoreAddonInstallService.getInstallTask();
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* cancleInstall
|
* cancleInstall
|
||||||
*/
|
*/
|
||||||
async cancleInstall(...args: any[]): Promise<any> {
|
async cancleInstall(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
iCoreAddonInstallService.cancleInstall();
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* installCheck
|
* installCheck
|
||||||
*/
|
*/
|
||||||
async installCheck(...args: any[]): Promise<any> {
|
async installCheck(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
return iCoreAddonInstallService.installCheck(addon);
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* uninstall
|
* uninstall
|
||||||
*/
|
*/
|
||||||
async uninstall(...args: any[]): Promise<any> {
|
async uninstall(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
return iCoreAddonInstallService.uninstall(addon);
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* uninstallCheck
|
* uninstallCheck
|
||||||
*/
|
*/
|
||||||
async uninstallCheck(...args: any[]): Promise<any> {
|
async uninstallCheck(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
return iCoreAddonInstallService.uninstallCheck(addon);
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* getTitleListByKey
|
* getTitleListByKey
|
||||||
*/
|
*/
|
||||||
async getTitleListByKey(...args: any[]): Promise<any> {
|
async getTitleListByKey(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const jsonKey: JSONArray = JSONUtil.parseArray(keys);
|
||||||
return null;
|
const jsonArray: JSONArray = new JSONArray();
|
||||||
|
if(jsonKey.size()>0){
|
||||||
|
const keyList: string[] = jsonKey.toList(String.class);
|
||||||
|
const addonList: Addon[] = addonMapper.selectList(new QueryWrapper<Addon>().in("`key`", keyList));
|
||||||
|
for (const addon of addonList) {
|
||||||
|
jsonArray.put(addon.getTitle());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return jsonArray.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* getAddonListByKeys
|
* getAddonListByKeys
|
||||||
*/
|
*/
|
||||||
async getAddonListByKeys(...args: any[]): Promise<any> {
|
async getAddonListByKeys(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
return cached.rememberObject(useCache, cacheTagName, Arrays.asList("getAddonListByKeys", addonKeys, type), uniqueKey => {
|
||||||
return null;
|
|
||||||
|
const query: QueryWrapper<Addon> = new QueryWrapper<>();
|
||||||
|
if(type === "")
|
||||||
|
{
|
||||||
|
query.in("`key`", addonKeys);
|
||||||
|
}else{
|
||||||
|
query.in("`key`", addonKeys).eq("type", type);
|
||||||
|
}
|
||||||
|
return addonMapper.selectList(query);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* download
|
* download
|
||||||
*/
|
*/
|
||||||
async download(...args: any[]): Promise<any> {
|
async download(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const instance: NiucloudUtils = NiucloudUtils.getInstance();
|
||||||
return null;
|
|
||||||
|
const actionQuery: Record<string, any> = {};
|
||||||
|
actionQuery.put("data[app_key]", addon);
|
||||||
|
actionQuery.put("data[version]", version);
|
||||||
|
actionQuery.put("data[product_key]", instance.getProductKey());
|
||||||
|
const actionToken: Record<string, any> = niucloudService.getActionToken("download", actionQuery);
|
||||||
|
|
||||||
|
const query: Record<string, any> = {};
|
||||||
|
query.put("authorize_code", instance.getCode());
|
||||||
|
query.put("addon_name", addon);
|
||||||
|
query.put("version", version);
|
||||||
|
query.put("token", actionToken == null ? "" : actionToken.getStr("token"));
|
||||||
|
|
||||||
|
const headResponse: HttpResponse = new NiucloudUtils.Cloud().build("cloud/download").header("Range", "bytes=0-").query(query).method(Method.HEAD).execute();
|
||||||
|
const totalLength: string = headResponse.header("Content-range");
|
||||||
|
const length: string = totalLength.split("/")[1];
|
||||||
|
|
||||||
|
const downloadDir: string = this.config.get('webRootDownResource') + "download/";
|
||||||
|
FileTools.createDirs(downloadDir);
|
||||||
|
|
||||||
|
const file: string = downloadDir + addon + ".zip";
|
||||||
|
if (fs.existsSync(file)) file.delete();
|
||||||
|
|
||||||
|
const response: HttpResponse = new NiucloudUtils.Cloud().build("cloud/download").header("Range", "bytes=0-" + length).query(query).method(Method.GET).execute();
|
||||||
|
|
||||||
|
try (const fos: FileOutputStream = new FileOutputStream(file)) {
|
||||||
|
fos.write(response.bodyBytes());
|
||||||
|
ZipUtil.unzip(file.getPath(), this.config.get('webRootDownAddon'), Charset.forName(System.getProperty("sun.jnu.encoding")));
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
throw new BadRequestException(e.getMessage());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* getIndexAddonList
|
* getIndexAddonList
|
||||||
*/
|
*/
|
||||||
async getIndexAddonList(...args: any[]): Promise<any> {
|
async getIndexAddonList(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const params: Record<string, any> = {};
|
||||||
return null;
|
const config: NiucloudConfigVo = coreNiucloudConfigService.getNiucloudConfig();
|
||||||
|
params.put("code", config.getAuthCode());
|
||||||
|
params.put("secret", config.getAuthSecret());
|
||||||
|
params.put("labels", param.getLabelId());
|
||||||
|
params.put("product_key", "sass");
|
||||||
|
params.put("is_recommend", 1);
|
||||||
|
params.put("order_field", "sale_num desc, visit_num desc");
|
||||||
|
const jsonObject: Record<string, any> = NiucloudUtils.Niucloud.get("store/app", params);
|
||||||
|
const data: Record<string, any> = jsonObject.getJSONObject("data");
|
||||||
|
return data.getJSONArray("data");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* cloudInstallLog
|
* cloudInstallLog
|
||||||
*/
|
*/
|
||||||
async cloudInstallLog(...args: any[]): Promise<any> {
|
async cloudInstallLog(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
return iCoreAddonInstallService.cloudInstallLog(addon);
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,15 +14,13 @@ export class AliappConfigServiceImplService {
|
|||||||
* getAliappConfig
|
* getAliappConfig
|
||||||
*/
|
*/
|
||||||
async getAliappConfig(...args: any[]): Promise<any> {
|
async getAliappConfig(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
return coreAliappConfigService.getAliappConfig(RequestUtils.siteId());
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* setAliappConfig
|
* setAliappConfig
|
||||||
*/
|
*/
|
||||||
async setAliappConfig(...args: any[]): Promise<any> {
|
async setAliappConfig(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
coreAliappConfigService.setAliappConfig(RequestUtils.siteId(), aliappConfigParam);
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,71 +14,194 @@ export class AuthServiceImplService {
|
|||||||
* checkSiteAuth
|
* checkSiteAuth
|
||||||
*/
|
*/
|
||||||
async checkSiteAuth(...args: any[]): Promise<any> {
|
async checkSiteAuth(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const uid: number = RequestUtils.uid();
|
||||||
return null;
|
|
||||||
|
//设置当前操作站点const siteId: id
|
||||||
|
number = RequestUtils.adminSiteId();
|
||||||
|
RequestUtils.setSiteId(siteId);
|
||||||
|
|
||||||
|
//缓存站点信息数据
|
||||||
|
const siteinfo: SiteInfoVo = siteService.info(siteId);
|
||||||
|
//站点不存在 抛出异常
|
||||||
|
if (siteinfo == null) {
|
||||||
|
throw new UnauthorizedException("SITE_NOT_EXIST", 400);
|
||||||
|
}
|
||||||
|
//没有当前站点的信息
|
||||||
|
if (!isSuperAdmin() && ObjectUtil.isNotNull(uid) && uid > 0) {
|
||||||
|
const sysUserRoleInfoVo: SysUserRoleInfoVo = sysUserRoleService.getUserRole(siteId, uid);
|
||||||
|
if (sysUserRoleInfoVo == null) {
|
||||||
|
throw new UnauthorizedException("NO_SITE_PERMISSION", 400);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
RequestUtils.setAppType(siteinfo.getAppType());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* isSuperAdmin
|
* isSuperAdmin
|
||||||
*/
|
*/
|
||||||
async isSuperAdmin(...args: any[]): Promise<any> {
|
async isSuperAdmin(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const siteId: number = RequestUtils.defaultSiteId();
|
||||||
return null;
|
const uid: number = RequestUtils.uid();
|
||||||
|
const superAdminUid: number = cached.tag("adminAuth").get("superAdminUid");
|
||||||
|
if (ObjectUtil.isNotNull(superAdminUid) && ObjectUtil.isNotEmpty(superAdminUid) && superAdminUid > 0) {
|
||||||
|
return superAdminUid === uid;
|
||||||
|
} else {
|
||||||
|
const sysUserRole: SysUserRole = sysUserRoleMapper.selectOne(new QueryWrapper<SysUserRole>().eq("site_id", siteId).eq("is_admin", 1).last(" limit 1"));
|
||||||
|
cached.tag("adminAuth").put("superAdminUid", sysUserRole.getUid());
|
||||||
|
return sysUserRole.getUid() === uid;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* checkRole
|
* checkRole
|
||||||
*/
|
*/
|
||||||
async checkRole(...args: any[]): Promise<any> {
|
async checkRole(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
//当前访问的路由地址
|
||||||
return null;
|
const rule: string = RequestUtils.getReqeustURI();
|
||||||
|
const method: string = RequestUtils.getRequestMethod();
|
||||||
|
|
||||||
|
//缓存站点信息数据
|
||||||
|
const siteinfo: SiteInfoVo = siteService.info(RequestUtils.siteId());
|
||||||
|
if (!method === "get") {
|
||||||
|
if (siteinfo.getStatus() === SiteStatusEnum.EXPIRE.getCode()) {
|
||||||
|
throw new UnauthorizedException("站点已打烊,续费后可继续使用此项功能", 400);
|
||||||
|
}
|
||||||
|
if (siteinfo.getStatus() === SiteStatusEnum.CLOSE.getCode()) {
|
||||||
|
throw new UnauthorizedException("站点已停止", 400);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const allMenuList: Record<string, any> = sysMenuService.getAllApiList(RequestUtils.appType(), 100);
|
||||||
|
const menulist: string[] = allMenuList.get(method);
|
||||||
|
const is_exists: number = menulist.indexOf(rule);
|
||||||
|
|
||||||
|
//判断当前访问的接口是否收到权限的限制
|
||||||
|
if (is_exists < 0) {
|
||||||
|
const otherMenuList: Record<string, any> = sysMenuService.getAllApiList(RequestUtils.appType() === AppTypeEnum.path.basename(ADMIN) ? AppTypeEnum.path.basename(SITE) : AppTypeEnum.path.basename(ADMIN), 100);
|
||||||
|
const methodMenuList: string[] = otherMenuList.get(method);
|
||||||
|
const is_method_exists: number = methodMenuList.indexOf(rule);
|
||||||
|
if (is_method_exists > 0) {
|
||||||
|
throw new UnauthorizedException("NO_PERMISSION", 400);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const roleMenuList: Record<string, any> = this.getAuthApiList();
|
||||||
|
/*if(roleMenuList.get(method).size()<=0 || roleMenuList.get(method).indexOf(rule)<=0){
|
||||||
|
throw new UnauthorizedException("NO_PERMISSION");
|
||||||
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* checkIsDemo
|
* checkIsDemo
|
||||||
*/
|
*/
|
||||||
async checkIsDemo(...args: any[]): Promise<any> {
|
async checkIsDemo(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const method: string = RequestUtils.getRequestMethod();
|
||||||
return null;
|
|
||||||
|
if (!method === "get" && this.config.get('isDemo')) {
|
||||||
|
throw new BadRequestException("演示环境不允许操作");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* getAuthMenuTreeList
|
* getAuthMenuTreeList
|
||||||
*/
|
*/
|
||||||
async getAuthMenuTreeList(...args: any[]): Promise<any> {
|
async getAuthMenuTreeList(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const isAdmin: number = 0;
|
||||||
return null;
|
const siteId: number = RequestUtils.siteId();
|
||||||
|
const uid: number = RequestUtils.uid();
|
||||||
|
const appType: string = RequestUtils.appType();
|
||||||
|
const authApi: Record<string, any> = {};
|
||||||
|
const sysUserRoleInfoVo: SysUserRoleInfoVo = new SysUserRoleInfoVo();
|
||||||
|
const menuList: SysMenu[] = [];
|
||||||
|
if (isSuperAdmin()) {
|
||||||
|
isAdmin = 1;
|
||||||
|
} else {
|
||||||
|
sysUserRoleInfoVo = sysUserRoleService.getUserRole(siteId, uid);
|
||||||
|
if (ObjectUtil.isNull(sysUserRoleInfoVo)) {
|
||||||
|
return new JSONArray();
|
||||||
|
}
|
||||||
|
isAdmin = sysUserRoleInfoVo.getIsAdmin();//是否是超级管理员
|
||||||
|
}
|
||||||
|
if (isAdmin > 0) {
|
||||||
|
menuList = sysMenuService.getMenuListByCondition(appType, siteId, 1, 0, [], addon);
|
||||||
|
} else {
|
||||||
|
const roleIdList: string[] = JSONUtil.toList(JSONUtil.parseArray(sysUserRoleInfoVo.getRoleIds()), String.class);
|
||||||
|
const menuKeyList: string[] = sysRoleService.getMenuIdsByRoleIds(siteId, roleIdList);
|
||||||
|
menuList = sysMenuService.getMenuListByCondition(appType, siteId, 100, 0, menuKeyList, addon);
|
||||||
|
}
|
||||||
|
|
||||||
|
const jsonArray: JSONArray = JSONUtil.parseArray(JacksonUtils.toSnakeCaseJSONString(menuList));
|
||||||
|
return TreeUtils.listToTree(jsonArray, "menu_key", "parent_key", "children");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* getAuthUserInfo
|
* getAuthUserInfo
|
||||||
*/
|
*/
|
||||||
async getAuthUserInfo(...args: any[]): Promise<any> {
|
async getAuthUserInfo(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const uid: number = RequestUtils.uid();
|
||||||
return null;
|
const userInfo: SysUserDetailVo = sysUserService.info(uid);
|
||||||
|
if (userInfo == null) return null;
|
||||||
|
|
||||||
|
const vo: AuthUserInfoVo = new AuthUserInfoVo();
|
||||||
|
BeanUtil.copyProperties(userInfo, vo);
|
||||||
|
return vo;
|
||||||
|
// const userRoleMPJQueryWrapper: MPJQueryWrapper<SysUserRole> = new MPJQueryWrapper<>();
|
||||||
|
// userRoleMPJQueryWrapper.select("sur.id, su.username, su.head_img, su.real_name, su.last_ip, su.last_time, su.login_count, sur.uid, sur.site_id, sur.role_ids, sur.create_time, sur.is_admin, sur.status")
|
||||||
|
// .setAlias("sur")
|
||||||
|
// .leftJoin("?_sys_user su ON sur.uid = su.uid".replace("?_", this.config.get('tablePrefix')));
|
||||||
|
// userRoleMPJQueryWrapper.eq("sur.uid", uid);
|
||||||
|
// userRoleMPJQueryWrapper.eq("sur.site_id", siteId);
|
||||||
|
// const authUserInfoVo: AuthUserInfoVo = sysUserRoleMapper.selectJoinOne(AuthUserInfoVo.class, userRoleMPJQueryWrapper);
|
||||||
|
// if(ObjectUtil.isNotNull(authUserInfoVo))
|
||||||
|
// {
|
||||||
|
// authUserInfoVo.setStatusName("");
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// return authUserInfoVo;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* editAuth
|
* editAuth
|
||||||
*/
|
*/
|
||||||
async editAuth(...args: any[]): Promise<any> {
|
async editAuth(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
if (ObjectUtil.isNotNull(editAuthUserParam.getPassword()) && ObjectUtil.isNotEmpty(editAuthUserParam.getPassword())) {
|
||||||
return null;
|
const sysUser: SysUser = sysUserService.find(RequestUtils.uid());
|
||||||
|
if (!PasswordEncipher.matche(editAuthUserParam.getOriginalPassword(), sysUser.getPassword())) {
|
||||||
|
throw new UnauthorizedException("OLD_PASSWORD_ERROR");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const sysUserParam: SysUserParam = new SysUserParam();
|
||||||
|
sysUserParam.setHeadImg(editAuthUserParam.getHeadImg());
|
||||||
|
sysUserParam.setRealName(editAuthUserParam.getRealName());
|
||||||
|
sysUserParam.setPassword(editAuthUserParam.getPassword());
|
||||||
|
sysUserService.edit(RequestUtils.uid(), sysUserParam);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* addUserLog
|
* addUserLog
|
||||||
*/
|
*/
|
||||||
async addUserLog(...args: any[]): Promise<any> {
|
async addUserLog(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
if (RequestUtils.getRequestMethod() === "get") return;
|
||||||
return null;
|
|
||||||
|
try {
|
||||||
|
const model: SysUserLog = new SysUserLog();
|
||||||
|
model.setSiteId(RequestUtils.siteId());
|
||||||
|
model.setUid(RequestUtils.uid());
|
||||||
|
model.setIp(RequestUtils.ip());
|
||||||
|
model.setUsername(StpUtil.getExtra("userName").toString());
|
||||||
|
model.setUrl(RequestUtils.getReqeustURI());
|
||||||
|
model.setParams("{}");
|
||||||
|
model.setType(RequestUtils.getRequestMethod());
|
||||||
|
model.setCreateTime(System.currentTimeMillis() / 1000);
|
||||||
|
model.setOperation(getDescription(request));
|
||||||
|
sysUserLogMapper.insert(model);
|
||||||
|
} catch (Exception e) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* setIsAllowChangeSite
|
* setIsAllowChangeSite
|
||||||
*/
|
*/
|
||||||
async setIsAllowChangeSite(...args: any[]): Promise<any> {
|
async setIsAllowChangeSite(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
coreConfigService.setConfig(0,"IS_ALLOW_CHANGE_SITE", JSONUtil.parseObj(param));
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,15 +14,20 @@ export class ConfigServiceImplService {
|
|||||||
* getLoginConfig
|
* getLoginConfig
|
||||||
*/
|
*/
|
||||||
async getLoginConfig(...args: any[]): Promise<any> {
|
async getLoginConfig(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const defaultSiteId: number = RequestUtils.defaultSiteId();
|
||||||
return null;
|
const sysConfig: Record<string, any> = coreConfigService.getConfigValue(defaultSiteId, ConfigKeyEnum.path.basename(ADMIN_LOGIN));
|
||||||
|
return JSONUtil.toBean(sysConfig, LoginConfigVo.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* setLoginConfig
|
* setLoginConfig
|
||||||
*/
|
*/
|
||||||
async setLoginConfig(...args: any[]): Promise<any> {
|
async setLoginConfig(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const jsonObject: Record<string, any> = new Record<string, any>();
|
||||||
return null;
|
jsonObject.set("is_captcha", loginConfigParam.getIsCaptcha());
|
||||||
|
jsonObject.set("is_site_captcha", loginConfigParam.getIsSiteCaptcha());
|
||||||
|
jsonObject.set("bg", loginConfigParam.getBg());
|
||||||
|
jsonObject.set("site_bg", loginConfigParam.getSiteBg());
|
||||||
|
coreConfigService.setConfig(RequestUtils.siteId(), ConfigKeyEnum.path.basename(ADMIN_LOGIN), jsonObject);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,23 +14,120 @@ export class LoginServiceImplService {
|
|||||||
* login
|
* login
|
||||||
*/
|
*/
|
||||||
async login(...args: any[]): Promise<any> {
|
async login(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const appType: string = userLoginParam.getAppType();
|
||||||
return null;
|
const userName: string = userLoginParam.getUsername();
|
||||||
|
const passWord: string = userLoginParam.getPassword();
|
||||||
|
|
||||||
|
if(!EnumUtils.isInclude(appType, AppTypeEnum.class, "getName")){
|
||||||
|
throw new UnauthorizedException("APP_TYPE_NOT_EXIST");
|
||||||
|
}
|
||||||
|
const siteId: number = RequestUtils.siteId();
|
||||||
|
|
||||||
|
const loginConfigVo: LoginConfigVo = configService.getLoginConfig();
|
||||||
|
const isCaptcha: number = 0;
|
||||||
|
if(appType === AppTypeEnum.path.basename(ADMIN)){
|
||||||
|
isCaptcha=loginConfigVo.getIsCaptcha();
|
||||||
|
}else if(appType === AppTypeEnum.path.basename(SITE)){
|
||||||
|
isCaptcha=loginConfigVo.getIsSiteCaptcha();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(isCaptcha==1){
|
||||||
|
//验证验证码
|
||||||
|
const captchaVO: CaptchaVO = new CaptchaVO();
|
||||||
|
captchaVO.setCaptchaVerification(userLoginParam.getCaptchaCode());
|
||||||
|
coreCaptchaImgService.verification(captchaVO);
|
||||||
|
}
|
||||||
|
const userInfo: SysUserInfoVo = sysUserService.getUserInfoByUserName(userName);
|
||||||
|
if(ObjectUtil.isNull(userInfo)){
|
||||||
|
throw new UnauthorizedException("账号密码错误");
|
||||||
|
}
|
||||||
|
|
||||||
|
//检测密码加密是否正确
|
||||||
|
if(!PasswordEncipher.matche(passWord, userInfo.getPassword())){
|
||||||
|
throw new UnauthorizedException("账号密码错误");
|
||||||
|
}
|
||||||
|
//设置当前登录用户id
|
||||||
|
RequestUtils.setUid(userInfo.getUid());
|
||||||
|
|
||||||
|
const defaultSiteId: number = 0;
|
||||||
|
const roleInfoVo: SysUserRoleInfoVo = new SysUserRoleInfoVo();
|
||||||
|
const siteIds: number[] = [];
|
||||||
|
if(appType === AppTypeEnum.path.basename(ADMIN)){
|
||||||
|
defaultSiteId=RequestUtils.defaultSiteId();
|
||||||
|
roleInfoVo=sysUserRoleService.getUserRole(defaultSiteId, userInfo.getUid());
|
||||||
|
if(ObjectUtil.isNotNull(roleInfoVo)){
|
||||||
|
if(userInfo.getStatus()<=0){
|
||||||
|
throw new UnauthorizedException("账号被锁定");
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
appType=AppTypeEnum.path.basename(SITE);
|
||||||
|
}
|
||||||
|
}else if(appType === AppTypeEnum.path.basename(SITE)){
|
||||||
|
siteIds=authSiteService.getSiteIds();
|
||||||
|
if(ObjectUtil.isNotNull(siteIds) && siteIds.size()>0){
|
||||||
|
defaultSiteId=siteIds.indexOf(RequestUtils.siteId())>0 || authService.isSuperAdmin()?RequestUtils.siteId():siteIds.get(0);
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
throw new UnauthorizedException("APP_TYPE_NOT_EXIST");
|
||||||
|
}
|
||||||
|
|
||||||
|
//修改用户登录信息
|
||||||
|
sysUserService.editUserLoginInfo(userInfo.getUid());
|
||||||
|
|
||||||
|
const loginModel: SaLoginModel = SaLoginModel.create();
|
||||||
|
loginModel.setDevice(RequestUtils.handler().getHeader("User-Agent"));
|
||||||
|
loginModel.setExtra("userName", userInfo.getUsername());
|
||||||
|
loginModel.setExtra("headImg", userInfo.getHeadImg());
|
||||||
|
loginModel.setExtra("realName", userInfo.getRealName());
|
||||||
|
// 执行登录
|
||||||
|
StpUtil.login("user-" + userInfo.getUid(), loginModel);
|
||||||
|
// 获取返回内容
|
||||||
|
const saTokenInfo: SaTokenInfo = StpUtil.getTokenInfo();
|
||||||
|
const resultVo: LoginResultVo = new LoginResultVo();
|
||||||
|
|
||||||
|
const userInfoVo: LoginUserInfoVo = new LoginUserInfoVo();
|
||||||
|
userInfoVo.setUid(userInfo.getUid());
|
||||||
|
userInfoVo.setUsername(userInfo.getUsername());
|
||||||
|
userInfoVo.setHeadImg(userInfo.getHeadImg());
|
||||||
|
userInfoVo.setIsSuperAdmin(authService.isSuperAdmin());
|
||||||
|
|
||||||
|
|
||||||
|
if(appType === AppTypeEnum.path.basename(ADMIN) || (appType === AppTypeEnum.path.basename(SITE) && defaultSiteId>0)){
|
||||||
|
RequestUtils.setSiteId(defaultSiteId);
|
||||||
|
const siteInfoVo: SiteInfoVo = siteService.info(RequestUtils.siteId());
|
||||||
|
resultVo.setSiteInfo(siteInfoVo);
|
||||||
|
}
|
||||||
|
if(appType === AppTypeEnum.path.basename(ADMIN) && !userInfoVo.getIsSuperAdmin()){
|
||||||
|
siteIds=authSiteService.getSiteIds();
|
||||||
|
}
|
||||||
|
|
||||||
|
resultVo.setToken(saTokenInfo.getTokenValue());
|
||||||
|
resultVo.setExpiresTime(DateUtils.currTime()+saTokenInfo.getTokenTimeout());
|
||||||
|
resultVo.setUserinfo(userInfoVo);
|
||||||
|
resultVo.setSiteId(defaultSiteId);
|
||||||
|
resultVo.setUserrole(roleInfoVo);
|
||||||
|
userInfoVo.setSiteIds(siteIds);
|
||||||
|
|
||||||
|
return resultVo;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* logout
|
* logout
|
||||||
*/
|
*/
|
||||||
async logout(...args: any[]): Promise<any> {
|
async logout(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
StpUtil.logout();
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* clearToken
|
* clearToken
|
||||||
*/
|
*/
|
||||||
async clearToken(...args: any[]): Promise<any> {
|
async clearToken(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
if(ObjectUtil.isNotNull(token) && ObjectUtil.isNotEmpty(token)){
|
||||||
return null;
|
StpUtil.logoutByTokenValue(token);
|
||||||
|
}else if(ObjectUtil.isNotNull(appType) && ObjectUtil.isNotEmpty(appType)){
|
||||||
|
StpUtil.logout(uid, appType);
|
||||||
|
}else{
|
||||||
|
StpUtil.logout(uid);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ export class CaptchaServiceImplService {
|
|||||||
* create
|
* create
|
||||||
*/
|
*/
|
||||||
async create(...args: any[]): Promise<any> {
|
async create(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -22,7 +21,6 @@ export class CaptchaServiceImplService {
|
|||||||
* check
|
* check
|
||||||
*/
|
*/
|
||||||
async check(...args: any[]): Promise<any> {
|
async check(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,71 +14,186 @@ export class AdminAppServiceImplService {
|
|||||||
* getAppConfig
|
* getAppConfig
|
||||||
*/
|
*/
|
||||||
async getAppConfig(...args: any[]): Promise<any> {
|
async getAppConfig(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
return coreAppService.getConfig(RequestUtils.siteId());
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* setAppConfig
|
* setAppConfig
|
||||||
*/
|
*/
|
||||||
async setAppConfig(...args: any[]): Promise<any> {
|
async setAppConfig(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
coreAppService.setConfig(RequestUtils.siteId(), param);
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* getVersionPage
|
* getVersionPage
|
||||||
*/
|
*/
|
||||||
async getVersionPage(...args: any[]): Promise<any> {
|
async getVersionPage(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const page: Page<AppVersion> = new Page<>(pageParam.getPage(), pageParam.getLimit());
|
||||||
return null;
|
|
||||||
|
const queryWrapper: QueryWrapper<AppVersion> = new QueryWrapper<>();
|
||||||
|
queryWrapper.eq("site_id", RequestUtils.siteId());
|
||||||
|
|
||||||
|
if (param.getPlatform() != null) {
|
||||||
|
queryWrapper.eq("platform", param.getPlatform());
|
||||||
|
}
|
||||||
|
queryWrapper.orderByDesc("create_time");
|
||||||
|
|
||||||
|
const resultPage: Page<AppVersion> = appVersionMapper.selectPage(page, queryWrapper);
|
||||||
|
|
||||||
|
const list: AppVersionListVo[] = new LinkedList();
|
||||||
|
for (const item of resultPage.getRecords()) {
|
||||||
|
const vo: AppVersionListVo = new AppVersionListVo();
|
||||||
|
BeanUtil.copyProperties(item, vo);
|
||||||
|
list.add(vo);
|
||||||
|
}
|
||||||
|
|
||||||
|
return PageResult.build(resultPage, list);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* getVersionInfo
|
* getVersionInfo
|
||||||
*/
|
*/
|
||||||
async getVersionInfo(...args: any[]): Promise<any> {
|
async getVersionInfo(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const appVersion: AppVersion = appVersionMapper.selectOne(
|
||||||
|
new QueryWrapper<AppVersion>()
|
||||||
|
.eq("id", id)
|
||||||
|
.eq("site_id", RequestUtils.siteId())
|
||||||
|
);
|
||||||
|
if (appVersion == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const vo: AppVersionInfoVo = new AppVersionInfoVo();
|
||||||
|
BeanUtil.copyProperties(appVersion, vo);
|
||||||
|
|
||||||
|
return vo;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* addVersion
|
* addVersion
|
||||||
*/
|
*/
|
||||||
async addVersion(...args: any[]): Promise<any> {
|
async addVersion(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const notRelease: AppVersion = appVersionMapper.selectOne(
|
||||||
return null;
|
new QueryWrapper<AppVersion>()
|
||||||
|
.eq("site_id", RequestUtils.siteId())
|
||||||
|
.eq("release_time", 0)
|
||||||
|
.last("limit 1")
|
||||||
|
);
|
||||||
|
Assert.isNull(notRelease, "当前已存在未发布的版本");
|
||||||
|
|
||||||
|
const lastVersion: AppVersion = appVersionMapper.selectOne(
|
||||||
|
new QueryWrapper<AppVersion>()
|
||||||
|
.eq("site_id", RequestUtils.siteId())
|
||||||
|
.orderByDesc("id")
|
||||||
|
.last("limit 1")
|
||||||
|
);
|
||||||
|
if (lastVersion != null && number.valueOf(param.getVersionCode()) <= number.valueOf(lastVersion.getVersionCode())) {
|
||||||
|
throw new BadRequestException("版本号必须高于上一版本设置的值");
|
||||||
|
}
|
||||||
|
|
||||||
|
const appVersion: AppVersion = new AppVersion();
|
||||||
|
param.setSiteId(RequestUtils.siteId());
|
||||||
|
BeanUtil.copyProperties(param, appVersion);
|
||||||
|
appVersion.setCreateTime(DateUtils.currTime());
|
||||||
|
|
||||||
|
if (param.getPackageType() === "cloud") {
|
||||||
|
appVersion.setTaskKey(coreAppCloudService.appCloudBuid(param));
|
||||||
|
appVersion.setStatus(AppDict.StatusEnum.STATUS_CREATING.getValue());
|
||||||
|
} else {
|
||||||
|
appVersion.setStatus(AppDict.StatusEnum.STATUS_UPLOAD_SUCCESS.getValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
return appVersionMapper.insert(appVersion) > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* editVersion
|
* editVersion
|
||||||
*/
|
*/
|
||||||
async editVersion(...args: any[]): Promise<any> {
|
async editVersion(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const appVersion: AppVersion = appVersionMapper.selectOne(
|
||||||
return null;
|
new QueryWrapper<AppVersion>()
|
||||||
|
.eq("site_id", RequestUtils.siteId())
|
||||||
|
.eq("id", id)
|
||||||
|
);
|
||||||
|
Assert.notNull(appVersion, "版本不存在");
|
||||||
|
|
||||||
|
const lastVersion: AppVersion = appVersionMapper.selectOne(
|
||||||
|
new QueryWrapper<AppVersion>()
|
||||||
|
.eq("site_id", RequestUtils.siteId())
|
||||||
|
.ne("id", id)
|
||||||
|
.orderByDesc("id")
|
||||||
|
.last("limit 1")
|
||||||
|
);
|
||||||
|
if (lastVersion != null && number.valueOf(param.getVersionCode()) <= number.valueOf(lastVersion.getVersionCode())) {
|
||||||
|
throw new BadRequestException("版本号必须高于上一版本设置的值");
|
||||||
|
}
|
||||||
|
|
||||||
|
BeanUtil.copyProperties(param, appVersion);
|
||||||
|
appVersion.setUpdateTime(DateUtils.currTime());
|
||||||
|
|
||||||
|
if (param.getPackageType() === "cloud") {
|
||||||
|
param.setSiteId(RequestUtils.siteId());
|
||||||
|
appVersion.setTaskKey(coreAppCloudService.appCloudBuid(param));
|
||||||
|
appVersion.setStatus(AppDict.StatusEnum.STATUS_CREATING.getValue());
|
||||||
|
} else {
|
||||||
|
appVersion.setStatus(AppDict.StatusEnum.STATUS_UPLOAD_SUCCESS.getValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
return appVersionMapper.updateById(appVersion) > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* delVersion
|
* delVersion
|
||||||
*/
|
*/
|
||||||
async delVersion(...args: any[]): Promise<any> {
|
async delVersion(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
appVersionMapper.delete(new QueryWrapper<AppVersion>()
|
||||||
return null;
|
.eq("id", id)
|
||||||
|
.eq("site_id", RequestUtils.siteId()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* getBuildLog
|
* getBuildLog
|
||||||
*/
|
*/
|
||||||
async getBuildLog(...args: any[]): Promise<any> {
|
async getBuildLog(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const vo: AppCompileLogVo = coreAppCloudService.getAppCompileLog(key);
|
||||||
return null;
|
if (vo.getStatus() === "fail") {
|
||||||
|
appVersionMapper.update(null, new UpdateWrapper<AppVersion>()
|
||||||
|
.eq("task_key", key)
|
||||||
|
.eq("site_id", RequestUtils.siteId())
|
||||||
|
.set("status", AppDict.StatusEnum.STATUS_CREATE_FAIL.getValue())
|
||||||
|
.set("update_time", DateUtils.currTime())
|
||||||
|
.set("fail_reason", ObjectUtil.defaultIfNull(vo.getFailReason(), "") ));
|
||||||
|
}
|
||||||
|
if (vo.getStatus() === "success") {
|
||||||
|
appVersionMapper.update(null, new UpdateWrapper<AppVersion>()
|
||||||
|
.eq("task_key", key)
|
||||||
|
.eq("site_id", RequestUtils.siteId())
|
||||||
|
.set("status", AppDict.StatusEnum.STATUS_UPLOAD_SUCCESS.getValue())
|
||||||
|
.set("update_time", DateUtils.currTime())
|
||||||
|
.set("package_path", vo.getFilePath() ));
|
||||||
|
}
|
||||||
|
return vo;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* release
|
* release
|
||||||
*/
|
*/
|
||||||
async release(...args: any[]): Promise<any> {
|
async release(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const appVersion: AppVersion = appVersionMapper.selectOne(
|
||||||
return null;
|
new QueryWrapper<AppVersion>()
|
||||||
|
.eq("site_id", RequestUtils.siteId())
|
||||||
|
.eq("id", id)
|
||||||
|
);
|
||||||
|
Assert.notNull(appVersion, "版本不存在");
|
||||||
|
if (!appVersion.getStatus() === AppDict.StatusEnum.STATUS_UPLOAD_SUCCESS.getValue()) {
|
||||||
|
throw new BadRequestException("版本未上传成功");
|
||||||
|
}
|
||||||
|
|
||||||
|
const model: AppVersion = new AppVersion();
|
||||||
|
model.setId(appVersion.getId());
|
||||||
|
appVersion.setStatus(AppDict.StatusEnum.STATUS_PUBLISHED.getValue());
|
||||||
|
appVersion.setReleaseTime(DateUtils.currTime());
|
||||||
|
|
||||||
|
return appVersionMapper.updateById(appVersion) > 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,55 +14,110 @@ export class DictServiceImplService {
|
|||||||
* getPage
|
* getPage
|
||||||
*/
|
*/
|
||||||
async getPage(...args: any[]): Promise<any> {
|
async getPage(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const page: number = pageParam.getPage();
|
||||||
return null;
|
const limit: number = pageParam.getLimit();
|
||||||
|
|
||||||
|
const queryWrapper: QueryWrapper<SysDict> = new QueryWrapper<>();
|
||||||
|
//查询条件判断组装
|
||||||
|
if (ObjectUtil.isNotEmpty(path.basename(searchParam))) {
|
||||||
|
queryWrapper.like("name", path.basename(searchParam));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ObjectUtil.isNotEmpty(searchParam.getKey())) {
|
||||||
|
queryWrapper.eq("`key`", searchParam.getKey());
|
||||||
|
}
|
||||||
|
|
||||||
|
queryWrapper.orderByDesc("id");
|
||||||
|
|
||||||
|
const iPage: IPage<SysDict> = dictMapper.selectPage(new Page<>(page, limit), queryWrapper);
|
||||||
|
const list: DictListVo[] = [];
|
||||||
|
for (const item of iPage.getRecords()) {
|
||||||
|
const vo: DictListVo = new DictListVo();
|
||||||
|
BeanUtils.copyProperties(item, vo);
|
||||||
|
list.add(vo);
|
||||||
|
}
|
||||||
|
return PageResult.build(page, limit, iPage.getTotal()).setData(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* info
|
* info
|
||||||
*/
|
*/
|
||||||
async info(...args: any[]): Promise<any> {
|
async info(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const model: SysDict = dictMapper.selectOne(
|
||||||
return null;
|
new QueryWrapper<SysDict>()
|
||||||
|
.eq("id", id)
|
||||||
|
.last("limit 1"));
|
||||||
|
|
||||||
|
Assert.notNull(model, "数据不存在");
|
||||||
|
|
||||||
|
const vo: DictInfoVo = new DictInfoVo();
|
||||||
|
BeanUtils.copyProperties(model, vo);
|
||||||
|
return vo;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* add
|
* add
|
||||||
*/
|
*/
|
||||||
async add(...args: any[]): Promise<any> {
|
async add(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const model: SysDict = new SysDict();
|
||||||
return null;
|
model.setName(path.basename(addParam));
|
||||||
|
model.setKey(addParam.getKey());
|
||||||
|
model.setMemo(addParam.getMemo());
|
||||||
|
model.setDictionary("[]");
|
||||||
|
model.setCreateTime(System.currentTimeMillis() / 1000);
|
||||||
|
model.setUpdateTime(System.currentTimeMillis() / 1000);
|
||||||
|
dictMapper.insert(model);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* edit
|
* edit
|
||||||
*/
|
*/
|
||||||
async edit(...args: any[]): Promise<any> {
|
async edit(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const model: SysDict = dictMapper.selectOne(
|
||||||
return null;
|
new QueryWrapper<SysDict>()
|
||||||
}
|
.eq("id", id)
|
||||||
|
.last("limit 1"));
|
||||||
|
|
||||||
/**
|
Assert.notNull(model, "数据不存在!");
|
||||||
* addDictData
|
|
||||||
*/
|
model.setId(id);
|
||||||
async addDictData(...args: any[]): Promise<any> {
|
model.setName(path.basename(editParam));
|
||||||
// TODO: 实现业务逻辑
|
model.setKey(editParam.getKey());
|
||||||
return null;
|
model.setMemo(editParam.getMemo());
|
||||||
|
model.setUpdateTime(System.currentTimeMillis() / 1000);
|
||||||
|
dictMapper.updateById(model);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* del
|
* del
|
||||||
*/
|
*/
|
||||||
async del(...args: any[]): Promise<any> {
|
async del(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const model: SysDict = dictMapper.selectOne(
|
||||||
return null;
|
new QueryWrapper<SysDict>()
|
||||||
|
.eq("id", id)
|
||||||
|
.last("limit 1"));
|
||||||
|
|
||||||
|
Assert.notNull(model, "数据不存在!");
|
||||||
|
|
||||||
|
dictMapper.deleteById(model);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* getAll
|
* getAll
|
||||||
*/
|
*/
|
||||||
async getAll(...args: any[]): Promise<any> {
|
async getAll(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const queryWrapper: QueryWrapper<SysDict> = new QueryWrapper<>();
|
||||||
return null;
|
|
||||||
|
|
||||||
|
queryWrapper.orderByDesc("id");
|
||||||
|
|
||||||
|
const voList: SysDict[] = dictMapper.selectList(queryWrapper);
|
||||||
|
const list: DictListVo[] = [];
|
||||||
|
for (const item of voList) {
|
||||||
|
const vo: DictListVo = new DictListVo();
|
||||||
|
BeanUtils.copyProperties(item, vo);
|
||||||
|
list.add(vo);
|
||||||
|
}
|
||||||
|
return list;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,23 +14,20 @@ export class DiyConfigServiceImplService {
|
|||||||
* getBottomList
|
* getBottomList
|
||||||
*/
|
*/
|
||||||
async getBottomList(...args: any[]): Promise<any> {
|
async getBottomList(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
return coreDiyConfigService.getBottomList();
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* getBottomConfig
|
* getBottomConfig
|
||||||
*/
|
*/
|
||||||
async getBottomConfig(...args: any[]): Promise<any> {
|
async getBottomConfig(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
return coreDiyConfigService.getBottomConfig(RequestUtils.siteId(), key);
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* setBottomConfig
|
* setBottomConfig
|
||||||
*/
|
*/
|
||||||
async setBottomConfig(...args: any[]): Promise<any> {
|
async setBottomConfig(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
coreDiyConfigService.setBottomConfig(RequestUtils.siteId(), param.getValue(), param.getKey());
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,23 +14,56 @@ export class DiyRouteServiceImplService {
|
|||||||
* list
|
* list
|
||||||
*/
|
*/
|
||||||
async list(...args: any[]): Promise<any[]> {
|
async list(...args: any[]): Promise<any[]> {
|
||||||
// TODO: 实现业务逻辑
|
const linkEnum: Record<string, any> = LinkEnum.getLink();
|
||||||
return [];
|
const routerList: DiyRouteListVo[] = [];
|
||||||
|
const sort: number = 0;
|
||||||
|
|
||||||
|
for (const key of linkEnum.keySet()) {
|
||||||
|
const parentItem: Record<string, any> = linkEnum.getJSONObject(key);
|
||||||
|
const addonInfo: Record<string, any> = parentItem.getJSONObject("addon_info");
|
||||||
|
const childArray: JSONArray = ObjectUtil.defaultIfNull(parentItem.getJSONArray("child_list"), new JSONArray());
|
||||||
|
|
||||||
|
sort = processChildItems(childArray, key, addonInfo, searchParam, routerList, sort);
|
||||||
|
}
|
||||||
|
|
||||||
|
return routerList;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* getInfoByName
|
* getInfoByName
|
||||||
*/
|
*/
|
||||||
async getInfoByName(...args: any[]): Promise<any> {
|
async getInfoByName(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const model: DiyRoute = diyRouteMapper.selectOne(
|
||||||
return null;
|
new QueryWrapper<DiyRoute>()
|
||||||
|
.eq("name", name)
|
||||||
|
.eq("site_id", RequestUtils.siteId())
|
||||||
|
.last("limit 1"));
|
||||||
|
if (model == null) return null;
|
||||||
|
|
||||||
|
const vo: DiyRouteInfoVo = new DiyRouteInfoVo();
|
||||||
|
BeanUtils.copyProperties(model, vo);
|
||||||
|
|
||||||
|
return vo;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* modifyShare
|
* modifyShare
|
||||||
*/
|
*/
|
||||||
async modifyShare(...args: any[]): Promise<any> {
|
async modifyShare(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const queryWrapper: QueryWrapper = new QueryWrapper<DiyRoute>()
|
||||||
return null;
|
.eq("name", path.basename(editParam))
|
||||||
|
.eq("site_id", RequestUtils.siteId())
|
||||||
|
.last("limit 1");
|
||||||
|
const model: DiyRoute = diyRouteMapper.selectOne(queryWrapper);
|
||||||
|
|
||||||
|
if (model != null) {
|
||||||
|
BeanUtils.copyProperties(editParam, model);
|
||||||
|
diyRouteMapper.update(model, queryWrapper);
|
||||||
|
} else {
|
||||||
|
const insertModel: DiyRoute = new DiyRoute();
|
||||||
|
BeanUtils.copyProperties(editParam, insertModel);
|
||||||
|
insertModel.setSiteId(RequestUtils.siteId());
|
||||||
|
diyRouteMapper.insert(insertModel);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,159 +14,667 @@ export class DiyServiceImplService {
|
|||||||
* list
|
* list
|
||||||
*/
|
*/
|
||||||
async list(...args: any[]): Promise<any[]> {
|
async list(...args: any[]): Promise<any[]> {
|
||||||
// TODO: 实现业务逻辑
|
const page: number = pageParam.getPage();
|
||||||
return [];
|
const limit: number = pageParam.getLimit();
|
||||||
|
|
||||||
|
const queryWrapper: QueryWrapper<DiyPage> = new QueryWrapper<>();
|
||||||
|
queryWrapper.eq("site_id", RequestUtils.siteId());
|
||||||
|
queryWrapper.orderByDesc("id");
|
||||||
|
|
||||||
|
if (ObjectUtil.isNotEmpty(searchParam.getTitle())) queryWrapper.like("title", searchParam.getTitle());
|
||||||
|
if (ObjectUtil.isNotEmpty(searchParam.getMode())) queryWrapper.eq("mode", searchParam.getMode());
|
||||||
|
if (ObjectUtil.isNotEmpty(searchParam.getType())) queryWrapper.eq("type", searchParam.getType());
|
||||||
|
|
||||||
|
const template: Record<string, any> = TemplateEnum.getTemplate();
|
||||||
|
const templateAddon: Record<string, any>[] = TemplateEnum.getTemplateAddons((RequestUtils.siteId()));
|
||||||
|
const iPage: IPage<DiyPage> = diyPageMapper.selectPage(new Page<DiyPage>(page, limit), queryWrapper);
|
||||||
|
const list: DiyPageListVo[] = [];
|
||||||
|
for (const item of iPage.getRecords()) {
|
||||||
|
const vo: DiyPageListVo = new DiyPageListVo();
|
||||||
|
BeanUtils.copyProperties(item, vo);
|
||||||
|
vo.setTypeName(ObjectUtil.defaultIfNull(template.getByPath(vo.getType() + ".title", String.class), ""));
|
||||||
|
vo.setTypePage(ObjectUtil.defaultIfNull(template.getByPath(vo.getType() + ".page", String.class), ""));
|
||||||
|
const addonName: string = templateAddon.stream()
|
||||||
|
.filter(temp => vo.getType() != null && vo.getType() === temp.get("type"))
|
||||||
|
.findFirst()
|
||||||
|
.map(addon => ObjectUtil.defaultIfNull(addon.get("title"), "").toString())
|
||||||
|
.orElse("");
|
||||||
|
vo.setAddonName(addonName);
|
||||||
|
list.add(vo);
|
||||||
|
}
|
||||||
|
return PageResult.build(page, limit, iPage.getTotal()).setData(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* allList
|
* allList
|
||||||
*/
|
*/
|
||||||
async allList(...args: any[]): Promise<any> {
|
async allList(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const queryWrapper: QueryWrapper<DiyPage> = new QueryWrapper<>();
|
||||||
return null;
|
queryWrapper.eq("site_id", RequestUtils.siteId());
|
||||||
|
queryWrapper.orderByDesc("id");
|
||||||
|
|
||||||
|
if (ObjectUtil.isNotEmpty(searchParam.getTitle())) queryWrapper.like("title", searchParam.getTitle());
|
||||||
|
if (ObjectUtil.isNotEmpty(searchParam.getMode())) queryWrapper.eq("mode", searchParam.getMode());
|
||||||
|
if (ObjectUtil.isNotEmpty(searchParam.getType())) {
|
||||||
|
const type: string[] = Arrays.stream(searchParam.getType()).collect(Collectors.toList());
|
||||||
|
queryWrapper.in("type", type);
|
||||||
|
}
|
||||||
|
|
||||||
|
const pages: DiyPage[] = diyPageMapper.selectList(queryWrapper);
|
||||||
|
const list: DiyPageListVo[] = [];
|
||||||
|
|
||||||
|
for (const item of pages) {
|
||||||
|
const vo: DiyPageListVo = new DiyPageListVo();
|
||||||
|
BeanUtils.copyProperties(item, vo);
|
||||||
|
list.add(vo);
|
||||||
|
}
|
||||||
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* info
|
* info
|
||||||
*/
|
*/
|
||||||
async info(...args: any[]): Promise<any> {
|
async info(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const model: DiyPage = diyPageMapper.selectOne(
|
||||||
return null;
|
new QueryWrapper<DiyPage>()
|
||||||
|
.eq("id", id)
|
||||||
|
.eq("site_id", RequestUtils.siteId()));
|
||||||
|
|
||||||
|
if (model == null) return null;
|
||||||
|
|
||||||
|
const vo: DiyPageInfoVo = new DiyPageInfoVo();
|
||||||
|
BeanUtils.copyProperties(model, vo);
|
||||||
|
|
||||||
|
return vo;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* infoByName
|
* infoByName
|
||||||
*/
|
*/
|
||||||
async infoByName(...args: any[]): Promise<any> {
|
async infoByName(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const model: DiyPage = diyPageMapper.selectOne(
|
||||||
return null;
|
new QueryWrapper<DiyPage>()
|
||||||
|
.eq("name", name)
|
||||||
|
.eq("is_default", 1)
|
||||||
|
.eq("site_id", RequestUtils.siteId()));
|
||||||
|
|
||||||
|
if (model == null) return null;
|
||||||
|
|
||||||
|
const vo: DiyPageInfoVo = new DiyPageInfoVo();
|
||||||
|
BeanUtils.copyProperties(model, vo);
|
||||||
|
|
||||||
|
return vo;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* add
|
* add
|
||||||
*/
|
*/
|
||||||
async add(...args: any[]): Promise<any> {
|
async add(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const model: DiyPage = new DiyPage();
|
||||||
return null;
|
BeanUtils.copyProperties(addParam, model);
|
||||||
|
model.setSiteId(addParam.getSiteId() == null ? RequestUtils.siteId() : addParam.getSiteId());
|
||||||
|
model.setCreateTime(System.currentTimeMillis() / 1000);
|
||||||
|
diyPageMapper.insert(model);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* edit
|
* edit
|
||||||
*/
|
*/
|
||||||
async edit(...args: any[]): Promise<any> {
|
async edit(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const model: DiyPage = diyPageMapper.selectOne(
|
||||||
return null;
|
new QueryWrapper<DiyPage>()
|
||||||
|
.eq("id", id)
|
||||||
|
.eq("site_id", RequestUtils.siteId()));
|
||||||
|
|
||||||
|
Assert.notNull(model, "数据不存在!");
|
||||||
|
|
||||||
|
BeanUtils.copyProperties(editParam, model);
|
||||||
|
model.setUpdateTime(System.currentTimeMillis() / 1000);
|
||||||
|
diyPageMapper.updateById(model);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* del
|
* del
|
||||||
*/
|
*/
|
||||||
async del(...args: any[]): Promise<any> {
|
async del(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
diyPageMapper.delete(new QueryWrapper<DiyPage>().eq("id", id).eq("site_id", RequestUtils.siteId()));
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* setUse
|
* setUse
|
||||||
*/
|
*/
|
||||||
async setUse(...args: any[]): Promise<any> {
|
async setUse(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const model: DiyPage = diyPageMapper.selectOne(new QueryWrapper<DiyPage>().eq("id", id).eq("site_id", RequestUtils.siteId()));
|
||||||
return null;
|
Assert.notNull(model, "页面不存在!");
|
||||||
|
|
||||||
|
const update: DiyPage = new DiyPage();
|
||||||
|
update.setIsDefault(0);
|
||||||
|
diyPageMapper.update(update, new QueryWrapper<DiyPage>().eq("name", path.basename(model)).eq("site_id", RequestUtils.siteId()));
|
||||||
|
|
||||||
|
update.setId(id);
|
||||||
|
update.setIsDefault(1);
|
||||||
|
update.setUpdateTime(System.currentTimeMillis() / 1000);
|
||||||
|
diyPageMapper.updateById(update);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* getLink
|
* getLink
|
||||||
*/
|
*/
|
||||||
async getLink(...args: any[]): Promise<any> {
|
async getLink(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const linkEnum: Record<string, any> = LinkEnum.getLink();
|
||||||
return null;
|
for (const key of linkEnum.keySet()) {
|
||||||
|
const item: Record<string, any> = linkEnum.getJSONObject(key);
|
||||||
|
|
||||||
|
item.put("name", key);
|
||||||
|
|
||||||
|
if (!"DIY_PAGE" === key && item.containsKey("child_list")) {
|
||||||
|
const childList: JSONArray = item.getJSONArray("child_list");
|
||||||
|
for (const i of number = 0; i < childList.size(); i++) {
|
||||||
|
const child: Record<string, any> = childList.getJSONObject(i);
|
||||||
|
child.put("parent", key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (key === "DIY_PAGE") {
|
||||||
|
const queryWrapper: QueryWrapper<DiyPage> = new QueryWrapper<>();
|
||||||
|
queryWrapper.eq("site_id", RequestUtils.siteId())
|
||||||
|
.and(wrapper => wrapper
|
||||||
|
.eq("type", "DIY_PAGE")
|
||||||
|
.or()
|
||||||
|
.ne("type", "DIY_PAGE")
|
||||||
|
.eq("is_default", 0)
|
||||||
|
)
|
||||||
|
.orderByDesc("update_time");
|
||||||
|
|
||||||
|
const pageList: DiyPage[] = diyPageMapper.selectList(queryWrapper);
|
||||||
|
const newChildList: JSONArray = new JSONArray();
|
||||||
|
for (const diyPage of pageList) {
|
||||||
|
const child: Record<string, any> = new Record<string, any>();
|
||||||
|
child.put("name", path.basename(diyPage));
|
||||||
|
child.put("title", diyPage.getPageTitle());
|
||||||
|
child.put("url", "/app/pages/index/diy?id=" + diyPage.getId());
|
||||||
|
newChildList.add(child);
|
||||||
|
}
|
||||||
|
item.put("child_list", newChildList);
|
||||||
|
}
|
||||||
|
if (key === "DIY_LINK") {
|
||||||
|
item.put("parent", "DIY_LINK");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return linkEnum;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* getPageInit
|
* getPageInit
|
||||||
*/
|
*/
|
||||||
async getPageInit(...args: any[]): Promise<any> {
|
async getPageInit(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const template: Record<string, any> = getTemplate(new TemplateParam());
|
||||||
return null;
|
|
||||||
|
const info: DiyPageInfoVo = null;
|
||||||
|
if (param.getId() > 0) {
|
||||||
|
info = this.info(param.getId());
|
||||||
|
} else if (!path.basename(param).isEmpty()) {
|
||||||
|
info = this.infoByName(path.basename(param));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (StringUtils.isNotBlank(path.basename(param))) {
|
||||||
|
const startConfig: StartUpPageConfigVo = coreDiyConfigService.getStartUpPageConfig(RequestUtils.siteId(), path.basename(param));
|
||||||
|
if (startConfig != null) {
|
||||||
|
if ("DIY_PAGE" === startConfig.getParent()) {
|
||||||
|
const page: string = startConfig.getPage();
|
||||||
|
const id: number = number.parseInt(page.replace("/app/pages/index/diy?id=", ""));
|
||||||
|
info = this.info(id);
|
||||||
|
if (info != null) {
|
||||||
|
param.setType(info.getType());
|
||||||
|
param.setName(path.basename(info));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for (const key of template.keySet()) {
|
||||||
|
const templateItem: Record<string, any> = template.getJSONObject(key);
|
||||||
|
const templatePage: string = templateItem != null ? templateItem.getStr("page") : "";
|
||||||
|
if (startConfig.getPage() === templatePage) {
|
||||||
|
info = this.infoByName(key);
|
||||||
|
if (info != null) {
|
||||||
|
param.setType(key);
|
||||||
|
param.setName(key);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (info != null) {
|
||||||
|
if (template.getJSONObject(info.getType()) != null) {
|
||||||
|
const page: Record<string, any> = template.getJSONObject(info.getType());
|
||||||
|
info.setTypeName(page.getStr("title"));
|
||||||
|
info.setPage(page.getStr("page"));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
const time: number = System.currentTimeMillis() / 1000;
|
||||||
|
const pageTitle: string = ObjectUtil.defaultIfBlank(param.getTitle(), "页面" + time);
|
||||||
|
const type: string = ObjectUtil.defaultIfBlank(param.getType(), "DIY_PAGE");
|
||||||
|
const name: string = type === "DIY_PAGE" ? "DIY_PAGE_RANDOM_" + time : type;
|
||||||
|
const typeName: string = "";
|
||||||
|
const templateName: string = "";
|
||||||
|
const pageRoute: string = "";
|
||||||
|
const mode: string = "diy";
|
||||||
|
const isDefault: number = 0;
|
||||||
|
const value: string = "";
|
||||||
|
|
||||||
|
const pageObj: Record<string, any> = null;
|
||||||
|
if (StringUtils.isNotBlank(path.basename(param)) && template.getJSONObject(path.basename(param)) != null) {
|
||||||
|
pageObj = template.getJSONObject(path.basename(param));
|
||||||
|
type = name = path.basename(param);
|
||||||
|
pageTitle = typeName = pageObj.getStr("title");
|
||||||
|
pageRoute = pageObj.getStr("page");
|
||||||
|
|
||||||
|
const pageData: Record<string, any> = this.getFirstPageData(type, "");
|
||||||
|
if (pageData != null) {
|
||||||
|
const templateObj: Record<string, any> = pageData.getJSONObject("template");
|
||||||
|
if (templateObj != null) {
|
||||||
|
mode = templateObj.getStr("mode");
|
||||||
|
value = templateObj.toString();
|
||||||
|
isDefault = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (template.getJSONObject(param.getType()) != null) {
|
||||||
|
pageObj = template.getJSONObject(param.getType());
|
||||||
|
typeName = pageObj.getStr("title");
|
||||||
|
pageRoute = pageObj.getStr("page");
|
||||||
|
|
||||||
|
const count: number = diyPageMapper.selectCount(new LambdaQueryWrapper<DiyPage>()
|
||||||
|
.eq(DiyPage::getSiteId, RequestUtils.siteId())
|
||||||
|
.eq(DiyPage::getType, param.getType()));
|
||||||
|
if (count == 0) {
|
||||||
|
isDefault = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 页面标题(用于前台展示)
|
||||||
|
const title: string = pageTitle;
|
||||||
|
if (!"DIY_PAGE" === type) {
|
||||||
|
title = typeName;
|
||||||
|
}
|
||||||
|
|
||||||
|
info = new DiyPageInfoVo();
|
||||||
|
info.setName(name);
|
||||||
|
info.setPageTitle(pageTitle); // 页面名称(用于后台展示)
|
||||||
|
info.setTitle(title); // 页面标题(用于前台展示)
|
||||||
|
info.setType(type);
|
||||||
|
info.setTypeName(typeName);
|
||||||
|
info.setTemplate(templateName);
|
||||||
|
info.setPage(pageRoute);
|
||||||
|
info.setMode(mode);
|
||||||
|
info.setValue(value);
|
||||||
|
info.setIsDefault(isDefault);
|
||||||
|
}
|
||||||
|
|
||||||
|
info.setComponent(getComponentList(info.getType()));
|
||||||
|
info.setDomainUrl(coreSysConfigService.getSceneDomain(RequestUtils.siteId()));
|
||||||
|
|
||||||
|
// 处理全局模板数据
|
||||||
|
const diyTemplate: Record<string, any> = new Record<string, any>();
|
||||||
|
if (StringUtils.isNotBlank(path.basename(info))) {
|
||||||
|
const templateParam: TemplateParam = new TemplateParam();
|
||||||
|
String[] key = {path.basename(info)};
|
||||||
|
templateParam.setKey(key);
|
||||||
|
diyTemplate = getTemplate(templateParam);
|
||||||
|
if (diyTemplate != null && diyTemplate.containsKey(path.basename(info))) {
|
||||||
|
const templateInfo: Record<string, any> = diyTemplate.getJSONObject(path.basename(info));
|
||||||
|
info.setGlobal(templateInfo.getJSONObject("global"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return info;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* getComponentList
|
* getComponentList
|
||||||
*/
|
*/
|
||||||
async getComponentList(...args: any[]): Promise<any> {
|
async getComponentList(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const data: Record<string, any> = ComponentEnum.getComponent();
|
||||||
return null;
|
|
||||||
|
// 安全遍历顶层数据
|
||||||
|
const categoryIterator: Iterator<String> = data.keySet().iterator();
|
||||||
|
const categoryToRemove: string[] = [];
|
||||||
|
|
||||||
|
while (categoryIterator.hasNext()) {
|
||||||
|
const categoryKey: string = categoryIterator.next();
|
||||||
|
const category: Record<string, any> = data.getJSONObject(categoryKey);
|
||||||
|
const componentList: Record<string, any> = category.getJSONObject("list");
|
||||||
|
|
||||||
|
// 用于存储排序值的映射
|
||||||
|
const sortMap: Record<string, any> = new Record<string, any>();
|
||||||
|
|
||||||
|
// 安全遍历组件列表
|
||||||
|
const keysToRemove: string[] = [];
|
||||||
|
for (const componentKey of new ArrayList<>(componentList.keySet())) {
|
||||||
|
const component: Record<string, any> = componentList.getJSONObject(componentKey);
|
||||||
|
const supportPage: JSONArray = component.getJSONArray("support_page");
|
||||||
|
|
||||||
|
if (supportPage == null) supportPage = new JSONArray();
|
||||||
|
|
||||||
|
if (supportPage.length === 0 || supportPage.includes(name)) {
|
||||||
|
sortMap.put(componentKey, component.getInt("sort", 0));
|
||||||
|
component.remove("sort");
|
||||||
|
component.remove("support_page");
|
||||||
|
} else {
|
||||||
|
keysToRemove.add(componentKey);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 批量移除组件
|
||||||
|
for (const key of keysToRemove) {
|
||||||
|
componentList.remove(key);
|
||||||
|
}
|
||||||
|
if (componentList.length === 0) {
|
||||||
|
categoryToRemove.add(categoryKey);
|
||||||
|
} else {
|
||||||
|
sortComponentsBySortValues(componentList, sortMap);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (const key of categoryToRemove) {
|
||||||
|
data.remove(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* getFirstPageData
|
* getFirstPageData
|
||||||
*/
|
*/
|
||||||
async getFirstPageData(...args: any[]): Promise<any> {
|
async getFirstPageData(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const pages: Record<string, any> = PagesEnum.getPagesByAddon(type, addon);
|
||||||
return null;
|
if (pages == null || pages.keySet().size() == 0) return null;
|
||||||
|
|
||||||
|
const template: string = pages.keySet().iterator().next();
|
||||||
|
const data: Record<string, any> = pages.getJSONObject(template);
|
||||||
|
data.set("type", type);
|
||||||
|
data.set("template", template);
|
||||||
|
|
||||||
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* getTemplate
|
* getTemplate
|
||||||
*/
|
*/
|
||||||
async getTemplate(...args: any[]): Promise<any> {
|
async getTemplate(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const template: Record<string, any> = TemplateEnum.getTemplate(param);
|
||||||
return null;
|
|
||||||
|
for (const key of template.keySet()) {
|
||||||
|
const pages: Record<string, any> = ObjectUtil.defaultIfNull(PagesEnum.getPages(key, param.getMode()), new Record<string, any>());
|
||||||
|
template.putByPath(key + ".template", pages);
|
||||||
|
}
|
||||||
|
//删除null值 防止序列化报错
|
||||||
|
JacksonUtils.removeNull(template);
|
||||||
|
return template;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* changeTemplate
|
* changeTemplate
|
||||||
*/
|
*/
|
||||||
async changeTemplate(...args: any[]): Promise<any> {
|
async changeTemplate(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
this.coreDiyConfigService.setStartUpPageConfig(RequestUtils.siteId(), value, value.getType());
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* getDecoratePage
|
* getDecoratePage
|
||||||
*/
|
*/
|
||||||
async getDecoratePage(...args: any[]): Promise<any> {
|
async getDecoratePage(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const templateParam: TemplateParam = new TemplateParam();
|
||||||
return null;
|
const oneType: string = searchParam.getType()[0];
|
||||||
|
String[] key = searchParam.getType();
|
||||||
|
templateParam.setKey(key);
|
||||||
|
const template: Record<string, any> = this.getTemplate(templateParam).getJSONObject(oneType);
|
||||||
|
if (template == null) throw new BadRequestException("模板不存在");
|
||||||
|
|
||||||
|
const defaultPage: Record<string, any> = getFirstPageData(oneType, "");
|
||||||
|
|
||||||
|
const useTemplate: Record<string, any> = new Record<string, any>();
|
||||||
|
useTemplate.put("type", searchParam.getType());
|
||||||
|
useTemplate.put("title", defaultPage == null ? "" : defaultPage.getStr("title", ""));
|
||||||
|
useTemplate.put("name", "");
|
||||||
|
useTemplate.put("cover", defaultPage == null ? "" : defaultPage.getStr("cover", ""));
|
||||||
|
useTemplate.put("page", template.getStr("page"));
|
||||||
|
useTemplate.put("action", template.getStr("action"));
|
||||||
|
useTemplate.put("url", "");
|
||||||
|
useTemplate.put("parent", "");
|
||||||
|
|
||||||
|
const info: DiyPageInfoVo = infoByName(oneType);
|
||||||
|
|
||||||
|
const startConfig: StartUpPageConfigVo = coreDiyConfigService.getStartUpPageConfig(RequestUtils.siteId(), oneType);
|
||||||
|
if (startConfig != null) {
|
||||||
|
useTemplate.set("title", startConfig.getTitle());
|
||||||
|
useTemplate.set("name", path.basename(startConfig));
|
||||||
|
useTemplate.set("page", startConfig.getPage());
|
||||||
|
useTemplate.set("action", startConfig.getAction());
|
||||||
|
useTemplate.set("url", startConfig.getPage());
|
||||||
|
useTemplate.set("parent", startConfig.getParent());
|
||||||
|
} else if (info != null) {
|
||||||
|
useTemplate.set("id", info.getId());
|
||||||
|
useTemplate.set("title", info.getTitle());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (useTemplate.getStr("cover").isEmpty() && useTemplate.getStr("url").isEmpty()) {
|
||||||
|
useTemplate.set("url", template.getStr("page"));
|
||||||
|
} else if (useTemplate.getStr("url").isEmpty()) {
|
||||||
|
useTemplate.set("url", template.getStr("page"));
|
||||||
|
}
|
||||||
|
|
||||||
|
const diyRouteSearchParam: DiyRouteSearchParam = new DiyRouteSearchParam();
|
||||||
|
diyRouteSearchParam.setUrl(useTemplate.getStr("page"));
|
||||||
|
const otherPage: DiyRouteListVo[] = diyRouteService.list(diyRouteSearchParam);
|
||||||
|
if (otherPage.size() > 0) {
|
||||||
|
const route: DiyRouteListVo = otherPage.get(0);
|
||||||
|
useTemplate.set("title", route.getTitle());
|
||||||
|
useTemplate.set("name", path.basename(route));
|
||||||
|
useTemplate.set("parent", route.getParent());
|
||||||
|
useTemplate.set("action", route.getAction());
|
||||||
|
}
|
||||||
|
|
||||||
|
template.put("use_template", useTemplate);
|
||||||
|
|
||||||
|
const sceneDomain: SceneDomainVo = coreSysConfigService.getSceneDomain(RequestUtils.siteId());
|
||||||
|
const domainUrl: Record<string, any> = new Record<string, any>();
|
||||||
|
domainUrl.put("wap_domain", sceneDomain.getWapDomain());
|
||||||
|
domainUrl.put("wap_url", sceneDomain.getWapUrl());
|
||||||
|
domainUrl.put("web_url", sceneDomain.getWebUrl());
|
||||||
|
template.put("domain_url", domainUrl);
|
||||||
|
|
||||||
|
return template;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* getPageByCarouselSearch
|
* getPageByCarouselSearch
|
||||||
*/
|
*/
|
||||||
async getPageByCarouselSearch(...args: any[]): Promise<any> {
|
async getPageByCarouselSearch(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const page: number = pageParam.getPage();
|
||||||
return null;
|
const limit: number = pageParam.getLimit();
|
||||||
|
|
||||||
|
const queryWrapper: QueryWrapper<DiyPage> = new QueryWrapper<DiyPage>()
|
||||||
|
.eq("site_id", RequestUtils.siteId())
|
||||||
|
.eq("type", "DIY_PAGE")
|
||||||
|
.notIn("value", Arrays.asList("top_fixed", "right_fixed", "bottom_fixed", "left_fixed", "fixed"))
|
||||||
|
.or()
|
||||||
|
.eq("site_id", RequestUtils.siteId())
|
||||||
|
.ne("type", "DIY_PAGE")
|
||||||
|
.eq("is_default", 0)
|
||||||
|
.notIn("value", Arrays.asList("top_fixed", "right_fixed", "bottom_fixed", "left_fixed", "fixed"))
|
||||||
|
.orderByDesc("id");
|
||||||
|
|
||||||
|
const iPage: IPage<DiyPage> = diyPageMapper.selectPage(new Page<DiyPage>(page, limit), queryWrapper);
|
||||||
|
const list: DiyPageListVo[] = [];
|
||||||
|
for (const item of iPage.getRecords()) {
|
||||||
|
const vo: DiyPageListVo = new DiyPageListVo();
|
||||||
|
BeanUtils.copyProperties(item, vo);
|
||||||
|
list.add(vo);
|
||||||
|
}
|
||||||
|
return PageResult.build(page, limit, iPage.getTotal()).setData(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* setDiyData
|
* setDiyData
|
||||||
*/
|
*/
|
||||||
async setDiyData(...args: any[]): Promise<any> {
|
async setDiyData(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const addonFlag: string = param.getKey();
|
||||||
return null;
|
|
||||||
|
const templateParam: TemplateParam = new TemplateParam();
|
||||||
|
String[] key = {param.getKey()};
|
||||||
|
templateParam.setKey(key);
|
||||||
|
const template: Record<string, any> = getTemplate(templateParam).getJSONObject(param.getKey());
|
||||||
|
if (template == null) return;
|
||||||
|
|
||||||
|
if (!param.getAddon().isEmpty()) {
|
||||||
|
const addonTemplateParam: TemplateParam = new TemplateParam();
|
||||||
|
addonTemplateParam.setAddon(param.getAddon());
|
||||||
|
addonTemplateParam.setType(param.getType());
|
||||||
|
const addonTemplate: Record<string, any> = getTemplate(addonTemplateParam);
|
||||||
|
if (addonTemplate != null && !addonTemplate.length === 0) {
|
||||||
|
addonFlag = addonTemplate.keySet().iterator().next();
|
||||||
|
template = addonTemplate.getJSONObject(addonFlag);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const pages: Record<string, any> = template.getJSONObject("template");
|
||||||
|
if (pages.length === 0) return;
|
||||||
|
|
||||||
|
const pageKey: string = pages.keySet().iterator().next();
|
||||||
|
const page: Record<string, any> = pages.getJSONObject(pageKey);
|
||||||
|
|
||||||
|
const info: DiyPage = diyPageMapper.selectOne(new QueryWrapper<DiyPage>()
|
||||||
|
.eq("name", addonFlag)
|
||||||
|
.eq("site_id", param.getSiteId())
|
||||||
|
.eq("is_default", 1)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (info == null) {
|
||||||
|
RequestUtils.setSiteId(param.getSiteId());
|
||||||
|
const addParam: DiyPageParam = new DiyPageParam();
|
||||||
|
addParam.setTitle(page.getStr("title", ""));
|
||||||
|
addParam.setPageTitle(page.getStr("title", ""));
|
||||||
|
addParam.setName(addonFlag);
|
||||||
|
addParam.setType(addonFlag);
|
||||||
|
addParam.setTemplate(pageKey);
|
||||||
|
addParam.setValue(page.getJSONObject("data").toString());
|
||||||
|
addParam.setMode(page.getStr("mode", ""));
|
||||||
|
addParam.setIsDefault(1);
|
||||||
|
addParam.setIsChange(0);
|
||||||
|
this.add(addParam);
|
||||||
|
} else {
|
||||||
|
if (path.basename(info) === "DIY_INDEX" && info.getType() === "DIY_INDEX") {
|
||||||
|
const update: DiyPage = new DiyPage();
|
||||||
|
update.setId(info.getId());
|
||||||
|
update.setValue(page.getJSONObject("data").toString());
|
||||||
|
diyPageMapper.updateById(update);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (param.getIsStart() === 1) {
|
||||||
|
const startPage: StartUpPageConfigParam = new StartUpPageConfigParam();
|
||||||
|
startPage.setType(param.getKey());
|
||||||
|
startPage.setMode(page.getStr("mode", ""));
|
||||||
|
startPage.setTitle(page.getStr("title", ""));
|
||||||
|
startPage.setAction(template.getStr("action", ""));
|
||||||
|
startPage.setPage(template.getStr("page"));
|
||||||
|
this.changeTemplate(startPage);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* copy
|
* copy
|
||||||
*/
|
*/
|
||||||
async copy(...args: any[]): Promise<any> {
|
async copy(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const page: DiyPage = diyPageMapper.selectOne(new QueryWrapper<DiyPage>().eq("id", id).eq("site_id", RequestUtils.siteId()));
|
||||||
return null;
|
if (page == null) throw new BadRequestException("页面不存在");
|
||||||
|
|
||||||
|
page.setId(null);
|
||||||
|
page.setPageTitle(page.getPageTitle() + "_副本");
|
||||||
|
page.setIsChange(0);
|
||||||
|
page.setIsDefault(0);
|
||||||
|
page.setShare("");
|
||||||
|
page.setCreateTime(System.currentTimeMillis() / 1000);
|
||||||
|
diyPageMapper.insert(page);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* loadDiyData
|
* loadDiyData
|
||||||
*/
|
*/
|
||||||
async loadDiyData(...args: any[]): Promise<any> {
|
async loadDiyData(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
// 获取参数
|
||||||
return null;
|
const mainAppStr: string = params.get("main_app").toString();
|
||||||
|
const mainApp: JSONArray = JSONUtil.parseArray(mainAppStr);
|
||||||
|
const count: number = mainApp.size();
|
||||||
|
const tag: string = params.getOrDefault("tag", "add");
|
||||||
|
const siteId: number = params.get("site_id");
|
||||||
|
|
||||||
|
// 创建addon数组,在开头添加空字符串
|
||||||
|
const addon: JSONArray = new JSONArray();
|
||||||
|
addon.add("");
|
||||||
|
addon.addAll(mainApp);
|
||||||
|
|
||||||
|
// 遍历处理
|
||||||
|
for (const k of number = 0; k < addon.size(); k++) {
|
||||||
|
const v: string = addon.get(k).toString();
|
||||||
|
int isStart;
|
||||||
|
|
||||||
|
if ("add" === tag) {
|
||||||
|
if (count > 1) {
|
||||||
|
// 站点多应用,使用系统的页面
|
||||||
|
isStart = (k == 0) ? 1 : 0;
|
||||||
|
} else {
|
||||||
|
// 站点单应用,将应用的设为使用中
|
||||||
|
isStart = (k == 0) ? 0 : 1;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// 编辑站点套餐的情况
|
||||||
|
if (count > 1) {
|
||||||
|
// 站点多应用,将不更新启动页
|
||||||
|
isStart = 0;
|
||||||
|
} else {
|
||||||
|
// 站点单应用,将应用的设为使用中
|
||||||
|
isStart = (k == 0) ? 0 : 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const setParam: SetDiyDataParam = new SetDiyDataParam();
|
||||||
|
setParam.setSiteId(siteId);
|
||||||
|
setParam.setType("index");
|
||||||
|
setParam.setKey("DIY_INDEX");
|
||||||
|
setParam.setIsStart(isStart);
|
||||||
|
setParam.setMainApp(addon);
|
||||||
|
setParam.setAddon(v);
|
||||||
|
setDiyData(setParam);
|
||||||
|
|
||||||
|
setParam.setType("member_index");
|
||||||
|
setParam.setKey("DIY_MEMBER_INDEX");
|
||||||
|
setDiyData(setParam);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* getPageLink
|
* getPageLink
|
||||||
*/
|
*/
|
||||||
async getPageLink(...args: any[]): Promise<any> {
|
async getPageLink(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const page: number = pageParam.getPage();
|
||||||
return null;
|
const limit: number = pageParam.getLimit();
|
||||||
|
|
||||||
|
const queryWrapper: QueryWrapper<DiyPage> = new QueryWrapper<DiyPage>()
|
||||||
|
.eq("site_id", RequestUtils.siteId())
|
||||||
|
.and(i => i.eq("type", "DIY_PAGE").or().ne("type", "DIY_PAGE").eq("is_default", 0))
|
||||||
|
.orderByDesc("update_time");
|
||||||
|
|
||||||
|
const templates: Record<string, any> = TemplateEnum.getTemplate(new TemplateParam());
|
||||||
|
|
||||||
|
const iPage: IPage<DiyPage> = diyPageMapper.selectPage(new Page<DiyPage>(page, limit), queryWrapper);
|
||||||
|
const list: DiyPageListVo[] = [];
|
||||||
|
for (const item of iPage.getRecords()) {
|
||||||
|
const vo: DiyPageListVo = new DiyPageListVo();
|
||||||
|
BeanUtils.copyProperties(item, vo);
|
||||||
|
vo.setTypeName(templates.getByPath(item.getType() + ".title", String.class));
|
||||||
|
list.add(vo);
|
||||||
|
}
|
||||||
|
return PageResult.build(page, limit, iPage.getTotal()).setData(list);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,55 +14,236 @@ export class DiyThemeServiceImplService {
|
|||||||
* getDiyTheme
|
* getDiyTheme
|
||||||
*/
|
*/
|
||||||
async getDiyTheme(...args: any[]): Promise<any> {
|
async getDiyTheme(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const siteId: number = RequestUtils.siteId();
|
||||||
return null;
|
const siteCache: SiteInfoVo = coreSiteService.getSiteCache(siteId);
|
||||||
|
const themeDataList: DiyTheme[] = diyThemeMapper.selectList(new QueryWrapper<DiyTheme>().eq("site_id", siteId).eq("type", "app").eq("is_selected", 1));
|
||||||
|
const themeData: Record<string, any> = {};
|
||||||
|
if (!themeDataList.length === 0){
|
||||||
|
themeData = themeDataList.stream().collect(Collectors.toMap(theme => theme.getAddon(), theme => theme));
|
||||||
|
}
|
||||||
|
|
||||||
|
const systemTheme: Record<string, any> = coreDiyService.getDefaultThemeColor("app");
|
||||||
|
const appTheme: Record<string, any> = new Record<string, any>();
|
||||||
|
const appThemeObj: Record<string, any> = new Record<string, any>();
|
||||||
|
appThemeObj.set("id", ObjectUtil.isNotEmpty(themeData.get("app")) ? themeData.get("app").getId() : "");
|
||||||
|
appThemeObj.set("icon", "");
|
||||||
|
appThemeObj.set("addon_title", "系统");
|
||||||
|
appThemeObj.set("title", ObjectUtil.isNotEmpty(themeData.get("app")) ? themeData.get("app").getTitle() : (!systemTheme.length === 0 ? systemTheme.getJSONArray("theme_color").getJSONObject(0).get("title") : ""));
|
||||||
|
|
||||||
|
const themeValue: any = ObjectUtil.isNotEmpty(themeData.get("app")) ?
|
||||||
|
themeData.get("app").getTheme() :
|
||||||
|
(!systemTheme.length === 0 ? systemTheme.getJSONArray("theme_color").getJSONObject(0).get("theme") : "");
|
||||||
|
if (themeValue instanceof String) {
|
||||||
|
appThemeObj.set("theme", JSONUtil.parseObj(themeValue));
|
||||||
|
} else {
|
||||||
|
appThemeObj.set("theme", themeValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
appTheme.putOpt("app", appThemeObj);
|
||||||
|
|
||||||
|
const data: Record<string, any> = new Record<string, any>();
|
||||||
|
const appsAndAddons: Addon[] = siteCache.getApps();
|
||||||
|
appsAndAddons.addAll(siteCache.getSiteAddons());
|
||||||
|
for (const value of appsAndAddons) {
|
||||||
|
const addonTheme: Record<string, any> = coreDiyService.getDefaultThemeColor(value.getKey());
|
||||||
|
if (!addonTheme.length === 0 && addonTheme.containsKey("theme_color")) {
|
||||||
|
const addonData: Record<string, any> = new Record<string, any>();
|
||||||
|
addonData.set("id", ObjectUtil.isNotEmpty(themeData.get(value.getKey())) ? themeData.get(value.getKey()).getId() : "");
|
||||||
|
addonData.set("icon", value.getIcon() != null ? value.getIcon() : "");
|
||||||
|
addonData.set("addon_title", value.getTitle() != null ? value.getTitle() : "");
|
||||||
|
addonData.set("title", ObjectUtil.isNotEmpty(themeData.get(value.getKey())) ? themeData.get(value.getKey()).getTitle() : addonTheme.getJSONArray("theme_color").getJSONObject(0).get("title"));
|
||||||
|
|
||||||
|
const addonThemeValue: any = ObjectUtil.isNotEmpty(themeData.get(value.getKey())) ?
|
||||||
|
themeData.get(value.getKey()).getTheme() :
|
||||||
|
addonTheme.getJSONArray("theme_color").getJSONObject(0).get("theme");
|
||||||
|
if (addonThemeValue instanceof String) {
|
||||||
|
addonData.set("theme", JSONUtil.parseObj(addonThemeValue));
|
||||||
|
} else {
|
||||||
|
addonData.set("theme", addonThemeValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
data.putOpt(value.getKey(), addonData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data.length === 0 || siteCache.getApps().size() > 1) {
|
||||||
|
const mergedData: Record<string, any> = new Record<string, any>();
|
||||||
|
for (const key of appTheme.keySet()) {
|
||||||
|
mergedData.putOpt(key, appTheme.get(key));
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const key of data.keySet()) {
|
||||||
|
if (!mergedData.containsKey(key)) {
|
||||||
|
mergedData.putOpt(key, data.get(key));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
data = mergedData;
|
||||||
|
}
|
||||||
|
|
||||||
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* setDiyTheme
|
* setDiyTheme
|
||||||
*/
|
*/
|
||||||
async setDiyTheme(...args: any[]): Promise<any> {
|
async setDiyTheme(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const siteId: number = RequestUtils.siteId();
|
||||||
return null;
|
const diyTheme: DiyTheme = diyThemeMapper.selectById(data.getId());
|
||||||
|
if (ObjectUtil.isEmpty(diyTheme)) {
|
||||||
|
throw new BadRequestException("主题色不存在");
|
||||||
|
}
|
||||||
|
const addonData: Addon[] = addonMapper.selectList(new QueryWrapper<Addon>().eq("support_app", data.getAddon()));
|
||||||
|
const addonSaveData: DiyTheme[] = [];
|
||||||
|
if(ObjectUtil.isNotEmpty(addonData)){
|
||||||
|
for (const addon of addonData) {
|
||||||
|
const saveData: DiyTheme = new DiyTheme();
|
||||||
|
saveData.setSiteId(siteId);
|
||||||
|
saveData.setType("addon");
|
||||||
|
saveData.setAddon(addon.getKey());
|
||||||
|
saveData.setTitle(diyTheme.getTitle());
|
||||||
|
saveData.setTheme(data.getTheme().toString());
|
||||||
|
saveData.setNewTheme(data.getNewTheme().toString());
|
||||||
|
saveData.setIsSelected(1);
|
||||||
|
saveData.setUpdateTime(System.currentTimeMillis() / 1000);
|
||||||
|
addonSaveData.add(saveData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
diyThemeMapper.update(null, new UpdateWrapper<DiyTheme>().eq("site_id", siteId).eq("addon", data.getAddon()).eq("type", "addon").set("is_selected", 0));
|
||||||
|
|
||||||
|
const model: DiyTheme = new DiyTheme();
|
||||||
|
BeanUtils.copyProperties(data, model);
|
||||||
|
model.setIsSelected(1);
|
||||||
|
model.setUpdateTime(System.currentTimeMillis() / 1000);
|
||||||
|
diyThemeMapper.updateById(model);
|
||||||
|
|
||||||
|
if (!ObjectUtil.isNotEmpty(addonSaveData)) {
|
||||||
|
for (const saveData of addonSaveData) {
|
||||||
|
|
||||||
|
diyThemeMapper.update(null, new UpdateWrapper<DiyTheme>().eq("site_id", siteId).eq("addon", saveData.getAddon()).eq("type", "addon").set("is_selected", 0));
|
||||||
|
diyThemeMapper.update(saveData, new UpdateWrapper<DiyTheme>().eq("site_id", siteId).eq("addon", saveData.getAddon()).eq("type", "addon").eq("title", saveData.getTitle()));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* getDefaultThemeColor
|
* getDefaultThemeColor
|
||||||
*/
|
*/
|
||||||
async getDefaultThemeColor(...args: any[]): Promise<any> {
|
async getDefaultThemeColor(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const addon: string = data.getAddon();
|
||||||
return null;
|
const themeList: DiyTheme[] = diyThemeMapper.selectList(new QueryWrapper<DiyTheme>().eq("site_id", RequestUtils.siteId()).eq("addon", addon));
|
||||||
|
const voList: DiyThemeInfoVo[] = [];
|
||||||
|
for (const theme of themeList) {
|
||||||
|
const vo: DiyThemeInfoVo = new DiyThemeInfoVo();
|
||||||
|
BeanUtils.copyProperties(theme, vo);
|
||||||
|
const addonTheme: Record<string, any> = coreDiyService.getDefaultThemeColor(theme.getAddon());
|
||||||
|
if (!addonTheme.length === 0 && addonTheme.containsKey("theme_field")) {
|
||||||
|
vo.setThemeField(addonTheme.getJSONArray("theme_field"));
|
||||||
|
}
|
||||||
|
voList.add(vo);
|
||||||
|
}
|
||||||
|
|
||||||
|
return voList;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* addDiyTheme
|
* addDiyTheme
|
||||||
*/
|
*/
|
||||||
async addDiyTheme(...args: any[]): Promise<any> {
|
async addDiyTheme(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const siteId: number = RequestUtils.siteId();
|
||||||
return null;
|
const addonData: Addon[] = addonMapper.selectList(new QueryWrapper<Addon>().eq("support_app", data.getAddon()));
|
||||||
|
const addonSaveData: DiyTheme[] = [];
|
||||||
|
if (!addonData.length === 0) {
|
||||||
|
for (const addon of addonData) {
|
||||||
|
|
||||||
|
const diyTheme: DiyTheme = new DiyTheme();
|
||||||
|
diyTheme.setSiteId(siteId);
|
||||||
|
diyTheme.setTheme("addon");
|
||||||
|
diyTheme.setAddon(addon.getKey());
|
||||||
|
diyTheme.setTitle(data.getTitle());
|
||||||
|
diyTheme.setTheme(data.getTheme().toString());
|
||||||
|
diyTheme.setNewTheme(data.getNewTheme().toString());
|
||||||
|
diyTheme.setDefaultTheme(data.getDefaultTheme().toString());
|
||||||
|
diyTheme.setThemeType("diy");
|
||||||
|
diyTheme.setCreateTime(System.currentTimeMillis() / 1000);
|
||||||
|
addonSaveData.add(diyTheme);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const model: DiyTheme = new DiyTheme();
|
||||||
|
BeanUtils.copyProperties(data, model);
|
||||||
|
model.setType("app");
|
||||||
|
model.setThemeType("diy");
|
||||||
|
model.setCreateTime(System.currentTimeMillis() / 1000);
|
||||||
|
addonSaveData.add(model);
|
||||||
|
if (ObjectUtil.isNotEmpty(addonSaveData)) {
|
||||||
|
for (const diyTheme of addonSaveData) {
|
||||||
|
diyThemeMapper.insert(diyTheme);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* editDiyTheme
|
* editDiyTheme
|
||||||
*/
|
*/
|
||||||
async editDiyTheme(...args: any[]): Promise<any> {
|
async editDiyTheme(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const diyThemeInfo: DiyTheme = diyThemeMapper.selectById(id);
|
||||||
return null;
|
if (ObjectUtil.isEmpty(diyThemeInfo)) {
|
||||||
|
throw new Error("主题色不存在");
|
||||||
|
}
|
||||||
|
const addonData: DiyTheme[] = diyThemeMapper.selectList(new QueryWrapper<DiyTheme>().eq("type", "addon").eq("title", diyThemeInfo.getTitle()));
|
||||||
|
const addonSaveData: DiyTheme[] = [];
|
||||||
|
if (ObjectUtil.isNotEmpty(addonData)) {
|
||||||
|
for (const diyTheme of addonData) {
|
||||||
|
const saveData: DiyTheme = new DiyTheme();
|
||||||
|
saveData.setId(diyTheme.getId());
|
||||||
|
saveData.setSiteId(diyTheme.getSiteId());
|
||||||
|
saveData.setTitle(diyTheme.getTitle());
|
||||||
|
saveData.setTheme(data.getTheme().toString());
|
||||||
|
saveData.setNewTheme(data.getNewTheme().toString());
|
||||||
|
saveData.setUpdateTime(System.currentTimeMillis() / 1000);
|
||||||
|
|
||||||
|
addonSaveData.add(saveData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
BeanUtils.copyProperties(data, diyThemeInfo);
|
||||||
|
diyThemeInfo.setUpdateTime(System.currentTimeMillis() / 1000);
|
||||||
|
|
||||||
|
diyThemeMapper.updateById(diyThemeInfo);
|
||||||
|
|
||||||
|
if (ObjectUtil.isNotEmpty(addonSaveData)) {
|
||||||
|
for (const diyTheme of addonSaveData) {
|
||||||
|
diyThemeMapper.updateById(diyTheme);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* delDiyTheme
|
* delDiyTheme
|
||||||
*/
|
*/
|
||||||
async delDiyTheme(...args: any[]): Promise<any> {
|
async delDiyTheme(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const diyThemeInfo: DiyTheme = diyThemeMapper.selectById(id);
|
||||||
return null;
|
if (ObjectUtil.isEmpty(diyThemeInfo)) {
|
||||||
|
throw new BadRequestException("主题色不存在");
|
||||||
|
}
|
||||||
|
if (diyThemeInfo.getThemeType() === "default") {
|
||||||
|
throw new BadRequestException("默认主题色不能删除");
|
||||||
|
}
|
||||||
|
diyThemeMapper.deleteById(diyThemeInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* checkDiyThemeTitleUnique
|
* checkDiyThemeTitleUnique
|
||||||
*/
|
*/
|
||||||
async checkDiyThemeTitleUnique(...args: any[]): Promise<any> {
|
async checkDiyThemeTitleUnique(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const queryWrapper: QueryWrapper<DiyTheme> = new QueryWrapper<>();
|
||||||
return null;
|
queryWrapper.eq("title", data.getTitle());
|
||||||
|
queryWrapper.eq("addon", data.getAddon());
|
||||||
|
if(ObjectUtil.isNotEmpty(data.getId()))
|
||||||
|
{
|
||||||
|
queryWrapper.ne("id", data.getId());
|
||||||
|
}
|
||||||
|
return diyThemeMapper.selectCount(queryWrapper) == 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,31 +14,29 @@ export class DiyFormConfigServiceImplService {
|
|||||||
* getWriteConfig
|
* getWriteConfig
|
||||||
*/
|
*/
|
||||||
async getWriteConfig(...args: any[]): Promise<any> {
|
async getWriteConfig(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
return coreDiyFormConfigService.getWriteConfig(RequestUtils.siteId(), formId);
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* editWriteConfig
|
* editWriteConfig
|
||||||
*/
|
*/
|
||||||
async editWriteConfig(...args: any[]): Promise<any> {
|
async editWriteConfig(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
editParam.setSiteId(RequestUtils.siteId());
|
||||||
return null;
|
coreDiyFormConfigService.editWriteConfig(editParam);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* getSubmitConfig
|
* getSubmitConfig
|
||||||
*/
|
*/
|
||||||
async getSubmitConfig(...args: any[]): Promise<any> {
|
async getSubmitConfig(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
return coreDiyFormConfigService.getSubmitConfig(RequestUtils.siteId(), formId);
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* editSubmitConfig
|
* editSubmitConfig
|
||||||
*/
|
*/
|
||||||
async editSubmitConfig(...args: any[]): Promise<any> {
|
async editSubmitConfig(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
editParam.setSiteId(RequestUtils.siteId());
|
||||||
return null;
|
coreDiyFormConfigService.editSubmitConfig(editParam);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,15 +14,202 @@ export class DiyFormRecordsServiceImplService {
|
|||||||
* getPage
|
* getPage
|
||||||
*/
|
*/
|
||||||
async getPage(...args: any[]): Promise<any> {
|
async getPage(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const page: number = pageParam.getPage();
|
||||||
return null;
|
const limit: number = pageParam.getLimit();
|
||||||
|
const queryWrapper: MPJQueryWrapper<DiyFormRecords> = new MPJQueryWrapper<>();
|
||||||
|
|
||||||
|
//sql语句
|
||||||
|
queryWrapper.select("ndfr.form_id, ndfr.member_id, nm.username, nm.member_no, nm.mobile, nm.nickname, nm.headimg,count(*) as write_count")
|
||||||
|
.setAlias("ndfr")
|
||||||
|
.leftJoin("?_member nm ON ndfr.member_id = nm.member_id".replace("?_", this.config.get('tablePrefix')));
|
||||||
|
|
||||||
|
queryWrapper.eq("ndfr.site_id", RequestUtils.siteId());
|
||||||
|
if (ObjectUtil.isNotEmpty(searchParam.getFormId())) {
|
||||||
|
queryWrapper.eq("ndfr.form_id", searchParam.getFormId());
|
||||||
|
}
|
||||||
|
if (ObjectUtil.isNotEmpty(searchParam.getKeyword())) {
|
||||||
|
queryWrapper.and(i => i.or(j => j.like("nm.nickname", searchParam.getKeyword()))
|
||||||
|
.or(j => j.like("nm.mobile", searchParam.getKeyword()))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
queryWrapper.groupBy("ndfr.member_id");
|
||||||
|
|
||||||
|
|
||||||
|
queryWrapper.orderByDesc("ndfr.form_id");
|
||||||
|
const iPage: IPage<DiyFormRecordsListVo> = diyFormRecordsMapper.selectJoinPage(new Page<>(page, limit), DiyFormRecordsListVo.class, queryWrapper);
|
||||||
|
for (const vo of iPage.getRecords()) {
|
||||||
|
const memberVo: Member = new Member();
|
||||||
|
BeanUtils.copyProperties(vo, memberVo);
|
||||||
|
vo.setMember(memberVo);
|
||||||
|
}
|
||||||
|
return PageResult.build(iPage);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* getFieldStatList
|
* getFieldStatList
|
||||||
*/
|
*/
|
||||||
async getFieldStatList(...args: any[]): Promise<any> {
|
async getFieldStatList(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const diyFormRecordsFieldsSearchParam: DiyFormRecordsFieldsSearchParam = new DiyFormRecordsFieldsSearchParam();
|
||||||
return null;
|
diyFormRecordsFieldsSearchParam.setFormId(searchParam.getFormId());
|
||||||
|
const fieldsList: DiyFormFieldsListVo[] = diyFormService.getFieldsList(diyFormRecordsFieldsSearchParam);
|
||||||
|
|
||||||
|
// 过滤简单字段列表
|
||||||
|
String[] simpleTypes = {"FormRadio", "FormCheckbox", "FormDateScope", "FormTimeScope", "FormImage"};
|
||||||
|
const simpleFieldList: DiyFormFieldsListVo[] = fieldsList.stream()
|
||||||
|
.filter(e => !Arrays.asList(simpleTypes).includes(e.getFieldType()))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
|
// 过滤 JSON 字段列表
|
||||||
|
String[] jsonTypes = {"FormRadio", "FormCheckbox", "FormDateScope", "FormTimeScope"};
|
||||||
|
const jsonFieldList: DiyFormFieldsListVo[] = fieldsList.stream()
|
||||||
|
.filter(e => Arrays.asList(jsonTypes).includes(e.getFieldType()))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
|
const totalCount: number = 0;
|
||||||
|
for (const field of simpleFieldList) {
|
||||||
|
// 统计每个字段值的填写数量
|
||||||
|
const valueQueryWrapper: QueryWrapper<DiyFormRecordsFields> = new QueryWrapper<>();
|
||||||
|
valueQueryWrapper.eq("site_id", RequestUtils.siteId())
|
||||||
|
.eq("field_key", field.getFieldKey())
|
||||||
|
.eq("field_type", field.getFieldType());
|
||||||
|
if (searchParam.getFormId() != null) {
|
||||||
|
valueQueryWrapper.eq("form_id", searchParam.getFormId());
|
||||||
|
}
|
||||||
|
const valueList: Record<string, any>[] = diyFormRecordsFieldsMapper.selectMaps(valueQueryWrapper
|
||||||
|
.select("form_id, field_key, field_type, field_value, count(*) as write_count")
|
||||||
|
.groupBy("field_value"));
|
||||||
|
for (const i of number = 0; i < valueList.size(); i++) {
|
||||||
|
const value: Record<string, any> = valueList.get(i);
|
||||||
|
const diyFormComponentEnum: DiyFormComponentEnum = new DiyFormComponentEnum();
|
||||||
|
const component: Record<string, any> = diyFormComponentEnum.getComponent(value.get("field_type").toString());
|
||||||
|
if(component.containsKey("render")){
|
||||||
|
const driver: string = component.getStr("render");
|
||||||
|
if(ObjectUtil.isNotEmpty(driver))
|
||||||
|
{
|
||||||
|
try{
|
||||||
|
Class<?> clazz = ClassLoaderUtil.loadClass(driver);
|
||||||
|
const obj: any = clazz.getDeclaredConstructor().newInstance();
|
||||||
|
const method: Method = clazz.getMethod("render", String.class, String.class);
|
||||||
|
value.put("render_value", method.invoke(obj, value.get("field_value").toString(), value.get("field_type").toString()));
|
||||||
|
}catch (Exception e){
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
value.put("render_value", value.get("field_value"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 计算总数量
|
||||||
|
totalCount = diyFormRecordsFieldsMapper.selectCount(new QueryWrapper<DiyFormRecordsFields>().eq("site_id", RequestUtils.siteId())
|
||||||
|
.eq("field_key", field.getFieldKey())
|
||||||
|
.eq("field_type", field.getFieldType()));
|
||||||
|
|
||||||
|
if (totalCount > 0) {
|
||||||
|
const totalPercent: number = 100;
|
||||||
|
for (const i of number = 0; i < valueList.size(); i++) {
|
||||||
|
const value: Record<string, any> = valueList.get(i);
|
||||||
|
double itemPercent;
|
||||||
|
if (i == valueList.size() - 1) {
|
||||||
|
itemPercent = totalPercent;
|
||||||
|
} else {
|
||||||
|
itemPercent = Math.round((number.parseInt(value.get("write_count").toString()) / totalCount) * 100 * 100) / 100.0;
|
||||||
|
}
|
||||||
|
value.put("write_percent", itemPercent);
|
||||||
|
totalPercent = totalPercent - itemPercent;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
field.setValueList(valueList);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 处理 JSON 字段列表
|
||||||
|
for (const field of jsonFieldList) {
|
||||||
|
// 查询字段记录
|
||||||
|
const fieldQueryWrapper: QueryWrapper<DiyFormRecordsFields> = new QueryWrapper<>();
|
||||||
|
fieldQueryWrapper.eq("site_id", RequestUtils.siteId())
|
||||||
|
.eq("field_key", field.getFieldKey())
|
||||||
|
.eq("field_type", field.getFieldType());
|
||||||
|
if (searchParam.getFormId() != null) {
|
||||||
|
fieldQueryWrapper.eq("form_id", searchParam.getFormId());
|
||||||
|
}
|
||||||
|
const fieldList: Record<string, any>[] = diyFormRecordsFieldsMapper.selectMaps(fieldQueryWrapper);
|
||||||
|
for (const i of number = 0; i < fieldList.size(); i++) {
|
||||||
|
const value: Record<string, any> = fieldList.get(i);
|
||||||
|
const diyFormComponentEnum: DiyFormComponentEnum = new DiyFormComponentEnum();
|
||||||
|
const component: Record<string, any> = diyFormComponentEnum.getComponent(value.get("field_type").toString());
|
||||||
|
if(component.containsKey("render")){
|
||||||
|
const driver: string = component.getStr("render");
|
||||||
|
if(ObjectUtil.isNotEmpty(driver))
|
||||||
|
{
|
||||||
|
try{
|
||||||
|
Class<?> clazz = ClassLoaderUtil.loadClass(driver);
|
||||||
|
const obj: any = clazz.getDeclaredConstructor().newInstance();
|
||||||
|
const method: Method = clazz.getMethod("render", String.class, String.class);
|
||||||
|
value.put("render_value", method.invoke(obj, value.get("field_value").toString(), value.get("field_type").toString()));
|
||||||
|
}catch (Exception e){
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
value.put("render_value", value.get("field_value"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
totalCount = 0;
|
||||||
|
const valueMap: Record<string, any> = {};
|
||||||
|
for (const record of fieldList) {
|
||||||
|
if (!"FormCheckbox" === record.get("field_type")) {
|
||||||
|
const key: string = record.get("field_key") + "_" + record.get("render_value");
|
||||||
|
if (valueMap.containsKey(key)) {
|
||||||
|
valueMap.get(key).put("write_count", valueMap.get(key).get("write_count") + 1);
|
||||||
|
totalCount++;
|
||||||
|
} else {
|
||||||
|
valueMap.put(key, record);
|
||||||
|
valueMap.get(key).put("write_count", 1);
|
||||||
|
totalCount++;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
String[] values = record.get("render_value").toString().split(",");
|
||||||
|
for (const value of values) {
|
||||||
|
const key: string = record.get("field_key") + "_" + value;
|
||||||
|
if (valueMap.containsKey(key)) {
|
||||||
|
valueMap.get(key).put("write_count", valueMap.get(key).get("write_count") + 1);
|
||||||
|
totalCount++;
|
||||||
|
} else {
|
||||||
|
const newRecord: Record<string, any> = new HashMap<>(record);
|
||||||
|
newRecord.put("render_value", value);
|
||||||
|
newRecord.put("write_count", 1);
|
||||||
|
valueMap.put(key, newRecord);
|
||||||
|
totalCount++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (totalCount > 0) {
|
||||||
|
const valueList: Record<string, any>[] = new ArrayList<>(valueMap.values());
|
||||||
|
const totalPercent: number = 100;
|
||||||
|
for (const i of number = 0; i < valueList.size(); i++) {
|
||||||
|
const value: Record<string, any> = valueList.get(i);
|
||||||
|
double itemPercent;
|
||||||
|
if (i == valueList.size() - 1) {
|
||||||
|
itemPercent = totalPercent;
|
||||||
|
} else {
|
||||||
|
itemPercent = Math.round((number.parseInt(value.get("write_count").toString()) / totalCount) * 100 * 100) / 100.0;
|
||||||
|
}
|
||||||
|
value.put("write_percent", itemPercent);
|
||||||
|
totalPercent = totalPercent - itemPercent;
|
||||||
|
}
|
||||||
|
field.setValueList(valueList);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 合并结果
|
||||||
|
const resultList: DiyFormFieldsListVo[] = [];
|
||||||
|
resultList.addAll(simpleFieldList);
|
||||||
|
resultList.addAll(jsonFieldList);
|
||||||
|
|
||||||
|
return resultList;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,167 +14,628 @@ export class DiyFormServiceImplService {
|
|||||||
* getPage
|
* getPage
|
||||||
*/
|
*/
|
||||||
async getPage(...args: any[]): Promise<any> {
|
async getPage(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const page: number = pageParam.getPage();
|
||||||
return null;
|
const limit: number = pageParam.getLimit();
|
||||||
|
|
||||||
|
const queryWrapper: QueryWrapper<DiyForm> = new QueryWrapper<>();
|
||||||
|
|
||||||
|
queryWrapper.eq("site_id", RequestUtils.siteId());
|
||||||
|
|
||||||
|
if (ObjectUtil.isNotEmpty(searchParam.getTitle())) {
|
||||||
|
queryWrapper.eq("title", searchParam.getTitle());
|
||||||
|
}
|
||||||
|
if (ObjectUtil.isNotEmpty(searchParam.getTitle())) {
|
||||||
|
queryWrapper.and(i => i.or(j => j.like("title", searchParam.getTitle()))
|
||||||
|
.or(j => j.like("page_title", searchParam.getTitle()))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (ObjectUtil.isNotEmpty(searchParam.getType())) {
|
||||||
|
queryWrapper.eq("type", searchParam.getType());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ObjectUtil.isNotEmpty(searchParam.getAddon())) {
|
||||||
|
queryWrapper.eq("addon", searchParam.getAddon());
|
||||||
|
}
|
||||||
|
|
||||||
|
queryWrapper.orderByDesc("form_id");
|
||||||
|
|
||||||
|
const iPage: IPage<DiyForm> = diyFormMapper.selectPage(new Page<>(page, limit), queryWrapper);
|
||||||
|
const list: DiyFormListVo[] = [];
|
||||||
|
for (const item of iPage.getRecords()) {
|
||||||
|
const vo: DiyFormListVo = new DiyFormListVo();
|
||||||
|
BeanUtils.copyProperties(item, vo);
|
||||||
|
list.add(vo);
|
||||||
|
}
|
||||||
|
return PageResult.build(page, limit, iPage.getTotal()).setData(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* getList
|
* getList
|
||||||
*/
|
*/
|
||||||
async getList(...args: any[]): Promise<any> {
|
async getList(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const queryWrapper: QueryWrapper<DiyForm> = new QueryWrapper<>();
|
||||||
return null;
|
|
||||||
|
queryWrapper.eq("site_id", RequestUtils.siteId());
|
||||||
|
|
||||||
|
if (ObjectUtil.isNotEmpty(searchParam.getTitle())) {
|
||||||
|
queryWrapper.eq("title", searchParam.getTitle());
|
||||||
|
}
|
||||||
|
if (ObjectUtil.isNotEmpty(searchParam.getTitle())) {
|
||||||
|
queryWrapper.and(i => i.or(j => j.like("title", searchParam.getTitle()))
|
||||||
|
.or(j => j.like("page_title", searchParam.getTitle()))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (ObjectUtil.isNotEmpty(searchParam.getType())) {
|
||||||
|
queryWrapper.eq("type", searchParam.getType());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ObjectUtil.isNotEmpty(searchParam.getAddon())) {
|
||||||
|
queryWrapper.eq("addon", searchParam.getAddon());
|
||||||
|
}
|
||||||
|
if (ObjectUtil.isNotEmpty(searchParam.getStatus())) {
|
||||||
|
queryWrapper.eq("status", searchParam.getStatus());
|
||||||
|
}
|
||||||
|
queryWrapper.orderByDesc("form_id");
|
||||||
|
const list: DiyForm[] = diyFormMapper.selectList(queryWrapper);
|
||||||
|
const voList: DiyFormListVo[] = [];
|
||||||
|
for (const item of list) {
|
||||||
|
const vo: DiyFormListVo = new DiyFormListVo();
|
||||||
|
BeanUtils.copyProperties(item, vo);
|
||||||
|
voList.add(vo);
|
||||||
|
}
|
||||||
|
return voList;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* getInfo
|
* getInfo
|
||||||
*/
|
*/
|
||||||
async getInfo(...args: any[]): Promise<any> {
|
async getInfo(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const model: DiyForm = diyFormMapper.selectOne(
|
||||||
return null;
|
new QueryWrapper<DiyForm>()
|
||||||
|
.eq("form_id", id)
|
||||||
|
.eq("site_id", RequestUtils.siteId()));
|
||||||
|
|
||||||
|
|
||||||
|
Assert.notNull(model, "万能表单不存在");
|
||||||
|
|
||||||
|
const vo: DiyFormInfoVo = new DiyFormInfoVo();
|
||||||
|
BeanUtils.copyProperties(model, vo);
|
||||||
|
return vo;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* getCount
|
* getCount
|
||||||
*/
|
*/
|
||||||
async getCount(...args: any[]): Promise<any> {
|
async getCount(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const queryWrapper: QueryWrapper<DiyForm> = new QueryWrapper<>();
|
||||||
return null;
|
|
||||||
|
queryWrapper.eq("site_id", RequestUtils.siteId());
|
||||||
|
if (ObjectUtil.isNotEmpty(searchParam.getType())) {
|
||||||
|
queryWrapper.eq("type", searchParam.getType());
|
||||||
|
}
|
||||||
|
const count: number = diyFormMapper.selectCount(queryWrapper);
|
||||||
|
if(ObjectUtil.isEmpty(count))
|
||||||
|
{
|
||||||
|
count = 0L;
|
||||||
|
}
|
||||||
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* add
|
* add
|
||||||
*/
|
*/
|
||||||
async add(...args: any[]): Promise<any> {
|
async add(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const model: DiyForm = new DiyForm();
|
||||||
return null;
|
|
||||||
|
model.setPageTitle(addParam.getPageTitle());
|
||||||
|
model.setTitle(addParam.getTitle());
|
||||||
|
model.setType(addParam.getType());
|
||||||
|
model.setStatus(1);
|
||||||
|
model.setTemplate(addParam.getTemplate());
|
||||||
|
model.setValue(addParam.getValue());
|
||||||
|
const diyFormTypeEnum: DiyFormTypeEnum = new DiyFormTypeEnum();
|
||||||
|
const type: Record<string, any> = diyFormTypeEnum.getType(addParam.getType());
|
||||||
|
if(type.containsKey("addon"))
|
||||||
|
{
|
||||||
|
model.setAddon(type.getStr("addon"));
|
||||||
|
}else{
|
||||||
|
model.setAddon("");
|
||||||
|
}
|
||||||
|
|
||||||
|
model.setShare(addParam.getShare());
|
||||||
|
model.setRemark(addParam.getRemark());
|
||||||
|
model.setSiteId(RequestUtils.siteId());
|
||||||
|
model.setCreateTime(System.currentTimeMillis() / 1000);
|
||||||
|
model.setUpdateTime(System.currentTimeMillis() / 1000);
|
||||||
|
diyFormMapper.insert(model);
|
||||||
|
const diyFormFields: DiyFormFields[] = [];
|
||||||
|
if (ObjectUtil.isNotEmpty(addParam.getValue())) {
|
||||||
|
const value: Record<string, any> = JSONUtil.parseObj(addParam.getValue());
|
||||||
|
const components: JSONArray = value.getJSONArray("value");
|
||||||
|
for (const componentObj of components) {
|
||||||
|
const component: Record<string, any> = JSONUtil.parseObj(componentObj);
|
||||||
|
const componentType: string = component.getStr("componentType");
|
||||||
|
const componentName: string = component.getStr("componentName");
|
||||||
|
if (!"diy_form" === componentType || "FormSubmit" === componentName) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
const field: Record<string, any> = component.getJSONObject("field");
|
||||||
|
|
||||||
|
const fieldRecord: DiyFormFields = new DiyFormFields();
|
||||||
|
fieldRecord.setSiteId(RequestUtils.siteId());
|
||||||
|
fieldRecord.setFormId(model.getFormId());
|
||||||
|
fieldRecord.setFieldKey(component.get("id").toString());
|
||||||
|
fieldRecord.setFieldType(componentName);
|
||||||
|
fieldRecord.setFieldName(field.containsKey("name") ? field.getStr("name") : "");
|
||||||
|
if(field.containsKey("remark"))
|
||||||
|
{
|
||||||
|
const remark: Record<string, any> = field.getJSONObject("remark");
|
||||||
|
if(remark.containsKey("text"))
|
||||||
|
{
|
||||||
|
fieldRecord.setFieldRemark(remark.getStr("text"));
|
||||||
|
}else{
|
||||||
|
fieldRecord.setFieldRemark("");
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
fieldRecord.setFieldRemark("");
|
||||||
|
}
|
||||||
|
fieldRecord.setFieldDefault(field.containsKey("default") ? field.get("default").toString() : "");
|
||||||
|
fieldRecord.setFieldRequired(field.containsKey("required") ? field.getInt("required") : 0);
|
||||||
|
fieldRecord.setFieldHidden(component.getInt("isHidden"));
|
||||||
|
fieldRecord.setFieldUnique(field.containsKey("unique") ? field.getInt("unique") : 0);
|
||||||
|
fieldRecord.setPrivacyProtection(field.containsKey("privacyProtection") ? field.getInt("privacyProtection") : 0);
|
||||||
|
fieldRecord.setCreateTime(System.currentTimeMillis() / 1000);
|
||||||
|
fieldRecord.setUpdateTime(System.currentTimeMillis() / 1000);
|
||||||
|
diyFormFields.add(fieldRecord);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!diyFormFields.length === 0) {
|
||||||
|
diyFormFieldsMapper.insert(diyFormFields);
|
||||||
|
}
|
||||||
|
|
||||||
|
const writeParam: DiyFormWriteConfigParam = new DiyFormWriteConfigParam();
|
||||||
|
writeParam.setSiteId(RequestUtils.siteId());
|
||||||
|
writeParam.setFormId(model.getFormId());
|
||||||
|
// 初始化表单填写配置
|
||||||
|
coreDiyFormConfigService.addWriteConfig(writeParam);
|
||||||
|
|
||||||
|
const submitConfigParam: DiyFormSubmitConfigParam = new DiyFormSubmitConfigParam();
|
||||||
|
submitConfigParam.setSiteId(RequestUtils.siteId());
|
||||||
|
submitConfigParam.setFormId(model.getFormId());
|
||||||
|
// 初始化表单提交成功页配置
|
||||||
|
coreDiyFormConfigService.addSubmitConfig(submitConfigParam);
|
||||||
|
|
||||||
|
return model.getFormId();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* edit
|
* edit
|
||||||
*/
|
*/
|
||||||
async edit(...args: any[]): Promise<any> {
|
async edit(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const model: DiyForm = diyFormMapper.selectOne(
|
||||||
return null;
|
new QueryWrapper<DiyForm>()
|
||||||
|
.eq("form_id", id)
|
||||||
|
.eq("site_id", RequestUtils.siteId()));
|
||||||
|
|
||||||
|
Assert.notNull(model, "万能表单不存在");
|
||||||
|
model.setTitle(editParam.getTitle());
|
||||||
|
model.setPageTitle(editParam.getPageTitle());
|
||||||
|
model.setTemplate(editParam.getTemplate());
|
||||||
|
model.setValue(editParam.getValue());
|
||||||
|
model.setUpdateTime(System.currentTimeMillis() / 1000);
|
||||||
|
diyFormMapper.updateById(model);
|
||||||
|
const formFieldsList: DiyFormFields[] = diyFormFieldsMapper.selectList(new QueryWrapper<DiyFormFields>().eq("form_id", id));
|
||||||
|
const formFieldsListMap: Record<string, any> = formFieldsList.stream().collect(Collectors.toMap(DiyFormFields::getFieldKey, a => a));
|
||||||
|
const existFieldKeys: string[] = [];
|
||||||
|
const diyFormFields: DiyFormFields[] = [];
|
||||||
|
if (ObjectUtil.isNotEmpty(editParam.getValue())) {
|
||||||
|
const value: Record<string, any> = JSONUtil.parseObj(editParam.getValue());
|
||||||
|
const components: JSONArray = value.getJSONArray("value");
|
||||||
|
for (const componentObj of components) {
|
||||||
|
const component: Record<string, any> = JSONUtil.parseObj(componentObj);
|
||||||
|
const componentType: string = component.getStr("componentType");
|
||||||
|
const componentName: string = component.getStr("componentName");
|
||||||
|
if (!"diy_form" === componentType || "FormSubmit" === componentName) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
const field: Record<string, any> = component.getJSONObject("field");
|
||||||
|
|
||||||
|
const fieldRecord: DiyFormFields = new DiyFormFields();
|
||||||
|
fieldRecord.setSiteId(RequestUtils.siteId());
|
||||||
|
fieldRecord.setFormId(model.getFormId());
|
||||||
|
fieldRecord.setFieldKey(component.get("id").toString());
|
||||||
|
fieldRecord.setFieldType(componentName);
|
||||||
|
fieldRecord.setFieldName(field.containsKey("name") ? field.getStr("name") : "");
|
||||||
|
if(field.containsKey("remark"))
|
||||||
|
{
|
||||||
|
const remark: Record<string, any> = field.getJSONObject("remark");
|
||||||
|
if(remark.containsKey("text"))
|
||||||
|
{
|
||||||
|
fieldRecord.setFieldRemark(remark.getStr("text"));
|
||||||
|
}else{
|
||||||
|
fieldRecord.setFieldRemark("");
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
fieldRecord.setFieldRemark("");
|
||||||
|
}
|
||||||
|
fieldRecord.setFieldDefault(field.containsKey("default") ? field.get("default").toString() : "");
|
||||||
|
fieldRecord.setFieldRequired(field.containsKey("required") ? field.getInt("required") : 0);
|
||||||
|
fieldRecord.setFieldHidden(component.getInt("isHidden"));
|
||||||
|
fieldRecord.setFieldUnique(field.containsKey("unique") ? field.getInt("unique") : 0);
|
||||||
|
fieldRecord.setPrivacyProtection(field.containsKey("privacyProtection") ? field.getInt("privacyProtection") : 0);
|
||||||
|
fieldRecord.setUpdateTime(System.currentTimeMillis() / 1000);
|
||||||
|
|
||||||
|
if(formFieldsListMap.containsKey(component.getStr("id")))
|
||||||
|
{
|
||||||
|
diyFormFieldsMapper.update(fieldRecord, new QueryWrapper<DiyFormFields>().eq("site_id", RequestUtils.siteId()).eq("field_id", formFieldsListMap.get(component.getStr("id")).getFieldId()));
|
||||||
|
existFieldKeys.add(component.getStr("id"));
|
||||||
|
}else{
|
||||||
|
diyFormFields.add(fieldRecord);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
if (!diyFormFields.length === 0) {
|
||||||
|
diyFormFieldsMapper.insert(diyFormFields);
|
||||||
|
}
|
||||||
|
for (Map.Entry<String, DiyFormFields> entry : formFieldsListMap.entrySet()) {
|
||||||
|
|
||||||
|
if(!existFieldKeys.includes(entry.getKey())) {
|
||||||
|
diyFormFieldsMapper.delete(new QueryWrapper<DiyFormFields>().eq("site_id", RequestUtils.siteId()).eq("field_id", entry.getValue().getFieldId()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
diyFormFieldsMapper.delete(new QueryWrapper<DiyFormFields>().eq("site_id", RequestUtils.siteId()).eq("form_id", model.getFormId()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* del
|
* del
|
||||||
*/
|
*/
|
||||||
async del(...args: any[]): Promise<any> {
|
async del(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const count: number = diyFormMapper.selectCount(new QueryWrapper<DiyForm>().in("form_id", formIds).eq("site_id", RequestUtils.siteId()).eq("status", 1));
|
||||||
return null;
|
if(count > 0){
|
||||||
|
throw new BadRequestException("存在正在使用的表单,无法删除");
|
||||||
|
}
|
||||||
|
//事件检测是否可以被删除
|
||||||
|
DiyFormDelBeforeEventDefiner.const event: DiyFormDelBeforeEvent = new DiyFormDelBeforeEventDefiner.DiyFormDelBeforeEvent();
|
||||||
|
for (const formId of formIds) {
|
||||||
|
event.setFormId(formId);
|
||||||
|
event.setSiteId(RequestUtils.siteId());
|
||||||
|
const result: DiyFormDelBeforeEventDefiner.DiyFromDelBeforeResult[] = EventAndSubscribeOfPublisher.publishAndCallback(event);
|
||||||
|
for (DiyFormDelBeforeEventDefiner.DiyFromDelBeforeResult res : result) {
|
||||||
|
if(ObjectUtil.isNotEmpty(res))
|
||||||
|
{
|
||||||
|
if(!res.getAllowOperate()) throw new BadRequestException("存在正在使用的表单,无法删除");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
diyFormMapper.delete(new QueryWrapper<DiyForm>().eq("site_id", RequestUtils.siteId()).in("form_id", formIds));
|
||||||
|
diyFormFieldsMapper.delete(new QueryWrapper<DiyFormFields>().eq("site_id", RequestUtils.siteId()).in("form_id", formIds));
|
||||||
|
diyFormSubmitConfigMapper.delete(new QueryWrapper<DiyFormSubmitConfig>().eq("site_id", RequestUtils.siteId()).in("form_id", formIds));
|
||||||
|
diyFormWriteConfigMapper.delete(new QueryWrapper<DiyFormWriteConfig>().eq("site_id", RequestUtils.siteId()).in("form_id", formIds));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* getInit
|
* getInit
|
||||||
*/
|
*/
|
||||||
async getInit(...args: any[]): Promise<any> {
|
async getInit(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const time: number = System.currentTimeMillis() / 1000;
|
||||||
return null;
|
const data: DiyFormInfoVo = new DiyFormInfoVo();
|
||||||
|
|
||||||
|
if (!params.getFormId() === 0) {
|
||||||
|
data = getInfo(params.getFormId());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ObjectUtil.isNotEmpty(data.getType())) {
|
||||||
|
const diyFormTypeEnum: DiyFormTypeEnum = new DiyFormTypeEnum();
|
||||||
|
const currentType: Record<string, any> = diyFormTypeEnum.getType(data.getType());
|
||||||
|
const typeName: string = currentType.getStr("title");
|
||||||
|
data.setTypeName(typeName);
|
||||||
|
} else {
|
||||||
|
if (ObjectUtil.isEmpty(params.getType())) {
|
||||||
|
throw new BadRequestException("DIY_FORM_TYPE_NOT_EXIST");
|
||||||
|
}
|
||||||
|
const type: string = params.getType();
|
||||||
|
|
||||||
|
// 新页面赋值
|
||||||
|
const pageTitle: string = params.getTitle() != null ? params.getTitle() : "表单页面" + time;
|
||||||
|
|
||||||
|
const diyFormTypeEnum: DiyFormTypeEnum = new DiyFormTypeEnum();
|
||||||
|
const currentType: Record<string, any> = diyFormTypeEnum.getType(params.getType());
|
||||||
|
const typeName: string = currentType.getStr("title");
|
||||||
|
const value: string = "";
|
||||||
|
|
||||||
|
data = new DiyFormInfoVo();
|
||||||
|
data.setFormId(0);
|
||||||
|
data.setPageTitle(pageTitle);
|
||||||
|
data.setTitle(typeName);
|
||||||
|
data.setType(type);
|
||||||
|
data.setTypeName(typeName);
|
||||||
|
data.setValue(value);
|
||||||
|
data.setStatus(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
const initVo: DiyFormInitVo = new DiyFormInitVo();
|
||||||
|
BeanUtils.copyProperties(data, initVo);
|
||||||
|
initVo.setComponent(getComponentList(data.getType()));
|
||||||
|
initVo.setDomainUrl(systemConfigService.getSceneDomain(RequestUtils.siteId()));
|
||||||
|
return initVo;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* modifyShare
|
* modifyShare
|
||||||
*/
|
*/
|
||||||
async modifyShare(...args: any[]): Promise<any> {
|
async modifyShare(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const diyForm: DiyForm = new DiyForm();
|
||||||
return null;
|
diyForm.setShare(share);
|
||||||
|
diyFormMapper.update(diyForm, new QueryWrapper<DiyForm>().eq("form_id", formId).eq("site_id", RequestUtils.siteId()));
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* getComponentList
|
* getComponentList
|
||||||
*/
|
*/
|
||||||
async getComponentList(...args: any[]): Promise<any> {
|
async getComponentList(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const formComponentEunm: DiyFormComponentEnum = new DiyFormComponentEnum();
|
||||||
return null;
|
const formComponentList: Record<string, any> = formComponentEunm.getComponent();
|
||||||
|
for (const formComponentObj of formComponentList.keySet()) {
|
||||||
|
const formComponent: Record<string, any> = formComponentList.getJSONObject(formComponentObj);
|
||||||
|
const list: Record<string, any> = formComponent.getJSONObject("list");
|
||||||
|
Iterator<Map.const iterator: Entry<String, Object>> = list.entrySet().iterator();
|
||||||
|
while (iterator.hasNext()) {
|
||||||
|
const cv: Record<string, any> = JSONUtil.parseObj(iterator.next());
|
||||||
|
if(cv.containsKey("support"))
|
||||||
|
{
|
||||||
|
const support: JSONArray = cv.getJSONArray("support");
|
||||||
|
if (support != null && support.size() > 0 && !support.includes(type)) {
|
||||||
|
iterator.remove();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
cv.remove("sort");
|
||||||
|
cv.remove("support");
|
||||||
|
}
|
||||||
|
// 根据 sort 排序
|
||||||
|
formComponent.put("list", sortJSONObjectBySortField(list));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
componentType(formComponentList, "diy_form");
|
||||||
* compare
|
|
||||||
*/
|
const data: Record<string, any> = formComponentList;
|
||||||
async compare(...args: any[]): Promise<any> {
|
if ("DIY_FORM" === type) {
|
||||||
// TODO: 实现业务逻辑
|
const diyComponentList: Record<string, any> = diyService.getComponentList("");
|
||||||
return null;
|
componentType(diyComponentList, "diy");
|
||||||
|
data = mergeJsonObjects(formComponentList, diyComponentList);;
|
||||||
|
}
|
||||||
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* getPageData
|
* getPageData
|
||||||
*/
|
*/
|
||||||
async getPageData(...args: any[]): Promise<any> {
|
async getPageData(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
return ObjectUtil.defaultIfNull(PagesEnum.getPages(type, name), new Record<string, any>());
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* copy
|
* copy
|
||||||
*/
|
*/
|
||||||
async copy(...args: any[]): Promise<any> {
|
async copy(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const diyForm: DiyForm = diyFormMapper.selectOne(new QueryWrapper<DiyForm>().eq("form_id", formId).eq("site_id", RequestUtils.siteId()));
|
||||||
return null;
|
if(ObjectUtil.isEmpty(diyForm)) throw new BadRequestException("万能表单不存在");
|
||||||
|
const diyFormSubmitConfig: DiyFormSubmitConfig = diyFormSubmitConfigMapper.selectOne(new QueryWrapper<DiyFormSubmitConfig>().eq("form_id", formId));
|
||||||
|
const diyFormWriteConfig: DiyFormWriteConfig = diyFormWriteConfigMapper.selectOne(new QueryWrapper<DiyFormWriteConfig>().eq("form_id", formId));
|
||||||
|
const diyFormFields: DiyFormFields[] = diyFormFieldsMapper.selectList(new QueryWrapper<DiyFormFields>().eq("form_id", formId));
|
||||||
|
|
||||||
|
// 复制表单信息
|
||||||
|
const newDiyForm: DiyForm = new DiyForm();
|
||||||
|
BeanUtils.copyProperties(diyForm, newDiyForm);
|
||||||
|
newDiyForm.setFormId(null); // 清空原有的 form_id,让数据库自动生成新的
|
||||||
|
newDiyForm.setPageTitle(newDiyForm.getPageTitle() + "_副本");
|
||||||
|
newDiyForm.setStatus(0);
|
||||||
|
newDiyForm.setShare("");
|
||||||
|
newDiyForm.setWriteNum(0);
|
||||||
|
const currentTime: number = System.currentTimeMillis() / 1000;
|
||||||
|
newDiyForm.setCreateTime(currentTime);
|
||||||
|
newDiyForm.setUpdateTime(currentTime);
|
||||||
|
|
||||||
|
// 插入新的表单信息
|
||||||
|
diyFormMapper.insert(newDiyForm);
|
||||||
|
const newFormId: number = newDiyForm.getFormId();
|
||||||
|
|
||||||
|
// 复制表单字段
|
||||||
|
if (!ObjectUtil.isEmpty(diyFormFields)) {
|
||||||
|
const newFormFieldList: DiyFormFields[] = [];
|
||||||
|
for (const item of diyFormFields) {
|
||||||
|
const newField: DiyFormFields = new DiyFormFields();
|
||||||
|
BeanUtils.copyProperties(item, newField);
|
||||||
|
newField.setFieldId(null); // 清空原有的 field_id,让数据库自动生成新的
|
||||||
|
newField.setFormId(newFormId);
|
||||||
|
newField.setWriteNum(0);
|
||||||
|
newField.setCreateTime(currentTime);
|
||||||
|
newField.setUpdateTime(currentTime);
|
||||||
|
newFormFieldList.add(newField);
|
||||||
|
}
|
||||||
|
const mybatisBatch: MybatisBatch<DiyFormFields> = new MybatisBatch<>(sqlSessionFactory, newFormFieldList);
|
||||||
|
MybatisBatch.const method: Method<DiyFormFields> = new MybatisBatch.Method<>(DiyFormFieldsMapper.class);
|
||||||
|
mybatisBatch.execute(method.insert());
|
||||||
|
}
|
||||||
|
|
||||||
|
// 复制填写配置
|
||||||
|
if (!ObjectUtil.isEmpty(diyFormWriteConfig)) {
|
||||||
|
const newWriteConfig: DiyFormWriteConfigParam = new DiyFormWriteConfigParam();
|
||||||
|
BeanUtils.copyProperties(diyFormWriteConfig, newWriteConfig);
|
||||||
|
newWriteConfig.setFormId(newFormId);
|
||||||
|
newWriteConfig.setId(null);
|
||||||
|
coreDiyFormConfigService.addWriteConfig(newWriteConfig);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 复制提交配置
|
||||||
|
if (!ObjectUtil.isEmpty(diyFormSubmitConfig)) {
|
||||||
|
const newSubmitConfig: DiyFormSubmitConfigParam = new DiyFormSubmitConfigParam();
|
||||||
|
BeanUtils.copyProperties(diyFormSubmitConfig, newSubmitConfig);
|
||||||
|
newSubmitConfig.setFormId(newFormId);
|
||||||
|
newSubmitConfig.setId(null);
|
||||||
|
coreDiyFormConfigService.addSubmitConfig(newSubmitConfig);
|
||||||
|
}
|
||||||
|
|
||||||
|
return newFormId;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* getTemplate
|
* getTemplate
|
||||||
*/
|
*/
|
||||||
async getTemplate(...args: any[]): Promise<any> {
|
async getTemplate(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const diyFormTemplateEnum: DiyFormTemplateEnum = new DiyFormTemplateEnum();
|
||||||
return null;
|
return diyFormTemplateEnum.getTemplate(params.getType(), params.getTemplateKey());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* getFormType
|
* getFormType
|
||||||
*/
|
*/
|
||||||
async getFormType(...args: any[]): Promise<any> {
|
async getFormType(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const types: DiyFormTypeEnum = new DiyFormTypeEnum();
|
||||||
return null;
|
return types.getType();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* modifyStatus
|
* modifyStatus
|
||||||
*/
|
*/
|
||||||
async modifyStatus(...args: any[]): Promise<any> {
|
async modifyStatus(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const diyForm: DiyForm = new DiyForm();
|
||||||
return null;
|
diyForm.setStatus(formStatusParam.getStatus());
|
||||||
|
diyFormMapper.update(diyForm, new QueryWrapper<DiyForm>().eq("form_id", formStatusParam.getFormId()).eq("site_id", RequestUtils.siteId()));
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* getRecordPages
|
* getRecordPages
|
||||||
*/
|
*/
|
||||||
async getRecordPages(...args: any[]): Promise<any> {
|
async getRecordPages(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
searchParam.setSiteId(RequestUtils.siteId());
|
||||||
return null;
|
return coreDiyFormRecordsService.page(pageParam, searchParam);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* getRecordInfo
|
* getRecordInfo
|
||||||
*/
|
*/
|
||||||
async getRecordInfo(...args: any[]): Promise<any> {
|
async getRecordInfo(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
return coreDiyFormRecordsService.info(recordId);
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* delRecord
|
* delRecord
|
||||||
*/
|
*/
|
||||||
async delRecord(...args: any[]): Promise<any> {
|
async delRecord(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
try {
|
||||||
return null;
|
// 减少填写数量
|
||||||
|
const formQueryWrapper: QueryWrapper<DiyForm> = new QueryWrapper<>();
|
||||||
|
formQueryWrapper.eq("form_id", formId);
|
||||||
|
const diyForm: DiyForm = diyFormMapper.selectOne(formQueryWrapper);
|
||||||
|
if (diyForm != null) {
|
||||||
|
diyForm.setWriteNum(diyForm.getWriteNum() - 1);
|
||||||
|
diyFormMapper.updateById(diyForm);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 删除记录
|
||||||
|
const recordsQueryWrapper: QueryWrapper<DiyFormRecords> = new QueryWrapper<>();
|
||||||
|
recordsQueryWrapper.eq("site_id", RequestUtils.siteId())
|
||||||
|
.eq("record_id", recordId);
|
||||||
|
diyFormRecordsMapper.delete(recordsQueryWrapper);
|
||||||
|
|
||||||
|
// 删除万能表单填写字段
|
||||||
|
const fieldsQueryWrapper: QueryWrapper<DiyFormRecordsFields> = new QueryWrapper<>();
|
||||||
|
fieldsQueryWrapper.eq("site_id", RequestUtils.siteId())
|
||||||
|
.eq("record_id", recordId);
|
||||||
|
diyFormRecordsFieldsMapper.delete(fieldsQueryWrapper);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
} catch (Exception e) {
|
||||||
|
// 事务会自动回滚,因为使用了 @Transactional 注解
|
||||||
|
throw new BadRequestException("删除记录失败: " + e.getMessage());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* getFieldsList
|
* getFieldsList
|
||||||
*/
|
*/
|
||||||
async getFieldsList(...args: any[]): Promise<any> {
|
async getFieldsList(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const queryWrapper: QueryWrapper<DiyFormFields> = new QueryWrapper<>();
|
||||||
return null;
|
queryWrapper.eq("site_id", RequestUtils.siteId())
|
||||||
|
.eq("form_id", diyFormRecordsFieldsSearchParam.getFormId());
|
||||||
|
if(diyFormRecordsFieldsSearchParam.getSort() === "asc")
|
||||||
|
{
|
||||||
|
queryWrapper.orderByAsc(diyFormRecordsFieldsSearchParam.getOrder());
|
||||||
|
}else {
|
||||||
|
queryWrapper.orderByDesc(diyFormRecordsFieldsSearchParam.getOrder());
|
||||||
|
}
|
||||||
|
const list: DiyFormFields[] = diyFormFieldsMapper.selectList(queryWrapper);
|
||||||
|
const listVo: DiyFormFieldsListVo[] = [];
|
||||||
|
for (const item of list) {
|
||||||
|
const vo: DiyFormFieldsListVo = new DiyFormFieldsListVo();
|
||||||
|
BeanUtils.copyProperties(item, vo);
|
||||||
|
listVo.add(vo);
|
||||||
|
}
|
||||||
|
return listVo;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* getSelectPage
|
* getSelectPage
|
||||||
*/
|
*/
|
||||||
async getSelectPage(...args: any[]): Promise<any> {
|
async getSelectPage(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const page: number = pageParam.getPage();
|
||||||
return null;
|
const limit: number = pageParam.getLimit();
|
||||||
|
// 验证表单ID集合
|
||||||
|
const verifyFormIds: number[] = [];
|
||||||
|
if (param.getVerifyFormIds() != null && !param.getVerifyFormIds().isEmpty()) {
|
||||||
|
// 查询存在的表单const existForms: ID
|
||||||
|
List<DiyForm> = diyFormMapper.selectList(
|
||||||
|
new QueryWrapper<DiyForm>()
|
||||||
|
.select("form_id")
|
||||||
|
.in("form_id", param.getVerifyFormIds())
|
||||||
|
);
|
||||||
|
|
||||||
|
verifyFormIds = existForms.stream()
|
||||||
|
.map(DiyForm::getFormId)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
// 构建查询条件
|
||||||
|
const queryWrapper: LambdaQueryWrapper<DiyForm> = new LambdaQueryWrapper<>();
|
||||||
|
queryWrapper.eq(DiyForm::getSiteId, RequestUtils.siteId())
|
||||||
|
.eq(DiyForm::getStatus, 1)
|
||||||
|
.orderByDesc(DiyForm::getFormId);
|
||||||
|
|
||||||
|
// 添加搜索条件
|
||||||
|
if (StringUtils.hasText(param.getTitle())) {
|
||||||
|
queryWrapper.like(DiyForm::getTitle, param.getTitle());
|
||||||
|
}
|
||||||
|
if (StringUtils.hasText(param.getType())) {
|
||||||
|
queryWrapper.eq(DiyForm::getType, param.getType());
|
||||||
|
}
|
||||||
|
if (StringUtils.hasText(param.getAddon())) {
|
||||||
|
queryWrapper.eq(DiyForm::getAddon, param.getAddon());
|
||||||
|
}
|
||||||
|
|
||||||
|
// 分页查询
|
||||||
|
const formPage: IPage<DiyForm> = diyFormMapper.selectPage(new Page<>(page, limit), queryWrapper);
|
||||||
|
|
||||||
|
if (formPage.getTotal() == 0){
|
||||||
|
return PageResult.build(page, limit, 0, []);
|
||||||
|
}
|
||||||
|
const resultList: DiyFormInfoVo[] = [];
|
||||||
|
formPage.getRecords().forEach(item => {
|
||||||
|
const diyFormInfoVo: DiyFormInfoVo = new DiyFormInfoVo();
|
||||||
|
BeanUtils.copyProperties(item, diyFormInfoVo);
|
||||||
|
const currentType: Record<string, any> = new DiyFormTypeEnum().getType(item.getType());
|
||||||
|
const typeName: string = currentType.getStr("title");
|
||||||
|
diyFormInfoVo.setTypeName(typeName);
|
||||||
|
const addon: Addon = addonMapper.selectOne(new LambdaQueryWrapper<Addon>().eq(Addon::getKey, item.getAddon()));
|
||||||
|
const addonName: string = ObjectUtil.isNotEmpty(addon) ? addon.getTitle() : "";
|
||||||
|
diyFormInfoVo.setAddonName(addonName);
|
||||||
|
resultList.add(diyFormInfoVo);
|
||||||
|
});
|
||||||
|
return PageResult.build(page, limit, formPage.getTotal(), resultList);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ export class GenerateColumnServiceImplService {
|
|||||||
* insertAll
|
* insertAll
|
||||||
*/
|
*/
|
||||||
async insertAll(...args: any[]): Promise<any> {
|
async insertAll(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
super.saveOrUpdateBatch(list);
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,79 +14,384 @@ export class GenerateServiceImplService {
|
|||||||
* getPage
|
* getPage
|
||||||
*/
|
*/
|
||||||
async getPage(...args: any[]): Promise<any> {
|
async getPage(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const page: number = pageParam.getPage();
|
||||||
return null;
|
const limit: number = pageParam.getLimit();
|
||||||
|
|
||||||
|
const queryWrapper: MPJQueryWrapper<GenerateTable> = new MPJQueryWrapper<>();
|
||||||
|
queryWrapper.setAlias("ngt");
|
||||||
|
queryWrapper.select("ngt.id, ngt.table_name, ngt.table_content, ngt.module_name, ngt.class_name, ngt.create_time, ngt.edit_type, ngt.addon_name, ngt.order_type, ngt.parent_menu, ngt.relations, ngt.synchronous_number, na.title, na.`key`");
|
||||||
|
queryWrapper.leftJoin("?_addon na ON na.`key` = ngt.addon_name".replace("?_", this.config.get('tablePrefix')));
|
||||||
|
if (ObjectUtil.isNotEmpty(searchParam.getTableName())) {
|
||||||
|
queryWrapper.like("ngt.table_name", searchParam.getTableName());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ObjectUtil.isNotEmpty(searchParam.getTableContent())) {
|
||||||
|
queryWrapper.eq("ngt.table_content", searchParam.getTableContent());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ObjectUtil.isNotEmpty(searchParam.getAddonName())) {
|
||||||
|
if (searchParam.getAddonName() === "2") {
|
||||||
|
queryWrapper.eq("ngt.addon_name", "");
|
||||||
|
} else {
|
||||||
|
queryWrapper.like("ngt.addon_name", searchParam.getAddonName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
queryWrapper.orderByDesc("ngt.create_time");
|
||||||
|
|
||||||
|
const iPage: IPage<GenerateListVo> = generateTableMapper.selectJoinPage(new Page<>(page, limit), GenerateListVo.class, queryWrapper);
|
||||||
|
return PageResult.build(iPage);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* getInfo
|
* getInfo
|
||||||
*/
|
*/
|
||||||
async getInfo(...args: any[]): Promise<any> {
|
async getInfo(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const generateTable: GenerateTable = generateTableMapper.selectById(id);
|
||||||
return null;
|
if (ObjectUtil.isEmpty(generateTable)) throw new AdminException("生成表不存在");
|
||||||
|
const vo: GenerateDetailVo = new GenerateDetailVo();
|
||||||
|
BeanUtils.copyProperties(generateTable, vo);
|
||||||
|
|
||||||
|
if (vo.getOrderType() != 0) {
|
||||||
|
const orderColumn: GenerateColumn = generateColumnMapper.selectOne(new QueryWrapper<GenerateColumn>().eq("table_id", id).eq("is_order", 1));
|
||||||
|
if (ObjectUtil.isNotEmpty(orderColumn)) {
|
||||||
|
vo.setOrderColumnName(orderColumn.getColumnName());
|
||||||
|
} else {
|
||||||
|
vo.setOrderColumnName("");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const deleteColumn: GenerateColumn = generateColumnMapper.selectOne(new QueryWrapper<GenerateColumn>().eq("table_id", id).eq("is_delete", 1));
|
||||||
|
if (ObjectUtil.isNotEmpty(deleteColumn)) {
|
||||||
|
vo.setDeleteColumnName(deleteColumn.getColumnName());
|
||||||
|
vo.setIsDelete(1);
|
||||||
|
} else {
|
||||||
|
vo.setDeleteColumnName("");
|
||||||
|
vo.setIsDelete(0);
|
||||||
|
}
|
||||||
|
const columnList: GenerateColumn[] = generateColumnMapper.selectList(new QueryWrapper<GenerateColumn>().eq("table_id", id));
|
||||||
|
if (ObjectUtil.isNotEmpty(columnList)) {
|
||||||
|
const columnVoList: GenerateColumnVo[] = [];
|
||||||
|
for (const column of columnList) {
|
||||||
|
const generateColumnVo: GenerateColumnVo = new GenerateColumnVo();
|
||||||
|
BeanUtils.copyProperties(column, generateColumnVo);
|
||||||
|
if (column.getViewType() === "number") {
|
||||||
|
if (!column.getValidateType().isEmpty()) {
|
||||||
|
if (column.getValidateType().startsWith("[")) {
|
||||||
|
const numValidate: JSONArray = JSONUtil.parseArray(column.getValidateType());
|
||||||
|
if (numValidate.get(0).toString() === "between") {
|
||||||
|
generateColumnVo.setViewMax(JSONUtil.parseArray(numValidate.get(1)).get(1).toString());
|
||||||
|
generateColumnVo.setViewMin(JSONUtil.parseArray(numValidate.get(1)).get(0).toString());
|
||||||
|
} else if (numValidate.get(0).toString() === "max") {
|
||||||
|
generateColumnVo.setViewMax(JSONUtil.parseArray(numValidate.get(1)).get(0).toString());
|
||||||
|
} else if (numValidate.get(0).toString() === "min") {
|
||||||
|
generateColumnVo.setViewMin(JSONUtil.parseArray(numValidate.get(1)).get(0).toString());
|
||||||
|
} else {
|
||||||
|
generateColumnVo.setViewMax("100");
|
||||||
|
generateColumnVo.setViewMin("0");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
generateColumnVo.setViewMax("100");
|
||||||
|
generateColumnVo.setViewMin("0");
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
generateColumnVo.setViewMax("100");
|
||||||
|
generateColumnVo.setViewMin("0");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
generateColumnVo.setViewMax("");
|
||||||
|
generateColumnVo.setViewMin("");
|
||||||
|
}
|
||||||
|
if (!column.getValidateType().isEmpty()) {
|
||||||
|
if (column.getValidateType().startsWith("[")) {
|
||||||
|
const num1Validate: JSONArray = JSONUtil.parseArray(column.getValidateType());
|
||||||
|
if (num1Validate.get(0).toString() === "between") {
|
||||||
|
generateColumnVo.setMaxNumber(JSONUtil.parseArray(num1Validate.get(1)).get(1).toString());
|
||||||
|
generateColumnVo.setMinNumber(JSONUtil.parseArray(num1Validate.get(1)).get(0).toString());
|
||||||
|
} else if (num1Validate.get(0).toString() === "max") {
|
||||||
|
generateColumnVo.setMaxNumber(JSONUtil.parseArray(num1Validate.get(1)).get(0).toString());
|
||||||
|
} else if (num1Validate.get(0).toString() === "min") {
|
||||||
|
generateColumnVo.setMinNumber(JSONUtil.parseArray(num1Validate.get(1)).get(0).toString());
|
||||||
|
} else {
|
||||||
|
generateColumnVo.setMaxNumber("120");
|
||||||
|
generateColumnVo.setMinNumber("1");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
generateColumnVo.setMaxNumber("120");
|
||||||
|
generateColumnVo.setMinNumber("1");
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
generateColumnVo.setMaxNumber("120");
|
||||||
|
generateColumnVo.setMinNumber("1");
|
||||||
|
}
|
||||||
|
if (!column.getModel().isEmpty()) {
|
||||||
|
generateColumnVo.setSelectType(2);
|
||||||
|
} else {
|
||||||
|
generateColumnVo.setSelectType(1);
|
||||||
|
}
|
||||||
|
columnVoList.add(generateColumnVo);
|
||||||
|
}
|
||||||
|
vo.setTableColumn(columnVoList);
|
||||||
|
}
|
||||||
|
return vo;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* add
|
* add
|
||||||
*/
|
*/
|
||||||
async add(...args: any[]): Promise<any> {
|
async add(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const sql: string = "SHOW TABLE STATUS WHERE 1=1 ";
|
||||||
return null;
|
const tablePrefix: string = this.config.get('tablePrefix');
|
||||||
|
if (!generateParam.getTableName().isEmpty()) {
|
||||||
|
sql += " const Name: AND = '" + generateParam.getTableName() + "'";
|
||||||
|
}
|
||||||
|
const listData: Record<string, any>[] = jdbcTemplate.queryForList(sql);
|
||||||
|
if (ObjectUtil.isEmpty(listData)) throw new AdminException("数据表不存在");
|
||||||
|
const table: Record<string, any> = listData.get(0);
|
||||||
|
if (ObjectUtil.isEmpty(table)) throw new AdminException("数据表不存在");
|
||||||
|
const tableName: string = table.get("Name").toString().substring(tablePrefix.length());
|
||||||
|
|
||||||
|
//添加生成表数据
|
||||||
|
const generateTable: GenerateTable = new GenerateTable();
|
||||||
|
generateTable.setTableName(tableName);
|
||||||
|
generateTable.setTableContent(table.get("Comment").toString());
|
||||||
|
generateTable.setClassName(tableName);
|
||||||
|
generateTable.setCreateTime(System.currentTimeMillis() / 1000);
|
||||||
|
generateTable.setModuleName(tableName);
|
||||||
|
generateTableMapper.insert(generateTable);
|
||||||
|
|
||||||
|
//添加生成字段数据
|
||||||
|
const columns: Record<string, any>[] = jdbcTemplate.queryForList("SELECT * FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = (SELECT DATABASE()) and TABLE_NAME='" + tablePrefix + tableName + "'");
|
||||||
|
const id: number = generateTable.getId();
|
||||||
|
const list: GenerateColumn[] = [];
|
||||||
|
for (const column of columns) {
|
||||||
|
const generateColumn: GenerateColumn = new GenerateColumn();
|
||||||
|
|
||||||
|
generateColumn.setIsRequired(0);
|
||||||
|
String[] defaultColumn = {"id", "create_time", "update_time"};
|
||||||
|
if (column.get("IS_NULLABLE").toString() === "NO" && !column.get("COLUMN_KEY") === "PRI" && Arrays.asList(defaultColumn).includes(column.get("COLUMN_NAME").toString())) {
|
||||||
|
generateColumn.setIsRequired(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
generateColumn.setTableId(id);
|
||||||
|
generateColumn.setColumnName(column.get("COLUMN_NAME").toString());
|
||||||
|
generateColumn.setColumnType(getDbFieldType(column.get("DATA_TYPE").toString()));
|
||||||
|
if (generateColumn.getColumnType() === "number" && generateColumn.getColumnName().includes("time")) {
|
||||||
|
generateColumn.setColumnType("number");
|
||||||
|
}
|
||||||
|
generateColumn.setColumnComment(column.get("COLUMN_COMMENT").toString());
|
||||||
|
generateColumn.setIsPk(column.get("COLUMN_KEY") === "PRI" ? 1 : 0);
|
||||||
|
generateColumn.setIsInsert(Arrays.asList(defaultColumn).includes(column.get("COLUMN_NAME").toString()) ? 0 : 1);
|
||||||
|
generateColumn.setIsUpdate(Arrays.asList(defaultColumn).includes(column.get("COLUMN_NAME").toString()) ? 0 : 1);
|
||||||
|
generateColumn.setIsLists(Arrays.asList(defaultColumn).includes(column.get("COLUMN_NAME").toString()) ? 0 : 1);
|
||||||
|
generateColumn.setIsDelete(0);
|
||||||
|
generateColumn.setQueryType("=");
|
||||||
|
generateColumn.setViewType("input");
|
||||||
|
generateColumn.setDictType("");
|
||||||
|
generateColumn.setAddon("");
|
||||||
|
generateColumn.setModel("");
|
||||||
|
generateColumn.setLabelKey("");
|
||||||
|
generateColumn.setValueKey("");
|
||||||
|
generateColumn.setCreateTime(System.currentTimeMillis() / 1000);
|
||||||
|
generateColumn.setUpdateTime(System.currentTimeMillis() / 1000);
|
||||||
|
list.add(generateColumn);
|
||||||
|
|
||||||
|
}
|
||||||
|
generateColumnService.insertAll(list);
|
||||||
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* edit
|
* edit
|
||||||
*/
|
*/
|
||||||
async edit(...args: any[]): Promise<any> {
|
async edit(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
//添加生成表数据
|
||||||
return null;
|
const generateTable: GenerateTable = new GenerateTable();
|
||||||
|
generateTable.setId(id);
|
||||||
|
generateTable.setTableName(generateParam.getTableName());
|
||||||
|
generateTable.setTableContent(generateParam.getTableContent());
|
||||||
|
generateTable.setModuleName(generateParam.getModuleName());
|
||||||
|
generateTable.setClassName(generateParam.getClassName());
|
||||||
|
generateTable.setEditType(generateParam.getEditType());
|
||||||
|
generateTable.setAddonName(generateParam.getAddonName());
|
||||||
|
generateTable.setOrderType(generateParam.getOrderType());
|
||||||
|
generateTable.setParentMenu(generateParam.getParentMenu());
|
||||||
|
generateTable.setRelations(generateParam.getRelations());
|
||||||
|
generateTableMapper.updateById(generateTable);
|
||||||
|
//更新表字段
|
||||||
|
generateColumnMapper.delete(new QueryWrapper<GenerateColumn>().eq("table_id", id));
|
||||||
|
const columns: JSONArray = JSONUtil.parseArray(generateParam.getTableColumn());
|
||||||
|
const list: GenerateColumn[] = [];
|
||||||
|
|
||||||
|
for (const i of number = 0; i < columns.size(); i++) {
|
||||||
|
const generateColumn: GenerateColumn = new GenerateColumn();
|
||||||
|
const column: Record<string, any> = columns.getJSONObject(i);
|
||||||
|
generateColumn.setTableId(id);
|
||||||
|
generateColumn.setColumnName(column.getStr("column_name"));
|
||||||
|
generateColumn.setColumnComment(column.getStr("column_comment"));
|
||||||
|
generateColumn.setIsPk(column.getInt("is_pk"));
|
||||||
|
generateColumn.setIsRequired(column.getInt("is_required"));
|
||||||
|
generateColumn.setIsInsert(column.getInt("is_insert"));
|
||||||
|
generateColumn.setIsUpdate(column.getInt("is_update"));
|
||||||
|
generateColumn.setIsLists(column.getInt("is_lists"));
|
||||||
|
generateColumn.setIsSearch(column.getInt("is_search"));
|
||||||
|
generateColumn.setIsDelete(0);
|
||||||
|
generateColumn.setIsOrder(0);
|
||||||
|
generateColumn.setQueryType(column.getStr("query_type"));
|
||||||
|
generateColumn.setViewType(ObjectUtil.isEmpty(column.getStr("view_type")) ? "input" : column.getStr("view_type"));
|
||||||
|
generateColumn.setDictType(ObjectUtil.isEmpty(column.getStr("dict_type")) ? "" : column.getStr("dict_type"));
|
||||||
|
generateColumn.setAddon(ObjectUtil.isEmpty(column.getStr("addon")) ? "" : column.getStr("addon"));
|
||||||
|
generateColumn.setModel(ObjectUtil.isEmpty(column.getStr("model")) ? "" : column.getStr("model"));
|
||||||
|
generateColumn.setLabelKey(ObjectUtil.isEmpty(column.getStr("label_key")) ? "" : column.getStr("label_key"));
|
||||||
|
generateColumn.setValueKey(ObjectUtil.isEmpty(column.getStr("value_key")) ? "" : column.getStr("value_key"));
|
||||||
|
generateColumn.setUpdateTime(System.currentTimeMillis() / 1000);
|
||||||
|
generateColumn.setCreateTime(System.currentTimeMillis() / 1000);
|
||||||
|
generateColumn.setColumnType(ObjectUtil.isEmpty(column.getStr("column_type")) ? "String" : column.getStr("column_type"));
|
||||||
|
generateColumn.setValidateType(ObjectUtil.isEmpty(column.getStr("validate_type")) ? "" : column.getStr("validate_type"));
|
||||||
|
//传入字段rule暂时不知含义,待定
|
||||||
|
|
||||||
|
if (generateParam.getIsDelete() == 1) {
|
||||||
|
if (column.getStr("column_name") === generateParam.getDeleteColumnName()) {
|
||||||
|
generateColumn.setIsDelete(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (generateParam.getOrderType() != 0) {
|
||||||
|
if (column.getStr("column_name") === generateParam.getOrderColumnName()) {
|
||||||
|
generateColumn.setIsOrder(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ObjectUtil.isNotEmpty(column.getStr("validate_type")) && !column.getStr("view_type") === "number") {
|
||||||
|
if (column.getStr("validate_type") === "between") {
|
||||||
|
const jsonArray: JSONArray = new JSONArray();
|
||||||
|
jsonArray.add("between");
|
||||||
|
jsonArray.add(new String[]{column.getStr("min_number"), column.getStr("max_number")});
|
||||||
|
generateColumn.setValidateType(jsonArray.toString());
|
||||||
|
} else if (column.getStr("validate_type") === "max") {
|
||||||
|
const jsonArray: JSONArray = new JSONArray();
|
||||||
|
jsonArray.add("max");
|
||||||
|
jsonArray.add(new String[]{column.getStr("max_number")});
|
||||||
|
generateColumn.setValidateType(jsonArray.toString());
|
||||||
|
} else if (column.getStr("validate_type") === "min") {
|
||||||
|
const jsonArray: JSONArray = new JSONArray();
|
||||||
|
jsonArray.add("min");
|
||||||
|
jsonArray.add(new String[]{column.getStr("min_number")});
|
||||||
|
generateColumn.setValidateType(jsonArray.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (column.getStr("view_type") === "number") {
|
||||||
|
const numJsonArray: JSONArray = new JSONArray();
|
||||||
|
numJsonArray.add("between");
|
||||||
|
numJsonArray.add(new String[]{column.getStr("view_min"), column.getStr("view_max")});
|
||||||
|
generateColumn.setValidateType(numJsonArray.toString());
|
||||||
|
}
|
||||||
|
if (ObjectUtil.isNotEmpty(column.getStr("model"))) {
|
||||||
|
generateColumn.setDictType("");
|
||||||
|
}
|
||||||
|
list.add(generateColumn);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
generateColumnService.insertAll(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* del
|
* del
|
||||||
*/
|
*/
|
||||||
async del(...args: any[]): Promise<any> {
|
async del(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
generateTableMapper.deleteById(id);
|
||||||
return null;
|
generateColumnMapper.delete(new QueryWrapper<GenerateColumn>().eq("table_id", id));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* generate
|
* generate
|
||||||
*/
|
*/
|
||||||
async generate(...args: any[]): Promise<any> {
|
async generate(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const generateTable: GenerateTable = generateTableMapper.selectById(generateCodeParam.getId());
|
||||||
return null;
|
const columnList: GenerateColumn[] = generateColumnMapper.selectList(new QueryWrapper<GenerateColumn>().eq("table_id", generateCodeParam.getId()));
|
||||||
|
const coreGenerateService: CoreGenerateService = new CoreGenerateService();
|
||||||
|
const list: CoreGenerateTemplateVo[] = coreGenerateService.generateCode(generateTable, columnList);
|
||||||
|
|
||||||
|
// 下载
|
||||||
|
if (generateCodeParam.getGenerateType() === "2") {
|
||||||
|
const tempDir: string = this.config.get('webRootDownResource') + "upload/generate/";
|
||||||
|
const packageDir: string = tempDir + "package/";
|
||||||
|
FileTools.createDirs(packageDir);
|
||||||
|
FileUtil.clean(tempDir);
|
||||||
|
for (const coreGenerateTemplateVo of list) {
|
||||||
|
FileTools.createDirs(packageDir + coreGenerateTemplateVo.getPath());
|
||||||
|
FileUtil.writeUtf8String(coreGenerateTemplateVo.getData(), packageDir + coreGenerateTemplateVo.getPath(, coreGenerateTemplateVo.getFileName()));
|
||||||
|
}
|
||||||
|
const zipFile: string = ZipUtil.zip(packageDir, tempDir + "package.zip");
|
||||||
|
} else {
|
||||||
|
// 同步
|
||||||
|
if (!this.config.get('envType') === "dev") throw new BadRequestException("只有在开发模式下才能进行同步代码");
|
||||||
|
|
||||||
|
for (const coreGenerateTemplateVo of list) {
|
||||||
|
if (coreGenerateTemplateVo.getType() === "sql") {
|
||||||
|
SQLScriptRunnerTools.execScript(coreGenerateTemplateVo.getData());
|
||||||
|
} else {
|
||||||
|
FileUtil.writeUtf8String(coreGenerateTemplateVo.getData(), this.config.get('projectRoot' + "/" + coreGenerateTemplateVo.getPath(), coreGenerateTemplateVo.getFileName()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* preview
|
* preview
|
||||||
*/
|
*/
|
||||||
async preview(...args: any[]): Promise<any> {
|
async preview(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const generateTable: GenerateTable = generateTableMapper.selectById(id);
|
||||||
return null;
|
const list: GenerateColumn[] = generateColumnMapper.selectList(new QueryWrapper<GenerateColumn>().eq("table_id", id));
|
||||||
|
const coreGenerateService: CoreGenerateService = new CoreGenerateService();
|
||||||
|
const columnList: CoreGenerateTemplateVo[] = coreGenerateService.generateCode(generateTable, list);
|
||||||
|
const voList: GeneratePreviewVo[] = [];
|
||||||
|
for (const coreGenerateTemplateVo of columnList) {
|
||||||
|
const vo: GeneratePreviewVo = new GeneratePreviewVo();
|
||||||
|
vo.setName(coreGenerateTemplateVo.getFileName());
|
||||||
|
vo.setType(coreGenerateTemplateVo.getType());
|
||||||
|
vo.setContent(coreGenerateTemplateVo.getData());
|
||||||
|
vo.setFileDir(coreGenerateTemplateVo.getPath() + "/");
|
||||||
|
voList.add(vo);
|
||||||
|
}
|
||||||
|
return voList;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* getDbFieldType
|
* getDbFieldType
|
||||||
*/
|
*/
|
||||||
async getDbFieldType(...args: any[]): Promise<any> {
|
async getDbFieldType(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
type = getDbType(type);
|
||||||
return null;
|
const map: Record<string, any> = SqlColumnEnum.getMap();
|
||||||
|
const field: string = "";
|
||||||
|
for (Map.Entry<String, String[]> entry : map.entrySet()) {
|
||||||
|
if (Arrays.asList(entry.getValue()).includes(type)) {
|
||||||
|
field = entry.getKey();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (field === "") {
|
||||||
|
field = "String";
|
||||||
|
}
|
||||||
|
return field;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* getDbType
|
* getDbType
|
||||||
*/
|
*/
|
||||||
async getDbType(...args: any[]): Promise<any> {
|
async getDbType(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
if (StrUtil.includes(columnType, "(")) {
|
||||||
return null;
|
return StrUtil.subAfter(columnType, "(", true);
|
||||||
|
} else {
|
||||||
|
return columnType;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* checkFile
|
* checkFile
|
||||||
*/
|
*/
|
||||||
async checkFile(...args: any[]): Promise<any> {
|
async checkFile(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -94,7 +399,6 @@ export class GenerateServiceImplService {
|
|||||||
* getTableColumn
|
* getTableColumn
|
||||||
*/
|
*/
|
||||||
async getTableColumn(...args: any[]): Promise<any> {
|
async getTableColumn(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,95 +14,358 @@ export class AuthSiteServiceImplService {
|
|||||||
* list
|
* list
|
||||||
*/
|
*/
|
||||||
async list(...args: any[]): Promise<any[]> {
|
async list(...args: any[]): Promise<any[]> {
|
||||||
// TODO: 实现业务逻辑
|
const page: number = pageParam.getPage();
|
||||||
return [];
|
const limit: number = pageParam.getLimit();
|
||||||
|
|
||||||
|
const queryWrapper: QueryWrapper<Site> = new QueryWrapper<>();
|
||||||
|
//查询条件判断组装
|
||||||
|
if (ObjectUtil.isNotEmpty(searchParam.getKeywords())) {
|
||||||
|
queryWrapper.like("site_name", searchParam.getKeywords()).or().like("site_id", searchParam.getKeywords());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ObjectUtil.isNotEmpty(searchParam.getStatus())) {
|
||||||
|
queryWrapper.eq("status", searchParam.getStatus());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ObjectUtil.isNotEmpty(searchParam.getGroupId())) {
|
||||||
|
queryWrapper.eq("group_id", searchParam.getGroupId());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ObjectUtil.isNotEmpty(searchParam.getApp())) {
|
||||||
|
queryWrapper.like("app", searchParam.getApp());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ObjectUtil.isNotEmpty(searchParam.getSiteDomain())) {
|
||||||
|
queryWrapper.like("site_domain", searchParam.getSiteDomain());
|
||||||
|
}
|
||||||
|
queryWrapper.ne("app_type", "admin");
|
||||||
|
|
||||||
|
const siteIds: number[] = getSiteIds();
|
||||||
|
if(!authService.isSuperAdmin()) {
|
||||||
|
if (ObjectUtil.isNotEmpty(siteIds)) {
|
||||||
|
queryWrapper.in("site_id", siteIds);
|
||||||
|
} else {
|
||||||
|
return PageResult.build(page, limit, 0).setData([]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ObjectUtil.isNotEmpty(searchParam.getCreateTime())) {
|
||||||
|
|
||||||
|
String[] createTime = searchParam.getCreateTime();
|
||||||
|
const startTime: number = (createTime[0] == null) ? 0: DateUtils.StringToTimestamp(createTime[0]);
|
||||||
|
console.log(startTime);
|
||||||
|
const endTime: number = (createTime[1] == null) ? 0: DateUtils.StringToTimestamp(createTime[1]);
|
||||||
|
if(startTime > 0 && endTime > 0)
|
||||||
|
{
|
||||||
|
queryWrapper.between("create_time", startTime, endTime);
|
||||||
|
}else if (startTime > 0 && endTime == 0)
|
||||||
|
{
|
||||||
|
queryWrapper.ge("create_time", startTime);
|
||||||
|
}else if (startTime == 0 && endTime > 0)
|
||||||
|
{
|
||||||
|
queryWrapper.le("create_time", startTime);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ObjectUtil.isNotEmpty(searchParam.getExpireTime())) {
|
||||||
|
|
||||||
|
String[] expireTime = searchParam.getExpireTime();
|
||||||
|
const startTime: number = (expireTime[0] == null) ? 0: DateUtils.StringToTimestamp(expireTime[0]);
|
||||||
|
console.log(startTime);
|
||||||
|
const endTime: number = (expireTime[1] == null) ? 0: DateUtils.StringToTimestamp(expireTime[1]);
|
||||||
|
if(startTime > 0 && endTime > 0)
|
||||||
|
{
|
||||||
|
queryWrapper.between("expire_time", startTime, endTime);
|
||||||
|
}else if (startTime > 0 && endTime == 0)
|
||||||
|
{
|
||||||
|
queryWrapper.ge("expire_time", startTime);
|
||||||
|
}else if (startTime == 0 && endTime > 0)
|
||||||
|
{
|
||||||
|
queryWrapper.le("expire_time", startTime);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(ObjectUtil.isEmpty(searchParam.getSort())){
|
||||||
|
queryWrapper.orderByDesc("create_time");
|
||||||
|
}else{
|
||||||
|
queryWrapper.orderByDesc(searchParam.getSort());
|
||||||
|
}
|
||||||
|
|
||||||
|
const iPage: IPage<Site> = siteMapper.selectPage(new Page<>(page, limit), queryWrapper);
|
||||||
|
const list: SiteListVo[] = [];
|
||||||
|
for (const item of iPage.getRecords()) {
|
||||||
|
const vo: SiteListVo = new SiteListVo();
|
||||||
|
BeanUtils.copyProperties(item, vo);
|
||||||
|
list.add(vo);
|
||||||
|
}
|
||||||
|
return PageResult.build(page, limit, iPage.getTotal()).setData(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* info
|
* info
|
||||||
*/
|
*/
|
||||||
async info(...args: any[]): Promise<any> {
|
async info(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const siteMPJQueryWrapper: MPJQueryWrapper<Site> = new MPJQueryWrapper<>();
|
||||||
return null;
|
siteMPJQueryWrapper.select("ns.site_id, ns.site_name, ns.group_id, ns.keywords, ns.app_type, ns.logo, ns.`desc`, ns.status, ns.latitude, ns.longitude, ns.province_id, ns.city_id, ns.district_id, ns.address, ns.full_address, ns.phone, ns.business_hours, ns.create_time, ns.expire_time, ns.front_end_name, ns.front_end_logo, ns.front_end_icon, ns.icon, ns.member_no, ns.app, ns.addons, ns.initalled_addon, ns.site_domain, nsg.group_name")
|
||||||
|
.setAlias("ns")
|
||||||
|
.leftJoin("?_site_group nsg ON ns.group_id = nsg.group_id".replace("?_", this.config.get('tablePrefix')));
|
||||||
|
siteMPJQueryWrapper.eq("ns.site_id", id);
|
||||||
|
const siteInfoVo: SiteInfoVo = siteMapper.selectJoinOne(SiteInfoVo.class, siteMPJQueryWrapper);
|
||||||
|
siteInfoVo.setAddonKeys(iCoreSiteService.getAddonKeysBySiteId(siteInfoVo.getSiteId()));
|
||||||
|
if(siteInfoVo.getAddonKeys().size()!=0){
|
||||||
|
siteInfoVo.setSiteAddons(addonMapper.selectList(new QueryWrapper<Addon>().in("`key`", siteInfoVo.getAddonKeys()).eq("type", AddonActionEnum.ADDON.getCode())));
|
||||||
|
siteInfoVo.setApps(addonMapper.selectList(new QueryWrapper<Addon>().in("`key`", siteInfoVo.getAddonKeys()).eq("type", AddonActionEnum.APP.getCode())));
|
||||||
|
}else{
|
||||||
|
siteInfoVo.setSiteAddons([]);
|
||||||
|
siteInfoVo.setApps([]);
|
||||||
|
}
|
||||||
|
return siteInfoVo;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* add
|
* add
|
||||||
*/
|
*/
|
||||||
async add(...args: any[]): Promise<any> {
|
async add(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const model: Site = new Site();
|
||||||
return null;
|
model.setSiteName(addParam.getSiteName());
|
||||||
|
model.setGroupId(addParam.getGroupId());
|
||||||
|
model.setKeywords(addParam.getKeywords());
|
||||||
|
model.setAppType(addParam.getAppType());
|
||||||
|
//model.setLogo(UrlUtils.toRelativeUrl(addParam.getLogo()));
|
||||||
|
model.setDesc(addParam.getDesc());
|
||||||
|
model.setStatus(addParam.getStatus());
|
||||||
|
model.setLatitude(addParam.getLatitude());
|
||||||
|
model.setLongitude(addParam.getLongitude());
|
||||||
|
model.setProvinceId(addParam.getProvinceId());
|
||||||
|
model.setCityId(addParam.getCityId());
|
||||||
|
model.setDistrictId(addParam.getDistrictId());
|
||||||
|
model.setAddress(addParam.getAddress());
|
||||||
|
model.setFullAddress(addParam.getFullAddress());
|
||||||
|
model.setPhone(addParam.getPhone());
|
||||||
|
model.setBusinessHours(addParam.getBusinessHours());
|
||||||
|
model.setCreateTime(System.currentTimeMillis() / 1000);
|
||||||
|
model.setExpireTime(addParam.getExpireTime());
|
||||||
|
model.setFrontEndName(addParam.getFrontEndName());
|
||||||
|
model.setFrontEndLogo(addParam.getFrontEndLogo());
|
||||||
|
model.setFrontEndIcon(addParam.getFrontEndIcon());
|
||||||
|
model.setIcon(addParam.getIcon());
|
||||||
|
model.setMemberNo(addParam.getMemberNo());
|
||||||
|
model.setApp(addParam.getApp());
|
||||||
|
model.setAddons(addParam.getAddons());
|
||||||
|
model.setInitalledAddon(addParam.getInitalledAddon());
|
||||||
|
model.setSiteDomain(addParam.getSiteDomain());
|
||||||
|
siteMapper.insert(model);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* edit
|
* edit
|
||||||
*/
|
*/
|
||||||
async edit(...args: any[]): Promise<any> {
|
async edit(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const model: Site = siteMapper.selectOne(
|
||||||
return null;
|
new QueryWrapper<Site>()
|
||||||
|
.eq("site_id", id)
|
||||||
|
.last("limit 1"));
|
||||||
|
|
||||||
|
Assert.notNull(model, "数据不存在!");
|
||||||
|
model.setSiteId(id);
|
||||||
|
model.setSiteName(editParam.getSiteName());
|
||||||
|
model.setGroupId(editParam.getGroupId());
|
||||||
|
model.setKeywords(editParam.getKeywords());
|
||||||
|
model.setAppType(editParam.getAppType());
|
||||||
|
//model.setLogo(UrlUtils.toRelativeUrl(editParam.getLogo()));
|
||||||
|
model.setDesc(editParam.getDesc());
|
||||||
|
model.setStatus(editParam.getStatus());
|
||||||
|
model.setLatitude(editParam.getLatitude());
|
||||||
|
model.setLongitude(editParam.getLongitude());
|
||||||
|
model.setProvinceId(editParam.getProvinceId());
|
||||||
|
model.setCityId(editParam.getCityId());
|
||||||
|
model.setDistrictId(editParam.getDistrictId());
|
||||||
|
model.setAddress(editParam.getAddress());
|
||||||
|
model.setFullAddress(editParam.getFullAddress());
|
||||||
|
model.setPhone(editParam.getPhone());
|
||||||
|
model.setBusinessHours(editParam.getBusinessHours());
|
||||||
|
model.setExpireTime(editParam.getExpireTime());
|
||||||
|
model.setFrontEndName(editParam.getFrontEndName());
|
||||||
|
model.setFrontEndLogo(editParam.getFrontEndLogo());
|
||||||
|
model.setFrontEndIcon(editParam.getFrontEndIcon());
|
||||||
|
model.setIcon(editParam.getIcon());
|
||||||
|
model.setMemberNo(editParam.getMemberNo());
|
||||||
|
model.setApp(editParam.getApp());
|
||||||
|
model.setAddons(editParam.getAddons());
|
||||||
|
model.setInitalledAddon(editParam.getInitalledAddon());
|
||||||
|
model.setSiteDomain(editParam.getSiteDomain());
|
||||||
|
siteMapper.updateById(model);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* del
|
* del
|
||||||
*/
|
*/
|
||||||
async del(...args: any[]): Promise<any> {
|
async del(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const model: Site = siteMapper.selectOne(
|
||||||
return null;
|
new QueryWrapper<Site>()
|
||||||
|
.eq("site_id", id)
|
||||||
|
.last("limit 1"));
|
||||||
|
|
||||||
|
Assert.notNull(model, "数据不存在!");
|
||||||
|
|
||||||
|
siteMapper.delete(new QueryWrapper<Site>().eq("site_id", id));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* closeSite
|
* closeSite
|
||||||
*/
|
*/
|
||||||
async closeSite(...args: any[]): Promise<any> {
|
async closeSite(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const model: Site = new Site();
|
||||||
return null;
|
model.setSiteId(siteId);
|
||||||
|
model.setStatus(SiteStatusEnum.CLOSE.getCode());
|
||||||
|
siteMapper.updateById(model);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* openSite
|
* openSite
|
||||||
*/
|
*/
|
||||||
async openSite(...args: any[]): Promise<any> {
|
async openSite(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const model: Site = new Site();
|
||||||
return null;
|
model.setSiteId(siteId);
|
||||||
|
model.setStatus(SiteStatusEnum.ON.getCode());
|
||||||
|
siteMapper.updateById(model);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* getSiteCountByCondition
|
* getSiteCountByCondition
|
||||||
*/
|
*/
|
||||||
async getSiteCountByCondition(...args: any[]): Promise<any> {
|
async getSiteCountByCondition(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const queryWrapper: QueryWrapper<Site> = new QueryWrapper<>();
|
||||||
return null;
|
if (ObjectUtil.isNotEmpty(siteSearchParam.getCreateTime())) {
|
||||||
|
|
||||||
|
String[] createTime = siteSearchParam.getCreateTime();
|
||||||
|
const startTime: number = (createTime[0] == null) ? 0: DateUtils.StringToTimestamp(createTime[0]);
|
||||||
|
const endTime: number = (createTime[1] == null) ? 0: DateUtils.StringToTimestamp(createTime[1]);
|
||||||
|
if(startTime > 0 && endTime > 0)
|
||||||
|
{
|
||||||
|
queryWrapper.between("create_time", startTime, endTime);
|
||||||
|
}else if (startTime > 0 && endTime == 0)
|
||||||
|
{
|
||||||
|
queryWrapper.ge("create_time", startTime);
|
||||||
|
}else if (startTime == 0 && endTime > 0)
|
||||||
|
{
|
||||||
|
queryWrapper.le("create_time", startTime);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ObjectUtil.isNotEmpty(siteSearchParam.getStatus())) {
|
||||||
|
queryWrapper.eq("status", siteSearchParam.getStatus());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ObjectUtil.isNotEmpty(siteSearchParam.getGroupId())) {
|
||||||
|
queryWrapper.eq("group_id", siteSearchParam.getGroupId());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ObjectUtil.isNotEmpty(siteSearchParam.getExpireTime())) {
|
||||||
|
|
||||||
|
String[] expireTime = siteSearchParam.getExpireTime();
|
||||||
|
const startTime: number = (expireTime[0] == null) ? 0: DateUtils.StringToTimestamp(expireTime[0]);
|
||||||
|
const endTime: number = (expireTime[1] == null) ? 0: DateUtils.StringToTimestamp(expireTime[1]);
|
||||||
|
if(startTime > 0 && endTime > 0)
|
||||||
|
{
|
||||||
|
queryWrapper.between("expire_time", startTime, endTime);
|
||||||
|
}else if (startTime > 0 && endTime == 0)
|
||||||
|
{
|
||||||
|
queryWrapper.ge("expire_time", startTime);
|
||||||
|
}else if (startTime == 0 && endTime > 0)
|
||||||
|
{
|
||||||
|
queryWrapper.le("expire_time", startTime);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const siteCount: number = siteMapper.selectCount(queryWrapper);
|
||||||
|
return siteCount.intValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* getSiteIds
|
* getSiteIds
|
||||||
*/
|
*/
|
||||||
async getSiteIds(...args: any[]): Promise<any> {
|
async getSiteIds(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const queryWrapper: MPJQueryWrapper<SysUserRole> = new MPJQueryWrapper<SysUserRole>();
|
||||||
return null;
|
queryWrapper.select("site_id").eq("uid", RequestUtils.uid()).ne("site_id", RequestUtils.defaultSiteId()).eq("status", 1);
|
||||||
|
const sysUserRoleList: SysUserRole[] = sysUserRoleMapper.selectList(queryWrapper);
|
||||||
|
const siteIds: number[] = [];
|
||||||
|
for (const sysUserRole of sysUserRoleList) {
|
||||||
|
siteIds.add(sysUserRole.getSiteId());
|
||||||
|
}
|
||||||
|
return siteIds;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* getSiteGroup
|
* getSiteGroup
|
||||||
*/
|
*/
|
||||||
async getSiteGroup(...args: any[]): Promise<any> {
|
async getSiteGroup(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const userCreateSiteVoList: UserCreateSiteVo[] = [];
|
||||||
return null;
|
if(authService.isSuperAdmin()){
|
||||||
|
const siteGroupList: SiteGroup[] = siteGroupMapper.selectList(new QueryWrapper<SiteGroup>());
|
||||||
|
for (const siteGroup of siteGroupList) {
|
||||||
|
const userCreateSiteVo: UserCreateSiteVo = new UserCreateSiteVo();
|
||||||
|
userCreateSiteVo.setGroupId(siteGroup.getGroupId());
|
||||||
|
const siteGroupVo: SiteGroupVo = new SiteGroupVo();
|
||||||
|
BeanUtil.copyProperties(siteGroup, siteGroupVo);
|
||||||
|
siteGroupVo.setAppName(addonService.getTitleListByKey(siteGroup.getApp()));
|
||||||
|
siteGroupVo.setAddonName(addonService.getTitleListByKey(siteGroup.getAddon()));
|
||||||
|
userCreateSiteVo.setSiteGroup(siteGroupVo);
|
||||||
|
userCreateSiteVoList.add(userCreateSiteVo);
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
const userCreateSiteLimitQueryWrapper: QueryWrapper<UserCreateSiteLimit> = new QueryWrapper<>();
|
||||||
|
userCreateSiteLimitQueryWrapper.eq("uid", RequestUtils.uid());
|
||||||
|
const userCreateSiteLimitList: UserCreateSiteLimit[] = userCreateSiteLimitMapper.selectList(userCreateSiteLimitQueryWrapper);
|
||||||
|
for (const userCreateSiteLimit of userCreateSiteLimitList) {
|
||||||
|
const userCreateSiteVo: UserCreateSiteVo = new UserCreateSiteVo();
|
||||||
|
BeanUtil.copyProperties(userCreateSiteLimit, userCreateSiteVo);
|
||||||
|
const siteGroup: SiteGroup = siteGroupMapper.selectById(userCreateSiteLimit.getGroupId());
|
||||||
|
const siteGroupVo: SiteGroupVo = new SiteGroupVo();
|
||||||
|
BeanUtil.copyProperties(siteGroup, siteGroupVo);
|
||||||
|
siteGroupVo.setAppName(addonService.getTitleListByKey(siteGroup.getApp()));
|
||||||
|
siteGroupVo.setAddonName(addonService.getTitleListByKey(siteGroup.getAddon()));
|
||||||
|
userCreateSiteVo.setSiteGroup(siteGroupVo);
|
||||||
|
userCreateSiteVoList.add(userCreateSiteVo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return userCreateSiteVoList;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* createSite
|
* createSite
|
||||||
*/
|
*/
|
||||||
async createSite(...args: any[]): Promise<any> {
|
async createSite(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const month: number = 1;
|
||||||
return null;
|
if(!authService.isSuperAdmin()){
|
||||||
|
const userCreateSiteLimit: UserCreateSiteLimit = userCreateSiteLimitMapper.selectOne(new QueryWrapper<UserCreateSiteLimit>().eq("uid", RequestUtils.uid()).eq("group_id", homeSiteAddParam.getGroupId()));
|
||||||
|
Assert.notNull(userCreateSiteLimit, "NO_PERMISSION_TO_CREATE_SITE_GROUP");
|
||||||
|
const userSiteNum: number = siteGroupService.getUserSiteGroupSiteNum(RequestUtils.uid(), homeSiteAddParam.getGroupId());
|
||||||
|
if(userSiteNum>userCreateSiteLimit.getNum()-1){
|
||||||
|
throw new BadRequestException("SITE_GROUP_CREATE_SITE_EXCEEDS_LIMIT");
|
||||||
|
}
|
||||||
|
month=userCreateSiteLimit.getMonth();
|
||||||
|
}
|
||||||
|
const siteAddParam: SiteAddParam = new SiteAddParam();
|
||||||
|
siteAddParam.setSiteName(homeSiteAddParam.getSiteName());
|
||||||
|
siteAddParam.setUid(RequestUtils.uid());
|
||||||
|
siteAddParam.setGroupId(homeSiteAddParam.getGroupId());
|
||||||
|
siteAddParam.setExpireTime(DateUtils.getDateAddMonth(month));
|
||||||
|
siteService.add(siteAddParam);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* getSiteGroupAppList
|
* getSiteGroupAppList
|
||||||
*/
|
*/
|
||||||
async getSiteGroupAppList(...args: any[]): Promise<any> {
|
async getSiteGroupAppList(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const siteGroupAppList: string[] = getSiteGroupApps();
|
||||||
return null;
|
if (CollectionUtils.isEmpty(siteGroupAppList)){
|
||||||
|
return List.of();
|
||||||
|
}
|
||||||
|
const addonList: Addon[] = addonMapper.selectList(new LambdaQueryWrapper<Addon>()
|
||||||
|
.eq(Addon::getStatus, AddonStatusEnum.ON.getCode())
|
||||||
|
.eq(Addon::getType, AddonActionEnum.APP.getCode())
|
||||||
|
.in(Addon::getKey, siteGroupAppList));
|
||||||
|
|
||||||
|
return processAddonList(addonList);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,55 +14,166 @@ export class MemberAccountServiceImplService {
|
|||||||
* list
|
* list
|
||||||
*/
|
*/
|
||||||
async list(...args: any[]): Promise<any[]> {
|
async list(...args: any[]): Promise<any[]> {
|
||||||
// TODO: 实现业务逻辑
|
const siteId: number = RequestUtils.siteId();
|
||||||
return [];
|
|
||||||
|
const page: number = pageParam.getPage();
|
||||||
|
const limit: number = pageParam.getLimit();
|
||||||
|
|
||||||
|
const queryWrapper: MPJQueryWrapper<MemberAccountLog> = new MPJQueryWrapper<>();
|
||||||
|
queryWrapper.setAlias("mal").innerJoin("?_member m ON mal.member_id = m.member_id".replace("?_", this.config.get('tablePrefix')));
|
||||||
|
queryWrapper.select("mal.*,m.member_no,m.username,m.nickname,m.mobile,m.headimg");
|
||||||
|
queryWrapper.eq("mal.site_id", siteId);
|
||||||
|
queryWrapper.eq("mal.account_type", searchParam.getAccountType());
|
||||||
|
queryWrapper.orderByDesc("mal.id");
|
||||||
|
|
||||||
|
if (ObjectUtil.isNotEmpty(searchParam.getKeywords()))
|
||||||
|
queryWrapper.like("m.member_no|m.username|m.nickname|m.mobile", searchParam.getKeywords());
|
||||||
|
if (ObjectUtil.defaultIfNull(searchParam.getMemberId(), 0) > 0)
|
||||||
|
queryWrapper.eq("mal.member_id", searchParam.getMemberId());
|
||||||
|
if (ObjectUtil.isNotEmpty(searchParam.getFromType()))
|
||||||
|
queryWrapper.eq("mal.from_type", searchParam.getFromType());
|
||||||
|
if (ObjectUtil.isNotEmpty(searchParam.getCreateTime()))
|
||||||
|
QueryMapperUtils.buildByTime(queryWrapper, "mal.create_time", searchParam.getCreateTime());
|
||||||
|
|
||||||
|
const iPage: IPage<MemberAccountLogVo> = memberAccountLogMapper.selectJoinPage(new Page<>(page, limit), MemberAccountLogVo.class, queryWrapper);
|
||||||
|
const list: MemberAccountLogListVo[] = [];
|
||||||
|
for (const item of iPage.getRecords()) {
|
||||||
|
const vo: MemberAccountLogListVo = new MemberAccountLogListVo();
|
||||||
|
BeanUtils.copyProperties(item, vo);
|
||||||
|
|
||||||
|
const memberInfoVo: MemberBriefInfoVo = new MemberBriefInfoVo();
|
||||||
|
BeanUtils.copyProperties(item, memberInfoVo);
|
||||||
|
|
||||||
|
vo.setMember(memberInfoVo);
|
||||||
|
list.add(vo);
|
||||||
|
}
|
||||||
|
return PageResult.build(page, limit, iPage.getTotal()).setData(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* getMemberAccountInfo
|
* getMemberAccountInfo
|
||||||
*/
|
*/
|
||||||
async getMemberAccountInfo(...args: any[]): Promise<number> {
|
async getMemberAccountInfo(...args: any[]): Promise<number> {
|
||||||
// TODO: 实现业务逻辑
|
const siteId: number = RequestUtils.siteId();
|
||||||
return 0;
|
|
||||||
|
const member: Member = memberMapper.selectOne(new QueryWrapper<Member>()
|
||||||
|
.eq("member_id", memberId)
|
||||||
|
.eq("site_id", siteId));
|
||||||
|
Assert.notNull(member, "会员不存在");
|
||||||
|
|
||||||
|
const memberAccountVo: MemberAccountVo = new MemberAccountVo();
|
||||||
|
BeanUtils.copyProperties(member, memberAccountVo);
|
||||||
|
|
||||||
|
return memberAccountVo;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* sumCommission
|
* sumCommission
|
||||||
*/
|
*/
|
||||||
async sumCommission(...args: any[]): Promise<any> {
|
async sumCommission(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const siteId: number = RequestUtils.siteId();
|
||||||
return null;
|
const vo: SumCommissionVo = new SumCommissionVo();
|
||||||
|
const zero: number = (new BigDecimal(0));
|
||||||
|
|
||||||
|
if (ObjectUtil.isNotEmpty(searchParam.getMemberId()) && searchParam.getMemberId() > 0) {
|
||||||
|
const memberAccountInfo: MemberAccountVo = this.getMemberAccountInfo(searchParam.getMemberId());
|
||||||
|
vo.setCommission(memberAccountInfo.getCommission());
|
||||||
|
vo.setCommissionCashOuting(memberAccountInfo.getCommissionCashOuting());
|
||||||
|
vo.setTotalCommission(memberAccountInfo.getCommissionGet());
|
||||||
|
const memberAccountLog: MemberAccountLog = memberAccountLogMapper.selectOne(new QueryWrapper<MemberAccountLog>()
|
||||||
|
.select("SUM(account_data) AS account_sum")
|
||||||
|
.eq("member_id", searchParam.getMemberId())
|
||||||
|
.eq("site_id", siteId)
|
||||||
|
.eq("account_type", AccountTypeEnum.COMMISSION.getType())
|
||||||
|
.eq("from_type", "cash_out"));
|
||||||
|
vo.setWithdrawnCommission(memberAccountLog == null ? zero : memberAccountLog.getAccountSum());
|
||||||
|
} else {
|
||||||
|
const member: Member = memberMapper.selectOne(new QueryWrapper<Member>()
|
||||||
|
.select("SUM(commission_get) AS commission_get,SUM(commission) AS commission, SUM(commission_cash_outing) AS commission_cash_outing")
|
||||||
|
.eq("site_id", siteId));
|
||||||
|
|
||||||
|
vo.setCommission(member == null ? zero : member.getCommission());
|
||||||
|
vo.setCommissionCashOuting(member == null ? zero : member.getCommissionCashOuting());
|
||||||
|
vo.setTotalCommission(member == null ? zero : member.getCommissionGet());
|
||||||
|
const memberAccountLog: MemberAccountLog = memberAccountLogMapper.selectOne(new QueryWrapper<MemberAccountLog>()
|
||||||
|
.select("SUM(account_data) AS account_sum")
|
||||||
|
.eq("site_id", siteId)
|
||||||
|
.eq("account_type", AccountTypeEnum.COMMISSION.getType())
|
||||||
|
.eq("from_type", "cash_out"));
|
||||||
|
vo.setWithdrawnCommission(memberAccountLog == null ? zero : memberAccountLog.getAccountSum());
|
||||||
|
}
|
||||||
|
return vo;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* sumBalance
|
* sumBalance
|
||||||
*/
|
*/
|
||||||
async sumBalance(...args: any[]): Promise<any> {
|
async sumBalance(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const siteId: number = RequestUtils.siteId();
|
||||||
return null;
|
const vo: SumBalanceVo = new SumBalanceVo();
|
||||||
|
|
||||||
|
if (ObjectUtil.isNotEmpty(searchParam.getMemberId()) && searchParam.getMemberId() > 0) {
|
||||||
|
const memberAccountInfo: MemberAccountVo = this.getMemberAccountInfo(searchParam.getMemberId());
|
||||||
|
|
||||||
|
vo.setBalance(memberAccountInfo == null ? new BigDecimal(0) : memberAccountInfo.getBalance());
|
||||||
|
vo.setMoney(memberAccountInfo == null ? new BigDecimal(0) : memberAccountInfo.getMoney());
|
||||||
|
} else {
|
||||||
|
const member: Member = memberMapper.selectOne(new QueryWrapper<Member>()
|
||||||
|
.select("SUM(balance) AS balance,SUM(money) AS money")
|
||||||
|
.eq("site_id", siteId));
|
||||||
|
|
||||||
|
vo.setBalance(member == null ? new BigDecimal(0) : member.getBalance());
|
||||||
|
vo.setMoney(member == null ? new BigDecimal(0) : member.getMoney());
|
||||||
|
}
|
||||||
|
|
||||||
|
return vo;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* sumPoint
|
* sumPoint
|
||||||
*/
|
*/
|
||||||
async sumPoint(...args: any[]): Promise<any> {
|
async sumPoint(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const siteId: number = RequestUtils.siteId();
|
||||||
return null;
|
const vo: SumPointVo = new SumPointVo();
|
||||||
|
|
||||||
|
if (ObjectUtil.isNotEmpty(searchParam.getMemberId()) && searchParam.getMemberId() > 0) {
|
||||||
|
const memberAccountInfo: MemberAccountVo = this.getMemberAccountInfo(searchParam.getMemberId());
|
||||||
|
const memberAccountLog: MemberAccountLog = memberAccountLogMapper.selectOne(new QueryWrapper<MemberAccountLog>()
|
||||||
|
.select("SUM(account_data) AS account_sum")
|
||||||
|
.eq("site_id", siteId)
|
||||||
|
.eq("member_id", searchParam.getMemberId())
|
||||||
|
.eq("account_type", AccountTypeEnum.POINT.getType())
|
||||||
|
.lt("account_data", 0));
|
||||||
|
vo.setPointGet(memberAccountInfo.getPointGet());
|
||||||
|
vo.setPointUse(memberAccountLog == null ? 0 : memberAccountLog.getAccountSum().abs().intValue());
|
||||||
|
} else {
|
||||||
|
const member: Member = memberMapper.selectOne(new QueryWrapper<Member>()
|
||||||
|
.select("SUM(point_get) AS point_get")
|
||||||
|
.eq("site_id", siteId));
|
||||||
|
vo.setPointGet(member == null ? 0 : member.getPointGet());
|
||||||
|
|
||||||
|
const memberAccountLog: MemberAccountLog = memberAccountLogMapper.selectOne(new QueryWrapper<MemberAccountLog>()
|
||||||
|
.select("SUM(account_data) AS account_sum")
|
||||||
|
.eq("site_id", siteId)
|
||||||
|
.eq("account_type", AccountTypeEnum.POINT.getType())
|
||||||
|
.lt("account_data", 0));
|
||||||
|
vo.setPointUse(memberAccountLog == null ? 0 : memberAccountLog.getAccountSum().abs().intValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
return vo;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* adjustPoint
|
* adjustPoint
|
||||||
*/
|
*/
|
||||||
async adjustPoint(...args: any[]): Promise<any> {
|
async adjustPoint(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
coreMemberAccountService.addLog(RequestUtils.siteId(), param.getMemberId(), AccountTypeEnum.POINT.getType(), param.getAccountData(), "adjust", param.getMemo(), "");
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* adjustBalance
|
* adjustBalance
|
||||||
*/
|
*/
|
||||||
async adjustBalance(...args: any[]): Promise<any> {
|
async adjustBalance(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
coreMemberAccountService.addLog(RequestUtils.siteId(), param.getMemberId(), AccountTypeEnum.BALANCE.getType(), param.getAccountData(), "adjust", param.getMemo(), "");
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,39 +14,74 @@ export class MemberAddressServiceImplService {
|
|||||||
* list
|
* list
|
||||||
*/
|
*/
|
||||||
async list(...args: any[]): Promise<any[]> {
|
async list(...args: any[]): Promise<any[]> {
|
||||||
// TODO: 实现业务逻辑
|
const queryWrapper: QueryWrapper<MemberAddress> = new QueryWrapper<>();
|
||||||
return [];
|
queryWrapper.orderByDesc("id");
|
||||||
|
queryWrapper.eq("site_id", RequestUtils.siteId());
|
||||||
|
if (ObjectUtil.isNotEmpty(searchParam.getMemberId())) queryWrapper.eq("member_id", searchParam.getMemberId());
|
||||||
|
|
||||||
|
const records: MemberAddress[] = memberAddressMapper.selectList(queryWrapper);
|
||||||
|
const list: MemberAddressListVo[] = [];
|
||||||
|
for (const item of records) {
|
||||||
|
const vo: MemberAddressListVo = new MemberAddressListVo();
|
||||||
|
BeanUtils.copyProperties(item, vo);
|
||||||
|
list.add(vo);
|
||||||
|
}
|
||||||
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* info
|
* info
|
||||||
*/
|
*/
|
||||||
async info(...args: any[]): Promise<any> {
|
async info(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const model: MemberAddress = memberAddressMapper.selectOne(
|
||||||
return null;
|
new QueryWrapper<MemberAddress>()
|
||||||
|
.eq("id", id)
|
||||||
|
.eq("site_id", RequestUtils.siteId())
|
||||||
|
);
|
||||||
|
|
||||||
|
Assert.notNull(model, "数据不存在");
|
||||||
|
|
||||||
|
const vo: MemberAddressInfoVo = new MemberAddressInfoVo();
|
||||||
|
BeanUtils.copyProperties(model, vo);
|
||||||
|
return vo;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* add
|
* add
|
||||||
*/
|
*/
|
||||||
async add(...args: any[]): Promise<any> {
|
async add(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const model: MemberAddress = new MemberAddress();
|
||||||
return null;
|
BeanUtils.copyProperties(addParam, model);
|
||||||
|
model.setSiteId(RequestUtils.siteId());
|
||||||
|
memberAddressMapper.insert(model);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* edit
|
* edit
|
||||||
*/
|
*/
|
||||||
async edit(...args: any[]): Promise<any> {
|
async edit(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const model: MemberAddress = memberAddressMapper.selectOne(
|
||||||
return null;
|
new QueryWrapper<MemberAddress>()
|
||||||
|
.eq("id", id)
|
||||||
|
.eq("site_id", RequestUtils.siteId())
|
||||||
|
);
|
||||||
|
|
||||||
|
Assert.notNull(model, "数据不存在!");
|
||||||
|
BeanUtils.copyProperties(editParam, model);
|
||||||
|
memberAddressMapper.updateById(model);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* del
|
* del
|
||||||
*/
|
*/
|
||||||
async del(...args: any[]): Promise<any> {
|
async del(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const model: MemberAddress = memberAddressMapper.selectOne(
|
||||||
return null;
|
new QueryWrapper<MemberAddress>()
|
||||||
|
.eq("id", id)
|
||||||
|
.eq("site_id", RequestUtils.siteId()));
|
||||||
|
|
||||||
|
Assert.notNull(model, "数据不存在!");
|
||||||
|
|
||||||
|
memberAddressMapper.delete(new QueryWrapper<MemberAddress>().eq("id", id));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,63 +14,148 @@ export class MemberCashOutServiceImplService {
|
|||||||
* pages
|
* pages
|
||||||
*/
|
*/
|
||||||
async pages(...args: any[]): Promise<any[]> {
|
async pages(...args: any[]): Promise<any[]> {
|
||||||
// TODO: 实现业务逻辑
|
const siteId: number = RequestUtils.siteId();
|
||||||
return [];
|
const page: number = pageParam.getPage();
|
||||||
|
const limit: number = pageParam.getLimit();
|
||||||
|
|
||||||
|
const queryWrapper: MPJQueryWrapper<MemberCashOut> = new MPJQueryWrapper<>();
|
||||||
|
queryWrapper.setAlias("mco").innerJoin("?_member m ON mco.member_id = m.member_id".replace("?_", this.config.get('tablePrefix')));
|
||||||
|
queryWrapper.select("mco.*,m.member_no,m.username,m.nickname,m.mobile,m.headimg");
|
||||||
|
queryWrapper.eq("mco.site_id", siteId);
|
||||||
|
queryWrapper.orderByDesc("mco.id");
|
||||||
|
|
||||||
|
if (ObjectUtil.isNotEmpty(searchParam.getKeywords())) {
|
||||||
|
queryWrapper.and(i => i.like("m.member_no", searchParam.getKeywords())
|
||||||
|
.or().like("m.username", searchParam.getKeywords())
|
||||||
|
.or().like("m.nickname", searchParam.getKeywords())
|
||||||
|
.or().like("m.mobile", searchParam.getKeywords())
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (ObjectUtil.isNotEmpty(searchParam.getMemberId()) && searchParam.getMemberId() > 0) queryWrapper.eq("mco.member_id", searchParam.getMemberId());
|
||||||
|
if (ObjectUtil.isNotEmpty(searchParam.getStatus())) queryWrapper.eq("mco.status", searchParam.getStatus());
|
||||||
|
if (ObjectUtil.isNotEmpty(searchParam.getCashOutNo())) queryWrapper.like("mco.cash_out_no", searchParam.getCashOutNo());
|
||||||
|
if (ObjectUtil.isNotEmpty(searchParam.getTransferType())) queryWrapper.like("mco.transfer_type", searchParam.getTransferType());
|
||||||
|
if (ObjectUtil.isNotEmpty(searchParam.getCreateTime())) QueryMapperUtils.buildByTime(queryWrapper, "mco.create_time", searchParam.getCreateTime());
|
||||||
|
if (ObjectUtil.isNotEmpty(searchParam.getTransferTime())) QueryMapperUtils.buildByTime(queryWrapper, "mco.transfer_time", searchParam.getTransferTime());
|
||||||
|
|
||||||
|
const iPage: IPage<MemberCashOutListVo> = memberCashOutMapper.selectJoinPage(new Page<>(page, limit), MemberCashOutListVo.class, queryWrapper);
|
||||||
|
for (const item of iPage.getRecords()) {
|
||||||
|
const memberInfoVo: MemberBriefInfoVo = new MemberBriefInfoVo();
|
||||||
|
BeanUtils.copyProperties(item, memberInfoVo);
|
||||||
|
item.setMember(memberInfoVo);
|
||||||
|
}
|
||||||
|
return PageResult.build(page, limit, iPage.getTotal()).setData(iPage.getRecords());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* info
|
* info
|
||||||
*/
|
*/
|
||||||
async info(...args: any[]): Promise<any> {
|
async info(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const siteId: number = RequestUtils.siteId();
|
||||||
return null;
|
|
||||||
|
const vo: MemberCashOutInfoVo = memberCashOutMapper.selectJoinOne(
|
||||||
|
MemberCashOutInfoVo.class,
|
||||||
|
new MPJQueryWrapper<MemberCashOut>()
|
||||||
|
.select("mco.*,m.member_no,m.username,m.nickname,m.mobile,m.headimg,pt.transfer_voucher,pt.transfer_remark")
|
||||||
|
.eq("mco.id", id)
|
||||||
|
.eq("mco.site_id", siteId)
|
||||||
|
.setAlias("mco")
|
||||||
|
.leftJoin("?_member m ON mco.member_id = m.member_id".replace("?_", this.config.get('tablePrefix')))
|
||||||
|
.leftJoin("?_pay_transfer pt ON mco.transfer_no = pt.transfer_no".replace("?_", this.config.get('tablePrefix')))
|
||||||
|
);
|
||||||
|
|
||||||
|
if (vo != null) {
|
||||||
|
MemberCashOutInfoVo.const transfer: Transfer = new MemberCashOutInfoVo.Transfer();
|
||||||
|
transfer.setTransferNo(vo.getTransferNo());
|
||||||
|
transfer.setTransferRemark(vo.getTransferRemark());
|
||||||
|
transfer.setTransferVoucher(vo.getTransferVoucher());
|
||||||
|
vo.setTransfer(transfer);
|
||||||
|
}
|
||||||
|
|
||||||
|
return vo;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* stat
|
* stat
|
||||||
*/
|
*/
|
||||||
async stat(...args: any[]): Promise<any> {
|
async stat(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const siteId: number = RequestUtils.siteId();
|
||||||
return null;
|
const vo: CashOutStatVo = new CashOutStatVo();
|
||||||
|
|
||||||
|
const transfered: MemberCashOut = memberCashOutMapper.selectOne(
|
||||||
|
new QueryWrapper<MemberCashOut>()
|
||||||
|
.eq("status", MemberCashOutStatusEnum.TRANSFERED.getStatus())
|
||||||
|
.eq("site_id", siteId)
|
||||||
|
.select("SUM(apply_money) AS apply_money")
|
||||||
|
.last("limit 1"));
|
||||||
|
|
||||||
|
const allMoney: MemberCashOut = memberCashOutMapper.selectOne(
|
||||||
|
new QueryWrapper<MemberCashOut>()
|
||||||
|
.ge("status", 0)
|
||||||
|
.eq("site_id", siteId)
|
||||||
|
.select("SUM(apply_money) AS apply_money")
|
||||||
|
.last("limit 1"));
|
||||||
|
|
||||||
|
const zero: number = new BigDecimal(0);
|
||||||
|
vo.setTransfered(transfered == null ? zero : transfered.getApplyMoney());
|
||||||
|
if (allMoney != null) {
|
||||||
|
vo.setCashOuting(allMoney.getApplyMoney().subtract(vo.getTransfered()));
|
||||||
|
} else {
|
||||||
|
vo.setCashOuting(zero);
|
||||||
|
}
|
||||||
|
return vo;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* audit
|
* audit
|
||||||
*/
|
*/
|
||||||
async audit(...args: any[]): Promise<any> {
|
async audit(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
iCoreMemberCashOutService.audit(RequestUtils.siteId(), param.getId(), param.getAction(), param);
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* transfer
|
* transfer
|
||||||
*/
|
*/
|
||||||
async transfer(...args: any[]): Promise<any> {
|
async transfer(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const siteId: number = RequestUtils.siteId();
|
||||||
return null;
|
|
||||||
|
const model: MemberCashOut = memberCashOutMapper.selectOne(
|
||||||
|
new QueryWrapper<MemberCashOut>()
|
||||||
|
.eq("id", param.getId())
|
||||||
|
.eq("site_id", siteId)
|
||||||
|
.last("limit 1"));
|
||||||
|
|
||||||
|
Assert.notNull(model, "数据不存在");
|
||||||
|
|
||||||
|
iCoreMemberCashOutService.transfer(model, param);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* cancel
|
* cancel
|
||||||
*/
|
*/
|
||||||
async cancel(...args: any[]): Promise<any> {
|
async cancel(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
iCoreMemberCashOutService.cancel(RequestUtils.siteId(), id);
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* remark
|
* remark
|
||||||
*/
|
*/
|
||||||
async remark(...args: any[]): Promise<any> {
|
async remark(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const model: MemberCashOut = memberCashOutMapper.selectOne(
|
||||||
return null;
|
new QueryWrapper<MemberCashOut>()
|
||||||
|
.eq("id", id)
|
||||||
|
.eq("site_id", RequestUtils.siteId())
|
||||||
|
);
|
||||||
|
Assert.notNull(model, "数据不存在");
|
||||||
|
|
||||||
|
model.setRemark(param.getRemark());
|
||||||
|
memberCashOutMapper.updateById(model);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* checkTransferStatus
|
* checkTransferStatus
|
||||||
*/
|
*/
|
||||||
async checkTransferStatus(...args: any[]): Promise<any> {
|
async checkTransferStatus(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
iCoreMemberCashOutService.checkTransferStatus(RequestUtils.siteId(), id);
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,79 +14,69 @@ export class MemberConfigServiceImplService {
|
|||||||
* getLoginConfig
|
* getLoginConfig
|
||||||
*/
|
*/
|
||||||
async getLoginConfig(...args: any[]): Promise<any> {
|
async getLoginConfig(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
return iCoreMemberConfigService.getLoginConfig(RequestUtils.siteId());
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* setLoginConfig
|
* setLoginConfig
|
||||||
*/
|
*/
|
||||||
async setLoginConfig(...args: any[]): Promise<any> {
|
async setLoginConfig(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
iCoreMemberConfigService.setLoginConfig(RequestUtils.siteId(), configParam);
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* getCashOutConfig
|
* getCashOutConfig
|
||||||
*/
|
*/
|
||||||
async getCashOutConfig(...args: any[]): Promise<any> {
|
async getCashOutConfig(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
return iCoreMemberConfigService.getCashOutConfig(RequestUtils.siteId());
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* setCashOutConfig
|
* setCashOutConfig
|
||||||
*/
|
*/
|
||||||
async setCashOutConfig(...args: any[]): Promise<any> {
|
async setCashOutConfig(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
iCoreMemberConfigService.setCashOutConfig(RequestUtils.siteId(), configParam);
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* getMemberConfig
|
* getMemberConfig
|
||||||
*/
|
*/
|
||||||
async getMemberConfig(...args: any[]): Promise<any> {
|
async getMemberConfig(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
return iCoreMemberConfigService.getMemberConfig(RequestUtils.siteId());
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* setMemberConfig
|
* setMemberConfig
|
||||||
*/
|
*/
|
||||||
async setMemberConfig(...args: any[]): Promise<any> {
|
async setMemberConfig(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
iCoreMemberConfigService.setMemberConfig(RequestUtils.siteId(), configParam);
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* getGrowthRuleConfig
|
* getGrowthRuleConfig
|
||||||
*/
|
*/
|
||||||
async getGrowthRuleConfig(...args: any[]): Promise<any> {
|
async getGrowthRuleConfig(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
return iCoreMemberConfigService.getGrowthRuleConfig(RequestUtils.siteId());
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* setGrowthRuleConfig
|
* setGrowthRuleConfig
|
||||||
*/
|
*/
|
||||||
async setGrowthRuleConfig(...args: any[]): Promise<any> {
|
async setGrowthRuleConfig(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
iCoreMemberConfigService.setGrowthRuleConfig(RequestUtils.siteId(), configParam);
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* getPointRuleConfig
|
* getPointRuleConfig
|
||||||
*/
|
*/
|
||||||
async getPointRuleConfig(...args: any[]): Promise<any> {
|
async getPointRuleConfig(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
return iCoreMemberConfigService.getPointRuleConfig(RequestUtils.siteId());
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* setPointRuleConfig
|
* setPointRuleConfig
|
||||||
*/
|
*/
|
||||||
async setPointRuleConfig(...args: any[]): Promise<any> {
|
async setPointRuleConfig(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
iCoreMemberConfigService.setPointRuleConfig(RequestUtils.siteId(), configParam);
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,47 +14,119 @@ export class MemberLabelServiceImplService {
|
|||||||
* list
|
* list
|
||||||
*/
|
*/
|
||||||
async list(...args: any[]): Promise<any[]> {
|
async list(...args: any[]): Promise<any[]> {
|
||||||
// TODO: 实现业务逻辑
|
const siteId: number = RequestUtils.siteId();
|
||||||
return [];
|
|
||||||
|
const page: number = pageParam.getPage();
|
||||||
|
const limit: number = pageParam.getLimit();
|
||||||
|
|
||||||
|
const queryWrapper: QueryWrapper<MemberLabel> = new QueryWrapper<>();
|
||||||
|
queryWrapper.eq("site_id", siteId);
|
||||||
|
queryWrapper.orderByDesc("label_id");
|
||||||
|
if (ObjectUtil.isNotEmpty(searchParam.getLabelName())){
|
||||||
|
queryWrapper.like("label_name", searchParam.getLabelName());
|
||||||
|
}
|
||||||
|
const iPage: IPage<MemberLabel> = memberLabelMapper.selectPage(new Page<>(page, limit), queryWrapper);
|
||||||
|
const list: MemberLabelListVo[] = [];
|
||||||
|
for (const item of iPage.getRecords()) {
|
||||||
|
const vo: MemberLabelListVo = new MemberLabelListVo();
|
||||||
|
const labelId: number = item.getLabelId();
|
||||||
|
const wrapper: QueryWrapper<Member> = new QueryWrapper<>();
|
||||||
|
wrapper.eq("site_id",siteId);
|
||||||
|
const canshu: string = String.valueOf(labelId);
|
||||||
|
//添加如果是空值判断
|
||||||
|
wrapper.apply("JSON_VALID(member_label) = 1 AND JSON_SEARCH(member_label, 'one', {0}) IS NOT NULL",canshu);
|
||||||
|
const members: Member[] = memberMapper.selectList(wrapper);
|
||||||
|
BeanUtils.copyProperties(item, vo);
|
||||||
|
vo.setMemberNum(members.size());
|
||||||
|
list.add(vo);
|
||||||
|
}
|
||||||
|
return PageResult.build(page, limit, iPage.getTotal()).setData(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* info
|
* info
|
||||||
*/
|
*/
|
||||||
async info(...args: any[]): Promise<any> {
|
async info(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const siteId: number = RequestUtils.siteId();
|
||||||
return null;
|
|
||||||
|
const model: MemberLabel = memberLabelMapper.selectOne(
|
||||||
|
new QueryWrapper<MemberLabel>()
|
||||||
|
.eq("site_id", siteId)
|
||||||
|
.eq("label_id", id)
|
||||||
|
.last("limit 1"));
|
||||||
|
|
||||||
|
Assert.notNull(model, "标签不存在");
|
||||||
|
|
||||||
|
const vo: MemberLabelInfoVo = new MemberLabelInfoVo();
|
||||||
|
BeanUtils.copyProperties(model, vo);
|
||||||
|
return vo;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* add
|
* add
|
||||||
*/
|
*/
|
||||||
async add(...args: any[]): Promise<any> {
|
async add(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const siteId: number = RequestUtils.siteId();
|
||||||
return null;
|
|
||||||
|
const model: MemberLabel = new MemberLabel();
|
||||||
|
model.setSiteId(siteId);
|
||||||
|
model.setLabelName(addParam.getLabelName());
|
||||||
|
model.setMemo(addParam.getMemo());
|
||||||
|
model.setSort(addParam.getSort());
|
||||||
|
model.setCreateTime(System.currentTimeMillis() / 1000);
|
||||||
|
|
||||||
|
memberLabelMapper.insert(model);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* edit
|
* edit
|
||||||
*/
|
*/
|
||||||
async edit(...args: any[]): Promise<any> {
|
async edit(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const siteId: number = RequestUtils.siteId();
|
||||||
return null;
|
|
||||||
|
const updateWrapper: UpdateWrapper<MemberLabel> = new UpdateWrapper<>();
|
||||||
|
updateWrapper.eq("site_id", siteId)
|
||||||
|
.eq("label_id", id);
|
||||||
|
|
||||||
|
const model: MemberLabel = new MemberLabel();
|
||||||
|
model.setLabelName(editParam.getLabelName());
|
||||||
|
model.setMemo(editParam.getMemo());
|
||||||
|
model.setSort(editParam.getSort());
|
||||||
|
model.setUpdateTime(System.currentTimeMillis() / 1000);
|
||||||
|
|
||||||
|
memberLabelMapper.update(model, updateWrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* del
|
* del
|
||||||
*/
|
*/
|
||||||
async del(...args: any[]): Promise<any> {
|
async del(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const siteId: number = RequestUtils.siteId();
|
||||||
return null;
|
|
||||||
|
const queryWrapper: QueryWrapper<MemberLabel> = new QueryWrapper<MemberLabel>()
|
||||||
|
.eq("site_id", siteId)
|
||||||
|
.eq("label_id", id);
|
||||||
|
|
||||||
|
memberLabelMapper.delete(queryWrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* all
|
* all
|
||||||
*/
|
*/
|
||||||
async all(...args: any[]): Promise<any> {
|
async all(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const siteId: number = RequestUtils.siteId();
|
||||||
return null;
|
|
||||||
|
const queryWrapper: MPJQueryWrapper<MemberLabel> = new MPJQueryWrapper<MemberLabel>();
|
||||||
|
queryWrapper.select("label_id,label_name").eq("site_id", siteId);
|
||||||
|
|
||||||
|
const labels: MemberLabel[] = memberLabelMapper.selectList(queryWrapper); // 调用 selectList 方法
|
||||||
|
|
||||||
|
const list: MemberLabelAllListVo[] = [];
|
||||||
|
for (const item of labels) {
|
||||||
|
const vo: MemberLabelAllListVo = new MemberLabelAllListVo();
|
||||||
|
BeanUtils.copyProperties(item, vo);
|
||||||
|
list.add(vo);
|
||||||
|
}
|
||||||
|
return list;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,47 +14,122 @@ export class MemberLevelServiceImplService {
|
|||||||
* list
|
* list
|
||||||
*/
|
*/
|
||||||
async list(...args: any[]): Promise<any[]> {
|
async list(...args: any[]): Promise<any[]> {
|
||||||
// TODO: 实现业务逻辑
|
const siteId: number = RequestUtils.siteId();
|
||||||
return [];
|
const page: number = pageParam.getPage();
|
||||||
|
const limit: number = pageParam.getLimit();
|
||||||
|
|
||||||
|
const queryWrapper: QueryWrapper<MemberLevel> = new QueryWrapper<>();
|
||||||
|
queryWrapper.eq("site_id", siteId);
|
||||||
|
queryWrapper.orderByAsc("growth");
|
||||||
|
if (ObjectUtil.isNotEmpty(searchParam.getLevelName())) queryWrapper.like("level_name", searchParam.getLevelName());
|
||||||
|
|
||||||
|
const iPage: IPage<MemberLevel> = memberLevelMapper.selectPage(new Page<>(page, limit), queryWrapper);
|
||||||
|
const list: MemberLevelListVo[] = [];
|
||||||
|
for (const item of iPage.getRecords()) {
|
||||||
|
const vo: MemberLevelListVo = new MemberLevelListVo();
|
||||||
|
BeanUtils.copyProperties(item, vo);
|
||||||
|
vo.setMemberNum(memberMapper.selectCount(new QueryWrapper<Member>().eq("member_level", vo.getLevelId())));
|
||||||
|
if (ObjectUtil.isNotEmpty(item.getLevelBenefits())) vo.setLevelBenefits(coreMemberService.getBenefitsContent(item.getSiteId(), JSONUtil.parseObj(item.getLevelBenefits()), "admin"));
|
||||||
|
if (ObjectUtil.isNotEmpty(item.getLevelGifts())) vo.setLevelGifts(coreMemberService.getGiftContent(item.getSiteId(), JSONUtil.parseObj(item.getLevelGifts()), "admin"));
|
||||||
|
list.add(vo);
|
||||||
|
}
|
||||||
|
return PageResult.build(page, limit, iPage.getTotal()).setData(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* info
|
* info
|
||||||
*/
|
*/
|
||||||
async info(...args: any[]): Promise<any> {
|
async info(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const siteId: number = RequestUtils.siteId();
|
||||||
return null;
|
|
||||||
|
const model: MemberLevel = memberLevelMapper.selectOne(
|
||||||
|
new QueryWrapper<MemberLevel>()
|
||||||
|
.eq("site_id", siteId)
|
||||||
|
.eq("level_id", id)
|
||||||
|
.last("limit 1"));
|
||||||
|
|
||||||
|
Assert.notNull(model, "等级不存在");
|
||||||
|
|
||||||
|
const vo: MemberLevelInfoVo = new MemberLevelInfoVo();
|
||||||
|
BeanUtils.copyProperties(model, vo);
|
||||||
|
return vo;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* add
|
* add
|
||||||
*/
|
*/
|
||||||
async add(...args: any[]): Promise<any> {
|
async add(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const siteId: number = RequestUtils.siteId();
|
||||||
return null;
|
|
||||||
|
const model: MemberLevel = new MemberLevel();
|
||||||
|
|
||||||
|
model.setSiteId(siteId);
|
||||||
|
model.setLevelName(addParam.getLevelName());
|
||||||
|
model.setGrowth(addParam.getGrowth());
|
||||||
|
model.setRemark(addParam.getRemark());
|
||||||
|
model.setCreateTime(System.currentTimeMillis() / 1000);
|
||||||
|
model.setLevelBenefits(addParam.getLevelBenefits().toString());
|
||||||
|
model.setLevelGifts(addParam.getLevelGifts().toString());
|
||||||
|
|
||||||
|
memberLevelMapper.insert(model);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* edit
|
* edit
|
||||||
*/
|
*/
|
||||||
async edit(...args: any[]): Promise<any> {
|
async edit(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const siteId: number = RequestUtils.siteId();
|
||||||
return null;
|
|
||||||
|
const updateWrapper: UpdateWrapper<MemberLevel> = new UpdateWrapper<>();
|
||||||
|
updateWrapper.eq("site_id", siteId)
|
||||||
|
.eq("level_id", id);
|
||||||
|
|
||||||
|
const model: MemberLevel = new MemberLevel();
|
||||||
|
model.setLevelName(editParam.getLevelName());
|
||||||
|
model.setGrowth(editParam.getGrowth());
|
||||||
|
model.setRemark(editParam.getRemark());
|
||||||
|
model.setUpdateTime(System.currentTimeMillis() / 1000);
|
||||||
|
model.setLevelBenefits(editParam.getLevelBenefits().toString());
|
||||||
|
model.setLevelGifts(editParam.getLevelGifts().toString());
|
||||||
|
|
||||||
|
memberLevelMapper.update(model, updateWrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* del
|
* del
|
||||||
*/
|
*/
|
||||||
async del(...args: any[]): Promise<any> {
|
async del(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const siteId: number = RequestUtils.siteId();
|
||||||
return null;
|
|
||||||
|
const memberNum: number = memberMapper.selectCount(new QueryWrapper<Member>()
|
||||||
|
.eq("site_id", siteId)
|
||||||
|
.eq("member_level", id));
|
||||||
|
if (memberNum > 0) throw new BadRequestException("该等级下存在会员不允许删除");
|
||||||
|
|
||||||
|
const queryWrapper: QueryWrapper<MemberLevel> = new QueryWrapper<MemberLevel>()
|
||||||
|
.eq("site_id", siteId)
|
||||||
|
.eq("level_id", id);
|
||||||
|
|
||||||
|
memberLevelMapper.delete(queryWrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* all
|
* all
|
||||||
*/
|
*/
|
||||||
async all(...args: any[]): Promise<any> {
|
async all(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const siteId: number = RequestUtils.siteId();
|
||||||
return null;
|
|
||||||
|
const queryWrapper: MPJQueryWrapper<MemberLevel> = new MPJQueryWrapper<MemberLevel>();
|
||||||
|
queryWrapper.select("level_id,level_name, growth,site_id,level_benefits,level_gifts").eq("site_id", siteId);
|
||||||
|
|
||||||
|
const labels: MemberLevel[] = memberLevelMapper.selectList(queryWrapper); // 调用 selectList 方法
|
||||||
|
|
||||||
|
const list: MemberLevelAllListVo[] = [];
|
||||||
|
for (const item of labels) {
|
||||||
|
const vo: MemberLevelAllListVo = new MemberLevelAllListVo();
|
||||||
|
BeanUtils.copyProperties(item, vo);
|
||||||
|
list.add(vo);
|
||||||
|
}
|
||||||
|
return list;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,95 +14,353 @@ export class MemberServiceImplService {
|
|||||||
* list
|
* list
|
||||||
*/
|
*/
|
||||||
async list(...args: any[]): Promise<any[]> {
|
async list(...args: any[]): Promise<any[]> {
|
||||||
// TODO: 实现业务逻辑
|
const page: number = pageParam.getPage();
|
||||||
return [];
|
const limit: number = pageParam.getLimit();
|
||||||
|
|
||||||
|
const siteId: number = RequestUtils.siteId();
|
||||||
|
const queryWrapper: MPJQueryWrapper<Member> = new MPJQueryWrapper<>();
|
||||||
|
queryWrapper.setAlias("m").leftJoin("?_member_level ml ON ml.level_id = m.member_level".replace("?_", this.config.get('tablePrefix')));
|
||||||
|
queryWrapper.select("m.*, ml.level_name as member_level_name");
|
||||||
|
queryWrapper.eq("m.site_id", siteId);
|
||||||
|
queryWrapper.orderByDesc("member_id");
|
||||||
|
|
||||||
|
// 查询条件
|
||||||
|
if (ObjectUtil.isNotEmpty(searchParam.getKeyword())) {
|
||||||
|
queryWrapper.and(i => i.like("member_no", searchParam.getKeyword()).or()
|
||||||
|
.like("username", searchParam.getKeyword()).or()
|
||||||
|
.like("nickname", searchParam.getKeyword()).or()
|
||||||
|
.like("mobile", searchParam.getKeyword()));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ObjectUtil.isNotNull(searchParam.getIsDel()) && ObjectUtil.isNotEmpty(searchParam.getKeyword())) {
|
||||||
|
queryWrapper.eq("is_del", searchParam.getIsDel());
|
||||||
|
}
|
||||||
|
if (ObjectUtil.isNotEmpty(searchParam.getMemberLevel()) && searchParam.getMemberLevel() != 0) {
|
||||||
|
queryWrapper.eq("member_level", searchParam.getMemberLevel());
|
||||||
|
}
|
||||||
|
if (ObjectUtil.isNotEmpty(searchParam.getRegisterChannel())) {
|
||||||
|
queryWrapper.eq("register_channel", searchParam.getRegisterChannel());
|
||||||
|
}
|
||||||
|
if (ObjectUtil.isNotEmpty(searchParam.getMemberLabel()) && searchParam.getMemberLabel() != 0) {
|
||||||
|
queryWrapper.like("member_label", searchParam.getMemberLabel());
|
||||||
|
}
|
||||||
|
if (ObjectUtil.isNotEmpty(searchParam.getRegisterType())) {
|
||||||
|
queryWrapper.eq("register_type", searchParam.getRegisterType());
|
||||||
|
}
|
||||||
|
if (ObjectUtil.isNotEmpty(searchParam.getCreateTime())) {
|
||||||
|
QueryMapperUtils.buildByTime(queryWrapper, "m.create_time", searchParam.getCreateTime());
|
||||||
|
}
|
||||||
|
|
||||||
|
const iPage: IPage<Member> = null;
|
||||||
|
const memberList: Member[] = [];
|
||||||
|
if (page > 0 && limit > 0) {
|
||||||
|
iPage = memberMapper.selectPage(new Page<>(page, limit), queryWrapper);
|
||||||
|
memberList = iPage.getRecords();
|
||||||
|
} else {
|
||||||
|
memberList = memberMapper.selectList(queryWrapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
const levelMap: Record<string, any> = Collections.emptyMap();
|
||||||
|
const levelIds: Set<number> = CollStreamUtil.toSet(memberList, Member::getMemberLevel);
|
||||||
|
if (ObjectUtil.isNotEmpty(levelIds)) {
|
||||||
|
levelMap = memberLevelMapper.selectBatchIds(levelIds).stream().collect(Collectors.toMap(MemberLevel::getLevelId, e => e));
|
||||||
|
}
|
||||||
|
|
||||||
|
const list: MemberListVo[] = [];
|
||||||
|
for (const item of memberList) {
|
||||||
|
const vo: MemberListVo = new MemberListVo();
|
||||||
|
BeanUtils.copyProperties(item, vo);
|
||||||
|
vo.setSexName(SexEnum.getNameBySex(item.getSex()));
|
||||||
|
vo.setStatusName(StatusEnum.getNameByStatus(item.getStatus()));
|
||||||
|
vo.setRegisterChannelName(ChannelEnum.getNameByCode(item.getRegisterChannel()));
|
||||||
|
vo.setMemberLevelName(levelMap.getOrDefault(item.getMemberLevel(), new MemberLevel()).getLevelName());
|
||||||
|
|
||||||
|
if (!item.getMemberLabel().isEmpty()) {
|
||||||
|
const memberLabelArrays: JSONArray = JSONUtil.parseArray(vo.getMemberLabel());
|
||||||
|
if (memberLabelArrays != null && memberLabelArrays.size() > 0) {
|
||||||
|
const memberLabelArray: MemberLabelAllListVo[] = [];
|
||||||
|
const labelList: MemberLabel[] = memberLabelMapper.selectList(new QueryWrapper<MemberLabel>().select("label_name").in("label_id", memberLabelArrays));
|
||||||
|
for (const labelItem of labelList) {
|
||||||
|
const labelVo: MemberLabelAllListVo = new MemberLabelAllListVo();
|
||||||
|
BeanUtils.copyProperties(labelItem, labelVo);
|
||||||
|
memberLabelArray.add(labelVo);
|
||||||
|
}
|
||||||
|
vo.setMemberLabelArray(memberLabelArray);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
list.add(vo);
|
||||||
|
}
|
||||||
|
return PageResult.build(const iPage: page, limit, = = null ? list.size() : iPage.getTotal()).setData(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* info
|
* info
|
||||||
*/
|
*/
|
||||||
async info(...args: any[]): Promise<any> {
|
async info(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const siteId: number = RequestUtils.siteId();
|
||||||
return null;
|
|
||||||
|
const model: Member = memberMapper.selectOne(
|
||||||
|
new MPJQueryWrapper<Member>()
|
||||||
|
.setAlias("m")
|
||||||
|
.leftJoin("?_member_level ml ON ml.level_id = m.member_level".replace("?_", this.config.get('tablePrefix')))
|
||||||
|
.select("m.*, ml.level_name as member_level_name")
|
||||||
|
.eq("member_id", id)
|
||||||
|
.eq("m.site_id", siteId)
|
||||||
|
.last("limit 1"));
|
||||||
|
|
||||||
|
Assert.notNull(model, "数据不存在");
|
||||||
|
|
||||||
|
const vo: MemberInfoVo = new MemberInfoVo();
|
||||||
|
BeanUtils.copyProperties(model, vo);
|
||||||
|
if ("0" === model.getMemberLevel()){
|
||||||
|
vo.setMemberLevel("");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (StrUtil.isNotEmpty(model.getMemberLabel()) && !Arrays.asList(model.getMemberLabel()).isEmpty()) {
|
||||||
|
const memberLabelArrays: JSONArray = JSONUtil.parseArray(vo.getMemberLabel());
|
||||||
|
if (memberLabelArrays != null && memberLabelArrays.size() > 0) {
|
||||||
|
const memberLabelArray: MemberLabelAllListVo[] = [];
|
||||||
|
const labelList: MemberLabel[] = memberLabelMapper.selectList(new QueryWrapper<MemberLabel>().select("label_name,label_id").in("label_id", memberLabelArrays));
|
||||||
|
for (const item of labelList) {
|
||||||
|
const labelVo: MemberLabelAllListVo = new MemberLabelAllListVo();
|
||||||
|
BeanUtils.copyProperties(item, labelVo);
|
||||||
|
memberLabelArray.add(labelVo);
|
||||||
|
}
|
||||||
|
vo.setMemberLabelArray(memberLabelArray);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return vo;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* add
|
* add
|
||||||
*/
|
*/
|
||||||
async add(...args: any[]): Promise<any> {
|
async add(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const siteId: number = RequestUtils.siteId();
|
||||||
return null;
|
|
||||||
|
addParam.setUsername(addParam.getMobile());
|
||||||
|
|
||||||
|
const mobileIsExist: Member = memberMapper.selectOne(new QueryWrapper<Member>()
|
||||||
|
.select("member_id")
|
||||||
|
.eq("site_id", siteId)
|
||||||
|
.and(i => i.eq("mobile", addParam.getMobile()).or().eq("username", addParam.getMobile()))
|
||||||
|
.last("limit 1"));
|
||||||
|
Assert.isNull(mobileIsExist, "手机号已存在");
|
||||||
|
|
||||||
|
if (addParam.getNickname().length() == 0 & addParam.getMobile().length() > 0) {
|
||||||
|
addParam.setNickname(addParam.getMobile().replaceAll("(\\d{3})\\d{4}(\\d{4})", "$1****$2"));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (addParam.getMemberNo().isEmpty()) {
|
||||||
|
addParam.setMemberNo(iCoreMemberService.createMemberNo(siteId));
|
||||||
|
} else {
|
||||||
|
const memberNoIsExist: Member = memberMapper.selectOne(new QueryWrapper<Member>()
|
||||||
|
.select("member_id")
|
||||||
|
.eq("site_id", siteId)
|
||||||
|
.eq("member_no", addParam.getMemberNo())
|
||||||
|
.last("limit 1"));
|
||||||
|
Assert.isNull(memberNoIsExist, "会员编码已存在");
|
||||||
|
}
|
||||||
|
|
||||||
|
const model: Member = new Member();
|
||||||
|
model.setSiteId(siteId);
|
||||||
|
model.setMobile(addParam.getMobile());
|
||||||
|
model.setMemberNo(addParam.getMemberNo());
|
||||||
|
model.setUsername(addParam.getUsername());
|
||||||
|
model.setNickname(addParam.getNickname());
|
||||||
|
model.setHeadimg(addParam.getHeadimg());
|
||||||
|
model.setPassword(PasswordEncipher.encode(addParam.getPassword()));
|
||||||
|
model.setRegisterType(MemberRegisterTypeEnum.MANUAL.getType());
|
||||||
|
model.setRegisterChannel(MemberRegisterChannelEnum.MANUAL.getType());
|
||||||
|
model.setCreateTime(System.currentTimeMillis() / 1000);
|
||||||
|
model.setMemberLabel("[]");
|
||||||
|
memberMapper.insert(model);
|
||||||
|
// 会员注册事件
|
||||||
|
const registerEvent: MemberRegisterEvent = new MemberRegisterEvent();
|
||||||
|
registerEvent.setSiteId(RequestUtils.siteId());
|
||||||
|
registerEvent.addAppSign("shop_fenxiao");
|
||||||
|
registerEvent.setName("MemberRegisterEvent");
|
||||||
|
registerEvent.setMember(model);
|
||||||
|
EventPublisher.publishEvent(registerEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* edit
|
* edit
|
||||||
*/
|
*/
|
||||||
async edit(...args: any[]): Promise<any> {
|
async edit(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const siteId: number = RequestUtils.siteId();
|
||||||
return null;
|
|
||||||
|
const updateWrapper: UpdateWrapper<Member> = new UpdateWrapper<>();
|
||||||
|
updateWrapper.eq("site_id", siteId)
|
||||||
|
.eq("member_id", id);
|
||||||
|
|
||||||
|
const model: Member = new Member();
|
||||||
|
model.setNickname(editParam.getNickname());
|
||||||
|
model.setHeadimg(editParam.getHeadimg());
|
||||||
|
model.setPassword(editParam.getPassword());
|
||||||
|
model.setSex(editParam.getSex());
|
||||||
|
model.setBirthday(editParam.getBirthday());
|
||||||
|
|
||||||
|
memberMapper.update(model, updateWrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* modify
|
* modify
|
||||||
*/
|
*/
|
||||||
async modify(...args: any[]): Promise<any> {
|
async modify(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
if (editParam == null || editParam.getField() == null || editParam.getValue() == null) {
|
||||||
return null;
|
if(editParam.getField() === "member_label"){
|
||||||
|
throw new AdminException("修改参数不能为空");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const siteId: number = RequestUtils.siteId();
|
||||||
|
const value: string = String.valueOf(editParam.getValue()).trim();
|
||||||
|
|
||||||
|
const updateWrapper: LambdaUpdateWrapper<Member> = new LambdaUpdateWrapper<>();
|
||||||
|
updateWrapper.eq(Member::getSiteId, siteId)
|
||||||
|
.eq(Member::getMemberId, editParam.getMemberId());
|
||||||
|
|
||||||
|
switch (editParam.getField()) {
|
||||||
|
case "nickname":
|
||||||
|
updateWrapper.set(Member::getNickname, value === "" || value === "null" ? "" : value);
|
||||||
|
break;
|
||||||
|
case "headimg":
|
||||||
|
updateWrapper.set(Member::getHeadimg, value === "" || value === "null" ? "" : value);
|
||||||
|
break;
|
||||||
|
case "member_label":
|
||||||
|
updateWrapper.set(Member::getMemberLabel, value.length === 0 ? "[]" : value);
|
||||||
|
break;
|
||||||
|
case "member_level":
|
||||||
|
updateWrapper.set(Member::getMemberLevel, value === "" || value === "null" ? 0 : number.parseInt(value));
|
||||||
|
break;
|
||||||
|
case "birthday":
|
||||||
|
updateWrapper.set(Member::getBirthday, value === "" || value === "null" ? "" : value);
|
||||||
|
break;
|
||||||
|
case "sex":
|
||||||
|
updateWrapper.set(Member::getSex, value === "" || value === "null" ? 0 : number.parseInt(value));
|
||||||
|
break;
|
||||||
|
case "id_card":
|
||||||
|
// if (!IdcardUtil.isValidCard(value) && !value.length === 0){
|
||||||
|
// throw new AdminException("请输入正确的身份证号");
|
||||||
|
// }
|
||||||
|
updateWrapper.set(Member::getIdCard, value === "" || value === "null" ? "" : value);
|
||||||
|
break;
|
||||||
|
case "remark":
|
||||||
|
updateWrapper.set(Member::getRemark, value === "" || value === "null" ? "" : value);
|
||||||
|
break;
|
||||||
|
case "mobile":
|
||||||
|
if (!PhoneUtil.isPhone(value) && !value.length === 0){
|
||||||
|
throw new AdminException("请输入正确的手机号");
|
||||||
|
}
|
||||||
|
updateWrapper.set(Member::getMobile, value === "" || value === "null" ? "" : value);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
memberMapper.update(updateWrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* del
|
* del
|
||||||
*/
|
*/
|
||||||
async del(...args: any[]): Promise<any> {
|
async del(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const siteId: number = RequestUtils.siteId();
|
||||||
return null;
|
|
||||||
|
const queryWrapper: QueryWrapper<Member> = new QueryWrapper<Member>()
|
||||||
|
.eq("site_id", siteId)
|
||||||
|
.eq("member_id", id)
|
||||||
|
.last("limit 1");
|
||||||
|
|
||||||
|
memberMapper.delete(queryWrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* all
|
* all
|
||||||
*/
|
*/
|
||||||
async all(...args: any[]): Promise<any> {
|
async all(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const siteId: number = RequestUtils.siteId();
|
||||||
return null;
|
|
||||||
|
const queryWrapper: MPJQueryWrapper<Member> = new MPJQueryWrapper<Member>();
|
||||||
|
queryWrapper.select("member_id,headimg,nickname").eq("site_id", siteId);
|
||||||
|
if (ObjectUtil.isNotEmpty(searchParam.getKeyword()))
|
||||||
|
queryWrapper.like("member_no|username|nickname|mobile", searchParam.getKeyword());
|
||||||
|
|
||||||
|
const members: Member[] = memberMapper.selectList(queryWrapper); // 调用 selectList 方法
|
||||||
|
|
||||||
|
const list: MemberAllListVo[] = [];
|
||||||
|
for (const item of members) {
|
||||||
|
const vo: MemberAllListVo = new MemberAllListVo();
|
||||||
|
BeanUtils.copyProperties(item, vo);
|
||||||
|
list.add(vo);
|
||||||
|
}
|
||||||
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* setStatus
|
* setStatus
|
||||||
*/
|
*/
|
||||||
async setStatus(...args: any[]): Promise<any> {
|
async setStatus(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const siteId: number = RequestUtils.siteId();
|
||||||
return null;
|
|
||||||
|
const updateWrapper: UpdateWrapper<Member> = new UpdateWrapper<>();
|
||||||
|
updateWrapper.in("member_id", param.getMemberIds());
|
||||||
|
updateWrapper.eq("site_id", siteId);
|
||||||
|
|
||||||
|
const updateMember: Member = new Member();
|
||||||
|
updateMember.setStatus(status);
|
||||||
|
memberMapper.update(updateMember, updateWrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* getMemberNo
|
* getMemberNo
|
||||||
*/
|
*/
|
||||||
async getMemberNo(...args: any[]): Promise<any> {
|
async getMemberNo(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
return iCoreMemberService.createMemberNo(RequestUtils.siteId());
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* getMemberGiftsContent
|
* getMemberGiftsContent
|
||||||
*/
|
*/
|
||||||
async getMemberGiftsContent(...args: any[]): Promise<any> {
|
async getMemberGiftsContent(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
return iCoreMemberService.getGiftContent(RequestUtils.siteId(), param.getJSONObject("gifts"), "admin");
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* getMemberBenefitsContent
|
* getMemberBenefitsContent
|
||||||
*/
|
*/
|
||||||
async getMemberBenefitsContent(...args: any[]): Promise<any> {
|
async getMemberBenefitsContent(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
return iCoreMemberService.getBenefitsContent(RequestUtils.siteId(), param.getJSONObject("benefits"), "admin");
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* batchModify
|
* batchModify
|
||||||
*/
|
*/
|
||||||
async batchModify(...args: any[]): Promise<any> {
|
async batchModify(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
if (ObjectUtil.isEmpty(param.getValue().toString())){
|
||||||
return null;
|
return;
|
||||||
|
}
|
||||||
|
const field: string = param.getField();
|
||||||
|
const memberIds: number[] = param.getMemberIds();
|
||||||
|
const isAll: number = param.getIsAll();
|
||||||
|
if (!"member_label" === field && !"member_level" === field){
|
||||||
|
throw new BadRequestException("不支持的字段:" + field);
|
||||||
|
}
|
||||||
|
const uw: UpdateWrapper<Member> = new UpdateWrapper<>();
|
||||||
|
if (isAll == 0){
|
||||||
|
if (!(!memberIds || memberIds.length === 0)){
|
||||||
|
uw.in("member_id", memberIds);
|
||||||
|
}
|
||||||
|
}else {
|
||||||
|
if (!(!memberIds || memberIds.length === 0)) {
|
||||||
|
uw.notIn("member_id", memberIds);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ("member_label" === field){
|
||||||
|
const value: JSONArray = JSONUtil.parseArray(param.getValue());
|
||||||
|
uw.set("member_label", JSONUtil.toJsonStr(value));
|
||||||
|
}else if ("member_level" === field){
|
||||||
|
uw.set("member_level", number.parseInt(param.getValue().toString()));
|
||||||
|
}
|
||||||
|
memberMapper.update(uw);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,23 +14,58 @@ export class MemberSignServiceImplService {
|
|||||||
* pages
|
* pages
|
||||||
*/
|
*/
|
||||||
async pages(...args: any[]): Promise<any[]> {
|
async pages(...args: any[]): Promise<any[]> {
|
||||||
// TODO: 实现业务逻辑
|
const siteId: number = RequestUtils.siteId();
|
||||||
return [];
|
const page: number = pageParam.getPage();
|
||||||
|
const limit: number = pageParam.getLimit();
|
||||||
|
|
||||||
|
const queryWrapper: MPJQueryWrapper<MemberSign> = new MPJQueryWrapper<>();
|
||||||
|
queryWrapper.setAlias("ms").innerJoin("?_member m ON ms.member_id = m.member_id".replace("?_", this.config.get('tablePrefix')));
|
||||||
|
queryWrapper.select("ms.*,m.member_no,m.username,m.nickname,m.mobile,m.headimg");
|
||||||
|
queryWrapper.eq("ms.site_id", siteId);
|
||||||
|
queryWrapper.orderByDesc("ms.sign_id");
|
||||||
|
|
||||||
|
if (ObjectUtil.isNotEmpty(searchParam.getKeywords())){
|
||||||
|
// queryWrapper.like("m.member_no|m.username|m.nickname|m.mobile", searchParam.getKeywords());
|
||||||
|
QueryMapperUtils.addMultiLike(queryWrapper, searchParam.getKeywords(),
|
||||||
|
"m.member_no", "m.username", "m.nickname", "m.mobile");
|
||||||
|
}
|
||||||
|
if (ObjectUtil.isNotEmpty(searchParam.getCreateTime())) {
|
||||||
|
QueryMapperUtils.buildByTime(queryWrapper, "ms.create_time", searchParam.getCreateTime());
|
||||||
|
}
|
||||||
|
|
||||||
|
const iPage: IPage<MemberSign> = memberSignMapper.selectPage(new Page<>(page, limit), queryWrapper);
|
||||||
|
const list: MemberSignListVo[] = [];
|
||||||
|
for (const item of iPage.getRecords()) {
|
||||||
|
const vo: MemberSignListVo = new MemberSignListVo();
|
||||||
|
BeanUtils.copyProperties(item, vo);
|
||||||
|
|
||||||
|
if (!item.getDayAward().isEmpty()) {
|
||||||
|
vo.setDayAward(coreMemberService.getGiftContent(item.getSiteId(), JSONUtil.parseObj(item.getDayAward()), "admin"));
|
||||||
|
}
|
||||||
|
if (!item.getContinueAward().isEmpty()) {
|
||||||
|
vo.setContinueAward(coreMemberService.getGiftContent(item.getSiteId(), JSONUtil.parseObj(item.getContinueAward()), "admin"));
|
||||||
|
}
|
||||||
|
const memberInfoVo: MemberBriefInfoVo = new MemberBriefInfoVo();
|
||||||
|
BeanUtils.copyProperties(item, memberInfoVo);
|
||||||
|
|
||||||
|
vo.setMember(memberInfoVo);
|
||||||
|
list.add(vo);
|
||||||
|
}
|
||||||
|
return PageResult.build(page, limit, iPage.getTotal()).setData(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* getSignConfig
|
* getSignConfig
|
||||||
*/
|
*/
|
||||||
async getSignConfig(...args: any[]): Promise<any> {
|
async getSignConfig(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const config: Record<string, any> = iCoreConfigService.getConfigValue(RequestUtils.siteId(), "SIGN_CONFIG");
|
||||||
return null;
|
return JSONUtil.toBean(config, SignConfigVo.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* setSignConfig
|
* setSignConfig
|
||||||
*/
|
*/
|
||||||
async setSignConfig(...args: any[]): Promise<any> {
|
async setSignConfig(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
iCoreConfigService.setConfig(RequestUtils.siteId(), "SIGN_CONFIG", JSONUtil.parseObj(configParam));
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,55 +14,139 @@ export class CloudBuildServiceImplService {
|
|||||||
* getBuildTask
|
* getBuildTask
|
||||||
*/
|
*/
|
||||||
async getBuildTask(...args: any[]): Promise<any> {
|
async getBuildTask(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
if (cached.get("cloud_build_task") == null) return null;
|
||||||
return null;
|
this.buildTask = (Record<string, any>) cached.get("cloud_build_task");
|
||||||
|
if (!this.buildTask.getStr("mode") === mode) return null;
|
||||||
|
return this.buildTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* buildPreCheck
|
* buildPreCheck
|
||||||
*/
|
*/
|
||||||
async buildPreCheck(...args: any[]): Promise<any> {
|
async buildPreCheck(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const checkResult: Record<string, any> = new Record<string, any>();
|
||||||
return null;
|
checkResult.put("is_pass", true);
|
||||||
|
checkResult.put("dir", new HashMap());
|
||||||
|
return checkResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* build
|
* build
|
||||||
*/
|
*/
|
||||||
async build(...args: any[]): Promise<any> {
|
async build(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
getBuildTask(mode);
|
||||||
return null;
|
|
||||||
|
if (this.buildTask != null) throw new BadRequestException("已有正在执行中的编译任务");
|
||||||
|
|
||||||
|
const taskKey: string = RandomUtil.randomString(10);
|
||||||
|
|
||||||
|
this.buildTask = new Record<string, any>();
|
||||||
|
this.buildTask.set("mode", mode);
|
||||||
|
this.buildTask.set("task_key", taskKey);
|
||||||
|
|
||||||
|
const tempDir: string = this.config.get('webRootDownRuntime') + "cloud_build/" + taskKey + "/";
|
||||||
|
const packageDir: string = tempDir + "package/";
|
||||||
|
FileTools.createDirs(packageDir);
|
||||||
|
|
||||||
|
buildPackage(packageDir);
|
||||||
|
|
||||||
|
const zipFile: string = ZipUtil.zip(packageDir, tempDir + "build.zip");
|
||||||
|
|
||||||
|
const instance: NiucloudUtils = NiucloudUtils.getInstance();
|
||||||
|
|
||||||
|
const actionQuery: Record<string, any> = {};
|
||||||
|
actionQuery.put("data[product_key]", instance.getProductKey());
|
||||||
|
const actionToken: Record<string, any> = niucloudService.getActionToken("cloudbuild", actionQuery);
|
||||||
|
|
||||||
|
const query: Record<string, any> = {};
|
||||||
|
query.put("authorize_code", instance.getCode());
|
||||||
|
query.put("timestamp", System.currentTimeMillis() / 1000);
|
||||||
|
query.put("token", actionToken == null ? "" : actionToken.getStr("token"));
|
||||||
|
|
||||||
|
const response: HttpResponse = new NiucloudUtils.Cloud().useThirdBuild().build("cloud/build").query(query)
|
||||||
|
.func(i => {
|
||||||
|
i.form("file", zipFile, "build.zip");
|
||||||
|
})
|
||||||
|
.method(Method.POST).execute();
|
||||||
|
|
||||||
|
const res: Record<string, any> = JSONUtil.parseObj(response.body());
|
||||||
|
|
||||||
|
if (!res.getInt("code", 0) === 1) throw new BadRequestException(res.getStr("msg"));
|
||||||
|
|
||||||
|
this.buildTask.set("timestamp", query.get("timestamp"));
|
||||||
|
cached.put("cloud_build_task", this.buildTask);
|
||||||
|
|
||||||
|
return this.buildTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* getBuildLog
|
* getBuildLog
|
||||||
*/
|
*/
|
||||||
async getBuildLog(...args: any[]): Promise<any> {
|
async getBuildLog(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
getBuildTask(mode);
|
||||||
return null;
|
|
||||||
|
if (this.buildTask == null) return null;
|
||||||
|
if (!this.buildTask.getStr("mode") === mode) return null;
|
||||||
|
|
||||||
|
const instance: NiucloudUtils = NiucloudUtils.getInstance();
|
||||||
|
|
||||||
|
const query: Record<string, any> = {};
|
||||||
|
query.put("authorize_code", instance.getCode());
|
||||||
|
query.put("timestamp", this.buildTask.getStr("timestamp"));
|
||||||
|
|
||||||
|
const response: HttpResponse = new NiucloudUtils.Cloud().useThirdBuild().build("cloud/get_build_logs").query(query).method(Method.GET).execute();
|
||||||
|
if (!JSONUtil.isJson(response.body())) return null;
|
||||||
|
|
||||||
|
const res: Record<string, any> = JSONUtil.parseObj(response.body());
|
||||||
|
|
||||||
|
const data: JSONArray = res.getByPath("data.0", JSONArray.class);
|
||||||
|
if (data.size() > 0) {
|
||||||
|
const last: Record<string, any> = data.getJSONObject(data.size() - 1);
|
||||||
|
if (last.getInt("percent", 0) === 100 && last.getInt("code", 0) === 1) {
|
||||||
|
res = buildSuccess(res);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* setLocalCloudCompileConfig
|
* setLocalCloudCompileConfig
|
||||||
*/
|
*/
|
||||||
async setLocalCloudCompileConfig(...args: any[]): Promise<any> {
|
async setLocalCloudCompileConfig(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const jsonObject: Record<string, any> = JSONUtil.parseObj(JSONUtil.toJsonPrettyStr(param));
|
||||||
return null;
|
coreConfigService.setConfig(RequestUtils.defaultSiteId(), "LOCAL_CLOUD_COMPILE_CONFIG", jsonObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* connectTest
|
* connectTest
|
||||||
*/
|
*/
|
||||||
async connectTest(...args: any[]): Promise<any> {
|
async connectTest(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
try {
|
||||||
return null;
|
const stringBuilder: StringBuilder = new StringBuilder();
|
||||||
|
stringBuilder.append("http://")
|
||||||
|
.append(InetAddress.getByName("oss.niucloud.com").getHostAddress())
|
||||||
|
.append(":8000/");
|
||||||
|
baseUrl = stringBuilder.toString();
|
||||||
|
if (checkLocal){
|
||||||
|
isConnected =checkLocal(url);
|
||||||
|
}
|
||||||
|
return isConnected;
|
||||||
|
} catch (UnknownHostException e) {
|
||||||
|
throw new AdminException("联通测试失败");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* clearBuildTask
|
* clearBuildTask
|
||||||
*/
|
*/
|
||||||
async clearBuildTask(...args: any[]): Promise<any> {
|
async clearBuildTask(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
if (this.buildTask == null) return;
|
||||||
return null;
|
const tempDir: string = this.config.get('webRootDownRuntime' + "cloud_build/" + this.buildTask.getStr("task_key"));
|
||||||
|
try {
|
||||||
|
if (fs.existsSync(tempDir)) FileUtils.deleteDirectory(tempDir);
|
||||||
|
} catch (Exception e) {
|
||||||
|
}
|
||||||
|
cached.remove("cloud_build_task");
|
||||||
|
this.buildTask = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,63 +14,138 @@ export class NiuCloudServiceImplService {
|
|||||||
* getFrameworkLastVersion
|
* getFrameworkLastVersion
|
||||||
*/
|
*/
|
||||||
async getFrameworkLastVersion(...args: any[]): Promise<any> {
|
async getFrameworkLastVersion(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const instance: NiucloudUtils = NiucloudUtils.getInstance();
|
||||||
return null;
|
|
||||||
|
const query: Record<string, any> = {};
|
||||||
|
query.put("product_key", instance.getProductKey());
|
||||||
|
|
||||||
|
const data: Record<string, any> = NiucloudUtils.Niucloud.get("store/framework/lastversion", query).getJSONObject("data");
|
||||||
|
|
||||||
|
const frameWorkVersion: FrameWorkVersion = new FrameWorkVersion();
|
||||||
|
if (data != null) {
|
||||||
|
frameWorkVersion.setLastVersion(data.getStr("last_version", ""));
|
||||||
|
frameWorkVersion.setLastUpdateTime(data.getStr("last_update_time", ""));
|
||||||
|
}
|
||||||
|
|
||||||
|
return frameWorkVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* getFrameworkVersionList
|
* getFrameworkVersionList
|
||||||
*/
|
*/
|
||||||
async getFrameworkVersionList(...args: any[]): Promise<any> {
|
async getFrameworkVersionList(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const instance: NiucloudUtils = NiucloudUtils.getInstance();
|
||||||
return null;
|
|
||||||
|
const query: Record<string, any> = {};
|
||||||
|
query.put("product_key", instance.getProductKey());
|
||||||
|
|
||||||
|
const data: JSONArray = NiucloudUtils.Niucloud.get("store/framework/version", query).getJSONArray("data");
|
||||||
|
if (data == null) return null;
|
||||||
|
|
||||||
|
const list: FrameworkVersionListVo[] = [];
|
||||||
|
for (const i of number = 0; i < data.size(); i++) {
|
||||||
|
list.add(JSONUtil.toBean(data.getJSONObject(i), FrameworkVersionListVo.class));
|
||||||
|
}
|
||||||
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* getAuthinfo
|
* getAuthinfo
|
||||||
*/
|
*/
|
||||||
async getAuthinfo(...args: any[]): Promise<any> {
|
async getAuthinfo(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const instance: NiucloudUtils = NiucloudUtils.getInstance();
|
||||||
return null;
|
|
||||||
|
const query: Record<string, any> = {};
|
||||||
|
query.put("code", instance.getCode());
|
||||||
|
query.put("secret", instance.getSecret());
|
||||||
|
query.put("product_key", instance.getProductKey());
|
||||||
|
|
||||||
|
const authInfo: Record<string, any> = NiucloudUtils.Niucloud.get("authinfo", query).getJSONObject("data");
|
||||||
|
if (authInfo == null) return null;
|
||||||
|
|
||||||
|
const vo: AuthInfoVo = new AuthInfoVo();
|
||||||
|
AuthInfoVo.const data: AuthInfo = JSONUtil.toBean(authInfo, AuthInfoVo.AuthInfo.class);
|
||||||
|
vo.setData(data);
|
||||||
|
return vo;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* setAuthorize
|
* setAuthorize
|
||||||
*/
|
*/
|
||||||
async setAuthorize(...args: any[]): Promise<any> {
|
async setAuthorize(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const instance: NiucloudUtils = NiucloudUtils.getInstance();
|
||||||
return null;
|
|
||||||
|
const query: Record<string, any> = {};
|
||||||
|
query.put("code", param.getAuthCode());
|
||||||
|
query.put("secret", param.getAuthSecret());
|
||||||
|
query.put("product_key", instance.getProductKey());
|
||||||
|
|
||||||
|
const authInfo: Record<string, any> = NiucloudUtils.Niucloud.get("authinfo", query).getJSONObject("data");
|
||||||
|
if (authInfo == null) throw new BadRequestException("未获取到授权信息");
|
||||||
|
|
||||||
|
coreNiucloudConfigService.setNiucloudConfig(param);
|
||||||
|
NiucloudUtils.Niucloud.clearAccessToken();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* getModuleList
|
* getModuleList
|
||||||
*/
|
*/
|
||||||
async getModuleList(...args: any[]): Promise<any> {
|
async getModuleList(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const instance: NiucloudUtils = NiucloudUtils.getInstance();
|
||||||
return null;
|
|
||||||
|
const query: Record<string, any> = {};
|
||||||
|
query.put("code", instance.getCode());
|
||||||
|
query.put("secret", instance.getSecret());
|
||||||
|
query.put("product_key", instance.getProductKey());
|
||||||
|
|
||||||
|
const addonList: JSONArray = NiucloudUtils.Niucloud.get("member_app_all", query).getJSONArray("data");
|
||||||
|
if (addonList == null && addonList.size() == 0) return null;
|
||||||
|
|
||||||
|
const list: ModuleListVo[] = [];
|
||||||
|
for (const i of number = 0; i < addonList.size(); i++) {
|
||||||
|
const item: Record<string, any> = addonList.getJSONObject(i);
|
||||||
|
const vo: ModuleListVo = JSONUtil.toBean(item, ModuleListVo.class);
|
||||||
|
list.add(vo);
|
||||||
|
}
|
||||||
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* getActionToken
|
* getActionToken
|
||||||
*/
|
*/
|
||||||
async getActionToken(...args: any[]): Promise<any> {
|
async getActionToken(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
return NiucloudUtils.Niucloud.get("member_app_action/" + action, query).getJSONObject("data");
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* checkKey
|
* checkKey
|
||||||
*/
|
*/
|
||||||
async checkKey(...args: any[]): Promise<any> {
|
async checkKey(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const instance: NiucloudUtils = NiucloudUtils.getInstance();
|
||||||
return null;
|
|
||||||
|
const query: Record<string, any> = {};
|
||||||
|
query.put("product_key", instance.getProductKey());
|
||||||
|
|
||||||
|
return NiucloudUtils.Niucloud.get("store/app_check/" + key, query).get("data", Boolean.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* getAppVersionList
|
* getAppVersionList
|
||||||
*/
|
*/
|
||||||
async getAppVersionList(...args: any[]): Promise<any> {
|
async getAppVersionList(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const instance: NiucloudUtils = NiucloudUtils.getInstance();
|
||||||
return null;
|
|
||||||
|
const query: Record<string, any> = {};
|
||||||
|
query.put("product_key", instance.getProductKey());
|
||||||
|
query.put("app_key", param.getAppKey());
|
||||||
|
|
||||||
|
const data: JSONArray = ObjectUtil.defaultIfNull(NiucloudUtils.Niucloud.get("store/app_version/list", query).get("data", JSONArray.class), new JSONArray());
|
||||||
|
|
||||||
|
const list: AppVersionListVo[] = [];
|
||||||
|
|
||||||
|
for (const i of number = 0; i < data.size(); i++) {
|
||||||
|
list.add(JSONUtil.toBean(data.getJSONObject(i), AppVersionListVo.class));
|
||||||
|
}
|
||||||
|
return list;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,15 +14,13 @@ export class NoticeLogServiceImplService {
|
|||||||
* getPage
|
* getPage
|
||||||
*/
|
*/
|
||||||
async getPage(...args: any[]): Promise<any> {
|
async getPage(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
return coreNoticeLogService.getPage(RequestUtils.siteId(), pageParam, noticeLogSearchParam);
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* getInfo
|
* getInfo
|
||||||
*/
|
*/
|
||||||
async getInfo(...args: any[]): Promise<any> {
|
async getInfo(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
return coreNoticeLogService.getInfo(RequestUtils.siteId(), id);
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,15 +14,14 @@ export class NoticeServiceImplService {
|
|||||||
* getAddonList
|
* getAddonList
|
||||||
*/
|
*/
|
||||||
async getAddonList(...args: any[]): Promise<any> {
|
async getAddonList(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
return coreNoticeService.getAddonList(RequestUtils.siteId());
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* getInfo
|
* getInfo
|
||||||
*/
|
*/
|
||||||
async getInfo(...args: any[]): Promise<any> {
|
async getInfo(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
// return coreNoticeService.getInfo(RequestUtils.siteId(), key);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -30,15 +29,21 @@ export class NoticeServiceImplService {
|
|||||||
* edit
|
* edit
|
||||||
*/
|
*/
|
||||||
async edit(...args: any[]): Promise<any> {
|
async edit(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
coreNoticeService.edit(RequestUtils.siteId(), key, data);
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* editMessageStatus
|
* editMessageStatus
|
||||||
*/
|
*/
|
||||||
async editMessageStatus(...args: any[]): Promise<any> {
|
async editMessageStatus(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
if (NoticeTypeEnum.getNameByType(param.getType()).isEmpty()) throw new BadRequestException("消息类型不存在");
|
||||||
return null;
|
|
||||||
|
const jsonModuleLoader: JsonModuleLoader = new JsonModuleLoader();
|
||||||
|
const notice: Record<string, any> = jsonModuleLoader.mergeResultElement("notice/notice.json");
|
||||||
|
if (notice.getJSONObject(param.getKey()) == null) throw new BadRequestException("消息类型不存在");
|
||||||
|
|
||||||
|
const data: Record<string, any> = new Record<string, any>();
|
||||||
|
data.put("is_" + param.getType(), param.getStatus());
|
||||||
|
coreNoticeService.edit(RequestUtils.siteId(), param.getKey(), data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,191 +14,686 @@ export class NuiSmsServiceImplService {
|
|||||||
* captcha
|
* captcha
|
||||||
*/
|
*/
|
||||||
async captcha(...args: any[]): Promise<any> {
|
async captcha(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
try {
|
||||||
return null;
|
const jsonObject: Record<string, any> = NiucloudUtils.Niucloud.get(SEND_CAPTCHA_URL, {});
|
||||||
|
const result: Record<string, any> = jsonObject.getJSONObject("data");
|
||||||
|
//删除null值 防止序列化报错
|
||||||
|
JacksonUtils.removeNull(result);
|
||||||
|
return result;
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("获取验证码失败异常信息:{}", e.getMessage());
|
||||||
|
throw new Error(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* sendMobileCode
|
* sendMobileCode
|
||||||
*/
|
*/
|
||||||
async sendMobileCode(...args: any[]): Promise<any> {
|
async sendMobileCode(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const body: Record<string, any> = {};
|
||||||
return null;
|
body.put("mobile", param.getMobile());
|
||||||
|
body.put("captcha_key", param.getCaptchaKey());
|
||||||
|
body.put("captcha_code", param.getCaptchaCode());
|
||||||
|
try {
|
||||||
|
const jsonObject: Record<string, any> = NiucloudUtils.Niucloud.post(SEND_CODE_URL, body);
|
||||||
|
const result: Record<string, any> = jsonObject.getJSONObject("data");
|
||||||
|
//删除null值 防止序列化报错
|
||||||
|
JacksonUtils.removeNull(result);
|
||||||
|
return result;
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("发送验证码失败异常信息:{}", e.getMessage());
|
||||||
|
throw new AdminException("发送验证码失败");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* registerAccount
|
* registerAccount
|
||||||
*/
|
*/
|
||||||
async registerAccount(...args: any[]): Promise<number> {
|
async registerAccount(...args: any[]): Promise<number> {
|
||||||
// TODO: 实现业务逻辑
|
if (ObjectUtil.isNotEmpty(param.getImgUrl())) {
|
||||||
return 0;
|
param.setImgUrl(Paths.get(RequestUtils.getReqeustURI(), param.getImgUrl()).toString());
|
||||||
|
}
|
||||||
|
const result: Record<string, any> = null;
|
||||||
|
try {
|
||||||
|
result = NiucloudUtils.Niucloud.post(ACCOUNT_REGISTER_URL, param);
|
||||||
|
//删除null值 防止序列化报错
|
||||||
|
JacksonUtils.removeNull(result);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("注册账号失败异常信息:{}", e.getMessage());
|
||||||
|
throw new AdminException("注册账号失败");
|
||||||
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* loginAccount
|
* loginAccount
|
||||||
*/
|
*/
|
||||||
async loginAccount(...args: any[]): Promise<number> {
|
async loginAccount(...args: any[]): Promise<number> {
|
||||||
// TODO: 实现业务逻辑
|
const url: string = String.format(LOGIN_ACCOUNT_URL, param.getUsername());
|
||||||
return 0;
|
const body: Record<string, any> = {};
|
||||||
|
body.put("username", param.getUsername());
|
||||||
|
body.put("password", param.getPassword());
|
||||||
|
try {
|
||||||
|
const jsonObject: Record<string, any> = NiucloudUtils.Niucloud.post(url, body);
|
||||||
|
const result: Record<string, any> = jsonObject.getJSONObject("data");
|
||||||
|
if (result == null) {
|
||||||
|
throw new AdminException("登录失败");
|
||||||
|
}
|
||||||
|
param.setSignature(" ");
|
||||||
|
param.setDefaultVal(" ");
|
||||||
|
setConfig(param);
|
||||||
|
//删除null值 防止序列化报错
|
||||||
|
JacksonUtils.removeNull(result);
|
||||||
|
return result;
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("登录账号失败异常信息:{}", e.getMessage());
|
||||||
|
throw new AdminException(e.getMessage());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* resetPassword
|
* resetPassword
|
||||||
*/
|
*/
|
||||||
async resetPassword(...args: any[]): Promise<any> {
|
async resetPassword(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const result: Record<string, any> = new Record<string, any>();
|
||||||
return null;
|
// 获取用户信息
|
||||||
|
const data: Record<string, any> = accountInfo(param.getUsername());
|
||||||
|
|
||||||
|
// 拆分手机号并验证
|
||||||
|
const mobiles: string = String.valueOf(data.getOrDefault("mobiles", ""));
|
||||||
|
const mobileList: string[] = Arrays.asList(mobiles.split(","));
|
||||||
|
if (!mobileList.includes(param.getMobile())) {
|
||||||
|
throw new AdminException("手机号错误");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 重置密码
|
||||||
|
const newPassword: string = null;
|
||||||
|
try {
|
||||||
|
const resetPasswordUrl: string = String.format(RESET_PASSWORD_URL, param.getUsername());
|
||||||
|
const resetPasswordBody: Record<string, any> = {};
|
||||||
|
resetPasswordBody.put("mobile", param.getMobile());
|
||||||
|
resetPasswordBody.put("code", param.getCode());
|
||||||
|
resetPasswordBody.put("key", param.getKey());
|
||||||
|
const resetPasswordJson: Record<string, any> = NiucloudUtils.Niucloud.put(resetPasswordUrl, resetPasswordBody);
|
||||||
|
const resetPasswordDataJson: Record<string, any> = resetPasswordJson.getJSONObject("data");
|
||||||
|
newPassword = resetPasswordDataJson.getStr("newPassword");
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("重置密码失败异常信息:{}", e.getMessage());
|
||||||
|
throw new AdminException("重置密码失败");
|
||||||
|
}
|
||||||
|
|
||||||
|
//修改配置
|
||||||
|
const registerAccountParam: RegisterAccountParam = new RegisterAccountParam();
|
||||||
|
registerAccountParam.setUsername(param.getUsername());
|
||||||
|
registerAccountParam.setPassword(param.getPassword());
|
||||||
|
setConfig(registerAccountParam);
|
||||||
|
|
||||||
|
result.put("password", newPassword);
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* accountInfo
|
* accountInfo
|
||||||
*/
|
*/
|
||||||
async accountInfo(...args: any[]): Promise<number> {
|
async accountInfo(...args: any[]): Promise<number> {
|
||||||
// TODO: 实现业务逻辑
|
const infoUrl: string = String.format(ACCOUNT_INFO_URL, username);
|
||||||
return 0;
|
try {
|
||||||
|
const jsonObject: Record<string, any> = NiucloudUtils.Niucloud.get(infoUrl, {});
|
||||||
|
const result: Record<string, any> = jsonObject.getJSONObject("data");
|
||||||
|
// 获取配置
|
||||||
|
const nyConfig: Record<string, any> = getConfig(false);
|
||||||
|
if (result != null && nyConfig != null && nyConfig.containsKey("username")) {
|
||||||
|
if (nyConfig.getStr("username") === result.getStr("username")) {
|
||||||
|
result.set("signature", nyConfig.getOrDefault("signature", "").toString().trim());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
JacksonUtils.removeNull(result);
|
||||||
|
return result;
|
||||||
|
} catch (JSONException e) {
|
||||||
|
log.error("获取用户信息失败异常信息:{}", e.getMessage());
|
||||||
|
throw new AdminException("获取用户信息失败");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* getTemplateList
|
* getTemplateList
|
||||||
*/
|
*/
|
||||||
async getTemplateList(...args: any[]): Promise<any> {
|
async getTemplateList(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const config: Record<string, any> = getConfig(false);
|
||||||
return null;
|
const siteId: number = RequestUtils.siteId();
|
||||||
|
if (ObjectUtil.isEmpty(config) || !config.getOrDefault("username", "") === username) {
|
||||||
|
throw new ApiException("牛云短信账号异常,请重新登录账号");
|
||||||
|
}
|
||||||
|
const list: SysNotice[] = sysNoticeMapper.selectList(new QueryWrapper<SysNotice>().eq("site_id", siteId));
|
||||||
|
const map: Record<string, any> = {};
|
||||||
|
if (!CollectionUtils.isEmpty(list)) {
|
||||||
|
map = list.stream().collect(Collectors.toMap(SysNotice::getKey, item => item));
|
||||||
|
}
|
||||||
|
const notice: TemplateListVo[] = [];
|
||||||
|
for (Map.Entry<String, NoticeEnumListVo> noticeMap : NoticeEnum.getNiuyunNotice().entrySet()) {
|
||||||
|
const noticeInfoVo: TemplateListVo = new TemplateListVo();
|
||||||
|
BeanUtil.copyProperties(noticeMap.getValue(), noticeInfoVo);
|
||||||
|
if (map.containsKey(noticeMap.getKey())) {
|
||||||
|
BeanUtil.copyProperties(map.get(noticeMap.getKey()), noticeInfoVo);
|
||||||
|
}
|
||||||
|
//针对短信,微信公众号,小程序配置
|
||||||
|
if (ObjectUtil.isNotEmpty(noticeMap.getValue().getSupport_type_map())) {
|
||||||
|
for (Map.Entry<String, Record<string, any>> supportTypeMap : noticeMap.getValue().getSupport_type_map().entrySet()) {
|
||||||
|
if (supportTypeMap.getKey() === "sms") {
|
||||||
|
noticeInfoVo.setSms(supportTypeMap.getValue());
|
||||||
|
}
|
||||||
|
if (supportTypeMap.getKey() === "wechat") {
|
||||||
|
noticeInfoVo.setWechat(supportTypeMap.getValue());
|
||||||
|
}
|
||||||
|
if (supportTypeMap.getKey() === "weapp") {
|
||||||
|
noticeInfoVo.setWeapp(supportTypeMap.getValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
notice.add(noticeInfoVo);
|
||||||
|
}
|
||||||
|
const niuSmsTemplates: NiuSmsTemplate[] = niuSmsTemplateMapper.selectList(new QueryWrapper<NiuSmsTemplate>()
|
||||||
|
.eq("sms_type", smsType)
|
||||||
|
.eq("username", username)
|
||||||
|
.eq("site_id", siteId));
|
||||||
|
const templateMap: Record<string, any> = {};
|
||||||
|
if (!CollectionUtils.isEmpty(niuSmsTemplates)){
|
||||||
|
templateMap = niuSmsTemplates.stream().collect(Collectors.toMap(NiuSmsTemplate::getTemplateKey, item => item));
|
||||||
|
}
|
||||||
|
const addonList: Addon[] = coreSiteService.getSiteAddons(siteId);
|
||||||
|
const sys: Addon = new Addon();
|
||||||
|
sys.setKey("system");
|
||||||
|
addonList.add(0, sys);
|
||||||
|
const result: TemplateListVo[] = [];
|
||||||
|
for (const addon of addonList) {
|
||||||
|
for (const noticeInfoVo of notice) {
|
||||||
|
if (addon.getKey() === noticeInfoVo.getAddon()) {
|
||||||
|
if ("system" === noticeInfoVo.getAddon()) {
|
||||||
|
noticeInfoVo.setAddon("系统");
|
||||||
|
}
|
||||||
|
const auditInfo: Record<string, any> = new Record<string, any>();
|
||||||
|
auditInfo.set("audit_msg", templateMap.containsKey(noticeInfoVo.getKey()) ? templateMap.get(noticeInfoVo.getKey()).getAuditMsg() : "");
|
||||||
|
auditInfo.set("audit_status", templateMap.containsKey(noticeInfoVo.getKey()) ? templateMap.get(noticeInfoVo.getKey()).getAuditStatus() : TemplateAuditStatus.TEMPLATE_NOT_REPORT.getCode());
|
||||||
|
auditInfo.set("audit_status_name", TemplateAuditStatus.getByCode(auditInfo.getInt("audit_status")).getDescription());
|
||||||
|
const paramsJson: string[] = [];
|
||||||
|
if (templateMap.containsKey(noticeInfoVo.getKey())){
|
||||||
|
const paramJson: string = templateMap.get(noticeInfoVo.getKey()).getParamJson();
|
||||||
|
if (ObjectUtil.isNotEmpty(paramJson)){
|
||||||
|
const jsonObject: Record<string, any> = JSONUtil.parseObj(paramJson);
|
||||||
|
paramsJson.addAll(jsonObject.keySet());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Collections.sort(paramsJson);
|
||||||
|
|
||||||
|
const variable: string[] = [];
|
||||||
|
if (ObjectUtil.isNotEmpty(noticeInfoVo.getVariable())) {
|
||||||
|
variable.addAll(noticeInfoVo.getVariable().keySet());
|
||||||
|
}
|
||||||
|
Collections.sort(variable);
|
||||||
|
|
||||||
|
const errorStatus: string = "";
|
||||||
|
// 比较两个键列表
|
||||||
|
if (templateMap.containsKey(noticeInfoVo.getKey()) && !variable === paramsJson) {
|
||||||
|
if (paramsJson.length === 0) {
|
||||||
|
errorStatus = String.valueOf(TemplateAuditStatus.TEMPLATE_NEED_PULL.getCode());
|
||||||
|
} else {
|
||||||
|
errorStatus = auditInfo.getInt("audit_status") == TemplateAuditStatus.TEMPLATE_PASS.getCode()
|
||||||
|
? String.valueOf(TemplateAuditStatus.TEMPLATE_STATUS_AGAIN_REPORT.getCode())
|
||||||
|
: String.valueOf(TemplateAuditStatus.TEMPLATE_NEED_EDIT.getCode());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
auditInfo.set("error_status", errorStatus);
|
||||||
|
if (StringUtil.isNotEmpty(errorStatus)){
|
||||||
|
auditInfo.set("error_status_name", TemplateAuditStatus.getByCode(number.parseInt(errorStatus)).getDescription());
|
||||||
|
}else {
|
||||||
|
auditInfo.set("error_status_name", "");
|
||||||
|
}
|
||||||
|
noticeInfoVo.setAuditInfo(auditInfo);
|
||||||
|
if (templateMap.containsKey(noticeInfoVo.getKey())){
|
||||||
|
const niuSmsTemplate: NiuSmsTemplate = templateMap.get(noticeInfoVo.getKey());
|
||||||
|
if ((niuSmsTemplate.getTemplateType( && niuSmsTemplate.getTemplateType(.trim() !== ''))){
|
||||||
|
noticeInfoVo.setTemplateTypeName(TemplateTypeEnum.fromCode(number.parseInt(niuSmsTemplate.getTemplateType())).getDescription());
|
||||||
|
}else {
|
||||||
|
noticeInfoVo.setTemplateTypeName("");
|
||||||
|
}
|
||||||
|
noticeInfoVo.setTemplateId(number.parseInt(niuSmsTemplate.getTemplateId()));
|
||||||
|
}
|
||||||
|
result.add(noticeInfoVo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* orderList
|
* orderList
|
||||||
*/
|
*/
|
||||||
async orderList(...args: any[]): Promise<any> {
|
async orderList(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const orderListUrl: string = String.format(ORDER_LIST_URL, username);
|
||||||
return null;
|
const result: Record<string, any> = null;
|
||||||
|
try {
|
||||||
|
const orderListParam: Record<string, any> = {};
|
||||||
|
orderListParam.put("out_trade_no", param.getOutTradeNo());
|
||||||
|
orderListParam.put("order_status", param.getStatus());
|
||||||
|
orderListParam.put("create_time_start", param.getCreateTimeStart());
|
||||||
|
orderListParam.put("create_time_end", param.getCreateTimeEnd());
|
||||||
|
orderListParam.put("limit", pageParam.getLimit());
|
||||||
|
orderListParam.put("page", pageParam.getPage());
|
||||||
|
const jsonObject: Record<string, any> = NiucloudUtils.Niucloud.get(orderListUrl, orderListParam);
|
||||||
|
result = jsonObject.getJSONObject("data");
|
||||||
|
//删除null值 防止序列化报错
|
||||||
|
JacksonUtils.removeNull(result);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("获取订单列表失败异常信息:{}", e.getMessage());
|
||||||
|
throw new AdminException("获取订单列表失败");
|
||||||
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* accountSendList
|
* accountSendList
|
||||||
*/
|
*/
|
||||||
async accountSendList(...args: any[]): Promise<number> {
|
async accountSendList(...args: any[]): Promise<number> {
|
||||||
// TODO: 实现业务逻辑
|
const accountSendUrl: string = String.format(ACCOUNT_SEND_LIST_URL, username);
|
||||||
return 0;
|
const accountSendParam: Record<string, any> = {};
|
||||||
|
accountSendParam.put("mobile", param.getMobile());
|
||||||
|
accountSendParam.put("content", param.getContent());
|
||||||
|
accountSendParam.put("smsStatus", param.getSmsStatus());
|
||||||
|
accountSendParam.put("limit", pageParam.getLimit());
|
||||||
|
accountSendParam.put("page", pageParam.getPage());
|
||||||
|
try {
|
||||||
|
const jsonObject: Record<string, any> = NiucloudUtils.Niucloud.get(accountSendUrl, accountSendParam);
|
||||||
|
const result: Record<string, any> = jsonObject.getJSONObject("data");
|
||||||
|
//删除null值 防止序列化报错
|
||||||
|
JacksonUtils.removeNull(result);
|
||||||
|
return result;
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("获取发送列表失败异常信息:{}", e.getMessage());
|
||||||
|
throw new AdminException("获取发送列表失败");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* enable
|
* enable
|
||||||
*/
|
*/
|
||||||
async enable(...args: any[]): Promise<any> {
|
async enable(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const registerAccountParam: RegisterAccountParam = new RegisterAccountParam();
|
||||||
return null;
|
if (isEnable == 1) {
|
||||||
|
const config: Record<string, any> = getConfig(true);
|
||||||
|
if (ObjectUtil.isEmpty(config) ||
|
||||||
|
!config.containsKey(NIUYUN) ||
|
||||||
|
(config.getJSONObject(NIUYUN)).get("username") == null ||
|
||||||
|
(config.getJSONObject(NIUYUN)).get("username").toString().isEmpty() ||
|
||||||
|
(config.getJSONObject(NIUYUN)).get("password") == null ||
|
||||||
|
(config.getJSONObject(NIUYUN)).get("password").toString().isEmpty() ||
|
||||||
|
(config.getJSONObject(NIUYUN)).get("signature") == null ||
|
||||||
|
(config.getJSONObject(NIUYUN)).get("signature").toString().isEmpty()) {
|
||||||
|
throw new AdminException("需登录账号并配置签名后才能启用牛云短信");
|
||||||
|
}
|
||||||
|
registerAccountParam.setDefaultVal(NIUYUN);
|
||||||
|
setConfig(registerAccountParam);
|
||||||
|
} else {
|
||||||
|
registerAccountParam.setDefaultVal(" ");
|
||||||
|
setConfig(registerAccountParam);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* editAccount
|
* editAccount
|
||||||
*/
|
*/
|
||||||
async editAccount(...args: any[]): Promise<number> {
|
async editAccount(...args: any[]): Promise<number> {
|
||||||
// TODO: 实现业务逻辑
|
const editAccountUrl: string = String.format(ACCOUNT_EDIT_URL, username);
|
||||||
return 0;
|
const editAccountBody: Record<string, any> = {};
|
||||||
|
editAccountBody.put("new_mobile", param.getNewMobile());
|
||||||
|
editAccountBody.put("mobile", param.getMobile());
|
||||||
|
editAccountBody.put("code", param.getCode());
|
||||||
|
editAccountBody.put("key", param.getKey());
|
||||||
|
editAccountBody.put("signature", param.getSignature());
|
||||||
|
try {
|
||||||
|
const jsonObject: Record<string, any> = NiucloudUtils.Niucloud.put(editAccountUrl, editAccountBody);
|
||||||
|
const registerAccountParam: RegisterAccountParam = new RegisterAccountParam();
|
||||||
|
registerAccountParam.setSignature(param.getSignature());
|
||||||
|
setConfig(registerAccountParam);
|
||||||
|
JacksonUtils.removeNull(jsonObject);
|
||||||
|
return jsonObject;
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("修改账号信息失败异常信息:{}", e.getMessage());
|
||||||
|
throw new AdminException("修改账号信息失败");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* signDelete
|
* signDelete
|
||||||
*/
|
*/
|
||||||
async signDelete(...args: any[]): Promise<any> {
|
async signDelete(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const config: Record<string, any> = getConfig(false);
|
||||||
return null;
|
param.setPassword(config.getStr("password"));
|
||||||
|
try {
|
||||||
|
const failList: any[] = delSign(username, param);
|
||||||
|
|
||||||
|
const configSignature: string = config.getStr("signature");
|
||||||
|
const signatures: string[] = param.getSignatures();
|
||||||
|
|
||||||
|
if (signatures != null && !failList.length === 0 &&
|
||||||
|
signatures.includes(configSignature) &&
|
||||||
|
!failList.includes(configSignature)) {
|
||||||
|
// 如果满足条件,则清空账户的签名
|
||||||
|
const editAccountParam: EditAccountParam = new EditAccountParam();
|
||||||
|
editAccountParam.setSignature("");
|
||||||
|
editAccount(username, editAccountParam);
|
||||||
|
}
|
||||||
|
return failList;
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("删除签名失败异常信息:{}", e.getMessage());
|
||||||
|
throw new AdminException("删除签名失败异常");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* signCreate
|
* signCreate
|
||||||
*/
|
*/
|
||||||
async signCreate(...args: any[]): Promise<any> {
|
async signCreate(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
if (ObjectUtil.isNotEmpty(param.getImgUrl())) {
|
||||||
return null;
|
param.setImgUrl(Paths.get(RequestUtils.getReqeustURI(), param.getImgUrl()).toString());
|
||||||
|
}
|
||||||
|
const signCreateUrl: string = String.format(SIGN_ADD_URL, username);
|
||||||
|
try {
|
||||||
|
const jsonObject: Record<string, any> = NiucloudUtils.Niucloud.post(signCreateUrl, param);
|
||||||
|
const data: Record<string, any> = jsonObject.getJSONObject("data");
|
||||||
|
if (data.containsKey("failList") && !data.getJSONArray("failList").isEmpty()) {
|
||||||
|
const failList: JSONArray = data.getJSONArray("failList");
|
||||||
|
throw new ApiException(failList.getJSONObject(0).getStr("msg"));
|
||||||
|
}
|
||||||
|
} catch (ApiException e) {
|
||||||
|
log.error("创建签名失败异常信息:{}", e.getMessage());
|
||||||
|
throw new AdminException("创建签名失败");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* getSmsPackageList
|
* getSmsPackageList
|
||||||
*/
|
*/
|
||||||
async getSmsPackageList(...args: any[]): Promise<any> {
|
async getSmsPackageList(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const pageListParam: Record<string, any> = {};
|
||||||
return null;
|
pageListParam.put("package_name", param.getPackageName());
|
||||||
|
pageListParam.put("sms_num", param.getSmsNum());
|
||||||
|
pageListParam.put("price_start", param.getPriceStart());
|
||||||
|
pageListParam.put("price_end", param.getPriceEnd());
|
||||||
|
pageListParam.put("original_price_start", param.getOriginalPriceStart());
|
||||||
|
pageListParam.put("original_price_end", param.getOriginalPriceEnd());
|
||||||
|
pageListParam.put("time_start", param.getTimeStart());
|
||||||
|
pageListParam.put("time_end", param.getTimeEnd());
|
||||||
|
pageListParam.put("page", 1);
|
||||||
|
pageListParam.put("limit", 15);
|
||||||
|
try {
|
||||||
|
const jsonObject: Record<string, any> = NiucloudUtils.Niucloud.get(PACKAGE_LIST_URL, pageListParam);
|
||||||
|
const result: Record<string, any> = jsonObject.getJSONObject("data");
|
||||||
|
//删除null值 防止序列化报错
|
||||||
|
JacksonUtils.removeNull(result);
|
||||||
|
return result;
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("获取套餐列表失败异常信息:{}", e.getMessage());
|
||||||
|
throw new AdminException("获取套餐列表失败");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* orderCalculate
|
* orderCalculate
|
||||||
*/
|
*/
|
||||||
async orderCalculate(...args: any[]): Promise<any> {
|
async orderCalculate(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const orderCalculateUrl: string = String.format(ORDER_CALCULATE_URL, username);
|
||||||
return null;
|
const orderCalculateBody: Record<string, any> = {};
|
||||||
|
orderCalculateBody.put("package_id", param.getPackageId());
|
||||||
|
try {
|
||||||
|
const jsonObject: Record<string, any> = NiucloudUtils.Niucloud.post(orderCalculateUrl, orderCalculateBody);
|
||||||
|
const result: Record<string, any> = jsonObject.getJSONObject("data");
|
||||||
|
//删除null值 防止序列化报错
|
||||||
|
JacksonUtils.removeNull(result);
|
||||||
|
return result;
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("计算订单失败异常信息:{}", e.getMessage());
|
||||||
|
throw new AdminException("计算订单失败");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* createOrder
|
* createOrder
|
||||||
*/
|
*/
|
||||||
async createOrder(...args: any[]): Promise<any> {
|
async createOrder(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const orderCreateUrl: string = String.format(ORDER_CREATE_URL, username);
|
||||||
return null;
|
const orderCreateBody: Record<string, any> = {};
|
||||||
|
orderCreateBody.put("package_id", param.getPackageId());
|
||||||
|
try {
|
||||||
|
const jsonObject: Record<string, any> = NiucloudUtils.Niucloud.post(orderCreateUrl, orderCreateBody);
|
||||||
|
const result: Record<string, any> = jsonObject.getJSONObject("data");
|
||||||
|
//删除null值 防止序列化报错
|
||||||
|
JacksonUtils.removeNull(result);
|
||||||
|
return result;
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("创建订单失败异常信息:{}", e.getMessage());
|
||||||
|
throw new AdminException("创建订单失败");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* getPayInfo
|
* getPayInfo
|
||||||
*/
|
*/
|
||||||
async getPayInfo(...args: any[]): Promise<any> {
|
async getPayInfo(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const request: HttpServletRequest = ((ServletRequestAttributes) RequestContextHolder.currentRequestAttributes()).getRequest();
|
||||||
return null;
|
|
||||||
|
const protocol: string = request.isSecure() ? "https" : "http";
|
||||||
|
const host: string = request.getServerName();
|
||||||
|
const port: number = request.getServerPort();
|
||||||
|
if (port != 80 && port != 443) {
|
||||||
|
host += ":" + port;
|
||||||
|
}
|
||||||
|
const returnUrl: string = String.format("%s://%s/site/setting/sms/pay", protocol, host);
|
||||||
|
const payInfoUrl: string = String.format(ORDER_PAY_URL, username);
|
||||||
|
const payInfoBody: Record<string, any> = {};
|
||||||
|
payInfoBody.put("notify_url", payInfoUrl);
|
||||||
|
payInfoBody.put("return_url", returnUrl);
|
||||||
|
payInfoBody.put("out_trade_no", outTradeNo);
|
||||||
|
try {
|
||||||
|
const jsonObject: Record<string, any> = NiucloudUtils.Niucloud.post(payInfoUrl, payInfoBody);
|
||||||
|
const result: Record<string, any> = jsonObject.getJSONObject("data");
|
||||||
|
//删除null值 防止序列化报错
|
||||||
|
JacksonUtils.removeNull(result);
|
||||||
|
return result;
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("获取支付信息失败异常信息:{}", e.getMessage());
|
||||||
|
throw new AdminException("获取支付信息失败");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* getOrderInfo
|
* getOrderInfo
|
||||||
*/
|
*/
|
||||||
async getOrderInfo(...args: any[]): Promise<any> {
|
async getOrderInfo(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const orderInfoUrl: string = String.format(ORDER_INFO_URL, username, outTradeNo);
|
||||||
return null;
|
try {
|
||||||
|
const jsonObject: Record<string, any> = NiucloudUtils.Niucloud.get(orderInfoUrl, {});
|
||||||
|
const result: Record<string, any> = jsonObject.getJSONObject("data");
|
||||||
|
//删除null值 防止序列化报错
|
||||||
|
JacksonUtils.removeNull(result);
|
||||||
|
return result;
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("获取订单信息失败异常信息:{}", e.getMessage());
|
||||||
|
throw new AdminException("获取订单信息失败");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* getOrderStatus
|
* getOrderStatus
|
||||||
*/
|
*/
|
||||||
async getOrderStatus(...args: any[]): Promise<any> {
|
async getOrderStatus(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const orderStatusUrl: string = String.format(ORDER_STATUS_URL, username, outTradeNo);
|
||||||
return null;
|
try {
|
||||||
|
const jsonObject: Record<string, any> = NiucloudUtils.Niucloud.get(orderStatusUrl, {});
|
||||||
|
const result: Record<string, any> = jsonObject.getJSONObject("data");
|
||||||
|
//删除null值 防止序列化报错
|
||||||
|
JacksonUtils.removeNull(result);
|
||||||
|
return result;
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("获取订单状态失败异常信息:{}", e.getMessage());
|
||||||
|
throw new AdminException("获取订单状态失败");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* templateCreate
|
* templateCreate
|
||||||
*/
|
*/
|
||||||
async templateCreate(...args: any[]): Promise<any> {
|
async templateCreate(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const templateKey: string = param.getTemplateKey();
|
||||||
return null;
|
const templateList: TemplateListVo[] = getTemplateList(smsType, username);
|
||||||
|
|
||||||
|
// 查找模版信息,如果不存在则抛出异常
|
||||||
|
const templateInfo: TemplateListVo = templateList.stream()
|
||||||
|
.filter(item => item.getKey() === templateKey)
|
||||||
|
.findFirst()
|
||||||
|
.orElseThrow(() => new AdminException("当前模版未配置短信内容"));
|
||||||
|
|
||||||
|
// 检查模版是否配置了短信内容,如果未配置则抛出异常
|
||||||
|
if (ObjectUtil.isEmpty(templateInfo.getSms()) || ObjectUtil.isEmpty(templateInfo.getSms().get("content"))) {
|
||||||
|
throw new AdminException("当前模版未配置短信内容");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 检查模版是否已经审核通过,如果已通过则抛出异常
|
||||||
|
const modelInfo: NiuSmsTemplate[] = niuSmsTemplateMapper.selectList(new QueryWrapper<NiuSmsTemplate>()
|
||||||
|
.eq("template_key", templateKey)
|
||||||
|
.eq("site_id", RequestUtils.siteId())
|
||||||
|
.eq("username", username));
|
||||||
|
if (!CollectionUtils.isEmpty(modelInfo) && TemplateAuditStatus.TEMPLATE_PASS.getCode().toString() === modelInfo.get(0.getAuditStatus())) {
|
||||||
|
throw new AdminException("审核通过的模版不允许修改");
|
||||||
|
}
|
||||||
|
|
||||||
|
const config: Record<string, any> = getConfig(false);
|
||||||
|
const templateCreateUrl: string = String.format(TEMPLATE_ADD_URL, username);
|
||||||
|
const templateCreateBody: Record<string, any> = {};
|
||||||
|
templateCreateBody.put("temName", path.basename(templateInfo));
|
||||||
|
templateCreateBody.put("temType", param.getTemplateType());
|
||||||
|
templateCreateBody.put("temContent", templateInfo.getSms().get("content"));
|
||||||
|
templateCreateBody.put("paramJson", param.getParamsJson());
|
||||||
|
templateCreateBody.put("extend", Map.of("template_key", templateKey));
|
||||||
|
templateCreateBody.put("signature", config.getStr("signature"));
|
||||||
|
templateCreateBody.put("temId", param.getTemplateId());
|
||||||
|
|
||||||
|
Record<string, any> result;
|
||||||
|
try {
|
||||||
|
const jsonObject: Record<string, any> = NiucloudUtils.Niucloud.post(templateCreateUrl, templateCreateBody);
|
||||||
|
result = jsonObject.getJSONObject("data");
|
||||||
|
JacksonUtils.removeNull(result); // 删除null值,防止序列化报错
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("创建模版失败异常信息:{},", e.getMessage());
|
||||||
|
throw new AdminException("创建模版失败");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取模板ID,如果不存在则设为const temId: 0
|
||||||
|
number = result.containsKey("temId") ? result.getInt("temId") : 0;
|
||||||
|
|
||||||
|
if (CollectionUtils.isEmpty(modelInfo)) {
|
||||||
|
const niuSmsTemplate: NiuSmsTemplate = new NiuSmsTemplate();
|
||||||
|
niuSmsTemplate.setSiteId(RequestUtils.siteId());
|
||||||
|
niuSmsTemplate.setSmsType(smsType);
|
||||||
|
niuSmsTemplate.setUsername(username);
|
||||||
|
niuSmsTemplate.setTemplateKey(templateKey);
|
||||||
|
niuSmsTemplate.setAuditStatus(TemplateAuditStatus.TEMPLATE_WAIT.getCode().toString());
|
||||||
|
niuSmsTemplate.setTemplateId(temId.toString());
|
||||||
|
niuSmsTemplate.setReportInfo(JSONUtil.toJsonStr(result));
|
||||||
|
niuSmsTemplate.setCreateTime(System.currentTimeMillis() / 1000);
|
||||||
|
niuSmsTemplate.setUpdateTime(System.currentTimeMillis() / 1000);
|
||||||
|
niuSmsTemplateMapper.insert(niuSmsTemplate);
|
||||||
|
} else {
|
||||||
|
const niuSmsTemplate: NiuSmsTemplate = modelInfo.get(0);
|
||||||
|
niuSmsTemplate.setAuditStatus(TemplateAuditStatus.TEMPLATE_WAIT.getCode().toString());
|
||||||
|
niuSmsTemplate.setTemplateId(temId.toString());
|
||||||
|
niuSmsTemplate.setReportInfo(JSONUtil.toJsonStr(result));
|
||||||
|
niuSmsTemplate.setUpdateTime(System.currentTimeMillis() / 1000);
|
||||||
|
niuSmsTemplateMapper.updateById(niuSmsTemplate);
|
||||||
|
}
|
||||||
|
|
||||||
|
return result != null ? result : new Record<string, any>();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* templateDelete
|
* templateDelete
|
||||||
*/
|
*/
|
||||||
async templateDelete(...args: any[]): Promise<any> {
|
async templateDelete(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const config: Record<string, any> = getConfig(false);
|
||||||
return null;
|
const deleteBody: Record<string, any> = {};
|
||||||
|
const time: number = DateUtil.currentSeconds();
|
||||||
|
deleteBody.put("tKey", time);
|
||||||
|
deleteBody.put("password", DigestUtil.md5Hex(DigestUtil.md5Hex(config.getStr("password")) + time));
|
||||||
|
deleteBody.put("username", username);
|
||||||
|
deleteBody.put("temId", templateId);
|
||||||
|
try {
|
||||||
|
sendHttp(TEMPLATE_DELETE, deleteBody);
|
||||||
|
niuSmsTemplateMapper.delete(new QueryWrapper<NiuSmsTemplate>().eq("template_id", templateId));
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("删除模版失败异常信息:{},", e.getMessage());
|
||||||
|
throw new AdminException("删除模版失败");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* templateInfo
|
* templateInfo
|
||||||
*/
|
*/
|
||||||
async templateInfo(...args: any[]): Promise<any> {
|
async templateInfo(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const niuSmsTemplate: NiuSmsTemplate = niuSmsTemplateMapper.selectOne(new LambdaQueryWrapper<NiuSmsTemplate>()
|
||||||
return null;
|
.eq(NiuSmsTemplate::getSiteId, RequestUtils.siteId())
|
||||||
|
.eq(NiuSmsTemplate::getSmsType, smsType)
|
||||||
|
.eq(NiuSmsTemplate::getUsername, username)
|
||||||
|
.eq(NiuSmsTemplate::getTemplateKey, templateKey));
|
||||||
|
if (ObjectUtil.isEmpty(niuSmsTemplate)){
|
||||||
|
throw new AdminException("短信模版暂未报备");
|
||||||
|
}
|
||||||
|
const orderCreateUrl: string = String.format(TEMPLATE_INFO_URL, username);
|
||||||
|
const templateInfoParam: Record<string, any> = {};
|
||||||
|
templateInfoParam.put("tem_id", niuSmsTemplate.getTemplateId());
|
||||||
|
try {
|
||||||
|
const jsonObject: Record<string, any> = NiucloudUtils.Niucloud.get(orderCreateUrl, templateInfoParam);
|
||||||
|
const result: Record<string, any> = jsonObject.getJSONObject("data");
|
||||||
|
//删除null值 防止序列化报错
|
||||||
|
JacksonUtils.removeNull(result);
|
||||||
|
const auditStatus: string = result.containsKey("auditResult") && ObjectUtil.isNotEmpty(result.getJSONObject("auditResult"))
|
||||||
|
? result.getStr("auditResult") : niuSmsTemplate.getAuditStatus();
|
||||||
|
niuSmsTemplate.setAuditStatus(auditStatus);
|
||||||
|
niuSmsTemplateMapper.updateById(niuSmsTemplate);
|
||||||
|
return niuSmsTemplate;
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("获取模版信息失败异常信息:{}", e.getMessage());
|
||||||
|
throw new AdminException("获取模版信息失败");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* sendHttp
|
* sendHttp
|
||||||
*/
|
*/
|
||||||
async sendHttp(...args: any[]): Promise<any> {
|
async sendHttp(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const response: HttpResponse = HttpRequest.post(url).body(JSONUtil.toJsonStr(body)).execute();
|
||||||
return null;
|
if (!response.isOk()) {
|
||||||
|
throw new AdminException("HTTP请求失败,状态码: " + response.getStatus());
|
||||||
|
}
|
||||||
|
|
||||||
|
const resJson: Record<string, any> = JSONUtil.parseObj(response.body());
|
||||||
|
if (resJson.getInt("code") != 200) {
|
||||||
|
throw new AdminException(resJson.getStr("msg"));
|
||||||
|
}
|
||||||
|
return resJson;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* setConfig
|
* setConfig
|
||||||
*/
|
*/
|
||||||
async setConfig(...args: any[]): Promise<any> {
|
async setConfig(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const config: Record<string, any> = getConfig(true);
|
||||||
return null;
|
config.put("default", ObjectUtil.isNotEmpty(param.getDefaultVal()) ? param.getDefaultVal() : config.getOrDefault("default", ""));
|
||||||
|
const niuSmsConfig: Record<string, any> = config.getJSONObject(NIUYUN);
|
||||||
|
const newNiuSmsConfig: Record<string, any> = {};
|
||||||
|
newNiuSmsConfig.put("username", ObjectUtil.isNotEmpty(param.getUsername()) ? param.getUsername() : niuSmsConfig != null ? niuSmsConfig.getOrDefault("username", "") : "");
|
||||||
|
newNiuSmsConfig.put("password", ObjectUtil.isNotEmpty(param.getPassword()) ? param.getPassword() : niuSmsConfig != null ? niuSmsConfig.getOrDefault("password", "") : "");
|
||||||
|
newNiuSmsConfig.put("signature", ObjectUtil.isNotEmpty(param.getSignature()) ? param.getSignature() : niuSmsConfig != null ? niuSmsConfig.getOrDefault("signature", "") : "");
|
||||||
|
config.put(NIUYUN, newNiuSmsConfig);
|
||||||
|
coreConfigService.setConfig(RequestUtils.siteId(), "SMS", config);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,31 +14,109 @@ export class PayChannelServiceImplService {
|
|||||||
* setAll
|
* setAll
|
||||||
*/
|
*/
|
||||||
async setAll(...args: any[]): Promise<any> {
|
async setAll(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
for (const channelKey of param.getConfig().keySet()) {
|
||||||
return null;
|
const channel: Record<string, any> = param.getConfig().getJSONObject(channelKey);
|
||||||
|
const payTypeList: JSONArray = channel.getJSONArray("pay_type");
|
||||||
|
for (const i of number = 0; i < payTypeList.size(); i++) {
|
||||||
|
const payType: Record<string, any> = payTypeList.getJSONObject(i);
|
||||||
|
set(channel.getStr("key"), payType.getStr("key"), payType);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* set
|
* set
|
||||||
*/
|
*/
|
||||||
async set(...args: any[]): Promise<any> {
|
async set(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const payChannel: PayChannel = payChannelMapper.selectOne(new QueryWrapper<PayChannel>()
|
||||||
return null;
|
.eq("site_id", RequestUtils.siteId())
|
||||||
|
.eq("channel", channel)
|
||||||
|
.eq("type", type)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (ObjectUtil.isNotEmpty(payChannel)) {
|
||||||
|
const config: Record<string, any> = JSONUtil.parseObj(payChannel.getConfig());
|
||||||
|
for (const key of data.getJSONObject("config").keySet()) {
|
||||||
|
const value: string = data.getJSONObject("config").getStr(key, "");
|
||||||
|
if (!value.includes("*")) config.set(key, value);
|
||||||
|
}
|
||||||
|
payChannel.setConfig(config.toString());
|
||||||
|
payChannel.setSort(data.getInt("sort"));
|
||||||
|
payChannel.setStatus(data.getInt("status"));
|
||||||
|
payChannelMapper.updateById(payChannel);
|
||||||
|
} else {
|
||||||
|
const model: PayChannel = new PayChannel();
|
||||||
|
model.setSiteId(RequestUtils.siteId());
|
||||||
|
model.setChannel(channel);
|
||||||
|
model.setType(type);
|
||||||
|
model.setConfig(data.getJSONObject("config").toString());
|
||||||
|
model.setSort(data.getInt("sort"));
|
||||||
|
model.setStatus(data.getInt("status"));
|
||||||
|
payChannelMapper.insert(model);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* getListByChannel
|
* getListByChannel
|
||||||
*/
|
*/
|
||||||
async getListByChannel(...args: any[]): Promise<any> {
|
async getListByChannel(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const payChannel: PayChannel[] = payChannelMapper.selectList(new QueryWrapper<PayChannel>()
|
||||||
return null;
|
.eq("site_id", RequestUtils.siteId())
|
||||||
|
.eq("channel", channel)
|
||||||
|
);
|
||||||
|
|
||||||
|
const list: PayChannelListVo[] = [];
|
||||||
|
for (const item of payChannel) {
|
||||||
|
const vo: PayChannelListVo = new PayChannelListVo();
|
||||||
|
BeanUtils.copyProperties(item, vo);
|
||||||
|
if (ObjectUtil.isNotEmpty(item.getConfig()) && "transfer" === channel) {
|
||||||
|
const config: Record<string, any> = JSONUtil.parseObj(item.getConfig());
|
||||||
|
// 定义需要隐藏的配置项列表
|
||||||
|
String[] keysToHide = {
|
||||||
|
"mch_secret_key",
|
||||||
|
"mch_secret_cert",
|
||||||
|
"mch_public_cert_path",
|
||||||
|
"wechat_public_cert_path",
|
||||||
|
"wechat_public_cert_id"
|
||||||
|
};
|
||||||
|
|
||||||
|
for (const key of keysToHide) {
|
||||||
|
const value: string = config.getStr(key);
|
||||||
|
if (ObjectUtil.isNotEmpty(value)) {
|
||||||
|
try {
|
||||||
|
config.set(key, StringUtils.hide(value, 0, value.length()));
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("字段:{},值:{},支付设置脱敏失败{}", key, value, e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
vo.setConfig(config.toString());
|
||||||
|
}
|
||||||
|
list.add(vo);
|
||||||
|
}
|
||||||
|
|
||||||
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* setTransfer
|
* setTransfer
|
||||||
*/
|
*/
|
||||||
async setTransfer(...args: any[]): Promise<any> {
|
async setTransfer(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const alipayConfig: Record<string, any> = param.getJSONObject("alipay_config");
|
||||||
return null;
|
const wechatpayConfig: Record<string, any> = param.getJSONObject("wechatpay_config");
|
||||||
|
|
||||||
|
if (wechatpayConfig != null) {
|
||||||
|
this.set("transfer", "wechatpay", new Record<string, any>()
|
||||||
|
.set("config", wechatpayConfig)
|
||||||
|
.set("status", 1)
|
||||||
|
.set("sort", 0));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (alipayConfig != null) {
|
||||||
|
this.set("transfer", "alipay", new Record<string, any>()
|
||||||
|
.set("config", alipayConfig)
|
||||||
|
.set("status", 1)
|
||||||
|
.set("sort", 0));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,23 +14,51 @@ export class PayRefundServiceImplService {
|
|||||||
* list
|
* list
|
||||||
*/
|
*/
|
||||||
async list(...args: any[]): Promise<any[]> {
|
async list(...args: any[]): Promise<any[]> {
|
||||||
// TODO: 实现业务逻辑
|
const page: number = pageParam.getPage();
|
||||||
return [];
|
const limit: number = pageParam.getLimit();
|
||||||
|
|
||||||
|
const queryWrapper: QueryWrapper<PayRefund> = new QueryWrapper<>();
|
||||||
|
queryWrapper.eq("site_id", RequestUtils.siteId());
|
||||||
|
if (ObjectUtil.isNotEmpty(searchParam.getRefundNo())) queryWrapper.eq("refund_no", searchParam.getRefundNo());
|
||||||
|
if (ObjectUtil.isNotEmpty(searchParam.getStatus())) queryWrapper.eq("status", searchParam.getStatus());
|
||||||
|
if (ObjectUtil.isNotEmpty(searchParam.getCreateTime())) QueryMapperUtils.buildByTime(queryWrapper, "create_time", searchParam.getCreateTime());
|
||||||
|
queryWrapper.orderByDesc("id");
|
||||||
|
|
||||||
|
const payTypeEnum: Record<string, any> = PayTypeEnum.getType();
|
||||||
|
|
||||||
|
const iPage: IPage<PayRefund> = payRefundMapper.selectPage(new Page<>(page, limit), queryWrapper);
|
||||||
|
const list: PayRefundListVo[] = [];
|
||||||
|
for (const item of iPage.getRecords()) {
|
||||||
|
const vo: PayRefundListVo = new PayRefundListVo();
|
||||||
|
BeanUtils.copyProperties(item, vo);
|
||||||
|
vo.setTypeName(payTypeEnum.getByPath(vo.getType() + ".name", String.class));
|
||||||
|
list.add(vo);
|
||||||
|
}
|
||||||
|
return PageResult.build(page, limit, iPage.getTotal()).setData(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* info
|
* info
|
||||||
*/
|
*/
|
||||||
async info(...args: any[]): Promise<any> {
|
async info(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const model: PayRefund = payRefundMapper.selectOne(
|
||||||
return null;
|
new QueryWrapper<PayRefund>()
|
||||||
|
.eq("refund_no", refundNo)
|
||||||
|
.eq("site_id", RequestUtils.siteId())
|
||||||
|
.last("limit 1"));
|
||||||
|
|
||||||
|
Assert.notNull(model, "数据不存在");
|
||||||
|
|
||||||
|
const vo: PayRefundInfoVo = new PayRefundInfoVo();
|
||||||
|
BeanUtils.copyProperties(model, vo);
|
||||||
|
return vo;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* transfer
|
* transfer
|
||||||
*/
|
*/
|
||||||
async transfer(...args: any[]): Promise<any> {
|
async transfer(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
param.setSiteId(RequestUtils.siteId());
|
||||||
return null;
|
coreRefundService.refund(param);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,63 +14,173 @@ export class PayServiceImplService {
|
|||||||
* list
|
* list
|
||||||
*/
|
*/
|
||||||
async list(...args: any[]): Promise<any[]> {
|
async list(...args: any[]): Promise<any[]> {
|
||||||
// TODO: 实现业务逻辑
|
const page: number = pageParam.getPage();
|
||||||
return [];
|
const limit: number = pageParam.getLimit();
|
||||||
|
|
||||||
|
const queryWrapper: QueryWrapper<Pay> = new QueryWrapper<>();
|
||||||
|
queryWrapper.orderByDesc("id");
|
||||||
|
|
||||||
|
const iPage: IPage<Pay> = payMapper.selectPage(new Page<>(page, limit), queryWrapper);
|
||||||
|
const list: PayListVo[] = [];
|
||||||
|
for (const item of iPage.getRecords()) {
|
||||||
|
const vo: PayListVo = new PayListVo();
|
||||||
|
BeanUtils.copyProperties(item, vo);
|
||||||
|
list.add(vo);
|
||||||
|
}
|
||||||
|
return PageResult.build(page, limit, iPage.getTotal()).setData(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* info
|
* info
|
||||||
*/
|
*/
|
||||||
async info(...args: any[]): Promise<any> {
|
async info(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const model: Pay = payMapper.selectOne(
|
||||||
return null;
|
new QueryWrapper<Pay>()
|
||||||
|
.eq("id", id)
|
||||||
|
.last("limit 1"));
|
||||||
|
|
||||||
|
Assert.notNull(model, "数据不存在");
|
||||||
|
|
||||||
|
const vo: PayInfoVo = new PayInfoVo();
|
||||||
|
BeanUtils.copyProperties(model, vo);
|
||||||
|
return vo;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* add
|
* add
|
||||||
*/
|
*/
|
||||||
async add(...args: any[]): Promise<any> {
|
async add(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const model: Pay = new Pay();
|
||||||
return null;
|
model.setSiteId(addParam.getSiteId());
|
||||||
|
model.setMainId(addParam.getMainId());
|
||||||
|
model.setOutTradeNo(addParam.getOutTradeNo());
|
||||||
|
model.setTradeType(addParam.getTradeType());
|
||||||
|
model.setTradeId(addParam.getTradeId());
|
||||||
|
model.setTradeNo(addParam.getTradeNo());
|
||||||
|
model.setBody(addParam.getBody());
|
||||||
|
model.setMoney(addParam.getMoney());
|
||||||
|
model.setVoucher(addParam.getVoucher());
|
||||||
|
model.setStatus(addParam.getStatus());
|
||||||
|
model.setJson(addParam.getJson());
|
||||||
|
model.setCreateTime(System.currentTimeMillis() / 1000);
|
||||||
|
model.setPayTime(addParam.getPayTime());
|
||||||
|
model.setCancelTime(addParam.getCancelTime());
|
||||||
|
model.setType(addParam.getType());
|
||||||
|
model.setMchId(addParam.getMchId());
|
||||||
|
model.setMainType(addParam.getMainType());
|
||||||
|
model.setChannel(addParam.getChannel());
|
||||||
|
model.setFailReason(addParam.getFailReason());
|
||||||
|
payMapper.insert(model);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* edit
|
* edit
|
||||||
*/
|
*/
|
||||||
async edit(...args: any[]): Promise<any> {
|
async edit(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const model: Pay = payMapper.selectOne(
|
||||||
return null;
|
new QueryWrapper<Pay>()
|
||||||
|
.eq("id", id)
|
||||||
|
.last("limit 1"));
|
||||||
|
|
||||||
|
Assert.notNull(model, "数据不存在!");
|
||||||
|
model.setId(id);
|
||||||
|
model.setSiteId(editParam.getSiteId());
|
||||||
|
model.setMainId(editParam.getMainId());
|
||||||
|
model.setOutTradeNo(editParam.getOutTradeNo());
|
||||||
|
model.setTradeType(editParam.getTradeType());
|
||||||
|
model.setTradeId(editParam.getTradeId());
|
||||||
|
model.setTradeNo(editParam.getTradeNo());
|
||||||
|
model.setBody(editParam.getBody());
|
||||||
|
model.setMoney(editParam.getMoney());
|
||||||
|
model.setVoucher(editParam.getVoucher());
|
||||||
|
model.setStatus(editParam.getStatus());
|
||||||
|
model.setJson(editParam.getJson());
|
||||||
|
model.setPayTime(editParam.getPayTime());
|
||||||
|
model.setCancelTime(editParam.getCancelTime());
|
||||||
|
model.setType(editParam.getType());
|
||||||
|
model.setMchId(editParam.getMchId());
|
||||||
|
model.setMainType(editParam.getMainType());
|
||||||
|
model.setChannel(editParam.getChannel());
|
||||||
|
model.setFailReason(editParam.getFailReason());
|
||||||
|
payMapper.updateById(model);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* del
|
* del
|
||||||
*/
|
*/
|
||||||
async del(...args: any[]): Promise<any> {
|
async del(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const model: Pay = payMapper.selectOne(
|
||||||
return null;
|
new QueryWrapper<Pay>()
|
||||||
|
.eq("id", id)
|
||||||
|
.last("limit 1"));
|
||||||
|
|
||||||
|
Assert.notNull(model, "数据不存在!");
|
||||||
|
|
||||||
|
payMapper.delete(new QueryWrapper<Pay>().eq("id", id));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* getFriendspayInfoByTrade
|
* getFriendspayInfoByTrade
|
||||||
*/
|
*/
|
||||||
async getFriendspayInfoByTrade(...args: any[]): Promise<any> {
|
async getFriendspayInfoByTrade(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const payInfo: GetInfoByTradeVo = corePayService.getInfoByTrade(RequestUtils.siteId(), param.getTradeType(), param.getTradeId(), param.getChannel(), "friendspay");
|
||||||
return null;
|
if (ObjectUtil.isEmpty(payInfo)) {
|
||||||
|
return new FriendsPayInfoByTradeVo();
|
||||||
|
}
|
||||||
|
|
||||||
|
const vo: FriendsPayInfoByTradeVo = new FriendsPayInfoByTradeVo();
|
||||||
|
BeanUtils.copyProperties(payInfo, vo);
|
||||||
|
vo.setConfig(payInfo.getConfig());
|
||||||
|
vo.setCreateTime(DateUtils.timestampToString(payInfo.getCreateTime()));
|
||||||
|
|
||||||
|
if (payInfo.getCancelTime() > 0) {
|
||||||
|
vo.setCancelTime(DateUtils.timestampToString(payInfo.getCancelTime()));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (payInfo.getPayTime() > 0) {
|
||||||
|
vo.setPayTime(DateUtils.timestampToString(payInfo.getPayTime()));
|
||||||
|
}
|
||||||
|
|
||||||
|
const posterQueryWrapper: QueryWrapper<SysPoster> = new QueryWrapper<>();
|
||||||
|
posterQueryWrapper.eq("site_id", RequestUtils.siteId())
|
||||||
|
.eq("type", "friendspay")
|
||||||
|
.eq("status", 1)
|
||||||
|
.eq("is_default", 1);
|
||||||
|
|
||||||
|
const poster: SysPoster = sysPosterMapper.selectOne(posterQueryWrapper);
|
||||||
|
if (ObjectUtil.isNotEmpty(poster)) {
|
||||||
|
vo.setPosterId(poster.getId());
|
||||||
|
}
|
||||||
|
|
||||||
|
const memberQueryWrapper: QueryWrapper<Member> = new QueryWrapper<>();
|
||||||
|
memberQueryWrapper.eq("site_id", RequestUtils.siteId())
|
||||||
|
.eq("member_id", vo.getMainId());
|
||||||
|
const member: Member = memberMapper.selectOne(memberQueryWrapper);
|
||||||
|
vo.setMember(member);
|
||||||
|
|
||||||
|
const qrcode: QR = getQrcode(param.getTradeType(), param.getTradeId(), param.getChannel());
|
||||||
|
vo.setLink(qrcode.link);
|
||||||
|
vo.setQrcode(qrcode.qrcode);
|
||||||
|
return vo;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* getPayTypeList
|
* getPayTypeList
|
||||||
*/
|
*/
|
||||||
async getPayTypeList(...args: any[]): Promise<any> {
|
async getPayTypeList(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const payTypeList: PayTypeVo[] = corePayService.getPayTypeByTrade(RequestUtils.siteId(), "", ChannelEnum.H5);
|
||||||
return null;
|
if (ObjectUtil.isEmpty(payTypeList)) {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
|
||||||
|
return payTypeList.stream().filter(o => o.getKey() === "balancepay" || o.getKey() === "friendspay").toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* pay
|
* pay
|
||||||
*/
|
*/
|
||||||
async pay(...args: any[]): Promise<any> {
|
async pay(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
param.setSiteId(RequestUtils.siteId());
|
||||||
return null;
|
return corePayService.pay(param);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,15 +14,21 @@ export class PayTransferServiceImplService {
|
|||||||
* setSceneId
|
* setSceneId
|
||||||
*/
|
*/
|
||||||
async setSceneId(...args: any[]): Promise<any> {
|
async setSceneId(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const config: Record<string, any> = coreTransferSceneService.getWechatTransferSceneConfig(RequestUtils.siteId());
|
||||||
return null;
|
|
||||||
|
const tradeScenelist: Record<string, any> = TransferSceneEnum.getWechatTransferSceneMap();
|
||||||
|
if (!tradeScenelist.containsKey(param.getScene())) {
|
||||||
|
throw new BadRequestException("不存在的商户转账场景");
|
||||||
|
}
|
||||||
|
|
||||||
|
config.put(param.getScene(), param.getSceneId());
|
||||||
|
coreTransferSceneService.setWechatTransferSceneConfig(RequestUtils.siteId(), config);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* setTradeScene
|
* setTradeScene
|
||||||
*/
|
*/
|
||||||
async setTradeScene(...args: any[]): Promise<any> {
|
async setTradeScene(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
coreTransferSceneService.setTradeScene(RequestUtils.siteId(), param.getType(), param);
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,15 +14,84 @@ export class SiteAccountLogServiceImplService {
|
|||||||
* list
|
* list
|
||||||
*/
|
*/
|
||||||
async list(...args: any[]): Promise<any[]> {
|
async list(...args: any[]): Promise<any[]> {
|
||||||
// TODO: 实现业务逻辑
|
const page: number = pageParam.getPage();
|
||||||
return [];
|
const limit: number = pageParam.getLimit();
|
||||||
|
|
||||||
|
const queryWrapper: QueryWrapper<SiteAccountLog> = new QueryWrapper<>();
|
||||||
|
queryWrapper.eq("site_id", RequestUtils.siteId());
|
||||||
|
//查询条件判断组装
|
||||||
|
if (ObjectUtil.isNotEmpty(searchParam.getTradeNo())) {
|
||||||
|
queryWrapper.like("trade_no", searchParam.getTradeNo());
|
||||||
|
}
|
||||||
|
if (ObjectUtil.isNotEmpty(searchParam.getType())) {
|
||||||
|
queryWrapper.eq("type", searchParam.getType());
|
||||||
|
}
|
||||||
|
if (ObjectUtil.isNotEmpty(searchParam.getCreateTime())) {
|
||||||
|
String[] createTime = searchParam.getCreateTime();
|
||||||
|
QueryMapperUtils.buildByTime(queryWrapper, "create_time", createTime);
|
||||||
|
}
|
||||||
|
queryWrapper.orderByDesc("create_time");
|
||||||
|
const iPage: IPage<SiteAccountLog> = siteAccountLogMapper.selectPage(new Page<>(page, limit), queryWrapper);
|
||||||
|
const list: SiteAccountLogListVo[] = [];
|
||||||
|
for (const item of iPage.getRecords()) {
|
||||||
|
const vo: SiteAccountLogListVo = new SiteAccountLogListVo();
|
||||||
|
BeanUtils.copyProperties(item, vo);
|
||||||
|
const typeModel: any = new Object();
|
||||||
|
if (item.getType() === "pay") {
|
||||||
|
typeModel = payMapper.selectOne(
|
||||||
|
new QueryWrapper<Pay>()
|
||||||
|
.eq("out_trade_no", item.getTradeNo())
|
||||||
|
.last("limit 1"));
|
||||||
|
} else if (item.getType() === "refund") {
|
||||||
|
typeModel = payRefundMapper.selectOne(
|
||||||
|
new QueryWrapper<PayRefund>()
|
||||||
|
.eq("refund_no", item.getTradeNo())
|
||||||
|
.last("limit 1"));
|
||||||
|
} else {
|
||||||
|
typeModel = payTransferMapper.selectOne(
|
||||||
|
new QueryWrapper<PayTransfer>()
|
||||||
|
.eq("transfer_no", item.getTradeNo())
|
||||||
|
.last("limit 1"));
|
||||||
|
}
|
||||||
|
vo.setPayInfo(typeModel);
|
||||||
|
list.add(vo);
|
||||||
|
}
|
||||||
|
|
||||||
|
return PageResult.build(page, limit, iPage.getTotal()).setData(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* info
|
* info
|
||||||
*/
|
*/
|
||||||
async info(...args: any[]): Promise<any> {
|
async info(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const model: SiteAccountLog = siteAccountLogMapper.selectOne(
|
||||||
return null;
|
new QueryWrapper<SiteAccountLog>()
|
||||||
|
.eq("site_id", RequestUtils.siteId())
|
||||||
|
.eq("id", id)
|
||||||
|
.last("limit 1"));
|
||||||
|
|
||||||
|
Assert.notNull(model, "数据不存在");
|
||||||
|
|
||||||
|
const vo: SiteAccountLogInfoVo = new SiteAccountLogInfoVo();
|
||||||
|
BeanUtils.copyProperties(model, vo);
|
||||||
|
const typeModel: any = new Object();
|
||||||
|
if (model.getType() === "pay") {
|
||||||
|
typeModel = payMapper.selectOne(
|
||||||
|
new QueryWrapper<Pay>()
|
||||||
|
.eq("out_trade_no", model.getTradeNo())
|
||||||
|
.last("limit 1"));
|
||||||
|
} else if (model.getType() === "refund") {
|
||||||
|
typeModel = payRefundMapper.selectOne(
|
||||||
|
new QueryWrapper<PayRefund>()
|
||||||
|
.eq("refund_no", model.getTradeNo())
|
||||||
|
.last("limit 1"));
|
||||||
|
} else {
|
||||||
|
typeModel = payTransferMapper.selectOne(
|
||||||
|
new QueryWrapper<PayTransfer>()
|
||||||
|
.eq("transfer_no", model.getTradeNo())
|
||||||
|
.last("limit 1"));
|
||||||
|
}
|
||||||
|
vo.setPayInfo(typeModel);
|
||||||
|
return vo;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,71 +14,214 @@ export class SiteGroupServiceImplService {
|
|||||||
* list
|
* list
|
||||||
*/
|
*/
|
||||||
async list(...args: any[]): Promise<any[]> {
|
async list(...args: any[]): Promise<any[]> {
|
||||||
// TODO: 实现业务逻辑
|
const page: number = pageParam.getPage();
|
||||||
return [];
|
const limit: number = pageParam.getLimit();
|
||||||
|
|
||||||
|
const queryWrapper: QueryWrapper<SiteGroup> = new QueryWrapper<>();
|
||||||
|
if (ObjectUtil.isNotEmpty(searchParam.getKeywords())) {
|
||||||
|
queryWrapper.like("group_name", searchParam.getKeywords());
|
||||||
|
}
|
||||||
|
queryWrapper.orderByDesc("group_id");
|
||||||
|
|
||||||
|
const iPage: IPage<SiteGroup> = siteGroupMapper.selectPage(new Page<>(page, limit), queryWrapper);
|
||||||
|
|
||||||
|
//获取所有的const addonList: addon
|
||||||
|
List<Addon> = addonMapper.selectList(new QueryWrapper<Addon>().orderByDesc("id"));
|
||||||
|
const list: SiteGroupListVo[] = [];
|
||||||
|
for (const item of iPage.getRecords()) {
|
||||||
|
const vo: SiteGroupListVo = new SiteGroupListVo();
|
||||||
|
vo.setGroupId(item.getGroupId());
|
||||||
|
vo.setGroupName(item.getGroupName());
|
||||||
|
vo.setGroupDesc(item.getGroupDesc());
|
||||||
|
vo.setCreateTime(item.getCreateTime());
|
||||||
|
vo.setUpdateTime(item.getUpdateTime());
|
||||||
|
const addonJson: JSONArray = JSONUtil.parseArray(item.getAddon());
|
||||||
|
vo.setAddon(addonJson);
|
||||||
|
const appJson: JSONArray = JSONUtil.parseArray(item.getApp());
|
||||||
|
vo.setApp(appJson);
|
||||||
|
const addonStr: string[] = [];
|
||||||
|
const appStr: string[] = [];
|
||||||
|
const appList: SiteGroupListVo.IconAndTitle[] = [];
|
||||||
|
const addonListResult: SiteGroupListVo.IconAndTitle[] = [];
|
||||||
|
for (const addon of addonList)
|
||||||
|
{
|
||||||
|
if(addonJson.includes(addon.getKey())){
|
||||||
|
addonStr.add(addon.getTitle());
|
||||||
|
SiteGroupListVo.const iconAndTitle: IconAndTitle = new SiteGroupListVo.IconAndTitle();
|
||||||
|
iconAndTitle.setTitle(addon.getTitle());
|
||||||
|
try {
|
||||||
|
iconAndTitle.setIcon(ImageToBase64ConverterUtil.convertToBase64(addon.getIcon()));
|
||||||
|
} catch (Exception e) {
|
||||||
|
iconAndTitle.setIcon("");
|
||||||
|
}
|
||||||
|
addonListResult.add(iconAndTitle);
|
||||||
|
}
|
||||||
|
if(appJson.includes(addon.getKey())){
|
||||||
|
appStr.add(addon.getTitle());
|
||||||
|
SiteGroupListVo.const iconAndTitle: IconAndTitle = new SiteGroupListVo.IconAndTitle();
|
||||||
|
iconAndTitle.setTitle(addon.getTitle());
|
||||||
|
try {
|
||||||
|
iconAndTitle.setIcon(ImageToBase64ConverterUtil.convertToBase64(addon.getIcon()));
|
||||||
|
} catch (Exception e) {
|
||||||
|
iconAndTitle.setIcon("");
|
||||||
|
}
|
||||||
|
|
||||||
|
appList.add(iconAndTitle);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
vo.setAddonName(addonStr);
|
||||||
|
vo.setAppName(appStr);
|
||||||
|
vo.setAddonList(addonListResult);
|
||||||
|
vo.setAppList(appList);
|
||||||
|
list.add(vo);
|
||||||
|
}
|
||||||
|
return PageResult.build(iPage.getCurrent(), iPage.getSize(), iPage.getTotal()).setData(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* getAll
|
* getAll
|
||||||
*/
|
*/
|
||||||
async getAll(...args: any[]): Promise<any> {
|
async getAll(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const queryWrapper: QueryWrapper<SiteGroup> = new QueryWrapper<>();
|
||||||
return null;
|
queryWrapper.orderByDesc("group_id");
|
||||||
|
return siteGroupMapper.selectList(queryWrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* info
|
* info
|
||||||
*/
|
*/
|
||||||
async info(...args: any[]): Promise<any> {
|
async info(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const model: SiteGroup = siteGroupMapper.selectOne(
|
||||||
return null;
|
new QueryWrapper<SiteGroup>()
|
||||||
|
.eq("group_id", id)
|
||||||
|
.last("limit 1"));
|
||||||
|
|
||||||
|
Assert.notNull(model, "数据不存在");
|
||||||
|
return model;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* add
|
* add
|
||||||
*/
|
*/
|
||||||
async add(...args: any[]): Promise<any> {
|
async add(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const groupRoles: JSONArray = new JSONArray();
|
||||||
return null;
|
groupRoles.addAll(addParam.getAddon());
|
||||||
|
groupRoles.addAll(addParam.getApp());
|
||||||
|
/**判断应用是否全部是有效的已安装应用 */
|
||||||
|
checkAddon(groupRoles);
|
||||||
|
const model: SiteGroup = new SiteGroup();
|
||||||
|
model.setGroupName(addParam.getGroupName());
|
||||||
|
model.setGroupDesc(addParam.getGroupDesc());
|
||||||
|
model.setApp(JSONUtil.toJsonStr(addParam.getApp()));
|
||||||
|
model.setAddon(JSONUtil.toJsonStr(addParam.getAddon()));
|
||||||
|
model.setCreateTime(DateUtils.currTime());
|
||||||
|
model.setUpdateTime(DateUtils.currTime());
|
||||||
|
siteGroupMapper.insert(model);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* edit
|
* edit
|
||||||
*/
|
*/
|
||||||
async edit(...args: any[]): Promise<any> {
|
async edit(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const model: SiteGroup = siteGroupMapper.selectOne(
|
||||||
return null;
|
new QueryWrapper<SiteGroup>()
|
||||||
|
.eq("group_id", id)
|
||||||
|
.last("limit 1"));
|
||||||
|
|
||||||
|
Assert.notNull(model, "数据不存在!");
|
||||||
|
|
||||||
|
const groupRoles: JSONArray = new JSONArray();
|
||||||
|
groupRoles.addAll(editParam.getAddon());
|
||||||
|
groupRoles.addAll(editParam.getApp());
|
||||||
|
/**判断应用是否全部是有效的已安装应用 */
|
||||||
|
checkAddon(groupRoles);
|
||||||
|
|
||||||
|
const group: SiteGroup = new SiteGroup();
|
||||||
|
group.setGroupId(id);
|
||||||
|
group.setGroupId(editParam.getGroupId());
|
||||||
|
group.setGroupName(editParam.getGroupName());
|
||||||
|
group.setGroupDesc(editParam.getGroupDesc());
|
||||||
|
group.setApp(JSONUtil.toJsonStr(editParam.getApp()));
|
||||||
|
group.setAddon(JSONUtil.toJsonStr(editParam.getAddon()));
|
||||||
|
group.setUpdateTime(DateUtils.currTime());
|
||||||
|
siteGroupMapper.updateById(group);
|
||||||
|
this.cached.remove("site_group_menu_ids" + id);
|
||||||
|
if (!model.getApp() === group.getApp()) {
|
||||||
|
// 修改站点应用
|
||||||
|
const siteModel: Site = new Site();
|
||||||
|
siteModel.setApp(model.getApp());
|
||||||
|
siteMapper.update(siteModel, new QueryWrapper<Site>().eq("group_id", id));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!model.getApp() === group.getApp() || !model.getAddon() === group.getAddon()) {
|
||||||
|
const siteList: Site[] = siteMapper.selectList(new QueryWrapper<Site>().eq("group_id", id));
|
||||||
|
if (ObjectUtil.isNotEmpty(siteList)) {
|
||||||
|
for (const site of siteList) {
|
||||||
|
siteService.siteAddonChange(site, model);
|
||||||
|
coreSiteService.clearSiteCache(site.getSiteId());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* del
|
* del
|
||||||
*/
|
*/
|
||||||
async del(...args: any[]): Promise<any> {
|
async del(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const model: SiteGroup = siteGroupMapper.selectOne(
|
||||||
return null;
|
new QueryWrapper<SiteGroup>()
|
||||||
|
.eq("group_id", id)
|
||||||
|
.last("limit 1"));
|
||||||
|
|
||||||
|
Assert.notNull(model, "数据不存在!");
|
||||||
|
const siteCount: number = siteMapper.selectCount(new QueryWrapper<Site>().eq("group_id", id));
|
||||||
|
if(siteCount>0){
|
||||||
|
throw new BadRequestException("当前套餐存在站点,不能删除");
|
||||||
|
}
|
||||||
|
siteGroupMapper.delete(new QueryWrapper<SiteGroup>().eq("group_id", id));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* checkAddon
|
* checkAddon
|
||||||
*/
|
*/
|
||||||
async checkAddon(...args: any[]): Promise<any> {
|
async checkAddon(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const addonListVoMap: Record<string, any> = coreAddonService.getInstallAddonList();
|
||||||
return null;
|
const keys: string[] = new ArrayList<>(addonListVoMap.keySet());
|
||||||
|
const addonString: string[] = JSONUtil.toList(jsonArray, String.class);
|
||||||
|
keys.retainAll(addonString);
|
||||||
|
if(keys.size()!=addonString.size()){
|
||||||
|
throw new AdminException("SITE_GROUP_APP_NOT_EXIST");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* getUserSiteGroupAll
|
* getUserSiteGroupAll
|
||||||
*/
|
*/
|
||||||
async getUserSiteGroupAll(...args: any[]): Promise<any> {
|
async getUserSiteGroupAll(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const siteGroupListVoList: SiteGroupListVo[] = [];
|
||||||
return null;
|
const siteGroupList: SiteGroup[] = siteGroupMapper.selectList(new QueryWrapper<>());
|
||||||
|
|
||||||
|
for (const siteGroup of siteGroupList) {
|
||||||
|
const siteGroupListVo: SiteGroupListVo = new SiteGroupListVo();
|
||||||
|
BeanUtils.copyProperties(siteGroup, siteGroupListVo);
|
||||||
|
siteGroupListVo.setSiteNum(getUserSiteGroupSiteNum(uid, siteGroup.getGroupId()));
|
||||||
|
siteGroupListVoList.add(siteGroupListVo);
|
||||||
|
}
|
||||||
|
return siteGroupListVoList;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* getUserSiteGroupSiteNum
|
* getUserSiteGroupSiteNum
|
||||||
*/
|
*/
|
||||||
async getUserSiteGroupSiteNum(...args: any[]): Promise<any> {
|
async getUserSiteGroupSiteNum(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const userRoleMPJQueryWrapper: MPJQueryWrapper<SysUserRole> = new MPJQueryWrapper<>();
|
||||||
return null;
|
userRoleMPJQueryWrapper.setAlias("sur")
|
||||||
|
.leftJoin("?_site s ON sur.site_id = s.site_id".replace("?_", this.config.get('tablePrefix')));
|
||||||
|
userRoleMPJQueryWrapper.eq("sur.uid", uid);
|
||||||
|
userRoleMPJQueryWrapper.eq("sur.is_admin", 1);
|
||||||
|
userRoleMPJQueryWrapper.eq("s.group_id", groupId);
|
||||||
|
const count: number = sysUserRoleMapper.selectJoinCount(userRoleMPJQueryWrapper);
|
||||||
|
return count;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,95 +14,446 @@ export class SiteServiceImplService {
|
|||||||
* list
|
* list
|
||||||
*/
|
*/
|
||||||
async list(...args: any[]): Promise<any[]> {
|
async list(...args: any[]): Promise<any[]> {
|
||||||
// TODO: 实现业务逻辑
|
const page: number = pageParam.getPage();
|
||||||
return [];
|
const limit: number = pageParam.getLimit();
|
||||||
|
|
||||||
|
const queryWrapper: MPJQueryWrapper<Site> = new MPJQueryWrapper();
|
||||||
|
queryWrapper.setAlias("se")
|
||||||
|
.selectAll(Site.class)
|
||||||
|
.select("sg.group_name")
|
||||||
|
.leftJoin("?_site_group sg on sg.group_id = se.group_id".replace("?_", this.config.get('tablePrefix')));
|
||||||
|
|
||||||
|
|
||||||
|
//查询条件判断组装
|
||||||
|
if (ObjectUtil.isNotEmpty(searchParam.getKeywords())) {
|
||||||
|
queryWrapper.like("se.siteName", searchParam.getKeywords()).or().like("se.siteName", searchParam.getKeywords());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ObjectUtil.isNotEmpty(searchParam.getApp())) {
|
||||||
|
queryWrapper.and(wrapper => wrapper
|
||||||
|
.like("sg.addon", searchParam.getApp())
|
||||||
|
.or()
|
||||||
|
.like("sg.app", searchParam.getApp())
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ObjectUtil.isNotEmpty(searchParam.getStatus())) {
|
||||||
|
queryWrapper.eq("se.status", searchParam.getStatus());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ObjectUtil.isNotEmpty(searchParam.getGroupId())) {
|
||||||
|
queryWrapper.eq("se.group_id", searchParam.getGroupId());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ObjectUtil.isNotEmpty(searchParam.getSiteDomain())) {
|
||||||
|
queryWrapper.like("se.site_domain", searchParam.getSiteDomain());
|
||||||
|
}
|
||||||
|
queryWrapper.ne("se.app_type", "admin");
|
||||||
|
if (ObjectUtil.isNotEmpty(searchParam.getCreateTime())) {
|
||||||
|
|
||||||
|
String[] createTime = searchParam.getCreateTime();
|
||||||
|
const startTime: number = (createTime[0] == null) ? 0L : DateUtils.StringToTimestamp(createTime[0]);
|
||||||
|
const endTime: number = (createTime[1] == null) ? 0L : DateUtils.StringToTimestamp(createTime[1]);
|
||||||
|
if (startTime > 0L && endTime > 0L) {
|
||||||
|
queryWrapper.between("se.create_time", startTime, endTime);
|
||||||
|
} else if (startTime > 0L && endTime == 0L) {
|
||||||
|
queryWrapper.ge("se.create_time", startTime);
|
||||||
|
} else if (startTime == 0L && endTime > 0L) {
|
||||||
|
queryWrapper.le("se.create_time", startTime);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ObjectUtil.isNotEmpty(searchParam.getExpireTime())) {
|
||||||
|
|
||||||
|
String[] expireTime = searchParam.getExpireTime();
|
||||||
|
const startTime: number = (expireTime[0] == null) ? 0 : DateUtils.StringToTimestamp(expireTime[0]);
|
||||||
|
const endTime: number = (expireTime[1] == null) ? 0 : DateUtils.StringToTimestamp(expireTime[1]);
|
||||||
|
if (startTime > 0 && endTime > 0) {
|
||||||
|
queryWrapper.between("se.expire_time", startTime, endTime);
|
||||||
|
} else if (startTime > 0 && endTime == 0) {
|
||||||
|
queryWrapper.ge("se.expire_time", startTime);
|
||||||
|
} else if (startTime == 0 && endTime > 0) {
|
||||||
|
queryWrapper.le("se.expire_time", startTime);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
queryWrapper.orderByDesc("se.create_time");
|
||||||
|
|
||||||
|
const iPage: IPage<SiteListVo> = siteMapper.selectJoinPage(new Page<>(page, limit), SiteListVo.class, queryWrapper);
|
||||||
|
|
||||||
|
const list: SiteListVo[] = [];
|
||||||
|
for (const item of iPage.getRecords()) {
|
||||||
|
const vo: SiteListVo = new SiteListVo();
|
||||||
|
BeanUtils.copyProperties(item, vo);
|
||||||
|
const userRoleMPJQueryWrapper: MPJQueryWrapper<SysUserRole> = new MPJQueryWrapper<>();
|
||||||
|
userRoleMPJQueryWrapper.select("nsu.uid, nsu.username, nsu.head_img, nsu.real_name, nsu.last_ip, nsu.last_time, nsu.create_time, nsu.login_count")
|
||||||
|
.setAlias("nsur")
|
||||||
|
.leftJoin("?_sys_user nsu ON nsur.uid = nsu.uid".replace("?_", this.config.get('tablePrefix')));
|
||||||
|
userRoleMPJQueryWrapper.eq("nsur.is_admin", 1);
|
||||||
|
userRoleMPJQueryWrapper.eq("nsur.site_id", item.getSiteId());
|
||||||
|
vo.setAdmin(sysUserRoleMapper.selectJoinOne(SiteAdminVo.class, userRoleMPJQueryWrapper));
|
||||||
|
list.add(vo);
|
||||||
|
}
|
||||||
|
return PageResult.build(page, limit, iPage.getTotal(), list);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* info
|
* info
|
||||||
*/
|
*/
|
||||||
async info(...args: any[]): Promise<any> {
|
async info(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
return iCoreSiteService.getSiteCache(id);
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* add
|
* add
|
||||||
*/
|
*/
|
||||||
async add(...args: any[]): Promise<any> {
|
async add(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const siteGroup: SiteGroup = siteGroupService.info(addParam.getGroupId());
|
||||||
return null;
|
if (ObjectUtil.isNull(siteGroup) || ObjectUtil.isEmpty(siteGroup)) {
|
||||||
|
throw new BadRequestException("SITE_GROUP_NOT_EXIST");
|
||||||
|
}
|
||||||
|
const model: Site = new Site();
|
||||||
|
model.setSiteName(addParam.getSiteName());
|
||||||
|
model.setGroupId(addParam.getGroupId());
|
||||||
|
model.setAppType(AppTypeEnum.path.basename(SITE));
|
||||||
|
model.setCreateTime(DateUtils.currTime());
|
||||||
|
model.setExpireTime(DateUtils.StringToTimestamp(addParam.getExpireTime()));
|
||||||
|
model.setApp(siteGroup.getApp());
|
||||||
|
model.setAddons("");
|
||||||
|
model.setSiteDomain(addParam.getSiteDomain());
|
||||||
|
siteMapper.insert(model);
|
||||||
|
const siteId: number = model.getSiteId();
|
||||||
|
if (ObjectUtil.isNull(addParam.getUid()) || addParam.getUid() == 0) {
|
||||||
|
//添加用户
|
||||||
|
const siteUserParam: SiteUserParam = new SiteUserParam();
|
||||||
|
siteUserParam.setUsername(addParam.getUsername());
|
||||||
|
siteUserParam.setHeadImg("");
|
||||||
|
siteUserParam.setStatus(1);
|
||||||
|
siteUserParam.setRealName(addParam.getRealName());
|
||||||
|
siteUserParam.setPassword(addParam.getPassword());
|
||||||
|
siteUserParam.setIsAdmin(1);
|
||||||
|
sysUserService.addSiteUser(siteUserParam, siteId);
|
||||||
|
} else {
|
||||||
|
const sysUserRoleParam: SysUserRoleParam = new SysUserRoleParam();
|
||||||
|
sysUserRoleParam.setUid(addParam.getUid());
|
||||||
|
sysUserRoleParam.setRoleIds(new JsonArray().toString());
|
||||||
|
sysUserRoleParam.setIsAdmin(1);
|
||||||
|
sysUserRoleParam.setSiteId(siteId);
|
||||||
|
userRoleService.add(sysUserRoleParam);
|
||||||
|
}
|
||||||
|
|
||||||
|
const event: SiteAddAfterEvent = new SiteAddAfterEvent();
|
||||||
|
event.setSiteId(siteId);
|
||||||
|
event.addAppSign("core");
|
||||||
|
event.setName("SiteAddAfterEvent");
|
||||||
|
event.setSite(model);
|
||||||
|
event.setSiteGroup(siteGroup);
|
||||||
|
EventAndSubscribeOfPublisher.publishAll(event);
|
||||||
|
|
||||||
|
const param: Record<string, any> = {};
|
||||||
|
param.put("site_id", siteId);
|
||||||
|
param.put("main_app", siteGroup.getApp());
|
||||||
|
param.put("tag", "add");
|
||||||
|
diyService.loadDiyData(param);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* edit
|
* edit
|
||||||
*/
|
*/
|
||||||
async edit(...args: any[]): Promise<any> {
|
async edit(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const model: Site = siteMapper.selectOne(
|
||||||
return null;
|
new QueryWrapper<Site>()
|
||||||
|
.eq("site_id", id)
|
||||||
|
.last("limit 1"));
|
||||||
|
|
||||||
|
Assert.notNull(model, "数据不存在!");
|
||||||
|
if (ObjectUtil.isNotNull(editParam.getGroupId()) && ObjectUtil.isNotEmpty(editParam.getGroupId()) && !editParam.getGroupId() === model.getGroupId()) {
|
||||||
|
model.setGroupId(editParam.getGroupId());
|
||||||
|
}
|
||||||
|
if (ObjectUtil.isNotNull(editParam.getSiteName()) && ObjectUtil.isNotEmpty(editParam.getSiteName())) {
|
||||||
|
model.setSiteName(editParam.getSiteName());
|
||||||
|
}
|
||||||
|
|
||||||
|
const oldSiteGroup: SiteGroup = siteGroupService.info(model.getGroupId());
|
||||||
|
|
||||||
|
const initallJsonArray: JSONArray = new JSONArray();
|
||||||
|
if (ObjectUtil.isNull(model.getInitalledAddon()) || ObjectUtil.isEmpty(model.getInitalledAddon())) {
|
||||||
|
initallJsonArray.addAll(JSONUtil.parseArray(oldSiteGroup.getApp()));
|
||||||
|
initallJsonArray.addAll(JSONUtil.parseArray(oldSiteGroup.getAddon()));
|
||||||
|
}
|
||||||
|
|
||||||
|
const siteGroup: SiteGroup = siteGroupService.info(editParam.getGroupId());
|
||||||
|
if (ObjectUtil.isNull(siteGroup) || ObjectUtil.isEmpty(siteGroup)) {
|
||||||
|
throw new BadRequestException("SITE_GROUP_NOT_EXIST");
|
||||||
|
}
|
||||||
|
initallJsonArray.addAll(JSONUtil.parseArray(siteGroup.getApp()));
|
||||||
|
initallJsonArray.addAll(JSONUtil.parseArray(siteGroup.getAddon()));
|
||||||
|
|
||||||
|
model.setInitalledAddon(JSONUtil.toJsonStr(initallJsonArray));
|
||||||
|
model.setSiteDomain(editParam.getSiteDomain());
|
||||||
|
model.setExpireTime(new DateTime(editParam.getExpireTime()).getTime() / 1000);
|
||||||
|
model.setStatus(model.getExpireTime() > DateUtils.currTime() ? SiteStatusEnum.ON.getCode() : SiteStatusEnum.EXPIRE.getCode());
|
||||||
|
siteMapper.updateById(model);
|
||||||
|
|
||||||
|
coreSiteService.clearSiteCache(id);
|
||||||
|
|
||||||
|
const event: SiteEditAfterEvent = new SiteEditAfterEvent();
|
||||||
|
event.setSiteId(model.getSiteId());
|
||||||
|
event.addAppSign("core");
|
||||||
|
event.setName("SiteEditAfterEvent");
|
||||||
|
event.setSite(model);
|
||||||
|
event.setSiteGroup(siteGroup);
|
||||||
|
EventAndSubscribeOfPublisher.publishAll(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* del
|
* del
|
||||||
*/
|
*/
|
||||||
async del(...args: any[]): Promise<any> {
|
async del(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const siteUserRoles: SysUserRole[] = null;
|
||||||
return null;
|
const delResult: number = 0;
|
||||||
|
|
||||||
|
try {
|
||||||
|
const model: Site = siteMapper.selectById(id);
|
||||||
|
Assert.notNull(model, "数据不存在!");
|
||||||
|
|
||||||
|
//获取所有需要处理的Mapper
|
||||||
|
List<Class<? extends BaseMapper<?>>> allModels = new ArrayList<>(generateService.getMappers("system"));
|
||||||
|
coreSiteService.getAddonKeysBySiteId(id).forEach(addon => allModels.addAll(generateService.getMappers(addon))
|
||||||
|
);
|
||||||
|
|
||||||
|
Class<?> wrapperClass = Class.forName("com.baomidou.mybatisplus.core.conditions.query.QueryWrapper");
|
||||||
|
Constructor<?> wrapperConstructor = wrapperClass.getConstructor(Class.class);
|
||||||
|
const eqMethod: Method = wrapperClass.getMethod("eq", boolean.class, Object.class, Object.class);
|
||||||
|
const deleteMethod: Method = BaseMapper.class.getMethod("delete", Wrapper.class);
|
||||||
|
|
||||||
|
// 处理所有关联表
|
||||||
|
for (Class<? extends BaseMapper<?>> mapperClass : allModels) {
|
||||||
|
BaseMapper<?> mapper = (BaseMapper<?>) SpringContext.getBean(mapperClass);
|
||||||
|
if (mapper == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
Class<?> entityClass = resolveEntityClass(mapperClass);
|
||||||
|
if (entityClass == null || !hasSiteIdField(entityClass)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
// 创建QueryWrapper并执行删除
|
||||||
|
const wrapper: any = wrapperConstructor.newInstance(entityClass);
|
||||||
|
eqMethod.invoke(wrapper, true, "site_id", id);
|
||||||
|
deleteMethod.invoke(mapper, wrapper);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("删除表数据失败: {} | 原因: {}",
|
||||||
|
entityClass.getSimpleName(),
|
||||||
|
e.getCause() != null ? e.getCause().getMessage() : e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 处理用户角色关系
|
||||||
|
const userRoleWrapper: QueryWrapper<SysUserRole> = new QueryWrapper<>();
|
||||||
|
userRoleWrapper.eq("site_id", id);
|
||||||
|
siteUserRoles = sysUserRoleMapper.selectList(userRoleWrapper);
|
||||||
|
delResult = sysUserRoleMapper.delete(userRoleWrapper);
|
||||||
|
|
||||||
|
// 删除站点主表
|
||||||
|
siteMapper.deleteById(id);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("删除站点失败: {}", e.getMessage(), e);
|
||||||
|
throw new BadRequestException("删除失败: " + (e.getCause() != null ? e.getCause().getMessage() : e.getMessage()));
|
||||||
|
}
|
||||||
|
|
||||||
|
// 清理缓存
|
||||||
|
if (delResult > 0 && siteUserRoles != null) {
|
||||||
|
siteUserRoles.forEach(userRole => {
|
||||||
|
cached.remove("user_role_" + userRole.getUid() + "_" + id);
|
||||||
|
cached.remove("user_role_list_" + userRole.getUid());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
cached.remove("site_cache_" + id);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* closeSite
|
* closeSite
|
||||||
*/
|
*/
|
||||||
async closeSite(...args: any[]): Promise<any> {
|
async closeSite(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const model: Site = new Site();
|
||||||
return null;
|
model.setSiteId(siteId);
|
||||||
|
model.setStatus(SiteStatusEnum.CLOSE.getCode());
|
||||||
|
siteMapper.updateById(model);
|
||||||
|
coreSiteService.clearSiteCache(siteId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* openSite
|
* openSite
|
||||||
*/
|
*/
|
||||||
async openSite(...args: any[]): Promise<any> {
|
async openSite(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const model: Site = new Site();
|
||||||
return null;
|
model.setSiteId(siteId);
|
||||||
|
model.setStatus(SiteStatusEnum.ON.getCode());
|
||||||
|
siteMapper.updateById(model);
|
||||||
|
coreSiteService.clearSiteCache(siteId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* getSiteCountByCondition
|
* getSiteCountByCondition
|
||||||
*/
|
*/
|
||||||
async getSiteCountByCondition(...args: any[]): Promise<any> {
|
async getSiteCountByCondition(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const queryWrapper: QueryWrapper<Site> = new QueryWrapper<>();
|
||||||
return null;
|
if (ObjectUtil.isNotEmpty(siteSearchParam.getCreateTime())) {
|
||||||
|
|
||||||
|
String[] createTime = siteSearchParam.getCreateTime();
|
||||||
|
const startTime: number = (createTime[0] == null) ? 0 : DateUtils.StringToTimestamp(createTime[0]);
|
||||||
|
const endTime: number = (createTime[1] == null) ? 0 : DateUtils.StringToTimestamp(createTime[1]);
|
||||||
|
if (startTime > 0 && endTime > 0) {
|
||||||
|
queryWrapper.between("create_time", startTime, endTime);
|
||||||
|
} else if (startTime > 0 && endTime == 0) {
|
||||||
|
queryWrapper.ge("create_time", startTime);
|
||||||
|
} else if (startTime == 0 && endTime > 0) {
|
||||||
|
queryWrapper.le("create_time", startTime);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ObjectUtil.isNotEmpty(siteSearchParam.getStatus())) {
|
||||||
|
queryWrapper.eq("status", siteSearchParam.getStatus());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ObjectUtil.isNotEmpty(siteSearchParam.getGroupId())) {
|
||||||
|
queryWrapper.eq("group_id", siteSearchParam.getGroupId());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ObjectUtil.isNotEmpty(siteSearchParam.getAppType())) {
|
||||||
|
queryWrapper.eq("app_type", siteSearchParam.getAppType());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ObjectUtil.isNotEmpty(siteSearchParam.getExpireTime())) {
|
||||||
|
|
||||||
|
String[] expireTime = siteSearchParam.getExpireTime();
|
||||||
|
const startTime: number = (expireTime[0] == null) ? 0 : DateUtils.StringToTimestamp(expireTime[0]);
|
||||||
|
const endTime: number = (expireTime[1] == null) ? 0 : DateUtils.StringToTimestamp(expireTime[1]);
|
||||||
|
if (startTime > 0 && endTime > 0) {
|
||||||
|
queryWrapper.between("expire_time", startTime, endTime);
|
||||||
|
} else if (startTime > 0 && endTime == 0) {
|
||||||
|
queryWrapper.ge("expire_time", startTime);
|
||||||
|
} else if (startTime == 0 && endTime > 0) {
|
||||||
|
queryWrapper.le("expire_time", startTime);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const siteCount: number = siteMapper.selectCount(queryWrapper);
|
||||||
|
return siteCount.intValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* getSiteAddons
|
* getSiteAddons
|
||||||
*/
|
*/
|
||||||
async getSiteAddons(...args: any[]): Promise<any> {
|
async getSiteAddons(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
return addonMapper.selectList(new QueryWrapper<Addon>()
|
||||||
return null;
|
.eq("type", AddonTypeEnum.ADDON.getType())
|
||||||
|
.eq("status", 1)
|
||||||
|
.in("`key`", coreSiteService.getAddonKeysBySiteId(RequestUtils.siteId())));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* siteAddonChange
|
* siteAddonChange
|
||||||
*/
|
*/
|
||||||
async siteAddonChange(...args: any[]): Promise<any> {
|
async siteAddonChange(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const event: SiteEditAfterEvent = new SiteEditAfterEvent();
|
||||||
return null;
|
event.setSiteId(site.getSiteId());
|
||||||
|
event.addAppSign("core");
|
||||||
|
event.setName("SiteEditAfterEvent");
|
||||||
|
event.setSite(site);
|
||||||
|
event.setSiteGroup(siteGroup);
|
||||||
|
coreSiteService.clearSiteCache(site.getSiteId());
|
||||||
|
EventAndSubscribeOfPublisher.publishAll(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* siteInit
|
* siteInit
|
||||||
*/
|
*/
|
||||||
async siteInit(...args: any[]): Promise<any> {
|
async siteInit(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const siteInfo: SiteInfoVo = info(siteId);
|
||||||
return null;
|
if (ObjectUtil.isEmpty(siteInfo)) {
|
||||||
|
throw new AdminException("站点不存在");
|
||||||
|
}
|
||||||
|
const tables: string[] = SiteInitEnum.getSiteInitTables(siteId);
|
||||||
|
return coreSiteService.siteInitBySiteId(siteId, tables);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* getSpecialMenuList
|
* getSpecialMenuList
|
||||||
*/
|
*/
|
||||||
async getSpecialMenuList(...args: any[]): Promise<any> {
|
async getSpecialMenuList(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const authMenuList: JSONArray = authService.getAuthMenuTreeList(1, "all");
|
||||||
return null;
|
|
||||||
|
// 将菜单列表转换为Map,便于通过menu_key查找
|
||||||
|
const authMenuMap: Record<string, any> = {};
|
||||||
|
for (const i of number = 0; i < authMenuList.size(); i++) {
|
||||||
|
const menu: Record<string, any> = authMenuList.getJSONObject(i);
|
||||||
|
authMenuMap.put(menu.get("menu_key").toString(), menu);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取"addon"菜单
|
||||||
|
const addonMenu: Record<string, any> = authMenuMap.get("addon");
|
||||||
|
if (addonMenu == null) {
|
||||||
|
return new SpecialMenuListVo("addon", []);
|
||||||
|
}
|
||||||
|
|
||||||
|
const showList: Record<string, any> = showCustomer(false);
|
||||||
|
const addonChildMenus: AddonChildMenuEnum.MenuConfig[] = AddonChildMenuEnum.getAll();
|
||||||
|
|
||||||
|
const menuList: SpecialMenuListVo.MenuVo[] = [];
|
||||||
|
|
||||||
|
// 遍历插件子菜单,构建菜单列表
|
||||||
|
for (AddonChildMenuEnum.MenuConfig item : addonChildMenus) {
|
||||||
|
const menuKey: string = item.getKey();
|
||||||
|
const menuKeyList: string[] = [];
|
||||||
|
if (showList.containsKey(menuKey) && showList.get(menuKey) instanceof Map) {
|
||||||
|
const menuItem: Record<string, any> = (Map<String, Object>) showList.get(menuKey);
|
||||||
|
if (menuItem.containsKey("list") && menuItem.get("list") instanceof List) {
|
||||||
|
const listItems: Record<string, any>[] = (List<Map<String, Object>>) menuItem.get("list");
|
||||||
|
for (const listItem of listItems) {
|
||||||
|
if (listItem.containsKey("key")) {
|
||||||
|
menuKeyList.add(listItem.get("key").toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
SpecialMenuListVo.const tempMenu: MenuVo = new SpecialMenuListVo.MenuVo();
|
||||||
|
tempMenu.setMenuName(path.basename(item));
|
||||||
|
tempMenu.setMenuKey(item.getKey());
|
||||||
|
tempMenu.setMenuShortName(item.getShortName());
|
||||||
|
tempMenu.setParentKey("addon");
|
||||||
|
tempMenu.setMenuType("0");
|
||||||
|
tempMenu.setIcon("iconfont iconzhuangxiu3");
|
||||||
|
tempMenu.setApiUrl("");
|
||||||
|
tempMenu.setRouterPath("");
|
||||||
|
tempMenu.setViewPath("");
|
||||||
|
tempMenu.setMethods("");
|
||||||
|
tempMenu.setSort(item.getSort());
|
||||||
|
tempMenu.setStatus("1");
|
||||||
|
tempMenu.setIsShow("1");
|
||||||
|
|
||||||
|
const children: SpecialMenuListVo.MenuVo[] = [];
|
||||||
|
const authChildren: JSONArray = addonMenu.getJSONArray("children");
|
||||||
|
if (authChildren != null) {
|
||||||
|
for (const j of number = 0; j < authChildren.size(); j++) {
|
||||||
|
const child: Record<string, any> = authChildren.getJSONObject(j);
|
||||||
|
if (menuKeyList.includes(child.get("menu_key").toString())) {
|
||||||
|
// 转换为MenuVo对象
|
||||||
|
SpecialMenuListVo.const childMenu: MenuVo = convertToMenuVo(child);
|
||||||
|
children.add(childMenu);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
tempMenu.setChildren(children);
|
||||||
|
menuList.add(tempMenu);
|
||||||
|
}
|
||||||
|
const result: SpecialMenuListVo = new SpecialMenuListVo();
|
||||||
|
result.setParentKey("addon");
|
||||||
|
result.setList(menuList);
|
||||||
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,55 +14,120 @@ export class SiteUserServiceImplService {
|
|||||||
* list
|
* list
|
||||||
*/
|
*/
|
||||||
async list(...args: any[]): Promise<any[]> {
|
async list(...args: any[]): Promise<any[]> {
|
||||||
// TODO: 实现业务逻辑
|
const page: number = pageParam.getPage();
|
||||||
return [];
|
const limit: number = pageParam.getLimit();
|
||||||
|
|
||||||
|
const userRoleMPJQueryWrapper: MPJQueryWrapper<SysUserRole> = new MPJQueryWrapper<>();
|
||||||
|
userRoleMPJQueryWrapper.select("nsur.id, nsur.is_admin, nsu.status, nsur.site_id, nsur.role_ids, nsu.uid, nsu.username, nsu.head_img, nsu.real_name, nsu.last_ip, nsu.last_time, nsu.create_time, nsu.login_count")
|
||||||
|
.setAlias("nsur")
|
||||||
|
.leftJoin("?_sys_user nsu ON nsur.uid = nsu.uid".replace("?_", this.config.get('tablePrefix')));
|
||||||
|
if(ObjectUtil.isNotNull(searchParam.getUsername()) && ObjectUtil.isNotEmpty(searchParam.getUsername())){
|
||||||
|
userRoleMPJQueryWrapper.like("nsu.username", searchParam.getUsername());
|
||||||
|
}
|
||||||
|
userRoleMPJQueryWrapper.eq("nsur.site_id", RequestUtils.siteId());
|
||||||
|
userRoleMPJQueryWrapper.isNotNull("nsu.uid");
|
||||||
|
userRoleMPJQueryWrapper.orderByDesc("nsur.is_admin");
|
||||||
|
userRoleMPJQueryWrapper.orderByDesc("nsur.id");
|
||||||
|
const iPage: IPage<SiteUserVo> = sysUserRoleMapper.selectJoinPage(new Page<>(page, limit), SiteUserVo.class, userRoleMPJQueryWrapper);
|
||||||
|
for (const siteUserVo of iPage.getRecords()) {
|
||||||
|
const roleArray: string[] = [];
|
||||||
|
if(ObjectUtil.isNotEmpty(siteUserVo.getRoleIds()) && JSONUtil.parseArray(siteUserVo.getRoleIds()).size()>0){
|
||||||
|
const roleQueryWrapper: QueryWrapper<SysRole> = new QueryWrapper<>();
|
||||||
|
roleQueryWrapper.in("role_id", JSONUtil.parseArray(siteUserVo.getRoleIds()));
|
||||||
|
const roleList: SysRole[] = sysRoleMapper.selectList(roleQueryWrapper);
|
||||||
|
for (const sysRole of roleList) {
|
||||||
|
roleArray.add(sysRole.getRoleName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
siteUserVo.setRoleArray(roleArray);
|
||||||
|
}
|
||||||
|
return PageResult.build(page, limit, iPage.getTotal()).setData(iPage.getRecords());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* add
|
* add
|
||||||
*/
|
*/
|
||||||
async add(...args: any[]): Promise<any> {
|
async add(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
if (siteUserParam.getUsername().matches(".*[\\u4e00-\\u9fa5].*")){
|
||||||
return null;
|
throw new AdminException("用户名不能包含中文");
|
||||||
|
}
|
||||||
|
sysUserService.addSiteUser(siteUserParam, RequestUtils.siteId());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* getInfo
|
* getInfo
|
||||||
*/
|
*/
|
||||||
async getInfo(...args: any[]): Promise<any> {
|
async getInfo(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const userRoleMPJQueryWrapper: MPJQueryWrapper<SysUserRole> = new MPJQueryWrapper<>();
|
||||||
return null;
|
userRoleMPJQueryWrapper.select("nsur.id, nsur.is_admin, nsur.status,nsur.site_id, nsur.role_ids, nsu.uid, nsu.username, nsu.head_img, nsu.real_name, nsu.last_ip, nsu.last_time, nsu.create_time, nsu.login_count")
|
||||||
|
.setAlias("nsur")
|
||||||
|
.leftJoin("?_sys_user nsu ON nsur.uid = nsu.uid".replace("?_", this.config.get('tablePrefix')));
|
||||||
|
userRoleMPJQueryWrapper.eq("nsur.site_id", RequestUtils.siteId());
|
||||||
|
userRoleMPJQueryWrapper.eq("nsu.uid", uid);
|
||||||
|
|
||||||
|
const siteUserVo: SiteUserVo = sysUserRoleMapper.selectJoinOne(SiteUserVo.class, userRoleMPJQueryWrapper);
|
||||||
|
return siteUserVo;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* edit
|
* edit
|
||||||
*/
|
*/
|
||||||
async edit(...args: any[]): Promise<any> {
|
async edit(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
try{
|
||||||
return null;
|
const sysUserParam: SysUserParam = new SysUserParam();
|
||||||
|
sysUserParam.setHeadImg(siteUserParam.getHeadImg());
|
||||||
|
if(ObjectUtil.isNotEmpty(siteUserParam.getPassword())){
|
||||||
|
sysUserParam.setPassword(siteUserParam.getPassword());
|
||||||
|
}
|
||||||
|
sysUserParam.setUsername(siteUserParam.getUsername());
|
||||||
|
sysUserParam.setStatus(siteUserParam.getStatus());
|
||||||
|
sysUserParam.setRealName(siteUserParam.getRealName());
|
||||||
|
sysUserService.edit(uid, sysUserParam);
|
||||||
|
//创建用户站点管理权限
|
||||||
|
const roleIds: string[] = siteUserParam.getRoleIds();
|
||||||
|
const sysUserRoleParam: SysUserRoleParam = new SysUserRoleParam();
|
||||||
|
sysUserRoleParam.setSiteId(RequestUtils.siteId());
|
||||||
|
sysUserRoleParam.setRoleIds(JSONUtil.toJsonStr(roleIds));
|
||||||
|
sysUserRoleParam.setUid(uid);
|
||||||
|
sysUserRoleParam.setStatus(siteUserParam.getStatus());
|
||||||
|
sysUserRoleService.edit(sysUserRoleParam);
|
||||||
|
}catch (Exception e){
|
||||||
|
throw new AdminException(e.getMessage());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* lock
|
* lock
|
||||||
*/
|
*/
|
||||||
async lock(...args: any[]): Promise<any> {
|
async lock(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const sysUser: SysUser = sysUserMapper.selectById(uid);
|
||||||
return null;
|
sysUser.setStatus(StatusEnum.OFF.getStatus());
|
||||||
|
sysUserMapper.updateById(sysUser);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* unlock
|
* unlock
|
||||||
*/
|
*/
|
||||||
async unlock(...args: any[]): Promise<any> {
|
async unlock(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const sysUser: SysUser = sysUserMapper.selectById(uid);
|
||||||
return null;
|
sysUser.setStatus(StatusEnum.ON.getStatus());
|
||||||
|
sysUserMapper.updateById(sysUser);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* delete
|
* delete
|
||||||
*/
|
*/
|
||||||
async delete(...args: any[]): Promise<void> {
|
async delete(...args: any[]): Promise<void> {
|
||||||
// TODO: 实现业务逻辑
|
const sysUserRoleList: SysUserRole[] = sysUserRoleMapper.selectList(new LambdaQueryWrapper<SysUserRole>().eq(SysUserRole::getUid, uid).eq(SysUserRole::getSiteId, RequestUtils.siteId()).last("limit 1"));
|
||||||
return;
|
if (CollectionUtils.isEmpty(sysUserRoleList)){
|
||||||
|
throw new BadRequestException("用户不存在");
|
||||||
|
}
|
||||||
|
const sysUserRole: SysUserRole = sysUserRoleList.get(0);
|
||||||
|
if (sysUserRole.getIsAdmin() == 1){
|
||||||
|
throw new BadRequestException("超级管理员不允许删除");
|
||||||
|
}
|
||||||
|
sysUserMapper.deleteById(uid);
|
||||||
|
loginService.clearToken(uid,null, null);
|
||||||
|
cached.remove("user_role_list_" + uid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,39 +14,136 @@ export class StatHourServiceImplService {
|
|||||||
* list
|
* list
|
||||||
*/
|
*/
|
||||||
async list(...args: any[]): Promise<any[]> {
|
async list(...args: any[]): Promise<any[]> {
|
||||||
// TODO: 实现业务逻辑
|
const page: number = pageParam.getPage();
|
||||||
return [];
|
const limit: number = pageParam.getLimit();
|
||||||
|
|
||||||
|
const queryWrapper: QueryWrapper<StatHour> = new QueryWrapper<>();
|
||||||
|
queryWrapper.orderByDesc("id");
|
||||||
|
|
||||||
|
const iPage: IPage<StatHour> = statHourMapper.selectPage(new Page<>(page, limit), queryWrapper);
|
||||||
|
const list: StatHourListVo[] = [];
|
||||||
|
for (const item of iPage.getRecords()) {
|
||||||
|
const vo: StatHourListVo = new StatHourListVo();
|
||||||
|
BeanUtils.copyProperties(item, vo);
|
||||||
|
list.add(vo);
|
||||||
|
}
|
||||||
|
return PageResult.build(page, limit, iPage.getTotal()).setData(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* info
|
* info
|
||||||
*/
|
*/
|
||||||
async info(...args: any[]): Promise<any> {
|
async info(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const model: StatHour = statHourMapper.selectOne(
|
||||||
return null;
|
new QueryWrapper<StatHour>()
|
||||||
|
.eq("id", id)
|
||||||
|
.last("limit 1"));
|
||||||
|
|
||||||
|
Assert.notNull(model, "数据不存在");
|
||||||
|
|
||||||
|
const vo: StatHourInfoVo = new StatHourInfoVo();
|
||||||
|
BeanUtils.copyProperties(model, vo);
|
||||||
|
return vo;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* add
|
* add
|
||||||
*/
|
*/
|
||||||
async add(...args: any[]): Promise<any> {
|
async add(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const model: StatHour = new StatHour();
|
||||||
return null;
|
model.setSiteId(addParam.getSiteId());
|
||||||
|
model.setAddon(addParam.getAddon());
|
||||||
|
model.setField(addParam.getField());
|
||||||
|
model.setFieldTotal(addParam.getFieldTotal());
|
||||||
|
model.setYear(addParam.getYear());
|
||||||
|
model.setMonth(addParam.getMonth());
|
||||||
|
model.setDay(addParam.getDay());
|
||||||
|
model.setStartTime(System.currentTimeMillis() / 1000);
|
||||||
|
model.setLastTime(addParam.getLastTime());
|
||||||
|
model.setHour0(addParam.getHour0());
|
||||||
|
model.setHour1(addParam.getHour1());
|
||||||
|
model.setHour2(addParam.getHour2());
|
||||||
|
model.setHour3(addParam.getHour3());
|
||||||
|
model.setHour4(addParam.getHour4());
|
||||||
|
model.setHour5(addParam.getHour5());
|
||||||
|
model.setHour6(addParam.getHour6());
|
||||||
|
model.setHour7(addParam.getHour7());
|
||||||
|
model.setHour8(addParam.getHour8());
|
||||||
|
model.setHour9(addParam.getHour9());
|
||||||
|
model.setHour10(addParam.getHour10());
|
||||||
|
model.setHour11(addParam.getHour11());
|
||||||
|
model.setHour12(addParam.getHour12());
|
||||||
|
model.setHour13(addParam.getHour13());
|
||||||
|
model.setHour14(addParam.getHour14());
|
||||||
|
model.setHour15(addParam.getHour15());
|
||||||
|
model.setHour16(addParam.getHour16());
|
||||||
|
model.setHour17(addParam.getHour17());
|
||||||
|
model.setHour18(addParam.getHour18());
|
||||||
|
model.setHour19(addParam.getHour19());
|
||||||
|
model.setHour20(addParam.getHour20());
|
||||||
|
model.setHour21(addParam.getHour21());
|
||||||
|
model.setHour22(addParam.getHour22());
|
||||||
|
model.setHour23(addParam.getHour23());
|
||||||
|
statHourMapper.insert(model);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* edit
|
* edit
|
||||||
*/
|
*/
|
||||||
async edit(...args: any[]): Promise<any> {
|
async edit(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const model: StatHour = statHourMapper.selectOne(
|
||||||
return null;
|
new QueryWrapper<StatHour>()
|
||||||
|
.eq("id", id)
|
||||||
|
.last("limit 1"));
|
||||||
|
|
||||||
|
Assert.notNull(model, "数据不存在!");
|
||||||
|
model.setId(id);
|
||||||
|
model.setSiteId(editParam.getSiteId());
|
||||||
|
model.setAddon(editParam.getAddon());
|
||||||
|
model.setField(editParam.getField());
|
||||||
|
model.setFieldTotal(editParam.getFieldTotal());
|
||||||
|
model.setYear(editParam.getYear());
|
||||||
|
model.setMonth(editParam.getMonth());
|
||||||
|
model.setDay(editParam.getDay());
|
||||||
|
model.setLastTime(editParam.getLastTime());
|
||||||
|
model.setHour0(editParam.getHour0());
|
||||||
|
model.setHour1(editParam.getHour1());
|
||||||
|
model.setHour2(editParam.getHour2());
|
||||||
|
model.setHour3(editParam.getHour3());
|
||||||
|
model.setHour4(editParam.getHour4());
|
||||||
|
model.setHour5(editParam.getHour5());
|
||||||
|
model.setHour6(editParam.getHour6());
|
||||||
|
model.setHour7(editParam.getHour7());
|
||||||
|
model.setHour8(editParam.getHour8());
|
||||||
|
model.setHour9(editParam.getHour9());
|
||||||
|
model.setHour10(editParam.getHour10());
|
||||||
|
model.setHour11(editParam.getHour11());
|
||||||
|
model.setHour12(editParam.getHour12());
|
||||||
|
model.setHour13(editParam.getHour13());
|
||||||
|
model.setHour14(editParam.getHour14());
|
||||||
|
model.setHour15(editParam.getHour15());
|
||||||
|
model.setHour16(editParam.getHour16());
|
||||||
|
model.setHour17(editParam.getHour17());
|
||||||
|
model.setHour18(editParam.getHour18());
|
||||||
|
model.setHour19(editParam.getHour19());
|
||||||
|
model.setHour20(editParam.getHour20());
|
||||||
|
model.setHour21(editParam.getHour21());
|
||||||
|
model.setHour22(editParam.getHour22());
|
||||||
|
model.setHour23(editParam.getHour23());
|
||||||
|
statHourMapper.updateById(model);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* del
|
* del
|
||||||
*/
|
*/
|
||||||
async del(...args: any[]): Promise<any> {
|
async del(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const model: StatHour = statHourMapper.selectOne(
|
||||||
return null;
|
new QueryWrapper<StatHour>()
|
||||||
|
.eq("id", id)
|
||||||
|
.last("limit 1"));
|
||||||
|
|
||||||
|
Assert.notNull(model, "数据不存在!");
|
||||||
|
|
||||||
|
statHourMapper.delete(new QueryWrapper<StatHour>().eq("id", id));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,139 @@ export class StatServiceImplService {
|
|||||||
* getIndexData
|
* getIndexData
|
||||||
*/
|
*/
|
||||||
async getIndexData(...args: any[]): Promise<any> {
|
async getIndexData(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const statInfoVo: StatInfoVo = new StatInfoVo();
|
||||||
return null;
|
String[] createTimes = new String[2];
|
||||||
|
createTimes[0] = DateUtils.currInitDate();
|
||||||
|
createTimes[1] = DateUtils.currDate();
|
||||||
|
/**
|
||||||
|
* 会员统计类
|
||||||
|
*/
|
||||||
|
const statToDayVo: StatToDayVo = new StatToDayVo();
|
||||||
|
//总会员数
|
||||||
|
const totalMemberCount: number = coreMemberService.getMemberCount(new MemberStatSearchParam());
|
||||||
|
statToDayVo.setTotalMemberCount(totalMemberCount);
|
||||||
|
|
||||||
|
//今天注册总会员数
|
||||||
|
const todayMemberParam: MemberStatSearchParam = new MemberStatSearchParam();
|
||||||
|
todayMemberParam.setCreateTime(createTimes);
|
||||||
|
statToDayVo.setTodayMemberCount(coreMemberService.getMemberCount(todayMemberParam));
|
||||||
|
//总站点数
|
||||||
|
statToDayVo.setTotalSiteCount(siteService.getSiteCountByCondition(new SiteSearchParam()));
|
||||||
|
//今日站点数
|
||||||
|
const todaySiteParam: SiteSearchParam = new SiteSearchParam();
|
||||||
|
todaySiteParam.setCreateTime(createTimes);
|
||||||
|
todaySiteParam.setAppType(AppTypeEnum.path.basename(SITE));
|
||||||
|
statToDayVo.setTodaySiteCount(siteService.getSiteCountByCondition(todaySiteParam));
|
||||||
|
//正常站点数
|
||||||
|
const normaSiteParam: SiteSearchParam = new SiteSearchParam();
|
||||||
|
normaSiteParam.setStatus(1);
|
||||||
|
normaSiteParam.setAppType(AppTypeEnum.path.basename(SITE));
|
||||||
|
statToDayVo.setNormaSiteCount(siteService.getSiteCountByCondition(normaSiteParam));
|
||||||
|
//到期站点数
|
||||||
|
const expireSiteParam: SiteSearchParam = new SiteSearchParam();
|
||||||
|
expireSiteParam.setStatus(2);
|
||||||
|
expireSiteParam.setAppType(AppTypeEnum.path.basename(SITE));
|
||||||
|
statToDayVo.setExpireSiteCount(siteService.getSiteCountByCondition(expireSiteParam));
|
||||||
|
//即将到期站点数
|
||||||
|
const weekExpireSiteParam: SiteSearchParam = new SiteSearchParam();
|
||||||
|
String[] expireTimes = new String[2];
|
||||||
|
expireTimes[0] = DateUtils.currDate();
|
||||||
|
expireTimes[1] = DateUtils.getDateAddDay(7);
|
||||||
|
weekExpireSiteParam.setStatus(1);
|
||||||
|
weekExpireSiteParam.setExpireTime(expireTimes);
|
||||||
|
weekExpireSiteParam.setAppType(AppTypeEnum.path.basename(SITE));
|
||||||
|
statToDayVo.setWeekExpireSiteCount(siteService.getSiteCountByCondition(weekExpireSiteParam));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 系统数据类
|
||||||
|
*/
|
||||||
|
const statSystemVo: StatSystemVo = new StatSystemVo();
|
||||||
|
statSystemVo = systemService.getInfo();
|
||||||
|
|
||||||
|
statInfoVo.setTodayData(statToDayVo);
|
||||||
|
statInfoVo.setSystem(statSystemVo);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 站点、会员数据统计数据
|
||||||
|
*/
|
||||||
|
const memberCountVo: StatDateVo = new StatDateVo();
|
||||||
|
const siteCountVo: StatDateVo = new StatDateVo();
|
||||||
|
const dates: string[] = [];
|
||||||
|
const memberValues: number[] = [];
|
||||||
|
const siteValues: number[] = [];
|
||||||
|
const statNum: number = 7;
|
||||||
|
for (const i of number = 0; i <= statNum; i++) {
|
||||||
|
|
||||||
|
const itemDay: string = DateUtils.getDateAddDay(i - statNum);
|
||||||
|
String[] startEndDate = DateUtils.getStartEndByDay(itemDay);
|
||||||
|
|
||||||
|
const itemMemberParam: MemberStatSearchParam = new MemberStatSearchParam();
|
||||||
|
itemMemberParam.setCreateTime(startEndDate);
|
||||||
|
const itemMemberCount: number = coreMemberService.getMemberCount(itemMemberParam);
|
||||||
|
dates.add(startEndDate[0]);
|
||||||
|
memberValues.add(itemMemberCount);
|
||||||
|
const itemSiteParam: SiteSearchParam = new SiteSearchParam();
|
||||||
|
itemSiteParam.setCreateTime(startEndDate);
|
||||||
|
const itemSiteCount: number = siteService.getSiteCountByCondition(itemSiteParam);
|
||||||
|
siteValues.add(itemSiteCount);
|
||||||
|
}
|
||||||
|
memberCountVo.setDate(dates);
|
||||||
|
memberCountVo.setValue(memberValues);
|
||||||
|
siteCountVo.setDate(dates);
|
||||||
|
siteCountVo.setValue(siteValues);
|
||||||
|
|
||||||
|
statInfoVo.setMemberCountStat(memberCountVo);
|
||||||
|
statInfoVo.setSiteStat(siteCountVo);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 会员性别类型统计
|
||||||
|
*/
|
||||||
|
const memberStat: StatTypeVo = new StatTypeVo();
|
||||||
|
const sexlist: string[] = [];
|
||||||
|
sexlist.add(SexEnum.path.basename(MAN));
|
||||||
|
sexlist.add(SexEnum.path.basename(WOMAN));
|
||||||
|
sexlist.add(SexEnum.path.basename(UNKNOWN));
|
||||||
|
|
||||||
|
const sexCountList: number[] = [];
|
||||||
|
const sexMemberParam: MemberStatSearchParam = new MemberStatSearchParam();
|
||||||
|
sexMemberParam.setSex(SexEnum.MAN.getValue());
|
||||||
|
const manSexCount: number = coreMemberService.getMemberCount(sexMemberParam);
|
||||||
|
sexMemberParam.setSex(SexEnum.WOMAN.getValue());
|
||||||
|
const womanSexCount: number = coreMemberService.getMemberCount(sexMemberParam);
|
||||||
|
sexCountList.add(manSexCount);
|
||||||
|
sexCountList.add(womanSexCount);
|
||||||
|
sexCountList.add(totalMemberCount - manSexCount - womanSexCount);
|
||||||
|
memberStat.setType(sexlist);
|
||||||
|
memberStat.setValue(sexCountList);
|
||||||
|
statInfoVo.setMemberStat(memberStat);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 站点分组 统计
|
||||||
|
*/
|
||||||
|
const siteGroupStat: StatTypeVo = new StatTypeVo();
|
||||||
|
const grouplist: string[] = [];
|
||||||
|
const groupCountList: number[] = [];
|
||||||
|
|
||||||
|
const groupList: SiteGroup[] = siteGroupService.getAll();
|
||||||
|
for (const siteGroup of groupList) {
|
||||||
|
grouplist.add(siteGroup.getGroupName());
|
||||||
|
const siteGroupParam: SiteSearchParam = new SiteSearchParam();
|
||||||
|
siteGroupParam.setGroupId(siteGroup.getGroupId());
|
||||||
|
groupCountList.add(siteService.getSiteCountByCondition(siteGroupParam));
|
||||||
|
}
|
||||||
|
siteGroupStat.setType(grouplist);
|
||||||
|
siteGroupStat.setValue(groupCountList);
|
||||||
|
statInfoVo.setSiteGroupStat(siteGroupStat);
|
||||||
|
/**
|
||||||
|
* 所有应用安装统计
|
||||||
|
*/
|
||||||
|
const appVo: StatAppVo = new StatAppVo();
|
||||||
|
const totalAddonCount: number = coreAddonService.getLocalAddonCount();
|
||||||
|
const installAddonCount: number = coreAddonService.getAddonCountByCondition(new CoreAddonSearchParam());
|
||||||
|
appVo.setAppCount(totalAddonCount);
|
||||||
|
appVo.setAppInstalledCount(installAddonCount);
|
||||||
|
appVo.setAppNoInstalledCount(Math.max(totalAddonCount - installAddonCount, 0));
|
||||||
|
statInfoVo.setApp(appVo);
|
||||||
|
return statInfoVo;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,23 +14,33 @@ export class SysAgreementServiceImplService {
|
|||||||
* list
|
* list
|
||||||
*/
|
*/
|
||||||
async list(...args: any[]): Promise<any[]> {
|
async list(...args: any[]): Promise<any[]> {
|
||||||
// TODO: 实现业务逻辑
|
const typeJson: Record<string, any> = AgreementEnum.getType();
|
||||||
return [];
|
const list: SysAgreementListVo[] = [];
|
||||||
|
|
||||||
|
for (Map.Entry<String, Object> map : typeJson.entrySet()) {
|
||||||
|
const vo: SysAgreementListVo = new SysAgreementListVo();
|
||||||
|
const sysAgreement: SysAgreement = coreAgreementService.getAgreement(RequestUtils.siteId(), map.getKey());
|
||||||
|
BeanUtils.copyProperties(sysAgreement, vo);
|
||||||
|
list.add(vo);
|
||||||
|
}
|
||||||
|
|
||||||
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* getAgreement
|
* getAgreement
|
||||||
*/
|
*/
|
||||||
async getAgreement(...args: any[]): Promise<any> {
|
async getAgreement(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const sysAgreement: SysAgreement = coreAgreementService.getAgreement(RequestUtils.siteId(), key);
|
||||||
return null;
|
const vo: SysAgreementInfoVo = new SysAgreementInfoVo();
|
||||||
|
BeanUtils.copyProperties(sysAgreement, vo);
|
||||||
|
return vo;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* setAgreement
|
* setAgreement
|
||||||
*/
|
*/
|
||||||
async setAgreement(...args: any[]): Promise<any> {
|
async setAgreement(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
coreAgreementService.setAgreement(RequestUtils.siteId(), key, title, content);
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,23 +14,30 @@ export class SysAreaServiceImplService {
|
|||||||
* getListByPid
|
* getListByPid
|
||||||
*/
|
*/
|
||||||
async getListByPid(...args: any[]): Promise<any> {
|
async getListByPid(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const queryWrapper: QueryWrapper<SysArea> = new QueryWrapper<>();
|
||||||
return null;
|
queryWrapper.eq("pid", pid);
|
||||||
|
return sysAreaMapper.selectList(queryWrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* getAreaTree
|
* getAreaTree
|
||||||
*/
|
*/
|
||||||
async getAreaTree(...args: any[]): Promise<any> {
|
async getAreaTree(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const queryWrapper: QueryWrapper<SysArea> = new QueryWrapper<>();
|
||||||
return null;
|
queryWrapper.le("level", level);
|
||||||
|
const list: SysArea[] = sysAreaMapper.selectList(queryWrapper);
|
||||||
|
const jsonArray: JSONArray = JSONUtil.parseArray(JSONUtil.toJsonStr(list));
|
||||||
|
return TreeUtils.listToTree(jsonArray, "id", "pid", "child");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* getAreaId
|
* getAreaId
|
||||||
*/
|
*/
|
||||||
async getAreaId(...args: any[]): Promise<any> {
|
async getAreaId(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const areaInfo: SysArea = sysAreaMapper.selectOne(new QueryWrapper<SysArea>().like("name", name).eq("level", level).last("limit 1"));
|
||||||
|
if (areaInfo != null) {
|
||||||
|
return areaInfo.getId();
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -38,7 +45,10 @@ export class SysAreaServiceImplService {
|
|||||||
* getAreaName
|
* getAreaName
|
||||||
*/
|
*/
|
||||||
async getAreaName(...args: any[]): Promise<any> {
|
async getAreaName(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const areaInfo: SysArea = sysAreaMapper.selectOne(new QueryWrapper<SysArea>().eq("id", id).last("limit 1"));
|
||||||
|
if (areaInfo != null) {
|
||||||
|
return path.basename(areaInfo);
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -46,23 +56,39 @@ export class SysAreaServiceImplService {
|
|||||||
* list
|
* list
|
||||||
*/
|
*/
|
||||||
async list(...args: any[]): Promise<any[]> {
|
async list(...args: any[]): Promise<any[]> {
|
||||||
// TODO: 实现业务逻辑
|
const page: number = pageParam.getPage();
|
||||||
return [];
|
const limit: number = pageParam.getLimit();
|
||||||
|
|
||||||
|
const queryWrapper: QueryWrapper<SysArea> = new QueryWrapper<>();
|
||||||
|
queryWrapper.orderByDesc(Arrays.asList("sort", "id"));
|
||||||
|
|
||||||
|
const iPage: IPage<SysArea> = sysAreaMapper.selectPage(new Page<>(page, limit), queryWrapper);
|
||||||
|
const list: SysAreaListVo[] = [];
|
||||||
|
for (const item of iPage.getRecords()) {
|
||||||
|
const vo: SysAreaListVo = new SysAreaListVo();
|
||||||
|
BeanUtils.copyProperties(item, vo);
|
||||||
|
list.add(vo);
|
||||||
|
}
|
||||||
|
return PageResult.build(page, limit, iPage.getTotal()).setData(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* getAddressInfo
|
* getAddressInfo
|
||||||
*/
|
*/
|
||||||
async getAddressInfo(...args: any[]): Promise<any> {
|
async getAddressInfo(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const map: SysMapVo = coreSysConfigService.getMap(RequestUtils.siteId());
|
||||||
return null;
|
const result: string = HttpUtil.get("https://apis.map.qq.com/ws/geocoder/v1/?location="+ location +"&key=" + map.getKey());
|
||||||
|
if (!JSONUtil.isJson(result)) return null;
|
||||||
|
return JSONUtil.parseObj(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* getAddress
|
* getAddress
|
||||||
*/
|
*/
|
||||||
async getAddress(...args: any[]): Promise<any> {
|
async getAddress(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const map: SysMapVo = coreSysConfigService.getMap(RequestUtils.siteId());
|
||||||
return null;
|
const result: string = HttpUtil.get("https://apis.map.qq.com/ws/geocoder/v1/?address="+ address +"&key=" + map.getKey());
|
||||||
|
if (!JSONUtil.isJson(result)) return null;
|
||||||
|
return JSONUtil.parseObj(result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,79 +14,147 @@ export class SysAttachmentServiceImplService {
|
|||||||
* list
|
* list
|
||||||
*/
|
*/
|
||||||
async list(...args: any[]): Promise<any[]> {
|
async list(...args: any[]): Promise<any[]> {
|
||||||
// TODO: 实现业务逻辑
|
const page: number = pageParam.getPage();
|
||||||
return [];
|
const limit: number = pageParam.getLimit();
|
||||||
|
|
||||||
|
const queryWrapper: QueryWrapper<SysAttachment> = new QueryWrapper<>();
|
||||||
|
queryWrapper.eq("site_id", RequestUtils.siteId());
|
||||||
|
queryWrapper.orderByDesc("att_id");
|
||||||
|
if (ObjectUtil.isNotEmpty(searchParam.getAttType())) queryWrapper.eq("att_type", searchParam.getAttType());
|
||||||
|
if (ObjectUtil.isNotEmpty(searchParam.getCateId()) && searchParam.getCateId() > 0) queryWrapper.eq("cate_id", searchParam.getCateId());
|
||||||
|
if (ObjectUtil.isNotEmpty(searchParam.getRealName())) queryWrapper.like("real_name", searchParam.getRealName());
|
||||||
|
|
||||||
|
const iPage: IPage<SysAttachment> = sysAttachmentMapper.selectPage(new Page<>(page, limit), queryWrapper);
|
||||||
|
const list: SysAttachmentListVo[] = [];
|
||||||
|
for (const item of iPage.getRecords()) {
|
||||||
|
const vo: SysAttachmentListVo = new SysAttachmentListVo();
|
||||||
|
BeanUtils.copyProperties(item, vo);
|
||||||
|
vo.setThumb(CommonUtils.thumbImageSmall(item.getSiteId(), item.getPath()));
|
||||||
|
list.add(vo);
|
||||||
|
}
|
||||||
|
return PageResult.build(page, limit, iPage.getTotal()).setData(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* image
|
* image
|
||||||
*/
|
*/
|
||||||
async image(...args: any[]): Promise<any> {
|
async image(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
param.setSiteId(RequestUtils.siteId());
|
||||||
return null;
|
param.setAttType("image");
|
||||||
|
param.setDir("attachment/image/" + param.getSiteId() + "/" + DateFormatUtils.getUploadFormat() + "/");
|
||||||
|
return coreUploadService.upload(param);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* video
|
* video
|
||||||
*/
|
*/
|
||||||
async video(...args: any[]): Promise<any> {
|
async video(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
param.setSiteId(RequestUtils.siteId());
|
||||||
return null;
|
param.setAttType("video");
|
||||||
|
param.setDir("attachment/video/" + param.getSiteId() + "/" + DateFormatUtils.getUploadFormat() + "/");
|
||||||
|
return coreUploadService.upload(param);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* document
|
* document
|
||||||
*/
|
*/
|
||||||
async document(...args: any[]): Promise<any> {
|
async document(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
param.setSiteId(RequestUtils.siteId());
|
||||||
return null;
|
param.setIsAttachment(0);
|
||||||
|
param.setAttType("document");
|
||||||
|
param.setStorageType("local");
|
||||||
|
param.setDir("attachment/document/" + param.getDocumentType() + "/" + param.getSiteId() + "/" + DateFormatUtils.getUploadFormat() + "/");
|
||||||
|
return coreUploadService.upload(param);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* batchMoveCategory
|
* batchMoveCategory
|
||||||
*/
|
*/
|
||||||
async batchMoveCategory(...args: any[]): Promise<any> {
|
async batchMoveCategory(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const model: SysAttachment = new SysAttachment();
|
||||||
return null;
|
model.setCateId(param.getCateId());
|
||||||
|
sysAttachmentMapper.update(model, new QueryWrapper<SysAttachment>()
|
||||||
|
.eq("site_id", RequestUtils.siteId())
|
||||||
|
.in("att_id", param.getAttIds()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* del
|
* del
|
||||||
*/
|
*/
|
||||||
async del(...args: any[]): Promise<any> {
|
async del(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const sysAttachmentList: SysAttachment[] = sysAttachmentMapper.selectList(
|
||||||
return null;
|
new QueryWrapper<SysAttachment>()
|
||||||
|
.eq("site_id", RequestUtils.siteId())
|
||||||
|
.in("att_id", param.getAttIds()));
|
||||||
|
if (sysAttachmentList.length === 0) {
|
||||||
|
throw new BadRequestException("请选择要删除的附件");
|
||||||
|
}
|
||||||
|
for (const sysAttachment of sysAttachmentList) {
|
||||||
|
coreUploadService.delete(sysAttachment.getSiteId(), sysAttachment.getStorageType(), sysAttachment.getPath());
|
||||||
|
}
|
||||||
|
sysAttachmentMapper.delete(new QueryWrapper<SysAttachment>().eq("site_id", RequestUtils.siteId()).in("att_id", param.getAttIds()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* getCategoryList
|
* getCategoryList
|
||||||
*/
|
*/
|
||||||
async getCategoryList(...args: any[]): Promise<any> {
|
async getCategoryList(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const siteId: number = RequestUtils.siteId();
|
||||||
return null;
|
|
||||||
|
const queryWrapper: MPJQueryWrapper<SysAttachmentCategory> = new MPJQueryWrapper<SysAttachmentCategory>();
|
||||||
|
queryWrapper.select("id,name,type").eq("site_id", siteId);
|
||||||
|
if (ObjectUtil.isNotEmpty(path.basename(searchParam))) queryWrapper.like("name", path.basename(searchParam));
|
||||||
|
if (ObjectUtil.isNotEmpty(searchParam.getType())) queryWrapper.eq("type", searchParam.getType());
|
||||||
|
|
||||||
|
const categorys: SysAttachmentCategory[] = sysAttachmentCategoryMapper.selectList(queryWrapper); // 调用 selectList 方法
|
||||||
|
|
||||||
|
const list: SysAttachmentCategoryListVo[] = [];
|
||||||
|
for (const item of categorys) {
|
||||||
|
const vo: SysAttachmentCategoryListVo = new SysAttachmentCategoryListVo();
|
||||||
|
BeanUtils.copyProperties(item, vo);
|
||||||
|
list.add(vo);
|
||||||
|
}
|
||||||
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* addCategory
|
* addCategory
|
||||||
*/
|
*/
|
||||||
async addCategory(...args: any[]): Promise<any> {
|
async addCategory(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
if (ObjectUtil.isEmpty(addParam.getType())) throw new BadRequestException("type参数不能为空");
|
||||||
return null;
|
|
||||||
|
const model: SysAttachmentCategory = new SysAttachmentCategory();
|
||||||
|
model.setSiteId(RequestUtils.siteId());
|
||||||
|
model.setType(addParam.getType());
|
||||||
|
model.setName(path.basename(addParam));
|
||||||
|
sysAttachmentCategoryMapper.insert(model);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* editCategory
|
* editCategory
|
||||||
*/
|
*/
|
||||||
async editCategory(...args: any[]): Promise<any> {
|
async editCategory(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const siteId: number = RequestUtils.siteId();
|
||||||
return null;
|
|
||||||
|
const updateWrapper: UpdateWrapper<SysAttachmentCategory> = new UpdateWrapper<>();
|
||||||
|
updateWrapper.eq("site_id", siteId).eq("id", id);
|
||||||
|
|
||||||
|
const model: SysAttachmentCategory = new SysAttachmentCategory();
|
||||||
|
model.setName(path.basename(editParam));
|
||||||
|
|
||||||
|
sysAttachmentCategoryMapper.update(model, updateWrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* delCategory
|
* delCategory
|
||||||
*/
|
*/
|
||||||
async delCategory(...args: any[]): Promise<any> {
|
async delCategory(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const siteId: number = RequestUtils.siteId();
|
||||||
return null;
|
|
||||||
|
const queryWrapper: QueryWrapper<SysAttachmentCategory> = new QueryWrapper<SysAttachmentCategory>()
|
||||||
|
.eq("site_id", siteId)
|
||||||
|
.eq("id", id);
|
||||||
|
|
||||||
|
sysAttachmentCategoryMapper.delete(queryWrapper);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,151 +14,411 @@ export class SysBackupRecordsServiceImplService {
|
|||||||
* page
|
* page
|
||||||
*/
|
*/
|
||||||
async page(...args: any[]): Promise<any[]> {
|
async page(...args: any[]): Promise<any[]> {
|
||||||
// TODO: 实现业务逻辑
|
const page: number = pageParam.getPage();
|
||||||
return [];
|
const limit: number = pageParam.getLimit();
|
||||||
|
|
||||||
|
const queryWrapper: QueryWrapper<SysBackupRecords> = new QueryWrapper<>();
|
||||||
|
queryWrapper.orderByDesc("create_time");
|
||||||
|
|
||||||
|
if (searchParam != null) {
|
||||||
|
if (searchParam.getContent() != null) {
|
||||||
|
queryWrapper.like("content", searchParam.getContent());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const iPage: IPage<SysBackupRecords> = sysBackupRecordsMapper.selectPage(new Page<>(page, limit), queryWrapper);
|
||||||
|
const list: SysBackupRecordsListVo[] = [];
|
||||||
|
for (const item of iPage.getRecords()) {
|
||||||
|
const vo: SysBackupRecordsListVo = new SysBackupRecordsListVo();
|
||||||
|
BeanUtils.copyProperties(item, vo);
|
||||||
|
vo.setCreateTime(DateUtils.timestampToString(item.getCreateTime()));
|
||||||
|
vo.setCompleteTime(DateUtils.timestampToString(item.getCompleteTime()));
|
||||||
|
vo.setStatusName(BackupRecordStatusEnum.getNameByStatus(vo.getStatus()));
|
||||||
|
vo.setBackupDir("webroot/runtime/upgrade/"+vo.getBackupKey()+"/backup");
|
||||||
|
list.add(vo);
|
||||||
|
}
|
||||||
|
|
||||||
|
return PageResult.build(page, limit, iPage.getTotal()).setData(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* add
|
* add
|
||||||
*/
|
*/
|
||||||
async add(...args: any[]): Promise<any> {
|
async add(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const model: SysBackupRecords = new SysBackupRecords();
|
||||||
return null;
|
BeanUtils.copyProperties(addParam, model);
|
||||||
|
model.setCreateTime(System.currentTimeMillis() / 1000);
|
||||||
|
sysBackupRecordsMapper.insert(model);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* edit
|
* edit
|
||||||
*/
|
*/
|
||||||
async edit(...args: any[]): Promise<any> {
|
async edit(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const model: SysBackupRecords = sysBackupRecordsMapper.selectOne(
|
||||||
return null;
|
new QueryWrapper<SysBackupRecords>()
|
||||||
|
.eq("id", id));
|
||||||
|
Assert.notNull(model, "备份记录不存在");
|
||||||
|
|
||||||
|
BeanUtils.copyProperties(editParam, model);
|
||||||
|
sysBackupRecordsMapper.updateById(model);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* clear
|
* clear
|
||||||
*/
|
*/
|
||||||
async clear(...args: any[]): Promise<any> {
|
async clear(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
sysBackupRecordsMapper.delete(new QueryWrapper<SysBackupRecords>()
|
||||||
return null;
|
.lt("create_time", threshold).in("status", STATUS_READY, STATUS_FAIL));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* del
|
* del
|
||||||
*/
|
*/
|
||||||
async del(...args: any[]): Promise<any> {
|
async del(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const queryWrapper: QueryWrapper = new QueryWrapper<SysUpgradeRecords>();
|
||||||
return null;
|
|
||||||
|
if (delParam.getIds() instanceof ArrayList<?>) {
|
||||||
|
const intArray: number[] = [];
|
||||||
|
((ArrayList<?>) delParam.getIds()).forEach(item => {
|
||||||
|
Assert.notNull(item, "id不能为空");
|
||||||
|
intArray.add(item);
|
||||||
|
});
|
||||||
|
queryWrapper.in("id", intArray);
|
||||||
|
} else {
|
||||||
|
queryWrapper.eq("id", delParam.getIds());
|
||||||
|
}
|
||||||
|
|
||||||
|
const backupRecords: SysBackupRecords[] = sysBackupRecordsMapper.selectList(queryWrapper);
|
||||||
|
if (ObjectUtil.isNotEmpty(backupRecords)) {
|
||||||
|
for (const item of backupRecords) {
|
||||||
|
const file: string = backupDir(item.getBackupKey(), "backup");
|
||||||
|
if (fs.existsSync(file)) {
|
||||||
|
try {
|
||||||
|
FileUtils.deleteDirectory(file);
|
||||||
|
} catch (Exception e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
sysBackupRecordsMapper.delete(queryWrapper);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* restore
|
* restore
|
||||||
*/
|
*/
|
||||||
async restore(...args: any[]): Promise<any> {
|
async restore(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const record: SysBackupRecords = checkDir(restoreParam);
|
||||||
return null;
|
|
||||||
|
const vo: BackupTaskVo = getRestoreTask();
|
||||||
|
if (vo == null) {
|
||||||
|
vo = new BackupTaskVo();
|
||||||
|
LinkedHashMap<String, BackupTaskVo.const steps: Step> = new LinkedHashMap<>();
|
||||||
|
steps.put("startRestore", new BackupTaskVo.Step("startRestore", "开始恢复"));
|
||||||
|
steps.put("backupCode", new BackupTaskVo.Step("backupCode", "备份源码"));
|
||||||
|
steps.put("backupSql", new BackupTaskVo.Step("backupSql", "备份数据库"));
|
||||||
|
steps.put("restoreBackupComplete", new BackupTaskVo.Step("restoreBackupComplete", "备份完成"));
|
||||||
|
steps.put("restoreCode", new BackupTaskVo.Step("restoreCode", "恢复源码备份"));
|
||||||
|
steps.put("restoreSql", new BackupTaskVo.Step("restoreSql", "恢复数据库备份"));
|
||||||
|
steps.put("restoreComplete", new BackupTaskVo.Step("restoreComplete", "恢复完成"));
|
||||||
|
vo.setKey(RandomUtil.randomString(10));
|
||||||
|
vo.setSteps(steps);
|
||||||
|
vo.setStep("startRestore");
|
||||||
|
vo.getExecuted().add("startRestore");
|
||||||
|
vo.setContent("开始恢复");
|
||||||
|
vo.setTask("");
|
||||||
|
|
||||||
|
const addParam: SysBackupRecordsParam = new SysBackupRecordsParam();
|
||||||
|
addParam.setBackupKey(vo.getKey());
|
||||||
|
addParam.setStatus(BackupRecordStatusEnum.STATUS_READY.getStatus());
|
||||||
|
addParam.setContent("自动备份");
|
||||||
|
addParam.setVersion(this.config.get('version'));
|
||||||
|
add(addParam);
|
||||||
|
}
|
||||||
|
vo.setBackupRecord(record);
|
||||||
|
if (!vo.getTask() === "") return vo;
|
||||||
|
|
||||||
|
const steps: string[] = vo.getSteps().keySet().stream().collect(Collectors.toList());
|
||||||
|
const step: string = steps.indexOf(vo.getStep()) < steps.size() - 1 ? steps.get(steps.indexOf(vo.getStep()) + 1) : "";
|
||||||
|
|
||||||
|
if (!step.length === 0) {
|
||||||
|
if (!vo.getExecuted().includes(step)) {
|
||||||
|
vo.getExecuted().add(step);
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
const param: Record<string, any> = null;
|
||||||
|
param = (Map<String, Object>) dynamicMethodCall(step, vo);
|
||||||
|
if (param != null) {
|
||||||
|
vo.setParams(param);
|
||||||
|
} else {
|
||||||
|
vo.setStep(step);
|
||||||
|
vo.setParams(null);
|
||||||
|
}
|
||||||
|
setBackupRestoreTaskCache(vo);
|
||||||
|
} catch (Exception e) {
|
||||||
|
vo.setStep(step);
|
||||||
|
vo.setTask("fail");
|
||||||
|
vo.setContent("备份恢复失败,稍后请手动恢复,备份文件路径:webroot/runtime/upgrade/"+ record.getBackupKey() +"/backup,失败原因:" + e.getMessage());
|
||||||
|
setBackupRestoreTaskCache(vo);
|
||||||
|
// 删除备份记录
|
||||||
|
sysBackupRecordsMapper.delete(new QueryWrapper<SysBackupRecords>().eq("backup_key", vo.getKey()));
|
||||||
|
e.printStackTrace();
|
||||||
|
console.log("恢复异常.");
|
||||||
|
|
||||||
|
sysUpgradeRecordsService.clearRestoreTaskCache(5);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return vo;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* backup
|
* backup
|
||||||
*/
|
*/
|
||||||
async backup(...args: any[]): Promise<any> {
|
async backup(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const vo: BackupTaskVo = getBackupTask();
|
||||||
return null;
|
if (vo == null) {
|
||||||
|
vo = new BackupTaskVo();
|
||||||
|
vo.setKey(RandomUtil.randomString(10));
|
||||||
|
vo.setStep("startBackup");
|
||||||
|
vo.getExecuted().add("startBackup");
|
||||||
|
vo.setContent("开始备份");
|
||||||
|
|
||||||
|
const addParam: SysBackupRecordsParam = new SysBackupRecordsParam();
|
||||||
|
addParam.setBackupKey(vo.getKey());
|
||||||
|
addParam.setStatus(BackupRecordStatusEnum.STATUS_READY.getStatus());
|
||||||
|
addParam.setContent("手动备份");
|
||||||
|
addParam.setVersion(this.config.get('version'));
|
||||||
|
add(addParam);
|
||||||
|
}
|
||||||
|
|
||||||
|
const steps: string[] = vo.getSteps().keySet().stream().collect(Collectors.toList());
|
||||||
|
const step: string = steps.indexOf(vo.getStep()) < steps.size() - 1 ? steps.get(steps.indexOf(vo.getStep()) + 1) : "";
|
||||||
|
|
||||||
|
if (!step.length === 0) {
|
||||||
|
if (!vo.getExecuted().includes(step)) {
|
||||||
|
vo.getExecuted().add(step);
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
const param: Record<string, any> = null;
|
||||||
|
param = (Map<String, Object>) dynamicMethodCall(step, vo);
|
||||||
|
if (param != null) {
|
||||||
|
vo.setParams(param);
|
||||||
|
} else {
|
||||||
|
vo.setStep(step);
|
||||||
|
vo.setParams(null);
|
||||||
|
}
|
||||||
|
setBackupTaskCache(vo);
|
||||||
|
} catch (Exception e) {
|
||||||
|
vo.setStep(step);
|
||||||
|
vo.setTask("fail");
|
||||||
|
vo.setContent("备份失败,稍后请重新手动备份,失败原因:" + e.getMessage());
|
||||||
|
setBackupTaskCache(vo);
|
||||||
|
// 删除备份记录
|
||||||
|
sysBackupRecordsMapper.delete(new QueryWrapper<SysBackupRecords>().eq("backup_key", vo.getKey()));
|
||||||
|
e.printStackTrace();
|
||||||
|
console.log("备份异常.");
|
||||||
|
|
||||||
|
sysUpgradeRecordsService.clearBackupTaskCache(5);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return vo;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* backupComplete
|
* backupComplete
|
||||||
*/
|
*/
|
||||||
async backupComplete(...args: any[]): Promise<any> {
|
async backupComplete(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const backupRecord: SysBackupRecords = new SysBackupRecords();
|
||||||
return null;
|
backupRecord.setStatus(UpgradeRecordStatusEnum.STATUS_COMPLETE.getStatus());
|
||||||
|
backupRecord.setCompleteTime(System.currentTimeMillis() / 1000);
|
||||||
|
sysBackupRecordsMapper.update(backupRecord, new QueryWrapper<SysBackupRecords>().eq("backup_key", vo.getKey()));
|
||||||
|
|
||||||
|
vo.setTask("end");
|
||||||
|
|
||||||
|
sysUpgradeRecordsService.clearBackupTaskCache(5);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* restoreBackupComplete
|
* restoreBackupComplete
|
||||||
*/
|
*/
|
||||||
async restoreBackupComplete(...args: any[]): Promise<any> {
|
async restoreBackupComplete(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const backupRecord: SysBackupRecords = new SysBackupRecords();
|
||||||
return null;
|
backupRecord.setStatus(UpgradeRecordStatusEnum.STATUS_COMPLETE.getStatus());
|
||||||
|
backupRecord.setCompleteTime(System.currentTimeMillis() / 1000);
|
||||||
|
sysBackupRecordsMapper.update(backupRecord, new QueryWrapper<SysBackupRecords>().eq("backup_key", vo.getKey()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* restoreComplete
|
* restoreComplete
|
||||||
*/
|
*/
|
||||||
async restoreComplete(...args: any[]): Promise<any> {
|
async restoreComplete(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
vo.setTask("end");
|
||||||
return null;
|
sysUpgradeRecordsService.clearRestoreTaskCache(5);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* setBackupTaskCache
|
* setBackupTaskCache
|
||||||
*/
|
*/
|
||||||
async setBackupTaskCache(...args: any[]): Promise<any> {
|
async setBackupTaskCache(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const cache: Cached = CacheFactory.getCacheOperator();
|
||||||
return null;
|
cache.put("backup_task", JSONUtil.parseObj(vo).toString(), 1800);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* setBackupRestoreTaskCache
|
* setBackupRestoreTaskCache
|
||||||
*/
|
*/
|
||||||
async setBackupRestoreTaskCache(...args: any[]): Promise<any> {
|
async setBackupRestoreTaskCache(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const cache: Cached = CacheFactory.getCacheOperator();
|
||||||
return null;
|
cache.put("backup_restore_task", JSONUtil.parseObj(vo).toString(), 1800);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* clearBackupTaskCache
|
* clearBackupTaskCache
|
||||||
*/
|
*/
|
||||||
async clearBackupTaskCache(...args: any[]): Promise<any> {
|
async clearBackupTaskCache(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
if (delayed > 0) {
|
||||||
return null;
|
try {
|
||||||
|
Thread.sleep(delayed * 1000);
|
||||||
|
} catch (Exception e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const cache: Cached = CacheFactory.getCacheOperator();
|
||||||
|
cache.remove("backup_task");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* clearRestoreTaskCache
|
* clearRestoreTaskCache
|
||||||
*/
|
*/
|
||||||
async clearRestoreTaskCache(...args: any[]): Promise<any> {
|
async clearRestoreTaskCache(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
if (delayed > 0) {
|
||||||
return null;
|
try {
|
||||||
|
Thread.sleep(delayed * 1000);
|
||||||
|
} catch (Exception e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const cache: Cached = CacheFactory.getCacheOperator();
|
||||||
|
cache.remove("backup_restore_task");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* getBackupTask
|
* getBackupTask
|
||||||
*/
|
*/
|
||||||
async getBackupTask(...args: any[]): Promise<any> {
|
async getBackupTask(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const cache: Cached = CacheFactory.getCacheOperator();
|
||||||
return null;
|
const data: any = cache.get("backup_task");
|
||||||
|
if (data == null) return null;
|
||||||
|
return JSONUtil.toBean(JSONUtil.parseObj(data), BackupTaskVo.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* getRestoreTask
|
* getRestoreTask
|
||||||
*/
|
*/
|
||||||
async getRestoreTask(...args: any[]): Promise<any> {
|
async getRestoreTask(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const cache: Cached = CacheFactory.getCacheOperator();
|
||||||
return null;
|
const data: any = cache.get("backup_restore_task");
|
||||||
|
if (data == null) return null;
|
||||||
|
return JSONUtil.toBean(JSONUtil.parseObj(data), BackupTaskVo.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* checkDir
|
* checkDir
|
||||||
*/
|
*/
|
||||||
async checkDir(...args: any[]): Promise<any> {
|
async checkDir(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const record: SysBackupRecords = sysBackupRecordsMapper.selectById(param.getId());
|
||||||
return null;
|
Assert.notNull(record, "备份记录不存在");
|
||||||
|
if (!record.getStatus() === BackupRecordStatusEnum.STATUS_COMPLETE.getStatus()) throw new Error("备份记录未完成");
|
||||||
|
|
||||||
|
const code: string = this.config.get('webRootDownRuntime' + "upgrade/"+ record.getBackupKey() + "/backup/code");
|
||||||
|
if (!fs.existsSync(code)) throw new Error("未找到备份的源码文件");
|
||||||
|
|
||||||
|
const sql: string = this.config.get('webRootDownRuntime' + "upgrade/"+ record.getBackupKey() + "/backup/sql");
|
||||||
|
if (!fs.existsSync(sql)) throw new Error("未找到备份的数据库文件");
|
||||||
|
|
||||||
|
return record;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* checkPermission
|
* checkPermission
|
||||||
*/
|
*/
|
||||||
async checkPermission(...args: any[]): Promise<any> {
|
async checkPermission(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const upgradeCheck: boolean = true;
|
||||||
return null;
|
|
||||||
|
const checkResult: Record<string, any> = new Record<string, any>();
|
||||||
|
const rootPath: string = "";
|
||||||
|
const runtimePath: string = "";
|
||||||
|
const readableDir: JSONArray = new JSONArray();
|
||||||
|
const writeDir: JSONArray = new JSONArray();
|
||||||
|
|
||||||
|
if (this.config.get('envType') === "dev") {
|
||||||
|
rootPath = this.config.get('projectRoot') + "/";
|
||||||
|
runtimePath = rootPath;
|
||||||
|
|
||||||
|
readableDir.put(new Record<string, any>().set("dir", rootPath + "niucloud-addon").set("status", true));
|
||||||
|
writeDir.put(new Record<string, any>().set("dir", rootPath + "niucloud-addon").set("status", true));
|
||||||
|
readableDir.put(new Record<string, any>().set("dir", rootPath + "webroot").set("status", true));
|
||||||
|
writeDir.put(new Record<string, any>().set("dir", rootPath + "webroot").set("status", true));
|
||||||
|
} else {
|
||||||
|
rootPath = this.config.get('webRoot') + "/";
|
||||||
|
runtimePath = rootPath + "runtime/";
|
||||||
|
|
||||||
|
readableDir.put(new Record<string, any>().set("dir", runtimePath).set("status", true));
|
||||||
|
writeDir.put(new Record<string, any>().set("dir", runtimePath).set("status", true));
|
||||||
|
}
|
||||||
|
|
||||||
|
readableDir.put(new Record<string, any>().set("dir", runtimePath + "admin").set("status", true));
|
||||||
|
readableDir.put(new Record<string, any>().set("dir", runtimePath + "uni-app").set("status", true));
|
||||||
|
readableDir.put(new Record<string, any>().set("dir", runtimePath + "web").set("status", true));
|
||||||
|
|
||||||
|
writeDir.put(new Record<string, any>().set("dir", runtimePath + "admin").set("status", true));
|
||||||
|
writeDir.put(new Record<string, any>().set("dir", runtimePath + "uni-app").set("status", true));
|
||||||
|
writeDir.put(new Record<string, any>().set("dir", runtimePath + "web").set("status", true));
|
||||||
|
|
||||||
|
for (const i of number = 0; i < readableDir.size(); i++) {
|
||||||
|
const dir: Record<string, any> = readableDir.getJSONObject(i);
|
||||||
|
dir.set("status", dir.getStr("dir").canRead());
|
||||||
|
dir.set("dir", dir.getStr("dir").replace(rootPath, ""));
|
||||||
|
readableDir.set(i, dir);
|
||||||
|
if (!dir.getBool("status")) upgradeCheck = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const i of number = 0; i < writeDir.size(); i++) {
|
||||||
|
const dir: Record<string, any> = writeDir.getJSONObject(i);
|
||||||
|
dir.set("status", dir.getStr("dir").canWrite());
|
||||||
|
dir.set("dir", dir.getStr("dir").replace(rootPath, ""));
|
||||||
|
writeDir.set(i, dir);
|
||||||
|
if (!dir.getBool("status")) upgradeCheck = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
checkResult.put("is_pass", upgradeCheck);
|
||||||
|
checkResult.put("dir", new Record<string, any>().set("is_readable", readableDir).set("is_write", writeDir));
|
||||||
|
return checkResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* dynamicMethodCall
|
* dynamicMethodCall
|
||||||
*/
|
*/
|
||||||
async dynamicMethodCall(...args: any[]): Promise<any> {
|
async dynamicMethodCall(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
try {
|
||||||
|
// 获取当前类的 Class 对象
|
||||||
|
Class<?> clazz = this.getClass();
|
||||||
|
// 获取方法对象
|
||||||
|
java.lang.reflect.const method: Method = clazz.getMethod(methodName, extractParameterTypes(args));
|
||||||
|
// 调用方法
|
||||||
|
console.log("dynamicMethodCall method:" + methodName);
|
||||||
|
const result: any = method.invoke(this, args);
|
||||||
|
if (method.getReturnType() == void.class) {
|
||||||
|
return null;
|
||||||
|
} else {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
} catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
|
||||||
|
if (e instanceof InvocationTargetException) {
|
||||||
|
((InvocationTargetException) e).getCause().printStackTrace();
|
||||||
|
throw new BadRequestException(((InvocationTargetException) e).getCause().getMessage());
|
||||||
|
} else {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -14,127 +14,111 @@ export class SysConfigServiceImplService {
|
|||||||
* getWebSite
|
* getWebSite
|
||||||
*/
|
*/
|
||||||
async getWebSite(...args: any[]): Promise<any> {
|
async getWebSite(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
return coreSysConfigService.getWebSite(RequestUtils.siteId());
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* setWebSite
|
* setWebSite
|
||||||
*/
|
*/
|
||||||
async setWebSite(...args: any[]): Promise<any> {
|
async setWebSite(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
coreSysConfigService.setWebSite(RequestUtils.siteId(), configParam);
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* getService
|
* getService
|
||||||
*/
|
*/
|
||||||
async getService(...args: any[]): Promise<any> {
|
async getService(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
return coreSysConfigService.getService(RequestUtils.siteId());
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* getCopyRight
|
* getCopyRight
|
||||||
*/
|
*/
|
||||||
async getCopyRight(...args: any[]): Promise<any> {
|
async getCopyRight(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
return coreSysConfigService.getCopyRight(RequestUtils.siteId());
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* setCopyRight
|
* setCopyRight
|
||||||
*/
|
*/
|
||||||
async setCopyRight(...args: any[]): Promise<any> {
|
async setCopyRight(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
coreSysConfigService.setCopyRight(RequestUtils.siteId(), configParam);
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* getMap
|
* getMap
|
||||||
*/
|
*/
|
||||||
async getMap(...args: any[]): Promise<any> {
|
async getMap(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
return coreSysConfigService.getMap(RequestUtils.siteId());
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* setMap
|
* setMap
|
||||||
*/
|
*/
|
||||||
async setMap(...args: any[]): Promise<any> {
|
async setMap(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
coreSysConfigService.setMap(RequestUtils.siteId(), configParam);
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* getDeveloperToken
|
* getDeveloperToken
|
||||||
*/
|
*/
|
||||||
async getDeveloperToken(...args: any[]): Promise<any> {
|
async getDeveloperToken(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
return coreSysConfigService.getDeveloperToken();
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* setDeveloperToken
|
* setDeveloperToken
|
||||||
*/
|
*/
|
||||||
async setDeveloperToken(...args: any[]): Promise<any> {
|
async setDeveloperToken(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
coreSysConfigService.setDeveloperToken(configParam);
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* getLayout
|
* getLayout
|
||||||
*/
|
*/
|
||||||
async getLayout(...args: any[]): Promise<any> {
|
async getLayout(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
return coreSysConfigService.getLayout(RequestUtils.siteId());
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* setLayout
|
* setLayout
|
||||||
*/
|
*/
|
||||||
async setLayout(...args: any[]): Promise<any> {
|
async setLayout(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
coreSysConfigService.setLayout(RequestUtils.siteId(), configParam);
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* getThemeColor
|
* getThemeColor
|
||||||
*/
|
*/
|
||||||
async getThemeColor(...args: any[]): Promise<any> {
|
async getThemeColor(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
return coreSysConfigService.getThemeColor(RequestUtils.siteId());
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* setThemeColor
|
* setThemeColor
|
||||||
*/
|
*/
|
||||||
async setThemeColor(...args: any[]): Promise<any> {
|
async setThemeColor(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
coreSysConfigService.setThemeColor(RequestUtils.siteId(), configParam);
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* getLogin
|
* getLogin
|
||||||
*/
|
*/
|
||||||
async getLogin(...args: any[]): Promise<any> {
|
async getLogin(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
return coreSysConfigService.getLogin(RequestUtils.siteId());
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* setLogin
|
* setLogin
|
||||||
*/
|
*/
|
||||||
async setLogin(...args: any[]): Promise<any> {
|
async setLogin(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
coreSysConfigService.setLogin(RequestUtils.siteId(), configParam);
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* getUrl
|
* getUrl
|
||||||
*/
|
*/
|
||||||
async getUrl(...args: any[]): Promise<any> {
|
async getUrl(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
return coreSysConfigService.getSceneDomain(RequestUtils.siteId());
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,31 +14,95 @@ export class SysExportServiceImplService {
|
|||||||
* list
|
* list
|
||||||
*/
|
*/
|
||||||
async list(...args: any[]): Promise<any[]> {
|
async list(...args: any[]): Promise<any[]> {
|
||||||
// TODO: 实现业务逻辑
|
const page: number = pageParam.getPage();
|
||||||
return [];
|
const limit: number = pageParam.getLimit();
|
||||||
|
|
||||||
|
const queryWrapper: QueryWrapper<SysExport> = new QueryWrapper<>();
|
||||||
|
queryWrapper.orderByDesc("id");
|
||||||
|
queryWrapper.like("export_key", searchParam.getExportKey());
|
||||||
|
|
||||||
|
if (ObjectUtil.isNotEmpty(searchParam.getExportKey())) {
|
||||||
|
queryWrapper.eq("export_status", searchParam.getExportStatus());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ObjectUtil.isNotEmpty(searchParam.getCreateTime())) {
|
||||||
|
String[] createTime = searchParam.getCreateTime();
|
||||||
|
const startTime: number = (createTime[0] == null) ? 0 : DateUtils.StringToTimestamp(createTime[0]);
|
||||||
|
const endTime: number = (createTime[1] == null) ? 0 : DateUtils.StringToTimestamp(createTime[1]);
|
||||||
|
if (startTime > 0 && endTime > 0) {
|
||||||
|
queryWrapper.between("create_time", startTime, endTime);
|
||||||
|
} else if (startTime > 0 && endTime == 0) {
|
||||||
|
queryWrapper.ge("create_time", startTime);
|
||||||
|
} else if (startTime == 0 && endTime > 0) {
|
||||||
|
queryWrapper.le("create_time", startTime);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const results: JSONArray = JsonModuleLoader.build().mergeResultSet("export/ExportType.json");
|
||||||
|
|
||||||
|
const iPage: IPage<SysExport> = sysExportMapper.selectPage(new Page<>(page, limit), queryWrapper);
|
||||||
|
const converted: IPage<SysExportListVo> = iPage.convert(export => {
|
||||||
|
SysExportListVo vo = new SysExportListVo();
|
||||||
|
BeanUtils.copyProperties(export, vo);
|
||||||
|
vo.setCreateTime(DateUtils.timestampToString(export.getCreateTime()));
|
||||||
|
vo.setExportStatusName(ExportEnum.getNameByCode(export.getExportStatus()));
|
||||||
|
results.stream()
|
||||||
|
.map(JSONUtil::parseObj)
|
||||||
|
.filter(o => o.containsKey(export.getExportKey()))
|
||||||
|
.findFirst()
|
||||||
|
.map(o => o.getJSONObject(export.getExportKey()))
|
||||||
|
.ifPresent(o => vo.setExportKeyName(o.getStr("name")));
|
||||||
|
|
||||||
|
return vo;
|
||||||
|
});
|
||||||
|
|
||||||
|
return PageResult.build(converted);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* del
|
* del
|
||||||
*/
|
*/
|
||||||
async del(...args: any[]): Promise<any> {
|
async del(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const model: SysExport = sysExportMapper.selectOne(
|
||||||
return null;
|
new QueryWrapper<SysExport>()
|
||||||
|
.eq("id", id)
|
||||||
|
.last("limit 1"));
|
||||||
|
|
||||||
|
Assert.notNull(model, "数据不存在!");
|
||||||
|
|
||||||
|
sysExportMapper.delete(new QueryWrapper<SysExport>().eq("id", id));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* checkExportData
|
* checkExportData
|
||||||
*/
|
*/
|
||||||
async checkExportData(...args: any[]): Promise<any> {
|
async checkExportData(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const pageParam: PageParam = new PageParam();
|
||||||
return null;
|
pageParam.setPage(number.parseInt(whereMap.getOrDefault("page", 0).toString()));
|
||||||
|
pageParam.setLimit(number.parseInt(whereMap.getOrDefault("limit", 0).toString()));
|
||||||
|
const jsonArray: JSONArray = coreExportService.getExportData(RequestUtils.siteId(), type, JSONUtil.parseObj(whereMap), pageParam);
|
||||||
|
return !jsonArray.length === 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* exportData
|
* exportData
|
||||||
*/
|
*/
|
||||||
async exportData(...args: any[]): Promise<any> {
|
async exportData(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const siteId: number = RequestUtils.siteId();
|
||||||
return null;
|
const pageParam: PageParam = new PageParam();
|
||||||
|
pageParam.setPage(whereMap.getOrDefault("page", 0));
|
||||||
|
pageParam.setLimit(whereMap.getOrDefault("limit", 0));
|
||||||
|
|
||||||
|
const dataColumn: JSONArray = coreExportService.getExportDataColumn(type);
|
||||||
|
const dataArray: JSONArray = coreExportService.getExportData(siteId, type, JSONUtil.parseObj(whereMap), pageParam);
|
||||||
|
|
||||||
|
const export: SysExport = new SysExport();
|
||||||
|
export.setSiteId(RequestUtils.siteId());
|
||||||
|
export.setExportKey(type);
|
||||||
|
export.setExportNum(CollectionUtil.size(dataArray));
|
||||||
|
export.setCreateTime(System.currentTimeMillis() / 1000);
|
||||||
|
coreExportService.add(export);
|
||||||
|
|
||||||
|
coreExportService.export(siteId, export.getId(), type, dataColumn, dataArray);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,103 +14,309 @@ export class SysMenuServiceImplService {
|
|||||||
* info
|
* info
|
||||||
*/
|
*/
|
||||||
async info(...args: any[]): Promise<any> {
|
async info(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const model: SysMenu = sysMenuMapper.selectOne(
|
||||||
return null;
|
new QueryWrapper<SysMenu>()
|
||||||
|
.eq("id", id)
|
||||||
|
.last("limit 1"));
|
||||||
|
|
||||||
|
Assert.notNull(model, "数据不存在");
|
||||||
|
|
||||||
|
const vo: SysMenuInfoVo = new SysMenuInfoVo();
|
||||||
|
BeanUtils.copyProperties(model, vo);
|
||||||
|
return vo;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get
|
* get
|
||||||
*/
|
*/
|
||||||
async get(...args: any[]): Promise<any> {
|
async get(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const queryWrapper: QueryWrapper<SysMenu> = new QueryWrapper<>();
|
||||||
return null;
|
queryWrapper.eq("app_type", appType);
|
||||||
|
queryWrapper.eq("menu_key", menuKey);
|
||||||
|
const sysMenu: SysMenu = sysMenuMapper.selectOne(queryWrapper);
|
||||||
|
Assert.notNull(sysMenu, "菜单数据不存在");
|
||||||
|
const sysMenuInfoVo: SysMenuInfoVo = new SysMenuInfoVo();
|
||||||
|
BeanUtil.copyProperties(sysMenu, sysMenuInfoVo);
|
||||||
|
return sysMenuInfoVo;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* add
|
* add
|
||||||
*/
|
*/
|
||||||
async add(...args: any[]): Promise<any> {
|
async add(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const sysMenu: SysMenu = this.find(addParam.getMenuKey(), addParam.getAppType());
|
||||||
return null;
|
if(ObjectUtil.isNotNull(sysMenu)){
|
||||||
|
throw new AdminException("validate_menu.exit_menu_key");
|
||||||
|
}
|
||||||
|
|
||||||
|
const model: SysMenu = new SysMenu();
|
||||||
|
BeanUtil.copyProperties(addParam, model);
|
||||||
|
model.setCreateTime(DateUtils.currTime());
|
||||||
|
model.setSource(MenuSourceEnum.CREATE.getCode());
|
||||||
|
sysMenuMapper.insert(model);
|
||||||
|
/** 清理缓存 */
|
||||||
|
cached.tag(cacheTagName).clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* edit
|
* edit
|
||||||
*/
|
*/
|
||||||
async edit(...args: any[]): Promise<any> {
|
async edit(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const model: SysMenu = sysMenuMapper.selectOne(
|
||||||
return null;
|
new QueryWrapper<SysMenu>()
|
||||||
|
.eq("app_type", appType)
|
||||||
|
.eq("menu_key", menuKey)
|
||||||
|
.last("limit 1"));
|
||||||
|
Assert.notNull(model, "数据不存在!");
|
||||||
|
BeanUtil.copyProperties(editParam, model);
|
||||||
|
sysMenuMapper.updateById(model);
|
||||||
|
/** 清理缓存 */
|
||||||
|
cached.tag(cacheTagName).clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* del
|
* del
|
||||||
*/
|
*/
|
||||||
async del(...args: any[]): Promise<any> {
|
async del(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const keyCount: number = sysMenuMapper.selectCount(new QueryWrapper<SysMenu>().eq("parent_key", menuKey).eq("app_type", appType));
|
||||||
return null;
|
if(keyCount>0){
|
||||||
|
throw new AdminException("MENU_NOT_ALLOW_DELETE");
|
||||||
|
}
|
||||||
|
sysMenuMapper.delete(new QueryWrapper<SysMenu>().eq("app_type", appType).eq("menu_key", menuKey));
|
||||||
|
/** 清理缓存 */
|
||||||
|
cached.tag(cacheTagName).clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* menuTree
|
* menuTree
|
||||||
*/
|
*/
|
||||||
async menuTree(...args: any[]): Promise<any> {
|
async menuTree(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
return cached.rememberObject(useCache, cacheTagName, Arrays.asList("menuTree"), uniqueKey => {
|
||||||
return null;
|
|
||||||
|
const queryWrapper: QueryWrapper<SysMenu> = new QueryWrapper<>();
|
||||||
|
queryWrapper.eq("app_type", "site");
|
||||||
|
queryWrapper.orderByDesc(Arrays.asList("sort", "id"));
|
||||||
|
const sysMenuList: SysMenu[] = sysMenuMapper.selectList(queryWrapper);
|
||||||
|
const jsonArray: JSONArray = JSONUtil.parseArray(JacksonUtils.toSnakeCaseJSONString(sysMenuList));
|
||||||
|
return TreeUtils.listToTree(jsonArray, "menu_key", "parent_key", "children");
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* getMenuListByCondition
|
* getMenuListByCondition
|
||||||
*/
|
*/
|
||||||
async getMenuListByCondition(...args: any[]): Promise<any> {
|
async getMenuListByCondition(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
return cached.remember(useCache, cacheTagName, Arrays.asList("getMenuListByCondition", appType, siteId, status, isButton, menuKeys, addon), uniqueKey => {
|
||||||
return null;
|
const addonList: string[] = coreSiteService.getAddonKeysBySiteId(siteId);
|
||||||
|
const queryWrapper: QueryWrapper<SysMenu> = new QueryWrapper<>();
|
||||||
|
if (ObjectUtil.isNotEmpty(appType)) {
|
||||||
|
queryWrapper.eq("app_type", appType);
|
||||||
|
}
|
||||||
|
if (addonList.size() > 0) {
|
||||||
|
addonList.add("");
|
||||||
|
queryWrapper.in("addon", addonList);
|
||||||
|
} else {
|
||||||
|
queryWrapper.in("addon", "");
|
||||||
|
}
|
||||||
|
if (status != 100) {
|
||||||
|
queryWrapper.eq("status", status);
|
||||||
|
}
|
||||||
|
if (menuKeys.size() > 0) {
|
||||||
|
queryWrapper.in("menu_key", menuKeys);
|
||||||
|
}
|
||||||
|
if (isButton == 0) {
|
||||||
|
queryWrapper.ne("menu_type", 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
//排除菜单 后期处理
|
||||||
|
|
||||||
|
const menuList: SysMenu[] = sysMenuMapper.selectList(queryWrapper);
|
||||||
|
return menuList;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* getMenuListByKeys
|
* getMenuListByKeys
|
||||||
*/
|
*/
|
||||||
async getMenuListByKeys(...args: any[]): Promise<any> {
|
async getMenuListByKeys(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const menuKeysVal: string = String.join("_", menuKeys);
|
||||||
return null;
|
const menuKeysValMD5: string = SecureUtil.md5(menuKeysVal);
|
||||||
|
const menuCatch: string = "menu" + menuKeysValMD5 + isTree.toString() + addon + siteId;
|
||||||
|
const outterMenuList: SysMenu[] = cached.cache(useCache, cacheTagName, menuCatch, uniqueKey => {
|
||||||
|
//通过站点id获取支持的应用插件
|
||||||
|
List<String> addonList = coreSiteService.getAddonKeysBySiteId(siteId);
|
||||||
|
|
||||||
|
//组装查询条件
|
||||||
|
const queryWrapper: QueryWrapper<SysMenu> = new QueryWrapper<>();
|
||||||
|
if (menuKeys.size() > 0) {
|
||||||
|
queryWrapper.in("menu_key", menuKeys);
|
||||||
|
}
|
||||||
|
const paichuList: SysMenu[] = null;
|
||||||
|
if(!addon === "all"){
|
||||||
|
queryWrapper.eq("addon",addon);
|
||||||
|
|
||||||
|
const jsonModuleLoader: JsonModuleLoader = new JsonModuleLoader();
|
||||||
|
const jsonObject: Record<string, any> = jsonModuleLoader.getResultElement(addon, "menu/site.json");
|
||||||
|
const delJsonInfo: JSONArray = jsonObject.getJSONArray("delete");
|
||||||
|
paichuList = JSONUtil.toList(delJsonInfo,SysMenu.class);
|
||||||
|
}else{
|
||||||
|
queryWrapper.in("addon", addonList);
|
||||||
|
for (const i of number = 0; i<addonList.size(); i++){
|
||||||
|
const jsonModuleLoader: JsonModuleLoader = new JsonModuleLoader();
|
||||||
|
const jsonObject: Record<string, any> = jsonModuleLoader.getResultElement(addonList.get(i), "menu/site.json");
|
||||||
|
const delJsonInfo: JSONArray = jsonObject.getJSONArray("delete");
|
||||||
|
paichuList = JSONUtil.toList(delJsonInfo,SysMenu.class);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (ObjectUtil.isNotEmpty(appType)) {
|
||||||
|
queryWrapper.eq("app_type", appType);
|
||||||
|
}
|
||||||
|
|
||||||
|
//排除菜单
|
||||||
|
if(ObjectUtil.isNotNull(paichuList) && paichuList.size()>0){
|
||||||
|
const paichuArr: string[] = [];
|
||||||
|
for (const i of number = 0; i<paichuList.size(); i++){
|
||||||
|
paichuArr.add(paichuList.get(i).getMenuKey());
|
||||||
|
}
|
||||||
|
queryWrapper.notIn("menu_key", paichuArr);
|
||||||
|
}
|
||||||
|
|
||||||
|
const menuList: SysMenu[] = sysMenuMapper.selectList(queryWrapper);
|
||||||
|
for (const menu of menuList) {
|
||||||
|
const langMenuKey: string = "dict_menu_" + menu.getAppType() + "." + menu.getMenuKey();
|
||||||
|
const langMenuName: string = LanguageUtils.get(langMenuKey);
|
||||||
|
|
||||||
|
if (!langMenuKey === langMenuName) {
|
||||||
|
menu.setMenuName(langMenuName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return menuList;
|
||||||
|
});
|
||||||
|
return outterMenuList;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* getAllMenuList
|
* getAllMenuList
|
||||||
*/
|
*/
|
||||||
async getAllMenuList(...args: any[]): Promise<any> {
|
async getAllMenuList(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
//站点const siteId: id
|
||||||
return null;
|
number = RequestUtils.siteId();
|
||||||
|
|
||||||
|
// 缓存Key值计算参数
|
||||||
|
const key: string = "menuList_"+appType+"_"+status + siteId.toString();
|
||||||
|
|
||||||
|
const outterMenuList: SysMenu[] = cached.cache(useCache, cacheTagName, key, uniqueKey => {
|
||||||
|
List<SysMenu> menuList = [];
|
||||||
|
try {
|
||||||
|
const queryWrapper: QueryWrapper<SysMenu> = new QueryWrapper<>();
|
||||||
|
if (ObjectUtil.isNotEmpty(appType)) {
|
||||||
|
queryWrapper.eq("app_type", appType);
|
||||||
|
}
|
||||||
|
|
||||||
|
//站点相关插件
|
||||||
|
if (!RequestUtils.defaultSiteId() === siteId) {
|
||||||
|
const addonList: string[] = coreSiteService.getAddonKeysBySiteId(siteId);
|
||||||
|
|
||||||
|
if (addonList.size() > 0) {
|
||||||
|
addonList.add("");
|
||||||
|
queryWrapper.in("addon", addonList);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (status != 100) {
|
||||||
|
queryWrapper.eq("status", status);
|
||||||
|
}
|
||||||
|
//排除菜单
|
||||||
|
menuList = sysMenuMapper.selectList(queryWrapper);
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new BaseException("查询菜单错误");
|
||||||
|
}
|
||||||
|
return menuList;
|
||||||
|
});
|
||||||
|
|
||||||
|
const jsonArray: JSONArray = JSONUtil.parseArray(JacksonUtils.toSnakeCaseJSONString(outterMenuList));
|
||||||
|
return TreeUtils.listToTree(jsonArray, "menu_key", "parent_key", "children");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* find
|
* find
|
||||||
*/
|
*/
|
||||||
async find(...args: any[]): Promise<any> {
|
async find(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const queryWrapper: QueryWrapper<SysMenu> = new QueryWrapper<>();
|
||||||
return null;
|
if(ObjectUtil.isNotNull(menuKey) && ObjectUtil.isNotEmpty(menuKey)){
|
||||||
|
queryWrapper.eq("menu_key", menuKey);
|
||||||
|
}
|
||||||
|
if(ObjectUtil.isNotNull(appType) && ObjectUtil.isNotEmpty(appType)){
|
||||||
|
queryWrapper.eq("app_type", appType);
|
||||||
|
}
|
||||||
|
const sysMenu: SysMenu = sysMenuMapper.selectOne(queryWrapper);
|
||||||
|
return sysMenu;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* getMenuByTypeDir
|
* getMenuByTypeDir
|
||||||
*/
|
*/
|
||||||
async getMenuByTypeDir(...args: any[]): Promise<any> {
|
async getMenuByTypeDir(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const outterMenuList: SysMenu[] = cached.remember(useCache, cacheTagName, Arrays.asList("getMenuByTypeDir", addon), uniqueKey => {
|
||||||
return null;
|
QueryWrapper<SysMenu> queryWrapper = new QueryWrapper<>();
|
||||||
|
queryWrapper.eq("app_type", "site");
|
||||||
|
queryWrapper.eq("menu_type", "0");
|
||||||
|
queryWrapper.eq("addon", addon === "system"? "": addon);
|
||||||
|
queryWrapper.orderByDesc("sort");
|
||||||
|
return sysMenuMapper.selectList(queryWrapper);
|
||||||
|
});
|
||||||
|
|
||||||
|
//暂无多语言设计
|
||||||
|
const jsonArray: JSONArray = JSONUtil.parseArray(JacksonUtils.toSnakeCaseJSONString(outterMenuList));
|
||||||
|
return TreeUtils.listToTree(jsonArray, "menu_key", "parent_key", "children");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* getAddonMenu
|
* getAddonMenu
|
||||||
*/
|
*/
|
||||||
async getAddonMenu(...args: any[]): Promise<any> {
|
async getAddonMenu(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
return cached.rememberObject(useCache, cacheTagName, Arrays.asList("getAddonMenu", appKey, status, isTree.toString(), isButton.toString()), uniqueKey => {
|
||||||
return null;
|
|
||||||
|
const queryWrapper: QueryWrapper<SysMenu> = new QueryWrapper<>();
|
||||||
|
queryWrapper.eq("app_type", "site");
|
||||||
|
queryWrapper.eq("addon", appKey);
|
||||||
|
queryWrapper.orderByDesc(Arrays.asList("sort", "id"));
|
||||||
|
if (!status === "all") {
|
||||||
|
queryWrapper.eq("status", status);
|
||||||
|
}
|
||||||
|
if (isButton == 0) {
|
||||||
|
queryWrapper.in("menu_type", new number[]{0, 1});
|
||||||
|
}
|
||||||
|
const sysMenuList: SysMenu[] = sysMenuMapper.selectList(queryWrapper);
|
||||||
|
const jsonArray: JSONArray = JSONUtil.parseArray(JacksonUtils.toSnakeCaseJSONString(sysMenuList));
|
||||||
|
if (isTree == 0) {
|
||||||
|
return jsonArray;
|
||||||
|
}
|
||||||
|
return TreeUtils.listToTree(jsonArray, "menu_key", "parent_key", "children");
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* getSystemMenu
|
* getSystemMenu
|
||||||
*/
|
*/
|
||||||
async getSystemMenu(...args: any[]): Promise<any> {
|
async getSystemMenu(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
return cached.rememberObject(useCache, cacheTagName, Arrays.asList("getSystemMenu", status, isTree.toString(), isButton.toString()), uniqueKey => {
|
||||||
return null;
|
const queryWrapper: QueryWrapper<SysMenu> = new QueryWrapper<>();
|
||||||
|
queryWrapper.eq("app_type", "site");
|
||||||
|
queryWrapper.eq("addon", "");
|
||||||
|
queryWrapper.orderByDesc(Arrays.asList("sort", "id"));
|
||||||
|
if (!status === "all") {
|
||||||
|
queryWrapper.eq("status", status);
|
||||||
|
}
|
||||||
|
if (isButton == 0) {
|
||||||
|
queryWrapper.in("menu_type", new number[]{0, 1});
|
||||||
|
}
|
||||||
|
const sysMenuList: SysMenu[] = sysMenuMapper.selectList(queryWrapper);
|
||||||
|
const jsonArray: JSONArray = JSONUtil.parseArray(JacksonUtils.toSnakeCaseJSONString(sysMenuList));
|
||||||
|
if (isTree == 0) {
|
||||||
|
return jsonArray;
|
||||||
|
}
|
||||||
|
return TreeUtils.listToTree(jsonArray, "menu_key", "parent_key", "children");
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,15 +14,43 @@ export class SysNoticeLogServiceImplService {
|
|||||||
* list
|
* list
|
||||||
*/
|
*/
|
||||||
async list(...args: any[]): Promise<any[]> {
|
async list(...args: any[]): Promise<any[]> {
|
||||||
// TODO: 实现业务逻辑
|
const page: number = pageParam.getPage();
|
||||||
return [];
|
const limit: number = pageParam.getLimit();
|
||||||
|
|
||||||
|
const queryWrapper: QueryWrapper<SysNoticeLog> = new QueryWrapper<>();
|
||||||
|
queryWrapper.eq("site_id", RequestUtils.siteId());
|
||||||
|
if (ObjectUtil.isNotEmpty(searchParam.getReceiver())) queryWrapper.eq("receiver", searchParam.getReceiver());
|
||||||
|
if (ObjectUtil.isNotEmpty(searchParam.getKey())) queryWrapper.eq("`key`", searchParam.getKey());
|
||||||
|
if (ObjectUtil.isNotEmpty(searchParam.getCreateTime())) QueryMapperUtils.buildByTime(queryWrapper, "create_time", searchParam.getCreateTime());
|
||||||
|
queryWrapper.orderByDesc("id");
|
||||||
|
|
||||||
|
const noticeEnum: Record<string, any> = NoticeEnum.getNotice();
|
||||||
|
|
||||||
|
const iPage: IPage<SysNoticeLog> = sysNoticeLogMapper.selectPage(new Page<>(page, limit), queryWrapper);
|
||||||
|
const list: SysNoticeLogListVo[] = [];
|
||||||
|
for (const item of iPage.getRecords()) {
|
||||||
|
const vo: SysNoticeLogListVo = new SysNoticeLogListVo();
|
||||||
|
BeanUtils.copyProperties(item, vo);
|
||||||
|
vo.setName(noticeEnum.get(item.getKey()) != null ? noticeEnum.get(item.getKey()).getName() : "");
|
||||||
|
list.add(vo);
|
||||||
|
}
|
||||||
|
return PageResult.build(page, limit, iPage.getTotal()).setData(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* info
|
* info
|
||||||
*/
|
*/
|
||||||
async info(...args: any[]): Promise<any> {
|
async info(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const model: SysNoticeLog = sysNoticeLogMapper.selectOne(
|
||||||
return null;
|
new QueryWrapper<SysNoticeLog>()
|
||||||
|
.eq("id", id)
|
||||||
|
.eq("site_id", RequestUtils.siteId())
|
||||||
|
.last("limit 1"));
|
||||||
|
|
||||||
|
Assert.notNull(model, "数据不存在");
|
||||||
|
|
||||||
|
const vo: SysNoticeLogInfoVo = new SysNoticeLogInfoVo();
|
||||||
|
BeanUtils.copyProperties(model, vo);
|
||||||
|
return vo;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,39 +14,94 @@ export class SysNoticeServiceImplService {
|
|||||||
* list
|
* list
|
||||||
*/
|
*/
|
||||||
async list(...args: any[]): Promise<any[]> {
|
async list(...args: any[]): Promise<any[]> {
|
||||||
// TODO: 实现业务逻辑
|
const page: number = pageParam.getPage();
|
||||||
return [];
|
const limit: number = pageParam.getLimit();
|
||||||
|
|
||||||
|
const queryWrapper: QueryWrapper<SysNotice> = new QueryWrapper<>();
|
||||||
|
queryWrapper.orderByDesc("id");
|
||||||
|
|
||||||
|
const iPage: IPage<SysNotice> = sysNoticeMapper.selectPage(new Page<>(page, limit), queryWrapper);
|
||||||
|
const list: SysNoticeListVo[] = [];
|
||||||
|
for (const item of iPage.getRecords()) {
|
||||||
|
const vo: SysNoticeListVo = new SysNoticeListVo();
|
||||||
|
BeanUtils.copyProperties(item, vo);
|
||||||
|
list.add(vo);
|
||||||
|
}
|
||||||
|
return PageResult.build(page, limit, iPage.getTotal()).setData(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* info
|
* info
|
||||||
*/
|
*/
|
||||||
async info(...args: any[]): Promise<any> {
|
async info(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const model: SysNotice = sysNoticeMapper.selectOne(
|
||||||
return null;
|
new QueryWrapper<SysNotice>()
|
||||||
|
.eq("id", id)
|
||||||
|
.last("limit 1"));
|
||||||
|
|
||||||
|
Assert.notNull(model, "数据不存在");
|
||||||
|
|
||||||
|
const vo: SysNoticeInfoVo = new SysNoticeInfoVo();
|
||||||
|
BeanUtils.copyProperties(model, vo);
|
||||||
|
return vo;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* add
|
* add
|
||||||
*/
|
*/
|
||||||
async add(...args: any[]): Promise<any> {
|
async add(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const model: SysNotice = new SysNotice();
|
||||||
return null;
|
model.setSiteId(addParam.getSiteId());
|
||||||
|
model.setKey(addParam.getKey());
|
||||||
|
model.setSmsContent(addParam.getSmsContent());
|
||||||
|
model.setIsWechat(addParam.getIsWechat());
|
||||||
|
model.setIsWeapp(addParam.getIsWeapp());
|
||||||
|
model.setIsSms(addParam.getIsSms());
|
||||||
|
model.setWechatTemplateId(addParam.getWechatTemplateId());
|
||||||
|
model.setWeappTemplateId(addParam.getWeappTemplateId());
|
||||||
|
model.setSmsId(addParam.getSmsId());
|
||||||
|
model.setCreateTime(System.currentTimeMillis() / 1000);
|
||||||
|
model.setWechatFirst(addParam.getWechatFirst());
|
||||||
|
model.setWechatRemark(addParam.getWechatRemark());
|
||||||
|
sysNoticeMapper.insert(model);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* edit
|
* edit
|
||||||
*/
|
*/
|
||||||
async edit(...args: any[]): Promise<any> {
|
async edit(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const model: SysNotice = sysNoticeMapper.selectOne(
|
||||||
return null;
|
new QueryWrapper<SysNotice>()
|
||||||
|
.eq("id", id)
|
||||||
|
.last("limit 1"));
|
||||||
|
|
||||||
|
Assert.notNull(model, "数据不存在!");
|
||||||
|
model.setId(id);
|
||||||
|
model.setSiteId(editParam.getSiteId());
|
||||||
|
model.setKey(editParam.getKey());
|
||||||
|
model.setSmsContent(editParam.getSmsContent());
|
||||||
|
model.setIsWechat(editParam.getIsWechat());
|
||||||
|
model.setIsWeapp(editParam.getIsWeapp());
|
||||||
|
model.setIsSms(editParam.getIsSms());
|
||||||
|
model.setWechatTemplateId(editParam.getWechatTemplateId());
|
||||||
|
model.setWeappTemplateId(editParam.getWeappTemplateId());
|
||||||
|
model.setSmsId(editParam.getSmsId());
|
||||||
|
model.setWechatFirst(editParam.getWechatFirst());
|
||||||
|
model.setWechatRemark(editParam.getWechatRemark());
|
||||||
|
sysNoticeMapper.updateById(model);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* del
|
* del
|
||||||
*/
|
*/
|
||||||
async del(...args: any[]): Promise<any> {
|
async del(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const model: SysNotice = sysNoticeMapper.selectOne(
|
||||||
return null;
|
new QueryWrapper<SysNotice>()
|
||||||
|
.eq("id", id)
|
||||||
|
.last("limit 1"));
|
||||||
|
|
||||||
|
Assert.notNull(model, "数据不存在!");
|
||||||
|
|
||||||
|
sysNoticeMapper.delete(new QueryWrapper<SysNotice>().eq("id", id));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,15 +14,46 @@ export class SysNoticeSmsLogServiceImplService {
|
|||||||
* list
|
* list
|
||||||
*/
|
*/
|
||||||
async list(...args: any[]): Promise<any[]> {
|
async list(...args: any[]): Promise<any[]> {
|
||||||
// TODO: 实现业务逻辑
|
const page: number = pageParam.getPage();
|
||||||
return [];
|
const limit: number = pageParam.getLimit();
|
||||||
|
|
||||||
|
const queryWrapper: QueryWrapper<SysNoticeSmsLog> = new QueryWrapper<>();
|
||||||
|
queryWrapper.eq("site_id", RequestUtils.siteId());
|
||||||
|
if (ObjectUtil.isNotEmpty(searchParam.getKey())) queryWrapper.eq("`key`", searchParam.getKey());
|
||||||
|
if (ObjectUtil.isNotEmpty(searchParam.getSmsType())) queryWrapper.eq("sms_type", searchParam.getSmsType());
|
||||||
|
if (ObjectUtil.isNotEmpty(searchParam.getMobile())) queryWrapper.eq("mobile", searchParam.getMobile());
|
||||||
|
if (ObjectUtil.isNotEmpty(searchParam.getCreateTime())) QueryMapperUtils.buildByTime(queryWrapper,"create_time" ,searchParam.getCreateTime());
|
||||||
|
queryWrapper.orderByDesc("id");
|
||||||
|
|
||||||
|
const smsTypeEnum: Record<string, any> = SmsTypeEnum.getType();
|
||||||
|
const notice: Record<string, any> = NoticeEnum.getNotice();
|
||||||
|
|
||||||
|
const iPage: IPage<SysNoticeSmsLog> = sysNoticeSmsLogMapper.selectPage(new Page<>(page, limit), queryWrapper);
|
||||||
|
const list: SysNoticeSmsLogListVo[] = [];
|
||||||
|
for (const item of iPage.getRecords()) {
|
||||||
|
const vo: SysNoticeSmsLogListVo = new SysNoticeSmsLogListVo();
|
||||||
|
BeanUtils.copyProperties(item, vo);
|
||||||
|
vo.setSmsTypeName(smsTypeEnum.getByPath(item.getSmsType() + ".name", String.class));
|
||||||
|
vo.setName(ObjectUtil.defaultIfNull(notice.get(item.getKey()).getName(), ""));
|
||||||
|
list.add(vo);
|
||||||
|
}
|
||||||
|
return PageResult.build(page, limit, iPage.getTotal()).setData(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* info
|
* info
|
||||||
*/
|
*/
|
||||||
async info(...args: any[]): Promise<any> {
|
async info(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const model: SysNoticeSmsLog = sysNoticeSmsLogMapper.selectOne(
|
||||||
return null;
|
new QueryWrapper<SysNoticeSmsLog>()
|
||||||
|
.eq("id", id)
|
||||||
|
.eq("site_id", RequestUtils.siteId())
|
||||||
|
.last("limit 1"));
|
||||||
|
if (model == null) return null;
|
||||||
|
|
||||||
|
const vo: SysNoticeSmsLogInfoVo = new SysNoticeSmsLogInfoVo();
|
||||||
|
BeanUtils.copyProperties(model, vo);
|
||||||
|
|
||||||
|
return vo;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,87 +14,211 @@ export class SysPosterServiceImplService {
|
|||||||
* page
|
* page
|
||||||
*/
|
*/
|
||||||
async page(...args: any[]): Promise<any[]> {
|
async page(...args: any[]): Promise<any[]> {
|
||||||
// TODO: 实现业务逻辑
|
const page: number = pageParam.getPage();
|
||||||
return [];
|
const limit: number = pageParam.getLimit();
|
||||||
|
|
||||||
|
const queryWrapper: QueryWrapper<SysPoster> = new QueryWrapper<>();
|
||||||
|
queryWrapper.eq("site_id", RequestUtils.siteId());
|
||||||
|
queryWrapper.orderByDesc("id");
|
||||||
|
|
||||||
|
if (ObjectUtil.isNotEmpty(path.basename(searchParam))) queryWrapper.like("name", path.basename(searchParam));
|
||||||
|
if (ObjectUtil.isNotEmpty(searchParam.getType())) queryWrapper.eq("type", searchParam.getType());
|
||||||
|
|
||||||
|
const iPage: IPage<SysPoster> = sysPosterMapper.selectPage(new Page<>(page, limit), queryWrapper);
|
||||||
|
const list: SysPosterListVo[] = [];
|
||||||
|
for (const item of iPage.getRecords()) {
|
||||||
|
const vo: SysPosterListVo = new SysPosterListVo();
|
||||||
|
BeanUtils.copyProperties(item, vo);
|
||||||
|
list.add(vo);
|
||||||
|
}
|
||||||
|
return PageResult.build(page, limit, iPage.getTotal()).setData(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* list
|
* list
|
||||||
*/
|
*/
|
||||||
async list(...args: any[]): Promise<any[]> {
|
async list(...args: any[]): Promise<any[]> {
|
||||||
// TODO: 实现业务逻辑
|
const queryWrapper: QueryWrapper<SysPoster> = new QueryWrapper<>();
|
||||||
return [];
|
queryWrapper.eq("site_id", RequestUtils.siteId());
|
||||||
|
queryWrapper.orderByDesc("id");
|
||||||
|
|
||||||
|
if (ObjectUtil.isNotEmpty(path.basename(searchParam))) queryWrapper.like("name", path.basename(searchParam));
|
||||||
|
if (ObjectUtil.isNotEmpty(searchParam.getType())) queryWrapper.eq("type", searchParam.getType());
|
||||||
|
|
||||||
|
const records: SysPoster[] = sysPosterMapper.selectList(queryWrapper);
|
||||||
|
const list: SysPosterListVo[] = [];
|
||||||
|
for (const item of records) {
|
||||||
|
const vo: SysPosterListVo = new SysPosterListVo();
|
||||||
|
BeanUtils.copyProperties(item, vo);
|
||||||
|
list.add(vo);
|
||||||
|
}
|
||||||
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* info
|
* info
|
||||||
*/
|
*/
|
||||||
async info(...args: any[]): Promise<any> {
|
async info(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const model: SysPoster = sysPosterMapper.selectOne(
|
||||||
return null;
|
new QueryWrapper<SysPoster>()
|
||||||
|
.eq("id", id)
|
||||||
|
.eq("site_id", RequestUtils.siteId()));
|
||||||
|
|
||||||
|
Assert.notNull(model, "海报不存在");
|
||||||
|
|
||||||
|
const vo: SysPosterInfoVo = new SysPosterInfoVo();
|
||||||
|
BeanUtils.copyProperties(model, vo);
|
||||||
|
return vo;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* add
|
* add
|
||||||
*/
|
*/
|
||||||
async add(...args: any[]): Promise<any> {
|
async add(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
if (addParam.getIsDefault() === 1) {
|
||||||
return null;
|
const update: UpdateWrapper = new UpdateWrapper<>();
|
||||||
|
update.setSql("is_default = 0");
|
||||||
|
update.eq("type", addParam.getType());
|
||||||
|
update.eq("is_default", 1);
|
||||||
|
update.eq("site_id", RequestUtils.siteId());
|
||||||
|
sysPosterMapper.update(null, update);
|
||||||
|
}
|
||||||
|
const model: SysPoster = new SysPoster();
|
||||||
|
BeanUtils.copyProperties(addParam, model);
|
||||||
|
model.setSiteId(RequestUtils.siteId());
|
||||||
|
model.setCreateTime(System.currentTimeMillis() / 1000);
|
||||||
|
sysPosterMapper.insert(model);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* edit
|
* edit
|
||||||
*/
|
*/
|
||||||
async edit(...args: any[]): Promise<any> {
|
async edit(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const model: SysPoster = sysPosterMapper.selectOne(
|
||||||
return null;
|
new QueryWrapper<SysPoster>()
|
||||||
|
.eq("id", id)
|
||||||
|
.eq("site_id", RequestUtils.siteId()));
|
||||||
|
|
||||||
|
Assert.notNull(model, "海报不存在!");
|
||||||
|
|
||||||
|
if (editParam.getIsDefault() === 1) {
|
||||||
|
const update: UpdateWrapper = new UpdateWrapper<>();
|
||||||
|
update.setSql("is_default = 0");
|
||||||
|
update.eq("type", editParam.getType());
|
||||||
|
update.eq("is_default", 1);
|
||||||
|
update.eq("site_id", RequestUtils.siteId());
|
||||||
|
sysPosterMapper.update(null, update);
|
||||||
|
}
|
||||||
|
|
||||||
|
BeanUtils.copyProperties(editParam, model);
|
||||||
|
model.setUpdateTime(System.currentTimeMillis() / 1000);
|
||||||
|
sysPosterMapper.updateById(model);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* del
|
* del
|
||||||
*/
|
*/
|
||||||
async del(...args: any[]): Promise<any> {
|
async del(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const model: SysPoster = sysPosterMapper.selectOne(
|
||||||
return null;
|
new QueryWrapper<SysPoster>()
|
||||||
|
.eq("id", id)
|
||||||
|
.eq("site_id", RequestUtils.siteId()));
|
||||||
|
|
||||||
|
Assert.notNull(model, "海报不存在!");
|
||||||
|
|
||||||
|
sysPosterMapper.delete(new QueryWrapper<SysPoster>().eq("id", id));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* init
|
* init
|
||||||
*/
|
*/
|
||||||
async init(...args: any[]): Promise<any> {
|
async init(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const vo: SysPosterInitVo = new SysPosterInitVo();
|
||||||
return null;
|
BeanUtils.copyProperties(param, vo);
|
||||||
|
|
||||||
|
if (ObjectUtil.isNotEmpty(param.getId()) && param.getId() > 0) {
|
||||||
|
const poster: SysPoster = sysPosterMapper.selectOne(
|
||||||
|
new QueryWrapper<SysPoster>()
|
||||||
|
.eq("id", param.getId())
|
||||||
|
.eq("site_id", RequestUtils.siteId()));
|
||||||
|
Assert.notNull(poster, "海报不存在!");
|
||||||
|
BeanUtils.copyProperties(poster, vo);
|
||||||
|
}
|
||||||
|
|
||||||
|
vo.setPosterType(PosterTypeEnum.getType(vo.getType()));
|
||||||
|
if (ObjectUtil.isNotEmpty(vo.getPosterType()) && ObjectUtil.isEmpty(vo.getAddon())) vo.setAddon(vo.getPosterType().getStr("addon", ""));
|
||||||
|
|
||||||
|
const components: Record<string, any> = JsonModuleLoader.build().mergeResultElement("poster/components.json");
|
||||||
|
|
||||||
|
vo.setComponent(new Record<string, any>());
|
||||||
|
for (const key of components.keySet()) {
|
||||||
|
const item: Record<string, any> = components.getJSONObject(key);
|
||||||
|
if (item.getJSONObject("list") == null || item.getJSONObject("list").keySet().size() == 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
const support: JSONArray = ObjectUtil.defaultIfNull(item.getJSONArray("support"), new JSONArray());
|
||||||
|
if (!key === vo.getType() && support.size() > 0 && !support.includes(vo.getType())) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
vo.getComponent().put(key, item);
|
||||||
|
}
|
||||||
|
|
||||||
|
return vo;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* template
|
* template
|
||||||
*/
|
*/
|
||||||
async template(...args: any[]): Promise<any> {
|
async template(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
return corePosterService.template(param.getAddon(), param.getType());
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* modifyStatus
|
* modifyStatus
|
||||||
*/
|
*/
|
||||||
async modifyStatus(...args: any[]): Promise<any> {
|
async modifyStatus(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const model: SysPoster = new SysPoster();
|
||||||
return null;
|
model.setStatus(status);
|
||||||
|
sysPosterMapper.update(model, new QueryWrapper<SysPoster>().eq("id", id).eq("site_id", RequestUtils.siteId()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* modifyDefault
|
* modifyDefault
|
||||||
*/
|
*/
|
||||||
async modifyDefault(...args: any[]): Promise<any> {
|
async modifyDefault(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const model: SysPoster = sysPosterMapper.selectOne(
|
||||||
return null;
|
new QueryWrapper<SysPoster>()
|
||||||
|
.eq("id", id)
|
||||||
|
.eq("site_id", RequestUtils.siteId()));
|
||||||
|
|
||||||
|
Assert.notNull(model, "海报不存在!");
|
||||||
|
|
||||||
|
const update: UpdateWrapper = new UpdateWrapper<>();
|
||||||
|
update.setSql("is_default = 0");
|
||||||
|
update.eq("type", model.getType());
|
||||||
|
update.eq("is_default", 1);
|
||||||
|
update.eq("site_id", RequestUtils.siteId());
|
||||||
|
sysPosterMapper.update(null, update);
|
||||||
|
|
||||||
|
const updateModel: SysPoster = new SysPoster();
|
||||||
|
updateModel.setIsDefault(1);
|
||||||
|
updateModel.setId(id);
|
||||||
|
sysPosterMapper.updateById(updateModel);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* preview
|
* preview
|
||||||
*/
|
*/
|
||||||
async preview(...args: any[]): Promise<any> {
|
async preview(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const getPosterParam: GetPosterParam = new GetPosterParam();
|
||||||
return null;
|
getPosterParam.setId(param.getId());
|
||||||
|
getPosterParam.setType(param.getType());
|
||||||
|
getPosterParam.setSiteId(RequestUtils.siteId());
|
||||||
|
getPosterParam.setChannel(ObjectUtil.defaultIfNull(param.getChannel(), "h5"));
|
||||||
|
const posterParam: Record<string, any> = {};
|
||||||
|
posterParam.put("mode", "preview");
|
||||||
|
getPosterParam.setParam(posterParam);
|
||||||
|
getPosterParam.setIsThrowException(true);
|
||||||
|
return corePosterService.get(getPosterParam);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,87 +14,204 @@ export class SysPrinterServiceImplService {
|
|||||||
* page
|
* page
|
||||||
*/
|
*/
|
||||||
async page(...args: any[]): Promise<any[]> {
|
async page(...args: any[]): Promise<any[]> {
|
||||||
// TODO: 实现业务逻辑
|
const page: number = pageParam.getPage();
|
||||||
return [];
|
const limit: number = pageParam.getLimit();
|
||||||
|
|
||||||
|
const queryWrapper: QueryWrapper<SysPrinter> = new QueryWrapper<>();
|
||||||
|
|
||||||
|
queryWrapper.eq("site_id", RequestUtils.siteId())
|
||||||
|
.orderByDesc("create_time");
|
||||||
|
|
||||||
|
if (ObjectUtil.isNotEmpty(searchParam.getPrinterName())) {
|
||||||
|
queryWrapper.like("printer_name", searchParam.getPrinterName());
|
||||||
|
}
|
||||||
|
|
||||||
|
const iPage: IPage<SysPrinter> = sysPrinterMapper.selectPage(new Page<>(page, limit), queryWrapper);
|
||||||
|
const list: SysPrinterListVo[] = [];
|
||||||
|
for (const item of iPage.getRecords()) {
|
||||||
|
const vo: SysPrinterListVo = new SysPrinterListVo();
|
||||||
|
BeanUtils.copyProperties(item, vo);
|
||||||
|
vo.setBrandName(SysPrinterBrandEnum.getNameByBrand(item.getBrand()));
|
||||||
|
vo.setTrigger(JSONArray.parseArray(item.getTrigger(), String.class));
|
||||||
|
list.add(vo);
|
||||||
|
}
|
||||||
|
return PageResult.build(page, limit, iPage.getTotal()).setData(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* getList
|
* getList
|
||||||
*/
|
*/
|
||||||
async getList(...args: any[]): Promise<any> {
|
async getList(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const queryWrapper: QueryWrapper<SysPrinter> = new QueryWrapper<>();
|
||||||
return null;
|
|
||||||
|
queryWrapper.eq("site_id", RequestUtils.siteId())
|
||||||
|
.orderByDesc("create_time")
|
||||||
|
.select("printer_id, apikey, brand, create_time, open_id, print_width, printer_code, printer_key, printer_name, site_id, status, template_type, 'trigger', update_time, value");
|
||||||
|
|
||||||
|
if (ObjectUtil.isNotEmpty(param.getPrinterName())) {
|
||||||
|
queryWrapper.like("printer_name", param.getPrinterName());
|
||||||
|
}
|
||||||
|
|
||||||
|
const list: SysPrinterListVo[] = [];
|
||||||
|
for (const item of sysPrinterMapper.selectList(queryWrapper)) {
|
||||||
|
const vo: SysPrinterListVo = new SysPrinterListVo();
|
||||||
|
BeanUtils.copyProperties(item, vo);
|
||||||
|
vo.setBrandName(SysPrinterBrandEnum.getNameByBrand(item.getBrand()));
|
||||||
|
vo.setValue(JSON.parseObject(item.getValue()));
|
||||||
|
vo.setTrigger(JSONArray.parseArray(item.getTrigger(), String.class));
|
||||||
|
list.add(vo);
|
||||||
|
}
|
||||||
|
|
||||||
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* info
|
* info
|
||||||
*/
|
*/
|
||||||
async info(...args: any[]): Promise<any> {
|
async info(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const model: SysPrinter = sysPrinterMapper.selectOne(
|
||||||
return null;
|
new QueryWrapper<SysPrinter>()
|
||||||
|
.eq("printer_id", id)
|
||||||
|
.eq("site_id", RequestUtils.siteId()));
|
||||||
|
|
||||||
|
Assert.notNull(model, "小票打印机不存在");
|
||||||
|
|
||||||
|
const vo: SysPrinterInfoVo = new SysPrinterInfoVo();
|
||||||
|
BeanUtils.copyProperties(model, vo);
|
||||||
|
vo.setValue(JSON.parseObject(model.getValue()));
|
||||||
|
return vo;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* add
|
* add
|
||||||
*/
|
*/
|
||||||
async add(...args: any[]): Promise<any> {
|
async add(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const model: SysPrinter = new SysPrinter();
|
||||||
return null;
|
BeanUtils.copyProperties(addParam, model);
|
||||||
|
model.setSiteId(RequestUtils.siteId());
|
||||||
|
model.setValue(JSON.toJSONString(addParam.getValue()));
|
||||||
|
model.setTemplateType(addParam.getTemplateType().get(0));
|
||||||
|
model.setTrigger(JSON.toJSONString(addParam.getTrigger()));
|
||||||
|
model.setCreateTime(System.currentTimeMillis() / 1000);
|
||||||
|
sysPrinterMapper.insert(model);
|
||||||
|
|
||||||
|
if (addParam.getBrand() === SysPrinterBrandEnum.YI_LIAN_YUN.getBrand()) {
|
||||||
|
const addPrinterYlyParam: SysPrinterAddPrinterYlyParam = new SysPrinterAddPrinterYlyParam();
|
||||||
|
BeanUtils.copyProperties(addParam, addPrinterYlyParam);
|
||||||
|
corePrinterService.addPrinterYly(addPrinterYlyParam);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* edit
|
* edit
|
||||||
*/
|
*/
|
||||||
async edit(...args: any[]): Promise<any> {
|
async edit(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const model: SysPrinter = sysPrinterMapper.selectOne(
|
||||||
return null;
|
new QueryWrapper<SysPrinter>()
|
||||||
|
.eq("printer_id", id)
|
||||||
|
.eq("site_id", RequestUtils.siteId()));
|
||||||
|
|
||||||
|
Assert.notNull(model, "小票打印机不存在");
|
||||||
|
BeanUtils.copyProperties(editParam, model);
|
||||||
|
model.setValue(JSON.toJSONString(editParam.getValue()));
|
||||||
|
model.setTemplateType(editParam.getTemplateType().get(0));
|
||||||
|
model.setTrigger(JSON.toJSONString(editParam.getTrigger()));
|
||||||
|
model.setUpdateTime(System.currentTimeMillis() / 1000);
|
||||||
|
sysPrinterMapper.updateById(model);
|
||||||
|
|
||||||
|
if (editParam.getBrand() === SysPrinterBrandEnum.YI_LIAN_YUN.getBrand()) {
|
||||||
|
const addPrinterYlyParam: SysPrinterAddPrinterYlyParam = new SysPrinterAddPrinterYlyParam();
|
||||||
|
BeanUtils.copyProperties(editParam, addPrinterYlyParam);
|
||||||
|
corePrinterService.addPrinterYly(addPrinterYlyParam);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* modifyStatus
|
* modifyStatus
|
||||||
*/
|
*/
|
||||||
async modifyStatus(...args: any[]): Promise<any> {
|
async modifyStatus(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const model: SysPrinter = sysPrinterMapper.selectOne(
|
||||||
return null;
|
new QueryWrapper<SysPrinter>()
|
||||||
|
.eq("printer_id", param.getPrinterId())
|
||||||
|
.eq("site_id", RequestUtils.siteId()));
|
||||||
|
model.setStatus(param.getStatus());
|
||||||
|
sysPrinterMapper.updateById(model);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* del
|
* del
|
||||||
*/
|
*/
|
||||||
async del(...args: any[]): Promise<any> {
|
async del(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const model: SysPrinter = sysPrinterMapper.selectOne(
|
||||||
return null;
|
new QueryWrapper<SysPrinter>()
|
||||||
|
.eq("printer_id", id)
|
||||||
|
.eq("site_id", RequestUtils.siteId()));
|
||||||
|
|
||||||
|
if (ObjectUtil.isEmpty(model)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
sysPrinterMapper.deleteById(id);
|
||||||
|
|
||||||
|
if (model.getBrand() === SysPrinterBrandEnum.YI_LIAN_YUN.getBrand()) {
|
||||||
|
corePrinterService.deletePrinterYly(model);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* getBrand
|
* getBrand
|
||||||
*/
|
*/
|
||||||
async getBrand(...args: any[]): Promise<any> {
|
async getBrand(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const jsonObject: Record<string, any> = new Record<string, any>();
|
||||||
return null;
|
for (const value of SysPrinterBrandEnum.values()) {
|
||||||
|
if (ObjectUtil.isEmpty(value.getBrand())) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
jsonObject.put(value.getBrand(), path.basename(value));
|
||||||
|
}
|
||||||
|
return jsonObject;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* refreshToken
|
* refreshToken
|
||||||
*/
|
*/
|
||||||
async refreshToken(...args: any[]): Promise<any> {
|
async refreshToken(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const model: SysPrinter = sysPrinterMapper.selectOne(
|
||||||
return null;
|
new QueryWrapper<SysPrinter>()
|
||||||
|
.eq("printer_id", id)
|
||||||
|
.eq("site_id", RequestUtils.siteId()));
|
||||||
|
|
||||||
|
if (ObjectUtil.isEmpty(model)) {
|
||||||
|
throw new Error("打印机不存在");
|
||||||
|
}
|
||||||
|
|
||||||
|
return corePrinterService.refreshToken(model);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* testPrint
|
* testPrint
|
||||||
*/
|
*/
|
||||||
async testPrint(...args: any[]): Promise<any> {
|
async testPrint(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const model: SysPrinter = sysPrinterMapper.selectOne(
|
||||||
return null;
|
new QueryWrapper<SysPrinter>()
|
||||||
|
.eq("printer_id", id)
|
||||||
|
.eq("site_id", RequestUtils.siteId()));
|
||||||
|
|
||||||
|
if (ObjectUtil.isEmpty(model)) {
|
||||||
|
throw new Error("打印机不存在");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (model.getBrand() === SysPrinterBrandEnum.YI_LIAN_YUN.getBrand()) {
|
||||||
|
testYlyPrint(model);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* printTicket
|
* printTicket
|
||||||
*/
|
*/
|
||||||
async printTicket(...args: any[]): Promise<any> {
|
async printTicket(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
param.setSiteId(RequestUtils.siteId());
|
||||||
return null;
|
return corePrinterService.printTicket(param);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,47 +14,135 @@ export class SysPrinterTemplateServiceImplService {
|
|||||||
* page
|
* page
|
||||||
*/
|
*/
|
||||||
async page(...args: any[]): Promise<any[]> {
|
async page(...args: any[]): Promise<any[]> {
|
||||||
// TODO: 实现业务逻辑
|
const page: number = pageParam.getPage();
|
||||||
return [];
|
const limit: number = pageParam.getLimit();
|
||||||
|
|
||||||
|
const queryWrapper: QueryWrapper<SysPrinterTemplate> = new QueryWrapper<>();
|
||||||
|
|
||||||
|
queryWrapper.eq("site_id", RequestUtils.siteId())
|
||||||
|
.orderByDesc("create_time");
|
||||||
|
|
||||||
|
if (ObjectUtil.isNotEmpty(searchParam.getTemplateId())) {
|
||||||
|
queryWrapper.eq("template_id", searchParam.getTemplateId());
|
||||||
|
}
|
||||||
|
if (ObjectUtil.isNotEmpty(searchParam.getTemplateName())) {
|
||||||
|
queryWrapper.like("template_name", searchParam.getTemplateName());
|
||||||
|
}
|
||||||
|
if (ObjectUtil.isNotEmpty(searchParam.getTemplateType())) {
|
||||||
|
queryWrapper.eq("template_type", searchParam.getTemplateType());
|
||||||
|
}
|
||||||
|
|
||||||
|
const iPage: IPage<SysPrinterTemplate> = sysPrinterTemplateMapper.selectPage(new Page<>(page, limit), queryWrapper);
|
||||||
|
const list: SysPrinterTemplateListVo[] = [];
|
||||||
|
for (const item of iPage.getRecords()) {
|
||||||
|
const vo: SysPrinterTemplateListVo = new SysPrinterTemplateListVo();
|
||||||
|
BeanUtils.copyProperties(item, vo);
|
||||||
|
vo.setTemplateTypeName(SysPrinterTypeEnum.getTypeName(item.getTemplateType()));
|
||||||
|
vo.setValue(JSON.parseObject(item.getValue()));
|
||||||
|
vo.setCreateTime(DateUtils.timestampToString(item.getCreateTime()));
|
||||||
|
list.add(vo);
|
||||||
|
}
|
||||||
|
return PageResult.build(page, limit, iPage.getTotal()).setData(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* getList
|
* getList
|
||||||
*/
|
*/
|
||||||
async getList(...args: any[]): Promise<any> {
|
async getList(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const queryWrapper: QueryWrapper<SysPrinterTemplate> = new QueryWrapper<>();
|
||||||
return null;
|
|
||||||
|
queryWrapper.eq("site_id", RequestUtils.siteId())
|
||||||
|
.orderByDesc("create_time");
|
||||||
|
|
||||||
|
if (ObjectUtil.isNotEmpty(searchParam.getTemplateId())) {
|
||||||
|
queryWrapper.eq("template_id", searchParam.getTemplateId());
|
||||||
|
}
|
||||||
|
if (ObjectUtil.isNotEmpty(searchParam.getTemplateName())) {
|
||||||
|
queryWrapper.like("template_name", searchParam.getTemplateName());
|
||||||
|
}
|
||||||
|
if (ObjectUtil.isNotEmpty(searchParam.getTemplateType())) {
|
||||||
|
queryWrapper.eq("template_type", searchParam.getTemplateType());
|
||||||
|
}
|
||||||
|
|
||||||
|
const voList: SysPrinterTemplateListVo[] = [];
|
||||||
|
for (const item of sysPrinterTemplateMapper.selectList(queryWrapper)) {
|
||||||
|
const vo: SysPrinterTemplateListVo = new SysPrinterTemplateListVo();
|
||||||
|
BeanUtils.copyProperties(item, vo);
|
||||||
|
vo.setTemplateTypeName(SysPrinterTypeEnum.getTypeName(item.getTemplateType()));
|
||||||
|
vo.setValue(JSON.parseObject(item.getValue()));
|
||||||
|
vo.setCreateTime(DateUtils.timestampToString(item.getCreateTime()));
|
||||||
|
voList.add(vo);
|
||||||
|
}
|
||||||
|
return voList;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* info
|
* info
|
||||||
*/
|
*/
|
||||||
async info(...args: any[]): Promise<any> {
|
async info(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const model: SysPrinterTemplate = sysPrinterTemplateMapper.selectOne(
|
||||||
return null;
|
new QueryWrapper<SysPrinterTemplate>()
|
||||||
|
.eq("template_id", id)
|
||||||
|
.eq("site_id", RequestUtils.siteId()));
|
||||||
|
|
||||||
|
Assert.notNull(model, "小票打印模板不存在");
|
||||||
|
|
||||||
|
const vo: SysPrinterTemplateInfoVo = new SysPrinterTemplateInfoVo();
|
||||||
|
BeanUtils.copyProperties(model, vo);
|
||||||
|
vo.setValue(JSON.parseObject(model.getValue()));
|
||||||
|
vo.setCreateTime(DateUtils.timestampToString(model.getCreateTime()));
|
||||||
|
return vo;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* add
|
* add
|
||||||
*/
|
*/
|
||||||
async add(...args: any[]): Promise<any> {
|
async add(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const model: SysPrinterTemplate = new SysPrinterTemplate();
|
||||||
return null;
|
BeanUtils.copyProperties(addParam, model);
|
||||||
|
model.setValue(JSON.toJSONString(addParam.getValue()));
|
||||||
|
model.setCreateTime(System.currentTimeMillis() / 1000);
|
||||||
|
model.setSiteId(RequestUtils.siteId());
|
||||||
|
|
||||||
|
sysPrinterTemplateMapper.insert(model);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* edit
|
* edit
|
||||||
*/
|
*/
|
||||||
async edit(...args: any[]): Promise<any> {
|
async edit(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const model: SysPrinterTemplate = sysPrinterTemplateMapper.selectOne(
|
||||||
return null;
|
new QueryWrapper<SysPrinterTemplate>()
|
||||||
|
.eq("template_id", id)
|
||||||
|
.eq("site_id", RequestUtils.siteId()));
|
||||||
|
|
||||||
|
Assert.notNull(model, "小票打印模板不存在");
|
||||||
|
BeanUtils.copyProperties(editParam, model);
|
||||||
|
sysPrinterTemplateMapper.updateById(model);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* del
|
* del
|
||||||
*/
|
*/
|
||||||
async del(...args: any[]): Promise<any> {
|
async del(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const template: SysPrinterTemplate = sysPrinterTemplateMapper.selectById(id);
|
||||||
return null;
|
|
||||||
|
const printerLambdaQueryWrapper: LambdaQueryWrapper<SysPrinter> = new LambdaQueryWrapper<>();
|
||||||
|
printerLambdaQueryWrapper.eq(SysPrinter::getSiteId, RequestUtils.siteId())
|
||||||
|
.like(SysPrinter::getTemplateType, template.getTemplateType());
|
||||||
|
const printers: SysPrinter[] = sysPrinterMapper.selectList(printerLambdaQueryWrapper);
|
||||||
|
|
||||||
|
const illegalPrinter: Optional<SysPrinter> = printers.stream()
|
||||||
|
.filter(printer => ObjectUtil.isNotEmpty(printer.getValue()))
|
||||||
|
.filter(printer => JSON.parseArray(printer.getValue()).stream()
|
||||||
|
.anyMatch(value => JSON.parseArray(value.toString()).stream()
|
||||||
|
.anyMatch(o => id === JSON.parseObject(o.toString().getInteger("template_id")))))
|
||||||
|
.findFirst();
|
||||||
|
|
||||||
|
if (illegalPrinter.isPresent()) {
|
||||||
|
throw new Error("该模板已被打印机[" + illegalPrinter.get().getPrinterName() + "]使用,无法删除");
|
||||||
|
}
|
||||||
|
|
||||||
|
sysPrinterTemplateMapper.deleteById(id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,55 +14,168 @@ export class SysRoleServiceImplService {
|
|||||||
* list
|
* list
|
||||||
*/
|
*/
|
||||||
async list(...args: any[]): Promise<any[]> {
|
async list(...args: any[]): Promise<any[]> {
|
||||||
// TODO: 实现业务逻辑
|
const page: number = pageParam.getPage();
|
||||||
return [];
|
const limit: number = pageParam.getLimit();
|
||||||
|
|
||||||
|
const queryWrapper: QueryWrapper<SysRole> = new QueryWrapper<>();
|
||||||
|
queryWrapper.orderByDesc("role_id");
|
||||||
|
queryWrapper.eq("site_id", RequestUtils.siteId());
|
||||||
|
if(ObjectUtil.isNotNull(searchParam.getRoleName()) && ObjectUtil.isNotEmpty(searchParam.getRoleName())){
|
||||||
|
queryWrapper.like("role_name", searchParam.getRoleName());
|
||||||
|
}
|
||||||
|
const iPage: IPage<SysRole> = sysRoleMapper.selectPage(new Page<SysRole>(page, limit), queryWrapper);
|
||||||
|
const list: SysRoleListVo[] = [];
|
||||||
|
for (const item of iPage.getRecords()) {
|
||||||
|
const vo: SysRoleListVo = new SysRoleListVo();
|
||||||
|
BeanUtils.copyProperties(item, vo);
|
||||||
|
list.add(vo);
|
||||||
|
}
|
||||||
|
return PageResult.build(page, limit, iPage.getTotal()).setData(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* info
|
* info
|
||||||
*/
|
*/
|
||||||
async info(...args: any[]): Promise<any> {
|
async info(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const model: SysRole = sysRoleMapper.selectOne(
|
||||||
return null;
|
new QueryWrapper<SysRole>()
|
||||||
|
.eq("role_id", id)
|
||||||
|
.last("limit 1"));
|
||||||
|
|
||||||
|
Assert.notNull(model, "数据不存在");
|
||||||
|
|
||||||
|
const vo: SysRoleInfoVo = new SysRoleInfoVo();
|
||||||
|
BeanUtils.copyProperties(model, vo);
|
||||||
|
return vo;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* add
|
* add
|
||||||
*/
|
*/
|
||||||
async add(...args: any[]): Promise<any> {
|
async add(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const isExist: SysRole = sysRoleMapper.selectOne(new QueryWrapper<SysRole>()
|
||||||
return null;
|
.select("role_id")
|
||||||
|
.eq("role_name", addParam.getRoleName())
|
||||||
|
.eq("site_id", RequestUtils.siteId())
|
||||||
|
.last("limit 1")
|
||||||
|
);
|
||||||
|
if (isExist != null) throw new AdminException("管理员角色已存在");
|
||||||
|
|
||||||
|
const model: SysRole = new SysRole();
|
||||||
|
model.setSiteId(RequestUtils.siteId());
|
||||||
|
model.setRoleName(addParam.getRoleName());
|
||||||
|
model.setRules(JSONUtil.toJsonStr(addParam.getRules()));
|
||||||
|
model.setStatus(addParam.getStatus());
|
||||||
|
model.setCreateTime(DateUtils.currTime());
|
||||||
|
model.setUpdateTime(DateUtils.currTime());
|
||||||
|
sysRoleMapper.insert(model);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* edit
|
* edit
|
||||||
*/
|
*/
|
||||||
async edit(...args: any[]): Promise<any> {
|
async edit(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const isExist: SysRole = sysRoleMapper.selectOne(new QueryWrapper<SysRole>()
|
||||||
return null;
|
.select("role_id")
|
||||||
|
.eq("role_name", editParam.getRoleName())
|
||||||
|
.eq("site_id", RequestUtils.siteId())
|
||||||
|
.ne("role_id", roleId)
|
||||||
|
.last("limit 1")
|
||||||
|
);
|
||||||
|
if (isExist != null) throw new AdminException("管理员角色已存在");
|
||||||
|
|
||||||
|
const model: SysRole = sysRoleMapper.selectOne(
|
||||||
|
new QueryWrapper<SysRole>()
|
||||||
|
.eq("role_id", roleId)
|
||||||
|
.last("limit 1"));
|
||||||
|
|
||||||
|
Assert.notNull(model, "数据不存在!");
|
||||||
|
model.setSiteId(RequestUtils.siteId());
|
||||||
|
model.setRoleName(editParam.getRoleName());
|
||||||
|
model.setRules(JSONUtil.toJsonStr(editParam.getRules()));
|
||||||
|
model.setStatus(editParam.getStatus());
|
||||||
|
model.setUpdateTime(DateUtils.currTime());
|
||||||
|
sysRoleMapper.updateById(model);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* del
|
* del
|
||||||
*/
|
*/
|
||||||
async del(...args: any[]): Promise<any> {
|
async del(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const model: SysRole = sysRoleMapper.selectOne(
|
||||||
return null;
|
new QueryWrapper<SysRole>()
|
||||||
|
.eq("role_id", id)
|
||||||
|
.last("limit 1"));
|
||||||
|
|
||||||
|
Assert.notNull(model, "数据不存在!");
|
||||||
|
const userRoleCount: number = sysUserRoleMapper.selectCount(new QueryWrapper<SysUserRole>().like("role_ids", id));
|
||||||
|
if(userRoleCount>0){
|
||||||
|
throw new AdminException("USER_ROLE_NOT_ALLOW_DELETE");
|
||||||
|
}
|
||||||
|
sysRoleMapper.delete(new QueryWrapper<SysRole>().eq("role_id", id));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* getMenuIdsByRoleIds
|
* getMenuIdsByRoleIds
|
||||||
*/
|
*/
|
||||||
async getMenuIdsByRoleIds(...args: any[]): Promise<any> {
|
async getMenuIdsByRoleIds(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const queryWrapper: QueryWrapper = new QueryWrapper<SysRole>();
|
||||||
return null;
|
queryWrapper.eq("status", RoleStatusEnum.ON.getCode());
|
||||||
|
// 判断roleIds不能为空
|
||||||
|
if(ObjectUtil.isNotNull(roleIds) && roleIds.size()>0){
|
||||||
|
queryWrapper.in("role_id", roleIds);
|
||||||
|
}
|
||||||
|
const roleList: SysRole[] = sysRoleMapper.selectList(queryWrapper);
|
||||||
|
const roleMenuJson: JSONArray = new JSONArray();
|
||||||
|
for (const sysRole of roleList) {
|
||||||
|
const ruleJson: JSONArray = JSONUtil.parseArray(sysRole.getRules());
|
||||||
|
roleMenuJson.addAll(ruleJson);
|
||||||
|
}
|
||||||
|
//去重
|
||||||
|
const list: string[] = JSONUtil.toList(roleMenuJson, String.class);
|
||||||
|
return CollectionUtil.distinct(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* getAllRole
|
* getAllRole
|
||||||
*/
|
*/
|
||||||
async getAllRole(...args: any[]): Promise<any> {
|
async getAllRole(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const queryWrapper: QueryWrapper<SysRole> = new QueryWrapper<>();
|
||||||
return null;
|
queryWrapper.eq("site_id", RequestUtils.siteId());
|
||||||
|
queryWrapper.eq("status", 1);
|
||||||
|
const roleList: SysRole[] = sysRoleMapper.selectList(queryWrapper);
|
||||||
|
const sysRoleListVoList: SysRoleListVo[] = [];
|
||||||
|
for (const sysRole of roleList) {
|
||||||
|
const vo: SysRoleListVo = new SysRoleListVo();
|
||||||
|
BeanUtils.copyProperties(sysRole, vo);
|
||||||
|
sysRoleListVoList.add(vo);
|
||||||
|
}
|
||||||
|
const sysUserRole: SysUserRole = null;
|
||||||
|
const isAdmin: boolean = false;
|
||||||
|
if (authService.isSuperAdmin()){
|
||||||
|
isAdmin=true;
|
||||||
|
}else {
|
||||||
|
sysUserRole = sysUserRoleMapper.selectOne(new LambdaQueryWrapper<SysUserRole>().eq(SysUserRole::getSiteId, RequestUtils.siteId()).eq(SysUserRole::getUid, RequestUtils.uid()));
|
||||||
|
if (ObjectUtil.isEmpty(sysUserRole)){
|
||||||
|
return List.of();
|
||||||
|
}
|
||||||
|
isAdmin = sysUserRole.getIsAdmin() == 1 ? true : false;
|
||||||
|
}
|
||||||
|
if (!isAdmin){
|
||||||
|
if ((sysUserRole.getRoleIds( && sysUserRole.getRoleIds(.trim() !== '')) && "[]" === sysUserRole.getRoleIds()){
|
||||||
|
const roleIdsStr: string = sysUserRole.getRoleIds().replaceAll("[\\[\\]\"]", "");
|
||||||
|
const menuIdsByRoleIds: string[] = getMenuIdsByRoleIds(RequestUtils.siteId(), Arrays.stream(roleIdsStr.split(",")).collect(Collectors.toList()));
|
||||||
|
for (const sysRoleListVo of sysRoleListVoList) {
|
||||||
|
const diff: string[] = new ArrayList<>(Collections.singleton(sysRoleListVo.getRules()));
|
||||||
|
diff.removeAll(menuIdsByRoleIds);
|
||||||
|
if (!diff.length === 0){
|
||||||
|
sysRoleListVo.setDisabled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
sysRoleListVoList.forEach(sysRoleListVo => sysRoleListVo.setRules(null));
|
||||||
|
return sysRoleListVoList;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,135 +14,306 @@ export class SysScheduleServiceImplService {
|
|||||||
* JobInvokeService
|
* JobInvokeService
|
||||||
*/
|
*/
|
||||||
async jobInvokeService(...args: any[]): Promise<any> {
|
async jobInvokeService(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
this.applicationContext = applicationContext;
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* init
|
* init
|
||||||
*/
|
*/
|
||||||
async init(...args: any[]): Promise<any> {
|
async init(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
// 通过 ApplicationContext 获取所有 IJobProvider 实现
|
||||||
return null;
|
const providers: Record<string, any> = applicationContext.getBeansOfType(IJobProvider.class);
|
||||||
|
log.info("Loaded job provider count: {}", providers.size());
|
||||||
|
for (const provider of providers.values()) {
|
||||||
|
log.info("Loaded job provider: {}", provider.getClass().getName());
|
||||||
|
const annotation: JobProvider = provider.getClass().getAnnotation(JobProvider.class);
|
||||||
|
if (annotation != null) {
|
||||||
|
// 使用注解的 key 作为 map 的键
|
||||||
|
jobProviderMap.put(annotation.key(), provider);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* getSysEnableList
|
* getSysEnableList
|
||||||
*/
|
*/
|
||||||
async getSysEnableList(...args: any[]): Promise<any> {
|
async getSysEnableList(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const queryWrapper: QueryWrapper<SysSchedule> = new QueryWrapper<>();
|
||||||
return null;
|
queryWrapper.eq("status", 1);
|
||||||
|
queryWrapper.orderByDesc("sort", "id");
|
||||||
|
return sysScheduleMapper.selectList(queryWrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* list
|
* list
|
||||||
*/
|
*/
|
||||||
async list(...args: any[]): Promise<any[]> {
|
async list(...args: any[]): Promise<any[]> {
|
||||||
// TODO: 实现业务逻辑
|
// 分页参数
|
||||||
return [];
|
const page: number = pageParam.getPage();
|
||||||
|
const limit: number = pageParam.getLimit();
|
||||||
|
// 构造查询条件执行查询
|
||||||
|
const queryWrapper: LambdaQueryWrapper<SysSchedule> = new LambdaQueryWrapper<>();
|
||||||
|
if (ObjectUtil.isNotEmpty(searchParam.getStatus()) && !"all" === searchParam.getStatus()){
|
||||||
|
if ("0" === searchParam.getStatus()){
|
||||||
|
searchParam.setStatus("2");
|
||||||
|
}
|
||||||
|
queryWrapper.eq( SysSchedule::getStatus, searchParam.getStatus());
|
||||||
|
}
|
||||||
|
queryWrapper.eq(ObjectUtil.isNotEmpty(searchParam.getKey()), SysSchedule::getKey, searchParam.getKey());
|
||||||
|
queryWrapper.orderByDesc(SysSchedule::getSort, SysSchedule::getId);
|
||||||
|
const sysSchedulePage: IPage<SysSchedule> = sysScheduleMapper.selectPage(new Page<>(page, limit), queryWrapper);
|
||||||
|
// 返回结果集
|
||||||
|
const sysScheduleListVoList: SysScheduleListVo[] = [];
|
||||||
|
for (const sysSchedule of sysSchedulePage.getRecords()) {
|
||||||
|
const sysScheduleListVo: SysScheduleListVo = new SysScheduleListVo();
|
||||||
|
BeanUtils.copyProperties(sysSchedule, sysScheduleListVo);
|
||||||
|
sysScheduleListVo.setTimeObject(sysSchedule.getTime());
|
||||||
|
sysScheduleListVo.setCrontabContent(QuartzJobManager.convertCronContent(sysSchedule.getTime()));
|
||||||
|
sysScheduleListVoList.add(sysScheduleListVo);
|
||||||
|
}
|
||||||
|
return PageResult.build(page, limit, sysSchedulePage.getTotal()).setData(sysScheduleListVoList);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* info
|
* info
|
||||||
*/
|
*/
|
||||||
async info(...args: any[]): Promise<any> {
|
async info(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const sysSchedule: SysSchedule = sysScheduleMapper.selectById(id);
|
||||||
return null;
|
const sysScheduleInfoVo: SysScheduleInfoVo = new SysScheduleInfoVo();
|
||||||
|
BeanUtils.copyProperties(sysSchedule, sysScheduleInfoVo);
|
||||||
|
return sysScheduleInfoVo;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* modifyStatus
|
* modifyStatus
|
||||||
*/
|
*/
|
||||||
async modifyStatus(...args: any[]): Promise<any> {
|
async modifyStatus(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const oldSysSchedule: SysSchedule = this.findByIdAndCheck(sysScheduleStatusParam.getId());
|
||||||
return null;
|
if (sysScheduleStatusParam.getStatus() == 2) {
|
||||||
|
QuartzJobManager.stopJob(oldSysSchedule);
|
||||||
|
} else {
|
||||||
|
QuartzJobManager.stopJob(oldSysSchedule);
|
||||||
|
QuartzJobManager.startJob(oldSysSchedule);
|
||||||
|
}
|
||||||
|
const newSysSchedule: SysSchedule = new SysSchedule();
|
||||||
|
newSysSchedule.setId(oldSysSchedule.getId());
|
||||||
|
newSysSchedule.setStatus(sysScheduleStatusParam.getStatus());
|
||||||
|
newSysSchedule.setUpdateTime(DateUtils.currTime());
|
||||||
|
sysScheduleMapper.updateById(newSysSchedule);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* add
|
* add
|
||||||
*/
|
*/
|
||||||
async add(...args: any[]): Promise<any> {
|
async add(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const jobKey: string = sysScheduleParam.getKey();
|
||||||
return null;
|
const jobInfo: JobInfo = JobProviderFactory.getJobInfo(jobKey);
|
||||||
|
if (jobInfo == null) {
|
||||||
|
throw new Error("任务不存在.");
|
||||||
|
}
|
||||||
|
// 校验任务是否存在
|
||||||
|
const queryWrapper: QueryWrapper<SysSchedule> = new QueryWrapper();
|
||||||
|
queryWrapper.eq("`key`", jobKey);
|
||||||
|
const sysScheduleList: SysSchedule[] = sysScheduleMapper.selectList(queryWrapper);
|
||||||
|
if (sysScheduleList != null && sysScheduleList.size() > 0) {
|
||||||
|
throw new Error("任务已经存在.");
|
||||||
|
}
|
||||||
|
// 新增一个任务
|
||||||
|
const newSysSchedule: SysSchedule = new SysSchedule();
|
||||||
|
BeanUtils.copyProperties(sysScheduleParam, newSysSchedule);
|
||||||
|
newSysSchedule.setTime(JSONUtil.toJsonStr(sysScheduleParam.getTime()));
|
||||||
|
newSysSchedule.setCreateTime(DateUtils.currTime());
|
||||||
|
newSysSchedule.setUpdateTime(DateUtils.currTime());
|
||||||
|
newSysSchedule.setSiteId(RequestUtils.adminSiteId());
|
||||||
|
newSysSchedule.setAddon(jobInfo.getSource());
|
||||||
|
const result: number = sysScheduleMapper.insert(newSysSchedule);
|
||||||
|
if (result > 0) {
|
||||||
|
if (newSysSchedule.getStatus() == 1) {
|
||||||
|
// 如果是启动状态,就启动任务
|
||||||
|
QuartzJobManager.startJob(newSysSchedule);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* edit
|
* edit
|
||||||
*/
|
*/
|
||||||
async edit(...args: any[]): Promise<any> {
|
async edit(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
// 存在性检查
|
||||||
return null;
|
this.findByIdAndCheck(id);
|
||||||
|
// 构建更新对象
|
||||||
|
const newSysSchedule: SysSchedule = new SysSchedule();
|
||||||
|
BeanUtils.copyProperties(sysScheduleParam, newSysSchedule);
|
||||||
|
newSysSchedule.setId(id);
|
||||||
|
newSysSchedule.setSiteId(RequestUtils.adminSiteId());
|
||||||
|
newSysSchedule.setUpdateTime(DateUtils.currTime());
|
||||||
|
newSysSchedule.setTime(JSONUtil.toJsonStr(sysScheduleParam.getTime()));
|
||||||
|
const result: number = sysScheduleMapper.updateById(newSysSchedule);
|
||||||
|
if (result <= 0) {
|
||||||
|
log.error("更新系统任务失败:id={}", id);
|
||||||
|
}
|
||||||
|
// 根据状态启停任务
|
||||||
|
if (sysScheduleParam.getStatus() == 2) {
|
||||||
|
QuartzJobManager.stopJob(newSysSchedule.getKey());
|
||||||
|
} else {
|
||||||
|
QuartzJobManager.stopJob(newSysSchedule.getKey());
|
||||||
|
QuartzJobManager.startJob(newSysSchedule);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* del
|
* del
|
||||||
*/
|
*/
|
||||||
async del(...args: any[]): Promise<any> {
|
async del(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const sysSchedule: SysSchedule = this.findByIdAndCheck(id);
|
||||||
return null;
|
if (sysSchedule.getStatus() == 1) {
|
||||||
|
QuartzJobManager.stopJob(sysSchedule);
|
||||||
|
}
|
||||||
|
sysScheduleMapper.deleteById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* template
|
* template
|
||||||
*/
|
*/
|
||||||
async template(...args: any[]): Promise<any> {
|
async template(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const sysScheduleTemplateVoList: SysScheduleTemplateVo[] = [];
|
||||||
return null;
|
const jobKeys: Set<String> = JobProviderFactory.jobKeys();
|
||||||
|
for (const jobKey of jobKeys) {
|
||||||
|
const jobInfo: JobInfo = JobProviderFactory.getJobInfo(jobKey);
|
||||||
|
const sysScheduleTemplateVo: SysScheduleTemplateVo = new SysScheduleTemplateVo();
|
||||||
|
sysScheduleTemplateVo.setKey(jobKey);
|
||||||
|
sysScheduleTemplateVo.setName(path.basename(jobInfo));
|
||||||
|
sysScheduleTemplateVo.setDesc(jobInfo.getDescribe());
|
||||||
|
sysScheduleTemplateVo.setClazz(jobInfo.getJobClass());
|
||||||
|
sysScheduleTemplateVo.setFunction(jobInfo.getJobClass());
|
||||||
|
sysScheduleTemplateVoList.add(sysScheduleTemplateVo);
|
||||||
|
}
|
||||||
|
return sysScheduleTemplateVoList;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* deleteScheduleLog
|
* deleteScheduleLog
|
||||||
*/
|
*/
|
||||||
async deleteScheduleLog(...args: any[]): Promise<void> {
|
async deleteScheduleLog(...args: any[]): Promise<void> {
|
||||||
// TODO: 实现业务逻辑
|
const sysScheduleLogs: SysScheduleLog[] = sysScheduleLogMapper.selectList(new QueryWrapper<SysScheduleLog>().eq("status", status).lt("execute_time", successThreshold));
|
||||||
|
if (CollectionUtils.isEmpty(sysScheduleLogs)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
const delIds: Set<number> = sysScheduleLogs.stream().map(SysScheduleLog::getId).collect(Collectors.toSet());
|
||||||
|
sysScheduleLogMapper.deleteBatchIds(delIds);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* resetSchedule
|
* resetSchedule
|
||||||
*/
|
*/
|
||||||
async resetSchedule(...args: any[]): Promise<any> {
|
async resetSchedule(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
coreScheduleService.resetSchedule();
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* logList
|
* logList
|
||||||
*/
|
*/
|
||||||
async logList(...args: any[]): Promise<any> {
|
async logList(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const page: number = pageParam.getPage();
|
||||||
return null;
|
const limit: number = pageParam.getLimit();
|
||||||
|
const qw: LambdaQueryWrapper<SysScheduleLog> = new LambdaQueryWrapper<>();
|
||||||
|
qw.eq(ObjectUtil.isNotEmpty(searchParam.getScheduleId()), SysScheduleLog::getScheduleId, searchParam.getScheduleId());
|
||||||
|
qw.eq(ObjectUtil.isNotEmpty(searchParam.getKey()), SysScheduleLog::getKey, searchParam.getKey());
|
||||||
|
if (ObjectUtil.isNotEmpty(searchParam.getStatus()) && !"all" === searchParam.getStatus()){
|
||||||
|
qw.eq(SysScheduleLog::getStatus, searchParam.getStatus());
|
||||||
|
}
|
||||||
|
if (ObjectUtil.isNotEmpty(searchParam.getExecuteTime())) {
|
||||||
|
QueryMapperUtils.buildByTime(qw, SysScheduleLog::getExecuteTime, searchParam.getExecuteTime());
|
||||||
|
}
|
||||||
|
const sysScheduleLogPage: Page<SysScheduleLog> = sysScheduleLogMapper.selectPage(new Page<>(page, limit), qw);
|
||||||
|
const result: SysScheduleLogListVo[] = [];
|
||||||
|
sysScheduleLogPage.getRecords().forEach(sysScheduleLog => {
|
||||||
|
const sysScheduleLogListVo: SysScheduleLogListVo = new SysScheduleLogListVo();
|
||||||
|
BeanUtils.copyProperties(sysScheduleLog, sysScheduleLogListVo);
|
||||||
|
result.add(sysScheduleLogListVo);
|
||||||
|
});
|
||||||
|
return PageResult.build(page, limit, sysScheduleLogPage.getTotal()).setData(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* addLog
|
* addLog
|
||||||
*/
|
*/
|
||||||
async addLog(...args: any[]): Promise<any> {
|
async addLog(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const sysSchedule: SysSchedule = sysScheduleMapper.selectOne(new LambdaQueryWrapper<SysSchedule>()
|
||||||
return null;
|
.eq(SysSchedule::getKey, log.getKey()).eq(SysSchedule::getAddon, log.getAddon()));
|
||||||
|
if (sysSchedule == null) return;
|
||||||
|
log.setScheduleId(sysSchedule.getId());
|
||||||
|
log.setExecuteTime(DateUtils.currTime());
|
||||||
|
sysScheduleLogMapper.insert(log);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* doSchedule
|
* doSchedule
|
||||||
*/
|
*/
|
||||||
async doSchedule(...args: any[]): Promise<any> {
|
async doSchedule(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const sysSchedule: SysSchedule = sysScheduleMapper.selectById(id);
|
||||||
return null;
|
if (sysSchedule == null) {
|
||||||
|
throw new BadRequestException("计划任务不存在");
|
||||||
|
}
|
||||||
|
const basePackage: string = String.format("com.niu.%s.job", sysSchedule.getAddon());
|
||||||
|
const classPath: string = QuartzJobManager.getClassPath(basePackage, sysSchedule.getKey());
|
||||||
|
const jobKey: string = sysSchedule.getKey();
|
||||||
|
try {
|
||||||
|
// 动态加载任务类
|
||||||
|
Class<?> jobClass = Class.forName(classPath);
|
||||||
|
|
||||||
|
// 验证是否为有效的任务类
|
||||||
|
if (!IJobProvider.class.isAssignableFrom(jobClass)) {
|
||||||
|
throw new BadRequestException("无效的任务类: " + classPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 实例化任务
|
||||||
|
const job: IJobProvider = (IJobProvider) jobClass.getDeclaredConstructor().newInstance();
|
||||||
|
|
||||||
|
// 执行任务
|
||||||
|
job.exec(null);
|
||||||
|
|
||||||
|
// 构建日志信息
|
||||||
|
const result: string = "计划任务:" + path.basename(sysSchedule) + "执行成功";
|
||||||
|
addLog(SysScheduleLog.builder()
|
||||||
|
.key(jobKey)
|
||||||
|
.name(path.basename(sysSchedule))
|
||||||
|
.addon(sysSchedule.getAddon())
|
||||||
|
.className(classPath)
|
||||||
|
.status("success")
|
||||||
|
.executeResult(result)
|
||||||
|
.job(classPath)
|
||||||
|
.build());
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
// 获取任务名称(即使在异常情况下也尝试获取)
|
||||||
|
const errorMsg: string = "计划任务:" + path.basename(sysSchedule) + "发生错误, 错误原因:" + e.getMessage() +
|
||||||
|
" at " + e.getStackTrace()[0].toString();
|
||||||
|
addLog(SysScheduleLog.builder()
|
||||||
|
.key(jobKey)
|
||||||
|
.name(path.basename(sysSchedule))
|
||||||
|
.addon(sysSchedule.getAddon())
|
||||||
|
.className(classPath)
|
||||||
|
.status("error")
|
||||||
|
.executeResult(errorMsg)
|
||||||
|
.job(classPath)
|
||||||
|
.build());
|
||||||
|
|
||||||
|
throw new BadRequestException("执行计划任务失败", e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* delLog
|
* delLog
|
||||||
*/
|
*/
|
||||||
async delLog(...args: any[]): Promise<any> {
|
async delLog(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
sysScheduleLogMapper.deleteByIds(Arrays.asList(ids));
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* clearLog
|
* clearLog
|
||||||
*/
|
*/
|
||||||
async clearLog(...args: any[]): Promise<any> {
|
async clearLog(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
sysScheduleLogMapper.delete(new QueryWrapper<SysScheduleLog>().eq("schedule_id", scheduleId));
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,39 +14,75 @@ export class SysUpgradeRecordsServiceImplService {
|
|||||||
* page
|
* page
|
||||||
*/
|
*/
|
||||||
async page(...args: any[]): Promise<any[]> {
|
async page(...args: any[]): Promise<any[]> {
|
||||||
// TODO: 实现业务逻辑
|
const page: number = pageParam.getPage();
|
||||||
return [];
|
const limit: number = pageParam.getLimit();
|
||||||
|
|
||||||
|
const queryWrapper: QueryWrapper<SysUpgradeRecords> = new QueryWrapper<>();
|
||||||
|
queryWrapper.orderByDesc("create_time");
|
||||||
|
|
||||||
|
if (searchParam != null) {
|
||||||
|
if (path.basename(searchParam) != null) {
|
||||||
|
queryWrapper.like("name", path.basename(searchParam));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
const iPage: IPage<SysUpgradeRecords> = sysUpgradeRecordsMapper.selectPage(new Page<>(page, limit), queryWrapper);
|
||||||
* add
|
const list: SysUpgradeRecordsListVo[] = [];
|
||||||
*/
|
for (const item of iPage.getRecords()) {
|
||||||
async add(...args: any[]): Promise<any> {
|
const vo: SysUpgradeRecordsListVo = new SysUpgradeRecordsListVo();
|
||||||
// TODO: 实现业务逻辑
|
BeanUtils.copyProperties(item, vo);
|
||||||
return null;
|
vo.setCreateTime(DateUtils.timestampToString(item.getCreateTime()));
|
||||||
|
vo.setCompleteTime(DateUtils.timestampToString(item.getCompleteTime()));
|
||||||
|
vo.setStatusName(UpgradeRecordStatusEnum.getNameByStatus(vo.getStatus()));
|
||||||
|
//判断为数组或者对象或者字符串
|
||||||
|
const value: string = item.getContent();
|
||||||
|
if (!StrUtil.isEmpty(value)) {
|
||||||
|
if (value.startsWith("[")) {
|
||||||
|
vo.setContent(JSON.parseArray(value));
|
||||||
|
} else if (value.startsWith("{")) {
|
||||||
|
vo.setContent(JSON.parseObject(value));
|
||||||
|
} else {
|
||||||
|
vo.setContent(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
list.add(vo);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
return PageResult.build(page, limit, iPage.getTotal()).setData(list);
|
||||||
* edit
|
|
||||||
*/
|
|
||||||
async edit(...args: any[]): Promise<any> {
|
|
||||||
// TODO: 实现业务逻辑
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* clear
|
public void add(SysUpgradeRecordsParam addParam) {
|
||||||
*/
|
const model: SysUpgradeRecords = new SysUpgradeRecords();
|
||||||
async clear(...args: any[]): Promise<any> {
|
BeanUtils.copyProperties(addParam, model);
|
||||||
// TODO: 实现业务逻辑
|
model.setCreateTime(System.currentTimeMillis() / 1000);
|
||||||
return null;
|
sysUpgradeRecordsMapper.insert(model);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* del
|
public void edit(String key, SysUpgradeRecordsParam editParam) {
|
||||||
*/
|
const model: SysUpgradeRecords = new SysUpgradeRecords();
|
||||||
async del(...args: any[]): Promise<any> {
|
BeanUtils.copyProperties(editParam, model);
|
||||||
// TODO: 实现业务逻辑
|
sysUpgradeRecordsMapper.update(model, new QueryWrapper<SysUpgradeRecords>().eq("upgrade_key", key));
|
||||||
return null;
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void clear(long threshold) {
|
||||||
|
sysUpgradeRecordsMapper.delete(new QueryWrapper<SysUpgradeRecords>()
|
||||||
|
.lt("create_time", threshold).in("status", STATUS_READY, STATUS_FAIL));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void del(SysUpgradeRecordsDelParam delParam) {
|
||||||
|
const queryWrapper: QueryWrapper = new QueryWrapper<SysUpgradeRecords>();
|
||||||
|
|
||||||
|
if (delParam.getIds().getClass().getName().startsWith("[")) {
|
||||||
|
String[] stringIds = (String[]) delParam.getIds();
|
||||||
|
queryWrapper.in("id", stringIds);
|
||||||
|
} else {
|
||||||
|
queryWrapper.eq("id", delParam.getIds());
|
||||||
|
}
|
||||||
|
sysUpgradeRecordsMapper.delete(queryWrapper);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,23 +14,54 @@ export class SysUserLogServiceImplService {
|
|||||||
* list
|
* list
|
||||||
*/
|
*/
|
||||||
async list(...args: any[]): Promise<any[]> {
|
async list(...args: any[]): Promise<any[]> {
|
||||||
// TODO: 实现业务逻辑
|
const page: number = pageParam.getPage();
|
||||||
return [];
|
const limit: number = pageParam.getLimit();
|
||||||
|
|
||||||
|
const queryWrapper: QueryWrapper<SysUserLog> = new QueryWrapper<>();
|
||||||
|
queryWrapper.eq("site_id", RequestUtils.siteId());
|
||||||
|
queryWrapper.orderByDesc("id");
|
||||||
|
if(ObjectUtil.isNotNull(searchParam.getUsername()) && ObjectUtil.isNotEmpty(searchParam.getUsername())){
|
||||||
|
queryWrapper.like("username", searchParam.getUsername());
|
||||||
|
}
|
||||||
|
if(ObjectUtil.isNotNull(searchParam.getIp()) && ObjectUtil.isNotEmpty(searchParam.getIp())){
|
||||||
|
queryWrapper.like("ip", searchParam.getIp());
|
||||||
|
}
|
||||||
|
|
||||||
|
if(ObjectUtil.isNotNull(searchParam.getUrl()) && ObjectUtil.isNotEmpty(searchParam.getUrl())){
|
||||||
|
queryWrapper.like("url", searchParam.getUrl());
|
||||||
|
}
|
||||||
|
const iPage: IPage<SysUserLog> = sysUserLogMapper.selectPage(new Page<SysUserLog>(page, limit), queryWrapper);
|
||||||
|
|
||||||
|
const list: SysUserLogListVo[] = [];
|
||||||
|
for (const item of iPage.getRecords()) {
|
||||||
|
const vo: SysUserLogListVo = new SysUserLogListVo();
|
||||||
|
BeanUtils.copyProperties(item, vo);
|
||||||
|
list.add(vo);
|
||||||
|
}
|
||||||
|
return PageResult.build(page, limit, iPage.getTotal()).setData(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* info
|
* info
|
||||||
*/
|
*/
|
||||||
async info(...args: any[]): Promise<any> {
|
async info(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const model: SysUserLog = sysUserLogMapper.selectOne(
|
||||||
return null;
|
new QueryWrapper<SysUserLog>()
|
||||||
|
.eq("id", id)
|
||||||
|
.eq("site_id", RequestUtils.siteId())
|
||||||
|
.last("limit 1"));
|
||||||
|
|
||||||
|
Assert.notNull(model, "数据不存在");
|
||||||
|
|
||||||
|
const vo: SysUserLogInfoVo = new SysUserLogInfoVo();
|
||||||
|
BeanUtils.copyProperties(model, vo);
|
||||||
|
return vo;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* destroy
|
* destroy
|
||||||
*/
|
*/
|
||||||
async destroy(...args: any[]): Promise<any> {
|
async destroy(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
sysUserLogMapper.delete(new QueryWrapper<SysUserLog>().eq("site_id", RequestUtils.siteId()));
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,47 +14,120 @@ export class SysUserRoleServiceImplService {
|
|||||||
* list
|
* list
|
||||||
*/
|
*/
|
||||||
async list(...args: any[]): Promise<any[]> {
|
async list(...args: any[]): Promise<any[]> {
|
||||||
// TODO: 实现业务逻辑
|
const page: number = pageParam.getPage();
|
||||||
return [];
|
const limit: number = pageParam.getLimit();
|
||||||
|
|
||||||
|
const queryWrapper: MPJQueryWrapper<SysUserRole> = new MPJQueryWrapper<>();
|
||||||
|
|
||||||
|
//sql语句
|
||||||
|
queryWrapper.select("nsu.uid, nsu.username, nsu.head_img, nsu.password, nsu.real_name, nsu.last_ip, nsu.last_time, nsu.create_time, nsu.login_count, nsu.status, nsu.is_del, nsu.delete_time, nsu.update_time, nsur.id, nsur.site_id, nsur.role_ids, nsur.is_admin")
|
||||||
|
.setAlias("nsur")
|
||||||
|
.leftJoin("?_sys_user nsu ON nsur.uid = nsu.uid".replace("?_", this.config.get('tablePrefix')));
|
||||||
|
|
||||||
|
//查询条件判断组装
|
||||||
|
if (ObjectUtil.isNotEmpty(searchParam.getUid())) {
|
||||||
|
queryWrapper.eq("nsu.uid", searchParam.getUid());
|
||||||
|
}
|
||||||
|
|
||||||
|
//排序
|
||||||
|
queryWrapper.orderByDesc("id");
|
||||||
|
//分页查询
|
||||||
|
const iPage: IPage<SysUserRoleListVo> = sysUserRoleMapper.selectJoinPage(
|
||||||
|
new Page<>(page, limit),
|
||||||
|
SysUserRoleListVo.class,
|
||||||
|
queryWrapper);
|
||||||
|
|
||||||
|
|
||||||
|
return PageResult.build(iPage);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* info
|
* info
|
||||||
*/
|
*/
|
||||||
async info(...args: any[]): Promise<any> {
|
async info(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const model: SysUserRole = sysUserRoleMapper.selectOne(
|
||||||
return null;
|
new QueryWrapper<SysUserRole>()
|
||||||
|
.eq("id", id)
|
||||||
|
.last("limit 1"));
|
||||||
|
|
||||||
|
Assert.notNull(model, "数据不存在");
|
||||||
|
|
||||||
|
const vo: SysUserRoleInfoVo = new SysUserRoleInfoVo();
|
||||||
|
BeanUtils.copyProperties(model, vo);
|
||||||
|
return vo;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* add
|
* add
|
||||||
*/
|
*/
|
||||||
async add(...args: any[]): Promise<any> {
|
async add(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const userRoleCount: number = sysUserRoleMapper.selectCount(
|
||||||
return null;
|
new QueryWrapper<SysUserRole>()
|
||||||
|
.eq("uid", addParam.getUid())
|
||||||
|
.eq("site_id", addParam.getSiteId())
|
||||||
|
);
|
||||||
|
if (userRoleCount>0){
|
||||||
|
throw new BadRequestException("SITE_USER_EXIST");
|
||||||
|
}
|
||||||
|
|
||||||
|
const model: SysUserRole = new SysUserRole();
|
||||||
|
model.setUid(addParam.getUid());
|
||||||
|
model.setSiteId(addParam.getSiteId()==null? RequestUtils.siteId():addParam.getSiteId());
|
||||||
|
model.setRoleIds(addParam.getRoleIds());
|
||||||
|
model.setCreateTime(DateUtils.currTime());
|
||||||
|
model.setIsAdmin(addParam.getIsAdmin()==null?0:addParam.getIsAdmin());
|
||||||
|
model.setStatus(ObjectUtil.isNull(addParam.getStatus())? StatusEnum.ON.getStatus() : addParam.getStatus());
|
||||||
|
if(model.getStatus()<1){
|
||||||
|
model.setRoleIds(addParam.getRoleIds()==null? JSONUtil.toJsonStr(new JsonArray()):addParam.getRoleIds());
|
||||||
|
}
|
||||||
|
sysUserRoleMapper.insert(model);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* edit
|
* edit
|
||||||
*/
|
*/
|
||||||
async edit(...args: any[]): Promise<any> {
|
async edit(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const model: SysUserRole = sysUserRoleMapper.selectOne(
|
||||||
return null;
|
new QueryWrapper<SysUserRole>()
|
||||||
|
.eq("uid", editParam.getUid())
|
||||||
|
.eq("site_id", editParam.getSiteId())
|
||||||
|
.last("limit 1"));
|
||||||
|
Assert.notNull(model, "数据不存在!");
|
||||||
|
const isAdmin: number = model.getIsAdmin();
|
||||||
|
if(isAdmin>0){
|
||||||
|
//超级管理员不允许改动权限
|
||||||
|
throw new AdminException("ADMIN_NOT_ALLOW_EDIT_ROLE");
|
||||||
|
}
|
||||||
|
model.setStatus(editParam.getStatus());
|
||||||
|
model.setRoleIds(editParam.getRoleIds());
|
||||||
|
sysUserRoleMapper.updateById(model);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* del
|
* del
|
||||||
*/
|
*/
|
||||||
async del(...args: any[]): Promise<any> {
|
async del(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const model: SysUserRole = sysUserRoleMapper.selectOne(
|
||||||
return null;
|
new QueryWrapper<SysUserRole>()
|
||||||
|
.eq("id", id)
|
||||||
|
.last("limit 1"));
|
||||||
|
|
||||||
|
Assert.notNull(model, "数据不存在!");
|
||||||
|
|
||||||
|
sysUserRoleMapper.delete(new QueryWrapper<SysUserRole>().eq("id", id));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* getUserRole
|
* getUserRole
|
||||||
*/
|
*/
|
||||||
async getUserRole(...args: any[]): Promise<any> {
|
async getUserRole(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const model: SysUserRole = sysUserRoleMapper.selectOne(new QueryWrapper<SysUserRole>().eq("uid", uid).eq("site_id", site_id).last(" limit 1"));
|
||||||
|
const vo: SysUserRoleInfoVo = new SysUserRoleInfoVo();
|
||||||
|
if(ObjectUtil.isNotNull(model)){
|
||||||
|
BeanUtils.copyProperties(model, vo);
|
||||||
|
return vo;
|
||||||
|
}else{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -14,143 +14,401 @@ export class SysUserServiceImplService {
|
|||||||
* getLoginService
|
* getLoginService
|
||||||
*/
|
*/
|
||||||
async getLoginService(...args: any[]): Promise<any> {
|
async getLoginService(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
return (ILoginService) SpringContext.getBean(LoginServiceImpl.class);
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* list
|
* list
|
||||||
*/
|
*/
|
||||||
async list(...args: any[]): Promise<any[]> {
|
async list(...args: any[]): Promise<any[]> {
|
||||||
// TODO: 实现业务逻辑
|
authService.isSuperAdmin();
|
||||||
return [];
|
const superAdminUid: number = cached.tag("adminAuth").get("superAdminUid");
|
||||||
|
|
||||||
|
const page: number = pageParam.getPage();
|
||||||
|
const limit: number = pageParam.getLimit();
|
||||||
|
|
||||||
|
const queryWrapper: QueryWrapper<SysUser> = new QueryWrapper<>();
|
||||||
|
queryWrapper.orderByDesc("uid");
|
||||||
|
|
||||||
|
if (ObjectUtil.isNotNull(searchParam.getUsername()) && ObjectUtil.isNotEmpty(searchParam.getUsername())) {
|
||||||
|
queryWrapper.like("username", searchParam.getUsername()).or().like("real_name", searchParam.getUsername());
|
||||||
|
}
|
||||||
|
if (ObjectUtil.isNotNull(searchParam.getLastTime()) && ObjectUtil.isNotEmpty(searchParam.getLastTime())) {
|
||||||
|
const startTime: number = 0;
|
||||||
|
const endTime: number = 0;
|
||||||
|
if (ObjectUtil.isNotNull(searchParam.getLastTime()[0])) {
|
||||||
|
startTime = DateUtils.StringToTimestamp(searchParam.getLastTime()[0]);
|
||||||
|
}
|
||||||
|
if (ObjectUtil.isNotNull(searchParam.getLastTime()[1])) {
|
||||||
|
endTime = DateUtils.StringToTimestamp(searchParam.getLastTime()[1]);
|
||||||
|
}
|
||||||
|
if (startTime > 0 && endTime > 0) {
|
||||||
|
queryWrapper.between("last_time", startTime, endTime);
|
||||||
|
} else if (startTime > 0) {
|
||||||
|
queryWrapper.ge("last_time", startTime);
|
||||||
|
} else if (endTime > 0) {
|
||||||
|
queryWrapper.le("last_time", endTime);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const iPage: IPage<SysUser> = sysUserMapper.selectPage(new Page<SysUser>(page, limit), queryWrapper);
|
||||||
|
|
||||||
|
const list: SysUserListVo[] = [];
|
||||||
|
for (const item of iPage.getRecords()) {
|
||||||
|
const vo: SysUserListVo = new SysUserListVo();
|
||||||
|
BeanUtils.copyProperties(item, vo);
|
||||||
|
const siteNum: number = sysUserRoleMapper.selectCount(new QueryWrapper<SysUserRole>().eq("uid", item.getUid()).ne("site_id", RequestUtils.defaultSiteId()));
|
||||||
|
vo.setSiteNum(siteNum.intValue());
|
||||||
|
vo.setIsSuperAdmin(superAdminUid == item.getUid());
|
||||||
|
list.add(vo);
|
||||||
|
}
|
||||||
|
return PageResult.build(page, limit, iPage.getTotal()).setData(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* info
|
* info
|
||||||
*/
|
*/
|
||||||
async info(...args: any[]): Promise<any> {
|
async info(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
authService.isSuperAdmin();
|
||||||
return null;
|
const superAdminUid: number = cached.tag("adminAuth").get("superAdminUid");
|
||||||
|
|
||||||
|
const model: SysUser = sysUserMapper.selectOne(
|
||||||
|
new QueryWrapper<SysUser>()
|
||||||
|
.eq("uid", id)
|
||||||
|
.last("limit 1"));
|
||||||
|
Assert.notNull(model, "用户数据不存在");
|
||||||
|
|
||||||
|
const vo: SysUserDetailVo = new SysUserDetailVo();
|
||||||
|
BeanUtils.copyProperties(model, vo);
|
||||||
|
|
||||||
|
const userRoleMPJQueryWrapper: MPJQueryWrapper<SysUserRole> = new MPJQueryWrapper<>();
|
||||||
|
userRoleMPJQueryWrapper.select("sur.*, s.site_id, s.site_name, s.app_type, s.status as siteStatus, s.expire_time")
|
||||||
|
.setAlias("sur")
|
||||||
|
.leftJoin("?_site s ON sur.site_id = s.site_id".replace("?_", this.config.get('tablePrefix')));
|
||||||
|
userRoleMPJQueryWrapper.eq("sur.uid", vo.getUid());
|
||||||
|
const userSiteRoleVoList: SysUserSiteRoleVo[] = sysUserRoleMapper.selectJoinList(SysUserSiteRoleVo.class, userRoleMPJQueryWrapper);
|
||||||
|
vo.setIsSuperAdmin(superAdminUid == id);
|
||||||
|
vo.setRoles(userSiteRoleVoList);
|
||||||
|
return vo;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* add
|
* add
|
||||||
*/
|
*/
|
||||||
async add(...args: any[]): Promise<any> {
|
async add(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
if (checkUserName(addParam.getUsername())) {
|
||||||
return null;
|
throw new AdminException("该用户名已被占用,请更换");
|
||||||
|
}
|
||||||
|
const sysUser: SysUser = new SysUser();
|
||||||
|
BeanUtils.copyProperties(addParam, sysUser);
|
||||||
|
sysUser.setCreateTime(DateUtils.currTime());
|
||||||
|
sysUser.setUpdateTime(DateUtils.currTime());
|
||||||
|
sysUser.setPassword(PasswordEncipher.encode(addParam.getPassword()));
|
||||||
|
sysUserMapper.insert(sysUser);
|
||||||
|
const uid: number = sysUser.getUid();
|
||||||
|
|
||||||
|
//添加用户建站限制
|
||||||
|
const createSiteLimitParamList: SysCreateSiteLimitParam[] = addParam.getCreateSiteLimit();
|
||||||
|
const addList: UserCreateSiteLimit[] = [];
|
||||||
|
if (ObjectUtil.isNotNull(createSiteLimitParamList) && createSiteLimitParamList.size() > 0) {
|
||||||
|
for (const sysCreateSiteLimitParam of createSiteLimitParamList) {
|
||||||
|
const userCreateSiteLimit: UserCreateSiteLimit = new UserCreateSiteLimit();
|
||||||
|
userCreateSiteLimit.setUid(uid);
|
||||||
|
userCreateSiteLimit.setGroupId(sysCreateSiteLimitParam.getGroupId());
|
||||||
|
userCreateSiteLimit.setMonth(sysCreateSiteLimitParam.getMonth());
|
||||||
|
userCreateSiteLimit.setNum(sysCreateSiteLimitParam.getNum());
|
||||||
|
addList.add(userCreateSiteLimit);
|
||||||
|
}
|
||||||
|
userCreateSiteLimitMapper.insert(addList);
|
||||||
|
}
|
||||||
|
return uid;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* edit
|
* edit
|
||||||
*/
|
*/
|
||||||
async edit(...args: any[]): Promise<any> {
|
async edit(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const model: SysUser = sysUserMapper.selectOne(
|
||||||
return null;
|
new QueryWrapper<SysUser>()
|
||||||
|
.eq("uid", uid)
|
||||||
|
.last("limit 1"));
|
||||||
|
Assert.notNull(model, "数据不存在!");
|
||||||
|
const isOffStatus: boolean = false;
|
||||||
|
if (ObjectUtil.isNotNull(editParam.getStatus())) {
|
||||||
|
model.setStatus(editParam.getStatus());
|
||||||
|
if (editParam.getStatus() == StatusEnum.OFF.getStatus()) {
|
||||||
|
isOffStatus = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (ObjectUtil.isNotNull(editParam.getHeadImg())) {
|
||||||
|
model.setHeadImg(editParam.getHeadImg());
|
||||||
|
}
|
||||||
|
if (ObjectUtil.isNotNull(editParam.getRealName())) {
|
||||||
|
model.setRealName(editParam.getRealName());
|
||||||
|
}
|
||||||
|
const isChangePassword: boolean = false;
|
||||||
|
if (ObjectUtil.isNotNull(editParam.getPassword()) && ObjectUtil.isNotEmpty(editParam.getPassword())) {
|
||||||
|
model.setPassword(PasswordEncipher.encode(editParam.getPassword()));
|
||||||
|
isChangePassword = true;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 更新用戶信息
|
||||||
|
*/
|
||||||
|
model.setUpdateTime(DateUtils.currTime());
|
||||||
|
sysUserMapper.updateById(model);
|
||||||
|
if (isOffStatus || isChangePassword) {
|
||||||
|
getLoginService().clearToken(uid, RequestUtils.appType(), "");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* del
|
* del
|
||||||
*/
|
*/
|
||||||
async del(...args: any[]): Promise<any> {
|
async del(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
authService.isSuperAdmin();
|
||||||
return null;
|
const superAdminUid: number = cached.tag("adminAuth").get("superAdminUid");
|
||||||
|
if (superAdminUid === id) {
|
||||||
|
throw new BadRequestException("超级管理员不允许删除");
|
||||||
|
}
|
||||||
|
const count: number = sysUserRoleMapper.selectCount(new QueryWrapper<SysUserRole>().eq("uid", id).ne("site_id", RequestUtils.defaultSiteId()));
|
||||||
|
if (count > 0) {
|
||||||
|
throw new BadRequestException("该用户是一些站点的管理员不允许删除");
|
||||||
|
}
|
||||||
|
|
||||||
|
const model: SysUser = sysUserMapper.selectOne(
|
||||||
|
new QueryWrapper<SysUser>()
|
||||||
|
.eq("uid", id)
|
||||||
|
.last("limit 1"));
|
||||||
|
|
||||||
|
Assert.notNull(model, "数据不存在!");
|
||||||
|
|
||||||
|
sysUserMapper.delete(new QueryWrapper<SysUser>().eq("uid", id));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* getUserInfoByUserName
|
* getUserInfoByUserName
|
||||||
*/
|
*/
|
||||||
async getUserInfoByUserName(...args: any[]): Promise<any> {
|
async getUserInfoByUserName(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const model: SysUser = sysUserMapper.selectOne(new QueryWrapper<SysUser>().eq("username", userName).last("limit 1"));
|
||||||
return null;
|
Assert.notNull(model, "账号或密码错误");
|
||||||
|
const vo: SysUserInfoVo = new SysUserInfoVo();
|
||||||
|
BeanUtils.copyProperties(model, vo);
|
||||||
|
return vo;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* editUserLoginInfo
|
* editUserLoginInfo
|
||||||
*/
|
*/
|
||||||
async editUserLoginInfo(...args: any[]): Promise<any> {
|
async editUserLoginInfo(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const model: SysUser = sysUserMapper.selectOne(
|
||||||
return null;
|
new QueryWrapper<SysUser>()
|
||||||
|
.eq("uid", uid)
|
||||||
|
.last("limit 1"));
|
||||||
|
|
||||||
|
Assert.notNull(model, "数据不存在!");
|
||||||
|
model.setLastTime(DateUtils.currTime());
|
||||||
|
model.setLastIp(IpUtils.getIpAddr(RequestUtils.handler()));
|
||||||
|
model.setLoginCount(model.getLoginCount() + 1);
|
||||||
|
sysUserMapper.updateById(model);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* addSiteUser
|
* addSiteUser
|
||||||
*/
|
*/
|
||||||
async addSiteUser(...args: any[]): Promise<any> {
|
async addSiteUser(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const uid: number = 0;
|
||||||
return null;
|
try {
|
||||||
|
if (ObjectUtil.isNotNull(siteUserParam.getUid()) && siteUserParam.getUid() > 0) {
|
||||||
|
const queryWrapper: QueryWrapper<SysUser> = new QueryWrapper<>();
|
||||||
|
queryWrapper.eq("uid", siteUserParam.getUid());
|
||||||
|
const sysUser: SysUser = sysUserMapper.selectOne(queryWrapper);
|
||||||
|
uid = siteUserParam.getUid();
|
||||||
|
if (ObjectUtil.isNull(sysUser)) {
|
||||||
|
throw new AdminException("USER_NOT_EXIST");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
const sysUserParam: SysUserParam = new SysUserParam();
|
||||||
|
sysUserParam.setHeadImg(siteUserParam.getHeadImg());
|
||||||
|
sysUserParam.setPassword(siteUserParam.getPassword());
|
||||||
|
sysUserParam.setLastIp("");
|
||||||
|
sysUserParam.setLoginCount(0);
|
||||||
|
sysUserParam.setUsername(siteUserParam.getUsername());
|
||||||
|
sysUserParam.setIsDel(0);
|
||||||
|
sysUserParam.setLastTime(DateUtils.currTime());
|
||||||
|
sysUserParam.setStatus(siteUserParam.getStatus());
|
||||||
|
sysUserParam.setRealName(siteUserParam.getRealName());
|
||||||
|
//添加用户
|
||||||
|
uid = this.add(sysUserParam);
|
||||||
|
}
|
||||||
|
const roleIds: string[] = siteUserParam.getRoleIds();
|
||||||
|
const isAdmin: number = siteUserParam.getIsAdmin() == null ? 0 : siteUserParam.getIsAdmin();
|
||||||
|
/**
|
||||||
|
* 创建用户站点管理权限
|
||||||
|
*/
|
||||||
|
const sysUserRoleParam: SysUserRoleParam = new SysUserRoleParam();
|
||||||
|
sysUserRoleParam.setRoleIds(JSONUtil.toJsonStr(roleIds));
|
||||||
|
sysUserRoleParam.setSiteId(siteId);
|
||||||
|
sysUserRoleParam.setUid(uid);
|
||||||
|
sysUserRoleParam.setStatus(siteUserParam.getStatus());
|
||||||
|
sysUserRoleParam.setIsAdmin(isAdmin);
|
||||||
|
sysUserRoleService.add(sysUserRoleParam);
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new AdminException(e.getMessage());
|
||||||
|
}
|
||||||
|
return uid;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* checkUserName
|
* checkUserName
|
||||||
*/
|
*/
|
||||||
async checkUserName(...args: any[]): Promise<any> {
|
async checkUserName(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const queryWrapper: QueryWrapper<SysUser> = new QueryWrapper<>();
|
||||||
return null;
|
queryWrapper.eq("username", userName);
|
||||||
|
const count: number = sysUserMapper.selectCount(queryWrapper);
|
||||||
|
if (count > 0) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* getUserAll
|
* getUserAll
|
||||||
*/
|
*/
|
||||||
async getUserAll(...args: any[]): Promise<any> {
|
async getUserAll(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const queryWrapper: QueryWrapper<SysUser> = new QueryWrapper<>();
|
||||||
return null;
|
queryWrapper.select("uid, username, head_img").orderByDesc("uid");
|
||||||
|
return sysUserMapper.selectList(queryWrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* getUserCreateSiteLimit
|
* getUserCreateSiteLimit
|
||||||
*/
|
*/
|
||||||
async getUserCreateSiteLimit(...args: any[]): Promise<any> {
|
async getUserCreateSiteLimit(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const userCreateSiteLimitList: UserCreateSiteLimit[] = userCreateSiteLimitMapper.selectList(new QueryWrapper<UserCreateSiteLimit>().eq("uid", uid));
|
||||||
return null;
|
const userCreateSiteLimitVoList: SysUserCreateSiteLimitVo[] = [];
|
||||||
|
for (const item of userCreateSiteLimitList) {
|
||||||
|
const userCreateSiteLimitVo: SysUserCreateSiteLimitVo = new SysUserCreateSiteLimitVo();
|
||||||
|
BeanUtil.copyProperties(item, userCreateSiteLimitVo);
|
||||||
|
userCreateSiteLimitVoList.add(userCreateSiteLimitVo);
|
||||||
|
}
|
||||||
|
return userCreateSiteLimitVoList;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* getUserCreateSiteLimitInfo
|
* getUserCreateSiteLimitInfo
|
||||||
*/
|
*/
|
||||||
async getUserCreateSiteLimitInfo(...args: any[]): Promise<any> {
|
async getUserCreateSiteLimitInfo(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const userCreateSiteLimit: UserCreateSiteLimit = userCreateSiteLimitMapper.selectById(id);
|
||||||
return null;
|
const sysUserCreateSiteLimitVo: SysUserCreateSiteLimitVo = new SysUserCreateSiteLimitVo();
|
||||||
|
if (ObjectUtil.isNotNull(userCreateSiteLimit)) {
|
||||||
|
BeanUtil.copyProperties(userCreateSiteLimit, sysUserCreateSiteLimitVo);
|
||||||
|
}
|
||||||
|
return sysUserCreateSiteLimitVo;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* addUserCreateSiteLimit
|
* addUserCreateSiteLimit
|
||||||
*/
|
*/
|
||||||
async addUserCreateSiteLimit(...args: any[]): Promise<any> {
|
async addUserCreateSiteLimit(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
userCreateSiteLimitMapper.delete(new QueryWrapper<UserCreateSiteLimit>().eq("uid", userCreateSiteLimitAddParam.getUid()).eq("group_id", userCreateSiteLimitAddParam.getGroupId()));
|
||||||
return null;
|
const userCreateSiteLimit: UserCreateSiteLimit = new UserCreateSiteLimit();
|
||||||
|
userCreateSiteLimit.setNum(userCreateSiteLimitAddParam.getNum());
|
||||||
|
userCreateSiteLimit.setUid(userCreateSiteLimitAddParam.getUid());
|
||||||
|
userCreateSiteLimit.setMonth(userCreateSiteLimitAddParam.getMonth());
|
||||||
|
userCreateSiteLimit.setGroupId(userCreateSiteLimitAddParam.getGroupId());
|
||||||
|
userCreateSiteLimitMapper.insert(userCreateSiteLimit);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* editUserCreateSiteLimit
|
* editUserCreateSiteLimit
|
||||||
*/
|
*/
|
||||||
async editUserCreateSiteLimit(...args: any[]): Promise<any> {
|
async editUserCreateSiteLimit(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const userCreateSiteLimit: UserCreateSiteLimit = userCreateSiteLimitMapper.selectById(userCreateSiteLimitEditParam.getId());
|
||||||
return null;
|
userCreateSiteLimit.setNum(userCreateSiteLimitEditParam.getNum());
|
||||||
|
userCreateSiteLimit.setMonth(userCreateSiteLimitEditParam.getMonth());
|
||||||
|
userCreateSiteLimitMapper.updateById(userCreateSiteLimit);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* delUserCreateSiteLimit
|
* delUserCreateSiteLimit
|
||||||
*/
|
*/
|
||||||
async delUserCreateSiteLimit(...args: any[]): Promise<any> {
|
async delUserCreateSiteLimit(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
userCreateSiteLimitMapper.deleteById(id);
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* find
|
* find
|
||||||
*/
|
*/
|
||||||
async find(...args: any[]): Promise<any> {
|
async find(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const sysuser: SysUser = sysUserMapper.selectById(uid);
|
||||||
return null;
|
Assert.notNull(sysuser, "用户数据不存在!");
|
||||||
|
return sysuser;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* getUserSelect
|
* getUserSelect
|
||||||
*/
|
*/
|
||||||
async getUserSelect(...args: any[]): Promise<any> {
|
async getUserSelect(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
// 1. 构建查询条件
|
||||||
return null;
|
const qw: MPJQueryWrapper<SysUser> = new MPJQueryWrapper<>();
|
||||||
|
qw.setAlias("u")
|
||||||
|
.leftJoin("?_sys_user_role ur on u.uid = ur.uid".replace("?_", this.config.get('tablePrefix')))
|
||||||
|
.select("u.uid, u.username, u.head_img")
|
||||||
|
.and(wrapper => wrapper.eq("ur.is_admin", 1))
|
||||||
|
.or()
|
||||||
|
.eq("ur.site_id", 0);
|
||||||
|
|
||||||
|
// 2. 获取并过滤用户
|
||||||
|
const userAll: SysUser[] = (username && username.trim() !== '')
|
||||||
|
? getUserAll().stream()
|
||||||
|
.filter(item => item.getUsername() === username)
|
||||||
|
.collect(Collectors.toList())
|
||||||
|
: getUserAll();
|
||||||
|
|
||||||
|
if (CollectionUtils.isEmpty(userAll)) {
|
||||||
|
return List.of();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 3. 获取有角色的用户ID集合
|
||||||
|
const allRoleUserIds: Set<number> = sysUserRoleMapper.selectList(
|
||||||
|
new QueryWrapper<SysUserRole>().select("uid").orderByDesc("id"))
|
||||||
|
.stream()
|
||||||
|
.map(SysUserRole::getUid)
|
||||||
|
.collect(Collectors.toSet());
|
||||||
|
|
||||||
|
// 4. 查询管理员用户
|
||||||
|
qw.orderByDesc("uid");
|
||||||
|
const adminUsers: SysUser[] = sysUserMapper.selectList(qw);
|
||||||
|
|
||||||
|
// 5. 查询无角色用户
|
||||||
|
const noRoleUsers: SysUser[] = [];
|
||||||
|
const noRoleUserIds: number[] = userAll.stream()
|
||||||
|
.map(SysUser::getUid)
|
||||||
|
.filter(uid => !allRoleUserIds.includes(uid))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
|
if (!CollectionUtils.isEmpty(noRoleUserIds)) {
|
||||||
|
noRoleUsers = sysUserMapper.selectList(
|
||||||
|
new QueryWrapper<SysUser>()
|
||||||
|
.select("uid, username, head_img")
|
||||||
|
.in("uid", noRoleUserIds)
|
||||||
|
.orderByDesc("uid"));
|
||||||
|
}
|
||||||
|
|
||||||
|
// 6. 合并结果并去重
|
||||||
|
const resultMap: Record<string, any> = new LinkedHashMap<>();
|
||||||
|
|
||||||
|
adminUsers.forEach(user => {
|
||||||
|
const vo: SysUserInfoVo = new SysUserInfoVo();
|
||||||
|
BeanUtils.copyProperties(user, vo);
|
||||||
|
resultMap.put(user.getUid(), vo);
|
||||||
|
});
|
||||||
|
noRoleUsers.forEach(user => {
|
||||||
|
const vo: SysUserInfoVo = new SysUserInfoVo();
|
||||||
|
BeanUtils.copyProperties(user, vo);
|
||||||
|
resultMap.put(user.getUid(), vo);
|
||||||
|
});
|
||||||
|
|
||||||
|
return new ArrayList<>(resultMap.values());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,31 +14,56 @@ export class SystemServiceImplService {
|
|||||||
* getInfo
|
* getInfo
|
||||||
*/
|
*/
|
||||||
async getInfo(...args: any[]): Promise<any> {
|
async getInfo(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const statSystemVo: StatSystemVo = new StatSystemVo();
|
||||||
return null;
|
statSystemVo.setOs(System.getProperty("os.name", "Linux"));
|
||||||
|
statSystemVo.setEnvironment(System.getProperty("catalina.home"));
|
||||||
|
statSystemVo.setPhpV(System.getProperty("java.version"));
|
||||||
|
|
||||||
|
const statVersionVo: StatVersionVo = new StatVersionVo();
|
||||||
|
statVersionVo.setVersion("202406150001");
|
||||||
|
statVersionVo.setCode("0.4.0");
|
||||||
|
|
||||||
|
statSystemVo.setVersion(statVersionVo);
|
||||||
|
return statSystemVo;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* clearCache
|
* clearCache
|
||||||
*/
|
*/
|
||||||
async clearCache(...args: any[]): Promise<any> {
|
async clearCache(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
cached.getAllKeys().stream().forEach(key => cached.remove(key));
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* getSpreadQrcode
|
* getSpreadQrcode
|
||||||
*/
|
*/
|
||||||
async getSpreadQrcode(...args: any[]): Promise<any> {
|
async getSpreadQrcode(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const vo: SpreadQrcodeVo = new SpreadQrcodeVo();
|
||||||
return null;
|
|
||||||
|
try {
|
||||||
|
const data: Record<string, any> = {};
|
||||||
|
for (SpreadQrcodeParam.Param qrcodeParam : param.getParams()) {
|
||||||
|
const jsonArray: JSONArray = JSONUtil.parseArray(qrcodeParam);
|
||||||
|
const jsonObject: Record<string, any> = JSONUtil.parseObj(jsonArray);
|
||||||
|
data.put(jsonObject.getStr("name"), qrcodeParam.getColumnValue());
|
||||||
|
}
|
||||||
|
const dir: string = "upload/qrcode/" + RequestUtils.siteId() + "/" + param.getFolder();
|
||||||
|
vo.setWeappPath(QrcodeUtils.qrcodeToFile(RequestUtils.siteId(), "weapp", "", param.getPage(), data, dir));
|
||||||
|
} catch (Exception e) {
|
||||||
|
|
||||||
|
}
|
||||||
|
return vo;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* getDatabaseVersion
|
* getDatabaseVersion
|
||||||
*/
|
*/
|
||||||
async getDatabaseVersion(...args: any[]): Promise<any> {
|
async getDatabaseVersion(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
try (const connection: Connection = dataSource.getConnection()) {
|
||||||
return null;
|
DatabaseMetaData metaData = connection.getMetaData();
|
||||||
|
return metaData.getDatabaseProductVersion();
|
||||||
|
}catch (SQLException e) {
|
||||||
|
return "未知";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,111 +14,503 @@ export class UpgradeServiceImplService {
|
|||||||
* setUpgradeService
|
* setUpgradeService
|
||||||
*/
|
*/
|
||||||
async setUpgradeService(...args: any[]): Promise<any> {
|
async setUpgradeService(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
this.upgradeService = upgradeService;
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* upgradeCheck
|
* upgradeCheck
|
||||||
*/
|
*/
|
||||||
async upgradeCheck(...args: any[]): Promise<any> {
|
async upgradeCheck(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
if (this.config.get('runActive') === "dev") throw new BadRequestException("开发环境下请先关闭服务启动webroot/jar下的web-app-boot-exec进行升级");
|
||||||
return null;
|
|
||||||
|
const upgradeCheck: boolean = true;
|
||||||
|
|
||||||
|
const checkResult: Record<string, any> = new Record<string, any>();
|
||||||
|
const rootPath: string = "";
|
||||||
|
const runtimePath: string = "";
|
||||||
|
const readableDir: JSONArray = new JSONArray();
|
||||||
|
const writeDir: JSONArray = new JSONArray();
|
||||||
|
|
||||||
|
if (this.config.get('envType') === "dev") {
|
||||||
|
rootPath = this.config.get('projectRoot') + "/";
|
||||||
|
runtimePath = rootPath;
|
||||||
|
|
||||||
|
readableDir.put(new Record<string, any>().set("dir", rootPath + "niucloud-addon").set("status", true));
|
||||||
|
writeDir.put(new Record<string, any>().set("dir", rootPath + "niucloud-addon").set("status", true));
|
||||||
|
readableDir.put(new Record<string, any>().set("dir", rootPath + "webroot").set("status", true));
|
||||||
|
writeDir.put(new Record<string, any>().set("dir", rootPath + "webroot").set("status", true));
|
||||||
|
} else {
|
||||||
|
rootPath = this.config.get('webRoot') + "/";
|
||||||
|
runtimePath = rootPath + "runtime/";
|
||||||
|
|
||||||
|
readableDir.put(new Record<string, any>().set("dir", runtimePath).set("status", true));
|
||||||
|
writeDir.put(new Record<string, any>().set("dir", runtimePath).set("status", true));
|
||||||
|
}
|
||||||
|
|
||||||
|
readableDir.put(new Record<string, any>().set("dir", runtimePath + "admin").set("status", true));
|
||||||
|
readableDir.put(new Record<string, any>().set("dir", runtimePath + "uni-app").set("status", true));
|
||||||
|
readableDir.put(new Record<string, any>().set("dir", runtimePath + "web").set("status", true));
|
||||||
|
|
||||||
|
writeDir.put(new Record<string, any>().set("dir", runtimePath + "admin").set("status", true));
|
||||||
|
writeDir.put(new Record<string, any>().set("dir", runtimePath + "uni-app").set("status", true));
|
||||||
|
writeDir.put(new Record<string, any>().set("dir", runtimePath + "web").set("status", true));
|
||||||
|
|
||||||
|
for (const i of number = 0; i < readableDir.size(); i++) {
|
||||||
|
const dir: Record<string, any> = readableDir.getJSONObject(i);
|
||||||
|
dir.set("status", dir.getStr("dir").canRead());
|
||||||
|
dir.set("dir", dir.getStr("dir").replace(rootPath, ""));
|
||||||
|
readableDir.set(i, dir);
|
||||||
|
if (!dir.getBool("status")) upgradeCheck = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const i of number = 0; i < writeDir.size(); i++) {
|
||||||
|
const dir: Record<string, any> = writeDir.getJSONObject(i);
|
||||||
|
dir.set("status", dir.getStr("dir").canWrite());
|
||||||
|
dir.set("dir", dir.getStr("dir").replace(rootPath, ""));
|
||||||
|
writeDir.set(i, dir);
|
||||||
|
if (!dir.getBool("status")) upgradeCheck = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
checkResult.put("is_pass", upgradeCheck);
|
||||||
|
checkResult.put("dir", new Record<string, any>().set("is_readable", readableDir).set("is_write", writeDir));
|
||||||
|
return checkResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* getUpgradeContent
|
* getUpgradeContent
|
||||||
*/
|
*/
|
||||||
async getUpgradeContent(...args: any[]): Promise<any> {
|
async getUpgradeContent(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const instance: NiucloudUtils = NiucloudUtils.getInstance();
|
||||||
return null;
|
const vo: UpgradeContentVo = new UpgradeContentVo();
|
||||||
|
|
||||||
|
const apps: Record<string, any>[] = [];
|
||||||
|
|
||||||
|
if (addon.length === 0) {
|
||||||
|
const query: Record<string, any> = {};
|
||||||
|
query.put("product_key", instance.getProductKey());
|
||||||
|
query.put("app_key", this.config.get('appKey'));
|
||||||
|
query.put("version", this.config.get('version'));
|
||||||
|
apps.add(query);
|
||||||
|
} else {
|
||||||
|
for (const key of addon.split(",")) {
|
||||||
|
const addonModel: Addon = addonMapper.selectOne(new QueryWrapper<Addon>().eq("`key`", key).select("version,type"));
|
||||||
|
const query: Record<string, any> = {};
|
||||||
|
query.put("product_key", instance.getProductKey());
|
||||||
|
query.put("app_key", key);
|
||||||
|
query.put("version", addonModel.getVersion());
|
||||||
|
if (addonModel.getType() === AddonTypeEnum.APP.getType()) {
|
||||||
|
apps.addFirst(query);
|
||||||
|
} else {
|
||||||
|
apps.add(query);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const item of apps) {
|
||||||
|
const content: Record<string, any> = NiucloudUtils.Niucloud.get("member_app_upgrade/content", item).getJSONObject("data");
|
||||||
|
if (content != null) {
|
||||||
|
UpgradeContentVo.const contentVo: Content = JSONUtil.toBean(content, UpgradeContentVo.Content.class);
|
||||||
|
vo.getContent().add(contentVo);
|
||||||
|
vo.getUpgradeApps().add(contentVo.getApp().getAppKey());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
vo.setLastBackup(sysBackupRecordsMapper.selectOne(new QueryWrapper<SysBackupRecords>()
|
||||||
|
.eq("status", "complete")
|
||||||
|
.orderByDesc("complete_time")
|
||||||
|
.last("limit 1")
|
||||||
|
));
|
||||||
|
|
||||||
|
return vo;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* upgrade
|
* upgrade
|
||||||
*/
|
*/
|
||||||
async upgrade(...args: any[]): Promise<any> {
|
async upgrade(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
if (this.config.get('runActive') === "dev") throw new BadRequestException("开发环境下请先关闭服务启动webroot/jar下的web-app-boot-exec进行升级");
|
||||||
return null;
|
if (getUpgradeTask() != null) throw new BadRequestException("已经有正在升级中的任务");
|
||||||
|
|
||||||
|
const upgradeContent: UpgradeContentVo = getUpgradeContent(upgradeParam.getAddon());
|
||||||
|
upgradeContent.setContent(upgradeContent.getContent().stream().filter(c => c.getVersionList().size() > 0).toList());
|
||||||
|
upgradeContent.setUpgradeApps(upgradeContent.getContent().stream().map(c => c.getApp().getAppKey()).toList());
|
||||||
|
if (upgradeContent.getContent().size() == 0) throw new BadRequestException("没有获取到可以升级的内容");
|
||||||
|
|
||||||
|
const instance: NiucloudUtils = NiucloudUtils.getInstance();
|
||||||
|
|
||||||
|
// 获取下载const actionQuery: token
|
||||||
|
Map<String, Object> = {};
|
||||||
|
actionQuery.put("data[product_key]", instance.getProductKey());
|
||||||
|
actionQuery.put("data[framework_version]", this.config.get('version'));
|
||||||
|
actionQuery.put("data[app_key]", upgradeContent.getContent().get(0).getApp().getAppKey());
|
||||||
|
actionQuery.put("data[version]", upgradeContent.getContent().get(0).getVersion());
|
||||||
|
|
||||||
|
const actionToken: Record<string, any> = niucloudService.getActionToken("upgrade", actionQuery);
|
||||||
|
|
||||||
|
const query: Record<string, any> = {};
|
||||||
|
query.put("authorize_code", instance.getCode());
|
||||||
|
query.put("token", actionToken == null ? "" : actionToken.getStr("token"));
|
||||||
|
const response: HttpResponse = new NiucloudUtils.Cloud().build("cloud/upgrade").query(query).method(Method.GET).execute();
|
||||||
|
|
||||||
|
if (response.getStatus() != 200) throw new BadRequestException("升级请求失败");
|
||||||
|
|
||||||
|
const body: Record<string, any> = JSONUtil.parseObj(response.body());
|
||||||
|
if (body.getInt("code") === 0) throw new Error(body.getStr("msg"));
|
||||||
|
|
||||||
|
const vo: UpgradeTaskVo = new UpgradeTaskVo();
|
||||||
|
vo.setEnvType(this.config.get('envType'));
|
||||||
|
vo.setUpgradeTime(DateUtil.now());
|
||||||
|
vo.setAddon(actionQuery.get("data[app_key]"));
|
||||||
|
vo.setKey(RandomUtil.randomString(10));
|
||||||
|
vo.setUpgrade(actionQuery);
|
||||||
|
vo.setStep("requestUpgrade");
|
||||||
|
vo.getExecuted().add("requestUpgrade");
|
||||||
|
vo.getLog().add(vo.getSteps().get("requestUpgrade").getTitle());
|
||||||
|
vo.setParams(query);
|
||||||
|
vo.setUpgradeContent(upgradeContent);
|
||||||
|
|
||||||
|
if (!upgradeParam.getIsNeedBackup()) {
|
||||||
|
vo.getSteps().remove("backupCode");
|
||||||
|
vo.getSteps().remove("backupSql");
|
||||||
|
}
|
||||||
|
if (!upgradeParam.getIsNeedCloudbuild()) {
|
||||||
|
vo.getSteps().remove("cloudBuild");
|
||||||
|
vo.getSteps().remove("gteCloudBuildLog");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 添加升级记录
|
||||||
|
const content: JSONArray = new JSONArray();
|
||||||
|
upgradeContent.getContent().stream().forEach(i => {
|
||||||
|
const item: Record<string, any> = new Record<string, any>();
|
||||||
|
item.set("app_key", i.getApp().getAppKey());
|
||||||
|
item.putByPath("app.name", i.getApp().getAppName());
|
||||||
|
item.set("version", i.getVersion());
|
||||||
|
item.set("upgrade_version", i.getUpgradeVersion());
|
||||||
|
content.put(item);
|
||||||
|
});
|
||||||
|
const record: SysUpgradeRecordsParam = new SysUpgradeRecordsParam();
|
||||||
|
record.setUpgradeKey(vo.getKey());
|
||||||
|
record.setStatus(UpgradeRecordStatusEnum.STATUS_READY.getStatus());
|
||||||
|
record.setContent(content.toString());
|
||||||
|
sysUpgradeRecordsService.add(record);
|
||||||
|
|
||||||
|
setUpgradeTaskCache(vo);
|
||||||
|
return vo;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* getUpgradeTask
|
* getUpgradeTask
|
||||||
*/
|
*/
|
||||||
async getUpgradeTask(...args: any[]): Promise<any> {
|
async getUpgradeTask(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const cache: Cached = CacheFactory.getCacheOperator();
|
||||||
return null;
|
const data: any = cache.get("upgrade");
|
||||||
|
if (data == null) return null;
|
||||||
|
return JSONUtil.toBean(JSONUtil.parseObj(data), UpgradeTaskVo.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* setUpgradeTaskCache
|
* setUpgradeTaskCache
|
||||||
*/
|
*/
|
||||||
async setUpgradeTaskCache(...args: any[]): Promise<any> {
|
async setUpgradeTaskCache(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const cache: Cached = CacheFactory.getCacheOperator();
|
||||||
return null;
|
cache.put("upgrade", JSONUtil.parseObj(vo).toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* clearUpgradeTask
|
* clearUpgradeTask
|
||||||
*/
|
*/
|
||||||
async clearUpgradeTask(...args: any[]): Promise<any> {
|
async clearUpgradeTask(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
if (delayed > 0) {
|
||||||
return null;
|
try {
|
||||||
|
Thread.sleep(delayed * 1000);
|
||||||
|
} catch (Exception e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const cache: Cached = CacheFactory.getCacheOperator();
|
||||||
|
cache.remove("upgrade");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* execute
|
* execute
|
||||||
*/
|
*/
|
||||||
async execute(...args: any[]): Promise<any> {
|
async execute(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const vo: UpgradeTaskVo = this.getUpgradeTask();
|
||||||
return null;
|
if (vo == null) return;
|
||||||
|
|
||||||
|
if (ObjectUtil.isNotEmpty(vo.getStatus()) && vo.getStatus() === "restarting") return;
|
||||||
|
|
||||||
|
const steps: string[] = vo.getSteps().keySet().stream().collect(Collectors.toList());
|
||||||
|
const step: string = steps.indexOf(vo.getStep()) < steps.size() - 1 ? steps.get(steps.indexOf(vo.getStep()) + 1) : "";
|
||||||
|
|
||||||
|
if (!step.length === 0) {
|
||||||
|
if (!vo.getExecuted().includes(step)) {
|
||||||
|
vo.getExecuted().add(step);
|
||||||
|
vo.getLog().add(vo.getSteps().get(step).getTitle());
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
const param: Record<string, any> = null;
|
||||||
|
param = (Map<String, Object>) dynamicMethodCall(step, vo);
|
||||||
|
if (param != null) {
|
||||||
|
vo.setParams(param);
|
||||||
|
} else {
|
||||||
|
vo.setStep(step);
|
||||||
|
vo.setParams(null);
|
||||||
|
vo.setAddon(vo.getUpgradeApps().get(0));
|
||||||
|
}
|
||||||
|
setUpgradeTaskCache(vo);
|
||||||
|
} catch (Exception e) {
|
||||||
|
if (e.getMessage().includes("队列")) {
|
||||||
|
throw e;
|
||||||
|
} else {
|
||||||
|
vo.setStep(step);
|
||||||
|
vo.getError().add(e.getMessage());
|
||||||
|
setUpgradeTaskCache(vo);
|
||||||
|
this.upgradeErrorHandle(vo);
|
||||||
|
e.printStackTrace();
|
||||||
|
console.log("升级异常.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* coverCode
|
||||||
|
*/
|
||||||
|
async coverCode(...args: any[]): Promise<any> {
|
||||||
|
if (this.config.get('envType') === "dev") {
|
||||||
|
vo.getUpgradeContent().getContent().forEach(item => {
|
||||||
|
const appKey: string = item.getApp().getAppKey();
|
||||||
|
const codeDir: string = upgradeDir(vo + "/download/" + appKey);
|
||||||
|
|
||||||
|
// 判断目录存在并且不为空
|
||||||
|
if (fs.existsSync(codeDir) && fs.readdirSync(codeDir).length > 0) {
|
||||||
|
item.getVersionList().stream().collect(Collectors.collectingAndThen(
|
||||||
|
Collectors.toList(),
|
||||||
|
l => {
|
||||||
|
Collections.reverse(l);
|
||||||
|
return l.stream();
|
||||||
|
})).forEach(version => {
|
||||||
|
// 如果是框架
|
||||||
|
const rootDir: string = null;
|
||||||
|
if (appKey === this.config.get('appKey')) {
|
||||||
|
rootDir = this.config.get('projectRoot');
|
||||||
|
} else {
|
||||||
|
rootDir = this.config.get('webRootDownAddon', appKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 处理文件变更记录
|
||||||
|
const changeRecord: string = codeDir, version.getVersionNo( + ".txt");
|
||||||
|
if (fs.existsSync(changeRecord)) {
|
||||||
|
// 移除新版本删除的文件
|
||||||
|
const change: string[] = null;
|
||||||
|
try {
|
||||||
|
change = Arrays.asList(FileUtils.readFileToString(changeRecord, "UTF-8").split("\n"));
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new Error(e);
|
||||||
|
}
|
||||||
|
if (ObjectUtil.isNotEmpty(change)) {
|
||||||
|
for (const line of change) {
|
||||||
|
String[] content = line.split(" ");
|
||||||
|
if (content[0] === "-") {
|
||||||
|
(rootDir, content[2]).deleteOnExit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const changeDir: string = codeDir, version.getVersionNo();
|
||||||
|
if (fs.existsSync(changeDir)) {
|
||||||
|
try {
|
||||||
|
FileUtils.copyDirectory(changeDir, rootDir);
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new Error(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const projectDir: string = this.config.get('projectNiucloudAddon', appKey);
|
||||||
|
if (fs.existsSync(projectDir)) {
|
||||||
|
try {
|
||||||
|
FileUtils.copyDirectory(this.config.get('webRootDownAddon' + appKey + "/java"), projectDir);
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new Error(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 合并resource
|
||||||
|
try {
|
||||||
|
FileUtils.copyDirectory(this.config.get('webRootDownAddon' + appKey + "/resource"), this.config.get('webRootDownResource', appKey));
|
||||||
|
} catch (IOException e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
vo.setStatus("restarting");
|
||||||
|
setUpgradeTaskCache(vo);
|
||||||
|
} else {
|
||||||
|
vo.setStep("coverCode");
|
||||||
|
vo.setStatus("restarting");
|
||||||
|
setUpgradeTaskCache(vo);
|
||||||
|
FileUtils.writeStringToFile(upgradeDir(vo, "upgrade.json"), JSONUtil.parseObj(vo.getUpgradeContent()).toString(), "UTF-8");
|
||||||
|
PipeNameUtils.noticeBootRestartByUpgrade(this.config.get('applicationName'), vo.getKey(), vo.getUpgradeContent().getLastBackup().getBackupKey());
|
||||||
|
Thread.sleep(3000);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* handleVue
|
||||||
|
*/
|
||||||
|
async handleVue(...args: any[]): Promise<any> {
|
||||||
|
const envs: WebAppEnvs = this.config;
|
||||||
|
|
||||||
|
for (const key of vo.getUpgradeApps()) {
|
||||||
|
if (!key === this.config.get('appKey')) {
|
||||||
|
const sourceDir: string = envs.webRootDownAddon + key;
|
||||||
|
if (fs.existsSync(sourceDir)) {
|
||||||
|
addonInstallTools.installVue(key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const addons: string[] = addonMapper.selectList(new MPJQueryWrapper<Addon>()
|
||||||
|
.select("`key`")
|
||||||
|
.eq("status", AddonStatusEnum.ON.getCode()))
|
||||||
|
.stream().map(i => i.getKey()).collect(Collectors.toList())
|
||||||
|
;
|
||||||
|
|
||||||
|
// 处理pages.json
|
||||||
|
if (envs.webRoot + "uni-app/".exists()) addonInstallTools.handlePagesJson(envs.webRoot + "/uni-app/", addons);
|
||||||
|
if (envs.webRootDownRuntime + "uni-app/".exists()) addonInstallTools.handlePagesJson(envs.webRootDownRuntime + "/uni-app/", addons);
|
||||||
|
|
||||||
|
// 处理组件
|
||||||
|
if (envs.webRoot + "uni-app/".exists()) addonInstallTools.handleUniappComponent(envs.webRoot + "/uni-app/", addons);
|
||||||
|
if (envs.webRootDownRuntime + "uni-app/".exists()) addonInstallTools.handleUniappComponent(envs.webRootDownRuntime + "/uni-app/", addons);
|
||||||
|
|
||||||
|
// 处理语言包
|
||||||
|
for (const addon of addons) {
|
||||||
|
addonInstallTools.setAddon(addon);
|
||||||
|
if (envs.webRoot + "uni-app/".exists()) addonInstallTools.mergeUniappLocale(envs.webRoot + "/uni-app/", "install");
|
||||||
|
if (envs.webRootDownRuntime + "uni-app/".exists()) addonInstallTools.mergeUniappLocale(envs.webRootDownRuntime + "/uni-app/", "install");
|
||||||
|
|
||||||
|
addonInstallTools.installDepend(addon);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* cloudBuild
|
* cloudBuild
|
||||||
*/
|
*/
|
||||||
async cloudBuild(...args: any[]): Promise<any> {
|
async cloudBuild(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
cloudBuildService.build("build");
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* upgradeComplete
|
* upgradeComplete
|
||||||
*/
|
*/
|
||||||
async upgradeComplete(...args: any[]): Promise<any> {
|
async upgradeComplete(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
vo.setStatus("success");
|
||||||
return null;
|
|
||||||
|
for (const key of vo.getUpgradeApps()) {
|
||||||
|
if (!key === this.config.get('appKey')) {
|
||||||
|
const addon: Addon = JSONUtil.toBean(coreAddonService.getAddonConfig(key), Addon.class);
|
||||||
|
coreAddonService.set(addon);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const backupDir: string = upgradeDir(vo);
|
||||||
|
FileUtil.writeUtf8String(JSONUtil.toJsonPrettyStr(JSONUtil.parseObj(vo)), backupDir, DateUtil.now( + ".log"));
|
||||||
|
|
||||||
|
// 变更升级记录
|
||||||
|
const editParam: SysUpgradeRecordsParam = new SysUpgradeRecordsParam();
|
||||||
|
editParam.setStatus(UpgradeRecordStatusEnum.STATUS_COMPLETE.getStatus());
|
||||||
|
editParam.setCompleteTime(System.currentTimeMillis() / 1000);
|
||||||
|
sysUpgradeRecordsService.edit(vo.getKey(), editParam);
|
||||||
|
|
||||||
|
upgradeService.clearUpgradeTask(5);
|
||||||
|
|
||||||
|
cloudBuildService.clearBuildTask();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* upgradeErrorHandle
|
* upgradeErrorHandle
|
||||||
*/
|
*/
|
||||||
async upgradeErrorHandle(...args: any[]): Promise<any> {
|
async upgradeErrorHandle(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
LinkedHashMap<String, UpgradeTaskVo.const steps: Step> = new LinkedHashMap<>();
|
||||||
return null;
|
steps.put("rollback", new UpgradeTaskVo.Step("rollback", "升级失败开始回滚"));
|
||||||
|
|
||||||
|
if (vo.getExecuted().includes("coverCode")) {
|
||||||
|
steps.put("restoreCover", new UpgradeTaskVo.Step("restoreCover", "恢复变更文件"));
|
||||||
|
}
|
||||||
|
if (vo.getExecuted().includes("handleUpgrade")) {
|
||||||
|
steps.put("restoreDatabase", new UpgradeTaskVo.Step("restoreDatabase", "恢复数据库"));
|
||||||
|
}
|
||||||
|
steps.put("restoreComplete", new UpgradeTaskVo.Step("restoreComplete", "回滚完成"));
|
||||||
|
|
||||||
|
vo.setSteps(steps);
|
||||||
|
vo.setStep("rollback");
|
||||||
|
vo.getLog().add(steps.get("rollback").getTitle());
|
||||||
|
vo.getExecuted().add("rollback");
|
||||||
|
|
||||||
|
setUpgradeTaskCache(vo);
|
||||||
|
|
||||||
|
// 变更升级记录
|
||||||
|
const editParam: SysUpgradeRecordsParam = new SysUpgradeRecordsParam();
|
||||||
|
editParam.setStatus(UpgradeRecordStatusEnum.STATUS_FAIL.getStatus());
|
||||||
|
editParam.setFailReason(JSONUtil.toJsonPrettyStr(vo.getError()));
|
||||||
|
sysUpgradeRecordsService.edit(vo.getKey(), editParam);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* operate
|
* operate
|
||||||
*/
|
*/
|
||||||
async operate(...args: any[]): Promise<any> {
|
async operate(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const vo: UpgradeTaskVo = this.getUpgradeTask();
|
||||||
return null;
|
if (vo == null) return;
|
||||||
|
|
||||||
|
switch (operate) {
|
||||||
|
case "local":
|
||||||
|
vo.setStep("gteCloudBuildLog");
|
||||||
|
setUpgradeTaskCache(vo);
|
||||||
|
break;
|
||||||
|
case "rollback":
|
||||||
|
vo.getError().add("失败原因:一键云编译队列任务过多");
|
||||||
|
upgradeErrorHandle(vo);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* restoreComplete
|
* restoreComplete
|
||||||
*/
|
*/
|
||||||
async restoreComplete(...args: any[]): Promise<any> {
|
async restoreComplete(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
vo.setStatus("rollback");
|
||||||
return null;
|
upgradeService.clearUpgradeTask(5);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* dynamicMethodCall
|
* dynamicMethodCall
|
||||||
*/
|
*/
|
||||||
async dynamicMethodCall(...args: any[]): Promise<any> {
|
async dynamicMethodCall(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
try {
|
||||||
|
// 获取当前类的 Class 对象
|
||||||
|
Class<?> clazz = this.getClass();
|
||||||
|
// 获取方法对象
|
||||||
|
java.lang.reflect.const method: Method = clazz.getMethod(methodName, extractParameterTypes(args));
|
||||||
|
// 调用方法
|
||||||
|
console.log("dynamicMethodCall method:" + methodName);
|
||||||
|
const result: any = method.invoke(this, args);
|
||||||
|
if (method.getReturnType() == void.class) {
|
||||||
|
return null;
|
||||||
|
} else {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
} catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
|
||||||
|
if (e instanceof InvocationTargetException) {
|
||||||
|
((InvocationTargetException) e).getCause().printStackTrace();
|
||||||
|
throw new BadRequestException(((InvocationTargetException) e).getCause().getMessage());
|
||||||
|
} else {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -14,23 +14,99 @@ export class StorageConfigServiceImplService {
|
|||||||
* getStorageList
|
* getStorageList
|
||||||
*/
|
*/
|
||||||
async getStorageList(...args: any[]): Promise<any> {
|
async getStorageList(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
return coreStorageService.getStorageList(RequestUtils.siteId());
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* getStorageConfig
|
* getStorageConfig
|
||||||
*/
|
*/
|
||||||
async getStorageConfig(...args: any[]): Promise<any> {
|
async getStorageConfig(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const storageTypeList: Record<string, any> = UploadLoader.getType();
|
||||||
return null;
|
if (ObjectUtil.isNull(storageTypeList.get(storageType))) {
|
||||||
|
throw new AdminException("OSS_TYPE_NOT_EXIST");
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 获取配置
|
||||||
|
*/
|
||||||
|
const storageConfig: Record<string, any> = coreStorageService.getStorageConfig(RequestUtils.siteId());
|
||||||
|
|
||||||
|
const storageValues: Record<string, any> = JSONUtil.parseObj(storageTypeList.get(storageType));
|
||||||
|
const coreStorAgeConfigVo: CoreStorAgeConfigVo = new CoreStorAgeConfigVo();
|
||||||
|
coreStorAgeConfigVo.setStorageType(storageType);
|
||||||
|
coreStorAgeConfigVo.setIsUse(storageType === storageConfig.get("default") ? StorageEnum.ON.getCode() : StorageEnum.OFF.getCode());
|
||||||
|
coreStorAgeConfigVo.setName(storageValues.get("name").toString());
|
||||||
|
coreStorAgeConfigVo.setComponent(storageValues.get("component").toString());
|
||||||
|
|
||||||
|
const encryptParams: JSONArray = ObjectUtil.defaultIfNull(storageValues.getJSONArray("encrypt_params"), new JSONArray());
|
||||||
|
|
||||||
|
const params: Record<string, any> = new Record<string, any>();
|
||||||
|
if (ObjectUtil.isNotNull(storageValues.get("params"))) {
|
||||||
|
const valuesParams: Record<string, any> = JSONUtil.parseObj(storageValues.get("params"));
|
||||||
|
const configParams: Record<string, any> = new Record<string, any>();
|
||||||
|
if (ObjectUtil.isNotNull(storageConfig.get(storageType))) {
|
||||||
|
configParams = JSONUtil.parseObj(storageConfig.get(storageType));
|
||||||
|
}
|
||||||
|
for (const paramsKey of valuesParams.keySet()) {
|
||||||
|
const itemParam: Record<string, any> = new Record<string, any>();
|
||||||
|
const paramsValues: string = valuesParams.get(paramsKey).toString();
|
||||||
|
itemParam.set("name", paramsValues);
|
||||||
|
const value: string = configParams.getStr(paramsKey);
|
||||||
|
if (encryptParams.includes(paramsKey) && ObjectUtil.isNotEmpty(value)) {
|
||||||
|
value = StringUtils.hide(value, 0, value.length());
|
||||||
|
}
|
||||||
|
itemParam.set("value", value);
|
||||||
|
params.set(paramsKey, itemParam);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
coreStorAgeConfigVo.setParams(params);
|
||||||
|
return coreStorAgeConfigVo;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* setStorageConfig
|
* setStorageConfig
|
||||||
*/
|
*/
|
||||||
async setStorageConfig(...args: any[]): Promise<any> {
|
async setStorageConfig(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const storageTypeList: Record<string, any> = UploadLoader.getType();
|
||||||
return null;
|
if (ObjectUtil.isNull(storageTypeList.get(storageType))) {
|
||||||
|
throw new AdminException("云存储类型不存在");
|
||||||
|
}
|
||||||
|
if (!storageType === FileEnum.LOCAL.getCode()) {
|
||||||
|
const domain: string = storageData.getStr("domain");
|
||||||
|
if (domain.indexOf("http://") < 0 && domain.indexOf("https://") < 0) {
|
||||||
|
throw new AdminException("空间域名请补全http://或https://");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 获取配置
|
||||||
|
*/
|
||||||
|
const storageConfig: Record<string, any> = coreStorageService.getStorageConfig(RequestUtils.siteId());
|
||||||
|
|
||||||
|
const storageValues: Record<string, any> = JSONUtil.parseObj(storageTypeList.get(storageType));
|
||||||
|
if (storageData.getInt("is_use") == 1) {
|
||||||
|
storageConfig.set("default", storageType);
|
||||||
|
} else {
|
||||||
|
if (storageData.getStr("storage_type") === storageConfig.get("default")) {
|
||||||
|
storageConfig.set("default", "");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const configParams: Record<string, any> = new Record<string, any>();
|
||||||
|
if (ObjectUtil.isNotNull(storageConfig.get(storageType))) {
|
||||||
|
configParams = JSONUtil.parseObj(storageConfig.get(storageType));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ObjectUtil.isNotNull(storageValues.get("params"))) {
|
||||||
|
const valuesParams: Record<string, any> = JSONUtil.parseObj(storageValues.get("params"));
|
||||||
|
for (const paramsKey of valuesParams.keySet()) {
|
||||||
|
const value: string = storageData.getStr(paramsKey);
|
||||||
|
if (!value.includes("*")) {
|
||||||
|
configParams.set(paramsKey, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
storageConfig.set(storageType, configParams);
|
||||||
|
|
||||||
|
coreConfigService.setConfig(RequestUtils.siteId(), "STORAGE", storageConfig);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,31 +14,79 @@ export class VerifierServiceImplService {
|
|||||||
* list
|
* list
|
||||||
*/
|
*/
|
||||||
async list(...args: any[]): Promise<any[]> {
|
async list(...args: any[]): Promise<any[]> {
|
||||||
// TODO: 实现业务逻辑
|
const page: number = pageParam.getPage();
|
||||||
return [];
|
const limit: number = pageParam.getLimit();
|
||||||
|
|
||||||
|
const queryWrapper: MPJQueryWrapper<Verifier> = new MPJQueryWrapper<>();
|
||||||
|
queryWrapper.setAlias("v").innerJoin("?_member m ON v.member_id = m.member_id".replace("?_", this.config.get('tablePrefix')));
|
||||||
|
queryWrapper.select("v.*,m.member_no,m.username,m.nickname,m.mobile,m.headimg");
|
||||||
|
queryWrapper.eq("v.site_id", RequestUtils.siteId());
|
||||||
|
queryWrapper.orderByDesc("id");
|
||||||
|
|
||||||
|
const iPage: IPage<VerifierVo> = verifierMapper.selectJoinPage(new Page<>(page, limit), VerifierVo.class, queryWrapper);
|
||||||
|
const list: VerifierListVo[] = [];
|
||||||
|
for (const item of iPage.getRecords()) {
|
||||||
|
const vo: VerifierListVo = new VerifierListVo();
|
||||||
|
BeanUtils.copyProperties(item, vo);
|
||||||
|
|
||||||
|
const memberInfoVo: MemberBriefInfoVo = new MemberBriefInfoVo();
|
||||||
|
BeanUtils.copyProperties(item, memberInfoVo);
|
||||||
|
vo.setMember(memberInfoVo);
|
||||||
|
|
||||||
|
list.add(vo);
|
||||||
|
}
|
||||||
|
return PageResult.build(page, limit, iPage.getTotal()).setData(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* all
|
* all
|
||||||
*/
|
*/
|
||||||
async all(...args: any[]): Promise<any> {
|
async all(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const queryWrapper: MPJQueryWrapper<Verifier> = new MPJQueryWrapper<>();
|
||||||
return null;
|
queryWrapper.setAlias("v").innerJoin("?_member m ON v.member_id = m.member_id".replace("?_", this.config.get('tablePrefix')));
|
||||||
|
queryWrapper.select("v.*,m.member_no,m.username,m.nickname,m.mobile,m.headimg");
|
||||||
|
queryWrapper.eq("v.site_id", RequestUtils.siteId());
|
||||||
|
queryWrapper.orderByDesc("id");
|
||||||
|
|
||||||
|
const verifierList: VerifierVo[] = verifierMapper.selectJoinList(VerifierVo.class, queryWrapper);
|
||||||
|
|
||||||
|
const list: VerifierListVo[] = [];
|
||||||
|
for (const item of verifierList) {
|
||||||
|
const vo: VerifierListVo = new VerifierListVo();
|
||||||
|
BeanUtils.copyProperties(item, vo);
|
||||||
|
|
||||||
|
const memberInfoVo: MemberBriefInfoVo = new MemberBriefInfoVo();
|
||||||
|
BeanUtils.copyProperties(item, memberInfoVo);
|
||||||
|
vo.setMember(memberInfoVo);
|
||||||
|
|
||||||
|
list.add(vo);
|
||||||
|
}
|
||||||
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* add
|
* add
|
||||||
*/
|
*/
|
||||||
async add(...args: any[]): Promise<any> {
|
async add(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const member: Member = memberMapper.selectOne(new QueryWrapper<Member>().select("member_id").eq("member_id", addParam.getMemberId()).eq("site_id", RequestUtils.siteId()));
|
||||||
return null;
|
Assert.notNull(member, "会员不存在");
|
||||||
|
|
||||||
|
const verifier: Verifier = verifierMapper.selectOne(new QueryWrapper<Verifier>().select("id").eq("member_id", addParam.getMemberId()).eq("site_id", RequestUtils.siteId()));
|
||||||
|
if (ObjectUtil.isNotEmpty(verifier)) return;
|
||||||
|
|
||||||
|
const model: Verifier = new Verifier();
|
||||||
|
model.setSiteId(RequestUtils.siteId());
|
||||||
|
model.setMemberId(addParam.getMemberId());
|
||||||
|
model.setCreateTime(System.currentTimeMillis() / 1000);
|
||||||
|
model.setVerifyType(JSONUtil.parseArray(addParam.getVerifyType()).toString());
|
||||||
|
|
||||||
|
verifierMapper.insert(model);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* del
|
* del
|
||||||
*/
|
*/
|
||||||
async del(...args: any[]): Promise<any> {
|
async del(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
verifierMapper.delete(new QueryWrapper<Verifier>().eq("id", id).eq("site_id", RequestUtils.siteId()));
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,15 +14,69 @@ export class VerifyServiceImplService {
|
|||||||
* list
|
* list
|
||||||
*/
|
*/
|
||||||
async list(...args: any[]): Promise<any[]> {
|
async list(...args: any[]): Promise<any[]> {
|
||||||
// TODO: 实现业务逻辑
|
const page: number = pageParam.getPage();
|
||||||
return [];
|
const limit: number = pageParam.getLimit();
|
||||||
|
|
||||||
|
const queryWrapper: MPJQueryWrapper<Verify> = new MPJQueryWrapper<>();
|
||||||
|
queryWrapper.setAlias("v").innerJoin("?_member m ON v.verifier_member_id = m.member_id".replace("?_", this.config.get('tablePrefix')));
|
||||||
|
queryWrapper.select("v.*,m.member_no,m.username,m.nickname,m.mobile,m.headimg");
|
||||||
|
queryWrapper.eq("v.site_id", RequestUtils.siteId());
|
||||||
|
queryWrapper.orderByDesc("id");
|
||||||
|
|
||||||
|
if (ObjectUtil.isNotEmpty(searchParam.getCode())) queryWrapper.eq("code", searchParam.getCode());
|
||||||
|
if (ObjectUtil.isNotEmpty(searchParam.getType())) queryWrapper.eq("type", searchParam.getType());
|
||||||
|
if (ObjectUtil.isNotEmpty(searchParam.getVerifierMemberId())) queryWrapper.eq("verifier_member_id", searchParam.getVerifierMemberId());
|
||||||
|
if (ObjectUtil.isNotEmpty(searchParam.getCreateTime())) QueryMapperUtils.buildByTime(queryWrapper, "v.create_time", searchParam.getCreateTime());
|
||||||
|
if (ObjectUtil.isNotEmpty(searchParam.getOrderId())){
|
||||||
|
queryWrapper.like("data", searchParam.getOrderId());
|
||||||
|
}
|
||||||
|
|
||||||
|
const iPage: IPage<VerifyVo> = verifyMapper.selectJoinPage(new Page<>(page, limit), VerifyVo.class, queryWrapper);
|
||||||
|
const list: VerifyListVo[] = [];
|
||||||
|
for (const item of iPage.getRecords()) {
|
||||||
|
const vo: VerifyListVo = new VerifyListVo();
|
||||||
|
BeanUtils.copyProperties(item, vo);
|
||||||
|
|
||||||
|
const memberInfoVo: MemberBriefInfoVo = new MemberBriefInfoVo();
|
||||||
|
BeanUtils.copyProperties(item, memberInfoVo);
|
||||||
|
vo.setMember(memberInfoVo);
|
||||||
|
|
||||||
|
list.add(vo);
|
||||||
|
}
|
||||||
|
return PageResult.build(page, limit, iPage.getTotal()).setData(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* detail
|
* detail
|
||||||
*/
|
*/
|
||||||
async detail(...args: any[]): Promise<any> {
|
async detail(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const queryWrapper: MPJQueryWrapper<Verify> = new MPJQueryWrapper<>();
|
||||||
return null;
|
queryWrapper.setAlias("v").innerJoin("?_member m ON v.verifier_member_id = m.member_id".replace("?_", this.config.get('tablePrefix')));
|
||||||
|
queryWrapper.select("v.*,m.member_no,m.username,m.nickname,m.mobile,m.headimg");
|
||||||
|
queryWrapper.eq("v.site_id", RequestUtils.siteId());
|
||||||
|
queryWrapper.eq("v.code", code);
|
||||||
|
|
||||||
|
const model: VerifyVo = verifyMapper.selectJoinOne(VerifyVo.class, queryWrapper);
|
||||||
|
Assert.notNull(model, "数据不存在");
|
||||||
|
|
||||||
|
const vo: VerifyInfoVo = new VerifyInfoVo();
|
||||||
|
BeanUtils.copyProperties(model, vo);
|
||||||
|
|
||||||
|
const memberInfoVo: MemberBriefInfoVo = new MemberBriefInfoVo();
|
||||||
|
BeanUtils.copyProperties(model, memberInfoVo);
|
||||||
|
vo.setMember(memberInfoVo);
|
||||||
|
|
||||||
|
VerifyInfoEventDefiner.const event: VerifyInfoEvent = new VerifyInfoEventDefiner.VerifyInfoEvent();
|
||||||
|
event.setData(vo);
|
||||||
|
const list: VerifyInfoEventDefiner.VerifyInfoEventResult[] = EventAndSubscribeOfPublisher.publishAndCallback(event);
|
||||||
|
if (!CollectionUtils.isEmpty(list)){
|
||||||
|
for (VerifyInfoEventDefiner.VerifyInfoEventResult verifyInfoEventResult : list) {
|
||||||
|
if (verifyInfoEventResult != null && verifyInfoEventResult.getDataMap() != null && !verifyInfoEventResult.getDataMap().isEmpty()){
|
||||||
|
vo.setVerifyInfo(verifyInfoEventResult.getDataMap());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return vo;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,39 +14,78 @@ export class WeappConfigServiceImplService {
|
|||||||
* getWeappConfig
|
* getWeappConfig
|
||||||
*/
|
*/
|
||||||
async getWeappConfig(...args: any[]): Promise<any> {
|
async getWeappConfig(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const weappConfigVo: WeappConfigVo = coreWeappConfigService.getWeappConfig(RequestUtils.siteId());
|
||||||
return null;
|
weappConfigVo = staticInfo(weappConfigVo);
|
||||||
|
|
||||||
|
if (weappConfigVo.getIsAuthorization() === 1) {
|
||||||
|
try {
|
||||||
|
const wxOpenMaService: WxOpenMaService = (WxOpenMaService) WechatUtils.miniapp(RequestUtils.siteId());
|
||||||
|
const domainResult: WxOpenMaDomainResult = wxOpenMaService.getDomain();
|
||||||
|
if (domainResult.getErrcode() === "0") {
|
||||||
|
WeappConfigVo.const domain: Domain = new WeappConfigVo.Domain();
|
||||||
|
domain.setRequestdomain(String.join(";", domainResult.getRequestDomain()));
|
||||||
|
domain.setWsrequestdomain(String.join(";", domainResult.getWsRequestDomain()));
|
||||||
|
domain.setUploaddomain(String.join(";", domainResult.getUploadDomain()));
|
||||||
|
domain.setDownloaddomain(String.join(";", domainResult.getDownloadDomain()));
|
||||||
|
weappConfigVo.setDomain(domain);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return weappConfigVo;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* setWeappConfig
|
* setWeappConfig
|
||||||
*/
|
*/
|
||||||
async setWeappConfig(...args: any[]): Promise<any> {
|
async setWeappConfig(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
coreWeappConfigService.setWeappConfig(RequestUtils.siteId(), weappConfigParam);
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* setDomain
|
* setDomain
|
||||||
*/
|
*/
|
||||||
async setDomain(...args: any[]): Promise<any> {
|
async setDomain(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
try {
|
||||||
return null;
|
const wxOpenMaService: WxOpenMaService = (WxOpenMaService) WechatUtils.miniapp(RequestUtils.siteId());
|
||||||
|
wxOpenMaService.modifyDomain(
|
||||||
|
"set",
|
||||||
|
ObjectUtil.isNotEmpty(param.getRequestdomain()) ? Arrays.asList(param.getRequestdomain().split(";")) : [],
|
||||||
|
ObjectUtil.isNotEmpty(param.getWsrequestdomain())? Arrays.asList(param.getWsrequestdomain().split(";")) : [],
|
||||||
|
ObjectUtil.isNotEmpty(param.getUploaddomain())? Arrays.asList(param.getUploaddomain().split(";")) : [],
|
||||||
|
ObjectUtil.isNotEmpty(param.getDownloaddomain())? Arrays.asList(param.getDownloaddomain().split(";")) : [],
|
||||||
|
ObjectUtil.isNotEmpty(param.getTcpdomain())? Arrays.asList(param.getTcpdomain().split(";")) : [],
|
||||||
|
ObjectUtil.isNotEmpty(param.getUdpdomain())? Arrays.asList(param.getUdpdomain().split(";")) : []
|
||||||
|
);
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new BadRequestException(e.getMessage());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* getPrivacySetting
|
* getPrivacySetting
|
||||||
*/
|
*/
|
||||||
async getPrivacySetting(...args: any[]): Promise<any> {
|
async getPrivacySetting(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
try {
|
||||||
return null;
|
const wxOpenMaService: WxOpenMaService = (WxOpenMaService) WechatUtils.miniapp(RequestUtils.siteId());
|
||||||
|
return wxOpenMaService.getPrivacyService().getPrivacySetting(2);
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new BadRequestException(e.getMessage());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* setPrivacySetting
|
* setPrivacySetting
|
||||||
*/
|
*/
|
||||||
async setPrivacySetting(...args: any[]): Promise<any> {
|
async setPrivacySetting(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
try {
|
||||||
return null;
|
const wxOpenMaService: WxOpenMaService = (WxOpenMaService) WechatUtils.miniapp(RequestUtils.siteId());
|
||||||
|
const setPrivacySetting: SetPrivacySetting = JSONUtil.toBean(privacySetting, SetPrivacySetting.class);
|
||||||
|
setPrivacySetting.setPrivacyVer(2);
|
||||||
|
wxOpenMaService.getPrivacyService().setPrivacySetting(setPrivacySetting);
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new BadRequestException(e.getMessage());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,15 +14,35 @@ export class WeappTemplateServiceImplService {
|
|||||||
* list
|
* list
|
||||||
*/
|
*/
|
||||||
async list(...args: any[]): Promise<any[]> {
|
async list(...args: any[]): Promise<any[]> {
|
||||||
// TODO: 实现业务逻辑
|
const addonNoticeList: AddonNoticeListVo[] = coreNoticeService.getAddonList(RequestUtils.siteId());
|
||||||
return [];
|
|
||||||
|
for (const item of addonNoticeList) {
|
||||||
|
const filter: NoticeInfoVo[] = [];
|
||||||
|
for (const noticeItem of item.getNotice()) {
|
||||||
|
if (noticeItem.getSupport_type().indexOf("weapp") != -1) {
|
||||||
|
filter.add(noticeItem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
item.setNotice(filter);
|
||||||
|
}
|
||||||
|
return addonNoticeList;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* sync
|
* sync
|
||||||
*/
|
*/
|
||||||
async sync(...args: any[]): Promise<any> {
|
async sync(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const list: Record<string, any> = coreNoticeService.getList(RequestUtils.siteId(), param.getKeys());
|
||||||
return null;
|
const keys: string[] = Arrays.asList(param.getKeys());
|
||||||
|
|
||||||
|
for (const item of list.values()) {
|
||||||
|
if (item.getWeapp() != null && (keys.size() == 0 || keys.includes(item.getKey()))) {
|
||||||
|
if (item.getWeappTemplateId().length() > 0) {
|
||||||
|
deleteTemplate(item.getWeappTemplateId());
|
||||||
|
}
|
||||||
|
const templateId: string = addTemplate(item.getWeapp().get("tid").toString(), item.getWeapp().getJSONArray("kid_list").toList(number.class), item.getWeapp().get("scene_desc").toString());
|
||||||
|
coreNoticeService.edit(RequestUtils.siteId(), item.getKey(), new Record<string, any>().set("weapp_template_id", templateId));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,31 +14,119 @@ export class WeappVersionServiceImplService {
|
|||||||
* list
|
* list
|
||||||
*/
|
*/
|
||||||
async list(...args: any[]): Promise<any[]> {
|
async list(...args: any[]): Promise<any[]> {
|
||||||
// TODO: 实现业务逻辑
|
const page: number = pageParam.getPage();
|
||||||
return [];
|
const limit: number = pageParam.getLimit();
|
||||||
|
|
||||||
|
const queryWrapper: QueryWrapper<WeappVersion> = new QueryWrapper<>();
|
||||||
|
queryWrapper.eq("site_id", RequestUtils.siteId());
|
||||||
|
queryWrapper.orderByDesc("id");
|
||||||
|
|
||||||
|
const iPage: IPage<WeappVersion> = weappVersionMapper.selectPage(new Page<WeappVersion>(page, limit), queryWrapper);
|
||||||
|
|
||||||
|
const list: WeappVersionListVo[] = [];
|
||||||
|
for (const item of iPage.getRecords()) {
|
||||||
|
const vo: WeappVersionListVo = new WeappVersionListVo();
|
||||||
|
BeanUtils.copyProperties(item, vo);
|
||||||
|
list.add(vo);
|
||||||
|
}
|
||||||
|
return PageResult.build(page,limit, iPage.getTotal()).setData(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* add
|
* add
|
||||||
*/
|
*/
|
||||||
async add(...args: any[]): Promise<any> {
|
async add(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
if (!RequestUtils.handler().getScheme() === "https") throw new BadRequestException("微信小程序请求地址只支持https请先配置ssl");
|
||||||
return null;
|
|
||||||
|
const weappConfig: WeappConfigVo = coreWeappConfigService.getWeappConfig(RequestUtils.siteId());
|
||||||
|
if (weappConfig.getAppId().isEmpty()) throw new BadRequestException("还没有配置微信小程序");
|
||||||
|
if (weappConfig.getUploadPrivateKey().isEmpty()) throw new BadRequestException("还没有配置微信小程序代码上传秘钥");
|
||||||
|
|
||||||
|
const uploading: WeappVersion = weappVersionMapper.selectOne(new QueryWrapper<WeappVersion>().select("id").eq("site_id", RequestUtils.siteId()).eq("status", WeappVersionStatusEnum.APPLET_UPLOADING));
|
||||||
|
if (uploading != null) throw new BadRequestException("小程序有正在上传的版本,请等待上一版本上传完毕后再进行操作");
|
||||||
|
|
||||||
|
const lastVersion: WeappVersion = weappVersionMapper.selectOne(new QueryWrapper<WeappVersion>().select("version_no").eq("site_id", RequestUtils.siteId()).orderByDesc("version_no").last("limit 1"));
|
||||||
|
const versionNo: number = lastVersion == null ? 1 : lastVersion.getVersionNo() + 1;
|
||||||
|
|
||||||
|
const addons: string[] = coreSiteService.getAddonKeysBySiteId(RequestUtils.siteId());
|
||||||
|
|
||||||
|
const uploadParam: WeappUploadParam = new WeappUploadParam();
|
||||||
|
uploadParam.setBaseUrl(RequestUtils.getDomain(true));
|
||||||
|
uploadParam.setAppId(weappConfig.getAppId());
|
||||||
|
uploadParam.setUploadPrivateKey(weappConfig.getUploadPrivateKey());
|
||||||
|
uploadParam.setSiteId(RequestUtils.siteId());
|
||||||
|
uploadParam.setVersion("1.0." + versionNo);
|
||||||
|
uploadParam.setDesc(param.getDesc());
|
||||||
|
uploadParam.setAddon(addons);
|
||||||
|
const taskKey: string = coreWeappCloudService.uploadWeapp(uploadParam);
|
||||||
|
|
||||||
|
const model: WeappVersion = new WeappVersion();
|
||||||
|
model.setSiteId(RequestUtils.siteId());
|
||||||
|
model.setVersion(uploadParam.getVersion());
|
||||||
|
model.setVersionNo(versionNo);
|
||||||
|
model.setDesc(param.getDesc());
|
||||||
|
model.setTaskKey(taskKey);
|
||||||
|
model.setCreateTime(System.currentTimeMillis() / 1000);
|
||||||
|
|
||||||
|
weappVersionMapper.insert(model);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* getWeappCompileLog
|
* getWeappCompileLog
|
||||||
*/
|
*/
|
||||||
async getWeappCompileLog(...args: any[]): Promise<any> {
|
async getWeappCompileLog(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const log: Record<string, any> = coreWeappCloudService.getWeappCompileLog(key);
|
||||||
return null;
|
if (log != null) {
|
||||||
|
const data: JSONArray = ObjectUtil.defaultIfNull(log.getByPath("data.0", JSONArray.class), new JSONArray());
|
||||||
|
if (data.size() > 0) {
|
||||||
|
const last: Record<string, any> = data.getJSONObject(data.size() - 1);
|
||||||
|
if (last.getInt("code", -1) === 0) {
|
||||||
|
const model: WeappVersion = new WeappVersion();
|
||||||
|
model.setStatus(WeappVersionStatusEnum.APPLET_UPLOAD_FAIL.getStatus());
|
||||||
|
model.setFailReason(last.getStr("msg", ""));
|
||||||
|
model.setUpdateTime(System.currentTimeMillis() / 1000);
|
||||||
|
|
||||||
|
weappVersionMapper.update(model, new QueryWrapper<WeappVersion>().eq("task_key", key));
|
||||||
|
return log;
|
||||||
|
}
|
||||||
|
if (last.getInt("percent", 0) === 100) {
|
||||||
|
const model: WeappVersion = new WeappVersion();
|
||||||
|
model.setStatus(WeappVersionStatusEnum.APPLET_UPLOAD_SUCCESS.getStatus());
|
||||||
|
model.setUpdateTime(System.currentTimeMillis() / 1000);
|
||||||
|
|
||||||
|
weappVersionMapper.update(model, new QueryWrapper<WeappVersion>().eq("task_key", key));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return log;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* getWeappPreviewImage
|
* getWeappPreviewImage
|
||||||
*/
|
*/
|
||||||
async getWeappPreviewImage(...args: any[]): Promise<any> {
|
async getWeappPreviewImage(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
number[] status = new number[] { WeappVersionStatusEnum.APPLET_AUDITING.getStatus(), WeappVersionStatusEnum.APPLET_UPLOAD_SUCCESS.getStatus() };
|
||||||
return null;
|
const version: WeappVersion = weappVersionMapper.selectOne(new QueryWrapper<WeappVersion>()
|
||||||
|
.eq("site_id", RequestUtils.siteId())
|
||||||
|
.in("status", status)
|
||||||
|
.orderByDesc("id")
|
||||||
|
.last("limit 1")
|
||||||
|
);
|
||||||
|
if (version == null) return "";
|
||||||
|
|
||||||
|
if (version.getFromType() === "cloud_build") {
|
||||||
|
return coreWeappCloudService.getWeappPreviewImage();
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
const wxOpenMaService: WxOpenMaService = (WxOpenMaService) WechatUtils.miniapp(RequestUtils.siteId());
|
||||||
|
const qrcode: string = wxOpenMaService.getTestQrcode("", {});
|
||||||
|
if (fs.existsSync(qrcode)) {
|
||||||
|
return "data:image/jpeg;base64," + Base64.getEncoder().encodeToString(FileUtils.readFileToByteArray(qrcode));
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
} catch (Exception e) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,23 +14,30 @@ export class WechatConfigServiceImplService {
|
|||||||
* getWechatConfig
|
* getWechatConfig
|
||||||
*/
|
*/
|
||||||
async getWechatConfig(...args: any[]): Promise<any> {
|
async getWechatConfig(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
return coreWechatConfigService.getWechatConfig(RequestUtils.siteId());
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* setWechatConfig
|
* setWechatConfig
|
||||||
*/
|
*/
|
||||||
async setWechatConfig(...args: any[]): Promise<any> {
|
async setWechatConfig(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
coreWechatConfigService.setWechatConfig(RequestUtils.siteId(), wechatConfigParam);
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* staticInfo
|
* staticInfo
|
||||||
*/
|
*/
|
||||||
async staticInfo(...args: any[]): Promise<any> {
|
async staticInfo(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const sysUrl: SceneDomainVo = sysConfigService.getUrl();
|
||||||
return null;
|
const request: HttpServletRequest = RequestUtils.handler();
|
||||||
|
|
||||||
|
const vo: WechatStaticInfoVo = new WechatStaticInfoVo();
|
||||||
|
vo.setServeUrl(request.getScheme() + "://" + request.getServerName() + "/api/wechat/serve/" + RequestUtils.siteId());
|
||||||
|
vo.setBusinessDomain(sysUrl.getWapDomain());
|
||||||
|
vo.setJsSecureDomain(sysUrl.getWapDomain());
|
||||||
|
vo.setWebAuthDomain(sysUrl.getWapDomain());
|
||||||
|
vo.setEncryptionType(WechatEncryptionTypeEnum.getMap());
|
||||||
|
|
||||||
|
return vo;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,31 +14,130 @@ export class WechatMediaServiceImplService {
|
|||||||
* list
|
* list
|
||||||
*/
|
*/
|
||||||
async list(...args: any[]): Promise<any[]> {
|
async list(...args: any[]): Promise<any[]> {
|
||||||
// TODO: 实现业务逻辑
|
const page: number = pageParam.getPage();
|
||||||
return [];
|
const limit: number = pageParam.getLimit();
|
||||||
|
|
||||||
|
const queryWrapper: QueryWrapper<WechatMedia> = new QueryWrapper<>();
|
||||||
|
queryWrapper.eq("site_id", RequestUtils.siteId());
|
||||||
|
queryWrapper.orderByDesc("id");
|
||||||
|
|
||||||
|
if (ObjectUtil.isNotEmpty(searchParam.getType())) queryWrapper.eq("type", searchParam.getType());
|
||||||
|
|
||||||
|
const iPage: IPage<WechatMedia> = wechatMediaMapper.selectPage(new Page<>(page, limit), queryWrapper);
|
||||||
|
const list: WechatMediaListVo[] = [];
|
||||||
|
for (const item of iPage.getRecords()) {
|
||||||
|
const vo: WechatMediaListVo = new WechatMediaListVo();
|
||||||
|
BeanUtils.copyProperties(item, vo);
|
||||||
|
list.add(vo);
|
||||||
|
}
|
||||||
|
return PageResult.build(page, limit, iPage.getTotal()).setData(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* image
|
* image
|
||||||
*/
|
*/
|
||||||
async image(...args: any[]): Promise<any> {
|
async image(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const param: AttachmentUploadParam = new AttachmentUploadParam();
|
||||||
return null;
|
param.setSiteId(RequestUtils.siteId());
|
||||||
|
param.setStorageType("local");
|
||||||
|
param.setFile(file);
|
||||||
|
param.setAttType("image");
|
||||||
|
param.setDir("attachment/image/" + param.getSiteId() + "/" + (new SimpleDateFormat("yyyyMM/dd").format(new Date())) + "/");
|
||||||
|
const uploadRes: AttachmentUploadVo = coreUploadService.upload(param);
|
||||||
|
|
||||||
|
const wxMaterial: WxMpMaterial = new WxMpMaterial();
|
||||||
|
wxMaterial.setFile(this.config.get('webRootDownResource' + uploadRes.getUrl()));
|
||||||
|
wxMaterial.setName(param.getNewFilename());
|
||||||
|
|
||||||
|
try {
|
||||||
|
const res: WxMpMaterialUploadResult = WechatUtils.mp(RequestUtils.siteId()).getMaterialService().materialFileUpload(WechatMediaTypeEnum.IMAGE.getType(), wxMaterial);
|
||||||
|
|
||||||
|
const model: WechatMedia = new WechatMedia();
|
||||||
|
model.setSiteId(RequestUtils.siteId());
|
||||||
|
model.setType(WechatMediaTypeEnum.IMAGE.getType());
|
||||||
|
model.setValue(uploadRes.getUrl());
|
||||||
|
model.setMediaId(res.getMediaId());
|
||||||
|
model.setCreateTime(System.currentTimeMillis() / 1000);
|
||||||
|
wechatMediaMapper.insert(model);
|
||||||
|
|
||||||
|
const vo: WechatMediaInfoVo = new WechatMediaInfoVo();
|
||||||
|
BeanUtils.copyProperties(model, vo);
|
||||||
|
return vo;
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new BadRequestException(e.getMessage());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* video
|
* video
|
||||||
*/
|
*/
|
||||||
async video(...args: any[]): Promise<any> {
|
async video(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const param: AttachmentUploadParam = new AttachmentUploadParam();
|
||||||
return null;
|
param.setSiteId(RequestUtils.siteId());
|
||||||
|
param.setStorageType("local");
|
||||||
|
param.setFile(file);
|
||||||
|
param.setAttType("video");
|
||||||
|
param.setDir("attachment/video/" + param.getSiteId() + "/" + (new SimpleDateFormat("yyyyMM/dd").format(new Date())) + "/");
|
||||||
|
const uploadRes: AttachmentUploadVo = coreUploadService.upload(param);
|
||||||
|
|
||||||
|
const wxMaterial: WxMpMaterial = new WxMpMaterial();
|
||||||
|
wxMaterial.setFile(this.config.get('webRootDownResource' + uploadRes.getUrl()));
|
||||||
|
wxMaterial.setName(param.getNewFilename());
|
||||||
|
wxMaterial.setVideoIntroduction((new SimpleDateFormat("yyyyMM/dd").format(new Date())) + "上传");
|
||||||
|
wxMaterial.setVideoTitle(param.getNewFilename());
|
||||||
|
|
||||||
|
try {
|
||||||
|
const res: WxMpMaterialUploadResult = WechatUtils.mp(RequestUtils.siteId()).getMaterialService().materialFileUpload(WechatMediaTypeEnum.VIDEO.getType(), wxMaterial);
|
||||||
|
|
||||||
|
const model: WechatMedia = new WechatMedia();
|
||||||
|
model.setSiteId(RequestUtils.siteId());
|
||||||
|
model.setType(WechatMediaTypeEnum.VIDEO.getType());
|
||||||
|
model.setValue(uploadRes.getUrl());
|
||||||
|
model.setMediaId(res.getMediaId());
|
||||||
|
model.setCreateTime(System.currentTimeMillis() / 1000);
|
||||||
|
wechatMediaMapper.insert(model);
|
||||||
|
|
||||||
|
const vo: WechatMediaInfoVo = new WechatMediaInfoVo();
|
||||||
|
BeanUtils.copyProperties(model, vo);
|
||||||
|
return vo;
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new BadRequestException(e.getMessage());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* syncNews
|
* syncNews
|
||||||
*/
|
*/
|
||||||
async syncNews(...args: any[]): Promise<any> {
|
async syncNews(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
try {
|
||||||
return null;
|
const count: number = 20;
|
||||||
|
|
||||||
|
const result: WxMpMaterialNewsBatchGetResult = WechatUtils.mp(RequestUtils.siteId()).getMaterialService().materialNewsBatchGet(offset, count);
|
||||||
|
if (result.getItemCount() > 0) {
|
||||||
|
for (WxMpMaterialNewsBatchGetResult.WxMaterialNewsBatchGetNewsItem item: result.getItems()) {
|
||||||
|
const media: WechatMedia = wechatMediaMapper.selectOne(new QueryWrapper<WechatMedia>().eq("site_id", RequestUtils.siteId()).eq("media_id", item.getMediaId()));
|
||||||
|
|
||||||
|
if (ObjectUtil.isNotEmpty(media)) {
|
||||||
|
media.setValue(JSONUtil.toJsonStr(item.getContent()));
|
||||||
|
media.setUpdateTime(System.currentTimeMillis() / 1000);
|
||||||
|
wechatMediaMapper.updateById(media);
|
||||||
|
} else {
|
||||||
|
const model: WechatMedia = new WechatMedia();
|
||||||
|
model.setSiteId(RequestUtils.siteId());
|
||||||
|
model.setType(WechatMediaTypeEnum.VIDEO.getType());
|
||||||
|
model.setValue(JSONUtil.toJsonStr(item.getContent()));
|
||||||
|
model.setMediaId(item.getMediaId());
|
||||||
|
model.setCreateTime(System.currentTimeMillis() / 1000);
|
||||||
|
wechatMediaMapper.insert(model);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (offset < Math.ceil(result.getTotalCount() / count)) {
|
||||||
|
offset++;
|
||||||
|
this.syncNews(offset);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new BadRequestException(e.getMessage());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,15 +14,20 @@ export class WechatMenuServiceImplService {
|
|||||||
* info
|
* info
|
||||||
*/
|
*/
|
||||||
async info(...args: any[]): Promise<any> {
|
async info(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
return coreConfigService.getConfigArrayValue(RequestUtils.siteId(), "WECHAT_MENU");
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* edit
|
* edit
|
||||||
*/
|
*/
|
||||||
async edit(...args: any[]): Promise<any> {
|
async edit(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
try{
|
||||||
return null;
|
const params: Record<string, any> = {};
|
||||||
|
params.put("button", data);
|
||||||
|
WechatUtils.mp(RequestUtils.siteId()).getMenuService().menuCreate(JSONUtil.parseObj(params).toString()) ;
|
||||||
|
coreConfigService.setConfig(RequestUtils.siteId(), "WECHAT_MENU", data);
|
||||||
|
}catch (WxErrorException e){
|
||||||
|
throw new AdminException(e.getMessage());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,71 +14,150 @@ export class WechatReplyServiceImplService {
|
|||||||
* getKeywordList
|
* getKeywordList
|
||||||
*/
|
*/
|
||||||
async getKeywordList(...args: any[]): Promise<any> {
|
async getKeywordList(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const page: number = pageParam.getPage();
|
||||||
return null;
|
const limit: number = pageParam.getLimit();
|
||||||
|
|
||||||
|
const queryWrapper: QueryWrapper<WechatReply> = new QueryWrapper<>();
|
||||||
|
queryWrapper.eq("reply_type", WechatReplyTypeEnum.REPLY_KEYWORD.getType());
|
||||||
|
queryWrapper.eq("site_id", RequestUtils.siteId());
|
||||||
|
queryWrapper.orderByDesc(Arrays.asList("sort", "id"));
|
||||||
|
|
||||||
|
if (ObjectUtil.isNotEmpty(searchParam.getKeyword())) queryWrapper.like("keyword", searchParam.getKeyword());
|
||||||
|
if (ObjectUtil.isNotEmpty(path.basename(searchParam))) queryWrapper.like("name", path.basename(searchParam));
|
||||||
|
|
||||||
|
const iPage: IPage<WechatReply> = wechatReplyMapper.selectPage(new Page<>(page, limit), queryWrapper);
|
||||||
|
const list: WechatReplyListVo[] = [];
|
||||||
|
for (const item of iPage.getRecords()) {
|
||||||
|
const vo: WechatReplyListVo = new WechatReplyListVo();
|
||||||
|
BeanUtils.copyProperties(item, vo);
|
||||||
|
list.add(vo);
|
||||||
|
}
|
||||||
|
return PageResult.build(page, limit, iPage.getTotal()).setData(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* getKeywordInfo
|
* getKeywordInfo
|
||||||
*/
|
*/
|
||||||
async getKeywordInfo(...args: any[]): Promise<any> {
|
async getKeywordInfo(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const model: WechatReply = wechatReplyMapper.selectOne(
|
||||||
return null;
|
new QueryWrapper<WechatReply>()
|
||||||
|
.eq("id", id)
|
||||||
|
.eq("site_id", RequestUtils.siteId())
|
||||||
|
.eq("reply_type", WechatReplyTypeEnum.REPLY_KEYWORD.getType()));
|
||||||
|
|
||||||
|
Assert.notNull(model, "数据不存在");
|
||||||
|
|
||||||
|
const vo: WechatReplyInfoVo = new WechatReplyInfoVo();
|
||||||
|
BeanUtils.copyProperties(model, vo);
|
||||||
|
return vo;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* addKeyword
|
* addKeyword
|
||||||
*/
|
*/
|
||||||
async addKeyword(...args: any[]): Promise<any> {
|
async addKeyword(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const model: WechatReply = new WechatReply();
|
||||||
return null;
|
model.setName(path.basename(addParam));
|
||||||
|
model.setSiteId(RequestUtils.siteId());
|
||||||
|
model.setKeyword(addParam.getKeyword());
|
||||||
|
model.setReplyType(WechatReplyTypeEnum.REPLY_KEYWORD.getType());
|
||||||
|
model.setMatchingType(addParam.getMatchingType());
|
||||||
|
model.setContent(addParam.getContent().toString());
|
||||||
|
model.setSort(addParam.getSort());
|
||||||
|
model.setCreateTime(System.currentTimeMillis() / 1000);
|
||||||
|
model.setReplyMethod(addParam.getReplyMethod());
|
||||||
|
wechatReplyMapper.insert(model);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* editKeyword
|
* editKeyword
|
||||||
*/
|
*/
|
||||||
async editKeyword(...args: any[]): Promise<any> {
|
async editKeyword(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const model: WechatReply = wechatReplyMapper.selectOne(
|
||||||
return null;
|
new QueryWrapper<WechatReply>()
|
||||||
|
.eq("id", id)
|
||||||
|
.eq("site_id", RequestUtils.siteId())
|
||||||
|
.eq("reply_type", WechatReplyTypeEnum.REPLY_KEYWORD.getType()));
|
||||||
|
|
||||||
|
Assert.notNull(model, "数据不存在!");
|
||||||
|
|
||||||
|
model.setName(path.basename(editParam));
|
||||||
|
model.setKeyword(editParam.getKeyword());
|
||||||
|
model.setMatchingType(editParam.getMatchingType());
|
||||||
|
model.setContent(editParam.getContent().toString());
|
||||||
|
model.setSort(editParam.getSort());
|
||||||
|
model.setUpdateTime(System.currentTimeMillis() / 1000);
|
||||||
|
model.setReplyMethod(editParam.getReplyMethod());
|
||||||
|
wechatReplyMapper.updateById(model);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* getDefault
|
* getDefault
|
||||||
*/
|
*/
|
||||||
async getDefault(...args: any[]): Promise<any> {
|
async getDefault(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
return coreWechatReplyService.getDefault(RequestUtils.siteId());
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* editDefault
|
* editDefault
|
||||||
*/
|
*/
|
||||||
async editDefault(...args: any[]): Promise<any> {
|
async editDefault(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const queryWrapper: QueryWrapper = new QueryWrapper<WechatReply>()
|
||||||
return null;
|
.eq("reply_type", WechatReplyTypeEnum.REPLY_DEFAULT.getType())
|
||||||
|
.eq("site_id", RequestUtils.siteId());
|
||||||
|
|
||||||
|
const reply: WechatReply = wechatReplyMapper.selectOne(queryWrapper);
|
||||||
|
|
||||||
|
if (ObjectUtil.isEmpty(reply)) {
|
||||||
|
const model: WechatReply = new WechatReply();
|
||||||
|
model.setContent(param.getContent().toString());
|
||||||
|
model.setSiteId(RequestUtils.siteId());
|
||||||
|
model.setReplyType(WechatReplyTypeEnum.REPLY_DEFAULT.getType());
|
||||||
|
wechatReplyMapper.insert(model);
|
||||||
|
} else {
|
||||||
|
const model: WechatReply = new WechatReply();
|
||||||
|
model.setContent(param.getContent().toString());
|
||||||
|
wechatReplyMapper.update(model, queryWrapper);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* getSubscribe
|
* getSubscribe
|
||||||
*/
|
*/
|
||||||
async getSubscribe(...args: any[]): Promise<any> {
|
async getSubscribe(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
return coreWechatReplyService.getSubscribe(RequestUtils.siteId());
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* editSubscribe
|
* editSubscribe
|
||||||
*/
|
*/
|
||||||
async editSubscribe(...args: any[]): Promise<any> {
|
async editSubscribe(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const queryWrapper: QueryWrapper = new QueryWrapper<WechatReply>()
|
||||||
return null;
|
.eq("reply_type", WechatReplyTypeEnum.REPLY_SUBSCRIBE.getType())
|
||||||
|
.eq("site_id", RequestUtils.siteId());
|
||||||
|
|
||||||
|
const reply: WechatReply = wechatReplyMapper.selectOne(queryWrapper);
|
||||||
|
|
||||||
|
if (ObjectUtil.isEmpty(reply)) {
|
||||||
|
const model: WechatReply = new WechatReply();
|
||||||
|
model.setContent(param.getContent().toString());
|
||||||
|
model.setSiteId(RequestUtils.siteId());
|
||||||
|
model.setReplyType(WechatReplyTypeEnum.REPLY_DEFAULT.getType());
|
||||||
|
wechatReplyMapper.insert(model);
|
||||||
|
} else {
|
||||||
|
const model: WechatReply = new WechatReply();
|
||||||
|
model.setContent(param.getContent().toString());
|
||||||
|
wechatReplyMapper.update(model, queryWrapper);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* delKeyword
|
* delKeyword
|
||||||
*/
|
*/
|
||||||
async delKeyword(...args: any[]): Promise<any> {
|
async delKeyword(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
wechatReplyMapper.delete(new QueryWrapper<WechatReply>()
|
||||||
return null;
|
.eq("reply_type", WechatReplyTypeEnum.REPLY_KEYWORD.getType())
|
||||||
|
.eq("id", id)
|
||||||
|
.eq("site_id", RequestUtils.siteId()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,15 +14,35 @@ export class WechatTemplateServiceImplService {
|
|||||||
* list
|
* list
|
||||||
*/
|
*/
|
||||||
async list(...args: any[]): Promise<any[]> {
|
async list(...args: any[]): Promise<any[]> {
|
||||||
// TODO: 实现业务逻辑
|
const addonNoticeList: AddonNoticeListVo[] = coreNoticeService.getAddonList(RequestUtils.siteId());
|
||||||
return [];
|
|
||||||
|
for (const item of addonNoticeList) {
|
||||||
|
const filter: NoticeInfoVo[] = [];
|
||||||
|
for (const noticeItem of item.getNotice()) {
|
||||||
|
if (noticeItem.getSupport_type().indexOf("wechat") != -1) {
|
||||||
|
filter.add(noticeItem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
item.setNotice(filter);
|
||||||
|
}
|
||||||
|
return addonNoticeList;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* sync
|
* sync
|
||||||
*/
|
*/
|
||||||
async sync(...args: any[]): Promise<any> {
|
async sync(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const list: Record<string, any> = coreNoticeService.getList(RequestUtils.siteId(), param.getKeys());
|
||||||
return null;
|
const keys: string[] = Arrays.asList(param.getKeys());
|
||||||
|
|
||||||
|
for (const item of list.values()) {
|
||||||
|
if (item.getWechat() != null && (keys.size() == 0 || keys.includes(item.getKey()))) {
|
||||||
|
if (item.getWeappTemplateId().length() > 0) {
|
||||||
|
deleteTemplate(item.getWeappTemplateId());
|
||||||
|
}
|
||||||
|
const templateId: string = addTemplate(item.getWechat().get("temp_key").toString(), item.getWechat().getJSONArray("keyword_name_list").toList(String.class));
|
||||||
|
coreNoticeService.edit(RequestUtils.siteId(), item.getKey(), new Record<string, any>().set("wechat_template_id", templateId));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,23 +14,28 @@ export class OplatformConfigServiceImplService {
|
|||||||
* getOplatformStaticInfo
|
* getOplatformStaticInfo
|
||||||
*/
|
*/
|
||||||
async getOplatformStaticInfo(...args: any[]): Promise<any> {
|
async getOplatformStaticInfo(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
return coreOplatformConfigService.getOplatformStaticInfo();
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* getWxOplatformConfig
|
* getWxOplatformConfig
|
||||||
*/
|
*/
|
||||||
async getWxOplatformConfig(...args: any[]): Promise<any> {
|
async getWxOplatformConfig(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const jsonObject: Record<string, any> = coreConfigService.getConfigValue(RequestUtils.defaultSiteId(), ConfigKeyEnum.path.basename(WXOPLATFORM));
|
||||||
return null;
|
const configJsonObject: Record<string, any> = new Record<string, any>();
|
||||||
|
configJsonObject.set("app_id", jsonObject.getStr("app_id", ""));
|
||||||
|
configJsonObject.set("app_secret", jsonObject.getStr("app_secret", ""));
|
||||||
|
configJsonObject.set("token", jsonObject.getStr("token", ""));
|
||||||
|
configJsonObject.set("aes_key", jsonObject.getStr("aes_key", ""));
|
||||||
|
configJsonObject.set("develop_app_id", jsonObject.getStr("develop_app_id", ""));
|
||||||
|
configJsonObject.set("develop_upload_private_key", jsonObject.getStr("develop_upload_private_key", ""));
|
||||||
|
return configJsonObject;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* setWxOplatformConfig
|
* setWxOplatformConfig
|
||||||
*/
|
*/
|
||||||
async setWxOplatformConfig(...args: any[]): Promise<any> {
|
async setWxOplatformConfig(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
coreOplatformConfigService.setOplatformConfig(oplatformConfigParam);
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,15 +14,64 @@ export class OplatformServerServiceImplService {
|
|||||||
* server
|
* server
|
||||||
*/
|
*/
|
||||||
async server(...args: any[]): Promise<any> {
|
async server(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
if (!StringUtils.toLowerCase() === "aes", param.getEncryptType(.toLowerCase())
|
||||||
return null;
|
|| !WechatUtils.WxOpen().getWxOpenComponentService().checkSignature(param.getTimestamp(), param.getNonce(), param.getSignature())) {
|
||||||
|
throw new IllegalArgumentException("非法请求");
|
||||||
|
}
|
||||||
|
|
||||||
|
const inMessage: WxOpenXmlMessage = WxOpenXmlMessage.fromEncryptedXml(param.getRequestBody(), WechatUtils.WxOpen().getWxOpenConfigStorage(), param.getTimestamp(), param.getNonce(), param.getMsgSignature());
|
||||||
|
log.info("开放平台授权事件推送消息:{}", inMessage);
|
||||||
|
|
||||||
|
try {
|
||||||
|
WechatUtils.WxOpen().getWxOpenComponentService().route(inMessage);
|
||||||
|
|
||||||
|
// 授权取消
|
||||||
|
if (inMessage.getInfoType() === "unauthorized") {
|
||||||
|
oplatformService.clearAuthorization(inMessage.getAuthorizerAppid());
|
||||||
|
}
|
||||||
|
// 更新授权
|
||||||
|
if (inMessage.getInfoType() === "updateauthorized") {
|
||||||
|
const siteId: number = coreOplatformService.getSiteIdByAuthorizerAppid(inMessage.getAuthorizerAppid());
|
||||||
|
RequestUtils.setSiteId(siteId);
|
||||||
|
|
||||||
|
const authorizationParam: AuthorizationParam = new AuthorizationParam();
|
||||||
|
authorizationParam.setAuthCode(inMessage.getAuthorizationCode());
|
||||||
|
oplatformService.authorization(authorizationParam);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("处理开放平台授权事件消息异常", e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* message
|
* message
|
||||||
*/
|
*/
|
||||||
async message(...args: any[]): Promise<any> {
|
async message(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
if (!StringUtils.toLowerCase() === "aes", param.getEncryptType(.toLowerCase())
|
||||||
return null;
|
|| !WechatUtils.WxOpen().getWxOpenComponentService().checkSignature(param.getTimestamp(), param.getNonce(), param.getSignature())) {
|
||||||
|
throw new IllegalArgumentException("非法请求");
|
||||||
|
}
|
||||||
|
|
||||||
|
const inMessage: WxMpXmlMessage = WxOpenXmlMessage.fromEncryptedMpXml(param.getRequestBody(), WechatUtils.WxOpen().getWxOpenConfigStorage(), param.getTimestamp(), param.getNonce(), param.getMsgSignature());
|
||||||
|
log.info("开放平台消息与事件推送消息:{}", inMessage);
|
||||||
|
|
||||||
|
if (inMessage.getMsgType() === WxConsts.XmlMsgType.EVENT) {
|
||||||
|
// 小程序审核成功
|
||||||
|
if (inMessage.getEvent() === WxConsts.EventType.WEAPP_AUDIT_SUCCESS) {
|
||||||
|
weappAuditSuccess(inMessage);
|
||||||
|
}
|
||||||
|
// 小程序审核失败
|
||||||
|
if (inMessage.getEvent() === WxConsts.EventType.WEAPP_AUDIT_FAIL) {
|
||||||
|
weappAuditFail(inMessage);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const wxOpenMessageRouter: WxOpenMessageRouter = new WxOpenMessageRouter(WechatUtils.WxOpen());
|
||||||
|
|
||||||
|
const outMessage: WxMpXmlOutMessage = wxOpenMessageRouter.route(inMessage, appid);
|
||||||
|
if(outMessage != null){
|
||||||
|
return WxOpenXmlMessage.wxMpOutXmlMessageToEncryptedXml(outMessage, WechatUtils.WxOpen().getWxOpenConfigStorage());
|
||||||
|
}
|
||||||
|
return "success";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,31 +14,92 @@ export class OplatformServiceImplService {
|
|||||||
* createPreAuthorizationUrl
|
* createPreAuthorizationUrl
|
||||||
*/
|
*/
|
||||||
async createPreAuthorizationUrl(...args: any[]): Promise<any> {
|
async createPreAuthorizationUrl(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
try {
|
||||||
return null;
|
const url: string = RequestUtils.getDomain(true) + "/site/wxoplatform/callback";
|
||||||
|
return WechatUtils.WxOpen().getWxOpenComponentService().getPreAuthUrl(url);
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new BadRequestException(e.getMessage());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* authorization
|
* authorization
|
||||||
*/
|
*/
|
||||||
async authorization(...args: any[]): Promise<any> {
|
async authorization(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
try {
|
||||||
return null;
|
const queryAuth: WxOpenQueryAuthResult = WechatUtils.WxOpen().getWxOpenComponentService().getQueryAuth(param.getAuthCode());
|
||||||
|
|
||||||
|
// 授权账号信息 授权信息
|
||||||
|
const result: WxOpenAuthorizerInfoResult = WechatUtils.WxOpen().getWxOpenComponentService().getAuthorizerInfo(queryAuth.getAuthorizationInfo().getAuthorizerAppid());
|
||||||
|
|
||||||
|
const authorizerInfo: WxOpenAuthorizerInfo = result.getAuthorizerInfo();
|
||||||
|
const authorization: WxOpenAuthorizationInfo = result.getAuthorizationInfo();
|
||||||
|
|
||||||
|
// 小程序
|
||||||
|
if (ObjectUtil.isNotEmpty(authorizerInfo.getMiniProgramInfo())) {
|
||||||
|
this.weappCheck(authorizerInfo, authorization);
|
||||||
|
|
||||||
|
const weappConfig: WeappConfigParam = new WeappConfigParam();
|
||||||
|
weappConfig.setAppId(authorization.getAuthorizerAppid());
|
||||||
|
weappConfig.setWeappName(authorizerInfo.getNickName());
|
||||||
|
weappConfig.setWeappOriginal(authorizerInfo.getUserName());
|
||||||
|
weappConfig.setIsAuthorization(1);
|
||||||
|
weappConfig.setQrCode(coreFetchService.image(authorizerInfo.getQrcodeUrl(), RequestUtils.siteId()));
|
||||||
|
coreWeappConfigService.setWeappConfig(RequestUtils.siteId(), weappConfig);
|
||||||
|
|
||||||
|
coreWeappConfigService.setWeappAuthorizationInfo(RequestUtils.siteId(), result);
|
||||||
|
} else { // 公众号
|
||||||
|
this.wechatCheck(authorizerInfo, authorization);
|
||||||
|
|
||||||
|
const wechatConfig: WechatConfigParam = new WechatConfigParam();
|
||||||
|
wechatConfig.setAppId(authorization.getAuthorizerAppid());
|
||||||
|
wechatConfig.setWechatName(authorizerInfo.getNickName());
|
||||||
|
wechatConfig.setWechatOriginal(authorizerInfo.getUserName());
|
||||||
|
wechatConfig.setIsAuthorization(1);
|
||||||
|
wechatConfig.setQrcode(coreFetchService.image(authorizerInfo.getQrcodeUrl(), RequestUtils.siteId()));
|
||||||
|
coreWechatConfigService.setWechatConfig(RequestUtils.siteId(), wechatConfig);
|
||||||
|
|
||||||
|
coreWechatConfigService.setWechatAuthorizationInfo(RequestUtils.siteId(), result);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new BadRequestException(e.getMessage());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* clearAuthorization
|
* clearAuthorization
|
||||||
*/
|
*/
|
||||||
async clearAuthorization(...args: any[]): Promise<any> {
|
async clearAuthorization(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
String[] configKey = new String[]{ ConfigKeyEnum.path.basename(WECHAT), ConfigKeyEnum.path.basename(WEAPP), ConfigKeyEnum.path.basename(WEAPP_AUTHORIZATION_INFO), ConfigKeyEnum.path.basename(WECHAT_AUTHORIZATION_INFO)};
|
||||||
return null;
|
sysConfigMapper.delete(new QueryWrapper<SysConfig>().like("value", appid).in("config_key", configKey));
|
||||||
|
coreConfigService.cacheClear();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* getAuthRecord
|
* getAuthRecord
|
||||||
*/
|
*/
|
||||||
async getAuthRecord(...args: any[]): Promise<any> {
|
async getAuthRecord(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const page: number = pageParam.getPage();
|
||||||
return null;
|
const limit: number = pageParam.getLimit();
|
||||||
|
|
||||||
|
const wrapper: MPJLambdaWrapper<SysConfig> = new MPJLambdaWrapper<SysConfig>();
|
||||||
|
wrapper.select(SysConfig::getCreateTime,SysConfig::getAddon,SysConfig::getStatus,SysConfig::getConfigKey, SysConfig::getValue, SysConfig::getSiteId, SysConfig::getUpdateTime);
|
||||||
|
wrapper.leftJoin(Site.class, "siteinfo",Site::getSiteId, SysConfig::getSiteId).select("site_name");
|
||||||
|
wrapper.in(SysConfig::getConfigKey, ConfigKeyEnum.path.basename(WECHAT_AUTHORIZATION_INFO), ConfigKeyEnum.path.basename(WEAPP_AUTHORIZATION_INFO));
|
||||||
|
wrapper.eq(SysConfig::getSiteId, RequestUtils.siteId());
|
||||||
|
wrapper.orderByDesc(SysConfig::getUpdateTime);
|
||||||
|
const pageObj: Page<SysConfig> = new Page<>(page, limit);
|
||||||
|
const iPage: IPage<SysConfig> = sysConfigMapper.selectPage(pageObj, wrapper);
|
||||||
|
const listInfo: OplatformRecordVo[] = [];
|
||||||
|
for (const item of iPage.getRecords()) {
|
||||||
|
const vo: OplatformRecordVo = new OplatformRecordVo();
|
||||||
|
BeanUtils.copyProperties(item, vo);
|
||||||
|
vo.setValue(JSONUtil.parseObj(item.getValue()));
|
||||||
|
const siteInfo: Site = new Site();
|
||||||
|
siteInfo.setSiteName(item.getSiteName());
|
||||||
|
vo.setSite(siteInfo);
|
||||||
|
listInfo.add(vo);
|
||||||
|
}
|
||||||
|
return PageResult.build(page, limit, iPage.getTotal()).setData(listInfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,95 +14,340 @@ export class WeappVersionServiceImplService {
|
|||||||
* setWeappVersionService
|
* setWeappVersionService
|
||||||
*/
|
*/
|
||||||
async setWeappVersionService(...args: any[]): Promise<any> {
|
async setWeappVersionService(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
this.weappVersionService = weappVersionService;
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* getLastCommitRecord
|
* getLastCommitRecord
|
||||||
*/
|
*/
|
||||||
async getLastCommitRecord(...args: any[]): Promise<any> {
|
async getLastCommitRecord(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const queryWrapper: QueryWrapper<WxOplatfromWeappVersion> = new QueryWrapper<>();
|
||||||
return null;
|
queryWrapper.orderByDesc("id")
|
||||||
|
.last("limit 1");
|
||||||
|
const wxOplatfromWeappVersion: WxOplatfromWeappVersion = wxOplatfromWeappVersionMapper.selectOne(queryWrapper);
|
||||||
|
if (wxOplatfromWeappVersion==null) return null;
|
||||||
|
const wxOplatfromWeappVersionVo: WxOplatfromWeappVersionVo = new WxOplatfromWeappVersionVo();
|
||||||
|
BeanUtils.copyProperties(wxOplatfromWeappVersion, wxOplatfromWeappVersionVo);
|
||||||
|
return wxOplatfromWeappVersionVo;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* list
|
* list
|
||||||
*/
|
*/
|
||||||
async list(...args: any[]): Promise<any[]> {
|
async list(...args: any[]): Promise<any[]> {
|
||||||
// TODO: 实现业务逻辑
|
const page: number = pageParam.getPage();
|
||||||
return [];
|
const limit: number = pageParam.getLimit();
|
||||||
|
|
||||||
|
const queryWrapper: QueryWrapper<WxOplatfromWeappVersion> = new QueryWrapper<>();
|
||||||
|
queryWrapper.orderByDesc("id");
|
||||||
|
|
||||||
|
const wxOplatfromMPJQueryWrapper: MPJQueryWrapper<WxOplatfromWeappVersion> = new MPJQueryWrapper<>();
|
||||||
|
wxOplatfromMPJQueryWrapper.select("wowv.id, wowv.site_group_id, wowv.template_id, wowv.user_version, wowv.user_desc, wowv.task_key, wowv.status, wowv.fail_reason, wowv.version_no, wowv.create_time, wowv.update_time, nsg.group_name as site_group_name")
|
||||||
|
.setAlias("wowv")
|
||||||
|
.leftJoin("?_site_group nsg ON nsg.group_id = wowv.site_group_id".replace("?_", this.config.get('tablePrefix')));
|
||||||
|
wxOplatfromMPJQueryWrapper.orderByDesc("wowv.id");
|
||||||
|
|
||||||
|
const iPage: IPage<WxOplatfromWeappVersionVo> = wxOplatfromWeappVersionMapper.selectJoinPage(new Page<>(page, limit), WxOplatfromWeappVersionVo.class, wxOplatfromMPJQueryWrapper);
|
||||||
|
return PageResult.build(page, limit, iPage.getTotal()).setData(iPage.getRecords());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* add
|
* add
|
||||||
*/
|
*/
|
||||||
async add(...args: any[]): Promise<any> {
|
async add(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const siteGroupList: SiteGroup[] = siteGroupMapper.selectList(new QueryWrapper<SiteGroup>().gt("group_id", 0).orderByAsc("create_time"));
|
||||||
return null;
|
if (ObjectUtil.isEmpty(siteGroupList)) throw new BadRequestException("请先添加站点套餐");
|
||||||
|
|
||||||
|
const siteGroup: SiteGroup = siteGroupId == null || siteGroupId == 0 ? siteGroupList.get(0) : siteGroupMapper.selectById(siteGroupId);
|
||||||
|
|
||||||
|
const uploading: WxOplatfromWeappVersion = wxOplatfromWeappVersionMapper.selectOne(new QueryWrapper<WxOplatfromWeappVersion>()
|
||||||
|
.eq("site_group_id", siteGroup.getGroupId())
|
||||||
|
.eq("status", 0)
|
||||||
|
.last("limit 1")
|
||||||
|
);
|
||||||
|
if (uploading != null) throw new BadRequestException("小程序有正在上传的版本,请等待上一版本上传完毕后再进行操作");
|
||||||
|
|
||||||
|
const lastVersion: WxOplatfromWeappVersion = wxOplatfromWeappVersionMapper.selectOne(new QueryWrapper<WxOplatfromWeappVersion>()
|
||||||
|
.select("version_no")
|
||||||
|
.eq("site_group_id", siteGroup.getGroupId())
|
||||||
|
.orderByDesc("id")
|
||||||
|
.last("limit 1")
|
||||||
|
);
|
||||||
|
|
||||||
|
const config: OplatformConfigVo = coreOplatformConfigService.getWxOplatformConfig();
|
||||||
|
|
||||||
|
const addon: string[] = CollUtil.newArrayList();
|
||||||
|
if (!siteGroup.getApp().isEmpty()) CollUtil.addAll(addon, JSONUtil.parseArray(siteGroup.getApp()));
|
||||||
|
if (!siteGroup.getAddon().isEmpty()) CollUtil.addAll(addon, JSONUtil.parseArray(siteGroup.getAddon()));
|
||||||
|
|
||||||
|
const weappUploadParam: WeappUploadParam = new WeappUploadParam();
|
||||||
|
weappUploadParam.setAppId(config.getDevelopAppId());
|
||||||
|
weappUploadParam.setBaseUrl(RequestUtils.getDomain(true));
|
||||||
|
weappUploadParam.setSiteId(0);
|
||||||
|
weappUploadParam.setVersion("1." + siteGroup.getGroupId() + "." + (lastVersion == null ? 1 : lastVersion.getVersionNo() + 1));
|
||||||
|
weappUploadParam.setUploadPrivateKey(config.getDevelopUploadPrivateKey());
|
||||||
|
weappUploadParam.setAddon(addon);
|
||||||
|
const taskKey: string = coreWeappCloudService.uploadWeapp(weappUploadParam);
|
||||||
|
|
||||||
|
const model: WxOplatfromWeappVersion = new WxOplatfromWeappVersion();
|
||||||
|
model.setSiteGroupId(siteGroup.getGroupId());
|
||||||
|
model.setUserVersion(weappUploadParam.getVersion());
|
||||||
|
model.setVersionNo(lastVersion == null ? 1 : lastVersion.getVersionNo() + 1);
|
||||||
|
model.setCreateTime(System.currentTimeMillis() / 1000);
|
||||||
|
model.setTaskKey(taskKey);
|
||||||
|
wxOplatfromWeappVersionMapper.insert(model);
|
||||||
|
|
||||||
|
weappVersionService.getVersionUploadResult(taskKey, isAll);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* getVersionUploadResult
|
* getVersionUploadResult
|
||||||
*/
|
*/
|
||||||
async getVersionUploadResult(...args: any[]): Promise<any> {
|
async getVersionUploadResult(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
if (scheduler == null || scheduler.isShutdown() || scheduler.isTerminated()) {
|
||||||
return null;
|
scheduler = Executors.newScheduledThreadPool(1);
|
||||||
|
}
|
||||||
|
scheduler.schedule(() => checkVersionUploadResult(taskKey, isAll), 10, TimeUnit.SECONDS);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* uploadSuccess
|
* uploadSuccess
|
||||||
*/
|
*/
|
||||||
async uploadSuccess(...args: any[]): Promise<any> {
|
async uploadSuccess(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const version: WxOplatfromWeappVersion = wxOplatfromWeappVersionMapper.selectOne(new QueryWrapper<WxOplatfromWeappVersion>().eq("task_key", taskKey));
|
||||||
return null;
|
|
||||||
|
const wxOpenService: WxOpenComponentService = WechatUtils.WxOpen().getWxOpenComponentService();
|
||||||
|
|
||||||
|
try {
|
||||||
|
const draftList: WxOpenMaCodeTemplate[] = wxOpenService.getTemplateDraftList();
|
||||||
|
if (ObjectUtil.isNotEmpty(draftList)) {
|
||||||
|
for (const item of draftList) {
|
||||||
|
if (item.getUserVersion() === version.getUserVersion()) {
|
||||||
|
// 添加模板
|
||||||
|
wxOpenService.addToTemplate(item.getDraftId());
|
||||||
|
|
||||||
|
const templateList: WxOpenMaCodeTemplate[] = wxOpenService.getTemplateList();
|
||||||
|
for (const template of templateList) {
|
||||||
|
if (template.getUserVersion() === version.getUserVersion()) {
|
||||||
|
version.setTemplateId(template.getTemplateId().toString());
|
||||||
|
wxOplatfromWeappVersionMapper.updateById(version);
|
||||||
|
|
||||||
|
// 删除之前的模板
|
||||||
|
const prev: WxOplatfromWeappVersion = wxOplatfromWeappVersionMapper.selectOne(new QueryWrapper<WxOplatfromWeappVersion>()
|
||||||
|
.select("template_id")
|
||||||
|
.eq("site_group_id", version.getSiteGroupId())
|
||||||
|
.lt("id", version.getId())
|
||||||
|
.orderByDesc("id")
|
||||||
|
.last("limit 1")
|
||||||
|
);
|
||||||
|
if (prev!= null) {
|
||||||
|
wxOpenService.deleteTemplate(number.valueOf(prev.getTemplateId()));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
console.log("小程序模板上传成功获取模板id异常");
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isAll) {
|
||||||
|
const siteGroup: SiteGroup = siteGroupMapper.selectOne(new QueryWrapper<SiteGroup>()
|
||||||
|
.select("group_id")
|
||||||
|
.gt("group_id", version.getSiteGroupId())
|
||||||
|
.orderByDesc("group_id")
|
||||||
|
.last("limit 1")
|
||||||
|
);
|
||||||
|
if (siteGroup != null) {
|
||||||
|
weappVersionService.add(siteGroup.getGroupId(), true);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* weappCommit
|
* weappCommit
|
||||||
*/
|
*/
|
||||||
async weappCommit(...args: any[]): Promise<any> {
|
async weappCommit(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
if (version == null) {
|
||||||
return null;
|
version = wxOplatfromWeappVersionMapper.selectOne(new QueryWrapper<WxOplatfromWeappVersion>()
|
||||||
|
.eq("site_group_id", siteGroupId)
|
||||||
|
.ne("template_id", "")
|
||||||
|
.orderByDesc("id")
|
||||||
|
.last("limit 1"));
|
||||||
|
if (version == null) throw new BadRequestException("平台尚未上传小程序到模板库");
|
||||||
|
}
|
||||||
|
|
||||||
|
const uploading: WeappVersion = weappVersionMapper.selectOne(new QueryWrapper<WeappVersion>().select("site_id").eq("site_id", siteId).eq("status", WeappVersionStatusEnum.APPLET_AUDITING.getStatus()).last("limit 1"));
|
||||||
|
if (uploading!= null) throw new BadRequestException("小程序有正在上传的版本,请等待上一版本上传完毕后再进行操作");
|
||||||
|
|
||||||
|
const weappCofig: WeappConfigVo = coreWeappConfigService.getWeappConfig(siteId);
|
||||||
|
|
||||||
|
try {
|
||||||
|
const extJson: Record<string, any> = new Record<string, any>();
|
||||||
|
extJson.set("extAppid", weappCofig.getAppId());
|
||||||
|
extJson.set("entryPagePath", "app/pages/index/index");
|
||||||
|
extJson.set("directCommit", true);
|
||||||
|
extJson.putByPath("ext.site_id", siteId);
|
||||||
|
|
||||||
|
const commitResult: WxOpenResult = WechatUtils.WxOpen().getWxOpenComponentService()
|
||||||
|
.getWxMaServiceByAppid(weappCofig.getAppId())
|
||||||
|
.codeCommit(number.valueOf(version.getTemplateId()), version.getUserVersion(), version.getUserDesc(), extJson);
|
||||||
|
|
||||||
|
if (!commitResult.getErrcode() === "0") throw new BadRequestException(commitResult.getErrmsg());
|
||||||
|
|
||||||
|
const model: WeappVersion = new WeappVersion();
|
||||||
|
model.setSiteId(siteId);
|
||||||
|
model.setVersion(version.getUserVersion());
|
||||||
|
model.setVersionNo(version.getVersionNo());
|
||||||
|
model.setDesc(version.getUserDesc());
|
||||||
|
model.setStatus(WeappVersionStatusEnum.APPLET_AUDITING.getStatus());
|
||||||
|
model.setCreateTime(System.currentTimeMillis() / 1000);
|
||||||
|
model.setFromType("open_platform");
|
||||||
|
weappVersionMapper.insert(model);
|
||||||
|
|
||||||
|
// 提交审核
|
||||||
|
weappVersionService.submitAudit(siteId, model.getId());
|
||||||
|
} catch (Exception e) {
|
||||||
|
console.log("小程序提交代码异常");
|
||||||
|
e.printStackTrace();
|
||||||
|
throw new BadRequestException(e.getMessage());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* submitAudit
|
* submitAudit
|
||||||
*/
|
*/
|
||||||
async submitAudit(...args: any[]): Promise<any> {
|
async submitAudit(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const version: WeappVersion = weappVersionMapper.selectById(versionId);
|
||||||
return null;
|
|
||||||
|
try {
|
||||||
|
const wxOpenMaService: WxOpenMaService = (WxOpenMaService) WechatUtils.miniapp(siteId);
|
||||||
|
|
||||||
|
const privacyInfo: WxOpenMaGetCodePrivacyInfoResult = wxOpenMaService.getCodePrivacyInfo();
|
||||||
|
if (!privacyInfo.getErrcode() === "0") {
|
||||||
|
version.setStatus(WeappVersionStatusEnum.APPLET_AUDIT_FAIL.getStatus());
|
||||||
|
version.setFailReason(privacyInfo.getErrmsg());
|
||||||
|
version.setUpdateTime(System.currentTimeMillis() / 1000);
|
||||||
|
weappVersionMapper.updateById(version);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const submitAuditMessage: WxOpenMaSubmitAuditMessage = new WxOpenMaSubmitAuditMessage();
|
||||||
|
const submitResult: WxOpenMaSubmitAuditResult = wxOpenMaService.submitAudit(submitAuditMessage);
|
||||||
|
|
||||||
|
version.setStatus(submitResult.getErrcode() === "0" ? WeappVersionStatusEnum.APPLET_AUDITING.getStatus() : WeappVersionStatusEnum.APPLET_AUDIT_FAIL.getStatus());
|
||||||
|
version.setFailReason(submitResult.getErrmsg());
|
||||||
|
version.setUpdateTime(System.currentTimeMillis() / 1000);
|
||||||
|
version.setAuditid(ObjectUtil.isNotNull(submitResult.getAuditId()) ? submitResult.getAuditId().toString() : "");
|
||||||
|
|
||||||
|
weappVersionMapper.updateById(version);
|
||||||
|
|
||||||
|
if (scheduler != null && !scheduler.isShutdown()) {
|
||||||
|
scheduler.shutdown();
|
||||||
|
}
|
||||||
|
} catch (WxErrorException e) {
|
||||||
|
// 如果检测任务结束未结束
|
||||||
|
if (e.getError().getErrorCode() == 61039) {
|
||||||
|
if (scheduler == null || scheduler.isShutdown() || scheduler.isTerminated()) {
|
||||||
|
scheduler = Executors.newScheduledThreadPool(1);
|
||||||
|
}
|
||||||
|
scheduler.schedule(() => submitAudit(siteId, versionId), 30, TimeUnit.SECONDS);
|
||||||
|
} else {
|
||||||
|
version.setStatus(WeappVersionStatusEnum.APPLET_AUDIT_FAIL.getStatus());
|
||||||
|
version.setFailReason(e.getError().getErrorMsg());
|
||||||
|
version.setUpdateTime(System.currentTimeMillis() / 1000);
|
||||||
|
weappVersionMapper.updateById(version);
|
||||||
|
|
||||||
|
if (scheduler != null && !scheduler.isShutdown()) {
|
||||||
|
scheduler.shutdown();
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log("小程序提交审核异常");
|
||||||
|
e.printStackTrace();
|
||||||
|
throw new BadRequestException(e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* siteWeappCommit
|
* siteWeappCommit
|
||||||
*/
|
*/
|
||||||
async siteWeappCommit(...args: any[]): Promise<any> {
|
async siteWeappCommit(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const site: SiteInfoVo = coreSiteService.getSiteCache(RequestUtils.siteId());
|
||||||
return null;
|
this.weappCommit(site.getSiteId(), site.getGroupId(), null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* getSiteGroupCommitRecord
|
* getSiteGroupCommitRecord
|
||||||
*/
|
*/
|
||||||
async getSiteGroupCommitRecord(...args: any[]): Promise<any> {
|
async getSiteGroupCommitRecord(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const page: number = pageParam.getPage();
|
||||||
return null;
|
const limit: number = pageParam.getLimit();
|
||||||
|
|
||||||
|
const iPage: IPage<SiteGroup> = siteGroupMapper.selectPage(new Page<>(page, limit), new QueryWrapper<SiteGroup>().select("group_id,group_name"));
|
||||||
|
const list: SiteGroupWeappVersionVo[] = [];
|
||||||
|
|
||||||
|
for (const item of iPage.getRecords()) {
|
||||||
|
const vo: SiteGroupWeappVersionVo = new SiteGroupWeappVersionVo();
|
||||||
|
BeanUtils.copyProperties(item, vo);
|
||||||
|
|
||||||
|
const lastVersion: WxOplatfromWeappVersion = wxOplatfromWeappVersionMapper.selectOne(new QueryWrapper<WxOplatfromWeappVersion>().eq("site_group_id", item.getGroupId()).orderByDesc("id").last("limit 1"));
|
||||||
|
if (lastVersion != null) {
|
||||||
|
const versionVo: WxOplatfromWeappVersionVo = new WxOplatfromWeappVersionVo();
|
||||||
|
BeanUtils.copyProperties(lastVersion, versionVo);
|
||||||
|
vo.setCommitRecord(versionVo);
|
||||||
|
}
|
||||||
|
list.add(vo);
|
||||||
|
}
|
||||||
|
|
||||||
|
return PageResult.build(page, limit, iPage.getTotal()).setData(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* undoAudit
|
* undoAudit
|
||||||
*/
|
*/
|
||||||
async undoAudit(...args: any[]): Promise<any> {
|
async undoAudit(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const version: WeappVersion = weappVersionMapper.selectOne(new QueryWrapper<WeappVersion>().eq("id", param.getId()).eq("site_id", RequestUtils.siteId()));
|
||||||
return null;
|
Assert.notNull(version, "未获取到小程序版本提交记录");
|
||||||
|
if (!version.getStatus() === WeappVersionStatusEnum.APPLET_AUDITING.getStatus()) throw new BadRequestException("只有审核中的才可以撤回");
|
||||||
|
|
||||||
|
const weappCofig: WeappConfigVo = coreWeappConfigService.getWeappConfig(RequestUtils.siteId());
|
||||||
|
|
||||||
|
try {
|
||||||
|
const commitResult: WxOpenResult = WechatUtils.WxOpen().getWxOpenComponentService()
|
||||||
|
.getWxMaServiceByAppid(weappCofig.getAppId()).undoCodeAudit();
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new BadRequestException(e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
version.setStatus(WeappVersionStatusEnum.APPLET_AUDIT_UNDO.getStatus());
|
||||||
|
version.setUpdateTime(System.currentTimeMillis() / 1000);
|
||||||
|
weappVersionMapper.updateById(version);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* syncSiteGroupAuthWeapp
|
* syncSiteGroupAuthWeapp
|
||||||
*/
|
*/
|
||||||
async syncSiteGroupAuthWeapp(...args: any[]): Promise<any> {
|
async syncSiteGroupAuthWeapp(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const version: WxOplatfromWeappVersion = wxOplatfromWeappVersionMapper.selectOne(new QueryWrapper<WxOplatfromWeappVersion>()
|
||||||
return null;
|
.eq("site_group_id", param.getSiteGroupId())
|
||||||
|
.ne("template_id", "")
|
||||||
|
.orderByDesc("id")
|
||||||
|
.last("limit 1")
|
||||||
|
);
|
||||||
|
Assert.notNull(version, "平台尚未上传小程序到模板库");
|
||||||
|
|
||||||
|
const siteIds: number[] = siteMapper.selectList(new QueryWrapper<Site>().select("site_id").eq("group_id", param.getSiteGroupId())).stream().map(Site::getSiteId).toList();
|
||||||
|
if (ObjectUtil.isNotEmpty(siteIds)) {
|
||||||
|
const authSite: SysConfig[] = sysConfigMapper.selectList(new QueryWrapper<SysConfig>().in("site_id", siteIds).eq("config_key", ConfigKeyEnum.path.basename(WEAPP_AUTHORIZATION_INFO)));
|
||||||
|
if (ObjectUtil.isNotEmpty(authSite)) {
|
||||||
|
authSite.forEach(item => {
|
||||||
|
weappCommit(item.getSiteId(), param.getSiteGroupId(), version);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,16 @@ export class AgreementServiceImplService {
|
|||||||
* info
|
* info
|
||||||
*/
|
*/
|
||||||
async info(...args: any[]): Promise<any> {
|
async info(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const queryWrapper: QueryWrapper<SysAgreement> = new QueryWrapper<>();
|
||||||
|
queryWrapper.select("site_id, agreement_key, title, content, create_time, update_time");
|
||||||
|
queryWrapper.eq("agreement_key", param.getKey());
|
||||||
|
queryWrapper.eq("site_id", param.siteId());
|
||||||
|
const sysAgreement: SysAgreement = sysAgreementMapper.selectOne(queryWrapper);
|
||||||
|
if (sysAgreement == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
const agreementInfoVo: AgreementInfoVo = new AgreementInfoVo();
|
||||||
|
BeanUtils.copyProperties(sysAgreement, agreementInfoVo);
|
||||||
|
return agreementInfoVo;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,39 +14,98 @@ export class AppServiceImplService {
|
|||||||
* wechatLogin
|
* wechatLogin
|
||||||
*/
|
*/
|
||||||
async wechatLogin(...args: any[]): Promise<any> {
|
async wechatLogin(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
try {
|
||||||
return null;
|
const app: WxMpService = WechatUtils.app(RequestUtils.siteId());
|
||||||
|
|
||||||
|
const wxOAuth2AccessToken: WxOAuth2AccessToken = app.getOAuth2Service().getAccessToken(param.getCode());
|
||||||
|
const wxUser: WxOAuth2UserInfo = app.getOAuth2Service().getUserInfo(wxOAuth2AccessToken, null);
|
||||||
|
|
||||||
|
return this.login(
|
||||||
|
ObjectUtil.defaultIfNull(wxUser.getOpenid(), ""),
|
||||||
|
ObjectUtil.defaultIfNull(wxUser.getUnionId(), ""),
|
||||||
|
ObjectUtil.defaultIfNull(wxUser.getNickname(), ""),
|
||||||
|
ObjectUtil.defaultIfNull(wxUser.getHeadImgUrl(), ""),
|
||||||
|
param.getPid()
|
||||||
|
);
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new BadRequestException(e.getMessage());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* getNewVersion
|
* getNewVersion
|
||||||
*/
|
*/
|
||||||
async getNewVersion(...args: any[]): Promise<any> {
|
async getNewVersion(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const appVersion: AppVersion = appVersionMapper.selectOne(new QueryWrapper<AppVersion>()
|
||||||
|
.eq("site_id", RequestUtils.siteId())
|
||||||
|
.eq("platform", param.getPlatform())
|
||||||
|
.gt("version_code", param.getVersionCode())
|
||||||
|
.eq("status", AppDict.StatusEnum.STATUS_PUBLISHED.getValue())
|
||||||
|
.orderByDesc("version_code"));
|
||||||
|
|
||||||
|
if (appVersion == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const newVersionVo: NewVersionVo = new NewVersionVo();
|
||||||
|
BeanUtil.copyProperties(appVersion, newVersionVo);
|
||||||
|
|
||||||
|
return newVersionVo;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* register
|
* register
|
||||||
*/
|
*/
|
||||||
async register(...args: any[]): Promise<any> {
|
async register(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
switch (param.getRegisterType()) {
|
||||||
|
case "wechat":
|
||||||
|
return wechatRegister(param);
|
||||||
|
default:
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* getAppConfig
|
* getAppConfig
|
||||||
*/
|
*/
|
||||||
async getAppConfig(...args: any[]): Promise<any> {
|
async getAppConfig(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const vo: ApiAppConfigVo = new ApiAppConfigVo();
|
||||||
return null;
|
const config: AppConfigVo = coreAppService.getConfig(RequestUtils.siteId());
|
||||||
|
BeanUtil.copyProperties(config, vo);
|
||||||
|
|
||||||
|
const weappConfig: WeappConfigVo = coreWeappConfigService.getWeappConfig(RequestUtils.siteId());
|
||||||
|
vo.setWeappOriginal(weappConfig.getWeappOriginal());
|
||||||
|
return vo;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* wechatRegister
|
* wechatRegister
|
||||||
*/
|
*/
|
||||||
async wechatRegister(...args: any[]): Promise<any> {
|
async wechatRegister(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
if (param.getOpenid().isEmpty()) throw new BadRequestException("openid不能为空");
|
||||||
return null;
|
try {
|
||||||
|
const member: Member = memberMapper.selectOne(new QueryWrapper<Member>().eq("wxapp_openid", param.getOpenid()).eq("site_id", RequestUtils.siteId()));
|
||||||
|
if (ObjectUtil.isNotNull(member)) throw new BadRequestException("账号已存在");
|
||||||
|
|
||||||
|
if (!param.getUnionid().isEmpty()) {
|
||||||
|
const unionidMember: Member = memberMapper.selectOne(new QueryWrapper<Member>().eq("wx_unionid", param.getUnionid()).eq("site_id", RequestUtils.siteId()));
|
||||||
|
if (ObjectUtil.isNotNull(unionidMember)) throw new BadRequestException("账号已存在");
|
||||||
|
}
|
||||||
|
|
||||||
|
const config: LoginConfigVo = coreMemberConfigService.getLoginConfig(RequestUtils.siteId());
|
||||||
|
if (config.getIsBindMobile() == 1) {
|
||||||
|
if (param.getMobile().isEmpty()) throw new BadRequestException("手机号不能为空");
|
||||||
|
registerService.checkMobileCode(param.getMobile(), param.getMobileKey(), param.getMobileCode());
|
||||||
|
}
|
||||||
|
|
||||||
|
const registerMember: Member = new Member();
|
||||||
|
registerMember.setWxappOpenid(param.getOpenid());
|
||||||
|
registerMember.setMobile(param.getMobile());
|
||||||
|
registerMember.setWxUnionid(param.getUnionid());
|
||||||
|
registerMember.setPid(param.getPid());
|
||||||
|
return registerService.register(registerMember);
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new BadRequestException(e.getMessage());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,47 +14,256 @@ export class DiyFormServiceImplService {
|
|||||||
* getInfo
|
* getInfo
|
||||||
*/
|
*/
|
||||||
async getInfo(...args: any[]): Promise<any> {
|
async getInfo(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
// 查询 const writeConfigWrapper: DiyFormWriteConfig
|
||||||
return null;
|
QueryWrapper<DiyFormWriteConfig> = new QueryWrapper<>();
|
||||||
|
writeConfigWrapper.eq("form_id", formId)
|
||||||
|
.eq("site_id", RequestUtils.siteId());
|
||||||
|
const writeConfig: DiyFormWriteConfig = diyFormWriteConfigMapper.selectOne(writeConfigWrapper);
|
||||||
|
|
||||||
|
// 查询表单信息
|
||||||
|
const formWrapper: QueryWrapper<DiyForm> = new QueryWrapper<>();
|
||||||
|
formWrapper.eq("form_id", formId)
|
||||||
|
.eq("status", 1)
|
||||||
|
.eq("site_id", RequestUtils.siteId());
|
||||||
|
const formInfo: DiyForm = diyFormMapper.selectOne(formWrapper);
|
||||||
|
|
||||||
|
const error: Record<string, any>[] = [];
|
||||||
|
const info: DiyFormInfoVo = new DiyFormInfoVo();
|
||||||
|
if (formInfo != null) {
|
||||||
|
BeanUtil.copyProperties(formInfo, info);
|
||||||
|
// 过滤隐藏的组件
|
||||||
|
const valueObj: Record<string, any> = JSONUtil.parseObj(formInfo.getValue());
|
||||||
|
if (valueObj.containsKey("value")) {
|
||||||
|
const valueArray: JSONArray = valueObj.getJSONArray("value");
|
||||||
|
if (valueArray != null) {
|
||||||
|
const newArray: JSONArray = new JSONArray();
|
||||||
|
for (const obj of valueArray) {
|
||||||
|
const item: Record<string, any> = (Record<string, any>) obj;
|
||||||
|
if (!item.getBool("isHidden", false)) {
|
||||||
|
newArray.add(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
valueObj.put("value", newArray);
|
||||||
|
info.setValue(valueObj.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 检查会员相关限制
|
||||||
|
const memberId: number = RequestUtils.memberId();
|
||||||
|
if (writeConfig != null && memberId != null) {
|
||||||
|
Map<String, String> errorMsg;
|
||||||
|
errorMsg = checkMemberCanJoinOrNot(memberId, writeConfig);
|
||||||
|
if (ObjectUtil.isNotEmpty(errorMsg)) {
|
||||||
|
error.add(errorMsg);
|
||||||
|
}
|
||||||
|
errorMsg = checkFormWriteTime(writeConfig);
|
||||||
|
if (ObjectUtil.isNotEmpty(errorMsg)) {
|
||||||
|
error.add(errorMsg);
|
||||||
|
}
|
||||||
|
errorMsg = checkFormWriteLimitNum(formId, writeConfig);
|
||||||
|
if (ObjectUtil.isNotEmpty(errorMsg)) {
|
||||||
|
error.add(errorMsg);
|
||||||
|
}
|
||||||
|
errorMsg = checkMemberWriteLimitNum(memberId, formId, writeConfig);
|
||||||
|
if (ObjectUtil.isNotEmpty(errorMsg)) {
|
||||||
|
error.add(errorMsg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
const errorMap: Record<string, any> = {};
|
||||||
|
errorMap.put("title", "当前表单无法查看");
|
||||||
|
errorMap.put("type", "表单状态");
|
||||||
|
errorMap.put("desc", "该表单已关闭");
|
||||||
|
error.add(errorMap);
|
||||||
|
}
|
||||||
|
info.setError(error);
|
||||||
|
return info;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* addRecord
|
* addRecord
|
||||||
*/
|
*/
|
||||||
async addRecord(...args: any[]): Promise<any> {
|
async addRecord(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
diyFormRecordsParam.setSiteId(RequestUtils.siteId());
|
||||||
return null;
|
diyFormRecordsParam.setMemberId(RequestUtils.memberId());
|
||||||
|
|
||||||
|
// 检查表单是否存在且已开启
|
||||||
|
const formQueryWrapper: QueryWrapper<DiyForm> = new QueryWrapper<>();
|
||||||
|
formQueryWrapper.eq("form_id", diyFormRecordsParam.getFormId())
|
||||||
|
.eq("site_id", RequestUtils.siteId());
|
||||||
|
const formInfo: DiyForm = diyFormMapper.selectOne(formQueryWrapper);
|
||||||
|
if (formInfo == null) {
|
||||||
|
throw new ApiException("表单不存在");
|
||||||
|
}
|
||||||
|
if (formInfo.getStatus() == 0) {
|
||||||
|
throw new ApiException("该表单已关闭");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 查询表单填写配置
|
||||||
|
const writeConfigQueryWrapper: QueryWrapper<DiyFormWriteConfig> = new QueryWrapper<>();
|
||||||
|
writeConfigQueryWrapper.eq("form_id", diyFormRecordsParam.getFormId())
|
||||||
|
.eq("site_id", RequestUtils.siteId());
|
||||||
|
const writeConfig: DiyFormWriteConfig = diyFormWriteConfigMapper.selectOne(writeConfigQueryWrapper);
|
||||||
|
|
||||||
|
if (writeConfig != null) {
|
||||||
|
// 检查会员是否可以参与
|
||||||
|
const canJoinError: Record<string, any> = checkMemberCanJoinOrNot(RequestUtils.memberId(), writeConfig);
|
||||||
|
if (!canJoinError.length === 0) {
|
||||||
|
throw new ApiException(canJoinError.get("desc"));
|
||||||
|
}
|
||||||
|
|
||||||
|
// 检查表单填写时间
|
||||||
|
const timeError: Record<string, any> = checkFormWriteTime(writeConfig);
|
||||||
|
if (!timeError.length === 0) {
|
||||||
|
throw new ApiException(timeError.get("desc"));
|
||||||
|
}
|
||||||
|
|
||||||
|
// 检查表单总填写次数限制
|
||||||
|
const formLimitError: Record<string, any> = checkFormWriteLimitNum(diyFormRecordsParam.getFormId(), writeConfig);
|
||||||
|
if (!formLimitError.length === 0) {
|
||||||
|
throw new ApiException(formLimitError.get("desc"));
|
||||||
|
}
|
||||||
|
|
||||||
|
// 检查会员填写次数限制
|
||||||
|
const memberLimitError: Record<string, any> = checkMemberWriteLimitNum(RequestUtils.memberId(), diyFormRecordsParam.getFormId(), writeConfig);
|
||||||
|
if (!memberLimitError.length === 0) {
|
||||||
|
throw new ApiException(memberLimitError.get("desc"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 调用核心服务添加记录
|
||||||
|
return coreDiyFormRecordsService.add(diyFormRecordsParam);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* getResult
|
* getResult
|
||||||
*/
|
*/
|
||||||
async getResult(...args: any[]): Promise<any> {
|
async getResult(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const diyFormRecords: DiyFormRecords = diyFormRecordsMapper.selectOne(new QueryWrapper<DiyFormRecords>().eq("record_id", recordId).eq("site_id", RequestUtils.siteId()).eq("member_id", RequestUtils.memberId()));
|
||||||
return null;
|
if (ObjectUtil.isEmpty(diyFormRecords)) throw new ApiException("表单记录不存在");
|
||||||
|
const vo: DiyFormRecordsInfoVo = new DiyFormRecordsInfoVo();
|
||||||
|
BeanUtil.copyProperties(diyFormRecords, vo);
|
||||||
|
const diyFormSubmitConfig: DiyFormSubmitConfig = diyFormSubmitConfigMapper.selectOne(new QueryWrapper<DiyFormSubmitConfig>().eq("form_id", vo.getFormId()));
|
||||||
|
const configInfoVo: DiyFormSubmitConfigInfoVo = new DiyFormSubmitConfigInfoVo();
|
||||||
|
if (ObjectUtil.isNotEmpty(diyFormSubmitConfig)) {
|
||||||
|
BeanUtil.copyProperties(diyFormSubmitConfig, configInfoVo);
|
||||||
|
}
|
||||||
|
vo.setDiyFormSubmitConfig(configInfoVo);
|
||||||
|
return vo;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* getFormRecordInfo
|
* getFormRecordInfo
|
||||||
*/
|
*/
|
||||||
async getFormRecordInfo(...args: any[]): Promise<any> {
|
async getFormRecordInfo(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const diyFormRecords: DiyFormRecords = diyFormRecordsMapper.selectOne(new QueryWrapper<DiyFormRecords>().eq("record_id", recordId).eq("site_id", RequestUtils.siteId()).eq("member_id", RequestUtils.memberId()));
|
||||||
return null;
|
const vo: DiyFormRecordsDetailVo = new DiyFormRecordsDetailVo();
|
||||||
|
if (ObjectUtil.isEmpty(diyFormRecords)) {
|
||||||
|
return vo;
|
||||||
|
}
|
||||||
|
BeanUtil.copyProperties(diyFormRecords, vo);
|
||||||
|
const list: DiyFormRecordsFields[] = diyFormRecordsFieldsMapper.selectList(new QueryWrapper<DiyFormRecordsFields>().eq("record_id", vo.getRecordId()));
|
||||||
|
if (ObjectUtil.isNotEmpty(list)) {
|
||||||
|
const volist: DiyFormRecordsFieldsListVo[] = [];
|
||||||
|
for (const item of list) {
|
||||||
|
const diyFormRecordsFieldsListVo: DiyFormRecordsFieldsListVo = new DiyFormRecordsFieldsListVo();
|
||||||
|
BeanUtils.copyProperties(item, diyFormRecordsFieldsListVo);
|
||||||
|
volist.add(diyFormRecordsFieldsListVo);
|
||||||
|
}
|
||||||
|
vo.setRecordsFieldList(volist);
|
||||||
|
}
|
||||||
|
return vo;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* getMemberInfoRecord
|
* getMemberInfoRecord
|
||||||
*/
|
*/
|
||||||
async getMemberInfoRecord(...args: any[]): Promise<any> {
|
async getMemberInfoRecord(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const memberConfig: MemberConfigVo = coreMemberConfigService.getMemberConfig(RequestUtils.siteId());
|
||||||
return null;
|
if (ObjectUtil.isEmpty(memberConfig.getFormId())) {
|
||||||
|
return List.of();
|
||||||
|
}
|
||||||
|
const formId: number = memberConfig.getFormId();
|
||||||
|
const mpjqw: MPJQueryWrapper<DiyFormRecords> = new MPJQueryWrapper<>();
|
||||||
|
mpjqw.setAlias("fr").leftJoin("?_diy_form_records_fields frf on frf.record_id = fr.record_id".replace("?_", this.config.get('tablePrefix')));
|
||||||
|
mpjqw.select("frf.form_id, frf.form_field_id, frf.field_key, frf.field_type, frf.field_name, frf.field_value, frf.field_required, frf.field_unique, frf.privacy_protection");
|
||||||
|
mpjqw.eq("fr.member_id", RequestUtils.memberId())
|
||||||
|
.eq("fr.form_id", formId)
|
||||||
|
.orderByDesc("fr.create_time");
|
||||||
|
const diyFormRecordsFields: DiyFormRecordsFields[] = diyFormRecordsMapper.selectJoinList(DiyFormRecordsFields.class, mpjqw);
|
||||||
|
|
||||||
|
const diyFormMpjqw: MPJQueryWrapper<DiyForm> = new MPJQueryWrapper<>();
|
||||||
|
diyFormMpjqw.setAlias("df")
|
||||||
|
.leftJoin("?_diy_form_fields dfi on dfi.form_id = df.form_id".replace("?_", this.config.get('tablePrefix')));
|
||||||
|
diyFormMpjqw.select("df.form_id,df.type, dfi.field_id, dfi.field_key, dfi.field_type, dfi.field_name, dfi.field_required, dfi.field_hidden, dfi.field_unique, dfi.privacy_protection");
|
||||||
|
diyFormMpjqw.eq("df.form_id", formId).eq("df.status", 1);
|
||||||
|
const diyFormFields: DiyFormFields[] = diyFormMapper.selectJoinList(DiyFormFields.class, diyFormMpjqw);
|
||||||
|
|
||||||
|
|
||||||
|
if (ObjectUtil.isEmpty(diyFormFields)) {
|
||||||
|
return List.of();
|
||||||
|
}
|
||||||
|
if (ObjectUtil.isEmpty(diyFormRecordsFields)) {
|
||||||
|
return setResult(diyFormFields);
|
||||||
|
}
|
||||||
|
|
||||||
|
const result: DiyMemberRecordVo = setResult(diyFormFields);
|
||||||
|
const fieldMap: Record<string, any> = diyFormRecordsFields.stream().collect(Collectors.toMap(DiyFormRecordsFields::getFieldKey, field => field));
|
||||||
|
for (const field of result.getFormField()) {
|
||||||
|
if (fieldMap.containsKey(field.getFieldKey())) {
|
||||||
|
field.setFieldValue(fieldMap.get(field.getFieldKey()).getFieldValue() == null ? "" : fieldMap.get(field.getFieldKey()).getFieldValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* editRecord
|
* editRecord
|
||||||
*/
|
*/
|
||||||
async editRecord(...args: any[]): Promise<any> {
|
async editRecord(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const diyFormRecords: DiyFormRecords = diyFormRecordsMapper.selectById(param.getRecordId());
|
||||||
return null;
|
if (ObjectUtil.isEmpty(diyFormRecords)) {
|
||||||
|
throw new ApiException("表单记录不存在");
|
||||||
|
}
|
||||||
|
const diyForm: DiyForm = diyFormMapper.selectOne(new LambdaQueryWrapper<DiyForm>().eq(DiyForm::getFormId, param.getFormId()));
|
||||||
|
if (ObjectUtil.isEmpty(diyForm)) {
|
||||||
|
throw new ApiException("表单不存在");
|
||||||
|
}
|
||||||
|
if (diyForm.getStatus() == 0) {
|
||||||
|
throw new ApiException("该表单已关闭");
|
||||||
|
}
|
||||||
|
// 查询表单填写配置
|
||||||
|
const writeConfigQueryWrapper: QueryWrapper<DiyFormWriteConfig> = new QueryWrapper<>();
|
||||||
|
writeConfigQueryWrapper.eq("form_id", param.getFormId())
|
||||||
|
.eq("site_id", RequestUtils.siteId());
|
||||||
|
const writeConfig: DiyFormWriteConfig = diyFormWriteConfigMapper.selectOne(writeConfigQueryWrapper);
|
||||||
|
|
||||||
|
if (writeConfig != null) {
|
||||||
|
// 检查会员是否可以参与
|
||||||
|
const canJoinError: Record<string, any> = checkMemberCanJoinOrNot(RequestUtils.memberId(), writeConfig);
|
||||||
|
if (!canJoinError.length === 0) {
|
||||||
|
throw new ApiException(canJoinError.get("desc"));
|
||||||
|
}
|
||||||
|
|
||||||
|
// 检查表单填写时间
|
||||||
|
const timeError: Record<string, any> = checkFormWriteTime(writeConfig);
|
||||||
|
if (!timeError.length === 0) {
|
||||||
|
throw new ApiException(timeError.get("desc"));
|
||||||
|
}
|
||||||
|
|
||||||
|
// 检查表单总填写次数限制
|
||||||
|
const formLimitError: Record<string, any> = checkFormWriteLimitNum(param.getFormId(), writeConfig);
|
||||||
|
if (!formLimitError.length === 0) {
|
||||||
|
throw new ApiException(formLimitError.get("desc"));
|
||||||
|
}
|
||||||
|
|
||||||
|
// 检查会员填写次数限制
|
||||||
|
const memberLimitError: Record<string, any> = checkMemberWriteLimitNum(RequestUtils.memberId(), param.getFormId(), writeConfig);
|
||||||
|
if (!memberLimitError.length === 0) {
|
||||||
|
throw new ApiException(memberLimitError.get("desc"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
coreDiyFormRecordsService.edit(param);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,39 +14,150 @@ export class DiyServiceImplService {
|
|||||||
* info
|
* info
|
||||||
*/
|
*/
|
||||||
async info(...args: any[]): Promise<any> {
|
async info(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const id: number = ObjectUtil.defaultIfNull(param.getId(), 0);
|
||||||
return null;
|
const name: string = ObjectUtil.defaultIfNull(path.basename(param), "");
|
||||||
|
|
||||||
|
log.info("id: {}, name: {}", id, name);
|
||||||
|
|
||||||
|
const startUpPage: StartUpPageConfigVo = null;
|
||||||
|
const template: Record<string, any> = null;
|
||||||
|
|
||||||
|
if (!StrUtil.isEmpty(name)) {
|
||||||
|
// 查询启动页
|
||||||
|
startUpPage = coreDiyConfigService.getStartUpPageConfig(param.siteId(), name);
|
||||||
|
log.info("startUpPage: {}", JSONUtil.toJsonStr(startUpPage));
|
||||||
|
|
||||||
|
const templateParam: TemplateParam = new TemplateParam();
|
||||||
|
String[] key = { name };
|
||||||
|
templateParam.setKey(key);
|
||||||
|
template = TemplateEnum.getTemplate(templateParam).getJSONObject(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (id == 0 && startUpPage != null && template != null && !startUpPage.getPage() === template.getStr("page")) {
|
||||||
|
log.info("enter if, template: {}", template.toString());
|
||||||
|
return startUpPage;
|
||||||
|
} else {
|
||||||
|
const queryWrapper: QueryWrapper<DiyPage> = new QueryWrapper();
|
||||||
|
queryWrapper.eq("site_id", param.siteId());
|
||||||
|
log.info("site_id: {}",param.siteId() );
|
||||||
|
|
||||||
|
const info: DiyPage = null;
|
||||||
|
|
||||||
|
log.info("id: {}, name: {}", id, name);
|
||||||
|
if (id > 0) {
|
||||||
|
queryWrapper.eq("id", id);
|
||||||
|
info = diyPageMapper.selectOne(queryWrapper);
|
||||||
|
} else if (!name.length === 0) {
|
||||||
|
queryWrapper.eq("name", name);
|
||||||
|
queryWrapper.eq("is_default", 1);
|
||||||
|
queryWrapper.orderByDesc("create_time");
|
||||||
|
queryWrapper.last("limit 1");
|
||||||
|
info = diyPageMapper.selectOne(queryWrapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
log.info("info: {}", JSONUtil.toJsonStr(info));
|
||||||
|
|
||||||
|
if (info == null) {
|
||||||
|
if (!name.length === 0) {
|
||||||
|
const pageData: Record<string, any> = getFirstPageData(name, "");
|
||||||
|
if (pageData != null) {
|
||||||
|
info = new DiyPage();
|
||||||
|
info.setId(param.siteId());
|
||||||
|
info.setTitle(pageData.getStr("title"));
|
||||||
|
info.setName(pageData.getStr("type"));
|
||||||
|
info.setType(pageData.getStr("type"));
|
||||||
|
info.setTemplate(pageData.getStr("template"));
|
||||||
|
info.setMode(pageData.getStr("mode"));
|
||||||
|
info.setValue(pageData.getJSONObject("data").toString());
|
||||||
|
info.setIsDefault(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
log.info("info: {}", JSONUtil.toJsonStr(info));
|
||||||
|
if (info == null) return null;
|
||||||
|
|
||||||
|
const vo: DiyInfoVo = new DiyInfoVo();
|
||||||
|
BeanUtils.copyProperties(info, vo);
|
||||||
|
log.info("vo: {}", JSONUtil.toJsonStr(vo));
|
||||||
|
return vo;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* getFirstPageData
|
* getFirstPageData
|
||||||
*/
|
*/
|
||||||
async getFirstPageData(...args: any[]): Promise<any> {
|
async getFirstPageData(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const pages: Record<string, any> = PagesEnum.getPagesByAddon(type, addon);
|
||||||
return null;
|
if (pages == null || pages.keySet().size() == 0) return null;
|
||||||
|
|
||||||
|
const template: string = pages.keySet().iterator().next();
|
||||||
|
const data: Record<string, any> = pages.getJSONObject(template);
|
||||||
|
data.set("type", type);
|
||||||
|
data.set("template", template);
|
||||||
|
|
||||||
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* tabbar
|
* tabbar
|
||||||
*/
|
*/
|
||||||
async tabbar(...args: any[]): Promise<any> {
|
async tabbar(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const diyTabbarVo: DiyTabbarVo = null;
|
||||||
return null;
|
return diyTabbarVo;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* tabbarList
|
* tabbarList
|
||||||
*/
|
*/
|
||||||
async tabbarList(...args: any[]): Promise<any> {
|
async tabbarList(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const list: BottomConfigVo[] = coreDiyConfigService.getBottomList();
|
||||||
return null;
|
const site: SiteInfoVo = coreSiteService.getSiteCache(param.siteId());
|
||||||
|
|
||||||
|
const tabbarList: BottomConfigVo[] = [];
|
||||||
|
for (const item of list) {
|
||||||
|
if (item.getKey() === "app" && list.size() > 1 && site.getApps().size() == 1) continue;
|
||||||
|
const config: BottomConfigVo = coreDiyConfigService.getBottomConfig(param.siteId(), item.getKey());
|
||||||
|
tabbarList.add(config);
|
||||||
|
}
|
||||||
|
|
||||||
|
return tabbarList;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* share
|
* share
|
||||||
*/
|
*/
|
||||||
async share(...args: any[]): Promise<any> {
|
async share(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const queryWrapper: QueryWrapper<DiyRoute> = new QueryWrapper();
|
||||||
return null;
|
queryWrapper.select("id,title,name,page,share,is_share");
|
||||||
|
queryWrapper.eq("page", param.getRoute());
|
||||||
|
queryWrapper.eq("site_id", param.siteId());
|
||||||
|
|
||||||
|
const diyRoute: DiyRoute = diyRouteMapper.selectOne(queryWrapper);
|
||||||
|
if (diyRoute == null || diyRoute.getShare().isEmpty()) return new Record<string, any>();
|
||||||
|
|
||||||
|
const share: Record<string, any> = JSONUtil.parseObj(diyRoute.getShare());
|
||||||
|
share.set("route", diyRoute.getPage());
|
||||||
|
share.set("query", "");
|
||||||
|
|
||||||
|
const query: Record<string, any> = new Record<string, any>();
|
||||||
|
|
||||||
|
if (param.getParams() != null && !param.getParams().isEmpty()) {
|
||||||
|
query = JSONUtil.parseObj(param.getParams());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (param.memberId() != null && param.memberId() > 0) {
|
||||||
|
query.set("mid", param.memberId());
|
||||||
|
}
|
||||||
|
|
||||||
|
const queryStr: string = "";
|
||||||
|
if (query.keySet().size() > 0) {
|
||||||
|
for (const key of query.keySet()) {
|
||||||
|
queryStr += queryStr.length === 0 ? key + "=" + query.getStr(key) : "&" + key + "=" + query.getStr(key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
share.set("url", share.getStr("route") + (queryStr.length === 0 ? "" : "?" + queryStr));
|
||||||
|
|
||||||
|
return share;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,23 +14,64 @@ export class AuthServiceImplService {
|
|||||||
* checkSite
|
* checkSite
|
||||||
*/
|
*/
|
||||||
async checkSite(...args: any[]): Promise<any> {
|
async checkSite(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const siteId: number = RequestUtils.apiSiteId();
|
||||||
return null;
|
|
||||||
|
if (siteId == 0) {
|
||||||
|
const site: Site = siteMapper.selectOne(new QueryWrapper<Site>().select("site_id").eq("site_domain", RequestUtils.getRequestDomain()));
|
||||||
|
if (site == null) throw new UnauthorizedException("站点不存在", 403);
|
||||||
|
siteId = site.getSiteId();
|
||||||
|
}
|
||||||
|
|
||||||
|
const siteInfoVo: SiteInfoVo = coreSiteService.getSiteCache(siteId);
|
||||||
|
if(ObjectUtil.isEmpty(siteInfoVo)){
|
||||||
|
throw new UnauthorizedException("站点不存在", 403);
|
||||||
|
}
|
||||||
|
const rule: string = RequestUtils.getReqeustURI();
|
||||||
|
if(!rule === "site"){
|
||||||
|
if(siteInfoVo.getStatus() == SiteStatusEnum.CLOSE.getCode() || siteInfoVo.getExpireTime() < DateUtils.currTime()){
|
||||||
|
throw new UnauthorizedException("站点已停止", 402);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
RequestUtils.setSiteId(siteId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* checkSiteAuth
|
* checkSiteAuth
|
||||||
*/
|
*/
|
||||||
async checkSiteAuth(...args: any[]): Promise<any> {
|
async checkSiteAuth(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
if(ObjectUtil.isNotNull(RequestUtils.memberId()) && RequestUtils.memberId()>0){
|
||||||
return null;
|
const memberInfoParam: MemberInfoParam = new MemberInfoParam();
|
||||||
|
memberInfoParam.setMemberId(RequestUtils.memberId());
|
||||||
|
memberInfoParam.setSiteId(RequestUtils.siteId());
|
||||||
|
const memberInfoVo: MemberInfoVo = memberService.info(memberInfoParam);
|
||||||
|
if(ObjectUtil.isNull(memberInfoVo) || ObjectUtil.isEmpty(memberInfoVo)){
|
||||||
|
// 退出登录
|
||||||
|
StpUtil.logout(RequestUtils.apiToken());
|
||||||
|
throw new UnauthorizedException("MEMBER_NOT_EXIST", 401);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* checkChannel
|
* checkChannel
|
||||||
*/
|
*/
|
||||||
async checkChannel(...args: any[]): Promise<any> {
|
async checkChannel(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const channel: string = RequestUtils.channel();
|
||||||
return null;
|
const siteId: number = RequestUtils.siteId();
|
||||||
|
if (channel != null){
|
||||||
|
if (channel === ChannelEnum.H5.getCode()){
|
||||||
|
const h5ConfigVo: H5ConfigVo = coreH5Service.getH5(siteId);
|
||||||
|
const isOpen: number = h5ConfigVo.getIsOpen();
|
||||||
|
if(isOpen==0){
|
||||||
|
throw new UnauthorizedException("站点已停止", 402);
|
||||||
|
}
|
||||||
|
}else if (channel === ChannelEnum.PC.getCode()){
|
||||||
|
const pcConfigVo: PcConfigVo = corePcService.getPc(siteId);
|
||||||
|
const isOpen: number = pcConfigVo.getIsOpen();
|
||||||
|
if(isOpen==0){
|
||||||
|
throw new UnauthorizedException("站点已停止", 402);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,63 +14,130 @@ export class LoginServiceImplService {
|
|||||||
* setRegisterService
|
* setRegisterService
|
||||||
*/
|
*/
|
||||||
async setRegisterService(...args: any[]): Promise<any> {
|
async setRegisterService(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
this.registerService = registerService;
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* account
|
* account
|
||||||
*/
|
*/
|
||||||
async account(...args: any[]): Promise<number> {
|
async account(...args: any[]): Promise<number> {
|
||||||
// TODO: 实现业务逻辑
|
const member: Member = memberMapper.selectOne(new QueryWrapper<Member>().eq("site_id", RequestUtils.siteId()).and(i => i.eq("username", param.getUsername()).or().eq("mobile", param.getUsername())));
|
||||||
return 0;
|
|
||||||
|
if (ObjectUtil.isNull(member)) throw new BadRequestException("账号不存在");
|
||||||
|
if (!PasswordEncipher.matche(param.getPassword(), member.getPassword())) throw new BadRequestException("账号或密码错误");
|
||||||
|
member.setLoginType(MemberLoginTypeEnum.USERNAME.getType());
|
||||||
|
|
||||||
|
return this.login(member);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* mobile
|
* mobile
|
||||||
*/
|
*/
|
||||||
async mobile(...args: any[]): Promise<any> {
|
async mobile(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const member: Member = memberMapper.selectOne(new QueryWrapper<Member>().eq("mobile", param.getMobile()).eq("site_id", RequestUtils.siteId()));
|
||||||
return null;
|
|
||||||
|
if (member != null) {
|
||||||
|
member.setLoginType(MemberLoginTypeEnum.MOBILE.getType());
|
||||||
|
return this.login(member);
|
||||||
|
} else {
|
||||||
|
const config: LoginConfigVo = coreMemberConfigService.getLoginConfig(RequestUtils.siteId());
|
||||||
|
// 开启强制绑定手机号 登录会自动注册
|
||||||
|
if (config.getIsBindMobile() == 1) {
|
||||||
|
const registerParam: MobileRegisterParam = new MobileRegisterParam();
|
||||||
|
BeanUtils.copyProperties(param, registerParam);
|
||||||
|
return registerService.mobile(registerParam);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw new BadRequestException("账号不存在");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* login
|
* login
|
||||||
*/
|
*/
|
||||||
async login(...args: any[]): Promise<any> {
|
async login(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
member = memberMapper.selectById(member.getMemberId());
|
||||||
return null;
|
if (StatusEnum.OFF === member.getStatus()) throw new BadRequestException("账号被锁定");
|
||||||
|
|
||||||
|
member.setLoginTime(System.currentTimeMillis() / 1000);
|
||||||
|
member.setLoginIp(RequestUtils.ip());
|
||||||
|
member.setLoginCount(member.getLoginCount() + 1);
|
||||||
|
member.setLoginChannel(RequestUtils.channel());
|
||||||
|
if (member.getLoginType() != null) member.setLoginType(member.getLoginType());
|
||||||
|
member.setLastVisitTime(System.currentTimeMillis() / 1000);
|
||||||
|
this.memberMapper.updateById(member);
|
||||||
|
|
||||||
|
const loginModel: SaLoginModel = SaLoginModel.create();
|
||||||
|
loginModel.setDevice(RequestUtils.handler().getHeader("User-Agent"));
|
||||||
|
loginModel.setExtra("memberId", member.getMemberId());
|
||||||
|
loginModel.setExtra("username", member.getUsername());
|
||||||
|
loginModel.setExtra("siteId", member.getSiteId());
|
||||||
|
// 执行登录
|
||||||
|
StpUtil.login("member-" + member.getMemberId(), loginModel);
|
||||||
|
// 获取返回内容
|
||||||
|
const saTokenInfo: SaTokenInfo = StpUtil.getTokenInfo();
|
||||||
|
|
||||||
|
const vo: LoginVo = new LoginVo();
|
||||||
|
vo.setToken(saTokenInfo.getTokenValue());
|
||||||
|
vo.setExpiresTime(DateUtils.currTime()+saTokenInfo.getTokenTimeout());
|
||||||
|
vo.setMobile(member.getMobile());
|
||||||
|
|
||||||
|
// 会员登录事件
|
||||||
|
const loginEvent: MemberLoginEvent = new MemberLoginEvent();
|
||||||
|
loginEvent.setSiteId(RequestUtils.siteId());
|
||||||
|
loginEvent.addAppSign("core");
|
||||||
|
loginEvent.setName("MemberLoginEvent");
|
||||||
|
loginEvent.setMember(member);
|
||||||
|
EventPublisher.publishEvent(loginEvent);
|
||||||
|
|
||||||
|
return vo;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* resetPassword
|
* resetPassword
|
||||||
*/
|
*/
|
||||||
async resetPassword(...args: any[]): Promise<any> {
|
async resetPassword(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const member: Member = memberMapper.selectOne(new QueryWrapper<Member>().select("member_id").eq("mobile", param.getMobile()).eq("site_id", RequestUtils.siteId()));
|
||||||
return null;
|
if (ObjectUtil.isNull(member)) throw new BadRequestException("当前填写的手机号不存在账号");
|
||||||
|
|
||||||
|
member.setPassword(PasswordEncipher.encode(param.getPassword()));
|
||||||
|
this.memberMapper.updateById(member);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* getLoginConfig
|
* getLoginConfig
|
||||||
*/
|
*/
|
||||||
async getLoginConfig(...args: any[]): Promise<any> {
|
async getLoginConfig(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
return coreMemberConfigService.getLoginConfig(RequestUtils.siteId());
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* sendMobileCode
|
* sendMobileCode
|
||||||
*/
|
*/
|
||||||
async sendMobileCode(...args: any[]): Promise<any> {
|
async sendMobileCode(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const key: string = RandomUtil.randomString(30);
|
||||||
return null;
|
|
||||||
|
const cache: MobileCodeCacheVo = new MobileCodeCacheVo();
|
||||||
|
cache.setMobile(param.getMobile());
|
||||||
|
cache.setCode(String.format("%0" + 4 + "d", RandomUtil.randomInt(1, 9999)));
|
||||||
|
cache.setType(param.getType());
|
||||||
|
|
||||||
|
const data: Record<string, any> = {};
|
||||||
|
data.put("mobile", param.getMobile());
|
||||||
|
data.put("code", cache.getCode());
|
||||||
|
|
||||||
|
coreNoticeService.send(param.siteId(), "member_verify_code", data);
|
||||||
|
|
||||||
|
this.cached.put(key, cache, 600);
|
||||||
|
|
||||||
|
const vo: SendMobileCodeVo = new SendMobileCodeVo();
|
||||||
|
vo.setKey(key);
|
||||||
|
return vo;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* logout
|
* logout
|
||||||
*/
|
*/
|
||||||
async logout(...args: any[]): Promise<any> {
|
async logout(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
StpUtil.logout();
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,39 +14,110 @@ export class RegisterServiceImplService {
|
|||||||
* checkLoginConfig
|
* checkLoginConfig
|
||||||
*/
|
*/
|
||||||
async checkLoginConfig(...args: any[]): Promise<any> {
|
async checkLoginConfig(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const config: LoginConfigVo = coreMemberConfigService.getLoginConfig(RequestUtils.siteId());
|
||||||
return null;
|
if (MemberLoginTypeEnum.USERNAME.getType() === type && config.getIsUsername() != 1) throw new BadRequestException("未开启账号登录注册");
|
||||||
|
if (MemberLoginTypeEnum.MOBILE.getType() === type && config.getIsMobile() != 1) throw new BadRequestException("未开启手机验证码登录注册");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* account
|
* account
|
||||||
*/
|
*/
|
||||||
async account(...args: any[]): Promise<number> {
|
async account(...args: any[]): Promise<number> {
|
||||||
// TODO: 实现业务逻辑
|
const memberExist: Member = memberMapper.selectOne(new QueryWrapper<Member>().select("member_id").eq("username", param.getUsername()).eq("site_id", RequestUtils.siteId()));
|
||||||
return 0;
|
if (ObjectUtil.isNotNull(memberExist)) throw new BadRequestException("账号已存在");
|
||||||
|
|
||||||
|
if (!param.getMobile().isEmpty()) {
|
||||||
|
const mobileExist: Member = memberMapper.selectOne(new QueryWrapper<Member>().select("member_id").eq("mobile", param.getMobile()).eq("site_id", RequestUtils.siteId()));
|
||||||
|
if (ObjectUtil.isNotNull(mobileExist)) throw new BadRequestException("当前手机号已绑定账号");
|
||||||
|
this.checkMobileCode(param.getMobile(), param.getMobileKey(), param.getMobileCode());
|
||||||
|
}
|
||||||
|
|
||||||
|
const member: Member = new Member();
|
||||||
|
member.setUsername(param.getUsername());
|
||||||
|
member.setNickname(param.getUsername());
|
||||||
|
member.setPassword(PasswordEncipher.encode(param.getPassword()));
|
||||||
|
member.setMobile(param.getMobile());
|
||||||
|
member.setRegisterType(MemberRegisterTypeEnum.USERNAME.getType());
|
||||||
|
member.setLoginType(MemberLoginTypeEnum.USERNAME.getType());
|
||||||
|
member.setPid(param.getPid());
|
||||||
|
|
||||||
|
return this.register(member);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* mobile
|
* mobile
|
||||||
*/
|
*/
|
||||||
async mobile(...args: any[]): Promise<any> {
|
async mobile(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const memberExist: Member = memberMapper.selectOne(new QueryWrapper<Member>().select("member_id").eq("mobile", param.getMobile()).eq("site_id", RequestUtils.siteId()));
|
||||||
return null;
|
if (ObjectUtil.isNotNull(memberExist)) throw new BadRequestException("账号已存在");
|
||||||
|
|
||||||
|
const member: Member = new Member();
|
||||||
|
member.setMobile(param.getMobile());
|
||||||
|
member.setNickname(param.getMobile().substring(0, 3) + "****" + param.getMobile().substring(7));
|
||||||
|
member.setRegisterType(MemberRegisterTypeEnum.MOBILE.getType());
|
||||||
|
member.setLoginType(MemberLoginTypeEnum.MOBILE.getType());
|
||||||
|
member.setPid(param.getPid());
|
||||||
|
member.setHeadimg(ObjectUtil.defaultIfNull(param.getAvatar(), ""));
|
||||||
|
member.setNickname(ObjectUtil.defaultIfNull(param.getNickname(), ""));
|
||||||
|
member.setWxOpenid(ObjectUtil.defaultIfNull(param.getOpenid(), ""));
|
||||||
|
|
||||||
|
return this.register(member);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* register
|
* register
|
||||||
*/
|
*/
|
||||||
async register(...args: any[]): Promise<any> {
|
async register(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
const request: HttpServletRequest = RequestUtils.handler();
|
||||||
return null;
|
const pid: number = ObjectUtil.defaultIfNull(member.getPid(), 0);
|
||||||
|
if (pid > 0) {
|
||||||
|
const inviteMember: Member = memberMapper.selectOne(new QueryWrapper<Member>().select("member_id").eq("member_id", member.getPid()).eq("site_id", RequestUtils.siteId()));
|
||||||
|
if (inviteMember == null) member.setPid(0);
|
||||||
|
}
|
||||||
|
if (member.getMobile() != null && !member.getMobile().isEmpty()) {
|
||||||
|
const mobile: Member = memberMapper.selectOne(new QueryWrapper<Member>().select("member_id").eq("mobile", member.getMobile()).eq("site_id", RequestUtils.siteId()));
|
||||||
|
if (ObjectUtil.isNotNull(mobile)) throw new BadRequestException("账号已存在");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ObjectUtil.isEmpty(member.getNickname())) {
|
||||||
|
if (ObjectUtil.isNotEmpty(member.getUsername())) {
|
||||||
|
member.setNickname(member.getUsername());
|
||||||
|
} else if (ObjectUtil.isNotEmpty(member.getMobile())) {
|
||||||
|
member.setNickname(member.getMobile().substring(0, 3) + "****" + member.getMobile().substring(7));
|
||||||
|
} else {
|
||||||
|
member.setNickname(createName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
member.setSiteId(RequestUtils.siteId());
|
||||||
|
member.setCreateTime(System.currentTimeMillis() / 1000);
|
||||||
|
member.setMemberNo(coreMemberService.createMemberNo(RequestUtils.siteId()));
|
||||||
|
member.setRegisterChannel(RequestUtils.channel());
|
||||||
|
this.memberMapper.insert(member);
|
||||||
|
|
||||||
|
// 会员注册事件
|
||||||
|
const registerEvent: MemberRegisterEvent = new MemberRegisterEvent();
|
||||||
|
registerEvent.setSiteId(RequestUtils.siteId());
|
||||||
|
registerEvent.addAppSign("core");
|
||||||
|
registerEvent.setName("MemberRegisterEvent");
|
||||||
|
registerEvent.setMember(member);
|
||||||
|
EventPublisher.publishEvent(registerEvent);
|
||||||
|
|
||||||
|
return loginService.login(member);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* checkMobileCode
|
* checkMobileCode
|
||||||
*/
|
*/
|
||||||
async checkMobileCode(...args: any[]): Promise<any> {
|
async checkMobileCode(...args: any[]): Promise<any> {
|
||||||
// TODO: 实现业务逻辑
|
if (mobile.length === 0) throw new BadRequestException("手机号必须填写");
|
||||||
return null;
|
const request: HttpServletRequest = RequestUtils.handler();
|
||||||
|
if (ObjectUtil.isEmpty(mobileKey) || ObjectUtil.isEmpty(mobileCode)) throw new BadRequestException("手机验证码有误");
|
||||||
|
const cache: any = cached.get(mobileKey);
|
||||||
|
if (ObjectUtil.isNull(cache)) throw new BadRequestException("手机验证码有误");
|
||||||
|
const vo: MobileCodeCacheVo = new MobileCodeCacheVo();
|
||||||
|
BeanUtils.copyProperties(cache, vo);
|
||||||
|
if (!vo.getMobile() === mobile || !vo.getCode() === mobileCode) throw new BadRequestException("手机验证码有误");
|
||||||
|
cached.remove(mobileKey);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user