Compare commits
33 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8bdfee8337 | ||
|
|
b856b39d9d | ||
|
|
2345812137 | ||
|
|
35be267360 | ||
|
|
25519391b7 | ||
|
|
40bed62bcb | ||
|
|
0a0433c3b8 | ||
|
|
5b911aa342 | ||
|
|
5695480021 | ||
|
|
6ffb83fc1b | ||
|
|
a5ec718bcf | ||
| addb2b671d | |||
|
|
905847a2d5 | ||
|
|
88129616b8 | ||
|
|
f1ff182d46 | ||
|
|
66a949a7a2 | ||
|
|
c5f96d8187 | ||
|
|
0c1e58266e | ||
|
|
54e8d258ad | ||
|
|
c69f390384 | ||
|
|
bb33cbcdb9 | ||
|
|
91d482a0f4 | ||
|
|
fb76f42760 | ||
|
|
3d34172c58 | ||
|
|
58b1c9d663 | ||
|
|
ee72554fdd | ||
|
|
561ac8a76a | ||
| 0a39c7fa4d | |||
|
|
d385267bfb | ||
| 2baa272f9d | |||
|
|
92d296115e | ||
|
|
a2b9de5038 | ||
| c984cefd68 |
5
.vscode/settings.json
vendored
Normal file
5
.vscode/settings.json
vendored
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"editor.codeLens": true,
|
||||||
|
"java.test.editor.enableShortcuts": true,
|
||||||
|
"testing.gutterEnabled": true
|
||||||
|
}
|
||||||
@ -1,110 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
|
|
||||||
<parent>
|
|
||||||
<groupId>com.yfd</groupId>
|
|
||||||
<artifactId>platform</artifactId>
|
|
||||||
<version>1.0</version>
|
|
||||||
<relativePath>../pom.xml</relativePath>
|
|
||||||
</parent>
|
|
||||||
|
|
||||||
<artifactId>platform-common</artifactId>
|
|
||||||
<version>1.0</version>
|
|
||||||
<packaging>jar</packaging>
|
|
||||||
|
|
||||||
<name>Platform Common</name>
|
|
||||||
<description>Platform Common Module</description>
|
|
||||||
|
|
||||||
<dependencies>
|
|
||||||
<!-- Spring Boot Starter -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-starter-web</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- Spring Boot Quartz -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-starter-quartz</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- Spring Boot Security -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-starter-security</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- Lombok -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.projectlombok</groupId>
|
|
||||||
<artifactId>lombok</artifactId>
|
|
||||||
<optional>true</optional>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- Hutool -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>cn.hutool</groupId>
|
|
||||||
<artifactId>hutool-all</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- Apache Commons -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.apache.commons</groupId>
|
|
||||||
<artifactId>commons-lang3</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>commons-codec</groupId>
|
|
||||||
<artifactId>commons-codec</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- POI -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.apache.poi</groupId>
|
|
||||||
<artifactId>poi</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.apache.poi</groupId>
|
|
||||||
<artifactId>poi-ooxml</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- IP2Region -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.lionsoul</groupId>
|
|
||||||
<artifactId>ip2region</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- UserAgentUtils -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>eu.bitwalker</groupId>
|
|
||||||
<artifactId>UserAgentUtils</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- MyBatis-Plus Generator -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.baomidou</groupId>
|
|
||||||
<artifactId>mybatis-plus-generator</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- Freemarker (for MyBatis-Plus Generator) -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.freemarker</groupId>
|
|
||||||
<artifactId>freemarker</artifactId>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
|
|
||||||
<build>
|
|
||||||
<plugins>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
|
||||||
<configuration>
|
|
||||||
<skip>true</skip>
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
|
||||||
</build>
|
|
||||||
|
|
||||||
</project>
|
|
||||||
@ -1,48 +0,0 @@
|
|||||||
package com.yfd.platform.common.request;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 统一请求参数结构
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
public class RequestParams {
|
|
||||||
/**
|
|
||||||
* 分页参数
|
|
||||||
*/
|
|
||||||
private PageParams page;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 排序参数
|
|
||||||
*/
|
|
||||||
private SortParams sort;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 筛选条件
|
|
||||||
*/
|
|
||||||
private Map<String, Object> filter;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 业务参数
|
|
||||||
*/
|
|
||||||
private Map<String, Object> params;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 分页参数类
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
public static class PageParams {
|
|
||||||
private int pageSize;
|
|
||||||
private int pageNumber;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 排序参数类
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
public static class SortParams {
|
|
||||||
private String field;
|
|
||||||
private String direction;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,60 +0,0 @@
|
|||||||
package com.yfd.platform.common.response;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 统一返回结构
|
|
||||||
*/
|
|
||||||
public class ResponseResult extends HashMap<String, Object> {
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
public ResponseResult() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ResponseResult unlogin() {
|
|
||||||
return message("401", "未登录");
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ResponseResult error() {
|
|
||||||
return error("操作失败");
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ResponseResult success() {
|
|
||||||
return success("操作成功");
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ResponseResult error(String msg) {
|
|
||||||
ResponseResult json = new ResponseResult();
|
|
||||||
json.put((String)"code", "1");//错误
|
|
||||||
json.put((String)"msg", msg);
|
|
||||||
return json;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ResponseResult message(String code, String msg) {
|
|
||||||
ResponseResult json = new ResponseResult();
|
|
||||||
json.put((String)"code", code);
|
|
||||||
json.put((String)"msg", msg);
|
|
||||||
return json;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ResponseResult success(String msg) {
|
|
||||||
ResponseResult json = new ResponseResult();
|
|
||||||
json.put((String)"code", "0");//正常
|
|
||||||
json.put((String)"msg", msg);
|
|
||||||
return json;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ResponseResult successData(Object obj) {
|
|
||||||
ResponseResult json = new ResponseResult();
|
|
||||||
json.put((String)"code", "0");//正常
|
|
||||||
json.put((String)"msg", "操作成功");
|
|
||||||
json.put("data", obj);
|
|
||||||
return json;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public ResponseResult put(String key, Object value) {
|
|
||||||
super.put(key, value);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,45 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2019-2020 the original author or authors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package com.yfd.platform.common.utils;
|
|
||||||
|
|
||||||
import com.yfd.platform.common.utils.SpringContextHolder;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author: liaojinlong
|
|
||||||
* @date: 2020/6/9 17:02
|
|
||||||
* @since: 1.0
|
|
||||||
* @see {@link SpringContextHolder}
|
|
||||||
* 针对某些初始化方法,在SpringContextHolder 初始化前时,<br>
|
|
||||||
* 可提交一个 提交回调任务。<br>
|
|
||||||
* 在SpringContextHolder 初始化后,进行回调使用
|
|
||||||
*/
|
|
||||||
|
|
||||||
public interface CallBack {
|
|
||||||
/**
|
|
||||||
* 回调执行方法
|
|
||||||
*/
|
|
||||||
void executor();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 本回调任务名称
|
|
||||||
* @return /
|
|
||||||
*/
|
|
||||||
default String getCallBackName() {
|
|
||||||
return Thread.currentThread().getId() + ":" + this.getClass().getName();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@ -1,75 +0,0 @@
|
|||||||
package com.yfd.platform.common.utils;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.generator.FastAutoGenerator;
|
|
||||||
import com.baomidou.mybatisplus.generator.config.OutputFile;
|
|
||||||
import com.baomidou.mybatisplus.generator.config.rules.NamingStrategy;
|
|
||||||
import com.baomidou.mybatisplus.generator.engine.FreemarkerTemplateEngine;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Scanner;
|
|
||||||
|
|
||||||
// 演示例子,执行 main 方法控制台输入模块表名回车自动生成对应项目目录中
|
|
||||||
public class CodeGenerator {
|
|
||||||
|
|
||||||
public static String scanner(String tip) {
|
|
||||||
Scanner scanner = new Scanner(System.in);
|
|
||||||
StringBuilder help = new StringBuilder();
|
|
||||||
help.append("请输入" + tip + ":");
|
|
||||||
System.out.println(help.toString());
|
|
||||||
if (scanner.hasNext()) {
|
|
||||||
String ipt = scanner.next();
|
|
||||||
if (ipt != null && !ipt.trim().isEmpty()) {
|
|
||||||
return ipt;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
throw new RuntimeException("请输入正确的" + tip + "!");
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
|
||||||
String projectPath = System.getProperty("user.dir");
|
|
||||||
String module = scanner("模块名称");
|
|
||||||
|
|
||||||
Map<OutputFile, String> pathInfo = new HashMap<>();
|
|
||||||
pathInfo.put(OutputFile.entity, projectPath + "/src/main/java/com/yfd/platform/" + module + "/domain");
|
|
||||||
pathInfo.put(OutputFile.mapper, projectPath + "/src/main/java/com/yfd/platform/" + module + "/mapper");
|
|
||||||
pathInfo.put(OutputFile.controller, projectPath + "/src/main/java/com/yfd/platform/" + module + "/controller");
|
|
||||||
pathInfo.put(OutputFile.serviceImpl, projectPath + "/src/main/java/com/yfd/platform/" + module + "/service/impl");
|
|
||||||
pathInfo.put(OutputFile.service, projectPath + "/src/main/java/com/yfd/platform/" + module + "/service");
|
|
||||||
pathInfo.put(OutputFile.xml, projectPath + "/src/main/resources/mapper/" + module);
|
|
||||||
|
|
||||||
FastAutoGenerator.create(
|
|
||||||
"jdbc:mysql://43.143.220.7:3306/frameworkdb2023?useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&autoReconnect=true&failOverReadOnly=false&allowMultiQueries=true&serverTimezone=Asia/Shanghai",
|
|
||||||
"root",
|
|
||||||
"zhengg7QkXa<gRqqQ2023")
|
|
||||||
.globalConfig(builder -> {
|
|
||||||
builder.author("TangWei")
|
|
||||||
.disableOpenDir()
|
|
||||||
.outputDir(projectPath + "/src/main/java");
|
|
||||||
})
|
|
||||||
.packageConfig(builder -> {
|
|
||||||
builder.parent("com.yfd.platform")
|
|
||||||
.moduleName(module)
|
|
||||||
.pathInfo(pathInfo);
|
|
||||||
})
|
|
||||||
.strategyConfig(builder -> {
|
|
||||||
builder.addInclude(scanner("表名,多个英文逗号分割").split(","))
|
|
||||||
.entityBuilder()
|
|
||||||
.enableLombok()
|
|
||||||
.naming(NamingStrategy.underline_to_camel)
|
|
||||||
.columnNaming(NamingStrategy.underline_to_camel)
|
|
||||||
.controllerBuilder()
|
|
||||||
.enableRestStyle()
|
|
||||||
.mapperBuilder()
|
|
||||||
.formatMapperFileName("%sMapper")
|
|
||||||
.serviceBuilder()
|
|
||||||
.formatServiceFileName("%sService")
|
|
||||||
.formatServiceImplFileName("%sServiceImpl")
|
|
||||||
.controllerBuilder()
|
|
||||||
.formatFileName("%sController");
|
|
||||||
})
|
|
||||||
.templateEngine(new FreemarkerTemplateEngine())
|
|
||||||
.execute();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,100 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2019-2020 Zheng Jie
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package com.yfd.platform.common.utils;
|
|
||||||
|
|
||||||
import javax.crypto.Cipher;
|
|
||||||
import javax.crypto.SecretKey;
|
|
||||||
import javax.crypto.SecretKeyFactory;
|
|
||||||
import javax.crypto.spec.DESKeySpec;
|
|
||||||
import javax.crypto.spec.IvParameterSpec;
|
|
||||||
import java.nio.charset.StandardCharsets;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 加密
|
|
||||||
* @author
|
|
||||||
* @date 2018-11-23
|
|
||||||
*/
|
|
||||||
|
|
||||||
public class EncryptUtils {
|
|
||||||
|
|
||||||
private static final String STR_PARAM = "Passw0rd";
|
|
||||||
|
|
||||||
private static Cipher cipher;
|
|
||||||
|
|
||||||
private static final IvParameterSpec IV = new IvParameterSpec(STR_PARAM.getBytes(StandardCharsets.UTF_8));
|
|
||||||
|
|
||||||
private static DESKeySpec getDesKeySpec(String source) throws Exception {
|
|
||||||
if (source == null || source.length() == 0){
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
cipher = Cipher.getInstance("DES/CBC/PKCS5Padding");
|
|
||||||
String strKey = "Passw0rd";
|
|
||||||
return new DESKeySpec(strKey.getBytes(StandardCharsets.UTF_8));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 对称加密
|
|
||||||
*/
|
|
||||||
public static String desEncrypt(String source) throws Exception {
|
|
||||||
DESKeySpec desKeySpec = getDesKeySpec(source);
|
|
||||||
SecretKeyFactory keyFactory = SecretKeyFactory.getInstance("DES");
|
|
||||||
SecretKey secretKey = keyFactory.generateSecret(desKeySpec);
|
|
||||||
cipher.init(Cipher.ENCRYPT_MODE, secretKey, IV);
|
|
||||||
return byte2hex(
|
|
||||||
cipher.doFinal(source.getBytes(StandardCharsets.UTF_8))).toUpperCase();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 对称解密
|
|
||||||
*/
|
|
||||||
public static String desDecrypt(String source) throws Exception {
|
|
||||||
byte[] src = hex2byte(source.getBytes(StandardCharsets.UTF_8));
|
|
||||||
DESKeySpec desKeySpec = getDesKeySpec(source);
|
|
||||||
SecretKeyFactory keyFactory = SecretKeyFactory.getInstance("DES");
|
|
||||||
SecretKey secretKey = keyFactory.generateSecret(desKeySpec);
|
|
||||||
cipher.init(Cipher.DECRYPT_MODE, secretKey, IV);
|
|
||||||
byte[] retByte = cipher.doFinal(src);
|
|
||||||
return new String(retByte);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static String byte2hex(byte[] inStr) {
|
|
||||||
String stmp;
|
|
||||||
StringBuilder out = new StringBuilder(inStr.length * 2);
|
|
||||||
for (byte b : inStr) {
|
|
||||||
stmp = Integer.toHexString(b & 0xFF);
|
|
||||||
if (stmp.length() == 1) {
|
|
||||||
// 如果是0至F的单位字符串,则添加0
|
|
||||||
out.append("0").append(stmp);
|
|
||||||
} else {
|
|
||||||
out.append(stmp);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return out.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static byte[] hex2byte(byte[] b) {
|
|
||||||
int size = 2;
|
|
||||||
if ((b.length % size) != 0){
|
|
||||||
throw new IllegalArgumentException("长度不是偶数");
|
|
||||||
}
|
|
||||||
byte[] b2 = new byte[b.length / 2];
|
|
||||||
for (int n = 0; n < b.length; n += size) {
|
|
||||||
String item = new String(b, n, 2);
|
|
||||||
b2[n / 2] = (byte) Integer.parseInt(item, 16);
|
|
||||||
}
|
|
||||||
return b2;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,395 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2019-2020 Zheng Jie
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package com.yfd.platform.common.utils;
|
|
||||||
|
|
||||||
import cn.hutool.core.date.DateUtil;
|
|
||||||
import cn.hutool.core.io.IoUtil;
|
|
||||||
import cn.hutool.core.util.IdUtil;
|
|
||||||
import cn.hutool.core.util.StrUtil;
|
|
||||||
import cn.hutool.poi.excel.BigExcelWriter;
|
|
||||||
import cn.hutool.poi.excel.ExcelUtil;
|
|
||||||
import com.yfd.platform.exception.BadRequestException;
|
|
||||||
import jakarta.servlet.ServletOutputStream;
|
|
||||||
import jakarta.servlet.http.HttpServletRequest;
|
|
||||||
import jakarta.servlet.http.HttpServletResponse;
|
|
||||||
import org.apache.poi.util.IOUtils;
|
|
||||||
import org.apache.poi.xssf.streaming.SXSSFSheet;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
|
||||||
|
|
||||||
import java.io.*;
|
|
||||||
import java.net.URLDecoder;
|
|
||||||
import java.security.MessageDigest;
|
|
||||||
import java.text.DecimalFormat;
|
|
||||||
import java.text.SimpleDateFormat;
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* File工具类,扩展 hutool 工具包
|
|
||||||
*
|
|
||||||
* @author
|
|
||||||
* @date 2018-12-27
|
|
||||||
*/
|
|
||||||
public class FileUtil extends cn.hutool.core.io.FileUtil {
|
|
||||||
|
|
||||||
private static final Logger log = LoggerFactory.getLogger(FileUtil.class);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 系统临时目录
|
|
||||||
* <br>
|
|
||||||
* windows 包含路径分割符,但Linux 不包含,
|
|
||||||
* 在windows \\==\ 前提下,
|
|
||||||
* 为安全起见 同意拼装 路径分割符,
|
|
||||||
* <pre>
|
|
||||||
* java.io.tmpdir
|
|
||||||
* windows : C:\Users/xxx\AppData\Local\Temp\
|
|
||||||
* linux: /temp
|
|
||||||
* </pre>
|
|
||||||
*/
|
|
||||||
public static final String SYS_TEM_DIR = System.getProperty("java.io.tmpdir") + File.separator;
|
|
||||||
/**
|
|
||||||
* 定义GB的计算常量
|
|
||||||
*/
|
|
||||||
private static final int GB = 1024 * 1024 * 1024;
|
|
||||||
/**
|
|
||||||
* 定义MB的计算常量
|
|
||||||
*/
|
|
||||||
private static final int MB = 1024 * 1024;
|
|
||||||
/**
|
|
||||||
* 定义KB的计算常量
|
|
||||||
*/
|
|
||||||
private static final int KB = 1024;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 格式化小数
|
|
||||||
*/
|
|
||||||
private static final DecimalFormat DF = new DecimalFormat("0.00");
|
|
||||||
|
|
||||||
public static final String IMAGE = "image";
|
|
||||||
public static final String TXT = "document";
|
|
||||||
public static final String MUSIC = "music";
|
|
||||||
public static final String VIDEO = "video";
|
|
||||||
public static final String OTHER = "other";
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* MultipartFile转File
|
|
||||||
*/
|
|
||||||
public static File toFile(MultipartFile multipartFile) {
|
|
||||||
// 获取文件名
|
|
||||||
String fileName = multipartFile.getOriginalFilename();
|
|
||||||
// 获取文件后缀
|
|
||||||
String prefix = "." + getExtensionName(fileName);
|
|
||||||
File file = null;
|
|
||||||
try {
|
|
||||||
// 用uuid作为文件名,防止生成的临时文件重复
|
|
||||||
file = File.createTempFile(IdUtil.simpleUUID(), prefix);
|
|
||||||
// MultipartFile to File
|
|
||||||
multipartFile.transferTo(file);
|
|
||||||
} catch (IOException e) {
|
|
||||||
log.error(e.getMessage(), e);
|
|
||||||
}
|
|
||||||
return file;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取文件扩展名,不带 .
|
|
||||||
*/
|
|
||||||
public static String getExtensionName(String filename) {
|
|
||||||
if ((filename != null) && (filename.length() > 0)) {
|
|
||||||
int dot = filename.lastIndexOf('.');
|
|
||||||
if ((dot > -1) && (dot < (filename.length() - 1))) {
|
|
||||||
return filename.substring(dot + 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return filename;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Java文件操作 获取不带扩展名的文件名
|
|
||||||
*/
|
|
||||||
public static String getFileNameNoEx(String filename) {
|
|
||||||
if ((filename != null) && (filename.length() > 0)) {
|
|
||||||
int dot = filename.lastIndexOf('.');
|
|
||||||
if ((dot > -1) && (dot < (filename.length()))) {
|
|
||||||
return filename.substring(0, dot);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return filename;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 文件大小转换
|
|
||||||
*/
|
|
||||||
public static String getSize(long size) {
|
|
||||||
String resultSize;
|
|
||||||
if (size / GB >= 1) {
|
|
||||||
//如果当前Byte的值大于等于1GB
|
|
||||||
resultSize = DF.format(size / (float) GB) + "GB ";
|
|
||||||
} else if (size / MB >= 1) {
|
|
||||||
//如果当前Byte的值大于等于1MB
|
|
||||||
resultSize = DF.format(size / (float) MB) + "MB ";
|
|
||||||
} else if (size / KB >= 1) {
|
|
||||||
//如果当前Byte的值大于等于1KB
|
|
||||||
resultSize = DF.format(size / (float) KB) + "KB ";
|
|
||||||
} else {
|
|
||||||
resultSize = size + "B ";
|
|
||||||
}
|
|
||||||
return resultSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* inputStream 转 File
|
|
||||||
*/
|
|
||||||
static File inputStreamToFile(InputStream ins, String name) throws Exception {
|
|
||||||
File file = new File(SYS_TEM_DIR + name);
|
|
||||||
if (file.exists()) {
|
|
||||||
return file;
|
|
||||||
}
|
|
||||||
OutputStream os = new FileOutputStream(file);
|
|
||||||
int bytesRead;
|
|
||||||
int len = 8192;
|
|
||||||
byte[] buffer = new byte[len];
|
|
||||||
while ((bytesRead = ins.read(buffer, 0, len)) != -1) {
|
|
||||||
os.write(buffer, 0, bytesRead);
|
|
||||||
}
|
|
||||||
os.close();
|
|
||||||
ins.close();
|
|
||||||
return file;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 将文件名解析成文件的上传路径
|
|
||||||
*/
|
|
||||||
public static File upload(MultipartFile file, String filePath) {
|
|
||||||
Date date = new Date();
|
|
||||||
SimpleDateFormat format = new SimpleDateFormat("yyyyMMddhhmmssS");
|
|
||||||
String name = getFileNameNoEx(file.getOriginalFilename());
|
|
||||||
String suffix = getExtensionName(file.getOriginalFilename());
|
|
||||||
String nowStr = "-" + format.format(date);
|
|
||||||
try {
|
|
||||||
String fileName = name + "." + suffix;
|
|
||||||
String path = filePath +File.separator + fileName;
|
|
||||||
// getCanonicalFile 可解析正确各种路径
|
|
||||||
File dest = new File(path).getCanonicalFile();
|
|
||||||
// 检测是否存在目录
|
|
||||||
if (!dest.getParentFile().exists()) {
|
|
||||||
if (!dest.getParentFile().mkdirs()) {
|
|
||||||
System.out.println("was not successful.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// 文件写入
|
|
||||||
file.transferTo(dest);
|
|
||||||
return dest;
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.error(e.getMessage(), e);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 将文件名解析成文件的上传路径
|
|
||||||
* file 上传的文件
|
|
||||||
* filePath 存储路径
|
|
||||||
* tofilename 保存文件名称
|
|
||||||
|
|
||||||
*/
|
|
||||||
public static File upload(MultipartFile file, String filePath,String tofilename) {
|
|
||||||
try {
|
|
||||||
String filename = filePath + File.separator + tofilename;
|
|
||||||
File dest = new File(filename).getCanonicalFile();
|
|
||||||
// 检测是否存在目录
|
|
||||||
if (!dest.getParentFile().exists()) {
|
|
||||||
if (!dest.getParentFile().mkdirs()) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// 文件写入
|
|
||||||
file.transferTo(dest);
|
|
||||||
return dest;
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.error(e.getMessage(), e);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 导出excel
|
|
||||||
*/
|
|
||||||
public static void downloadExcel(List<Map<String, Object>> list, HttpServletResponse response) throws IOException {
|
|
||||||
String tempPath = SYS_TEM_DIR + IdUtil.fastSimpleUUID() + ".xlsx";
|
|
||||||
String filename = "record"+cn.hutool.core.date.DateUtil.format(DateUtil.date(), "yyyyMMddHHmmss");
|
|
||||||
File file = new File(tempPath);
|
|
||||||
BigExcelWriter writer = ExcelUtil.getBigWriter(file);
|
|
||||||
// 一次性写出内容,使用默认样式,强制输出标题
|
|
||||||
writer.write(list, true);
|
|
||||||
SXSSFSheet sheet = (SXSSFSheet)writer.getSheet();
|
|
||||||
//上面需要强转SXSSFSheet 不然没有trackAllColumnsForAutoSizing方法
|
|
||||||
sheet.trackAllColumnsForAutoSizing();
|
|
||||||
//列宽自适应
|
|
||||||
writer.autoSizeColumnAll();
|
|
||||||
//response为HttpServletResponse对象
|
|
||||||
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8");
|
|
||||||
//test.xls是弹出下载对话框的文件名,不能为中文,中文请自行编码
|
|
||||||
response.setHeader("Content-Disposition", "attachment;filename="+filename+".xlsx");
|
|
||||||
ServletOutputStream out = response.getOutputStream();
|
|
||||||
// 终止后删除临时文件
|
|
||||||
file.deleteOnExit();
|
|
||||||
writer.flush(out, true);
|
|
||||||
//此处记得关闭输出Servlet流
|
|
||||||
IoUtil.close(out);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String getFileType(String type) {
|
|
||||||
String documents = "txt doc pdf ppt pps xlsx xls docx";
|
|
||||||
String music = "mp3 wav wma mpa ram ra aac aif m4a";
|
|
||||||
String video = "avi mpg mpe mpeg asf wmv mov qt rm mp4 flv m4v webm ogv ogg";
|
|
||||||
String image = "bmp dib pcp dif wmf gif jpg tif eps psd cdr iff tga pcd mpt png jpeg";
|
|
||||||
if (image.contains(type)) {
|
|
||||||
return IMAGE;
|
|
||||||
} else if (documents.contains(type)) {
|
|
||||||
return TXT;
|
|
||||||
} else if (music.contains(type)) {
|
|
||||||
return MUSIC;
|
|
||||||
} else if (video.contains(type)) {
|
|
||||||
return VIDEO;
|
|
||||||
} else {
|
|
||||||
return OTHER;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void checkSize(long maxSize, long size) {
|
|
||||||
// 1M
|
|
||||||
int len = 1024 * 1024;
|
|
||||||
if (size > (maxSize * len)) {
|
|
||||||
throw new BadRequestException("文件超出规定大小");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 判断两个文件是否相同
|
|
||||||
*/
|
|
||||||
public static boolean check(File file1, File file2) {
|
|
||||||
String img1Md5 = getMd5(file1);
|
|
||||||
String img2Md5 = getMd5(file2);
|
|
||||||
return img1Md5.equals(img2Md5);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 判断两个文件是否相同
|
|
||||||
*/
|
|
||||||
public static boolean check(String file1Md5, String file2Md5) {
|
|
||||||
return file1Md5.equals(file2Md5);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static byte[] getByte(File file) {
|
|
||||||
// 得到文件长度
|
|
||||||
byte[] b = new byte[(int) file.length()];
|
|
||||||
try {
|
|
||||||
InputStream in = new FileInputStream(file);
|
|
||||||
try {
|
|
||||||
System.out.println(in.read(b));
|
|
||||||
} catch (IOException e) {
|
|
||||||
log.error(e.getMessage(), e);
|
|
||||||
}
|
|
||||||
} catch (FileNotFoundException e) {
|
|
||||||
log.error(e.getMessage(), e);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return b;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static String getMd5(byte[] bytes) {
|
|
||||||
// 16进制字符
|
|
||||||
char[] hexDigits = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
|
|
||||||
try {
|
|
||||||
MessageDigest mdTemp = MessageDigest.getInstance("MD5");
|
|
||||||
mdTemp.update(bytes);
|
|
||||||
byte[] md = mdTemp.digest();
|
|
||||||
int j = md.length;
|
|
||||||
char[] str = new char[j * 2];
|
|
||||||
int k = 0;
|
|
||||||
// 移位 输出字符串
|
|
||||||
for (byte byte0 : md) {
|
|
||||||
str[k++] = hexDigits[byte0 >>> 4 & 0xf];
|
|
||||||
str[k++] = hexDigits[byte0 & 0xf];
|
|
||||||
}
|
|
||||||
return new String(str);
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.error(e.getMessage(), e);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 下载文件
|
|
||||||
*
|
|
||||||
* @param request /
|
|
||||||
* @param response /
|
|
||||||
* @param file /
|
|
||||||
*/
|
|
||||||
public static void downloadFile(HttpServletRequest request, HttpServletResponse response, File file, boolean deleteOnExit) {
|
|
||||||
response.setCharacterEncoding(request.getCharacterEncoding());
|
|
||||||
response.setContentType("application/octet-stream");
|
|
||||||
FileInputStream fis = null;
|
|
||||||
try {
|
|
||||||
fis = new FileInputStream(file);
|
|
||||||
response.setHeader("Content-Disposition", "attachment; filename=" + file.getName());
|
|
||||||
IOUtils.copy(fis, response.getOutputStream());
|
|
||||||
response.flushBuffer();
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.error(e.getMessage(), e);
|
|
||||||
} finally {
|
|
||||||
if (fis != null) {
|
|
||||||
try {
|
|
||||||
fis.close();
|
|
||||||
if (deleteOnExit) {
|
|
||||||
file.deleteOnExit();
|
|
||||||
}
|
|
||||||
} catch (IOException e) {
|
|
||||||
log.error(e.getMessage(), e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* 预览PDF文件
|
|
||||||
*
|
|
||||||
* @param filepath /
|
|
||||||
* @param response /
|
|
||||||
*/
|
|
||||||
public static void viewPDF(String filepath, HttpServletResponse response) throws IOException {
|
|
||||||
File file=new File(filepath);
|
|
||||||
String originFileName=file.getName(); //中文编码
|
|
||||||
response.setCharacterEncoding("UTF-8");
|
|
||||||
String showName= StrUtil.isNotBlank(originFileName)?originFileName:file.getName();
|
|
||||||
showName= URLDecoder.decode(showName,"UTF-8");
|
|
||||||
response.setHeader("Content-Disposition","inline;fileName="+new String(showName.getBytes(), "ISO8859-1")+";fileName*=UTF-8''"+ new String(showName.getBytes(), "ISO8859-1"));
|
|
||||||
FileInputStream fis = new FileInputStream(file);
|
|
||||||
response.setHeader("content-type", "application/pdf");
|
|
||||||
response.setContentType("application/pdf; charset=utf-8");
|
|
||||||
IOUtils.copy(fis, response.getOutputStream());
|
|
||||||
fis.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String getMd5(File file) {
|
|
||||||
return getMd5(getByte(file));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,152 +0,0 @@
|
|||||||
package com.yfd.platform.common.utils;
|
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
|
||||||
import java.sql.Timestamp;
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
import java.time.format.DateTimeFormatter;
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
public class ObjectConverterUtil {
|
|
||||||
|
|
||||||
// 日期时间格式
|
|
||||||
private static final DateTimeFormatter DATE_TIME_FORMATTER =
|
|
||||||
DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 将 List<Map> 中的大写字段名转换为与实体类一致的小写格式
|
|
||||||
* 适用于 Oracle 数据库查询结果转换
|
|
||||||
* 时间类型字段会转换为字符串格式
|
|
||||||
*
|
|
||||||
* @param entityClass 实体类 Class 对象
|
|
||||||
* @param sourceList 源数据列表(字段名为大写)
|
|
||||||
* @return 转换后的列表(字段名与实体类一致)
|
|
||||||
*/
|
|
||||||
public static <T> List<Map<String, Object>> convertMapFieldsToEntityFormat(
|
|
||||||
Class<T> entityClass,
|
|
||||||
List<Map<String, Object>> sourceList) {
|
|
||||||
|
|
||||||
if (sourceList == null || sourceList.isEmpty()) {
|
|
||||||
return sourceList;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 获取实体类的所有字段及类型
|
|
||||||
Map<String, Field> fieldMap = new HashMap<>();
|
|
||||||
for (Field field : entityClass.getDeclaredFields()) {
|
|
||||||
fieldMap.put(field.getName(), field);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 转换每个 Map
|
|
||||||
return sourceList.stream().map(sourceMap -> {
|
|
||||||
Map<String, Object> targetMap = new HashMap<>();
|
|
||||||
|
|
||||||
for (Map.Entry<String, Object> entry : sourceMap.entrySet()) {
|
|
||||||
String dbColumnName = entry.getKey(); // 数据库列名(大写)
|
|
||||||
Object value = entry.getValue();
|
|
||||||
|
|
||||||
// 将大写列名转为小写
|
|
||||||
String lowerCaseName = dbColumnName.toLowerCase();
|
|
||||||
|
|
||||||
// 如果实体类中有对应的字段
|
|
||||||
if (fieldMap.containsKey(lowerCaseName)) {
|
|
||||||
Field field = fieldMap.get(lowerCaseName);
|
|
||||||
String fieldType = field.getType().getSimpleName();
|
|
||||||
|
|
||||||
// 处理时间类型,转换为字符串
|
|
||||||
if ("Timestamp".equals(fieldType) || "Date".equals(fieldType) ||
|
|
||||||
"LocalDateTime".equals(fieldType)) {
|
|
||||||
targetMap.put(lowerCaseName, formatDateTimeValue(value));
|
|
||||||
} else {
|
|
||||||
targetMap.put(lowerCaseName, value);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// 如果实体类中没有对应字段,保留原列名(转小写)
|
|
||||||
targetMap.put(lowerCaseName, value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return targetMap;
|
|
||||||
}).collect(Collectors.toList());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 通用方法:将单个 Map 的大写字段转换为实体类格式
|
|
||||||
* 时间类型字段会转换为字符串格式
|
|
||||||
*
|
|
||||||
* @param entityClass 实体类 Class 对象
|
|
||||||
* @param sourceMap 源 Map(字段名为大写)
|
|
||||||
* @return 转换后的 Map(字段名与实体类一致)
|
|
||||||
*/
|
|
||||||
public static <T> Map<String, Object> convertSingleMapFieldsToEntityFormat(
|
|
||||||
Class<T> entityClass,
|
|
||||||
Map<String, Object> sourceMap) {
|
|
||||||
|
|
||||||
if (sourceMap == null) {
|
|
||||||
return sourceMap;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 获取实体类的所有字段及类型
|
|
||||||
Map<String, Field> fieldMap = new HashMap<>();
|
|
||||||
for (Field field : entityClass.getDeclaredFields()) {
|
|
||||||
fieldMap.put(field.getName(), field);
|
|
||||||
}
|
|
||||||
|
|
||||||
Map<String, Object> targetMap = new HashMap<>();
|
|
||||||
|
|
||||||
for (Map.Entry<String, Object> entry : sourceMap.entrySet()) {
|
|
||||||
String dbColumnName = entry.getKey();
|
|
||||||
Object value = entry.getValue();
|
|
||||||
|
|
||||||
// 将大写列名转为小写
|
|
||||||
String lowerCaseName = dbColumnName.toLowerCase();
|
|
||||||
|
|
||||||
// 验证字段是否存在于实体类中
|
|
||||||
if (fieldMap.containsKey(lowerCaseName)) {
|
|
||||||
Field field = fieldMap.get(lowerCaseName);
|
|
||||||
String fieldType = field.getType().getSimpleName();
|
|
||||||
|
|
||||||
// 处理时间类型,转换为字符串
|
|
||||||
if ("Timestamp".equals(fieldType) || "Date".equals(fieldType) ||
|
|
||||||
"LocalDateTime".equals(fieldType)) {
|
|
||||||
targetMap.put(lowerCaseName, formatDateTimeValue(value));
|
|
||||||
} else {
|
|
||||||
targetMap.put(lowerCaseName, value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return targetMap;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 格式化时间类型值为字符串
|
|
||||||
*
|
|
||||||
* @param value 时间值(可能是 Timestamp、Date 或 LocalDateTime)
|
|
||||||
* @return 格式化后的字符串,如果为 null 则返回 null
|
|
||||||
*/
|
|
||||||
private static String formatDateTimeValue(Object value) {
|
|
||||||
if (value == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (value instanceof Timestamp) {
|
|
||||||
LocalDateTime localDateTime = ((Timestamp) value).toLocalDateTime();
|
|
||||||
return localDateTime.format(DATE_TIME_FORMATTER);
|
|
||||||
} else if (value instanceof Date) {
|
|
||||||
// 包括 java.sql.Date 和 java.util.Date
|
|
||||||
LocalDateTime localDateTime = ((Date) value).toInstant()
|
|
||||||
.atZone(java.time.ZoneId.systemDefault())
|
|
||||||
.toLocalDateTime();
|
|
||||||
return localDateTime.format(DATE_TIME_FORMATTER);
|
|
||||||
} else if (value instanceof LocalDateTime) {
|
|
||||||
return ((LocalDateTime) value).format(DATE_TIME_FORMATTER);
|
|
||||||
} else {
|
|
||||||
// 其他类型直接转字符串
|
|
||||||
return value.toString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,29 +0,0 @@
|
|||||||
package com.yfd.platform.common.utils;
|
|
||||||
|
|
||||||
import org.springframework.core.io.ClassPathResource;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStreamReader;
|
|
||||||
import java.util.Properties;
|
|
||||||
/******************************
|
|
||||||
* 用途说明:
|
|
||||||
* 作者姓名: pcj
|
|
||||||
* 创建时间: 2022/9/20 14:31
|
|
||||||
******************************/
|
|
||||||
public class PropertiesUtils {
|
|
||||||
public final static String RESOURCE_PATH = "application.properties";
|
|
||||||
|
|
||||||
public final static Properties properties = new Properties();
|
|
||||||
|
|
||||||
public static String getPropertyField(String parameter) {
|
|
||||||
//对应resources目录下的资源路径
|
|
||||||
ClassPathResource resource = new ClassPathResource(RESOURCE_PATH);
|
|
||||||
try {
|
|
||||||
properties.load(new InputStreamReader(resource.getInputStream(), "gbk"));
|
|
||||||
} catch (IOException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
return properties.getProperty(parameter);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,34 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2019-2020 Zheng Jie
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package com.yfd.platform.common.utils;
|
|
||||||
|
|
||||||
import jakarta.servlet.http.HttpServletRequest;
|
|
||||||
import org.springframework.web.context.request.RequestContextHolder;
|
|
||||||
import org.springframework.web.context.request.ServletRequestAttributes;
|
|
||||||
|
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取 HttpServletRequest
|
|
||||||
* @author
|
|
||||||
* @date 2018-11-24
|
|
||||||
*/
|
|
||||||
public class RequestHolder {
|
|
||||||
|
|
||||||
public static HttpServletRequest getHttpServletRequest() {
|
|
||||||
return ((ServletRequestAttributes) Objects.requireNonNull(RequestContextHolder.getRequestAttributes())).getRequest();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,190 +0,0 @@
|
|||||||
package com.yfd.platform.common.utils;
|
|
||||||
|
|
||||||
import org.apache.commons.codec.binary.Base64;
|
|
||||||
|
|
||||||
import javax.crypto.Cipher;
|
|
||||||
import java.security.*;
|
|
||||||
import java.security.interfaces.RSAPrivateKey;
|
|
||||||
import java.security.interfaces.RSAPublicKey;
|
|
||||||
import java.security.spec.PKCS8EncodedKeySpec;
|
|
||||||
import java.security.spec.X509EncodedKeySpec;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author https://www.cnblogs.com/nihaorz/p/10690643.html
|
|
||||||
* @description Rsa 工具类,公钥私钥生成,加解密
|
|
||||||
* @date 2020-05-18
|
|
||||||
**/
|
|
||||||
public class RsaUtils {
|
|
||||||
|
|
||||||
private static final String SRC = "123456";
|
|
||||||
|
|
||||||
public static void main(String[] args) throws Exception {
|
|
||||||
System.out.println("\n");
|
|
||||||
// RsaKeyPair keyPair = generateKeyPair();
|
|
||||||
String publicKey = "MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBANL378k3RiZHWx5AfJqdH9xRNBmD9wGD2iRe41HdTNF8RUhNnHit5NpMNtGL0NPTSSpPjjI1kJfVorRvaQerUgkCAwEAAQ==";
|
|
||||||
String privateKey = "MIIBUwIBADANBgkqhkiG9w0BAQEFAASCAT0wggE5AgEAAkEA0vfvyTdGJkdbHkB8\n" +
|
|
||||||
"mp0f3FE0GYP3AYPaJF7jUd1M0XxFSE2ceK3k2kw20YvQ09NJKk+OMjWQl9WitG9p\n" +
|
|
||||||
"B6tSCQIDAQABAkA2SimBrWC2/wvauBuYqjCFwLvYiRYqZKThUS3MZlebXJiLB+Ue\n" +
|
|
||||||
"/gUifAAKIg1avttUZsHBHrop4qfJCwAI0+YRAiEA+W3NK/RaXtnRqmoUUkb59zsZ\n" +
|
|
||||||
"UBLpvZgQPfj1MhyHDz0CIQDYhsAhPJ3mgS64NbUZmGWuuNKp5coY2GIj/zYDMJp6\n" +
|
|
||||||
"vQIgUueLFXv/eZ1ekgz2Oi67MNCk5jeTF2BurZqNLR3MSmUCIFT3Q6uHMtsB9Eha\n" +
|
|
||||||
"4u7hS31tj1UWE+D+ADzp59MGnoftAiBeHT7gDMuqeJHPL4b+kC+gzV4FGTfhR9q3\n" +
|
|
||||||
"tTbklZkD2A==";
|
|
||||||
RsaKeyPair keyPair =new RsaKeyPair(publicKey, privateKey);
|
|
||||||
System.out.println("私钥:" + keyPair.getPrivateKey());
|
|
||||||
System.out.println("\n");
|
|
||||||
test1(keyPair);
|
|
||||||
System.out.println("\n");
|
|
||||||
// test2(keyPair);
|
|
||||||
System.out.println("\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 公钥加密私钥解密
|
|
||||||
*/
|
|
||||||
private static void test1(RsaKeyPair keyPair) throws Exception {
|
|
||||||
System.out.println("***************** 公钥加密私钥解密开始 *****************");
|
|
||||||
String text1 = encryptByPublicKey(keyPair.getPublicKey(), RsaUtils.SRC);
|
|
||||||
String text2 = decryptByPrivateKey(keyPair.getPrivateKey(), text1);
|
|
||||||
System.out.println("加密前:" + RsaUtils.SRC);
|
|
||||||
System.out.println("加密后:" + text1);
|
|
||||||
System.out.println("解密后:" + text2);
|
|
||||||
if (RsaUtils.SRC.equals(text2)) {
|
|
||||||
System.out.println("解密字符串和原始字符串一致,解密成功");
|
|
||||||
} else {
|
|
||||||
System.out.println("解密字符串和原始字符串不一致,解密失败");
|
|
||||||
}
|
|
||||||
System.out.println("***************** 公钥加密私钥解密结束 *****************");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 私钥加密公钥解密
|
|
||||||
* @throws Exception /
|
|
||||||
*/
|
|
||||||
private static void test2(RsaKeyPair keyPair) throws Exception {
|
|
||||||
System.out.println("***************** 私钥加密公钥解密开始 *****************");
|
|
||||||
String text1 = encryptByPrivateKey(keyPair.getPrivateKey(), RsaUtils.SRC);
|
|
||||||
String text2 = decryptByPublicKey(keyPair.getPublicKey(), text1);
|
|
||||||
System.out.println("加密前:" + RsaUtils.SRC);
|
|
||||||
System.out.println("加密后:" + text1);
|
|
||||||
System.out.println("解密后:" + text2);
|
|
||||||
if (RsaUtils.SRC.equals(text2)) {
|
|
||||||
System.out.println("解密字符串和原始字符串一致,解密成功");
|
|
||||||
} else {
|
|
||||||
System.out.println("解密字符串和原始字符串不一致,解密失败");
|
|
||||||
}
|
|
||||||
System.out.println("***************** 私钥加密公钥解密结束 *****************");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 公钥解密
|
|
||||||
*
|
|
||||||
* @param publicKeyText 公钥
|
|
||||||
* @param text 待解密的信息
|
|
||||||
* @return /
|
|
||||||
* @throws Exception /
|
|
||||||
*/
|
|
||||||
public static String decryptByPublicKey(String publicKeyText, String text) throws Exception {
|
|
||||||
X509EncodedKeySpec x509EncodedKeySpec = new X509EncodedKeySpec(Base64.decodeBase64(publicKeyText));
|
|
||||||
KeyFactory keyFactory = KeyFactory.getInstance("RSA");
|
|
||||||
PublicKey publicKey = keyFactory.generatePublic(x509EncodedKeySpec);
|
|
||||||
Cipher cipher = Cipher.getInstance("RSA");
|
|
||||||
cipher.init(Cipher.DECRYPT_MODE, publicKey);
|
|
||||||
byte[] result = cipher.doFinal(Base64.decodeBase64(text));
|
|
||||||
return new String(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 私钥加密
|
|
||||||
*
|
|
||||||
* @param privateKeyText 私钥
|
|
||||||
* @param text 待加密的信息
|
|
||||||
* @return /
|
|
||||||
* @throws Exception /
|
|
||||||
*/
|
|
||||||
public static String encryptByPrivateKey(String privateKeyText, String text) throws Exception {
|
|
||||||
PKCS8EncodedKeySpec pkcs8EncodedKeySpec = new PKCS8EncodedKeySpec(Base64.decodeBase64(privateKeyText));
|
|
||||||
KeyFactory keyFactory = KeyFactory.getInstance("RSA");
|
|
||||||
PrivateKey privateKey = keyFactory.generatePrivate(pkcs8EncodedKeySpec);
|
|
||||||
Cipher cipher = Cipher.getInstance("RSA");
|
|
||||||
cipher.init(Cipher.ENCRYPT_MODE, privateKey);
|
|
||||||
byte[] result = cipher.doFinal(text.getBytes());
|
|
||||||
return Base64.encodeBase64String(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 私钥解密
|
|
||||||
*
|
|
||||||
* @param privateKeyText 私钥
|
|
||||||
* @param text 待解密的文本
|
|
||||||
* @return /
|
|
||||||
* @throws Exception /
|
|
||||||
*/
|
|
||||||
public static String decryptByPrivateKey(String privateKeyText, String text) throws Exception {
|
|
||||||
PKCS8EncodedKeySpec pkcs8EncodedKeySpec5 = new PKCS8EncodedKeySpec(Base64.decodeBase64(privateKeyText));
|
|
||||||
KeyFactory keyFactory = KeyFactory.getInstance("RSA");
|
|
||||||
PrivateKey privateKey = keyFactory.generatePrivate(pkcs8EncodedKeySpec5);
|
|
||||||
Cipher cipher = Cipher.getInstance("RSA");
|
|
||||||
cipher.init(Cipher.DECRYPT_MODE, privateKey);
|
|
||||||
byte[] result = cipher.doFinal(Base64.decodeBase64(text));
|
|
||||||
return new String(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 公钥加密
|
|
||||||
*
|
|
||||||
* @param publicKeyText 公钥
|
|
||||||
* @param text 待加密的文本
|
|
||||||
* @return /
|
|
||||||
*/
|
|
||||||
public static String encryptByPublicKey(String publicKeyText, String text) throws Exception {
|
|
||||||
X509EncodedKeySpec x509EncodedKeySpec2 = new X509EncodedKeySpec(Base64.decodeBase64(publicKeyText));
|
|
||||||
KeyFactory keyFactory = KeyFactory.getInstance("RSA");
|
|
||||||
PublicKey publicKey = keyFactory.generatePublic(x509EncodedKeySpec2);
|
|
||||||
Cipher cipher = Cipher.getInstance("RSA");
|
|
||||||
cipher.init(Cipher.ENCRYPT_MODE, publicKey);
|
|
||||||
byte[] result = cipher.doFinal(text.getBytes());
|
|
||||||
return Base64.encodeBase64String(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 构建RSA密钥对
|
|
||||||
*
|
|
||||||
* @return /
|
|
||||||
* @throws NoSuchAlgorithmException /
|
|
||||||
*/
|
|
||||||
public static RsaKeyPair generateKeyPair() throws NoSuchAlgorithmException {
|
|
||||||
KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance("RSA");
|
|
||||||
keyPairGenerator.initialize(1024);
|
|
||||||
KeyPair keyPair = keyPairGenerator.generateKeyPair();
|
|
||||||
RSAPublicKey rsaPublicKey = (RSAPublicKey) keyPair.getPublic();
|
|
||||||
RSAPrivateKey rsaPrivateKey = (RSAPrivateKey) keyPair.getPrivate();
|
|
||||||
String publicKeyString = Base64.encodeBase64String(rsaPublicKey.getEncoded());
|
|
||||||
String privateKeyString = Base64.encodeBase64String(rsaPrivateKey.getEncoded());
|
|
||||||
return new RsaKeyPair(publicKeyString, privateKeyString);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* RSA密钥对对象
|
|
||||||
*/
|
|
||||||
public static class RsaKeyPair {
|
|
||||||
|
|
||||||
private final String publicKey;
|
|
||||||
private final String privateKey;
|
|
||||||
|
|
||||||
public RsaKeyPair(String publicKey, String privateKey) {
|
|
||||||
this.publicKey = publicKey;
|
|
||||||
this.privateKey = privateKey;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getPublicKey() {
|
|
||||||
return publicKey;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getPrivateKey() {
|
|
||||||
return privateKey;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,145 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2019-2020 Zheng Jie
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package com.yfd.platform.common.utils;
|
|
||||||
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.springframework.beans.BeansException;
|
|
||||||
import org.springframework.beans.factory.DisposableBean;
|
|
||||||
import org.springframework.context.ApplicationContext;
|
|
||||||
import org.springframework.context.ApplicationContextAware;
|
|
||||||
import org.springframework.core.env.Environment;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
/**
|
|
||||||
* @author Jie
|
|
||||||
* @date 2019-01-07
|
|
||||||
*/
|
|
||||||
@Slf4j
|
|
||||||
public class SpringContextHolder implements ApplicationContextAware, DisposableBean {
|
|
||||||
|
|
||||||
private static ApplicationContext applicationContext = null;
|
|
||||||
private static final List<CallBack> CALL_BACKS = new ArrayList<>();
|
|
||||||
private static boolean addCallback = true;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 针对 某些初始化方法,在SpringContextHolder 未初始化时 提交回调方法。
|
|
||||||
* 在SpringContextHolder 初始化后,进行回调使用
|
|
||||||
*
|
|
||||||
* @param callBack 回调函数
|
|
||||||
*/
|
|
||||||
public synchronized static void addCallBacks(CallBack callBack) {
|
|
||||||
if (addCallback) {
|
|
||||||
SpringContextHolder.CALL_BACKS.add(callBack);
|
|
||||||
} else {
|
|
||||||
log.warn("CallBack:{} 已无法添加!立即执行", callBack.getCallBackName());
|
|
||||||
callBack.executor();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 从静态变量applicationContext中取得Bean, 自动转型为所赋值对象的类型.
|
|
||||||
*/
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
public static <T> T getBean(String name) {
|
|
||||||
assertContextInjected();
|
|
||||||
return (T) applicationContext.getBean(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 从静态变量applicationContext中取得Bean, 自动转型为所赋值对象的类型.
|
|
||||||
*/
|
|
||||||
public static <T> T getBean(Class<T> requiredType) {
|
|
||||||
assertContextInjected();
|
|
||||||
return applicationContext.getBean(requiredType);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取SpringBoot 配置信息
|
|
||||||
*
|
|
||||||
* @param property 属性key
|
|
||||||
* @param defaultValue 默认值
|
|
||||||
* @param requiredType 返回类型
|
|
||||||
* @return /
|
|
||||||
*/
|
|
||||||
public static <T> T getProperties(String property, T defaultValue, Class<T> requiredType) {
|
|
||||||
T result = defaultValue;
|
|
||||||
try {
|
|
||||||
result = getBean(Environment.class).getProperty(property, requiredType);
|
|
||||||
} catch (Exception ignored) {}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取SpringBoot 配置信息
|
|
||||||
*
|
|
||||||
* @param property 属性key
|
|
||||||
* @return /
|
|
||||||
*/
|
|
||||||
public static String getProperties(String property) {
|
|
||||||
return getProperties(property, null, String.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取SpringBoot 配置信息
|
|
||||||
*
|
|
||||||
* @param property 属性key
|
|
||||||
* @param requiredType 返回类型
|
|
||||||
* @return /
|
|
||||||
*/
|
|
||||||
public static <T> T getProperties(String property, Class<T> requiredType) {
|
|
||||||
return getProperties(property, null, requiredType);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 检查ApplicationContext不为空.
|
|
||||||
*/
|
|
||||||
private static void assertContextInjected() {
|
|
||||||
if (applicationContext == null) {
|
|
||||||
throw new IllegalStateException("applicaitonContext属性未注入, 请在applicationContext" +
|
|
||||||
".xml中定义SpringContextHolder或在SpringBoot启动类中注册SpringContextHolder.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 清除SpringContextHolder中的ApplicationContext为Null.
|
|
||||||
*/
|
|
||||||
private static void clearHolder() {
|
|
||||||
log.debug("清除SpringContextHolder中的ApplicationContext:"
|
|
||||||
+ applicationContext);
|
|
||||||
applicationContext = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void destroy() {
|
|
||||||
SpringContextHolder.clearHolder();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
|
|
||||||
if (SpringContextHolder.applicationContext != null) {
|
|
||||||
log.warn("SpringContextHolder中的ApplicationContext被覆盖, 原有ApplicationContext为:" + SpringContextHolder.applicationContext);
|
|
||||||
}
|
|
||||||
SpringContextHolder.applicationContext = applicationContext;
|
|
||||||
if (addCallback) {
|
|
||||||
for (CallBack callBack : SpringContextHolder.CALL_BACKS) {
|
|
||||||
callBack.executor();
|
|
||||||
}
|
|
||||||
CALL_BACKS.clear();
|
|
||||||
}
|
|
||||||
SpringContextHolder.addCallback = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,306 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2019-2020 Zheng Jie
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package com.yfd.platform.common.utils;
|
|
||||||
|
|
||||||
|
|
||||||
import cn.hutool.http.HttpUtil;
|
|
||||||
import cn.hutool.json.JSONObject;
|
|
||||||
import cn.hutool.json.JSONUtil;
|
|
||||||
import com.yfd.platform.constant.Constant;
|
|
||||||
import eu.bitwalker.useragentutils.Browser;
|
|
||||||
import eu.bitwalker.useragentutils.UserAgent;
|
|
||||||
import jakarta.servlet.http.HttpServletRequest;
|
|
||||||
import lombok.SneakyThrows;
|
|
||||||
import org.lionsoul.ip2region.DataBlock;
|
|
||||||
import org.lionsoul.ip2region.DbConfig;
|
|
||||||
import org.lionsoul.ip2region.DbSearcher;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.springframework.core.io.ClassPathResource;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.net.InetAddress;
|
|
||||||
import java.net.NetworkInterface;
|
|
||||||
import java.net.UnknownHostException;
|
|
||||||
import java.util.Calendar;
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.Enumeration;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author
|
|
||||||
* 字符串工具类, 继承org.apache.commons.lang3.StringUtils类
|
|
||||||
*/
|
|
||||||
public class StringUtils extends org.apache.commons.lang3.StringUtils {
|
|
||||||
|
|
||||||
private static final Logger log = LoggerFactory.getLogger(StringUtils.class);
|
|
||||||
private static boolean ipLocal = false;
|
|
||||||
private static File file ;
|
|
||||||
private static DbConfig config;
|
|
||||||
private static final char SEPARATOR = '_';
|
|
||||||
private static final String UNKNOWN = "unknown";
|
|
||||||
|
|
||||||
static {
|
|
||||||
SpringContextHolder.addCallBacks(() -> {
|
|
||||||
StringUtils.ipLocal = SpringContextHolder.getProperties("ip.local-parsing", false, Boolean.class);
|
|
||||||
if (ipLocal) {
|
|
||||||
/*
|
|
||||||
* 此文件为独享 ,不必关闭
|
|
||||||
*/
|
|
||||||
String path = "ip2region/ip2region.db";
|
|
||||||
String name = "ip2region.db";
|
|
||||||
try {
|
|
||||||
config = new DbConfig();
|
|
||||||
file = FileUtil.inputStreamToFile(new ClassPathResource(path).getInputStream(), name);
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.error(e.getMessage(), e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 驼峰命名法工具
|
|
||||||
*
|
|
||||||
* @return toCamelCase(" hello_world ") == "helloWorld"
|
|
||||||
* toCapitalizeCamelCase("hello_world") == "HelloWorld"
|
|
||||||
* toUnderScoreCase("helloWorld") = "hello_world"
|
|
||||||
*/
|
|
||||||
public static String toCamelCase(String s) {
|
|
||||||
if (s == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
s = s.toLowerCase();
|
|
||||||
|
|
||||||
StringBuilder sb = new StringBuilder(s.length());
|
|
||||||
boolean upperCase = false;
|
|
||||||
for (int i = 0; i < s.length(); i++) {
|
|
||||||
char c = s.charAt(i);
|
|
||||||
|
|
||||||
if (c == SEPARATOR) {
|
|
||||||
upperCase = true;
|
|
||||||
} else if (upperCase) {
|
|
||||||
sb.append(Character.toUpperCase(c));
|
|
||||||
upperCase = false;
|
|
||||||
} else {
|
|
||||||
sb.append(c);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return sb.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 驼峰命名法工具
|
|
||||||
*
|
|
||||||
* @return toCamelCase(" hello_world ") == "helloWorld"
|
|
||||||
* toCapitalizeCamelCase("hello_world") == "HelloWorld"
|
|
||||||
* toUnderScoreCase("helloWorld") = "hello_world"
|
|
||||||
*/
|
|
||||||
public static String toCapitalizeCamelCase(String s) {
|
|
||||||
if (s == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
s = toCamelCase(s);
|
|
||||||
return s.substring(0, 1).toUpperCase() + s.substring(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 驼峰命名法工具
|
|
||||||
*
|
|
||||||
* @return toCamelCase(" hello_world ") == "helloWorld"
|
|
||||||
* toCapitalizeCamelCase("hello_world") == "HelloWorld"
|
|
||||||
* toUnderScoreCase("helloWorld") = "hello_world"
|
|
||||||
*/
|
|
||||||
static String toUnderScoreCase(String s) {
|
|
||||||
if (s == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
StringBuilder sb = new StringBuilder();
|
|
||||||
boolean upperCase = false;
|
|
||||||
for (int i = 0; i < s.length(); i++) {
|
|
||||||
char c = s.charAt(i);
|
|
||||||
|
|
||||||
boolean nextUpperCase = true;
|
|
||||||
|
|
||||||
if (i < (s.length() - 1)) {
|
|
||||||
nextUpperCase = Character.isUpperCase(s.charAt(i + 1));
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((i > 0) && Character.isUpperCase(c)) {
|
|
||||||
if (!upperCase || !nextUpperCase) {
|
|
||||||
sb.append(SEPARATOR);
|
|
||||||
}
|
|
||||||
upperCase = true;
|
|
||||||
} else {
|
|
||||||
upperCase = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
sb.append(Character.toLowerCase(c));
|
|
||||||
}
|
|
||||||
|
|
||||||
return sb.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取ip地址
|
|
||||||
*/
|
|
||||||
public static String getIp(HttpServletRequest request) {
|
|
||||||
String ip = request.getHeader("x-forwarded-for");
|
|
||||||
if (ip == null || ip.length() == 0 || UNKNOWN.equalsIgnoreCase(ip)) {
|
|
||||||
ip = request.getHeader("Proxy-Client-IP");
|
|
||||||
}
|
|
||||||
if (ip == null || ip.length() == 0 || UNKNOWN.equalsIgnoreCase(ip)) {
|
|
||||||
ip = request.getHeader("WL-Proxy-Client-IP");
|
|
||||||
}
|
|
||||||
if (ip == null || ip.length() == 0 || UNKNOWN.equalsIgnoreCase(ip)) {
|
|
||||||
ip = request.getRemoteAddr();
|
|
||||||
}
|
|
||||||
String comma = ",";
|
|
||||||
String localhost = "127.0.0.1";
|
|
||||||
if (ip.contains(comma)) {
|
|
||||||
ip = ip.split(",")[0];
|
|
||||||
}
|
|
||||||
if (localhost.equals(ip)) {
|
|
||||||
// 获取本机真正的ip地址
|
|
||||||
try {
|
|
||||||
ip = InetAddress.getLocalHost().getHostAddress();
|
|
||||||
} catch (UnknownHostException e) {
|
|
||||||
log.error(e.getMessage(), e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return ip;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据ip获取详细地址
|
|
||||||
*/
|
|
||||||
@SneakyThrows
|
|
||||||
public static String getCityInfo(String ip) {
|
|
||||||
if (ipLocal) {
|
|
||||||
return getLocalCityInfo(ip);
|
|
||||||
} else {
|
|
||||||
return getHttpCityInfo(ip);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据ip获取详细地址
|
|
||||||
*/
|
|
||||||
public static String getHttpCityInfo(String ip) {
|
|
||||||
String host = "202.108.22.5";
|
|
||||||
//超时应该在3钞以上
|
|
||||||
int timeOut = 3000;
|
|
||||||
boolean status = false;
|
|
||||||
try {
|
|
||||||
status = InetAddress.getByName(host).isReachable(timeOut);
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
String api ="";
|
|
||||||
if (status){
|
|
||||||
api = HttpUtil.get(String.format(Constant.Url.IP_URL, ip));
|
|
||||||
}else {
|
|
||||||
api = "{\"ip\":\"127.0.0.1\",\"pro\":\"\",\"proCode\":\"999999\",\"city\":\"\",\"cityCode\":\"0\",\"region\":\"\",\"regionCode\":\"0\",\"addr\":\" 局域网\",\"regionNames\":\"\",\"err\":\"noprovince\"}";
|
|
||||||
}
|
|
||||||
JSONObject object = JSONUtil.parseObj(api);
|
|
||||||
return object.get("addr", String.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据ip获取详细地址
|
|
||||||
*/
|
|
||||||
public static String getLocalCityInfo(String ip) {
|
|
||||||
try {
|
|
||||||
DataBlock dataBlock = new DbSearcher(config, file.getPath())
|
|
||||||
.binarySearch(ip);
|
|
||||||
String region = dataBlock.getRegion();
|
|
||||||
String address = region.replace("0|", "");
|
|
||||||
char symbol = '|';
|
|
||||||
if (address.charAt(address.length() - 1) == symbol) {
|
|
||||||
address = address.substring(0, address.length() - 1);
|
|
||||||
}
|
|
||||||
return address.equals(Constant.REGION) ? "内网IP" : address;
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.error(e.getMessage(), e);
|
|
||||||
}
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String getBrowser(HttpServletRequest request) {
|
|
||||||
UserAgent userAgent = UserAgent.parseUserAgentString(request.getHeader("User-Agent"));
|
|
||||||
Browser browser = userAgent.getBrowser();
|
|
||||||
return browser.getName();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获得当天是周几
|
|
||||||
*/
|
|
||||||
public static String getWeekDay() {
|
|
||||||
String[] weekDays = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"};
|
|
||||||
Calendar cal = Calendar.getInstance();
|
|
||||||
cal.setTime(new Date());
|
|
||||||
|
|
||||||
int w = cal.get(Calendar.DAY_OF_WEEK) - 1;
|
|
||||||
if (w < 0) {
|
|
||||||
w = 0;
|
|
||||||
}
|
|
||||||
return weekDays[w];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取当前机器的IP
|
|
||||||
*
|
|
||||||
* @return /
|
|
||||||
*/
|
|
||||||
public static String getLocalIp() {
|
|
||||||
try {
|
|
||||||
InetAddress candidateAddress = null;
|
|
||||||
// 遍历所有的网络接口
|
|
||||||
for (Enumeration<NetworkInterface> interfaces = NetworkInterface.getNetworkInterfaces(); interfaces.hasMoreElements();) {
|
|
||||||
NetworkInterface anInterface = interfaces.nextElement();
|
|
||||||
// 在所有的接口下再遍历IP
|
|
||||||
for (Enumeration<InetAddress> inetAddresses = anInterface.getInetAddresses(); inetAddresses.hasMoreElements();) {
|
|
||||||
InetAddress inetAddr = inetAddresses.nextElement();
|
|
||||||
// 排除loopback类型地址
|
|
||||||
if (!inetAddr.isLoopbackAddress()) {
|
|
||||||
if (inetAddr.isSiteLocalAddress()) {
|
|
||||||
// 如果是site-local地址,就是它了
|
|
||||||
return inetAddr.getHostAddress();
|
|
||||||
} else if (candidateAddress == null) {
|
|
||||||
// site-local类型的地址未被发现,先记录候选地址
|
|
||||||
candidateAddress = inetAddr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (candidateAddress != null) {
|
|
||||||
return candidateAddress.getHostAddress();
|
|
||||||
}
|
|
||||||
// 如果没有发现 non-loopback地址.只能用最次选的方案
|
|
||||||
InetAddress jdkSuppliedAddress = InetAddress.getLocalHost();
|
|
||||||
if (jdkSuppliedAddress == null) {
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
return jdkSuppliedAddress.getHostAddress();
|
|
||||||
} catch (Exception e) {
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,134 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
|
|
||||||
<parent>
|
|
||||||
<groupId>com.yfd</groupId>
|
|
||||||
<artifactId>platform</artifactId>
|
|
||||||
<version>1.0</version>
|
|
||||||
<relativePath>../pom.xml</relativePath>
|
|
||||||
</parent>
|
|
||||||
|
|
||||||
<artifactId>platform-system</artifactId>
|
|
||||||
<version>1.0</version>
|
|
||||||
<packaging>jar</packaging>
|
|
||||||
|
|
||||||
<name>Platform System</name>
|
|
||||||
<description>Platform System Module</description>
|
|
||||||
|
|
||||||
<dependencies>
|
|
||||||
<!-- Common Module -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.yfd</groupId>
|
|
||||||
<artifactId>platform-common</artifactId>
|
|
||||||
<version>1.0</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- Spring Boot Starter -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-starter</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- Spring Boot Web -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-starter-web</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- Spring Boot WebSocket -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-starter-websocket</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- MyBatis Plus -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.baomidou</groupId>
|
|
||||||
<artifactId>mybatis-plus-spring-boot4-starter</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- Spring Security -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-starter-security</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- AspectJ -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.aspectj</groupId>
|
|
||||||
<artifactId>aspectjweaver</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- Druid -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.alibaba</groupId>
|
|
||||||
<artifactId>druid</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- Easy Captcha -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.github.whvcse</groupId>
|
|
||||||
<artifactId>easy-captcha</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.openjdk.nashorn</groupId>
|
|
||||||
<artifactId>nashorn-core</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<!-- SpringDoc OpenAPI -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springdoc</groupId>
|
|
||||||
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- Lombok -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.projectlombok</groupId>
|
|
||||||
<artifactId>lombok</artifactId>
|
|
||||||
<optional>true</optional>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.baomidou</groupId>
|
|
||||||
<artifactId>mybatis-plus-jsqlparser</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.alibaba.fastjson2</groupId>
|
|
||||||
<artifactId>fastjson2</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-starter-data-redis</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- Oracle JDBC Driver -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.oracle.database.jdbc</groupId>
|
|
||||||
<artifactId>ojdbc8</artifactId>
|
|
||||||
<scope>runtime</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.oracle.database.nls</groupId>
|
|
||||||
<artifactId>orai18n</artifactId>
|
|
||||||
<scope>runtime</scope>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
|
|
||||||
<!-- <build>-->
|
|
||||||
<!-- <plugins>-->
|
|
||||||
<!-- <plugin>-->
|
|
||||||
<!-- <groupId>org.springframework.boot</groupId>-->
|
|
||||||
<!-- <artifactId>spring-boot-maven-plugin</artifactId>-->
|
|
||||||
<!-- <configuration>-->
|
|
||||||
<!-- <mainClass>com.yfd.platform.system.PlatformApplication</mainClass>-->
|
|
||||||
<!-- </configuration>-->
|
|
||||||
<!-- </plugin>-->
|
|
||||||
<!-- </plugins>-->
|
|
||||||
<!-- </build>-->
|
|
||||||
|
|
||||||
</project>
|
|
||||||
@ -1,42 +0,0 @@
|
|||||||
package com.yfd.platform.constant;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author TangWei
|
|
||||||
* @Date: 2023/3/3 17:40
|
|
||||||
* @Description: 常量类
|
|
||||||
*/
|
|
||||||
public class Constant {
|
|
||||||
|
|
||||||
public static final String LOGIN = "login:";
|
|
||||||
public static final String TOKEN = "token:";
|
|
||||||
public static final String USER_ID = "userid";
|
|
||||||
public static final String DATE_TIME_FORMAT = "yyyy-MM-dd HH:mm:ss";
|
|
||||||
|
|
||||||
public static final String CODE_KEY = "code-key-";
|
|
||||||
public static final long CODE_EXPIRATION_TIME = 1000 * 60;
|
|
||||||
/**
|
|
||||||
* 用于IP定位转换
|
|
||||||
*/
|
|
||||||
public static final String REGION = "内网IP|内网IP";
|
|
||||||
/**
|
|
||||||
* win 系统
|
|
||||||
*/
|
|
||||||
public static final String WIN = "win";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* mac 系统
|
|
||||||
*/
|
|
||||||
public static final String MAC = "mac";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 常用接口
|
|
||||||
*/
|
|
||||||
public static class Url {
|
|
||||||
|
|
||||||
// IP归属地查询
|
|
||||||
// public static final String IP_URL = "http://whois.pconline.com
|
|
||||||
// .cn/ipJson.jsp?ip=%s&json=true";
|
|
||||||
public static final String IP_URL = "http://whois.pconline.com" +
|
|
||||||
".cn/ipJson.jsp?ip=%s&json=true";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,100 +0,0 @@
|
|||||||
server:
|
|
||||||
port: 8093
|
|
||||||
|
|
||||||
spring:
|
|
||||||
#应用名称
|
|
||||||
application:
|
|
||||||
name: Project-plateform
|
|
||||||
datasource:
|
|
||||||
type: com.alibaba.druid.pool.DruidDataSource
|
|
||||||
druid:
|
|
||||||
master:
|
|
||||||
driverClassName: oracle.jdbc.OracleDriver
|
|
||||||
url: "${DB_MASTER_URL:jdbc:oracle:thin:@172.16.21.134:1521/SDLYZ}"
|
|
||||||
username: "${DB_MASTER_USERNAME:QGC}"
|
|
||||||
password: "${DB_MASTER_PASSWORD:ar6Yr7Vxo5}"
|
|
||||||
slave:
|
|
||||||
driverClassName: oracle.jdbc.OracleDriver
|
|
||||||
url: "${DB_SLAVE_URL:jdbc:oracle:thin:@172.16.21.134:1521/SDLYZ}"
|
|
||||||
username: "${DB_SLAVE_USERNAME:QGC}"
|
|
||||||
password: "${DB_SLAVE_PASSWORD:ar6Yr7Vxo5}"
|
|
||||||
|
|
||||||
mvc:
|
|
||||||
pathmatch:
|
|
||||||
matching-strategy: ant_path_matcher
|
|
||||||
servlet:
|
|
||||||
multipart:
|
|
||||||
max-file-size: 30MB
|
|
||||||
max-request-size: 100MB
|
|
||||||
data:
|
|
||||||
redis:
|
|
||||||
host: 172.16.21.142
|
|
||||||
port: 6379
|
|
||||||
password: zny5678 # 如果有密码
|
|
||||||
database: 0
|
|
||||||
|
|
||||||
logging:
|
|
||||||
file:
|
|
||||||
name: logs/projectname.log
|
|
||||||
level:
|
|
||||||
com.genersoft.iot: debug
|
|
||||||
com.genersoft.iot.vmp.storager.dao: info
|
|
||||||
com.genersoft.iot.vmp.gb28181: info
|
|
||||||
|
|
||||||
# 在线文档: swagger-ui(生产环境建议关闭)
|
|
||||||
swagger-ui:
|
|
||||||
enabled: true
|
|
||||||
|
|
||||||
|
|
||||||
# 登录相关配置
|
|
||||||
login:
|
|
||||||
# 登录缓存
|
|
||||||
cache-enable: true
|
|
||||||
# 是否限制单用户登录
|
|
||||||
single-login: false
|
|
||||||
# 验证码
|
|
||||||
login-code:
|
|
||||||
# 验证码类型配置 查看 LoginProperties 类
|
|
||||||
code-type: arithmetic
|
|
||||||
|
|
||||||
# 启动自动数据库初始化(仅 dev/server):
|
|
||||||
app:
|
|
||||||
init:
|
|
||||||
enabled: false
|
|
||||||
schema: classpath:db-init/sql/min-schema.sql
|
|
||||||
# data 文件可选;为避免复杂 dump 解析问题,先不导入
|
|
||||||
# data:
|
|
||||||
marker-table: sys_user
|
|
||||||
marker-version: v1.0.0
|
|
||||||
# 登录图形验证码有效时间/分钟
|
|
||||||
expiration: 2
|
|
||||||
# 验证码高度
|
|
||||||
width: 111
|
|
||||||
# 验证码宽度
|
|
||||||
heigth: 36
|
|
||||||
# 内容长度
|
|
||||||
length: 2
|
|
||||||
# 字体名称,为空则使用默认字体
|
|
||||||
font-name:
|
|
||||||
# 字体大小
|
|
||||||
font-size: 25
|
|
||||||
|
|
||||||
# IP 本地解析
|
|
||||||
ip:
|
|
||||||
local-parsing: true
|
|
||||||
|
|
||||||
|
|
||||||
file-space: #项目文档空间
|
|
||||||
files: D:\demoproject\files\ #单独上传的文件附件
|
|
||||||
system: D:\demoproject\system\ #单独上传的文件
|
|
||||||
|
|
||||||
task:
|
|
||||||
pool:
|
|
||||||
# 核心线程池大小
|
|
||||||
core-pool-size: 10
|
|
||||||
# 最大线程数
|
|
||||||
max-pool-size: 30
|
|
||||||
# 活跃时间
|
|
||||||
keep-alive-seconds: 60
|
|
||||||
# 队列容量
|
|
||||||
queue-capacity: 50
|
|
||||||
464
backend/pom.xml
464
backend/pom.xml
@ -11,7 +11,7 @@
|
|||||||
<groupId>com.yfd</groupId>
|
<groupId>com.yfd</groupId>
|
||||||
<artifactId>platform</artifactId>
|
<artifactId>platform</artifactId>
|
||||||
<version>1.0</version>
|
<version>1.0</version>
|
||||||
<packaging>pom</packaging>
|
<packaging>jar</packaging>
|
||||||
<name>platform</name>
|
<name>platform</name>
|
||||||
<description>springboot 项目基础框架4.0.3</description>
|
<description>springboot 项目基础框架4.0.3</description>
|
||||||
<properties>
|
<properties>
|
||||||
@ -32,8 +32,7 @@
|
|||||||
<hutool.version>5.8.8</hutool.version>
|
<hutool.version>5.8.8</hutool.version>
|
||||||
<poi.version>4.1.2</poi.version>
|
<poi.version>4.1.2</poi.version>
|
||||||
<poi.ooxml.version>4.1.2</poi.ooxml.version>
|
<poi.ooxml.version>4.1.2</poi.ooxml.version>
|
||||||
<fastjson.version>1.2.83</fastjson.version>
|
<fastjson.version>1.2.70</fastjson.version>
|
||||||
<fastjson2.version>2.0.53</fastjson2.version>
|
|
||||||
<springdoc.version>3.0.2</springdoc.version>
|
<springdoc.version>3.0.2</springdoc.version>
|
||||||
<freemarker.version>2.3.28</freemarker.version>
|
<freemarker.version>2.3.28</freemarker.version>
|
||||||
<jsoup.version>1.11.3</jsoup.version>
|
<jsoup.version>1.11.3</jsoup.version>
|
||||||
@ -41,13 +40,12 @@
|
|||||||
<ip2region.version>1.7.2</ip2region.version>
|
<ip2region.version>1.7.2</ip2region.version>
|
||||||
<easy.captcha.version>1.6.2</easy.captcha.version>
|
<easy.captcha.version>1.6.2</easy.captcha.version>
|
||||||
<useragentutils.version>1.21</useragentutils.version>
|
<useragentutils.version>1.21</useragentutils.version>
|
||||||
<redis.version>4.0.3</redis.version>
|
<gson.version>2.10.1</gson.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<!-- 统一管理 MyBatis 相关版本,解决依赖收敛冲突 -->
|
<!-- 统一管理 MyBatis 相关版本,解决依赖收敛冲突 -->
|
||||||
<dependencyManagement>
|
<dependencyManagement>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<!-- MyBatis 相关依赖 -->
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.mybatis</groupId>
|
<groupId>org.mybatis</groupId>
|
||||||
<artifactId>mybatis</artifactId>
|
<artifactId>mybatis</artifactId>
|
||||||
@ -58,168 +56,284 @@
|
|||||||
<artifactId>mybatis-spring</artifactId>
|
<artifactId>mybatis-spring</artifactId>
|
||||||
<version>3.0.3</version>
|
<version>3.0.3</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>org.mybatis.spring.boot</groupId>
|
|
||||||
<artifactId>mybatis-spring-boot-starter</artifactId>
|
|
||||||
<version>${mybatis.spring.boot.starter.version}</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- MyBatis-Plus 相关依赖 -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.baomidou</groupId>
|
|
||||||
<artifactId>mybatis-plus-spring-boot4-starter</artifactId>
|
|
||||||
<version>${mybatis-plus.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.baomidou</groupId>
|
|
||||||
<artifactId>mybatis-plus-jsqlparser</artifactId>
|
|
||||||
<version>${mybatis-plus.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.baomidou</groupId>
|
|
||||||
<artifactId>mybatis-plus-generator</artifactId>
|
|
||||||
<version>${mybatis-plus.version}</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- 数据库相关依赖 -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.alibaba</groupId>
|
|
||||||
<artifactId>druid</artifactId>
|
|
||||||
<version>${druid.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.dameng</groupId>
|
|
||||||
<artifactId>DmJdbcDriver18</artifactId>
|
|
||||||
<version>8.1.2.79</version>
|
|
||||||
<scope>runtime</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.oracle.database.jdbc</groupId>
|
|
||||||
<artifactId>ojdbc8</artifactId>
|
|
||||||
<version>21.9.0.0</version>
|
|
||||||
<scope>runtime</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.oracle.database.nls</groupId>
|
|
||||||
<artifactId>orai18n</artifactId>
|
|
||||||
<version>21.9.0.0</version>
|
|
||||||
<scope>runtime</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.xerial</groupId>
|
|
||||||
<artifactId>sqlite-jdbc</artifactId>
|
|
||||||
<version>${sqlite-jdbc.version}</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- 工具类依赖 -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.google.guava</groupId>
|
|
||||||
<artifactId>guava</artifactId>
|
|
||||||
<version>${guava.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.apache.commons</groupId>
|
|
||||||
<artifactId>commons-lang3</artifactId>
|
|
||||||
<version>3.12.0</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>commons-codec</groupId>
|
|
||||||
<artifactId>commons-codec</artifactId>
|
|
||||||
<version>1.15</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.projectlombok</groupId>
|
|
||||||
<artifactId>lombok</artifactId>
|
|
||||||
<version>1.18.42</version>
|
|
||||||
<optional>true</optional>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>cn.hutool</groupId>
|
|
||||||
<artifactId>hutool-all</artifactId>
|
|
||||||
<version>${hutool.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.apache.poi</groupId>
|
|
||||||
<artifactId>poi</artifactId>
|
|
||||||
<version>${poi.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.apache.poi</groupId>
|
|
||||||
<artifactId>poi-ooxml</artifactId>
|
|
||||||
<version>${poi.ooxml.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.alibaba</groupId>
|
|
||||||
<artifactId>fastjson</artifactId>
|
|
||||||
<version>${fastjson.version}</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.alibaba.fastjson2</groupId>
|
|
||||||
<artifactId>fastjson2</artifactId><!-- 或更新的 2.x 版本 -->
|
|
||||||
<version>${fastjson2.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.freemarker</groupId>
|
|
||||||
<artifactId>freemarker</artifactId>
|
|
||||||
<version>${freemarker.version}</version>
|
|
||||||
<scope>compile</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.jsoup</groupId>
|
|
||||||
<artifactId>jsoup</artifactId>
|
|
||||||
<version>${jsoup.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.github.ulisesbocchio</groupId>
|
|
||||||
<artifactId>jasypt-spring-boot-starter</artifactId>
|
|
||||||
<version>${jasypt.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.lionsoul</groupId>
|
|
||||||
<artifactId>ip2region</artifactId>
|
|
||||||
<version>${ip2region.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.github.whvcse</groupId>
|
|
||||||
<artifactId>easy-captcha</artifactId>
|
|
||||||
<version>${easy.captcha.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>eu.bitwalker</groupId>
|
|
||||||
<artifactId>UserAgentUtils</artifactId>
|
|
||||||
<version>${useragentutils.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.openjdk.nashorn</groupId>
|
|
||||||
<artifactId>nashorn-core</artifactId>
|
|
||||||
<version>15.4</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- SpringDoc 相关依赖 -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springdoc</groupId>
|
|
||||||
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
|
|
||||||
<version>${springdoc.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<!-- Spring Boot Redis -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-starter-data-redis</artifactId>
|
|
||||||
<version>${redis.version}</version>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</dependencyManagement>
|
</dependencyManagement>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<!-- 父模块仅声明依赖管理,具体依赖由子模块根据需要引入 -->
|
|
||||||
</dependencies>
|
|
||||||
|
|
||||||
<modules>
|
<dependency>
|
||||||
<module>platform-system</module>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<module>platform-common</module>
|
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||||
<module>qgc-env-server</module>
|
</dependency>
|
||||||
<module>qgc-eng-server</module>
|
|
||||||
</modules>
|
<!-- spring-web -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-web</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- spring-security -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-security</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!--Spring boot Redis-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-data-redis</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- WebSocket依赖 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-websocket</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!--Spring 缓存-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-cache</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- 测试 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-test</artifactId>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!--Guava是一种基于开源的Java库高性能数据缓存-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.google.guava</groupId>
|
||||||
|
<artifactId>guava</artifactId>
|
||||||
|
<version>${guava.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- 对于 jar 包,spring-boot-starter-web 已包含嵌入式 Tomcat,无需显式 provided -->
|
||||||
|
|
||||||
|
<!-- spring-quartz任务-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-quartz</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- spring-elasticsearch搜素-->
|
||||||
|
<!-- <dependency>-->
|
||||||
|
<!-- <groupId>org.springframework.boot</groupId>-->
|
||||||
|
<!-- <artifactId>spring-boot-starter-data-elasticsearch</artifactId>-->
|
||||||
|
<!-- </dependency>-->
|
||||||
|
|
||||||
|
<!-- spring-Mybatis-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.mybatis.spring.boot</groupId>
|
||||||
|
<artifactId>mybatis-spring-boot-starter</artifactId>
|
||||||
|
<version>${mybatis.spring.boot.starter.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- 显式固定 MyBatis 版本,避免与 MyBatis-Plus 不兼容的方法签名问题 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.mybatis</groupId>
|
||||||
|
<artifactId>mybatis</artifactId>
|
||||||
|
<version>${mybatis.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- druid数据库连接池 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba</groupId>
|
||||||
|
<artifactId>druid</artifactId>
|
||||||
|
<version>${druid.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!--数据库连接-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-jdbc</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- mysql数据库 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.mysql</groupId>
|
||||||
|
<artifactId>mysql-connector-j</artifactId>
|
||||||
|
<scope>runtime</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- 达梦 DM8 JDBC(驱动类:dm.jdbc.driver.DmDriver) -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.dameng</groupId>
|
||||||
|
<artifactId>DmJdbcDriver18</artifactId>
|
||||||
|
<version>8.1.2.79</version>
|
||||||
|
<scope>runtime</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- Oracle JDBC 驱动(驱动类:oracle.jdbc.OracleDriver) -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.oracle.database.jdbc</groupId>
|
||||||
|
<artifactId>ojdbc8</artifactId>
|
||||||
|
<version>21.9.0.0</version>
|
||||||
|
<scope>runtime</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- Oracle 国际化支持包(解决 ZHS16GBK 等字符集问题) -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.oracle.database.nls</groupId>
|
||||||
|
<artifactId>orai18n</artifactId>
|
||||||
|
<version>21.9.0.0</version>
|
||||||
|
<scope>runtime</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- sqlite-jdbc数据库 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.xerial</groupId>
|
||||||
|
<artifactId>sqlite-jdbc</artifactId>
|
||||||
|
<version>${sqlite-jdbc.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- mybatis-plus 数据库扩展插件-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.baomidou</groupId>
|
||||||
|
<artifactId>mybatis-plus-spring-boot4-starter</artifactId>
|
||||||
|
<version>${mybatis-plus.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.baomidou</groupId>
|
||||||
|
<artifactId>mybatis-plus-jsqlparser</artifactId>
|
||||||
|
<version>${mybatis-plus.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.baomidou</groupId>
|
||||||
|
<artifactId>mybatis-plus-generator</artifactId>
|
||||||
|
<version>${mybatis-plus.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!--apache.commons -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.commons</groupId>
|
||||||
|
<artifactId>commons-lang3</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!--lombok bean注解 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.projectlombok</groupId>
|
||||||
|
<artifactId>lombok</artifactId>
|
||||||
|
<optional>true</optional>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- 日志相关 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-aspectj</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- 胡图工具类 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>cn.hutool</groupId>
|
||||||
|
<artifactId>hutool-all</artifactId>
|
||||||
|
<version>${hutool.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- excel工具 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.poi</groupId>
|
||||||
|
<artifactId>poi</artifactId>
|
||||||
|
<version>${poi.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.poi</groupId>
|
||||||
|
<artifactId>poi-ooxml</artifactId>
|
||||||
|
<version>${poi.ooxml.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- fastjson -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba</groupId>
|
||||||
|
<artifactId>fastjson</artifactId>
|
||||||
|
<version>${fastjson.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- Springdoc OpenAPI 替换 Springfox -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springdoc</groupId>
|
||||||
|
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
|
||||||
|
<version>${springdoc.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<!-- Micrometer Prometheus 导出器 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.micrometer</groupId>
|
||||||
|
<artifactId>micrometer-registry-prometheus</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<!-- 删除重复的 WebSocket 依赖(上方已声明一次) -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.freemarker</groupId>
|
||||||
|
<artifactId>freemarker</artifactId>
|
||||||
|
<version>${freemarker.version}</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.jsoup</groupId>
|
||||||
|
<artifactId>jsoup</artifactId>
|
||||||
|
<version>${jsoup.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- 数据库密码加密 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.github.ulisesbocchio</groupId>
|
||||||
|
<artifactId>jasypt-spring-boot-starter</artifactId>
|
||||||
|
<version>${jasypt.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.lionsoul</groupId>
|
||||||
|
<artifactId>ip2region</artifactId>
|
||||||
|
<version>${ip2region.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- Java图形验证码 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.github.whvcse</groupId>
|
||||||
|
<artifactId>easy-captcha</artifactId>
|
||||||
|
<version>${easy.captcha.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- 解析客户端操作系统、浏览器信息 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>eu.bitwalker</groupId>
|
||||||
|
<artifactId>UserAgentUtils</artifactId>
|
||||||
|
<version>${useragentutils.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<!-- Restore JavaScript engine on JDK 15+ for ArithmeticCaptcha -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.openjdk.nashorn</groupId>
|
||||||
|
<artifactId>nashorn-core</artifactId>
|
||||||
|
<version>15.4</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- gson -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.google.code.gson</groupId>
|
||||||
|
<artifactId>gson</artifactId>
|
||||||
|
<version>${gson.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<!-- <dependency>-->
|
||||||
|
<!-- <groupId>com.zny.platform</groupId>-->
|
||||||
|
<!-- <artifactId>dec-framework-kendo</artifactId>-->
|
||||||
|
<!-- <version>0.4.0.5-SNAPSHOT</version>-->
|
||||||
|
<!-- <exclusions>-->
|
||||||
|
<!-- <exclusion>-->
|
||||||
|
<!-- <groupId>dm.jdbc.driver</groupId>-->
|
||||||
|
<!-- <artifactId>18</artifactId>-->
|
||||||
|
<!-- </exclusion>-->
|
||||||
|
<!-- </exclusions>-->
|
||||||
|
<!-- </dependency>-->
|
||||||
|
|
||||||
|
|
||||||
|
<!-- 显式添加 Jackson 依赖 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-json</artifactId>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
<resources>
|
<resources>
|
||||||
@ -319,18 +433,18 @@
|
|||||||
<goal>enforce</goal>
|
<goal>enforce</goal>
|
||||||
</goals>
|
</goals>
|
||||||
<configuration>
|
<configuration>
|
||||||
<rules>
|
<rules>
|
||||||
<!-- 推荐升级 Maven 到 3.8+;临时放宽版本以便构建 -->
|
<!-- 推荐升级 Maven 到 3.8+;临时放宽版本以便构建 -->
|
||||||
<requireMavenVersion>
|
<requireMavenVersion>
|
||||||
<version>[3.6.3,)</version>
|
<version>[3.6.3,)</version>
|
||||||
</requireMavenVersion>
|
</requireMavenVersion>
|
||||||
<requireJavaVersion>
|
<requireJavaVersion>
|
||||||
<version>[21,)</version>
|
<version>[21,)</version>
|
||||||
</requireJavaVersion>
|
</requireJavaVersion>
|
||||||
<dependencyConvergence/>
|
<dependencyConvergence/>
|
||||||
<!-- 如需严格校验插件版本,可在升级 Maven 后再启用 -->
|
<!-- 如需严格校验插件版本,可在升级 Maven 后再启用 -->
|
||||||
</rules>
|
</rules>
|
||||||
</configuration>
|
</configuration>
|
||||||
</execution>
|
</execution>
|
||||||
</executions>
|
</executions>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|||||||
@ -1,43 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
|
|
||||||
<parent>
|
|
||||||
<groupId>com.yfd</groupId>
|
|
||||||
<artifactId>platform</artifactId>
|
|
||||||
<version>1.0</version>
|
|
||||||
<relativePath>../pom.xml</relativePath>
|
|
||||||
</parent>
|
|
||||||
|
|
||||||
<artifactId>qgc-eng-server</artifactId>
|
|
||||||
<version>1.0</version>
|
|
||||||
<packaging>jar</packaging>
|
|
||||||
|
|
||||||
<name>QGC Eng Server</name>
|
|
||||||
<description>QGC Engineering Server Module</description>
|
|
||||||
|
|
||||||
<dependencies>
|
|
||||||
<!-- Common Module -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.yfd</groupId>
|
|
||||||
<artifactId>platform-common</artifactId>
|
|
||||||
<version>1.0</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- System Module -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.yfd</groupId>
|
|
||||||
<artifactId>platform-system</artifactId>
|
|
||||||
<version>1.0</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- MyBatis Plus -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.baomidou</groupId>
|
|
||||||
<artifactId>mybatis-plus-spring-boot4-starter</artifactId>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
|
|
||||||
</project>
|
|
||||||
@ -1,47 +0,0 @@
|
|||||||
package com.yfd.platform.eng.controller;
|
|
||||||
|
|
||||||
import com.yfd.platform.common.response.ResponseResult;
|
|
||||||
import com.yfd.platform.eng.service.IEngService;
|
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
|
||||||
|
|
||||||
import jakarta.annotation.Resource;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 工程控制器
|
|
||||||
*/
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("/eng")
|
|
||||||
@Tag(name = "工程管理")
|
|
||||||
public class EngController {
|
|
||||||
|
|
||||||
@Resource
|
|
||||||
private IEngService engService;
|
|
||||||
|
|
||||||
@PostMapping("/getEngData")
|
|
||||||
@Operation(summary = "获取工程数据")
|
|
||||||
public ResponseResult getEngData(@RequestBody Map<String, Object> params) {
|
|
||||||
return ResponseResult.successData(engService.getEngData(params));
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("/addEngData")
|
|
||||||
@Operation(summary = "添加工程数据")
|
|
||||||
public ResponseResult addEngData(@RequestBody Map<String, Object> params) {
|
|
||||||
return ResponseResult.successData(engService.addEngData(params));
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("/updateEngData")
|
|
||||||
@Operation(summary = "更新工程数据")
|
|
||||||
public ResponseResult updateEngData(@RequestBody Map<String, Object> params) {
|
|
||||||
return ResponseResult.successData(engService.updateEngData(params));
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("/deleteEngData")
|
|
||||||
@Operation(summary = "删除工程数据")
|
|
||||||
public ResponseResult deleteEngData(@RequestBody Map<String, Object> params) {
|
|
||||||
engService.deleteEngData(params);
|
|
||||||
return ResponseResult.success();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,35 +0,0 @@
|
|||||||
package com.yfd.platform.eng.service;
|
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 工程服务接口
|
|
||||||
*/
|
|
||||||
public interface IEngService {
|
|
||||||
/**
|
|
||||||
* 获取工程数据
|
|
||||||
* @param params 参数
|
|
||||||
* @return 工程数据
|
|
||||||
*/
|
|
||||||
Map<String, Object> getEngData(Map<String, Object> params);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 添加工程数据
|
|
||||||
* @param params 参数
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
Map<String, Object> addEngData(Map<String, Object> params);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新工程数据
|
|
||||||
* @param params 参数
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
Map<String, Object> updateEngData(Map<String, Object> params);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除工程数据
|
|
||||||
* @param params 参数
|
|
||||||
*/
|
|
||||||
void deleteEngData(Map<String, Object> params);
|
|
||||||
}
|
|
||||||
@ -1,43 +0,0 @@
|
|||||||
package com.yfd.platform.eng.service.impl;
|
|
||||||
|
|
||||||
import com.yfd.platform.eng.service.IEngService;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 工程服务实现类
|
|
||||||
*/
|
|
||||||
public class EngServiceImpl implements IEngService {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Map<String, Object> getEngData(Map<String, Object> params) {
|
|
||||||
Map<String, Object> result = new HashMap<>();
|
|
||||||
// TODO: 实现获取工程数据逻辑
|
|
||||||
result.put("total", 0);
|
|
||||||
result.put("data", null);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Map<String, Object> addEngData(Map<String, Object> params) {
|
|
||||||
Map<String, Object> result = new HashMap<>();
|
|
||||||
// TODO: 实现添加工程数据逻辑
|
|
||||||
result.put("success", true);
|
|
||||||
result.put("message", "工程数据添加成功");
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Map<String, Object> updateEngData(Map<String, Object> params) {
|
|
||||||
Map<String, Object> result = new HashMap<>();
|
|
||||||
// TODO: 实现更新工程数据逻辑
|
|
||||||
result.put("success", true);
|
|
||||||
result.put("message", "工程数据更新成功");
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void deleteEngData(Map<String, Object> params) {
|
|
||||||
// TODO: 实现删除工程数据逻辑
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,48 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
|
|
||||||
<parent>
|
|
||||||
<groupId>com.yfd</groupId>
|
|
||||||
<artifactId>platform</artifactId>
|
|
||||||
<version>1.0</version>
|
|
||||||
<relativePath>../pom.xml</relativePath>
|
|
||||||
</parent>
|
|
||||||
|
|
||||||
<artifactId>qgc-env-server</artifactId>
|
|
||||||
<version>1.0</version>
|
|
||||||
<packaging>jar</packaging>
|
|
||||||
|
|
||||||
<name>QGC Env Server</name>
|
|
||||||
<description>QGC Environment Server Module</description>
|
|
||||||
|
|
||||||
<dependencies>
|
|
||||||
<!-- Common Module -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.yfd</groupId>
|
|
||||||
<artifactId>platform-common</artifactId>
|
|
||||||
<version>1.0</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- System Module -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.yfd</groupId>
|
|
||||||
<artifactId>platform-system</artifactId>
|
|
||||||
<version>1.0</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- MyBatis Plus -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.baomidou</groupId>
|
|
||||||
<artifactId>mybatis-plus-spring-boot4-starter</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-starter-data-redis</artifactId>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
|
|
||||||
</project>
|
|
||||||
@ -1,47 +0,0 @@
|
|||||||
package com.yfd.platform.env.controller;
|
|
||||||
|
|
||||||
import com.yfd.platform.common.response.ResponseResult;
|
|
||||||
import com.yfd.platform.env.service.IEnvService;
|
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
|
||||||
|
|
||||||
import jakarta.annotation.Resource;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 环境控制器
|
|
||||||
*/
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("/env")
|
|
||||||
@Tag(name = "环境管理")
|
|
||||||
public class EnvController {
|
|
||||||
|
|
||||||
@Resource
|
|
||||||
private IEnvService envService;
|
|
||||||
|
|
||||||
@PostMapping("/getEnvData")
|
|
||||||
@Operation(summary = "获取环境数据")
|
|
||||||
public ResponseResult getEnvData(@RequestBody Map<String, Object> params) {
|
|
||||||
return ResponseResult.successData(envService.getEnvData(params));
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("/addEnvData")
|
|
||||||
@Operation(summary = "添加环境数据")
|
|
||||||
public ResponseResult addEnvData(@RequestBody Map<String, Object> params) {
|
|
||||||
return ResponseResult.successData(envService.addEnvData(params));
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("/updateEnvData")
|
|
||||||
@Operation(summary = "更新环境数据")
|
|
||||||
public ResponseResult updateEnvData(@RequestBody Map<String, Object> params) {
|
|
||||||
return ResponseResult.successData(envService.updateEnvData(params));
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("/deleteEnvData")
|
|
||||||
@Operation(summary = "删除环境数据")
|
|
||||||
public ResponseResult deleteEnvData(@RequestBody Map<String, Object> params) {
|
|
||||||
envService.deleteEnvData(params);
|
|
||||||
return ResponseResult.success();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,4 +0,0 @@
|
|||||||
package com.yfd.platform.env.entity;
|
|
||||||
|
|
||||||
public class Env {
|
|
||||||
}
|
|
||||||
@ -1,7 +0,0 @@
|
|||||||
package com.yfd.platform.env.mapper;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
|
||||||
import com.yfd.platform.env.entity.Env;
|
|
||||||
|
|
||||||
public interface IEnvMapper extends BaseMapper<Env> {
|
|
||||||
}
|
|
||||||
@ -1,35 +0,0 @@
|
|||||||
package com.yfd.platform.env.service;
|
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 环境服务接口
|
|
||||||
*/
|
|
||||||
public interface IEnvService {
|
|
||||||
/**
|
|
||||||
* 获取环境数据
|
|
||||||
* @param params 参数
|
|
||||||
* @return 环境数据
|
|
||||||
*/
|
|
||||||
Map<String, Object> getEnvData(Map<String, Object> params);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 添加环境数据
|
|
||||||
* @param params 参数
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
Map<String, Object> addEnvData(Map<String, Object> params);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新环境数据
|
|
||||||
* @param params 参数
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
Map<String, Object> updateEnvData(Map<String, Object> params);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除环境数据
|
|
||||||
* @param params 参数
|
|
||||||
*/
|
|
||||||
void deleteEnvData(Map<String, Object> params);
|
|
||||||
}
|
|
||||||
@ -1,46 +0,0 @@
|
|||||||
package com.yfd.platform.env.service.impl;
|
|
||||||
|
|
||||||
import com.yfd.platform.env.service.IEnvService;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 环境服务实现类
|
|
||||||
*/
|
|
||||||
@Service
|
|
||||||
public class EnvServiceImpl implements IEnvService {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Map<String, Object> getEnvData(Map<String, Object> params) {
|
|
||||||
Map<String, Object> result = new HashMap<>();
|
|
||||||
// TODO: 实现获取环境数据逻辑
|
|
||||||
result.put("total", 0);
|
|
||||||
result.put("data", null);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Map<String, Object> addEnvData(Map<String, Object> params) {
|
|
||||||
Map<String, Object> result = new HashMap<>();
|
|
||||||
// TODO: 实现添加环境数据逻辑
|
|
||||||
result.put("success", true);
|
|
||||||
result.put("message", "环境数据添加成功");
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Map<String, Object> updateEnvData(Map<String, Object> params) {
|
|
||||||
Map<String, Object> result = new HashMap<>();
|
|
||||||
// TODO: 实现更新环境数据逻辑
|
|
||||||
result.put("success", true);
|
|
||||||
result.put("message", "环境数据更新成功");
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void deleteEnvData(Map<String, Object> params) {
|
|
||||||
// TODO: 实现删除环境数据逻辑
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,94 +0,0 @@
|
|||||||
server:
|
|
||||||
port: 8093
|
|
||||||
|
|
||||||
spring:
|
|
||||||
#应用名称
|
|
||||||
application:
|
|
||||||
name: Project-plateform
|
|
||||||
datasource:
|
|
||||||
type: com.alibaba.druid.pool.DruidDataSource
|
|
||||||
druid:
|
|
||||||
master:
|
|
||||||
driverClassName: dm.jdbc.driver.DmDriver
|
|
||||||
url: "${DB_MASTER_URL:jdbc:dm://localhost:5236/WPPDB}"
|
|
||||||
username: "${DB_MASTER_USERNAME:WPPDB}"
|
|
||||||
password: "${DB_MASTER_PASSWORD:}"
|
|
||||||
slave:
|
|
||||||
driverClassName: dm.jdbc.driver.DmDriver
|
|
||||||
url: "${DB_SLAVE_URL:jdbc:dm://localhost:5236/WPPDB}"
|
|
||||||
username: "${DB_SLAVE_USERNAME:WPPDB}"
|
|
||||||
password: "${DB_SLAVE_PASSWORD:}"
|
|
||||||
|
|
||||||
mvc:
|
|
||||||
pathmatch:
|
|
||||||
matching-strategy: ant_path_matcher
|
|
||||||
servlet:
|
|
||||||
multipart:
|
|
||||||
max-file-size: 30MB
|
|
||||||
max-request-size: 100MB
|
|
||||||
|
|
||||||
logging:
|
|
||||||
file:
|
|
||||||
name: logs/projectname.log
|
|
||||||
level:
|
|
||||||
com.genersoft.iot: debug
|
|
||||||
com.genersoft.iot.vmp.storager.dao: info
|
|
||||||
com.genersoft.iot.vmp.gb28181: info
|
|
||||||
|
|
||||||
# 在线文档: swagger-ui(生产环境建议关闭)
|
|
||||||
swagger-ui:
|
|
||||||
enabled: true
|
|
||||||
|
|
||||||
|
|
||||||
# 登录相关配置
|
|
||||||
login:
|
|
||||||
# 登录缓存
|
|
||||||
cache-enable: true
|
|
||||||
# 是否限制单用户登录
|
|
||||||
single-login: false
|
|
||||||
# 验证码
|
|
||||||
login-code:
|
|
||||||
# 验证码类型配置 查看 LoginProperties 类
|
|
||||||
code-type: arithmetic
|
|
||||||
|
|
||||||
# 启动自动数据库初始化(仅 dev/server):
|
|
||||||
app:
|
|
||||||
init:
|
|
||||||
enabled: false
|
|
||||||
schema: classpath:db-init/sql/min-schema.sql
|
|
||||||
# data 文件可选;为避免复杂 dump 解析问题,先不导入
|
|
||||||
# data:
|
|
||||||
marker-table: sys_user
|
|
||||||
marker-version: v1.0.0
|
|
||||||
# 登录图形验证码有效时间/分钟
|
|
||||||
expiration: 2
|
|
||||||
# 验证码高度
|
|
||||||
width: 111
|
|
||||||
# 验证码宽度
|
|
||||||
heigth: 36
|
|
||||||
# 内容长度
|
|
||||||
length: 2
|
|
||||||
# 字体名称,为空则使用默认字体
|
|
||||||
font-name:
|
|
||||||
# 字体大小
|
|
||||||
font-size: 25
|
|
||||||
|
|
||||||
# IP 本地解析
|
|
||||||
ip:
|
|
||||||
local-parsing: true
|
|
||||||
|
|
||||||
|
|
||||||
file-space: #项目文档空间
|
|
||||||
files: D:\demoproject\files\ #单独上传的文件附件
|
|
||||||
system: D:\demoproject\system\ #单独上传的文件
|
|
||||||
|
|
||||||
task:
|
|
||||||
pool:
|
|
||||||
# 核心线程池大小
|
|
||||||
core-pool-size: 10
|
|
||||||
# 最大线程数
|
|
||||||
max-pool-size: 30
|
|
||||||
# 活跃时间
|
|
||||||
keep-alive-seconds: 60
|
|
||||||
# 队列容量
|
|
||||||
queue-capacity: 50
|
|
||||||
@ -1,30 +0,0 @@
|
|||||||
jasypt:
|
|
||||||
encryptor:
|
|
||||||
password: ${JASYPT_PASSWORD:}
|
|
||||||
|
|
||||||
# 密码加密传输,前端公钥加密,后端私钥解密(共性配置)
|
|
||||||
rsa:
|
|
||||||
private_key: ${RSA_PRIVATE_KEY:}
|
|
||||||
|
|
||||||
# Actuator & Micrometer 默认配置(共性)
|
|
||||||
management:
|
|
||||||
endpoints:
|
|
||||||
web:
|
|
||||||
exposure:
|
|
||||||
include: health,info,metrics,prometheus,env,beans,threaddump,loggers,configprops
|
|
||||||
endpoint:
|
|
||||||
health:
|
|
||||||
show-details: always
|
|
||||||
metrics:
|
|
||||||
tags:
|
|
||||||
application: ${spring.application.name:platform}
|
|
||||||
|
|
||||||
|
|
||||||
# Springdoc 默认配置(共性)
|
|
||||||
springdoc:
|
|
||||||
api-docs:
|
|
||||||
enabled: true
|
|
||||||
swagger-ui:
|
|
||||||
enabled: true
|
|
||||||
path: /swagger-ui.html
|
|
||||||
packages-to-scan: com.yfd.platform
|
|
||||||
@ -1,52 +0,0 @@
|
|||||||
server:
|
|
||||||
port: 8090
|
|
||||||
|
|
||||||
spring:
|
|
||||||
#应用名称
|
|
||||||
application:
|
|
||||||
name: Project-plateform
|
|
||||||
datasource:
|
|
||||||
type: com.alibaba.druid.pool.DruidDataSource
|
|
||||||
druid:
|
|
||||||
master:
|
|
||||||
driverClassName: com.mysql.cj.jdbc.Driver
|
|
||||||
url: "${DB_MASTER_URL:jdbc:mysql://43.138.168.68:3306/frameworkdb2025?useUnicode=true&characterEncoding=UTF8&rewriteBatchedStatements=true}"
|
|
||||||
username: "${DB_MASTER_USERNAME:root}"
|
|
||||||
password: "${DB_MASTER_PASSWORD:}"
|
|
||||||
|
|
||||||
mvc:
|
|
||||||
pathmatch:
|
|
||||||
matching-strategy: ant_path_matcher
|
|
||||||
servlet:
|
|
||||||
multipart:
|
|
||||||
max-file-size: 30MB
|
|
||||||
max-request-size: 100MB
|
|
||||||
|
|
||||||
logging:
|
|
||||||
file:
|
|
||||||
name: logs/projectname.log
|
|
||||||
|
|
||||||
level:
|
|
||||||
com.genersoft.iot: debug
|
|
||||||
com.genersoft.iot.vmp.storager.dao: info
|
|
||||||
com.genersoft.iot.vmp.gb28181: info
|
|
||||||
|
|
||||||
# 在线文档: swagger-ui(生产环境建议关闭)
|
|
||||||
swagger-ui:
|
|
||||||
enabled: false
|
|
||||||
|
|
||||||
file-space: #项目文档空间
|
|
||||||
files: D:\demoproject\files\ #单独上传的文件附件
|
|
||||||
useravatar: D:\demoproject\useravatar\ #用户头像
|
|
||||||
system: D:\demoproject\system\ #系统文档根目录,用于头像等静态资源
|
|
||||||
|
|
||||||
# 启动自动数据库初始化(仅 dev/server):
|
|
||||||
app:
|
|
||||||
init:
|
|
||||||
enabled: true
|
|
||||||
schema: classpath:db-init/sql/min-schema.sql
|
|
||||||
# data 文件可选;为避免复杂 dump 解析问题,先不导入
|
|
||||||
# data:
|
|
||||||
marker-table: sys_user
|
|
||||||
marker-version: v1.0.0
|
|
||||||
|
|
||||||
@ -1,34 +0,0 @@
|
|||||||
spring:
|
|
||||||
profiles:
|
|
||||||
active: devtw
|
|
||||||
|
|
||||||
jasypt:
|
|
||||||
encryptor:
|
|
||||||
password: ${JASYPT_PASSWORD:}
|
|
||||||
|
|
||||||
#密码加密传输,前端公钥加密,后端私钥解密
|
|
||||||
rsa:
|
|
||||||
private_key: ${RSA_PRIVATE_KEY:MIIBUwIBADANBgkqhkiG9w0BAQEFAASCAT0wggE5AgEAAkEA0vfvyTdGJkdbHkB8mp0f3FE0GYP3AYPaJF7jUd1M0XxFSE2ceK3k2kw20YvQ09NJKk+OMjWQl9WitG9pB6tSCQIDAQABAkA2SimBrWC2/wvauBuYqjCFwLvYiRYqZKThUS3MZlebXJiLB+Ue/gUifAAKIg1avttUZsHBHrop4qfJCwAI0+YRAiEA+W3NK/RaXtnRqmoUUkb59zsZUBLpvZgQPfj1MhyHDz0CIQDYhsAhPJ3mgS64NbUZmGWuuNKp5coY2GIj/zYDMJp6vQIgUueLFXv/eZ1ekgz2Oi67MNCk5jeTF2BurZqNLR3MSmUCIFT3Q6uHMtsB9Eha4u7hS31tj1UWE+D+ADzp59MGnoftAiBeHT7gDMuqeJHPL4b+kC+gzV4FGTfhR9q3tTbklZkD2A==}
|
|
||||||
|
|
||||||
# Actuator & Micrometer 默认配置
|
|
||||||
management:
|
|
||||||
endpoints:
|
|
||||||
web:
|
|
||||||
exposure:
|
|
||||||
include: health,info,metrics,prometheus,env,beans,threaddump,loggers,configprops
|
|
||||||
endpoint:
|
|
||||||
health:
|
|
||||||
show-details: always
|
|
||||||
metrics:
|
|
||||||
tags:
|
|
||||||
application: ${spring.application.name:platform}
|
|
||||||
|
|
||||||
|
|
||||||
# Springdoc 默认配置
|
|
||||||
springdoc:
|
|
||||||
api-docs:
|
|
||||||
enabled: true
|
|
||||||
swagger-ui:
|
|
||||||
enabled: true
|
|
||||||
path: /swagger-ui.html
|
|
||||||
packages-to-scan: com.yfd.platform
|
|
||||||
@ -1,8 +0,0 @@
|
|||||||
__ ____ ____ .___________. _______ ______ __ __
|
|
||||||
| | \ \ / / | || ____| / || | | |
|
|
||||||
| | \ \/ / `---| |----`| |__ | ,----'| |__| |
|
|
||||||
.--. | | \_ _/ | | | __| | | | __ |
|
|
||||||
| `--' | | | | | | |____ | `----.| | | |
|
|
||||||
\______/ |__| |__| |_______| \______||__| |__|
|
|
||||||
|
|
||||||
|
|
||||||
@ -1,4 +0,0 @@
|
|||||||
# If you use SLF4J. First, you need to tell log4jdbc-log4j2 that you want to use the SLF4J logger
|
|
||||||
log4jdbc.spylogdelegator.name=net.sf.log4jdbc.log.slf4j.Slf4jSpyLogDelegator
|
|
||||||
log4jdbc.auto.load.popular.drivers=false
|
|
||||||
log4jdbc.drivers=com.mysql.cj.jdbc.Driver
|
|
||||||
@ -1,38 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<configuration scan="true" scanPeriod="60 seconds">
|
|
||||||
<!-- 通用变量 -->
|
|
||||||
<property name="LOG_PATH" value="logs"/>
|
|
||||||
<property name="LOG_FILE" value="platform"/>
|
|
||||||
<property name="LOG_PATTERN" value="%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n"/>
|
|
||||||
|
|
||||||
<!-- 控制台输出:强制 UTF-8 编码 -->
|
|
||||||
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
|
|
||||||
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
|
|
||||||
<charset>UTF-8</charset>
|
|
||||||
<pattern>${LOG_PATTERN}</pattern>
|
|
||||||
</encoder>
|
|
||||||
</appender>
|
|
||||||
|
|
||||||
<!-- 文件输出:滚动日志,UTF-8 编码 -->
|
|
||||||
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
|
||||||
<file>${LOG_PATH}/${LOG_FILE}.log</file>
|
|
||||||
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
|
|
||||||
<charset>UTF-8</charset>
|
|
||||||
<pattern>${LOG_PATTERN}</pattern>
|
|
||||||
</encoder>
|
|
||||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
|
||||||
<fileNamePattern>${LOG_PATH}/${LOG_FILE}.%d{yyyy-MM-dd}.log</fileNamePattern>
|
|
||||||
<maxHistory>30</maxHistory>
|
|
||||||
</rollingPolicy>
|
|
||||||
</appender>
|
|
||||||
|
|
||||||
<!-- Spring 与第三方库日志级别示例(可根据需要调整) -->
|
|
||||||
<logger name="org.springframework" level="INFO"/>
|
|
||||||
<logger name="com.alibaba.druid" level="INFO"/>
|
|
||||||
|
|
||||||
<!-- 根日志 -->
|
|
||||||
<root level="INFO">
|
|
||||||
<appender-ref ref="CONSOLE"/>
|
|
||||||
<appender-ref ref="FILE"/>
|
|
||||||
</root>
|
|
||||||
</configuration>
|
|
||||||
@ -1,45 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<configuration scan="true" scanPeriod="30 seconds" debug="false">
|
|
||||||
<contextName>yfAdmin</contextName>
|
|
||||||
<property name="log.charset" value="utf-8" />
|
|
||||||
<property name="log.pattern" value="%black(%contextName-) %red(%d{yyyy-MM-dd HH:mm:ss}) %green([%thread]) %highlight(%-5level) %boldMagenta(%logger{36}) - %gray(%msg%n)" />
|
|
||||||
|
|
||||||
<!--输出到控制台-->
|
|
||||||
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
|
|
||||||
<encoder>
|
|
||||||
<pattern>${log.pattern}</pattern>
|
|
||||||
<charset>${log.charset}</charset>
|
|
||||||
</encoder>
|
|
||||||
</appender>
|
|
||||||
|
|
||||||
<!--普通日志输出到控制台-->
|
|
||||||
<root level="info">
|
|
||||||
<appender-ref ref="console" />
|
|
||||||
</root>
|
|
||||||
|
|
||||||
<!--监控sql日志输出 -->
|
|
||||||
<logger name="jdbc.sqlonly" level="INFO" additivity="false">
|
|
||||||
<appender-ref ref="console" />
|
|
||||||
</logger>
|
|
||||||
|
|
||||||
<logger name="jdbc.resultset" level="ERROR" additivity="false">
|
|
||||||
<appender-ref ref="console" />
|
|
||||||
</logger>
|
|
||||||
|
|
||||||
<!-- 如想看到表格数据,将OFF改为INFO -->
|
|
||||||
<logger name="jdbc.resultsettable" level="OFF" additivity="false">
|
|
||||||
<appender-ref ref="console" />
|
|
||||||
</logger>
|
|
||||||
|
|
||||||
<logger name="jdbc.connection" level="OFF" additivity="false">
|
|
||||||
<appender-ref ref="console" />
|
|
||||||
</logger>
|
|
||||||
|
|
||||||
<logger name="jdbc.sqltiming" level="OFF" additivity="false">
|
|
||||||
<appender-ref ref="console" />
|
|
||||||
</logger>
|
|
||||||
|
|
||||||
<logger name="jdbc.audit" level="OFF" additivity="false">
|
|
||||||
<appender-ref ref="console" />
|
|
||||||
</logger>
|
|
||||||
</configuration>
|
|
||||||
@ -1,5 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
|
||||||
<mapper namespace="com.yfd.platform.env.mapper.IEnvMapper">
|
|
||||||
|
|
||||||
</mapper>
|
|
||||||
@ -1,29 +1,36 @@
|
|||||||
package com.yfd.platform.env;
|
package com.yfd.platform;
|
||||||
|
|
||||||
import com.yfd.platform.common.utils.SpringContextHolder;
|
import com.yfd.platform.annotation.rest.AnonymousGetMapping;
|
||||||
|
import com.yfd.platform.datasource.DynamicDataSourceConfig;
|
||||||
|
import com.yfd.platform.utils.SpringContextHolder;
|
||||||
import org.mybatis.spring.annotation.MapperScan;
|
import org.mybatis.spring.annotation.MapperScan;
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
import org.springframework.boot.data.redis.autoconfigure.DataRedisAutoConfiguration;
|
import org.springframework.boot.data.redis.autoconfigure.DataRedisAutoConfiguration;
|
||||||
import org.springframework.boot.jdbc.autoconfigure.DataSourceAutoConfiguration;
|
import org.springframework.boot.jdbc.autoconfigure.DataSourceAutoConfiguration;
|
||||||
import org.springframework.boot.web.server.servlet.context.ServletComponentScan;
|
import org.springframework.boot.web.server.servlet.context.ServletComponentScan;
|
||||||
|
import org.springframework.cache.annotation.EnableCaching;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.ComponentScan;
|
import org.springframework.context.annotation.ComponentScan;
|
||||||
import org.springframework.context.annotation.EnableAspectJAutoProxy;
|
import org.springframework.context.annotation.EnableAspectJAutoProxy;
|
||||||
|
import org.springframework.context.annotation.Import;
|
||||||
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
//@SpringBootApplication
|
||||||
@RestController
|
@RestController
|
||||||
@EnableTransactionManagement
|
@EnableTransactionManagement
|
||||||
@ServletComponentScan("com.yfd.platform.system.config")
|
@ServletComponentScan("com.yfd.platform.config")
|
||||||
@MapperScan(basePackages = "com.yfd.platform.*.mapper")
|
@MapperScan(basePackages = {"com.yfd.platform.*.mapper", "com.yfd.platform.common"})
|
||||||
@ComponentScan(basePackages = "com.yfd.platform")
|
//@ComponentScan("com.zny.dec")
|
||||||
@SpringBootApplication(exclude= {DataSourceAutoConfiguration.class, DataRedisAutoConfiguration.class})
|
@SpringBootApplication(exclude= {DataSourceAutoConfiguration.class, DataRedisAutoConfiguration.class})
|
||||||
public class EnvPlatformApplication {
|
//@SpringBootApplication
|
||||||
|
@Import({DynamicDataSourceConfig.class})
|
||||||
|
@EnableCaching
|
||||||
|
public class PlatformApplication {
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
SpringApplication.run(EnvPlatformApplication.class, args);
|
SpringApplication.run(PlatformApplication.class, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
@ -36,7 +43,7 @@ public class EnvPlatformApplication {
|
|||||||
*
|
*
|
||||||
* @return /
|
* @return /
|
||||||
*/
|
*/
|
||||||
@GetMapping("/")
|
@AnonymousGetMapping("/")
|
||||||
public String index() {
|
public String index() {
|
||||||
return "Backend service started successfully";
|
return "Backend service started successfully";
|
||||||
}
|
}
|
||||||
@ -1,4 +1,4 @@
|
|||||||
package com.yfd.platform.env;
|
package com.yfd.platform;
|
||||||
|
|
||||||
import org.springframework.boot.builder.SpringApplicationBuilder;
|
import org.springframework.boot.builder.SpringApplicationBuilder;
|
||||||
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
|
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
|
||||||
@ -7,7 +7,7 @@ public class ServletInitializer extends SpringBootServletInitializer {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
|
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
|
||||||
return application.sources(EnvPlatformApplication.class);
|
return application.sources(PlatformApplication.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -16,6 +16,7 @@
|
|||||||
package com.yfd.platform.aspect;
|
package com.yfd.platform.aspect;
|
||||||
|
|
||||||
import com.yfd.platform.system.domain.SysLog;
|
import com.yfd.platform.system.domain.SysLog;
|
||||||
|
import com.yfd.platform.system.mapper.SysUserMapper;
|
||||||
import com.yfd.platform.system.service.ISysLogService;
|
import com.yfd.platform.system.service.ISysLogService;
|
||||||
import com.yfd.platform.system.service.IUserService;
|
import com.yfd.platform.system.service.IUserService;
|
||||||
import com.yfd.platform.utils.RequestHolder;
|
import com.yfd.platform.utils.RequestHolder;
|
||||||
@ -0,0 +1,554 @@
|
|||||||
|
//
|
||||||
|
// Source code recreated from a .class file by IntelliJ IDEA
|
||||||
|
// (powered by FernFlower decompiler)
|
||||||
|
//
|
||||||
|
|
||||||
|
package com.yfd.platform.common;
|
||||||
|
|
||||||
|
import cn.hutool.json.JSONArray;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class DataSourceLoadOptionsBase {
|
||||||
|
@Schema(description = "string 是否是默认小写")
|
||||||
|
private Boolean stringToLowerDefault = false;
|
||||||
|
|
||||||
|
@Schema(description = "是否需要返回总数")
|
||||||
|
private Boolean requireTotalCount = false;
|
||||||
|
|
||||||
|
@Schema(description = "当前查询是否是分组数查询")
|
||||||
|
public Boolean requireGroupCount = false;
|
||||||
|
|
||||||
|
@Schema(description = "分组结果是否平铺")
|
||||||
|
public Boolean groupResultFlat = false;
|
||||||
|
|
||||||
|
@Schema(description = "当前查询是否是总数查询")
|
||||||
|
public Boolean isCountQuery = false;
|
||||||
|
|
||||||
|
@Schema(description = "从结果集开始跳过的数目")
|
||||||
|
private Integer skip = 0;
|
||||||
|
|
||||||
|
@Schema(description = "需要加载的对象个数")
|
||||||
|
private Integer take = 0;
|
||||||
|
|
||||||
|
@Schema(description = "排序表达式")
|
||||||
|
public SortingInfo[] sort;
|
||||||
|
|
||||||
|
@Schema(description = "分组表达式")
|
||||||
|
public GroupingInfo[] group;
|
||||||
|
|
||||||
|
@Schema(description = "过滤表达式")
|
||||||
|
public JSONArray filter;
|
||||||
|
|
||||||
|
@Schema(description = "总数表达式")
|
||||||
|
public SummaryInfo[] totalSummary;
|
||||||
|
|
||||||
|
@Schema(description = "分组总数表达式")
|
||||||
|
public SummaryInfo[] groupSummary;
|
||||||
|
|
||||||
|
@Schema(description = "选择表达式,需要去重查询的字段")
|
||||||
|
public String[] distinctSelect;
|
||||||
|
|
||||||
|
@Schema(description = "选择表达式,需要查询的字段")
|
||||||
|
public String[] select;
|
||||||
|
|
||||||
|
@Schema(description = "限制选择表达式")
|
||||||
|
public String[] preSelect;
|
||||||
|
|
||||||
|
@Schema(description = "")
|
||||||
|
public Boolean remoteSelect = false;
|
||||||
|
|
||||||
|
@Schema(description = "")
|
||||||
|
public Boolean remoteGrouping;
|
||||||
|
|
||||||
|
@Schema(description = "")
|
||||||
|
public Boolean expandLinqSumType;
|
||||||
|
|
||||||
|
@Schema(description = "主键数组")
|
||||||
|
public String[] primaryKey;
|
||||||
|
|
||||||
|
@Schema(description = "默认排序")
|
||||||
|
public String defaultSort;
|
||||||
|
|
||||||
|
@Schema(description = "是否 filter 表达式应该被转化为小写")
|
||||||
|
public Boolean stringToLower = false;
|
||||||
|
|
||||||
|
@Schema(description = "")
|
||||||
|
public Boolean paginateViaPrimaryKey = false;
|
||||||
|
|
||||||
|
@Schema(description = "根据主键 key 排序")
|
||||||
|
public Boolean sortByPrimaryKey = false;
|
||||||
|
|
||||||
|
@Schema(description = "")
|
||||||
|
public Boolean allowAsyncOverSync = false;
|
||||||
|
|
||||||
|
@Schema(hidden = true)
|
||||||
|
private Map<String, Object> extMap = new HashMap();
|
||||||
|
|
||||||
|
public DataSourceLoadOptionsBase() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public Boolean getStringToLowerDefault() {
|
||||||
|
return this.stringToLowerDefault;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Boolean getRequireTotalCount() {
|
||||||
|
return this.requireTotalCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Boolean getRequireGroupCount() {
|
||||||
|
return this.requireGroupCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Boolean getGroupResultFlat() {
|
||||||
|
return this.groupResultFlat;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Boolean getIsCountQuery() {
|
||||||
|
return this.isCountQuery;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getSkip() {
|
||||||
|
return this.skip;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getTake() {
|
||||||
|
return this.take;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SortingInfo[] getSort() {
|
||||||
|
return this.sort;
|
||||||
|
}
|
||||||
|
|
||||||
|
public GroupingInfo[] getGroup() {
|
||||||
|
return this.group;
|
||||||
|
}
|
||||||
|
|
||||||
|
public JSONArray getFilter() {
|
||||||
|
return this.filter;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SummaryInfo[] getTotalSummary() {
|
||||||
|
return this.totalSummary;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SummaryInfo[] getGroupSummary() {
|
||||||
|
return this.groupSummary;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String[] getDistinctSelect() {
|
||||||
|
return this.distinctSelect;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String[] getSelect() {
|
||||||
|
return this.select;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String[] getPreSelect() {
|
||||||
|
return this.preSelect;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Boolean getRemoteSelect() {
|
||||||
|
return this.remoteSelect;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Boolean getRemoteGrouping() {
|
||||||
|
return this.remoteGrouping;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Boolean getExpandLinqSumType() {
|
||||||
|
return this.expandLinqSumType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String[] getPrimaryKey() {
|
||||||
|
return this.primaryKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDefaultSort() {
|
||||||
|
return this.defaultSort;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Boolean getStringToLower() {
|
||||||
|
return this.stringToLower;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Boolean getPaginateViaPrimaryKey() {
|
||||||
|
return this.paginateViaPrimaryKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Boolean getSortByPrimaryKey() {
|
||||||
|
return this.sortByPrimaryKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Boolean getAllowAsyncOverSync() {
|
||||||
|
return this.allowAsyncOverSync;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<String, Object> getExtMap() {
|
||||||
|
return this.extMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStringToLowerDefault(final Boolean stringToLowerDefault) {
|
||||||
|
this.stringToLowerDefault = stringToLowerDefault;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRequireTotalCount(final Boolean requireTotalCount) {
|
||||||
|
this.requireTotalCount = requireTotalCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRequireGroupCount(final Boolean requireGroupCount) {
|
||||||
|
this.requireGroupCount = requireGroupCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setGroupResultFlat(final Boolean groupResultFlat) {
|
||||||
|
this.groupResultFlat = groupResultFlat;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIsCountQuery(final Boolean isCountQuery) {
|
||||||
|
this.isCountQuery = isCountQuery;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSkip(final Integer skip) {
|
||||||
|
this.skip = skip;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTake(final Integer take) {
|
||||||
|
this.take = take;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSort(final SortingInfo[] sort) {
|
||||||
|
this.sort = sort;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setGroup(final GroupingInfo[] group) {
|
||||||
|
this.group = group;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFilter(final JSONArray filter) {
|
||||||
|
this.filter = filter;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTotalSummary(final SummaryInfo[] totalSummary) {
|
||||||
|
this.totalSummary = totalSummary;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setGroupSummary(final SummaryInfo[] groupSummary) {
|
||||||
|
this.groupSummary = groupSummary;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDistinctSelect(final String[] distinctSelect) {
|
||||||
|
this.distinctSelect = distinctSelect;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSelect(final String[] select) {
|
||||||
|
this.select = select;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPreSelect(final String[] preSelect) {
|
||||||
|
this.preSelect = preSelect;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRemoteSelect(final Boolean remoteSelect) {
|
||||||
|
this.remoteSelect = remoteSelect;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRemoteGrouping(final Boolean remoteGrouping) {
|
||||||
|
this.remoteGrouping = remoteGrouping;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setExpandLinqSumType(final Boolean expandLinqSumType) {
|
||||||
|
this.expandLinqSumType = expandLinqSumType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPrimaryKey(final String[] primaryKey) {
|
||||||
|
this.primaryKey = primaryKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDefaultSort(final String defaultSort) {
|
||||||
|
this.defaultSort = defaultSort;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStringToLower(final Boolean stringToLower) {
|
||||||
|
this.stringToLower = stringToLower;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPaginateViaPrimaryKey(final Boolean paginateViaPrimaryKey) {
|
||||||
|
this.paginateViaPrimaryKey = paginateViaPrimaryKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSortByPrimaryKey(final Boolean sortByPrimaryKey) {
|
||||||
|
this.sortByPrimaryKey = sortByPrimaryKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAllowAsyncOverSync(final Boolean allowAsyncOverSync) {
|
||||||
|
this.allowAsyncOverSync = allowAsyncOverSync;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setExtMap(final Map<String, Object> extMap) {
|
||||||
|
this.extMap = extMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean equals(final Object o) {
|
||||||
|
if (o == this) {
|
||||||
|
return true;
|
||||||
|
} else if (!(o instanceof DataSourceLoadOptionsBase)) {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
DataSourceLoadOptionsBase other = (DataSourceLoadOptionsBase)o;
|
||||||
|
if (!other.canEqual(this)) {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
Object this$stringToLowerDefault = this.getStringToLowerDefault();
|
||||||
|
Object other$stringToLowerDefault = other.getStringToLowerDefault();
|
||||||
|
if (this$stringToLowerDefault == null) {
|
||||||
|
if (other$stringToLowerDefault != null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else if (!this$stringToLowerDefault.equals(other$stringToLowerDefault)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Object this$requireTotalCount = this.getRequireTotalCount();
|
||||||
|
Object other$requireTotalCount = other.getRequireTotalCount();
|
||||||
|
if (this$requireTotalCount == null) {
|
||||||
|
if (other$requireTotalCount != null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else if (!this$requireTotalCount.equals(other$requireTotalCount)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Object this$requireGroupCount = this.getRequireGroupCount();
|
||||||
|
Object other$requireGroupCount = other.getRequireGroupCount();
|
||||||
|
if (this$requireGroupCount == null) {
|
||||||
|
if (other$requireGroupCount != null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else if (!this$requireGroupCount.equals(other$requireGroupCount)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Object this$groupResultFlat = this.getGroupResultFlat();
|
||||||
|
Object other$groupResultFlat = other.getGroupResultFlat();
|
||||||
|
if (this$groupResultFlat == null) {
|
||||||
|
if (other$groupResultFlat != null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else if (!this$groupResultFlat.equals(other$groupResultFlat)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Object this$isCountQuery = this.getIsCountQuery();
|
||||||
|
Object other$isCountQuery = other.getIsCountQuery();
|
||||||
|
if (this$isCountQuery == null) {
|
||||||
|
if (other$isCountQuery != null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else if (!this$isCountQuery.equals(other$isCountQuery)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Object this$skip = this.getSkip();
|
||||||
|
Object other$skip = other.getSkip();
|
||||||
|
if (this$skip == null) {
|
||||||
|
if (other$skip != null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else if (!this$skip.equals(other$skip)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Object this$take = this.getTake();
|
||||||
|
Object other$take = other.getTake();
|
||||||
|
if (this$take == null) {
|
||||||
|
if (other$take != null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else if (!this$take.equals(other$take)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Object this$remoteSelect = this.getRemoteSelect();
|
||||||
|
Object other$remoteSelect = other.getRemoteSelect();
|
||||||
|
if (this$remoteSelect == null) {
|
||||||
|
if (other$remoteSelect != null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else if (!this$remoteSelect.equals(other$remoteSelect)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Object this$remoteGrouping = this.getRemoteGrouping();
|
||||||
|
Object other$remoteGrouping = other.getRemoteGrouping();
|
||||||
|
if (this$remoteGrouping == null) {
|
||||||
|
if (other$remoteGrouping != null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else if (!this$remoteGrouping.equals(other$remoteGrouping)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Object this$expandLinqSumType = this.getExpandLinqSumType();
|
||||||
|
Object other$expandLinqSumType = other.getExpandLinqSumType();
|
||||||
|
if (this$expandLinqSumType == null) {
|
||||||
|
if (other$expandLinqSumType != null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else if (!this$expandLinqSumType.equals(other$expandLinqSumType)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Object this$stringToLower = this.getStringToLower();
|
||||||
|
Object other$stringToLower = other.getStringToLower();
|
||||||
|
if (this$stringToLower == null) {
|
||||||
|
if (other$stringToLower != null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else if (!this$stringToLower.equals(other$stringToLower)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Object this$paginateViaPrimaryKey = this.getPaginateViaPrimaryKey();
|
||||||
|
Object other$paginateViaPrimaryKey = other.getPaginateViaPrimaryKey();
|
||||||
|
if (this$paginateViaPrimaryKey == null) {
|
||||||
|
if (other$paginateViaPrimaryKey != null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else if (!this$paginateViaPrimaryKey.equals(other$paginateViaPrimaryKey)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Object this$sortByPrimaryKey = this.getSortByPrimaryKey();
|
||||||
|
Object other$sortByPrimaryKey = other.getSortByPrimaryKey();
|
||||||
|
if (this$sortByPrimaryKey == null) {
|
||||||
|
if (other$sortByPrimaryKey != null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else if (!this$sortByPrimaryKey.equals(other$sortByPrimaryKey)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Object this$allowAsyncOverSync = this.getAllowAsyncOverSync();
|
||||||
|
Object other$allowAsyncOverSync = other.getAllowAsyncOverSync();
|
||||||
|
if (this$allowAsyncOverSync == null) {
|
||||||
|
if (other$allowAsyncOverSync != null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else if (!this$allowAsyncOverSync.equals(other$allowAsyncOverSync)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!Arrays.deepEquals(this.getSort(), other.getSort())) {
|
||||||
|
return false;
|
||||||
|
} else if (!Arrays.deepEquals(this.getGroup(), other.getGroup())) {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
Object this$filter = this.getFilter();
|
||||||
|
Object other$filter = other.getFilter();
|
||||||
|
if (this$filter == null) {
|
||||||
|
if (other$filter != null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else if (!this$filter.equals(other$filter)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!Arrays.deepEquals(this.getTotalSummary(), other.getTotalSummary())) {
|
||||||
|
return false;
|
||||||
|
} else if (!Arrays.deepEquals(this.getGroupSummary(), other.getGroupSummary())) {
|
||||||
|
return false;
|
||||||
|
} else if (!Arrays.deepEquals(this.getDistinctSelect(), other.getDistinctSelect())) {
|
||||||
|
return false;
|
||||||
|
} else if (!Arrays.deepEquals(this.getSelect(), other.getSelect())) {
|
||||||
|
return false;
|
||||||
|
} else if (!Arrays.deepEquals(this.getPreSelect(), other.getPreSelect())) {
|
||||||
|
return false;
|
||||||
|
} else if (!Arrays.deepEquals(this.getPrimaryKey(), other.getPrimaryKey())) {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
Object this$defaultSort = this.getDefaultSort();
|
||||||
|
Object other$defaultSort = other.getDefaultSort();
|
||||||
|
if (this$defaultSort == null) {
|
||||||
|
if (other$defaultSort != null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else if (!this$defaultSort.equals(other$defaultSort)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Object this$extMap = this.getExtMap();
|
||||||
|
Object other$extMap = other.getExtMap();
|
||||||
|
if (this$extMap == null) {
|
||||||
|
if (other$extMap != null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else if (!this$extMap.equals(other$extMap)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected boolean canEqual(final Object other) {
|
||||||
|
return other instanceof DataSourceLoadOptionsBase;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int hashCode() {
|
||||||
|
int PRIME = 59;
|
||||||
|
int result = 1;
|
||||||
|
Object $stringToLowerDefault = this.getStringToLowerDefault();
|
||||||
|
result = result * 59 + ($stringToLowerDefault == null ? 43 : $stringToLowerDefault.hashCode());
|
||||||
|
Object $requireTotalCount = this.getRequireTotalCount();
|
||||||
|
result = result * 59 + ($requireTotalCount == null ? 43 : $requireTotalCount.hashCode());
|
||||||
|
Object $requireGroupCount = this.getRequireGroupCount();
|
||||||
|
result = result * 59 + ($requireGroupCount == null ? 43 : $requireGroupCount.hashCode());
|
||||||
|
Object $groupResultFlat = this.getGroupResultFlat();
|
||||||
|
result = result * 59 + ($groupResultFlat == null ? 43 : $groupResultFlat.hashCode());
|
||||||
|
Object $isCountQuery = this.getIsCountQuery();
|
||||||
|
result = result * 59 + ($isCountQuery == null ? 43 : $isCountQuery.hashCode());
|
||||||
|
Object $skip = this.getSkip();
|
||||||
|
result = result * 59 + ($skip == null ? 43 : $skip.hashCode());
|
||||||
|
Object $take = this.getTake();
|
||||||
|
result = result * 59 + ($take == null ? 43 : $take.hashCode());
|
||||||
|
Object $remoteSelect = this.getRemoteSelect();
|
||||||
|
result = result * 59 + ($remoteSelect == null ? 43 : $remoteSelect.hashCode());
|
||||||
|
Object $remoteGrouping = this.getRemoteGrouping();
|
||||||
|
result = result * 59 + ($remoteGrouping == null ? 43 : $remoteGrouping.hashCode());
|
||||||
|
Object $expandLinqSumType = this.getExpandLinqSumType();
|
||||||
|
result = result * 59 + ($expandLinqSumType == null ? 43 : $expandLinqSumType.hashCode());
|
||||||
|
Object $stringToLower = this.getStringToLower();
|
||||||
|
result = result * 59 + ($stringToLower == null ? 43 : $stringToLower.hashCode());
|
||||||
|
Object $paginateViaPrimaryKey = this.getPaginateViaPrimaryKey();
|
||||||
|
result = result * 59 + ($paginateViaPrimaryKey == null ? 43 : $paginateViaPrimaryKey.hashCode());
|
||||||
|
Object $sortByPrimaryKey = this.getSortByPrimaryKey();
|
||||||
|
result = result * 59 + ($sortByPrimaryKey == null ? 43 : $sortByPrimaryKey.hashCode());
|
||||||
|
Object $allowAsyncOverSync = this.getAllowAsyncOverSync();
|
||||||
|
result = result * 59 + ($allowAsyncOverSync == null ? 43 : $allowAsyncOverSync.hashCode());
|
||||||
|
result = result * 59 + Arrays.deepHashCode(this.getSort());
|
||||||
|
result = result * 59 + Arrays.deepHashCode(this.getGroup());
|
||||||
|
Object $filter = this.getFilter();
|
||||||
|
result = result * 59 + ($filter == null ? 43 : $filter.hashCode());
|
||||||
|
result = result * 59 + Arrays.deepHashCode(this.getTotalSummary());
|
||||||
|
result = result * 59 + Arrays.deepHashCode(this.getGroupSummary());
|
||||||
|
result = result * 59 + Arrays.deepHashCode(this.getDistinctSelect());
|
||||||
|
result = result * 59 + Arrays.deepHashCode(this.getSelect());
|
||||||
|
result = result * 59 + Arrays.deepHashCode(this.getPreSelect());
|
||||||
|
result = result * 59 + Arrays.deepHashCode(this.getPrimaryKey());
|
||||||
|
Object $defaultSort = this.getDefaultSort();
|
||||||
|
result = result * 59 + ($defaultSort == null ? 43 : $defaultSort.hashCode());
|
||||||
|
Object $extMap = this.getExtMap();
|
||||||
|
result = result * 59 + ($extMap == null ? 43 : $extMap.hashCode());
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString() {
|
||||||
|
return "DataSourceLoadOptionsBase(stringToLowerDefault=" + this.getStringToLowerDefault() + ", requireTotalCount=" + this.getRequireTotalCount() + ", requireGroupCount=" + this.getRequireGroupCount() + ", groupResultFlat=" + this.getGroupResultFlat() + ", isCountQuery=" + this.getIsCountQuery() + ", skip=" + this.getSkip() + ", take=" + this.getTake() + ", sort=" + Arrays.deepToString(this.getSort()) + ", group=" + Arrays.deepToString(this.getGroup()) + ", filter=" + this.getFilter() + ", totalSummary=" + Arrays.deepToString(this.getTotalSummary()) + ", groupSummary=" + Arrays.deepToString(this.getGroupSummary()) + ", distinctSelect=" + Arrays.deepToString(this.getDistinctSelect()) + ", select=" + Arrays.deepToString(this.getSelect()) + ", preSelect=" + Arrays.deepToString(this.getPreSelect()) + ", remoteSelect=" + this.getRemoteSelect() + ", remoteGrouping=" + this.getRemoteGrouping() + ", expandLinqSumType=" + this.getExpandLinqSumType() + ", primaryKey=" + Arrays.deepToString(this.getPrimaryKey()) + ", defaultSort=" + this.getDefaultSort() + ", stringToLower=" + this.getStringToLower() + ", paginateViaPrimaryKey=" + this.getPaginateViaPrimaryKey() + ", sortByPrimaryKey=" + this.getSortByPrimaryKey() + ", allowAsyncOverSync=" + this.getAllowAsyncOverSync() + ", extMap=" + this.getExtMap() + ")";
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,691 @@
|
|||||||
|
|
||||||
|
package com.yfd.platform.common;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollectionUtil;
|
||||||
|
import cn.hutool.json.JSONArray;
|
||||||
|
import cn.hutool.json.JSONUtil;
|
||||||
|
import org.jsoup.helper.StringUtil;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class DataSourceRequest {
|
||||||
|
private int page;
|
||||||
|
private int pageSize;
|
||||||
|
private int take;
|
||||||
|
private int skip;
|
||||||
|
private List<String> distinctSelect;
|
||||||
|
private List<String> select;
|
||||||
|
private List<SortDescriptor> sort;
|
||||||
|
private List<GroupDescriptor> group;
|
||||||
|
private List<AggregateDescriptor> aggregate;
|
||||||
|
private HashMap<String, Object> data = new HashMap();
|
||||||
|
private Boolean groupResultFlat = false;
|
||||||
|
private FilterDescriptor filter = new FilterDescriptor();
|
||||||
|
|
||||||
|
public DataSourceRequest() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> getDistinctSelect() {
|
||||||
|
return this.distinctSelect;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDistinctSelect(List<String> distinctSelect) {
|
||||||
|
this.distinctSelect = distinctSelect;
|
||||||
|
}
|
||||||
|
|
||||||
|
public HashMap<String, Object> getData() {
|
||||||
|
return this.data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void handleUnknown(String key, Object value) {
|
||||||
|
this.data.put(key, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getPage() {
|
||||||
|
return this.page;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPage(int page) {
|
||||||
|
this.page = page;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getPageSize() {
|
||||||
|
return this.pageSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPageSize(int pageSize) {
|
||||||
|
this.pageSize = pageSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getTake() {
|
||||||
|
return this.take;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTake(int take) {
|
||||||
|
this.take = take;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getSkip() {
|
||||||
|
return this.skip;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSkip(int skip) {
|
||||||
|
this.skip = skip;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<SortDescriptor> getSort() {
|
||||||
|
return this.sort;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSort(List<SortDescriptor> sort) {
|
||||||
|
this.sort = sort;
|
||||||
|
}
|
||||||
|
|
||||||
|
public FilterDescriptor getFilter() {
|
||||||
|
return this.filter;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFilter(FilterDescriptor filter) {
|
||||||
|
this.filter = filter;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> getSelect() {
|
||||||
|
return this.select;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSelect(List<String> select) {
|
||||||
|
this.select = select;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Boolean getGroupResultFlat() {
|
||||||
|
return this.groupResultFlat;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setGroupResultFlat(Boolean groupResultFlat) {
|
||||||
|
this.groupResultFlat = groupResultFlat;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static JSONArray toDevextremeFilter(FilterDescriptor filter) {
|
||||||
|
JSONArray jsonArray = new JSONArray();
|
||||||
|
filter(jsonArray, filter);
|
||||||
|
return jsonArray;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void restrict(JSONArray jsonArray, FilterDescriptor filter) {
|
||||||
|
String operator = filter.getOperator();
|
||||||
|
String field = filter.getField();
|
||||||
|
String dataType = filter.getDataType();
|
||||||
|
jsonArray.put(field);
|
||||||
|
Object value = filter.getValue();
|
||||||
|
boolean ignoreCase = filter.isIgnoreCase();
|
||||||
|
String devCondition = null;
|
||||||
|
String[] var10000 = new String[]{"isnull", "isnotnull", "isempty", "isnotempty"};
|
||||||
|
switch (operator) {
|
||||||
|
case "eq":
|
||||||
|
devCondition = "=";
|
||||||
|
jsonArray.put(devCondition);
|
||||||
|
jsonArray.put(value);
|
||||||
|
break;
|
||||||
|
case "neq":
|
||||||
|
devCondition = "<>";
|
||||||
|
jsonArray.put(devCondition);
|
||||||
|
jsonArray.put(value);
|
||||||
|
break;
|
||||||
|
case "gt":
|
||||||
|
devCondition = ">";
|
||||||
|
jsonArray.put(devCondition);
|
||||||
|
jsonArray.put(value);
|
||||||
|
break;
|
||||||
|
case "gte":
|
||||||
|
devCondition = ">=";
|
||||||
|
jsonArray.put(devCondition);
|
||||||
|
jsonArray.put(value);
|
||||||
|
break;
|
||||||
|
case "lt":
|
||||||
|
devCondition = "<";
|
||||||
|
jsonArray.put(devCondition);
|
||||||
|
jsonArray.put(value);
|
||||||
|
break;
|
||||||
|
case "lte":
|
||||||
|
devCondition = "<=";
|
||||||
|
jsonArray.put(devCondition);
|
||||||
|
jsonArray.put(value);
|
||||||
|
break;
|
||||||
|
case "startswith":
|
||||||
|
devCondition = "startswith";
|
||||||
|
jsonArray.put(devCondition);
|
||||||
|
jsonArray.put(value);
|
||||||
|
break;
|
||||||
|
case "endswith":
|
||||||
|
devCondition = "endswith";
|
||||||
|
jsonArray.put(devCondition);
|
||||||
|
jsonArray.put(value);
|
||||||
|
break;
|
||||||
|
case "contains":
|
||||||
|
devCondition = "contains";
|
||||||
|
jsonArray.put(devCondition);
|
||||||
|
jsonArray.put(value);
|
||||||
|
break;
|
||||||
|
case "doesnotcontain":
|
||||||
|
devCondition = "notcontains";
|
||||||
|
jsonArray.put(devCondition);
|
||||||
|
jsonArray.put(value);
|
||||||
|
break;
|
||||||
|
case "isnull":
|
||||||
|
devCondition = "isnull";
|
||||||
|
jsonArray.put(devCondition);
|
||||||
|
jsonArray.put((Object)null);
|
||||||
|
break;
|
||||||
|
case "isnotnull":
|
||||||
|
devCondition = "isnotnull";
|
||||||
|
jsonArray.put(devCondition);
|
||||||
|
jsonArray.put((Object)null);
|
||||||
|
break;
|
||||||
|
case "isempty":
|
||||||
|
devCondition = "=";
|
||||||
|
jsonArray.put(devCondition);
|
||||||
|
jsonArray.put("");
|
||||||
|
break;
|
||||||
|
case "isnotempty":
|
||||||
|
devCondition = "!=";
|
||||||
|
jsonArray.put(devCondition);
|
||||||
|
jsonArray.put("");
|
||||||
|
break;
|
||||||
|
case "in":
|
||||||
|
devCondition = "in";
|
||||||
|
jsonArray.put(devCondition);
|
||||||
|
jsonArray.put(value);
|
||||||
|
break;
|
||||||
|
case "ni":
|
||||||
|
devCondition = "ni";
|
||||||
|
jsonArray.put(devCondition);
|
||||||
|
jsonArray.put(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
jsonArray.put(dataType);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void filter(JSONArray jsonArray, FilterDescriptor filter) {
|
||||||
|
if (filter != null) {
|
||||||
|
List<FilterDescriptor> filters = filter.filters;
|
||||||
|
int size = filters.size();
|
||||||
|
String logic = null;
|
||||||
|
if (!filters.isEmpty()) {
|
||||||
|
if (!filter.getFilters().isEmpty() && filter.getFilters().size() > 1 && filter.getLogic().toString().equals("or")) {
|
||||||
|
logic = "or";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!filter.getFilters().isEmpty() && filter.getFilters().size() > 1 && filter.getLogic().toString().equals("and")) {
|
||||||
|
logic = "and";
|
||||||
|
}
|
||||||
|
|
||||||
|
int index = 0;
|
||||||
|
|
||||||
|
for(FilterDescriptor entry : filters) {
|
||||||
|
if (!entry.getFilters().isEmpty()) {
|
||||||
|
JSONArray filterJsonArray = new JSONArray();
|
||||||
|
filter(filterJsonArray, entry);
|
||||||
|
jsonArray.put(filterJsonArray);
|
||||||
|
if (index != size - 1) {
|
||||||
|
jsonArray.put(logic);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
JSONArray restrictJsonArray = new JSONArray();
|
||||||
|
restrict(restrictJsonArray, entry);
|
||||||
|
jsonArray.put(restrictJsonArray);
|
||||||
|
if (index != size - 1) {
|
||||||
|
jsonArray.put(logic);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
++index;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void sort(DataSourceLoadOptionsBase dataSourceLoadOptionsBase, List<SortDescriptor> sort) {
|
||||||
|
if (sort != null && !sort.isEmpty()) {
|
||||||
|
SortingInfo[] decSort = new SortingInfo[sort.size()];
|
||||||
|
int i = 0;
|
||||||
|
|
||||||
|
for(SortDescriptor entry : sort) {
|
||||||
|
String field = entry.getField();
|
||||||
|
String dir = entry.getDir();
|
||||||
|
SortingInfo sortingInfo = new SortingInfo();
|
||||||
|
sortingInfo.setSelector(field);
|
||||||
|
if (StringUtil.isBlank(dir)) {
|
||||||
|
sortingInfo.setDesc(false);
|
||||||
|
} else if (dir.equals("asc")) {
|
||||||
|
sortingInfo.setDesc(false);
|
||||||
|
} else if (dir.equals("desc")) {
|
||||||
|
sortingInfo.setDesc(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
decSort[i] = sortingInfo;
|
||||||
|
++i;
|
||||||
|
}
|
||||||
|
|
||||||
|
dataSourceLoadOptionsBase.setSort(decSort);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void calculateAggregates(DataSourceLoadOptionsBase dataSourceLoadOptionsBase, List<AggregateDescriptor> aggregates) {
|
||||||
|
if (aggregates != null && !aggregates.isEmpty()) {
|
||||||
|
SummaryInfo[] totalSummary = new SummaryInfo[aggregates.size()];
|
||||||
|
int i = 0;
|
||||||
|
|
||||||
|
for(AggregateDescriptor aggregateDescriptor : aggregates) {
|
||||||
|
SummaryInfo summaryInfo = new SummaryInfo();
|
||||||
|
summaryInfo.setSelector(aggregateDescriptor.getField());
|
||||||
|
summaryInfo.setSummaryType(aggregateDescriptor.getAggregate());
|
||||||
|
totalSummary[i] = summaryInfo;
|
||||||
|
++i;
|
||||||
|
}
|
||||||
|
|
||||||
|
dataSourceLoadOptionsBase.setTotalSummary(totalSummary);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void group(DataSourceLoadOptionsBase dataSourceLoadOptionsBase) {
|
||||||
|
new ArrayList();
|
||||||
|
List<GroupDescriptor> group = this.getGroup();
|
||||||
|
if (group != null && !group.isEmpty()) {
|
||||||
|
GroupingInfo[] devGroup = new GroupingInfo[group.size()];
|
||||||
|
int i = 0;
|
||||||
|
|
||||||
|
for(GroupDescriptor groupDescriptor : group) {
|
||||||
|
GroupingInfo groupingInfo = new GroupingInfo();
|
||||||
|
groupingInfo.setSelector(groupDescriptor.getField());
|
||||||
|
String dir = groupDescriptor.getDir();
|
||||||
|
if (StringUtil.isBlank(dir)) {
|
||||||
|
groupingInfo.setDesc(false);
|
||||||
|
} else if (dir.equals("asc")) {
|
||||||
|
groupingInfo.setDesc(false);
|
||||||
|
} else if (dir.equals("desc")) {
|
||||||
|
groupingInfo.setDesc(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
groupingInfo.setNeedSortFlag(groupDescriptor.getNeedSortFlag());
|
||||||
|
List<AggregateDescriptor> aggregateDescriptors = groupDescriptor.getAggregates();
|
||||||
|
if (CollectionUtil.isNotEmpty(aggregateDescriptors)) {
|
||||||
|
for(AggregateDescriptor aggregateDescriptor : aggregateDescriptors) {
|
||||||
|
SummaryInfo summaryInfo = new SummaryInfo();
|
||||||
|
summaryInfo.setSelector(aggregateDescriptor.getField());
|
||||||
|
summaryInfo.setSummaryType(aggregateDescriptor.getAggregate());
|
||||||
|
groupingInfo.getSummaryInfos().add(summaryInfo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
devGroup[i] = groupingInfo;
|
||||||
|
++i;
|
||||||
|
}
|
||||||
|
|
||||||
|
dataSourceLoadOptionsBase.setGroup(devGroup);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void page(DataSourceLoadOptionsBase dataSourceLoadOptionsBase, int take, int skip) {
|
||||||
|
dataSourceLoadOptionsBase.setTake(take);
|
||||||
|
dataSourceLoadOptionsBase.setSkip(skip);
|
||||||
|
}
|
||||||
|
|
||||||
|
public DataSourceLoadOptionsBase toDevRequest() {
|
||||||
|
DataSourceLoadOptionsBase dataSourceLoadOptionsBase = new DataSourceLoadOptionsBase();
|
||||||
|
JSONArray filter = toDevextremeFilter(this.getFilter());
|
||||||
|
dataSourceLoadOptionsBase.setFilter(filter);
|
||||||
|
dataSourceLoadOptionsBase.setGroupResultFlat(this.getGroupResultFlat());
|
||||||
|
dataSourceLoadOptionsBase.setRequireTotalCount(true);
|
||||||
|
if (CollectionUtil.isNotEmpty(this.getSelect())) {
|
||||||
|
String[] res = new String[this.getSelect().size()];
|
||||||
|
dataSourceLoadOptionsBase.setSelect((String[])this.getSelect().toArray(res));
|
||||||
|
}
|
||||||
|
|
||||||
|
sort(dataSourceLoadOptionsBase, this.sortDescriptors());
|
||||||
|
page(dataSourceLoadOptionsBase, this.getTake(), this.getSkip());
|
||||||
|
List<GroupDescriptor> groups = this.getGroup();
|
||||||
|
if (groups != null && !groups.isEmpty()) {
|
||||||
|
this.group(dataSourceLoadOptionsBase);
|
||||||
|
}
|
||||||
|
|
||||||
|
List<AggregateDescriptor> aggregates = this.getAggregate();
|
||||||
|
if (aggregates != null && !aggregates.isEmpty()) {
|
||||||
|
calculateAggregates(dataSourceLoadOptionsBase, aggregates);
|
||||||
|
}
|
||||||
|
|
||||||
|
return dataSourceLoadOptionsBase;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DataSourceResult toDataSourceResult(LoadResult loadResult) {
|
||||||
|
DataSourceResult dataSourceResult = new DataSourceResult();
|
||||||
|
if (null != loadResult.getData()) {
|
||||||
|
List results = (List)loadResult.getData();
|
||||||
|
dataSourceResult.setData(results);
|
||||||
|
if (null == loadResult.getTotalCount()) {
|
||||||
|
loadResult.setTotalCount(results.size());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dataSourceResult.setTotal((long)loadResult.getTotalCount());
|
||||||
|
dataSourceResult.setAggregates(loadResult.getAggregates());
|
||||||
|
return dataSourceResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<SortDescriptor> sortDescriptors() {
|
||||||
|
List<SortDescriptor> sort = new ArrayList();
|
||||||
|
List<GroupDescriptor> groups = this.getGroup();
|
||||||
|
List<SortDescriptor> sorts = this.getSort();
|
||||||
|
if (groups != null) {
|
||||||
|
sort.addAll(groups);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sorts != null) {
|
||||||
|
sort.addAll(sorts);
|
||||||
|
}
|
||||||
|
|
||||||
|
return sort;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<GroupDescriptor> getGroup() {
|
||||||
|
return this.group;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setGroup(List<GroupDescriptor> group) {
|
||||||
|
this.group = group;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<AggregateDescriptor> getAggregate() {
|
||||||
|
return this.aggregate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAggregate(List<AggregateDescriptor> aggregate) {
|
||||||
|
this.aggregate = aggregate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
DataSourceRequest dataSourceRequest = new DataSourceRequest();
|
||||||
|
dataSourceRequest.setPage(1);
|
||||||
|
dataSourceRequest.setPageSize(20);
|
||||||
|
dataSourceRequest.setSkip(0);
|
||||||
|
dataSourceRequest.setTake(20);
|
||||||
|
FilterDescriptor filter = new FilterDescriptor();
|
||||||
|
filter.setLogic("and");
|
||||||
|
List<FilterDescriptor> andFilters = new ArrayList();
|
||||||
|
FilterDescriptor filter1 = new FilterDescriptor();
|
||||||
|
filter1.setField("freight");
|
||||||
|
filter1.setValue(12);
|
||||||
|
filter1.setOperator("eq");
|
||||||
|
andFilters.add(filter1);
|
||||||
|
FilterDescriptor filter2 = new FilterDescriptor();
|
||||||
|
filter2.setField("freight");
|
||||||
|
filter2.setValue(23);
|
||||||
|
filter2.setOperator("eq");
|
||||||
|
andFilters.add(filter2);
|
||||||
|
FilterDescriptor filter3 = new FilterDescriptor();
|
||||||
|
filter3.setLogic("or");
|
||||||
|
FilterDescriptor filter4 = new FilterDescriptor();
|
||||||
|
filter4.setField("freight");
|
||||||
|
filter4.setValue("23");
|
||||||
|
filter4.setOperator("startswith");
|
||||||
|
List<FilterDescriptor> orFilters = new ArrayList();
|
||||||
|
orFilters.add(filter4);
|
||||||
|
FilterDescriptor filter5 = new FilterDescriptor();
|
||||||
|
filter5.setField("freight");
|
||||||
|
filter5.setValue("23");
|
||||||
|
filter5.setOperator("eq");
|
||||||
|
orFilters.add(filter5);
|
||||||
|
filter3.setFilters(orFilters);
|
||||||
|
andFilters.add(filter3);
|
||||||
|
filter.setFilters(andFilters);
|
||||||
|
dataSourceRequest.setFilter(filter);
|
||||||
|
DataSourceLoadOptionsBase loadOptions = dataSourceRequest.toDevRequest();
|
||||||
|
System.out.println(JSONUtil.toJsonStr(loadOptions));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class SortDescriptor {
|
||||||
|
private String field;
|
||||||
|
private String dir;
|
||||||
|
private Boolean needSortFlag = true;
|
||||||
|
|
||||||
|
public SortDescriptor() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getField() {
|
||||||
|
return this.field;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setField(String field) {
|
||||||
|
this.field = field;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDir() {
|
||||||
|
return this.dir;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDir(String dir) {
|
||||||
|
this.dir = dir;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Boolean getNeedSortFlag() {
|
||||||
|
return this.needSortFlag;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNeedSortFlag(Boolean needSortFlag) {
|
||||||
|
this.needSortFlag = needSortFlag;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class GroupDescriptor extends SortDescriptor {
|
||||||
|
private List<AggregateDescriptor> aggregates = new ArrayList();
|
||||||
|
|
||||||
|
public GroupDescriptor() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<AggregateDescriptor> getAggregates() {
|
||||||
|
return this.aggregates;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class AggregateDescriptor {
|
||||||
|
private String field;
|
||||||
|
private String aggregate;
|
||||||
|
|
||||||
|
public AggregateDescriptor() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getField() {
|
||||||
|
return this.field;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setField(String field) {
|
||||||
|
this.field = field;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAggregate() {
|
||||||
|
return this.aggregate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAggregate(String aggregate) {
|
||||||
|
this.aggregate = aggregate;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class FilterDescriptor {
|
||||||
|
private String logic;
|
||||||
|
private List<FilterDescriptor> filters = new ArrayList();
|
||||||
|
private String field;
|
||||||
|
private Object value;
|
||||||
|
private String operator;
|
||||||
|
private String dataType = "";
|
||||||
|
private boolean ignoreCase = true;
|
||||||
|
|
||||||
|
public FilterDescriptor() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getField() {
|
||||||
|
return this.field;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setField(String field) {
|
||||||
|
this.field = field;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Object getValue() {
|
||||||
|
return this.value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setValue(Object value) {
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getOperator() {
|
||||||
|
return this.operator;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOperator(String operator) {
|
||||||
|
this.operator = operator;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getLogic() {
|
||||||
|
return this.logic;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLogic(String logic) {
|
||||||
|
this.logic = logic;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isIgnoreCase() {
|
||||||
|
return this.ignoreCase;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIgnoreCase(boolean ignoreCase) {
|
||||||
|
this.ignoreCase = ignoreCase;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDataType() {
|
||||||
|
return this.dataType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDataType(String dataType) {
|
||||||
|
this.dataType = dataType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<FilterDescriptor> getFilters() {
|
||||||
|
return this.filters;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFilters(final List<FilterDescriptor> filters) {
|
||||||
|
this.filters = filters;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean equals(final Object o) {
|
||||||
|
if (o == this) {
|
||||||
|
return true;
|
||||||
|
} else if (!(o instanceof FilterDescriptor)) {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
FilterDescriptor other = (FilterDescriptor)o;
|
||||||
|
if (!other.canEqual(this)) {
|
||||||
|
return false;
|
||||||
|
} else if (this.isIgnoreCase() != other.isIgnoreCase()) {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
Object this$logic = this.getLogic();
|
||||||
|
Object other$logic = other.getLogic();
|
||||||
|
if (this$logic == null) {
|
||||||
|
if (other$logic != null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else if (!this$logic.equals(other$logic)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Object this$filters = this.getFilters();
|
||||||
|
Object other$filters = other.getFilters();
|
||||||
|
if (this$filters == null) {
|
||||||
|
if (other$filters != null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else if (!this$filters.equals(other$filters)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Object this$field = this.getField();
|
||||||
|
Object other$field = other.getField();
|
||||||
|
if (this$field == null) {
|
||||||
|
if (other$field != null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else if (!this$field.equals(other$field)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Object this$value = this.getValue();
|
||||||
|
Object other$value = other.getValue();
|
||||||
|
if (this$value == null) {
|
||||||
|
if (other$value != null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else if (!this$value.equals(other$value)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Object this$operator = this.getOperator();
|
||||||
|
Object other$operator = other.getOperator();
|
||||||
|
if (this$operator == null) {
|
||||||
|
if (other$operator != null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else if (!this$operator.equals(other$operator)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Object this$dataType = this.getDataType();
|
||||||
|
Object other$dataType = other.getDataType();
|
||||||
|
if (this$dataType == null) {
|
||||||
|
if (other$dataType != null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else if (!this$dataType.equals(other$dataType)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected boolean canEqual(final Object other) {
|
||||||
|
return other instanceof FilterDescriptor;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int hashCode() {
|
||||||
|
int PRIME = 59;
|
||||||
|
int result = 1;
|
||||||
|
result = result * 59 + (this.isIgnoreCase() ? 79 : 97);
|
||||||
|
Object $logic = this.getLogic();
|
||||||
|
result = result * 59 + ($logic == null ? 43 : $logic.hashCode());
|
||||||
|
Object $filters = this.getFilters();
|
||||||
|
result = result * 59 + ($filters == null ? 43 : $filters.hashCode());
|
||||||
|
Object $field = this.getField();
|
||||||
|
result = result * 59 + ($field == null ? 43 : $field.hashCode());
|
||||||
|
Object $value = this.getValue();
|
||||||
|
result = result * 59 + ($value == null ? 43 : $value.hashCode());
|
||||||
|
Object $operator = this.getOperator();
|
||||||
|
result = result * 59 + ($operator == null ? 43 : $operator.hashCode());
|
||||||
|
Object $dataType = this.getDataType();
|
||||||
|
result = result * 59 + ($dataType == null ? 43 : $dataType.hashCode());
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString() {
|
||||||
|
return "DataSourceRequest.FilterDescriptor(logic=" + this.getLogic() + ", filters=" + this.getFilters() + ", field=" + this.getField() + ", value=" + this.getValue() + ", operator=" + this.getOperator() + ", dataType=" + this.getDataType() + ", ignoreCase=" + this.isIgnoreCase() + ")";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,99 @@
|
|||||||
|
//
|
||||||
|
// Source code recreated from a .class file by IntelliJ IDEA
|
||||||
|
// (powered by FernFlower decompiler)
|
||||||
|
//
|
||||||
|
|
||||||
|
package com.yfd.platform.common;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class DataSourceResult<T> {
|
||||||
|
private Long total;
|
||||||
|
private List<T> data;
|
||||||
|
private Map<String, Object> aggregates;
|
||||||
|
|
||||||
|
public long getTotal() {
|
||||||
|
return this.total;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTotal(long total) {
|
||||||
|
this.total = total;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<T> getData() {
|
||||||
|
return this.data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setData(List<T> data) {
|
||||||
|
this.data = data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<String, Object> getAggregates() {
|
||||||
|
return this.aggregates;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAggregates(Map<String, Object> aggregates) {
|
||||||
|
this.aggregates = aggregates;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DataSourceResult() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean equals(final Object o) {
|
||||||
|
if (o == this) {
|
||||||
|
return true;
|
||||||
|
} else if (!(o instanceof DataSourceResult)) {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
DataSourceResult<?> other = (DataSourceResult)o;
|
||||||
|
if (!other.canEqual(this)) {
|
||||||
|
return false;
|
||||||
|
} else if (this.getTotal() != other.getTotal()) {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
Object this$data = this.getData();
|
||||||
|
Object other$data = other.getData();
|
||||||
|
if (this$data == null) {
|
||||||
|
if (other$data != null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else if (!this$data.equals(other$data)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Object this$aggregates = this.getAggregates();
|
||||||
|
Object other$aggregates = other.getAggregates();
|
||||||
|
if (this$aggregates == null) {
|
||||||
|
if (other$aggregates != null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else if (!this$aggregates.equals(other$aggregates)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected boolean canEqual(final Object other) {
|
||||||
|
return other instanceof DataSourceResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int hashCode() {
|
||||||
|
int PRIME = 59;
|
||||||
|
int result = 1;
|
||||||
|
long $total = this.getTotal();
|
||||||
|
result = result * 59 + (int)($total >>> 32 ^ $total);
|
||||||
|
Object $data = this.getData();
|
||||||
|
result = result * 59 + ($data == null ? 43 : $data.hashCode());
|
||||||
|
Object $aggregates = this.getAggregates();
|
||||||
|
result = result * 59 + ($aggregates == null ? 43 : $aggregates.hashCode());
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString() {
|
||||||
|
return "DataSourceResult(total=" + this.getTotal() + ", data=" + this.getData() + ", aggregates=" + this.getAggregates() + ")";
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,262 @@
|
|||||||
|
package com.yfd.platform.common;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
import org.apache.ibatis.annotations.Select;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通用动态 SQL Mapper。
|
||||||
|
* <p>
|
||||||
|
* 说明:
|
||||||
|
* <p>
|
||||||
|
* 1. 该接口通过注解 SQL 直接执行动态查询,适用于“表名/联表 SQL/查询列”需要运行期决定的场景;<br>
|
||||||
|
* 2. 带 {@code QueryWrapper} 的方法统一使用 {@code ew.customSqlSegment} 追加条件;<br>
|
||||||
|
* 3. 传入的 {@code sql}/{@code select}/{@code tableName} 属于动态片段,请在上层确保来源可信,避免注入风险。
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface DynamicSQLMapper<T> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页执行完整 SQL(SQL 内可使用 map 参数)。
|
||||||
|
*/
|
||||||
|
@Select({"<script>", "${sql}", "</script>"})
|
||||||
|
List<Map<String, Object>> pageAllList(Page<?> page,
|
||||||
|
@Param("sql") String sql,
|
||||||
|
@Param("map") Map<String, Object> map);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页执行完整 SQL(泛型结果,依赖 MyBatis 映射规则)。
|
||||||
|
*/
|
||||||
|
@Select({"<script>", "${sql}", "</script>"})
|
||||||
|
<R> List<R> pageAllListWithResultType(Page<?> page,
|
||||||
|
@Param("sql") String sql,
|
||||||
|
@Param("map") Map<String, Object> map,
|
||||||
|
@Param("resultType") Class<R> resultType);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 不分页执行完整 SQL。
|
||||||
|
*/
|
||||||
|
@Select({"<script>", "${sql}", "</script>"})
|
||||||
|
List<Map<String, Object>> getAllList(@Param("sql") String sql,
|
||||||
|
@Param("map") Map<String, Object> map);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 不分页执行完整 SQL(泛型结果,依赖 MyBatis 映射规则)。
|
||||||
|
*/
|
||||||
|
@Select({"<script>", "${sql}", "</script>"})
|
||||||
|
<R> List<R> getAllListWithResultType(@Param("sql") String sql,
|
||||||
|
@Param("map") Map<String, Object> map,
|
||||||
|
@Param("resultType") Class<R> resultType);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 统计条数(含动态条件)。
|
||||||
|
*/
|
||||||
|
@Select({
|
||||||
|
"<script>",
|
||||||
|
"select count(1) count from ${sql}",
|
||||||
|
"<if test='ew != null and ew.customSqlSegment != null and ew.customSqlSegment != \"\"'>",
|
||||||
|
"${ew.customSqlSegment}",
|
||||||
|
"</if>",
|
||||||
|
"</script>"
|
||||||
|
})
|
||||||
|
Integer count(@Param("sql") String sql,
|
||||||
|
@Param("ew") QueryWrapper<?> queryWrapper);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 统计条数(无动态条件)。
|
||||||
|
*/
|
||||||
|
@Select({"<script>", "select count(1) count from ${sql}", "</script>"})
|
||||||
|
Integer countNoWrapper(@Param("sql") String sql);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页查询(含动态条件)。
|
||||||
|
*/
|
||||||
|
@Select({
|
||||||
|
"<script>",
|
||||||
|
"select ${select} from ${sql}",
|
||||||
|
"<if test='ew != null and ew.customSqlSegment != null and ew.customSqlSegment != \"\"'>",
|
||||||
|
"${ew.customSqlSegment}",
|
||||||
|
"</if>",
|
||||||
|
"</script>"
|
||||||
|
})
|
||||||
|
List<Map<String, Object>> pageList(Page<?> page,
|
||||||
|
@Param("select") String select,
|
||||||
|
@Param("sql") String sql,
|
||||||
|
@Param("ew") QueryWrapper<?> queryWrapper);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页查询(含动态条件,泛型结果)。
|
||||||
|
*/
|
||||||
|
@Select({
|
||||||
|
"<script>",
|
||||||
|
"select ${select} from ${sql}",
|
||||||
|
"<if test='ew != null and ew.customSqlSegment != null and ew.customSqlSegment != \"\"'>",
|
||||||
|
"${ew.customSqlSegment}",
|
||||||
|
"</if>",
|
||||||
|
"</script>"
|
||||||
|
})
|
||||||
|
<R> List<R> pageListWithResultType(Page<?> page,
|
||||||
|
@Param("select") String select,
|
||||||
|
@Param("sql") String sql,
|
||||||
|
@Param("ew") QueryWrapper<?> queryWrapper,
|
||||||
|
@Param("resultType") Class<R> resultType);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页查询(条件可选;方法名保持兼容)。
|
||||||
|
*/
|
||||||
|
@Select({
|
||||||
|
"<script>",
|
||||||
|
"select ${select} from ${sql}",
|
||||||
|
"<if test='ew != null and ew.customSqlSegment != null and ew.customSqlSegment != \"\"'>",
|
||||||
|
"${ew.customSqlSegment}",
|
||||||
|
"</if>",
|
||||||
|
"</script>"
|
||||||
|
})
|
||||||
|
List<Map<String, Object>> pageNoFilterList(Page<?> page,
|
||||||
|
@Param("select") String select,
|
||||||
|
@Param("sql") String sql,
|
||||||
|
@Param("ew") QueryWrapper<?> queryWrapper);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页查询(无动态条件)。
|
||||||
|
*/
|
||||||
|
@Select({"<script>", "select ${select} from ${sql}", "</script>"})
|
||||||
|
List<Map<String, Object>> pageListNoWrapper(Page<?> page,
|
||||||
|
@Param("select") String select,
|
||||||
|
@Param("sql") String sql);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 非分页查询(含动态条件)。
|
||||||
|
*/
|
||||||
|
@Select({
|
||||||
|
"<script>",
|
||||||
|
"select ${select} from ${sql}",
|
||||||
|
"<if test='ew != null and ew.customSqlSegment != null and ew.customSqlSegment != \"\"'>",
|
||||||
|
"${ew.customSqlSegment}",
|
||||||
|
"</if>",
|
||||||
|
"</script>"
|
||||||
|
})
|
||||||
|
List<Map<String, Object>> getList(@Param("select") String select,
|
||||||
|
@Param("sql") String sql,
|
||||||
|
@Param("ew") QueryWrapper<?> queryWrapper);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 非分页查询(含动态条件,历史命名保留;返回 Map 结构)。
|
||||||
|
*/
|
||||||
|
@Select({
|
||||||
|
"<script>",
|
||||||
|
"select ${select} from ${sql}",
|
||||||
|
"<if test='ew != null and ew.customSqlSegment != null and ew.customSqlSegment != \"\"'>",
|
||||||
|
"${ew.customSqlSegment}",
|
||||||
|
"</if>",
|
||||||
|
"</script>"
|
||||||
|
})
|
||||||
|
List<Map<String, Object>> getListWithResultType(@Param("select") String select,
|
||||||
|
@Param("sql") String sql,
|
||||||
|
@Param("ew") QueryWrapper<?> queryWrapper);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 单表条件查询(直接传 where 条件片段)。
|
||||||
|
*/
|
||||||
|
@Select({"<script>", "select ${select} from ${table} where ${condition}", "</script>"})
|
||||||
|
List<Map<String, Object>> getSingleTableList(@Param("select") String select,
|
||||||
|
@Param("table") String table,
|
||||||
|
@Param("condition") String condition);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 非分页查询(条件可选;方法名保持兼容)。
|
||||||
|
*/
|
||||||
|
@Select({
|
||||||
|
"<script>",
|
||||||
|
"select ${select} from ${sql}",
|
||||||
|
"<if test='ew != null and ew.customSqlSegment != null and ew.customSqlSegment != \"\"'>",
|
||||||
|
"${ew.customSqlSegment}",
|
||||||
|
"</if>",
|
||||||
|
"</script>"
|
||||||
|
})
|
||||||
|
List<Map<String, Object>> getNoFilterList(@Param("select") String select,
|
||||||
|
@Param("sql") String sql,
|
||||||
|
@Param("ew") QueryWrapper<?> queryWrapper);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 非分页查询(无动态条件)。
|
||||||
|
*/
|
||||||
|
@Select({"<script>", "select ${select} from ${sql}", "</script>"})
|
||||||
|
List<Map<String, Object>> getListNoWrapper(@Param("select") String select,
|
||||||
|
@Param("sql") String sql);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 汇总查询(含动态条件),返回单行汇总结果。
|
||||||
|
*/
|
||||||
|
@Select({
|
||||||
|
"<script>",
|
||||||
|
"select ${select} from ${sql}",
|
||||||
|
"<if test='ew != null and ew.customSqlSegment != null and ew.customSqlSegment != \"\"'>",
|
||||||
|
"${ew.customSqlSegment}",
|
||||||
|
"</if>",
|
||||||
|
"</script>"
|
||||||
|
})
|
||||||
|
Map<String, Object> totalSummary(@Param("select") String select,
|
||||||
|
@Param("sql") String sql,
|
||||||
|
@Param("ew") QueryWrapper<?> queryWrapper);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 汇总查询(无动态条件)。
|
||||||
|
*/
|
||||||
|
@Select({"<script>", "select ${select} from ${sql}", "</script>"})
|
||||||
|
Map<String, Object> totalSummaryNoWrapper(@Param("select") String select,
|
||||||
|
@Param("sql") String sql);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 单表汇总查询(含动态条件)。
|
||||||
|
*/
|
||||||
|
@Select({
|
||||||
|
"<script>",
|
||||||
|
"select ${select} from ${tableName}",
|
||||||
|
"<if test='ew != null and ew.customSqlSegment != null and ew.customSqlSegment != \"\"'>",
|
||||||
|
"${ew.customSqlSegment}",
|
||||||
|
"</if>",
|
||||||
|
"</script>"
|
||||||
|
})
|
||||||
|
Map<String, Object> totalSummarySingleTable(@Param("select") String select,
|
||||||
|
@Param("tableName") String tableName,
|
||||||
|
@Param("ew") QueryWrapper<?> queryWrapper);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 单表汇总查询(无动态条件)。
|
||||||
|
*/
|
||||||
|
@Select({"<script>", "select ${select} from ${tableName}", "</script>"})
|
||||||
|
Map<String, Object> totalSummaryNoWrapperSingleTable(@Param("select") String select,
|
||||||
|
@Param("tableName") String tableName);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取表中最大排序值。
|
||||||
|
*/
|
||||||
|
@Select({"<script>", "select max(order_index) from ${tableName}", "</script>"})
|
||||||
|
Integer getOrderIndexMax(@Param("tableName") String tableName);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 按条件获取表中最大排序值。
|
||||||
|
*/
|
||||||
|
@Select({
|
||||||
|
"<script>",
|
||||||
|
"select max(order_index) from ${tableName}",
|
||||||
|
"<if test='ew != null and ew.customSqlSegment != null and ew.customSqlSegment != \"\"'>",
|
||||||
|
"${ew.customSqlSegment}",
|
||||||
|
"</if>",
|
||||||
|
"</script>"
|
||||||
|
})
|
||||||
|
Integer getOrderIndexMaxByParentId(@Param("tableName") String tableName,
|
||||||
|
@Param("ew") QueryWrapper<?> queryWrapper);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取分组字段列表。
|
||||||
|
*/
|
||||||
|
@Select({"<script>", "select ${info} from ${joinsql} group by ${info}", "</script>"})
|
||||||
|
List<Object> getGroup(@Param("info") String info, @Param("joinsql") String joinsql);
|
||||||
|
}
|
||||||
@ -0,0 +1,44 @@
|
|||||||
|
//
|
||||||
|
// Source code recreated from a .class file by IntelliJ IDEA
|
||||||
|
// (powered by FernFlower decompiler)
|
||||||
|
//
|
||||||
|
|
||||||
|
package com.yfd.platform.common;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class FilterFieldMeta {
|
||||||
|
private DataSourceRequest.FilterDescriptor filterDescriptor;
|
||||||
|
private Map<String, ItemEntity> fieldMeta;
|
||||||
|
private List<OrderBy> orderByList;
|
||||||
|
|
||||||
|
public FilterFieldMeta(DataSourceRequest.FilterDescriptor filterDescriptor, Map<String, ItemEntity> fieldMeta) {
|
||||||
|
this.filterDescriptor = filterDescriptor;
|
||||||
|
this.fieldMeta = fieldMeta;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DataSourceRequest.FilterDescriptor getFilterDescriptor() {
|
||||||
|
return this.filterDescriptor;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFilterDescriptor(DataSourceRequest.FilterDescriptor filterDescriptor) {
|
||||||
|
this.filterDescriptor = filterDescriptor;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<String, ItemEntity> getFieldMeta() {
|
||||||
|
return this.fieldMeta;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFieldMeta(Map<String, ItemEntity> fieldMeta) {
|
||||||
|
this.fieldMeta = fieldMeta;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<OrderBy> getOrderByList() {
|
||||||
|
return this.orderByList;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOrderByList(List<OrderBy> orderByList) {
|
||||||
|
this.orderByList = orderByList;
|
||||||
|
}
|
||||||
|
}
|
||||||
200
backend/src/main/java/com/yfd/platform/common/Group.java
Normal file
200
backend/src/main/java/com/yfd/platform/common/Group.java
Normal file
@ -0,0 +1,200 @@
|
|||||||
|
//
|
||||||
|
// Source code recreated from a .class file by IntelliJ IDEA
|
||||||
|
// (powered by FernFlower decompiler)
|
||||||
|
//
|
||||||
|
|
||||||
|
package com.yfd.platform.common;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class Group {
|
||||||
|
private Object key;
|
||||||
|
private String keyName;
|
||||||
|
private Map<String, Object> keyExt;
|
||||||
|
@JsonIgnore
|
||||||
|
private Object field;
|
||||||
|
private List items;
|
||||||
|
private int count = 0;
|
||||||
|
private Object[] summary;
|
||||||
|
private Map<String, Object> aggregates;
|
||||||
|
|
||||||
|
public Group() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public Object getKey() {
|
||||||
|
return this.key;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getKeyName() {
|
||||||
|
return this.keyName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<String, Object> getKeyExt() {
|
||||||
|
return this.keyExt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Object getField() {
|
||||||
|
return this.field;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List getItems() {
|
||||||
|
return this.items;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getCount() {
|
||||||
|
return this.count;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Object[] getSummary() {
|
||||||
|
return this.summary;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<String, Object> getAggregates() {
|
||||||
|
return this.aggregates;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setKey(final Object key) {
|
||||||
|
this.key = key;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setKeyName(final String keyName) {
|
||||||
|
this.keyName = keyName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setKeyExt(final Map<String, Object> keyExt) {
|
||||||
|
this.keyExt = keyExt;
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
public void setField(final Object field) {
|
||||||
|
this.field = field;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setItems(final List items) {
|
||||||
|
this.items = items;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCount(final int count) {
|
||||||
|
this.count = count;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSummary(final Object[] summary) {
|
||||||
|
this.summary = summary;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAggregates(final Map<String, Object> aggregates) {
|
||||||
|
this.aggregates = aggregates;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean equals(final Object o) {
|
||||||
|
if (o == this) {
|
||||||
|
return true;
|
||||||
|
} else if (!(o instanceof Group)) {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
Group other = (Group)o;
|
||||||
|
if (!other.canEqual(this)) {
|
||||||
|
return false;
|
||||||
|
} else if (this.getCount() != other.getCount()) {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
Object this$key = this.getKey();
|
||||||
|
Object other$key = other.getKey();
|
||||||
|
if (this$key == null) {
|
||||||
|
if (other$key != null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else if (!this$key.equals(other$key)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Object this$keyName = this.getKeyName();
|
||||||
|
Object other$keyName = other.getKeyName();
|
||||||
|
if (this$keyName == null) {
|
||||||
|
if (other$keyName != null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else if (!this$keyName.equals(other$keyName)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Object this$keyExt = this.getKeyExt();
|
||||||
|
Object other$keyExt = other.getKeyExt();
|
||||||
|
if (this$keyExt == null) {
|
||||||
|
if (other$keyExt != null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else if (!this$keyExt.equals(other$keyExt)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Object this$field = this.getField();
|
||||||
|
Object other$field = other.getField();
|
||||||
|
if (this$field == null) {
|
||||||
|
if (other$field != null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else if (!this$field.equals(other$field)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Object this$items = this.getItems();
|
||||||
|
Object other$items = other.getItems();
|
||||||
|
if (this$items == null) {
|
||||||
|
if (other$items != null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else if (!this$items.equals(other$items)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!Arrays.deepEquals(this.getSummary(), other.getSummary())) {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
Object this$aggregates = this.getAggregates();
|
||||||
|
Object other$aggregates = other.getAggregates();
|
||||||
|
if (this$aggregates == null) {
|
||||||
|
if (other$aggregates != null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else if (!this$aggregates.equals(other$aggregates)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected boolean canEqual(final Object other) {
|
||||||
|
return other instanceof Group;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int hashCode() {
|
||||||
|
int PRIME = 59;
|
||||||
|
int result = 1;
|
||||||
|
result = result * 59 + this.getCount();
|
||||||
|
Object $key = this.getKey();
|
||||||
|
result = result * 59 + ($key == null ? 43 : $key.hashCode());
|
||||||
|
Object $keyName = this.getKeyName();
|
||||||
|
result = result * 59 + ($keyName == null ? 43 : $keyName.hashCode());
|
||||||
|
Object $keyExt = this.getKeyExt();
|
||||||
|
result = result * 59 + ($keyExt == null ? 43 : $keyExt.hashCode());
|
||||||
|
Object $field = this.getField();
|
||||||
|
result = result * 59 + ($field == null ? 43 : $field.hashCode());
|
||||||
|
Object $items = this.getItems();
|
||||||
|
result = result * 59 + ($items == null ? 43 : $items.hashCode());
|
||||||
|
result = result * 59 + Arrays.deepHashCode(this.getSummary());
|
||||||
|
Object $aggregates = this.getAggregates();
|
||||||
|
result = result * 59 + ($aggregates == null ? 43 : $aggregates.hashCode());
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString() {
|
||||||
|
return "Group(key=" + this.getKey() + ", keyName=" + this.getKeyName() + ", keyExt=" + this.getKeyExt() + ", field=" + this.getField() + ", items=" + this.getItems() + ", count=" + this.getCount() + ", summary=" + Arrays.deepToString(this.getSummary()) + ", aggregates=" + this.getAggregates() + ")";
|
||||||
|
}
|
||||||
|
}
|
||||||
189
backend/src/main/java/com/yfd/platform/common/GroupHelper.java
Normal file
189
backend/src/main/java/com/yfd/platform/common/GroupHelper.java
Normal file
@ -0,0 +1,189 @@
|
|||||||
|
//
|
||||||
|
// Source code recreated from a .class file by IntelliJ IDEA
|
||||||
|
// (powered by FernFlower decompiler)
|
||||||
|
//
|
||||||
|
|
||||||
|
package com.yfd.platform.common;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollectionUtil;
|
||||||
|
import cn.hutool.core.util.NumberUtil;
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class GroupHelper {
|
||||||
|
public GroupHelper() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Group> group(List<Map<String, Object>> data, List<GroupingInfo> groupInfo) {
|
||||||
|
List<Group> groups = this.group(data, (GroupingInfo)groupInfo.get(0));
|
||||||
|
if (groupInfo.size() > 1 && CollectionUtil.isNotEmpty(groups)) {
|
||||||
|
for(Group group : groups) {
|
||||||
|
group.setItems(this.group(group.getItems(), groupInfo.subList(1, groupInfo.size())));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return groups;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Map> faltGroup(List<Map<String, Object>> data, List<GroupingInfo> groupInfo) {
|
||||||
|
List<Map> result = new ArrayList();
|
||||||
|
|
||||||
|
for(Map<String, Object> item : data) {
|
||||||
|
result.add(this.flatGroupResult(item, groupInfo));
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Map flatGroupResult(Map<String, Object> item, List<GroupingInfo> groupInfos) {
|
||||||
|
Map<String, Object> group = new HashMap();
|
||||||
|
|
||||||
|
for(GroupingInfo groupInfo : groupInfos) {
|
||||||
|
Object groupKey = this.getKey(item, groupInfo);
|
||||||
|
if (CollectionUtil.isNotEmpty(groupInfo.getSummaryInfos())) {
|
||||||
|
for(SummaryInfo summaryInfo : groupInfo.getSummaryInfos()) {
|
||||||
|
String summaryType = summaryInfo.getSummaryType();
|
||||||
|
StringBuilder stringBuilder = new StringBuilder();
|
||||||
|
stringBuilder.append(summaryType).append("_").append(summaryInfo.getSelector());
|
||||||
|
String key = stringBuilder.toString();
|
||||||
|
Object tempCount = item.get(key);
|
||||||
|
if (tempCount == null) {
|
||||||
|
tempCount = item.get(key.toUpperCase());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tempCount != null) {
|
||||||
|
if (tempCount instanceof Number) {
|
||||||
|
group.put(key, tempCount);
|
||||||
|
} else {
|
||||||
|
Integer count = NumberUtil.parseInt(tempCount.toString());
|
||||||
|
group.put(key, count);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Object tempCount = item.get("count_" + groupInfo.getSelector());
|
||||||
|
if (tempCount == null) {
|
||||||
|
tempCount = item.get("COUNT_" + groupInfo.getSelector().toUpperCase());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tempCount != null) {
|
||||||
|
Integer count = NumberUtil.parseInt(tempCount.toString());
|
||||||
|
group.put("count_" + groupInfo.getSelector(), count);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
group.put(groupInfo.getSelector(), groupKey);
|
||||||
|
group.put(groupInfo.getSelector() + "_value", groupKey);
|
||||||
|
group.put(groupInfo.getSelector() + "_ext", (Object)null);
|
||||||
|
}
|
||||||
|
|
||||||
|
return group;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Group> group(List<Map<String, Object>> data, GroupingInfo groupInfo) {
|
||||||
|
Map<Object, Group> groupsIndex = new HashMap();
|
||||||
|
List<Group> groups = new ArrayList();
|
||||||
|
|
||||||
|
for(Map<String, Object> item : data) {
|
||||||
|
Object groupKey = this.getKey(item, groupInfo);
|
||||||
|
Object groupIndexKey = groupKey != null ? groupKey : null;
|
||||||
|
Object tempCount = item.get("count_" + groupInfo.getSelector());
|
||||||
|
if (tempCount == null) {
|
||||||
|
tempCount = item.get("COUNT_" + groupInfo.getSelector().toUpperCase());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!groupsIndex.containsKey(groupIndexKey)) {
|
||||||
|
Group newGroup = new Group();
|
||||||
|
newGroup.setKey(groupKey);
|
||||||
|
newGroup.setField(groupInfo.getSelector());
|
||||||
|
if (tempCount != null) {
|
||||||
|
newGroup.setCount(NumberUtil.parseInt(tempCount.toString()));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (CollectionUtil.isNotEmpty(groupInfo.getSummaryInfos())) {
|
||||||
|
Map<String, Object> groupSummarys = new HashMap();
|
||||||
|
|
||||||
|
for(SummaryInfo summaryInfo : groupInfo.getSummaryInfos()) {
|
||||||
|
String summaryType = summaryInfo.getSummaryType();
|
||||||
|
StringBuilder stringBuilder = new StringBuilder();
|
||||||
|
stringBuilder.append(summaryType).append("_").append(summaryInfo.getSelector());
|
||||||
|
String key = stringBuilder.toString();
|
||||||
|
Object summaryValue = item.get(key);
|
||||||
|
if (summaryValue == null) {
|
||||||
|
summaryValue = item.get(key.toUpperCase());
|
||||||
|
}
|
||||||
|
|
||||||
|
groupSummarys.put(key, summaryValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
newGroup.setAggregates(groupSummarys);
|
||||||
|
}
|
||||||
|
|
||||||
|
groupsIndex.put(groupIndexKey, newGroup);
|
||||||
|
groups.add(newGroup);
|
||||||
|
} else {
|
||||||
|
Group newGroup = (Group)groupsIndex.get(groupIndexKey);
|
||||||
|
if (tempCount != null) {
|
||||||
|
newGroup.setCount(newGroup.getCount() + NumberUtil.parseInt(tempCount.toString()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Group group = (Group)groupsIndex.get(groupIndexKey);
|
||||||
|
if (group.getItems() == null) {
|
||||||
|
group.setItems(new ArrayList());
|
||||||
|
group.getItems().add(item);
|
||||||
|
} else {
|
||||||
|
group.getItems().add(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return groups;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Object getKey(Map<String, Object> obj, GroupingInfo groupInfo) {
|
||||||
|
Object memberValue = obj.get(groupInfo.getSelector());
|
||||||
|
if (memberValue == null) {
|
||||||
|
memberValue = obj.get(groupInfo.getSelector().toUpperCase());
|
||||||
|
}
|
||||||
|
|
||||||
|
String intervalString = groupInfo.getGroupInterval();
|
||||||
|
if (!StrUtil.isEmpty(intervalString) && memberValue != null) {
|
||||||
|
if (NumberUtil.isNumber(intervalString)) {
|
||||||
|
BigDecimal number = NumberUtil.toBigDecimal((Number)memberValue);
|
||||||
|
BigDecimal interval = NumberUtil.toBigDecimal(intervalString);
|
||||||
|
return number.subtract(number.divideAndRemainder(interval)[1]);
|
||||||
|
} else {
|
||||||
|
switch (intervalString) {
|
||||||
|
case "year":
|
||||||
|
return toDateTime(memberValue).getYear();
|
||||||
|
case "month":
|
||||||
|
return toDateTime(memberValue).getMonth();
|
||||||
|
case "day":
|
||||||
|
return toDateTime(memberValue).getDayOfYear();
|
||||||
|
case "dayOfWeek":
|
||||||
|
return toDateTime(memberValue).getDayOfWeek();
|
||||||
|
case "hour":
|
||||||
|
return toDateTime(memberValue).getHour();
|
||||||
|
case "minute":
|
||||||
|
return toDateTime(memberValue).getMinute();
|
||||||
|
case "second":
|
||||||
|
return toDateTime(memberValue).getSecond();
|
||||||
|
default:
|
||||||
|
throw new RuntimeException("memberValue字段解析失败");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return memberValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static LocalDateTime toDateTime(Object value) {
|
||||||
|
return value instanceof LocalDateTime ? (LocalDateTime)value : LocalDateTime.parse(value.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,72 @@
|
|||||||
|
//
|
||||||
|
// Source code recreated from a .class file by IntelliJ IDEA
|
||||||
|
// (powered by FernFlower decompiler)
|
||||||
|
//
|
||||||
|
|
||||||
|
package com.yfd.platform.common;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class GroupResult {
|
||||||
|
private String selectSql;
|
||||||
|
private String groupSql;
|
||||||
|
private String summaryInfoSql;
|
||||||
|
private String groupBySql;
|
||||||
|
private String orderBySql;
|
||||||
|
private Map<String, Object> paramMap = new HashMap();
|
||||||
|
|
||||||
|
public GroupResult(String groupSql, String orderBySql, Map<String, Object> paramMap) {
|
||||||
|
this.groupSql = groupSql;
|
||||||
|
this.orderBySql = orderBySql;
|
||||||
|
this.paramMap = paramMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getGroupSql() {
|
||||||
|
return this.groupSql;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setGroupSql(String groupSql) {
|
||||||
|
this.groupSql = groupSql;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<String, Object> getParamMap() {
|
||||||
|
return this.paramMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setParamMap(Map<String, Object> paramMap) {
|
||||||
|
this.paramMap = paramMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getOrderBySql() {
|
||||||
|
return this.orderBySql;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOrderBySql(String orderBySql) {
|
||||||
|
this.orderBySql = orderBySql;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSelectSql() {
|
||||||
|
return this.selectSql;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSelectSql(String selectSql) {
|
||||||
|
this.selectSql = selectSql;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getGroupBySql() {
|
||||||
|
return this.groupBySql;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setGroupBySql(String groupBySql) {
|
||||||
|
this.groupBySql = groupBySql;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSummaryInfoSql() {
|
||||||
|
return this.summaryInfoSql;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSummaryInfoSql(String summaryInfoSql) {
|
||||||
|
this.summaryInfoSql = summaryInfoSql;
|
||||||
|
}
|
||||||
|
}
|
||||||
118
backend/src/main/java/com/yfd/platform/common/GroupingInfo.java
Normal file
118
backend/src/main/java/com/yfd/platform/common/GroupingInfo.java
Normal file
@ -0,0 +1,118 @@
|
|||||||
|
//
|
||||||
|
// Source code recreated from a .class file by IntelliJ IDEA
|
||||||
|
// (powered by FernFlower decompiler)
|
||||||
|
//
|
||||||
|
|
||||||
|
package com.yfd.platform.common;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
//@Data
|
||||||
|
//@EqualsAndHashCode(callSuper = true)
|
||||||
|
public class GroupingInfo extends SortingInfo {
|
||||||
|
|
||||||
|
private List<SummaryInfo> summaryInfos = new ArrayList();
|
||||||
|
|
||||||
|
@Schema(description = "分组时间间隔")
|
||||||
|
private String groupInterval;
|
||||||
|
|
||||||
|
@Schema(description = "分组数据是否应该返回")
|
||||||
|
private Boolean isExpanded = false;
|
||||||
|
|
||||||
|
public GroupingInfo() {
|
||||||
|
this.summaryInfos = new ArrayList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<SummaryInfo> getSummaryInfos() {
|
||||||
|
return this.summaryInfos;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getGroupInterval() {
|
||||||
|
return this.groupInterval;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Boolean getIsExpanded() {
|
||||||
|
return this.isExpanded;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSummaryInfos(final List<SummaryInfo> summaryInfos) {
|
||||||
|
this.summaryInfos = summaryInfos;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setGroupInterval(final String groupInterval) {
|
||||||
|
this.groupInterval = groupInterval;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIsExpanded(final Boolean isExpanded) {
|
||||||
|
this.isExpanded = isExpanded;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean equals(final Object o) {
|
||||||
|
if (o == this) {
|
||||||
|
return true;
|
||||||
|
} else if (!(o instanceof GroupingInfo)) {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
GroupingInfo other = (GroupingInfo)o;
|
||||||
|
if (!other.canEqual(this)) {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
Object this$isExpanded = this.getIsExpanded();
|
||||||
|
Object other$isExpanded = other.getIsExpanded();
|
||||||
|
if (this$isExpanded == null) {
|
||||||
|
if (other$isExpanded != null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else if (!this$isExpanded.equals(other$isExpanded)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Object this$summaryInfos = this.getSummaryInfos();
|
||||||
|
Object other$summaryInfos = other.getSummaryInfos();
|
||||||
|
if (this$summaryInfos == null) {
|
||||||
|
if (other$summaryInfos != null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else if (!this$summaryInfos.equals(other$summaryInfos)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Object this$groupInterval = this.getGroupInterval();
|
||||||
|
Object other$groupInterval = other.getGroupInterval();
|
||||||
|
if (this$groupInterval == null) {
|
||||||
|
if (other$groupInterval != null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else if (!this$groupInterval.equals(other$groupInterval)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected boolean canEqual(final Object other) {
|
||||||
|
return other instanceof GroupingInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int hashCode() {
|
||||||
|
int PRIME = 59;
|
||||||
|
int result = 1;
|
||||||
|
Object $isExpanded = this.getIsExpanded();
|
||||||
|
result = result * 59 + ($isExpanded == null ? 43 : $isExpanded.hashCode());
|
||||||
|
Object $summaryInfos = this.getSummaryInfos();
|
||||||
|
result = result * 59 + ($summaryInfos == null ? 43 : $summaryInfos.hashCode());
|
||||||
|
Object $groupInterval = this.getGroupInterval();
|
||||||
|
result = result * 59 + ($groupInterval == null ? 43 : $groupInterval.hashCode());
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString() {
|
||||||
|
return "GroupingInfo(summaryInfos=" + this.getSummaryInfos() + ", groupInterval=" + this.getGroupInterval() + ", isExpanded=" + this.getIsExpanded() + ")";
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,28 @@
|
|||||||
|
//
|
||||||
|
// Source code recreated from a .class file by IntelliJ IDEA
|
||||||
|
// (powered by FernFlower decompiler)
|
||||||
|
//
|
||||||
|
|
||||||
|
package com.yfd.platform.common;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import com.fasterxml.jackson.core.JsonGenerator;
|
||||||
|
import com.fasterxml.jackson.databind.JsonSerializer;
|
||||||
|
import com.fasterxml.jackson.databind.SerializerProvider;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
public class GuidStringSerialize extends JsonSerializer<String> {
|
||||||
|
private final String GUID_EMPTY = "00000000-0000-0000-0000-000000000000";
|
||||||
|
|
||||||
|
public GuidStringSerialize() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public void serialize(String value, JsonGenerator jGen, SerializerProvider sProvider) throws IOException {
|
||||||
|
if ("00000000-0000-0000-0000-000000000000".equals(value) || StrUtil.isBlank(value)) {
|
||||||
|
value = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
jGen.writeString(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,63 @@
|
|||||||
|
//
|
||||||
|
// Source code recreated from a .class file by IntelliJ IDEA
|
||||||
|
// (powered by FernFlower decompiler)
|
||||||
|
//
|
||||||
|
|
||||||
|
package com.yfd.platform.common;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
|
||||||
|
public class ItemEntity {
|
||||||
|
private String filterItem;
|
||||||
|
private String itemMap;
|
||||||
|
private String alias;
|
||||||
|
private String fieldSql;
|
||||||
|
|
||||||
|
public ItemEntity(String filterItem, String itemMap, String alias) {
|
||||||
|
this.filterItem = filterItem;
|
||||||
|
this.itemMap = itemMap;
|
||||||
|
this.alias = alias;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFieldSql() {
|
||||||
|
if (StrUtil.isNotBlank(this.fieldSql)) {
|
||||||
|
return this.fieldSql;
|
||||||
|
} else {
|
||||||
|
if (StrUtil.isNotBlank(this.alias)) {
|
||||||
|
StringBuilder stringBuilder = new StringBuilder();
|
||||||
|
stringBuilder.append(this.alias);
|
||||||
|
stringBuilder.append(".");
|
||||||
|
stringBuilder.append(this.itemMap);
|
||||||
|
this.fieldSql = stringBuilder.toString();
|
||||||
|
} else {
|
||||||
|
this.fieldSql = this.itemMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.fieldSql;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFilterItem() {
|
||||||
|
return this.filterItem;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFilterItem(String filterItem) {
|
||||||
|
this.filterItem = filterItem;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getItemMap() {
|
||||||
|
return this.itemMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setItemMap(String itemMap) {
|
||||||
|
this.itemMap = itemMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAlias() {
|
||||||
|
return this.alias;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAlias(String alias) {
|
||||||
|
this.alias = alias;
|
||||||
|
}
|
||||||
|
}
|
||||||
150
backend/src/main/java/com/yfd/platform/common/LoadResult.java
Normal file
150
backend/src/main/java/com/yfd/platform/common/LoadResult.java
Normal file
@ -0,0 +1,150 @@
|
|||||||
|
//
|
||||||
|
// Source code recreated from a .class file by IntelliJ IDEA
|
||||||
|
// (powered by FernFlower decompiler)
|
||||||
|
//
|
||||||
|
|
||||||
|
package com.yfd.platform.common;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class LoadResult<T> {
|
||||||
|
private T data;
|
||||||
|
private Integer totalCount;
|
||||||
|
private Integer groupCount;
|
||||||
|
@Schema(
|
||||||
|
hidden = true
|
||||||
|
)
|
||||||
|
private Object[] summary;
|
||||||
|
@JsonIgnore
|
||||||
|
private Map<String, Object> aggregates;
|
||||||
|
|
||||||
|
public LoadResult() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public T getData() {
|
||||||
|
return this.data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getTotalCount() {
|
||||||
|
return this.totalCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getGroupCount() {
|
||||||
|
return this.groupCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Object[] getSummary() {
|
||||||
|
return this.summary;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<String, Object> getAggregates() {
|
||||||
|
return this.aggregates;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setData(final T data) {
|
||||||
|
this.data = data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTotalCount(final Integer totalCount) {
|
||||||
|
this.totalCount = totalCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setGroupCount(final Integer groupCount) {
|
||||||
|
this.groupCount = groupCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSummary(final Object[] summary) {
|
||||||
|
this.summary = summary;
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
public void setAggregates(final Map<String, Object> aggregates) {
|
||||||
|
this.aggregates = aggregates;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean equals(final Object o) {
|
||||||
|
if (o == this) {
|
||||||
|
return true;
|
||||||
|
} else if (!(o instanceof LoadResult)) {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
LoadResult<?> other = (LoadResult)o;
|
||||||
|
if (!other.canEqual(this)) {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
Object this$totalCount = this.getTotalCount();
|
||||||
|
Object other$totalCount = other.getTotalCount();
|
||||||
|
if (this$totalCount == null) {
|
||||||
|
if (other$totalCount != null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else if (!this$totalCount.equals(other$totalCount)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Object this$groupCount = this.getGroupCount();
|
||||||
|
Object other$groupCount = other.getGroupCount();
|
||||||
|
if (this$groupCount == null) {
|
||||||
|
if (other$groupCount != null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else if (!this$groupCount.equals(other$groupCount)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Object this$data = this.getData();
|
||||||
|
Object other$data = other.getData();
|
||||||
|
if (this$data == null) {
|
||||||
|
if (other$data != null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else if (!this$data.equals(other$data)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!Arrays.deepEquals(this.getSummary(), other.getSummary())) {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
Object this$aggregates = this.getAggregates();
|
||||||
|
Object other$aggregates = other.getAggregates();
|
||||||
|
if (this$aggregates == null) {
|
||||||
|
if (other$aggregates != null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else if (!this$aggregates.equals(other$aggregates)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected boolean canEqual(final Object other) {
|
||||||
|
return other instanceof LoadResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int hashCode() {
|
||||||
|
int PRIME = 59;
|
||||||
|
int result = 1;
|
||||||
|
Object $totalCount = this.getTotalCount();
|
||||||
|
result = result * 59 + ($totalCount == null ? 43 : $totalCount.hashCode());
|
||||||
|
Object $groupCount = this.getGroupCount();
|
||||||
|
result = result * 59 + ($groupCount == null ? 43 : $groupCount.hashCode());
|
||||||
|
Object $data = this.getData();
|
||||||
|
result = result * 59 + ($data == null ? 43 : $data.hashCode());
|
||||||
|
result = result * 59 + Arrays.deepHashCode(this.getSummary());
|
||||||
|
Object $aggregates = this.getAggregates();
|
||||||
|
result = result * 59 + ($aggregates == null ? 43 : $aggregates.hashCode());
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString() {
|
||||||
|
return "LoadResult(data=" + this.getData() + ", totalCount=" + this.getTotalCount() + ", groupCount=" + this.getGroupCount() + ", summary=" + Arrays.deepToString(this.getSummary()) + ", aggregates=" + this.getAggregates() + ")";
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,80 @@
|
|||||||
|
package com.yfd.platform.common;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
import org.apache.ibatis.annotations.Select;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@Mapper
|
||||||
|
public interface MicroservicDynamicSQLMapper<T> {
|
||||||
|
|
||||||
|
@Select({"${sql}"})
|
||||||
|
List<Map<String, Object>> pageAllList(Page page, String sql, @Param("map") Map<String, Object> map);
|
||||||
|
|
||||||
|
@Select({"${sql}"})
|
||||||
|
<resultType> List<resultType> pageAllListWithResultType(Page page, @Param("sql") String sql, @Param("map") Map<String, Object> map, @Param("resultType") Class<resultType> resultType);
|
||||||
|
|
||||||
|
@Select({"${sql}"})
|
||||||
|
List<Map> getAllList(String sql, @Param("map") Map<String, Object> map);
|
||||||
|
|
||||||
|
@Select({"${sql}"})
|
||||||
|
<resultType> List<resultType> getAllListWithResultType(@Param("sql") String sql, @Param("map") Map<String, Object> map, @Param("resultType") Class<resultType> resultType);
|
||||||
|
|
||||||
|
@Select({"select count(1) count from ${sql} and ${ew.sqlSegment}"})
|
||||||
|
Integer count(@Param("select") String select, @Param("sql") String sql, @Param("ew") QueryWrapper queryWrapper);
|
||||||
|
|
||||||
|
@Select({"select count(1) count from ${sql}"})
|
||||||
|
Integer countNoWrapper(@Param("select") String select, @Param("sql") String sql);
|
||||||
|
|
||||||
|
@Select({"select ${select} from ${sql} and ${ew.sqlSegment}"})
|
||||||
|
List<Map> pageList(Page page, @Param("select") String select, @Param("sql") String sql, @Param("ew") QueryWrapper queryWrapper);
|
||||||
|
|
||||||
|
@Select({"select ${select} from ${sql} and ${ew.sqlSegment}"})
|
||||||
|
<resultType> List<resultType> pageListWithResultType(Page page, @Param("select") String select, @Param("sql") String sql, @Param("ew") QueryWrapper queryWrapper, @Param("resultType") Class<resultType> resultType);
|
||||||
|
|
||||||
|
@Select({"select ${select} from ${sql} ${ew.sqlSegment}"})
|
||||||
|
List<Map> pageNoFilterList(Page page, @Param("select") String select, @Param("sql") String sql, @Param("ew") QueryWrapper queryWrapper);
|
||||||
|
|
||||||
|
@Select({"select ${select} from ${sql}"})
|
||||||
|
List<Map> pageListNoWrapper(Page page, @Param("select") String select, @Param("sql") String sql);
|
||||||
|
|
||||||
|
@Select({"select ${select} from ${sql} and ${ew.sqlSegment}"})
|
||||||
|
List<Map> getList(@Param("select") String select, @Param("sql") String sql, @Param("ew") QueryWrapper queryWrapper);
|
||||||
|
|
||||||
|
@Select({"select ${select} from ${sql} and ${ew.sqlSegment}"})
|
||||||
|
List<Map> getListWithResultType(@Param("select") String select, @Param("sql") String sql, @Param("ew") QueryWrapper queryWrapper);
|
||||||
|
|
||||||
|
@Select({"select ${select} from ${table} where ${condition}"})
|
||||||
|
List<Map> getSingleTableList(@Param("select") String select, @Param("table") String table, @Param("condition") String condition);
|
||||||
|
|
||||||
|
@Select({"select ${select} from ${sql} ${ew.sqlSegment}"})
|
||||||
|
List<Map> getNoFilterList(@Param("select") String select, @Param("sql") String sql, @Param("ew") QueryWrapper queryWrapper);
|
||||||
|
|
||||||
|
@Select({"select ${select} from ${sql}"})
|
||||||
|
List<Map> getListNoWrapper(@Param("select") String select, @Param("sql") String sql);
|
||||||
|
|
||||||
|
@Select({"select ${select} from ${sql} and ${ew.sqlSegment}"})
|
||||||
|
Map totalSummary(@Param("select") String select, @Param("sql") String sql, @Param("ew") QueryWrapper queryWrapper);
|
||||||
|
|
||||||
|
@Select({"select ${select} from ${sql}"})
|
||||||
|
Map totalSummaryNoWrapper(@Param("select") String select, @Param("sql") String sql);
|
||||||
|
|
||||||
|
@Select({"select ${select} from ${tableName} where ${ew.sqlSegment}"})
|
||||||
|
Map totalSummarySingleTable(@Param("select") String select, @Param("tableName") String tableName, @Param("ew") QueryWrapper queryWrapper);
|
||||||
|
|
||||||
|
@Select({"select ${select} from ${tableName}"})
|
||||||
|
Map totalSummaryNoWrapperSingleTable(@Param("select") String select, @Param("tableName") String tableName);
|
||||||
|
|
||||||
|
@Select({"select max(order_index) from ${tableName}"})
|
||||||
|
Integer getOrderIndexMax(@Param("tableName") String tableName);
|
||||||
|
|
||||||
|
@Select({"select max(order_index) from ${tableName} where ${ew.sqlSegment}"})
|
||||||
|
Integer getOrderIndexMaxByParentId(@Param("tableName") String tableName, @Param("ew") QueryWrapper queryWrapper);
|
||||||
|
|
||||||
|
@Select({"select ${info} from ${joinsql} group by ${info}"})
|
||||||
|
List<Object> getGroup(@Param("info") String info, @Param("joinsql") String joinsql);
|
||||||
|
}
|
||||||
33
backend/src/main/java/com/yfd/platform/common/OrderBy.java
Normal file
33
backend/src/main/java/com/yfd/platform/common/OrderBy.java
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
//
|
||||||
|
// Source code recreated from a .class file by IntelliJ IDEA
|
||||||
|
// (powered by FernFlower decompiler)
|
||||||
|
//
|
||||||
|
|
||||||
|
package com.yfd.platform.common;
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
|
public class OrderBy {
|
||||||
|
public static final String ORDER_ASC = "asc";
|
||||||
|
public static final String ORDER_DESC = "desc";
|
||||||
|
private final String sort;
|
||||||
|
private final String order;
|
||||||
|
|
||||||
|
public OrderBy(String sort, String order) {
|
||||||
|
this.sort = sort;
|
||||||
|
this.order = order;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSort() {
|
||||||
|
return this.sort;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getOrder() {
|
||||||
|
return this.order;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isValid(Set<String> fieldSet) {
|
||||||
|
return fieldSet.contains(this.sort) && (StringUtils.isBlank(this.order) || "asc".equalsIgnoreCase(this.order) || "desc".equalsIgnoreCase(this.order));
|
||||||
|
}
|
||||||
|
}
|
||||||
85
backend/src/main/java/com/yfd/platform/common/PageInfo.java
Normal file
85
backend/src/main/java/com/yfd/platform/common/PageInfo.java
Normal file
@ -0,0 +1,85 @@
|
|||||||
|
//
|
||||||
|
// Source code recreated from a .class file by IntelliJ IDEA
|
||||||
|
// (powered by FernFlower decompiler)
|
||||||
|
//
|
||||||
|
|
||||||
|
package com.yfd.platform.common;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
|
||||||
|
public class PageInfo {
|
||||||
|
private Boolean hasPageInfo;
|
||||||
|
private Page page;
|
||||||
|
|
||||||
|
public PageInfo() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public Boolean getHasPageInfo() {
|
||||||
|
return this.hasPageInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Page getPage() {
|
||||||
|
return this.page;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setHasPageInfo(final Boolean hasPageInfo) {
|
||||||
|
this.hasPageInfo = hasPageInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPage(final Page page) {
|
||||||
|
this.page = page;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean equals(final Object o) {
|
||||||
|
if (o == this) {
|
||||||
|
return true;
|
||||||
|
} else if (!(o instanceof PageInfo)) {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
PageInfo other = (PageInfo)o;
|
||||||
|
if (!other.canEqual(this)) {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
Object this$hasPageInfo = this.getHasPageInfo();
|
||||||
|
Object other$hasPageInfo = other.getHasPageInfo();
|
||||||
|
if (this$hasPageInfo == null) {
|
||||||
|
if (other$hasPageInfo != null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else if (!this$hasPageInfo.equals(other$hasPageInfo)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Object this$page = this.getPage();
|
||||||
|
Object other$page = other.getPage();
|
||||||
|
if (this$page == null) {
|
||||||
|
if (other$page != null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else if (!this$page.equals(other$page)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected boolean canEqual(final Object other) {
|
||||||
|
return other instanceof PageInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int hashCode() {
|
||||||
|
int PRIME = 59;
|
||||||
|
int result = 1;
|
||||||
|
Object $hasPageInfo = this.getHasPageInfo();
|
||||||
|
result = result * 59 + ($hasPageInfo == null ? 43 : $hasPageInfo.hashCode());
|
||||||
|
Object $page = this.getPage();
|
||||||
|
result = result * 59 + ($page == null ? 43 : $page.hashCode());
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString() {
|
||||||
|
return "PageInfo(hasPageInfo=" + this.getHasPageInfo() + ", page=" + this.getPage() + ")";
|
||||||
|
}
|
||||||
|
}
|
||||||
111
backend/src/main/java/com/yfd/platform/common/SortingInfo.java
Normal file
111
backend/src/main/java/com/yfd/platform/common/SortingInfo.java
Normal file
@ -0,0 +1,111 @@
|
|||||||
|
//
|
||||||
|
// Source code recreated from a .class file by IntelliJ IDEA
|
||||||
|
// (powered by FernFlower decompiler)
|
||||||
|
//
|
||||||
|
|
||||||
|
package com.yfd.platform.common;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
|
||||||
|
public class SortingInfo {
|
||||||
|
@Schema(description = "排序字段")
|
||||||
|
public String selector;
|
||||||
|
|
||||||
|
@Schema(description = "是否是降序")
|
||||||
|
public Boolean desc = true;
|
||||||
|
|
||||||
|
@Schema(description = "是否需要排序标记")
|
||||||
|
public Boolean needSortFlag = true;
|
||||||
|
|
||||||
|
public SortingInfo() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSelector() {
|
||||||
|
return this.selector;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Boolean getDesc() {
|
||||||
|
return this.desc;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Boolean getNeedSortFlag() {
|
||||||
|
return this.needSortFlag;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSelector(final String selector) {
|
||||||
|
this.selector = selector;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDesc(final Boolean desc) {
|
||||||
|
this.desc = desc;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNeedSortFlag(final Boolean needSortFlag) {
|
||||||
|
this.needSortFlag = needSortFlag;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean equals(final Object o) {
|
||||||
|
if (o == this) {
|
||||||
|
return true;
|
||||||
|
} else if (!(o instanceof SortingInfo)) {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
SortingInfo other = (SortingInfo)o;
|
||||||
|
if (!other.canEqual(this)) {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
Object this$desc = this.getDesc();
|
||||||
|
Object other$desc = other.getDesc();
|
||||||
|
if (this$desc == null) {
|
||||||
|
if (other$desc != null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else if (!this$desc.equals(other$desc)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Object this$needSortFlag = this.getNeedSortFlag();
|
||||||
|
Object other$needSortFlag = other.getNeedSortFlag();
|
||||||
|
if (this$needSortFlag == null) {
|
||||||
|
if (other$needSortFlag != null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else if (!this$needSortFlag.equals(other$needSortFlag)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Object this$selector = this.getSelector();
|
||||||
|
Object other$selector = other.getSelector();
|
||||||
|
if (this$selector == null) {
|
||||||
|
if (other$selector != null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else if (!this$selector.equals(other$selector)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected boolean canEqual(final Object other) {
|
||||||
|
return other instanceof SortingInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int hashCode() {
|
||||||
|
int PRIME = 59;
|
||||||
|
int result = 1;
|
||||||
|
Object $desc = this.getDesc();
|
||||||
|
result = result * 59 + ($desc == null ? 43 : $desc.hashCode());
|
||||||
|
Object $needSortFlag = this.getNeedSortFlag();
|
||||||
|
result = result * 59 + ($needSortFlag == null ? 43 : $needSortFlag.hashCode());
|
||||||
|
Object $selector = this.getSelector();
|
||||||
|
result = result * 59 + ($selector == null ? 43 : $selector.hashCode());
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString() {
|
||||||
|
return "SortingInfo(selector=" + this.getSelector() + ", desc=" + this.getDesc() + ", needSortFlag=" + this.getNeedSortFlag() + ")";
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,93 @@
|
|||||||
|
//
|
||||||
|
// Source code recreated from a .class file by IntelliJ IDEA
|
||||||
|
// (powered by FernFlower decompiler)
|
||||||
|
//
|
||||||
|
|
||||||
|
package com.yfd.platform.common;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
|
||||||
|
public class SummaryInfo {
|
||||||
|
@Schema(description = "计算总数的字段")
|
||||||
|
public String selector;
|
||||||
|
|
||||||
|
@Schema(description = "计算总数的类型")
|
||||||
|
public String summaryType;
|
||||||
|
|
||||||
|
public SummaryInfo() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public SummaryInfo(String selector, String summaryType) {
|
||||||
|
this.selector = selector;
|
||||||
|
this.summaryType = summaryType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSelector() {
|
||||||
|
return this.selector;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSummaryType() {
|
||||||
|
return this.summaryType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSelector(final String selector) {
|
||||||
|
this.selector = selector;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSummaryType(final String summaryType) {
|
||||||
|
this.summaryType = summaryType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean equals(final Object o) {
|
||||||
|
if (o == this) {
|
||||||
|
return true;
|
||||||
|
} else if (!(o instanceof SummaryInfo)) {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
SummaryInfo other = (SummaryInfo)o;
|
||||||
|
if (!other.canEqual(this)) {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
Object this$selector = this.getSelector();
|
||||||
|
Object other$selector = other.getSelector();
|
||||||
|
if (this$selector == null) {
|
||||||
|
if (other$selector != null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else if (!this$selector.equals(other$selector)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Object this$summaryType = this.getSummaryType();
|
||||||
|
Object other$summaryType = other.getSummaryType();
|
||||||
|
if (this$summaryType == null) {
|
||||||
|
if (other$summaryType != null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else if (!this$summaryType.equals(other$summaryType)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected boolean canEqual(final Object other) {
|
||||||
|
return other instanceof SummaryInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int hashCode() {
|
||||||
|
int PRIME = 59;
|
||||||
|
int result = 1;
|
||||||
|
Object $selector = this.getSelector();
|
||||||
|
result = result * 59 + ($selector == null ? 43 : $selector.hashCode());
|
||||||
|
Object $summaryType = this.getSummaryType();
|
||||||
|
result = result * 59 + ($summaryType == null ? 43 : $summaryType.hashCode());
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString() {
|
||||||
|
return "SummaryInfo(selector=" + this.getSelector() + ", summaryType=" + this.getSummaryType() + ")";
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,36 @@
|
|||||||
|
package com.yfd.platform.common.enums;
|
||||||
|
|
||||||
|
public enum QecIntervalEnum {
|
||||||
|
QEC_STLL_1_DY95("QEC_STLL_1_DY95","生态流量达标率所在统计区间:>=95%"),
|
||||||
|
QEC_STLL_2_90AND95("QEC_STLL_2_90AND95","生态流量达标率所在统计区间:90%~95%"),
|
||||||
|
QEC_STLL_3_80AND90("QEC_STLL_3_80AND90","生态流量达标率所在统计区间:80%~90%"),
|
||||||
|
QEC_STLL_4_XY80("QEC_STLL_4_XY80","生态流量达标率所在统计区间:<80%"),
|
||||||
|
QEC_STLL_5_EMPTY("QEC_STLL_5_EMPTY","无生态流量数据"),
|
||||||
|
QEC_STLL_6_NOEQMN("QEC_STLL_6_NOEQMN","无生态流量要求");
|
||||||
|
/** 变量类型 code */
|
||||||
|
private String code;
|
||||||
|
|
||||||
|
|
||||||
|
/** 描述. */
|
||||||
|
private String desc;
|
||||||
|
|
||||||
|
|
||||||
|
QecIntervalEnum(String code, String desc) {
|
||||||
|
this.code = code;
|
||||||
|
this.desc = desc;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the code - {返回值描述信息}.
|
||||||
|
*/
|
||||||
|
public String getCode() {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the desc - {返回值描述信息}.
|
||||||
|
*/
|
||||||
|
public String getDesc() {
|
||||||
|
return desc;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,22 @@
|
|||||||
|
package com.yfd.platform.common.enums;
|
||||||
|
|
||||||
|
public enum ShowEnum {
|
||||||
|
Q(1,"环评要求"),
|
||||||
|
M(2,"水利部要求"),
|
||||||
|
A(3,"多年平均流量10%"),
|
||||||
|
N(4,"无生态流量要求");
|
||||||
|
private Integer code;
|
||||||
|
private String desc;
|
||||||
|
|
||||||
|
ShowEnum(Integer code,String desc){
|
||||||
|
this.code=code;
|
||||||
|
this.desc=desc;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getCode(){
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
public String getDesc(){
|
||||||
|
return desc;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -2,18 +2,22 @@ package com.yfd.platform.config;
|
|||||||
|
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import cn.hutool.json.JSONUtil;
|
|
||||||
import cn.hutool.jwt.JWT;
|
import cn.hutool.jwt.JWT;
|
||||||
import cn.hutool.jwt.JWTUtil;
|
import cn.hutool.jwt.JWTUtil;
|
||||||
//import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.yfd.platform.component.ServerSendEventServer;
|
||||||
import com.yfd.platform.constant.Constant;
|
import com.yfd.platform.constant.Constant;
|
||||||
import com.yfd.platform.system.domain.LoginUser;
|
import com.yfd.platform.system.domain.LoginUser;
|
||||||
|
import com.yfd.platform.system.domain.Message;
|
||||||
|
import com.yfd.platform.system.service.IMessageService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
||||||
import org.springframework.security.core.context.SecurityContextHolder;
|
import org.springframework.security.core.context.SecurityContextHolder;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import org.springframework.web.filter.OncePerRequestFilter;
|
import org.springframework.web.filter.OncePerRequestFilter;
|
||||||
|
|
||||||
|
import jakarta.annotation.Resource;
|
||||||
import jakarta.servlet.FilterChain;
|
import jakarta.servlet.FilterChain;
|
||||||
import jakarta.servlet.ServletException;
|
import jakarta.servlet.ServletException;
|
||||||
import jakarta.servlet.http.HttpServletRequest;
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
@ -57,7 +61,7 @@ public class JwtAuthenticationTokenFilter extends OncePerRequestFilter {
|
|||||||
//从cachekey中获取用户信息
|
//从cachekey中获取用户信息
|
||||||
String cachekey = "login:" + userid;
|
String cachekey = "login:" + userid;
|
||||||
String jsonstr = webConfig.loginuserCache().get(cachekey);
|
String jsonstr = webConfig.loginuserCache().get(cachekey);
|
||||||
LoginUser loginUser = JSONUtil.toBean(jsonstr, LoginUser.class);
|
LoginUser loginUser = JSON.parseObject(jsonstr, LoginUser.class);
|
||||||
if (ObjectUtil.isEmpty(loginUser)) {
|
if (ObjectUtil.isEmpty(loginUser)) {
|
||||||
httpServletResponse.sendError(HttpServletResponse.SC_FORBIDDEN,
|
httpServletResponse.sendError(HttpServletResponse.SC_FORBIDDEN,
|
||||||
"登录用户已失效!");
|
"登录用户已失效!");
|
||||||
@ -1,14 +1,20 @@
|
|||||||
package com.yfd.platform.config;
|
package com.yfd.platform.config;
|
||||||
|
|
||||||
|
import cn.hutool.cache.Cache;
|
||||||
|
import cn.hutool.cache.impl.CacheObj;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.yfd.platform.component.ServerSendEventServer;
|
import com.yfd.platform.component.ServerSendEventServer;
|
||||||
import com.yfd.platform.constant.Constant;
|
import com.yfd.platform.constant.Constant;
|
||||||
import com.yfd.platform.system.domain.Message;
|
import com.yfd.platform.system.domain.Message;
|
||||||
|
import com.yfd.platform.system.domain.SysUser;
|
||||||
import com.yfd.platform.system.service.IMessageService;
|
import com.yfd.platform.system.service.IMessageService;
|
||||||
import com.yfd.platform.system.service.IUserService;
|
import com.yfd.platform.system.service.IUserService;
|
||||||
|
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
||||||
|
import org.springframework.security.core.context.SecurityContextHolder;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
|
import java.util.Iterator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author TangWei
|
* @author TangWei
|
||||||
@ -1,8 +1,8 @@
|
|||||||
package com.yfd.platform.config;
|
package com.yfd.platform.config;
|
||||||
|
|
||||||
import com.yfd.platform.config.bean.LoginProperties;
|
import com.yfd.platform.config.bean.LoginProperties;
|
||||||
import com.yfd.platform.system.exception.AccessDeniedHandExcetion;
|
import com.yfd.platform.exception.AccessDeniedHandExcetion;
|
||||||
import com.yfd.platform.system.exception.AuthenticationException;
|
import com.yfd.platform.exception.AuthenticationException;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
@ -53,6 +53,7 @@ public class SecurityConfig {
|
|||||||
.authorizeHttpRequests(auth -> auth
|
.authorizeHttpRequests(auth -> auth
|
||||||
.requestMatchers("/user/login").anonymous()
|
.requestMatchers("/user/login").anonymous()
|
||||||
.requestMatchers("/user/code").permitAll()
|
.requestMatchers("/user/code").permitAll()
|
||||||
|
.requestMatchers("/eng/**").permitAll()
|
||||||
.requestMatchers(HttpMethod.GET, "/").permitAll()
|
.requestMatchers(HttpMethod.GET, "/").permitAll()
|
||||||
.requestMatchers(HttpMethod.GET,
|
.requestMatchers(HttpMethod.GET,
|
||||||
"/*.html",
|
"/*.html",
|
||||||
@ -18,7 +18,7 @@ package com.yfd.platform.config.bean;
|
|||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import com.wf.captcha.*;
|
import com.wf.captcha.*;
|
||||||
import com.wf.captcha.base.Captcha;
|
import com.wf.captcha.base.Captcha;
|
||||||
import com.yfd.platform.system.exception.BadConfigurationException;
|
import com.yfd.platform.exception.BadConfigurationException;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
@ -17,7 +17,7 @@ package com.yfd.platform.config.thread;
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
import com.yfd.platform.common.utils.SpringContextHolder;
|
import com.yfd.platform.utils.SpringContextHolder;
|
||||||
|
|
||||||
import java.util.concurrent.ArrayBlockingQueue;
|
import java.util.concurrent.ArrayBlockingQueue;
|
||||||
import java.util.concurrent.ThreadPoolExecutor;
|
import java.util.concurrent.ThreadPoolExecutor;
|
||||||
@ -0,0 +1,54 @@
|
|||||||
|
package com.yfd.platform.eng.controller;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.yfd.platform.common.DataSourceRequest;
|
||||||
|
import com.yfd.platform.common.DataSourceResult;
|
||||||
|
import com.yfd.platform.config.ResponseResult;
|
||||||
|
import com.yfd.platform.eng.entity.vo.AlarmStcdCountVo;
|
||||||
|
import com.yfd.platform.eng.service.AlarmPointService;
|
||||||
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import jakarta.annotation.Resource;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 运行告警锚点控制器
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/eng/alarmPoint")
|
||||||
|
@Tag(name = "运行告警锚点控制器")
|
||||||
|
public class AlarmPointController {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 服务对象
|
||||||
|
*/
|
||||||
|
@Resource
|
||||||
|
private AlarmPointService alarmPointService;
|
||||||
|
|
||||||
|
@PostMapping({"/GetKendoListCust"})
|
||||||
|
@Operation(summary = "条件过滤数据列表定制")
|
||||||
|
public ResponseResult getKendoListCust(@RequestBody DataSourceRequest dataSourceRequest) {
|
||||||
|
Page page = new Page<>(dataSourceRequest.getPage(), dataSourceRequest.getPageSize());
|
||||||
|
Map<String, Object> filterResult = null; // 实际应该根据业务需求处理筛选
|
||||||
|
DataSourceResult<AlarmStcdCountVo> dataSourceResult = alarmPointService.processKendoList(dataSourceRequest, filterResult, page);
|
||||||
|
alarmPointService.processKendoGetListLoadResult(dataSourceRequest, dataSourceResult);
|
||||||
|
return ResponseResult.successData(dataSourceResult);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取警报统计数据
|
||||||
|
* @param stcd 电站ID
|
||||||
|
* @return 响应结果
|
||||||
|
*/
|
||||||
|
@PostMapping({"/getAlarmCount"})
|
||||||
|
@Operation(summary = "获取警报统计数据")
|
||||||
|
public ResponseResult getAlarmCount(String stcd) {
|
||||||
|
AlarmStcdCountVo vo = alarmPointService.getAlarmCount(stcd);
|
||||||
|
return ResponseResult.successData(vo);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,121 @@
|
|||||||
|
package com.yfd.platform.eng.controller;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.yfd.platform.common.DataSourceRequest;
|
||||||
|
import com.yfd.platform.common.DataSourceResult;
|
||||||
|
import com.yfd.platform.common.GroupResult;
|
||||||
|
import com.yfd.platform.config.ResponseResult;
|
||||||
|
import com.yfd.platform.eng.service.EngEqService;
|
||||||
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import jakarta.annotation.Resource;
|
||||||
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 电站生态流量统计查询
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/eng/eq/")
|
||||||
|
@Tag(name = "电站生态流量统计查询")
|
||||||
|
public class EngEqController {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 服务对象
|
||||||
|
*/
|
||||||
|
@Resource
|
||||||
|
private EngEqService msEngEqService;
|
||||||
|
|
||||||
|
@PostMapping({"/GetKendoListCust"})
|
||||||
|
@Operation(summary = "条件过滤数据列表定制")
|
||||||
|
public ResponseResult getKendoListCust(@RequestBody DataSourceRequest dataSourceRequest) {
|
||||||
|
Page page = new Page<>(dataSourceRequest.getPage(), dataSourceRequest.getPageSize());
|
||||||
|
Map<String, GroupResult> filterResult = null; // 实际应该根据业务需求处理筛选
|
||||||
|
DataSourceResult dataSourceResult = msEngEqService.processKendoList(dataSourceRequest, filterResult, page);
|
||||||
|
msEngEqService.processKendoGetListLoadResult(dataSourceRequest, dataSourceResult);
|
||||||
|
return ResponseResult.successData(dataSourceResult);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导出
|
||||||
|
* @param dataSourceRequest 数据源请求
|
||||||
|
* @param response 响应
|
||||||
|
*/
|
||||||
|
@PostMapping({"/export"})
|
||||||
|
@Operation(summary = "导出")
|
||||||
|
public void export(@RequestBody DataSourceRequest dataSourceRequest, HttpServletResponse response) {
|
||||||
|
// 实际应该实现导出逻辑
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 月统计数据有数据的电站
|
||||||
|
* @param dataSourceRequest 数据源请求
|
||||||
|
* @return 响应结果
|
||||||
|
*/
|
||||||
|
@PostMapping("/lastEngDataSite")
|
||||||
|
@Operation(summary = "查询指定时间有数据的站点")
|
||||||
|
public ResponseResult lastEngDataSite(@RequestBody DataSourceRequest dataSourceRequest) {
|
||||||
|
DataSourceResult result = msEngEqService.lastEngDataSite(dataSourceRequest);
|
||||||
|
return ResponseResult.successData(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/default/stcd")
|
||||||
|
@Operation(summary = "获取生态流量默认有数据的电站")
|
||||||
|
public ResponseResult getDefaultStcd(@RequestBody DataSourceRequest dataSourceRequest) {
|
||||||
|
DataSourceResult result = msEngEqService.getDefaultStcd(dataSourceRequest);
|
||||||
|
return ResponseResult.successData(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/getSfdbInfo")
|
||||||
|
@Operation(summary = "获取不达标详情数据")
|
||||||
|
public ResponseResult getSfdbInfo(@RequestBody DataSourceRequest dataSourceRequest) {
|
||||||
|
DataSourceResult result = msEngEqService.getSfdbInfo(dataSourceRequest);
|
||||||
|
return ResponseResult.successData(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping({"/qecSfdbCountByStcd"})
|
||||||
|
@Operation(summary = "生态流量不达标测站数")
|
||||||
|
public ResponseResult qecSfdbCountByStcd(@RequestBody DataSourceRequest dataSourceRequest) {
|
||||||
|
DataSourceResult result = msEngEqService.qecSfdbCountByStcd(dataSourceRequest);
|
||||||
|
return ResponseResult.successData(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生态流量达标率计算(基地维度、不达标原因维度)
|
||||||
|
* @param dataSourceRequest 数据源请求
|
||||||
|
* @return 响应结果
|
||||||
|
*/
|
||||||
|
@PostMapping({"/qecRateCount"})
|
||||||
|
@Operation(summary = "生态流量达标率计算(基地维度、不达标原因维度)")
|
||||||
|
public ResponseResult qecRateCount(@RequestBody DataSourceRequest dataSourceRequest) {
|
||||||
|
DataSourceResult result = msEngEqService.qecRateCount(dataSourceRequest);
|
||||||
|
return ResponseResult.successData(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生态流量不达标数量计算(电站维度、不达标原因维度)
|
||||||
|
* @param dataSourceRequest 数据源请求
|
||||||
|
* @return 响应结果
|
||||||
|
*/
|
||||||
|
@PostMapping({"/qecSfdbCount"})
|
||||||
|
@Operation(summary = "生态流量不达标数量计算(电站维度、不达标原因维度)")
|
||||||
|
public ResponseResult qecSfdbCount(@RequestBody DataSourceRequest dataSourceRequest) {
|
||||||
|
DataSourceResult result = msEngEqService.qecSfdbCount(dataSourceRequest);
|
||||||
|
return ResponseResult.successData(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping({"/group/GetKendoListCust"})
|
||||||
|
public ResponseResult getGroupKendoListCust(@RequestBody DataSourceRequest dataSourceRequest) {
|
||||||
|
Page page = new Page<>(dataSourceRequest.getPage(), dataSourceRequest.getPageSize());
|
||||||
|
Map<String, GroupResult> filterResult = null; // 实际应该根据业务需求处理筛选
|
||||||
|
DataSourceResult dataSourceResult = msEngEqService.processKendoList(dataSourceRequest, filterResult, page);
|
||||||
|
msEngEqService.processKendoGetListLoadResult(dataSourceRequest, dataSourceResult);
|
||||||
|
return ResponseResult.successData(dataSourceResult);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,108 @@
|
|||||||
|
package com.yfd.platform.eng.controller;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.yfd.platform.common.DataSourceRequest;
|
||||||
|
import com.yfd.platform.common.DataSourceResult;
|
||||||
|
import com.yfd.platform.config.ResponseResult;
|
||||||
|
import com.yfd.platform.eng.service.EngEqDataService;
|
||||||
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import jakarta.annotation.Resource;
|
||||||
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 电站实时数据查询
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/eng/eq/data")
|
||||||
|
@Tag(name = "电站实时数据查询")
|
||||||
|
public class EngEqDataController {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 服务对象
|
||||||
|
*/
|
||||||
|
@Resource
|
||||||
|
private EngEqDataService engEqDataService;
|
||||||
|
|
||||||
|
@PostMapping({"/GetKendoListCust"})
|
||||||
|
@Operation(summary = "生态流量沿程变化-小时")
|
||||||
|
public ResponseResult getKendoListCust(@RequestBody DataSourceRequest dataSourceRequest) {
|
||||||
|
Page page = new Page<>(dataSourceRequest.getPage(), dataSourceRequest.getPageSize());
|
||||||
|
Map<String, Object> filterResult = null; // 实际应该根据业务需求处理筛选
|
||||||
|
DataSourceResult dataSourceResult = engEqDataService.processKendoList(dataSourceRequest, filterResult, page);
|
||||||
|
engEqDataService.processKendoGetListLoadResult(dataSourceRequest, dataSourceResult);
|
||||||
|
return ResponseResult.successData(dataSourceResult);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导出
|
||||||
|
* @param dataSourceRequest 数据源请求
|
||||||
|
* @param response 响应
|
||||||
|
*/
|
||||||
|
@PostMapping({"/export"})
|
||||||
|
@Operation(summary = "导出")
|
||||||
|
public void export(@RequestBody DataSourceRequest dataSourceRequest, HttpServletResponse response) {
|
||||||
|
// 实际应该实现导出逻辑
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping({"/day/GetKendoListCust"})
|
||||||
|
@Operation(summary = "查询生态流量 日 数据")
|
||||||
|
public ResponseResult getKendoDayListCust(@RequestBody DataSourceRequest dataSourceRequest) {
|
||||||
|
Page page = new Page<>(dataSourceRequest.getPage(), dataSourceRequest.getPageSize());
|
||||||
|
Map<String, Object> filterResult = null; // 实际应该根据业务需求处理筛选
|
||||||
|
String groupBy = ""; // 实际应该根据业务需求处理分组
|
||||||
|
DataSourceResult dataSourceResult = engEqDataService.processDayKendoList(dataSourceRequest, filterResult, page, groupBy);
|
||||||
|
engEqDataService.processKendoGetListLoadResult(dataSourceRequest, dataSourceResult);
|
||||||
|
return ResponseResult.successData(dataSourceResult);
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping({"/drtp/GetKendoListCust"})
|
||||||
|
@Operation(summary = "查询生态流量 周旬月季年 数据")
|
||||||
|
public ResponseResult getKendoDrtpListCust(@RequestBody DataSourceRequest dataSourceRequest) {
|
||||||
|
Page page = new Page<>(dataSourceRequest.getPage(), dataSourceRequest.getPageSize());
|
||||||
|
Map<String, Object> filterResult = null; // 实际应该根据业务需求处理筛选
|
||||||
|
String groupBy = ""; // 实际应该根据业务需求处理分组
|
||||||
|
DataSourceResult dataSourceResult = engEqDataService.processKendoDrtpList(dataSourceRequest, filterResult, page, groupBy);
|
||||||
|
engEqDataService.processKendoGetListLoadResult(dataSourceRequest, dataSourceResult);
|
||||||
|
return ResponseResult.successData(dataSourceResult);
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping({"/fastSiteLastData/GetKendoListCust"})
|
||||||
|
@Operation(summary = "查询沿程第一个电站的生态流量数据时间")
|
||||||
|
public ResponseResult getFastSiteLastData(@RequestBody DataSourceRequest dataSourceRequest) {
|
||||||
|
Page page = new Page<>(dataSourceRequest.getPage(), dataSourceRequest.getPageSize());
|
||||||
|
Map<String, Object> filterResult = null; // 实际应该根据业务需求处理筛选
|
||||||
|
String groupBy = ""; // 实际应该根据业务需求处理分组
|
||||||
|
DataSourceResult dataSourceResult = engEqDataService.getFastSiteLastData(dataSourceRequest, filterResult, page, groupBy);
|
||||||
|
engEqDataService.processKendoGetListLoadResult(dataSourceRequest, dataSourceResult);
|
||||||
|
return ResponseResult.successData(dataSourceResult);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生态流量沿程变化(面板)
|
||||||
|
* @param dataSourceRequest 数据源请求
|
||||||
|
* @return 响应结果
|
||||||
|
*/
|
||||||
|
@PostMapping({"/along/GetKendoListCust"})
|
||||||
|
@Operation(summary = "查询生态流量(沿程数据)")
|
||||||
|
public ResponseResult getKendoAlongListCust(@RequestBody DataSourceRequest dataSourceRequest) {
|
||||||
|
Page page = new Page<>(dataSourceRequest.getPage(), dataSourceRequest.getPageSize());
|
||||||
|
Map<String, Object> filterResult = null; // 实际应该根据业务需求处理筛选
|
||||||
|
DataSourceResult dataSourceResult = engEqDataService.processKendoList(dataSourceRequest, filterResult, page);
|
||||||
|
engEqDataService.processKendoGetListLoadResult(dataSourceRequest, dataSourceResult);
|
||||||
|
return ResponseResult.successData(dataSourceResult);
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping({"/getEngLimit"})
|
||||||
|
@Operation(summary = "根据时间范围查询电站生态流量限值及来源")
|
||||||
|
public ResponseResult getEngLimit(@RequestBody DataSourceRequest dataSourceRequest) {
|
||||||
|
Object result = engEqDataService.getEngLimit(dataSourceRequest);
|
||||||
|
return ResponseResult.successData(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,131 @@
|
|||||||
|
package com.yfd.platform.eng.controller;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.yfd.platform.annotation.Log;
|
||||||
|
import com.yfd.platform.common.DataSourceLoadOptionsBase;
|
||||||
|
import com.yfd.platform.common.DataSourceRequest;
|
||||||
|
import com.yfd.platform.common.DataSourceResult;
|
||||||
|
import com.yfd.platform.config.ResponseResult;
|
||||||
|
import com.yfd.platform.eng.domain.MsEngEq;
|
||||||
|
import com.yfd.platform.eng.service.EngEqIntervalService;
|
||||||
|
import com.yfd.platform.eng.service.EngEqService;
|
||||||
|
import com.yfd.platform.utils.KendoUtil;
|
||||||
|
import com.yfd.platform.utils.QgcQueryWrapperUtil;
|
||||||
|
import com.yfd.platform.utils.QueryWrapperUtil;
|
||||||
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import jakarta.annotation.Resource;
|
||||||
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生态流量区间统计控制器
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/eng/eq/interval")
|
||||||
|
@Tag(name = "电站生态流量区间统计查询")
|
||||||
|
public class EngEqIntervalController {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 服务对象
|
||||||
|
*/
|
||||||
|
@Resource
|
||||||
|
private EngEqIntervalService eqIntervalService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private EngEqService engEqService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生态流量达标情况
|
||||||
|
* @param dataSourceRequest 数据源请求
|
||||||
|
* @return 响应结果
|
||||||
|
*/
|
||||||
|
@PostMapping({"/GetKendoListCust"})
|
||||||
|
@Operation(summary = "生态流量达标情况")
|
||||||
|
public ResponseResult getKendoListCust(@RequestBody DataSourceRequest dataSourceRequest) {
|
||||||
|
Page<MsEngEq> page = new Page<>(dataSourceRequest.getPage(), dataSourceRequest.getPageSize());
|
||||||
|
Map<String, Object> filterResult = null; // 实际应该根据业务需求处理筛选
|
||||||
|
DataSourceResult result = eqIntervalService.processKendoList(dataSourceRequest, filterResult, page);
|
||||||
|
eqIntervalService.processKendoGetListLoadResult(dataSourceRequest, result);
|
||||||
|
return ResponseResult.successData(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导出
|
||||||
|
* @param dataSourceRequest 数据源请求
|
||||||
|
* @param response 响应
|
||||||
|
*/
|
||||||
|
@PostMapping({"/export"})
|
||||||
|
@Operation(summary = "导出")
|
||||||
|
@Log(module = "生态流量", value = "导出生态流量数据")
|
||||||
|
public void export(@RequestBody DataSourceRequest dataSourceRequest, HttpServletResponse response) {
|
||||||
|
// 实际应该实现导出逻辑
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生态流量达标率 小时统计(二级页面)
|
||||||
|
* @param dataSourceRequest 数据源请求
|
||||||
|
* @return 响应结果
|
||||||
|
*/
|
||||||
|
@PostMapping({"/qgc/hour/GetKendoListCust"})
|
||||||
|
@Operation(summary = "生态流量达标率 小时统计(二级页面)")
|
||||||
|
public ResponseResult getQgcHourKendoListCust(@RequestBody DataSourceRequest dataSourceRequest) {
|
||||||
|
String kendoGroupCode = "EngEqHour";
|
||||||
|
// Map<String, GroupResult> filterResult = KendoUtil.getGroupResultMap(dataSourceRequest, null, EngEqIntervalController.class);
|
||||||
|
// String groupBy = KendoUtil.getGroupBy(dataSourceRequest);
|
||||||
|
Page page = KendoUtil.getPage(dataSourceRequest);
|
||||||
|
DataSourceResult result = eqIntervalService.getQgcHourKendoListCust(dataSourceRequest, null, page, null);
|
||||||
|
// eqIntervalService.processKendoGetListLoadResult(dataSourceRequest, result);
|
||||||
|
return ResponseResult.successData(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生态流量达标率 日统计(二级页面)
|
||||||
|
* @param dataSourceRequest 数据源请求
|
||||||
|
* @return 响应结果
|
||||||
|
*/
|
||||||
|
@PostMapping({"/qgc/day/GetKendoListCust"})
|
||||||
|
@Operation(summary = "生态流量达标率 日统计(二级页面)")
|
||||||
|
public ResponseResult getQgcDayKendoListCust(@RequestBody DataSourceRequest dataSourceRequest) {
|
||||||
|
Page<MsEngEq> page = new Page<>(dataSourceRequest.getPage(), dataSourceRequest.getPageSize());
|
||||||
|
Map<String, Object> filterResult = null; // 实际应该根据业务需求处理筛选
|
||||||
|
String groupBy = ""; // 实际应该根据业务需求处理分组
|
||||||
|
DataSourceResult result = eqIntervalService.getQgcDayKendoListCust(dataSourceRequest, filterResult, page, groupBy);
|
||||||
|
eqIntervalService.processKendoGetListLoadResult(dataSourceRequest, result);
|
||||||
|
return ResponseResult.successData(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生态流量达标率 区间范围统计(一级页面)
|
||||||
|
* @param dataSourceRequest 数据源请求
|
||||||
|
* @return 响应结果
|
||||||
|
*/
|
||||||
|
@PostMapping({"/qgc/getQgcStaticData"})
|
||||||
|
@Operation(summary = "生态流量达标率 区间范围统计(一级页面)")
|
||||||
|
// @Log(module = "生态流量", value = "生态流量达标率统计")
|
||||||
|
public ResponseResult getQgcStaticData(@RequestBody DataSourceRequest dataSourceRequest) {
|
||||||
|
DataSourceLoadOptionsBase loadOptionsBase = dataSourceRequest.toDevRequest();
|
||||||
|
String type = QgcQueryWrapperUtil.getFilterFieldValue(loadOptionsBase, "type");
|
||||||
|
ResponseResult r;
|
||||||
|
if("hour".equals(type)){
|
||||||
|
r = this.getQgcHourKendoListCust(dataSourceRequest);
|
||||||
|
}else if("day".equals(type)){
|
||||||
|
r = this.getQgcDayKendoListCust(dataSourceRequest);
|
||||||
|
}else{
|
||||||
|
return ResponseResult.error("请选择生态流量达标率统计类型(小时还是天统计)");
|
||||||
|
}
|
||||||
|
if(r != null && r.get("code").equals("0") && r.get("data") != null){
|
||||||
|
DataSourceResult dataSourceResult = (DataSourceResult) r.get("data");
|
||||||
|
if(dataSourceResult != null && dataSourceResult.getData() != null){
|
||||||
|
Map<String, Object> staticData = eqIntervalService.getQgcQecStaticData(dataSourceResult.getData(), type);
|
||||||
|
return ResponseResult.successData(staticData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ResponseResult.success();
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,54 @@
|
|||||||
|
package com.yfd.platform.eng.controller;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.yfd.platform.common.DataSourceRequest;
|
||||||
|
import com.yfd.platform.common.DataSourceResult;
|
||||||
|
import com.yfd.platform.common.GroupResult;
|
||||||
|
import com.yfd.platform.config.ResponseResult;
|
||||||
|
import com.yfd.platform.eng.service.EngEqService;
|
||||||
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import jakarta.annotation.Resource;
|
||||||
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 电站生态流量统计结果查询
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/eng/eq/stat")
|
||||||
|
@Tag(name = "电站生态流量统计结果查询")
|
||||||
|
public class EngEqStatController {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 服务对象
|
||||||
|
*/
|
||||||
|
@Resource
|
||||||
|
private EngEqService msEngEqService;
|
||||||
|
|
||||||
|
@PostMapping({"/GetKendoListCust"})
|
||||||
|
@Operation(summary = "条件过滤数据列表定制")
|
||||||
|
public ResponseResult getKendoListCust(@RequestBody DataSourceRequest dataSourceRequest) {
|
||||||
|
Page page = new Page<>(dataSourceRequest.getPage(), dataSourceRequest.getPageSize());
|
||||||
|
Map<String, GroupResult> filterResult = null; // 实际应该根据业务需求处理筛选
|
||||||
|
DataSourceResult dataSourceResult = msEngEqService.processKendoList(dataSourceRequest, filterResult, page);
|
||||||
|
msEngEqService.processKendoGetListLoadResult(dataSourceRequest, dataSourceResult);
|
||||||
|
return ResponseResult.successData(dataSourceResult);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导出
|
||||||
|
* @param dataSourceRequest 数据源请求
|
||||||
|
* @param response 响应
|
||||||
|
*/
|
||||||
|
@PostMapping({"/export"})
|
||||||
|
@Operation(summary = "导出")
|
||||||
|
public void export(@RequestBody DataSourceRequest dataSourceRequest, HttpServletResponse response) {
|
||||||
|
// 实际应该实现导出逻辑
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,42 @@
|
|||||||
|
package com.yfd.platform.eng.controller;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.yfd.platform.common.DataSourceRequest;
|
||||||
|
import com.yfd.platform.common.DataSourceResult;
|
||||||
|
import com.yfd.platform.config.ResponseResult;
|
||||||
|
import com.yfd.platform.eng.entity.EqSpecial;
|
||||||
|
import com.yfd.platform.eng.service.EngSpecialService;
|
||||||
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import jakarta.annotation.Resource;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 电站专题-环保设施运行情况
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/eng/special")
|
||||||
|
@Tag(name = "电站专题-环保设施运行情况")
|
||||||
|
public class EngSpecialController {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 服务对象
|
||||||
|
*/
|
||||||
|
@Resource
|
||||||
|
private EngSpecialService engSpecialService;
|
||||||
|
|
||||||
|
@PostMapping({"/GetKendoListCust"})
|
||||||
|
@Operation(summary = "条件过滤数据列表定制")
|
||||||
|
public ResponseResult getKendoListCust(@RequestBody DataSourceRequest dataSourceRequest) {
|
||||||
|
Page page = new Page<>(dataSourceRequest.getPage(), dataSourceRequest.getPageSize());
|
||||||
|
Map<String, Object> filterResult = null; // 实际应该根据业务需求处理筛选
|
||||||
|
DataSourceResult<EqSpecial> dataSourceResult = engSpecialService.processKendoList(dataSourceRequest, filterResult, page);
|
||||||
|
engSpecialService.processKendoGetListLoadResult(dataSourceRequest, dataSourceResult);
|
||||||
|
return ResponseResult.successData(dataSourceResult);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,61 @@
|
|||||||
|
package com.yfd.platform.eng.domain;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生态流量实体类
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@TableName("ms_eng_eq")
|
||||||
|
public class MsEngEq implements Serializable {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 主键
|
||||||
|
*/
|
||||||
|
private String id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 电站ID
|
||||||
|
*/
|
||||||
|
private String stationId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 电站名称
|
||||||
|
*/
|
||||||
|
private String stationName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 时间
|
||||||
|
*/
|
||||||
|
private Date time;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生态流量值
|
||||||
|
*/
|
||||||
|
private Double eqValue;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 达标状态
|
||||||
|
*/
|
||||||
|
private String status;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 统计类型(hour/day)
|
||||||
|
*/
|
||||||
|
private String type;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建时间
|
||||||
|
*/
|
||||||
|
private Date createTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新时间
|
||||||
|
*/
|
||||||
|
private Date updateTime;
|
||||||
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user