Commit df2f89e0 authored by luben's avatar luben

1

parent 191df7f7
This diff is collapsed.
This diff is collapsed.
...@@ -3,6 +3,8 @@ ...@@ -3,6 +3,8 @@
<component name="Encoding" defaultCharsetForPropertiesFiles="UTF-8"> <component name="Encoding" defaultCharsetForPropertiesFiles="UTF-8">
<file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" /> <file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/src/main/resources" charset="UTF-8" /> <file url="file://$PROJECT_DIR$/src/main/resources" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/../../untitled/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/../../untitled/src/main/resources" charset="UTF-8" />
<file url="PROJECT" charset="UTF-8" /> <file url="PROJECT" charset="UTF-8" />
</component> </component>
</project> </project>
\ No newline at end of file
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
<option name="originalFiles"> <option name="originalFiles">
<list> <list>
<option value="$PROJECT_DIR$/pom.xml" /> <option value="$PROJECT_DIR$/pom.xml" />
<option value="$PROJECT_DIR$/../../untitled/pom.xml" />
</list> </list>
</option> </option>
</component> </component>
......
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
</component>
</project>
\ No newline at end of file
<?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/maven-v4_0_0.xsd">
<parent>
<artifactId>spring-boot-dependencies</artifactId>
<groupId>org.springframework.boot</groupId>
<version>2.3.3.RELEASE</version>
<relativePath>../pom.xml/pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>com.ruoyi</groupId>
<artifactId>untitled</artifactId>
<version>1.0-SNAPSHOT</version>
<build>
<finalName>untitled</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer>
<mainClass>com.ruoyi.StartApplication</mainClass>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>Service</groupId>
<artifactId>service</artifactId>
<version>2.0.0</version>
<scope>system</scope>
<systemPath>${project.basedir}/src/main/lib/service-invoke-sdk-2.0.0-SNAPSHOT.jar</systemPath>
</dependency>
</dependencies>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
</properties>
</project>
...@@ -72,11 +72,9 @@ ...@@ -72,11 +72,9 @@
</dependency> </dependency>
<dependency> <dependency>
<groupId>Service</groupId> <groupId>com.sefonsoft.cloud.govern</groupId>
<artifactId>service</artifactId> <artifactId>service-invoke-sdk</artifactId>
<version>2.0.0</version> <version>2.0.0-SNAPSHOT</version>
<scope>system</scope>
<systemPath>${project.basedir}/src/main/java/libs/service-invoke-sdk-2.0.0-SNAPSHOT.jar</systemPath>
</dependency> </dependency>
<!-- 阿里JSON解析器 --> <!-- 阿里JSON解析器 -->
...@@ -117,6 +115,17 @@ ...@@ -117,6 +115,17 @@
</executions> </executions>
</plugin> </plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<fork>true</fork>
<mainClass>com.ruoyi.StartApplication</mainClass>
<includeSystemScope>true</includeSystemScope>
</configuration>
</plugin>
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId> <artifactId>maven-shade-plugin</artifactId>
...@@ -142,6 +151,39 @@ ...@@ -142,6 +151,39 @@
</plugins> </plugins>
</build> </build>
<repositories>
<repository>
<id>public</id>
<name>aliyun nexus</name>
<url>https://maven.aliyun.com/repository/public</url>
<releases>
<enabled>true</enabled>
</releases>
</repository>
<repository>
<id>rdc-releases</id>
<url>https://packages.aliyun.com/maven/repository/2283650-release-rhQZ6Q/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
<updatePolicy>always</updatePolicy>
</snapshots>
</repository>
<repository>
<id>rdc-snapshots</id>
<url>https://packages.aliyun.com/maven/repository/2283650-snapshot-Qfwnvj/</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</snapshots>
</repository>
</repositories>
</project> </project>
\ No newline at end of file
Manifest-Version: 1.0
Main-Class: com.ruoyi.StartApplication
...@@ -3,13 +3,12 @@ package com.ruoyi; ...@@ -3,13 +3,12 @@ package com.ruoyi;
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.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.scheduling.annotation.EnableScheduling; import org.springframework.scheduling.annotation.EnableScheduling;
@EnableScheduling @EnableScheduling
@SpringBootApplication @SpringBootApplication
@MapperScan("com.ruoyi.generator.mapper") @MapperScan("com.ruoyi.getInfo.mapper")
public class StartApplication { public class StartApplication {
public static void main(String[] args) { public static void main(String[] args) {
......
package com.ruoyi.generator.utils;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.ruoyi.generator.domain.getInfoDomain;
import com.ruoyi.generator.service.getInfoService;
//import com.sefonsoft.cloud.govern.service.invoke.ServiceSdk;
//import com.sefonsoft.cloud.govern.service.invoke.domain.*;
//import com.sefonsoft.cloud.govern.service.invoke.utils.Tools;
import com.ruoyi.service.ServiceSdk;
import com.ruoyi.service.domain.*;
import com.ruoyi.service.utils.Tools;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import org.slf4j.*;
@Component("ServiceSdkTest")
public class ServiceSdkTest {
@Autowired
getInfoService infoService;
public static final Logger LOGGER = LoggerFactory.getLogger(ServiceSdkTest.class);
private static String url ="https://2.19.247.137:18199/data-service/gateway/v2.0/data-service";
private static String userId="a_sunjiyuan05033655";
//订阅ID
private static String subServiceId = "1827987788174319616";
//应用系统标识
private static String applicationId = "SYS001";
//认证token
private static String accessToken = "1827987788174319617";
//第一次请求时nextToken位空,下次请求从上次请求的结果中获取nextToken
private static String nextToken = "";
// @Scheduled(fixedRate = 36000000)
public void getData() throws Exception {
DataServiceRequestDTO req = null;
int size = 1000;
int currentSize = 1;
//currentSize==0 的时候说明没有获取到数据,break
while(currentSize != 0){
//nextToken判断是否为第一次
if(Tools.isNull(nextToken)){
List<ServiceRequestFieldDTO> mustFields = new ArrayList<ServiceRequestFieldDTO>();
//
mustFields.add(new ServiceRequestFieldDTO("areaId","c..","eq","1591285477854248961"));
List<ServiceRequestFieldDTO> shouldFields = new ArrayList<ServiceRequestFieldDTO>();
DateTime date = DateUtil.date();
DateTime today = DateUtil.beginOfDay(date);
//or 一天执行一次 获取当天日期之前的数据
shouldFields.add(new ServiceRequestFieldDTO("create_date","dt","le",today));
shouldFields.add(new ServiceRequestFieldDTO("delete_date","dt","le",today));
shouldFields.add(new ServiceRequestFieldDTO("update_date","dt","le",today));
//查询条件
DataQuery query = new DataQuery.Builder()
.must(mustFields)
.should(shouldFields)
.build();
//
req = new DataServiceRequestDTO.Builder()
.size(size)
.includeColumns(true)
.dataQuery(query)
.sort(new SortDTO("id","asc"))
.build();
} else {
//如果非第一次查询,那么nextToken非空
req = new DataServiceRequestDTO.Builder()
.size(size)
.nextToken(nextToken) //翻页token,必填参数
.includeColumns(false)
.build();
}
//获取本次result
String result = ServiceSdk.invoke(url,req,userId,subServiceId,applicationId,accessToken);
// String data = JSONUtil.parseObj(result).get("data").toString();
// nextToken = JSONUtil.parseObj(data).get("next_token").toString();
JSONObject JsonData = JSONUtil.parseObj(JSONUtil.parseObj(result).get("data").toString());
//转为JSONObject 获取nextToken以及当前页查询数量
nextToken = JsonData.get("next_token").toString();
currentSize = JsonData.getInt("currentSize");
//遍历数据存储
JSONArray jsonArray = JsonData.getJSONArray("list");
for(int i =0; i<jsonArray.size(); i++){
JSONObject data = jsonArray.getJSONObject(i);
getInfoDomain domain = new getInfoDomain();
domain.setId(data.get("id").toString());
domain.setCreateDate((Date) data.get("createDate"));
domain.setCreater(data.get("creater").toString());
domain.setUpdateDate((Date) data.get("updateDate"));
domain.setUpdater(data.get("updater").toString());
domain.setDeleteDate((Date) data.get("deleteDate"));
domain.setDeleter(data.get("deleter").toString());
domain.setRemark(data.get("remark").toString());
domain.setSort((Integer) data.get("sort"));
domain.setSts(data.get("sts").toString());
domain.setAreaId(data.get("areaId").toString());
domain.setCompanyName(data.get("companyName").toString());
domain.setDescription(data.get("description").toString());
domain.setGreat((Integer) data.get("great"));
domain.setInvest((Integer) data.get("invest"));
domain.setMapAddr(data.get("mapAddr").toString());
domain.setMode(data.get("mode").toString());
domain.setProjectAddr(data.get("projectAddr").toString());
domain.setProjectName(data.get("projectName").toString());
domain.setRecordCode(data.get("recordCode").toString());
domain.setRecordDate((Date) data.get("recordDate"));
domain.setStage(data.get("stage").toString());
int num = infoService.addInfo(domain);
LOGGER.info("本次导入{}条数据",num);
}
}
}
}
package com.ruoyi.generator.domain; package com.ruoyi.getInfo.domain;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data; import lombok.Data;
import java.util.Date; import java.util.Date;
@Data @Data
@TableName("t_project")
public class getInfoDomain { public class getInfoDomain {
private String id; private String id;
......
package com.ruoyi.generator.mapper; package com.ruoyi.getInfo.mapper;
import com.ruoyi.generator.domain.getInfoDomain; import com.ruoyi.getInfo.domain.getInfoDomain;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
@Mapper @Mapper
......
package com.ruoyi.generator.service; package com.ruoyi.getInfo.service;
import com.ruoyi.generator.domain.getInfoDomain; import com.ruoyi.getInfo.domain.getInfoDomain;
public interface getInfoService { public interface getInfoService {
......
package com.ruoyi.generator.service.impl; package com.ruoyi.getInfo.service.impl;
import com.ruoyi.generator.domain.getInfoDomain; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ruoyi.generator.mapper.getInfoMapper; import com.ruoyi.getInfo.domain.getInfoDomain;
import com.ruoyi.generator.service.getInfoService; import com.ruoyi.getInfo.mapper.getInfoMapper;
import com.ruoyi.getInfo.service.getInfoService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -15,6 +16,7 @@ public class getInfoServiceImpl implements getInfoService { ...@@ -15,6 +16,7 @@ public class getInfoServiceImpl implements getInfoService {
@Override @Override
public int addInfo(getInfoDomain info) { public int addInfo(getInfoDomain info) {
return getinfomapper.addInfo(info); return getinfomapper.addInfo(info);
} }
} }
package com.ruoyi.generator.utils; package com.ruoyi.getInfo.utils;
import cn.hutool.core.date.DateTime; import cn.hutool.core.date.DateTime;
...@@ -6,8 +6,8 @@ import cn.hutool.core.date.DateUtil; ...@@ -6,8 +6,8 @@ import cn.hutool.core.date.DateUtil;
import cn.hutool.json.JSONArray; import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONObject; import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil; import cn.hutool.json.JSONUtil;
import com.ruoyi.generator.domain.getInfoDomain; import com.ruoyi.getInfo.domain.getInfoDomain;
import com.ruoyi.generator.service.getInfoService; import com.ruoyi.getInfo.service.getInfoService;
import com.sefonsoft.cloud.govern.service.invoke.ServiceSdk; import com.sefonsoft.cloud.govern.service.invoke.ServiceSdk;
import com.sefonsoft.cloud.govern.service.invoke.domain.DataQuery; import com.sefonsoft.cloud.govern.service.invoke.domain.DataQuery;
import com.sefonsoft.cloud.govern.service.invoke.domain.DataServiceRequestDTO; import com.sefonsoft.cloud.govern.service.invoke.domain.DataServiceRequestDTO;
...@@ -27,7 +27,7 @@ import org.springframework.stereotype.Component; ...@@ -27,7 +27,7 @@ import org.springframework.stereotype.Component;
public class ServiceSdkT { public class ServiceSdkT {
@Autowired @Autowired
getInfoService infoService; getInfoService infoService;
public static final Logger LOGGER = LoggerFactory.getLogger(ServiceSdkTest.class); public static final Logger LOGGER = LoggerFactory.getLogger(ServiceSdkT.class);
private static String url = "https://2.19.247.137:18199/data-service/gateway/v2.0/data-service"; private static String url = "https://2.19.247.137:18199/data-service/gateway/v2.0/data-service";
private static String userId = "a_sunjiyuan05033655"; private static String userId = "a_sunjiyuan05033655";
private static String subServiceId = "1827987788174319616"; private static String subServiceId = "1827987788174319616";
...@@ -39,11 +39,11 @@ public class ServiceSdkT { ...@@ -39,11 +39,11 @@ public class ServiceSdkT {
} }
@Scheduled( @Scheduled(
fixedRate = 36000000L fixedRate = 5L
) )
public void getData() throws Exception { public void getData() throws Exception {
DataServiceRequestDTO req = null; DataServiceRequestDTO req = null;
int size = 1000; int size = 2000;
int currentSize = 1; int currentSize = 1;
while(currentSize != 0) { while(currentSize != 0) {
......
package com.ruoyi.service;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.ruoyi.service.client.HttpClient;
import com.ruoyi.service.constants.SignatureMethod;
import com.ruoyi.service.constants.SignatureVersion;
import com.ruoyi.service.domain.APIRequestDTO;
import com.ruoyi.service.domain.AuthInfo;
import com.ruoyi.service.utils.HttpUtils;
import com.ruoyi.service.utils.IdentifyTools;
import okhttp3.Request;
import okhttp3.Response;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class ServiceSdk {
private static final Logger logger = LoggerFactory.getLogger(com.ruoyi.service.ServiceSdk.class);
public ServiceSdk() {
}
public static String invoke(String url, APIRequestDTO request, String userId, String subServiceId, String applicationId, String accessToken) throws Exception {
logger.info("start request data");
AuthInfo auth = new AuthInfo(userId, SignatureVersion.VERSION2.getCode(), "UTF-8");
String signatureMethod = (SignatureVersion.VERSION2.getCode().equals(auth.getSignatureVersion()) ? SignatureMethod.HmacSHA256 : SignatureMethod.HmacSHA1).getCode();
String signStr = IdentifyTools.sign(JSONObject.toJSONString(auth), accessToken, signatureMethod, auth.getEncoding());
auth.setSignature(signStr);
request.setAuthInfo(auth);
request.setApplicationId(applicationId);
request.setSubServiceId(subServiceId);
Request httpRequest = HttpUtils.createHttpRequest(url, JSON.toJSONString(request));
Response response = HttpClient.getInstance().getClient().newCall(httpRequest).execute();
logger.info("request data finished");
return HttpUtils.readBody(response);
}
}
package com.ruoyi.service.client;
import java.security.SecureRandom;
import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;
import java.util.concurrent.TimeUnit;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.KeyManager;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSession;
import javax.net.ssl.SSLSocketFactory;
import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;
import com.ruoyi.service.client.HttpConfig;
import okhttp3.ConnectionPool;
import okhttp3.OkHttpClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class HttpClient {
private static final Logger LOG = LoggerFactory.getLogger(com.ruoyi.service.client.HttpClient.class);
private static com.ruoyi.service.client.HttpClient httpClient = null;
private OkHttpClient okHttpClient;
private HttpClient() {
this.initOkHttpClient();
}
public static com.ruoyi.service.client.HttpClient getInstance() {
if (null == httpClient) {
Class var0 = com.ruoyi.service.client.HttpClient.class;
synchronized(com.ruoyi.service.client.HttpClient.class) {
if (null == httpClient) {
httpClient = new com.ruoyi.service.client.HttpClient();
}
}
}
return httpClient;
}
public OkHttpClient getClient() {
return this.okHttpClient;
}
private void initOkHttpClient() {
this.okHttpClient = this.okHttpClient();
}
private OkHttpClient okHttpClient() {
return (new OkHttpClient.Builder()).sslSocketFactory(this.sslSocketFactory(), this.x509TrustManager()).hostnameVerifier(new HostnameVerifier() {
public boolean verify(String s, SSLSession sslSession) {
return true;
}
}).retryOnConnectionFailure(false).connectionPool(this.pool()).connectTimeout((long) HttpConfig.connectTimeoutSeconds(), TimeUnit.SECONDS).readTimeout((long)HttpConfig.readTimeoutSeconds(), TimeUnit.SECONDS).writeTimeout((long)HttpConfig.writeTimeoutSeconds(), TimeUnit.SECONDS).build();
}
private X509TrustManager x509TrustManager() {
return new X509TrustManager() {
public void checkClientTrusted(X509Certificate[] x509Certificates, String s) throws CertificateException {
}
public void checkServerTrusted(X509Certificate[] x509Certificates, String s) throws CertificateException {
}
public X509Certificate[] getAcceptedIssuers() {
return new X509Certificate[0];
}
};
}
private SSLSocketFactory sslSocketFactory() {
try {
SSLContext sslContext = SSLContext.getInstance("TLS");
sslContext.init((KeyManager[])null, new TrustManager[]{this.x509TrustManager()}, new SecureRandom());
return sslContext.getSocketFactory();
} catch (Exception var2) {
Exception e = var2;
LOG.error("create ssl socket factory failed", e);
return null;
}
}
private ConnectionPool pool() {
return new ConnectionPool(HttpConfig.maxConnections(), (long)HttpConfig.connKeepaliveMinute(), TimeUnit.MINUTES);
}
}
package com.ruoyi.service.client;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.net.URL;
import java.util.Properties;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class HttpConfig {
private static final Logger LOG = LoggerFactory.getLogger(com.ruoyi.service.client.HttpConfig.class);
private static final String ES_CONFIG_FILE = "httpclient.properties";
private static int connectTimeoutSeconds = 30;
private static int readTimeoutSeconds = 30;
private static int writeTimeoutSeconds = 30;
private static int maxConnections = 10;
private static int connKeepaliveMinute = 5;
public HttpConfig() {
}
public static Properties readProperties(String fileName) throws Exception {
Properties properties = new Properties();
try {
boolean flag = true;
String configPath = System.getProperty("user.dir") + File.separator + "conf" + File.separator + fileName;
File file = new File(configPath);
if (flag && file.exists()) {
properties.load(new FileInputStream(file));
flag = false;
}
if (flag) {
URL url = Thread.currentThread().getContextClassLoader().getResource("");
String path = url.getPath().replace("classes", "conf") + fileName;
file = new File(path);
if (file.exists()) {
properties.load(new FileInputStream(file));
flag = false;
}
}
if (flag) {
InputStream inputStream = com.ruoyi.service.client.HttpConfig.class.getClassLoader().getResourceAsStream(fileName);
if (null != inputStream) {
properties.load(inputStream);
}
}
return properties;
} catch (Exception var7) {
Exception e = var7;
LOG.error("Read config properties error,file=" + fileName, e);
throw e;
}
}
public static int connectTimeoutSeconds() {
return connectTimeoutSeconds;
}
public static int readTimeoutSeconds() {
return readTimeoutSeconds;
}
public static int writeTimeoutSeconds() {
return writeTimeoutSeconds;
}
public static int maxConnections() {
return maxConnections;
}
public static int connKeepaliveMinute() {
return connKeepaliveMinute;
}
static {
try {
Properties properties = readProperties("httpclient.properties");
if (null != properties && !properties.isEmpty()) {
connectTimeoutSeconds = Integer.parseInt(properties.getProperty("connect.timeout.seconds"));
readTimeoutSeconds = Integer.parseInt(properties.getProperty("read.timeout.seconds"));
writeTimeoutSeconds = Integer.parseInt(properties.getProperty("write.timeout.seconds"));
maxConnections = Integer.parseInt(properties.getProperty("max.connections"));
connKeepaliveMinute = Integer.parseInt(properties.getProperty("connection.keep.alive.minutes"));
}
LOG.info("connectTimeoutSeconds:" + connectTimeoutSeconds);
LOG.info("readTimeoutSeconds:" + readTimeoutSeconds);
LOG.info("writeTimeoutSeconds:" + writeTimeoutSeconds);
LOG.info("maxConnections:" + maxConnections);
LOG.info("connKeepaliveMinute:" + connKeepaliveMinute);
} catch (Exception var1) {
Exception e = var1;
LOG.error("Failed to load properties file conf/httpclient.properties", e);
}
}
}
package com.ruoyi.service.constants;
public class GlobalConfig {
public static final String DEFAULT_ENCODING = "UTF-8";
public static final String CONTENT_TYPE = "application/json;charset=UTF-8";
public GlobalConfig() {
}
}
\ No newline at end of file
package com.ruoyi.service.constants;
public enum SignatureMethod {
HmacSHA256("HmacSHA256", "散列消息认证码Sha256"),
HmacSHA1("HmacSHA1", "散列消息认证码Sha1");
private final String code;
private final String description;
private SignatureMethod(String code, String desc) {
this.code = code;
this.description = desc;
}
public static com.ruoyi.service.constants.SignatureMethod getByCode(String code) {
com.ruoyi.service.constants.SignatureMethod[] var1 = values();
int var2 = var1.length;
for(int var3 = 0; var3 < var2; ++var3) {
com.ruoyi.service.constants.SignatureMethod processCode = var1[var3];
if (processCode.getCode().equals(code)) {
return processCode;
}
}
return null;
}
public String getCode() {
return this.code;
}
public String getDescription() {
return this.description;
}
}
package com.ruoyi.service.constants;
public enum SignatureVersion {
VERSION1("1.0", "散列消息认证码Sha256"),
VERSION2("2.0", "散列消息认证码Sha1");
private final String code;
private final String description;
private SignatureVersion(String code, String desc) {
this.code = code;
this.description = desc;
}
public static com.ruoyi.service.constants.SignatureVersion getByCode(String code) {
com.ruoyi.service.constants.SignatureVersion[] var1 = values();
int var2 = var1.length;
for(int var3 = 0; var3 < var2; ++var3) {
com.ruoyi.service.constants.SignatureVersion processCode = var1[var3];
if (processCode.getCode().equals(code)) {
return processCode;
}
}
return null;
}
public String getCode() {
return this.code;
}
public String getDescription() {
return this.description;
}
}
package com.ruoyi.service.domain;
public class APIRequestDTO {
private AuthInfo authInfo;
private String subServiceId;
private String applicationId;
public AuthInfo getAuthInfo() {
return this.authInfo;
}
public String getSubServiceId() {
return this.subServiceId;
}
public String getApplicationId() {
return this.applicationId;
}
public void setAuthInfo(AuthInfo authInfo) {
this.authInfo = authInfo;
}
public void setSubServiceId(String subServiceId) {
this.subServiceId = subServiceId;
}
public void setApplicationId(String applicationId) {
this.applicationId = applicationId;
}
public boolean equals(Object o) {
if (o == this) {
return true;
} else if (!(o instanceof com.ruoyi.service.domain.APIRequestDTO)) {
return false;
} else {
com.ruoyi.service.domain.APIRequestDTO other = (com.ruoyi.service.domain.APIRequestDTO)o;
if (!other.canEqual(this)) {
return false;
} else {
label47: {
Object this$authInfo = this.getAuthInfo();
Object other$authInfo = other.getAuthInfo();
if (this$authInfo == null) {
if (other$authInfo == null) {
break label47;
}
} else if (this$authInfo.equals(other$authInfo)) {
break label47;
}
return false;
}
Object this$subServiceId = this.getSubServiceId();
Object other$subServiceId = other.getSubServiceId();
if (this$subServiceId == null) {
if (other$subServiceId != null) {
return false;
}
} else if (!this$subServiceId.equals(other$subServiceId)) {
return false;
}
Object this$applicationId = this.getApplicationId();
Object other$applicationId = other.getApplicationId();
if (this$applicationId == null) {
if (other$applicationId != null) {
return false;
}
} else if (!this$applicationId.equals(other$applicationId)) {
return false;
}
return true;
}
}
}
protected boolean canEqual(Object other) {
return other instanceof com.ruoyi.service.domain.APIRequestDTO;
}
public int hashCode() {
int PRIME = 1;
int result = 1;
Object $authInfo = this.getAuthInfo();
result = result * 59 + ($authInfo == null ? 43 : $authInfo.hashCode());
Object $subServiceId = this.getSubServiceId();
result = result * 59 + ($subServiceId == null ? 43 : $subServiceId.hashCode());
Object $applicationId = this.getApplicationId();
result = result * 59 + ($applicationId == null ? 43 : $applicationId.hashCode());
return result;
}
public String toString() {
return "APIRequestDTO(authInfo=" + this.getAuthInfo() + ", subServiceId=" + this.getSubServiceId() + ", applicationId=" + this.getApplicationId() + ")";
}
public APIRequestDTO() {
}
public APIRequestDTO(AuthInfo authInfo, String subServiceId, String applicationId) {
this.authInfo = authInfo;
this.subServiceId = subServiceId;
this.applicationId = applicationId;
}
}
package com.ruoyi.service.domain;
import com.ruoyi.service.constants.SignatureVersion;
public class AuthInfo {
private String userId = "";
private String signature = "";
private String signatureVersion;
private String encoding;
private long timeStamp;
public AuthInfo(String userId, String signatureVersion, String encoding) {
this.signatureVersion = SignatureVersion.VERSION2.getCode();
this.encoding = "UTF-8";
this.timeStamp = System.currentTimeMillis();
this.userId = userId;
this.signatureVersion = signatureVersion;
this.encoding = encoding;
}
public String getUserId() {
return this.userId;
}
public String getSignature() {
return this.signature;
}
public String getSignatureVersion() {
return this.signatureVersion;
}
public String getEncoding() {
return this.encoding;
}
public long getTimeStamp() {
return this.timeStamp;
}
public void setUserId(String userId) {
this.userId = userId;
}
public void setSignature(String signature) {
this.signature = signature;
}
public void setSignatureVersion(String signatureVersion) {
this.signatureVersion = signatureVersion;
}
public void setEncoding(String encoding) {
this.encoding = encoding;
}
public void setTimeStamp(long timeStamp) {
this.timeStamp = timeStamp;
}
public boolean equals(Object o) {
if (o == this) {
return true;
} else if (!(o instanceof com.ruoyi.service.domain.AuthInfo)) {
return false;
} else {
com.ruoyi.service.domain.AuthInfo other = (com.ruoyi.service.domain.AuthInfo)o;
if (!other.canEqual(this)) {
return false;
} else if (this.getTimeStamp() != other.getTimeStamp()) {
return false;
} else {
label61: {
Object this$userId = this.getUserId();
Object other$userId = other.getUserId();
if (this$userId == null) {
if (other$userId == null) {
break label61;
}
} else if (this$userId.equals(other$userId)) {
break label61;
}
return false;
}
label54: {
Object this$signature = this.getSignature();
Object other$signature = other.getSignature();
if (this$signature == null) {
if (other$signature == null) {
break label54;
}
} else if (this$signature.equals(other$signature)) {
break label54;
}
return false;
}
Object this$signatureVersion = this.getSignatureVersion();
Object other$signatureVersion = other.getSignatureVersion();
if (this$signatureVersion == null) {
if (other$signatureVersion != null) {
return false;
}
} else if (!this$signatureVersion.equals(other$signatureVersion)) {
return false;
}
Object this$encoding = this.getEncoding();
Object other$encoding = other.getEncoding();
if (this$encoding == null) {
if (other$encoding != null) {
return false;
}
} else if (!this$encoding.equals(other$encoding)) {
return false;
}
return true;
}
}
}
protected boolean canEqual(Object other) {
return other instanceof com.ruoyi.service.domain.AuthInfo;
}
public int hashCode() {
int PRIME = 1;
int result = 1;
long $timeStamp = this.getTimeStamp();
result = result * 59 + (int)($timeStamp >>> 32 ^ $timeStamp);
Object $userId = this.getUserId();
result = result * 59 + ($userId == null ? 43 : $userId.hashCode());
Object $signature = this.getSignature();
result = result * 59 + ($signature == null ? 43 : $signature.hashCode());
Object $signatureVersion = this.getSignatureVersion();
result = result * 59 + ($signatureVersion == null ? 43 : $signatureVersion.hashCode());
Object $encoding = this.getEncoding();
result = result * 59 + ($encoding == null ? 43 : $encoding.hashCode());
return result;
}
public String toString() {
return "AuthInfo(userId=" + this.getUserId() + ", signature=" + this.getSignature() + ", signatureVersion=" + this.getSignatureVersion() + ", encoding=" + this.getEncoding() + ", timeStamp=" + this.getTimeStamp() + ")";
}
public AuthInfo() {
this.signatureVersion = SignatureVersion.VERSION2.getCode();
this.encoding = "UTF-8";
this.timeStamp = System.currentTimeMillis();
}
}
package com.ruoyi.service.domain;
import com.ruoyi.service.domain.ServiceRequestFieldDTO;
import com.ruoyi.service.utils.Tools;
import java.util.ArrayList;
import java.util.List;
public class DataQuery {
private List<ServiceRequestFieldDTO> must;
private List<ServiceRequestFieldDTO> should;
public DataQuery() {
}
public DataQuery(List<ServiceRequestFieldDTO> must, List<ServiceRequestFieldDTO> should) {
this.must = must;
this.should = should;
}
public com.ruoyi.service.domain.DataQuery must(ServiceRequestFieldDTO field) {
if (Tools.isNull(this.must)) {
this.must = new ArrayList();
}
this.must.add(field);
return this;
}
public com.ruoyi.service.domain.DataQuery should(ServiceRequestFieldDTO field) {
if (Tools.isNull(this.should)) {
this.should = new ArrayList();
}
this.should.add(field);
return this;
}
public List<ServiceRequestFieldDTO> getMust() {
return this.must;
}
public List<ServiceRequestFieldDTO> getShould() {
return this.should;
}
public static class Builder {
private List<ServiceRequestFieldDTO> must;
private List<ServiceRequestFieldDTO> should;
public Builder() {
}
public com.ruoyi.service.domain.DataQuery.Builder must(ServiceRequestFieldDTO field) {
if (Tools.isNull(this.must)) {
this.must = new ArrayList();
}
this.must.add(field);
return this;
}
public com.ruoyi.service.domain.DataQuery.Builder should(ServiceRequestFieldDTO field) {
if (Tools.isNull(this.should)) {
this.should = new ArrayList();
}
this.should.add(field);
return this;
}
public com.ruoyi.service.domain.DataQuery.Builder must(List<ServiceRequestFieldDTO> fields) {
if (Tools.isNull(this.must)) {
this.must = new ArrayList();
}
this.must.addAll(fields);
return this;
}
public com.ruoyi.service.domain.DataQuery.Builder should(List<ServiceRequestFieldDTO> fields) {
if (Tools.isNull(this.should)) {
this.should = new ArrayList();
}
this.should.addAll(fields);
return this;
}
public com.ruoyi.service.domain.DataQuery build() {
return new com.ruoyi.service.domain.DataQuery(this.must, this.should);
}
}
}
package com.ruoyi.service.domain;
import com.ruoyi.service.domain.APIRequestDTO;
import com.ruoyi.service.domain.DataQuery;
import com.ruoyi.service.domain.ServiceRequestFieldDTO;
import com.ruoyi.service.domain.SortDTO;
import com.ruoyi.service.utils.Tools;
import java.util.ArrayList;
import java.util.List;
public class DataServiceRequestDTO extends APIRequestDTO {
private String nextToken = "";
private int size = 10;
private boolean includeColumns = false;
private List<com.ruoyi.service.domain.ServiceRequestFieldDTO> queryFields;
private com.ruoyi.service.domain.DataQuery dataQuery;
private List<SortDTO> sorts;
public DataServiceRequestDTO() {
}
public DataServiceRequestDTO(String nextToken, int size, boolean includeColumns, List<com.ruoyi.service.domain.ServiceRequestFieldDTO> queryFields, List<SortDTO> sorts) {
this.nextToken = nextToken;
this.size = size;
this.includeColumns = includeColumns;
this.queryFields = queryFields;
this.sorts = sorts;
}
public DataServiceRequestDTO(String nextToken, int size, boolean includeColumns, com.ruoyi.service.domain.DataQuery dataQuery, List<SortDTO> sorts) {
this.nextToken = nextToken;
this.size = size;
this.includeColumns = includeColumns;
this.dataQuery = dataQuery;
this.sorts = sorts;
}
public DataServiceRequestDTO(String nextToken, int size, boolean includeColumns, com.ruoyi.service.domain.DataQuery dataQuery, List<com.ruoyi.service.domain.ServiceRequestFieldDTO> queryFields, List<SortDTO> sorts) {
this.nextToken = nextToken;
this.size = size;
this.includeColumns = includeColumns;
this.dataQuery = dataQuery;
this.queryFields = queryFields;
this.sorts = sorts;
}
public String getNextToken() {
return this.nextToken;
}
public int getSize() {
return this.size;
}
public boolean isIncludeColumns() {
return this.includeColumns;
}
public List<com.ruoyi.service.domain.ServiceRequestFieldDTO> getQueryFields() {
return this.queryFields;
}
public com.ruoyi.service.domain.DataQuery getDataQuery() {
return this.dataQuery;
}
public List<SortDTO> getSorts() {
return this.sorts;
}
public static class Builder {
private String nextToken = "";
private int size = 10;
private boolean includeColumns = false;
private List<com.ruoyi.service.domain.ServiceRequestFieldDTO> queryFields;
private List<SortDTO> sorts;
private com.ruoyi.service.domain.DataQuery dataQuery;
public Builder() {
}
public com.ruoyi.service.domain.DataServiceRequestDTO.Builder nextToken(String nextToken) {
this.nextToken = nextToken;
return this;
}
public com.ruoyi.service.domain.DataServiceRequestDTO.Builder size(int size) {
this.size = size;
return this;
}
public com.ruoyi.service.domain.DataServiceRequestDTO.Builder includeColumns(boolean includeColumns) {
this.includeColumns = includeColumns;
return this;
}
public com.ruoyi.service.domain.DataServiceRequestDTO.Builder dataQuery(DataQuery dataQuery) {
this.dataQuery = dataQuery;
return this;
}
/** @deprecated */
@Deprecated
public com.ruoyi.service.domain.DataServiceRequestDTO.Builder queryFields(List<com.ruoyi.service.domain.ServiceRequestFieldDTO> queryFields) {
this.queryFields = queryFields;
return this;
}
/** @deprecated */
@Deprecated
public com.ruoyi.service.domain.DataServiceRequestDTO.Builder query(ServiceRequestFieldDTO queryField) {
if (Tools.isNull(this.queryFields)) {
this.queryFields = new ArrayList();
}
this.queryFields.add(queryField);
return this;
}
public com.ruoyi.service.domain.DataServiceRequestDTO.Builder sorts(List<SortDTO> sorts) {
this.sorts = sorts;
return this;
}
public com.ruoyi.service.domain.DataServiceRequestDTO.Builder sort(SortDTO sort) {
if (Tools.isNull(this.sorts)) {
this.sorts = new ArrayList();
}
this.sorts.add(sort);
return this;
}
public com.ruoyi.service.domain.DataServiceRequestDTO build() {
return new com.ruoyi.service.domain.DataServiceRequestDTO(this.nextToken, this.size, this.includeColumns, this.dataQuery, this.queryFields, this.sorts);
}
}
}
package com.ruoyi.service.domain;
public class ServiceRequestFieldDTO {
private String fieldCode;
private String fieldName;
private String fieldType;
private String operateName;
private String operateCode;
private Object fieldValue;
public ServiceRequestFieldDTO(String fieldCode, String fieldType, String operateCode, Object fieldValue) {
this.fieldCode = fieldCode;
this.fieldType = fieldType;
this.operateCode = operateCode;
this.fieldValue = fieldValue;
}
public String getFieldCode() {
return this.fieldCode;
}
public String getFieldName() {
return this.fieldName;
}
public String getFieldType() {
return this.fieldType;
}
public String getOperateName() {
return this.operateName;
}
public String getOperateCode() {
return this.operateCode;
}
public Object getFieldValue() {
return this.fieldValue;
}
public void setFieldCode(String fieldCode) {
this.fieldCode = fieldCode;
}
public void setFieldName(String fieldName) {
this.fieldName = fieldName;
}
public void setFieldType(String fieldType) {
this.fieldType = fieldType;
}
public void setOperateName(String operateName) {
this.operateName = operateName;
}
public void setOperateCode(String operateCode) {
this.operateCode = operateCode;
}
public void setFieldValue(Object fieldValue) {
this.fieldValue = fieldValue;
}
public boolean equals(Object o) {
if (o == this) {
return true;
} else if (!(o instanceof com.ruoyi.service.domain.ServiceRequestFieldDTO)) {
return false;
} else {
com.ruoyi.service.domain.ServiceRequestFieldDTO other = (com.ruoyi.service.domain.ServiceRequestFieldDTO)o;
if (!other.canEqual(this)) {
return false;
} else {
Object this$fieldCode = this.getFieldCode();
Object other$fieldCode = other.getFieldCode();
if (this$fieldCode == null) {
if (other$fieldCode != null) {
return false;
}
} else if (!this$fieldCode.equals(other$fieldCode)) {
return false;
}
Object this$fieldName = this.getFieldName();
Object other$fieldName = other.getFieldName();
if (this$fieldName == null) {
if (other$fieldName != null) {
return false;
}
} else if (!this$fieldName.equals(other$fieldName)) {
return false;
}
Object this$fieldType = this.getFieldType();
Object other$fieldType = other.getFieldType();
if (this$fieldType == null) {
if (other$fieldType != null) {
return false;
}
} else if (!this$fieldType.equals(other$fieldType)) {
return false;
}
label62: {
Object this$operateName = this.getOperateName();
Object other$operateName = other.getOperateName();
if (this$operateName == null) {
if (other$operateName == null) {
break label62;
}
} else if (this$operateName.equals(other$operateName)) {
break label62;
}
return false;
}
label55: {
Object this$operateCode = this.getOperateCode();
Object other$operateCode = other.getOperateCode();
if (this$operateCode == null) {
if (other$operateCode == null) {
break label55;
}
} else if (this$operateCode.equals(other$operateCode)) {
break label55;
}
return false;
}
Object this$fieldValue = this.getFieldValue();
Object other$fieldValue = other.getFieldValue();
if (this$fieldValue == null) {
if (other$fieldValue != null) {
return false;
}
} else if (!this$fieldValue.equals(other$fieldValue)) {
return false;
}
return true;
}
}
}
protected boolean canEqual(Object other) {
return other instanceof com.ruoyi.service.domain.ServiceRequestFieldDTO;
}
public int hashCode() {
int PRIME = 1;
int result = 1;
Object $fieldCode = this.getFieldCode();
result = result * 59 + ($fieldCode == null ? 43 : $fieldCode.hashCode());
Object $fieldName = this.getFieldName();
result = result * 59 + ($fieldName == null ? 43 : $fieldName.hashCode());
Object $fieldType = this.getFieldType();
result = result * 59 + ($fieldType == null ? 43 : $fieldType.hashCode());
Object $operateName = this.getOperateName();
result = result * 59 + ($operateName == null ? 43 : $operateName.hashCode());
Object $operateCode = this.getOperateCode();
result = result * 59 + ($operateCode == null ? 43 : $operateCode.hashCode());
Object $fieldValue = this.getFieldValue();
result = result * 59 + ($fieldValue == null ? 43 : $fieldValue.hashCode());
return result;
}
public String toString() {
return "ServiceRequestFieldDTO(fieldCode=" + this.getFieldCode() + ", fieldName=" + this.getFieldName() + ", fieldType=" + this.getFieldType() + ", operateName=" + this.getOperateName() + ", operateCode=" + this.getOperateCode() + ", fieldValue=" + this.getFieldValue() + ")";
}
public ServiceRequestFieldDTO() {
}
}
package com.ruoyi.service.domain;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
@ApiModel("数据服务请求排序参数")
public class SortDTO {
@ApiModelProperty("排序字段")
private String sort;
@ApiModelProperty("排序方式:asc:升序、desc:降序")
private String sortOrder;
public String getSort() {
return this.sort;
}
public String getSortOrder() {
return this.sortOrder;
}
public void setSort(String sort) {
this.sort = sort;
}
public void setSortOrder(String sortOrder) {
this.sortOrder = sortOrder;
}
public boolean equals(Object o) {
if (o == this) {
return true;
} else if (!(o instanceof com.ruoyi.service.domain.SortDTO)) {
return false;
} else {
com.ruoyi.service.domain.SortDTO other = (com.ruoyi.service.domain.SortDTO)o;
if (!other.canEqual(this)) {
return false;
} else {
Object this$sort = this.getSort();
Object other$sort = other.getSort();
if (this$sort == null) {
if (other$sort != null) {
return false;
}
} else if (!this$sort.equals(other$sort)) {
return false;
}
Object this$sortOrder = this.getSortOrder();
Object other$sortOrder = other.getSortOrder();
if (this$sortOrder == null) {
if (other$sortOrder != null) {
return false;
}
} else if (!this$sortOrder.equals(other$sortOrder)) {
return false;
}
return true;
}
}
}
protected boolean canEqual(Object other) {
return other instanceof com.ruoyi.service.domain.SortDTO;
}
public int hashCode() {
int PRIME = 1;
int result = 1;
Object $sort = this.getSort();
result = result * 59 + ($sort == null ? 43 : $sort.hashCode());
Object $sortOrder = this.getSortOrder();
result = result * 59 + ($sortOrder == null ? 43 : $sortOrder.hashCode());
return result;
}
public String toString() {
return "SortDTO(sort=" + this.getSort() + ", sortOrder=" + this.getSortOrder() + ")";
}
public SortDTO(String sort, String sortOrder) {
this.sort = sort;
this.sortOrder = sortOrder;
}
public SortDTO() {
}
}
package com.ruoyi.service.domain;
import com.ruoyi.service.domain.APIRequestDTO;
import java.util.HashMap;
public class ThirdServiceRequestDTO extends APIRequestDTO {
private HashMap<String, String> params;
private String bodyContent;
public ThirdServiceRequestDTO() {
}
public ThirdServiceRequestDTO(HashMap<String, String> params, String bodyContent) {
this.params = params;
this.bodyContent = bodyContent;
}
public HashMap<String, String> getParams() {
return this.params;
}
public String getBodyContent() {
return this.bodyContent;
}
public static class Builder {
private HashMap<String, String> params;
private String bodyContent;
public Builder() {
}
public com.ruoyi.service.domain.ThirdServiceRequestDTO.Builder params(HashMap<String, String> params) {
this.params = params;
return this;
}
public com.ruoyi.service.domain.ThirdServiceRequestDTO.Builder bodyContent(String bodyContent) {
this.bodyContent = bodyContent;
return this;
}
public com.ruoyi.service.domain.ThirdServiceRequestDTO build() {
return new com.ruoyi.service.domain.ThirdServiceRequestDTO(this.params, this.bodyContent);
}
}
}
package com.ruoyi.service.utils;
import com.ruoyi.service.utils.Tools;
import okhttp3.MediaType;
import okhttp3.Request;
import okhttp3.RequestBody;
import okhttp3.Response;
//import org.apache.commons.lang.exception.ExceptionUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class HttpUtils {
private static final Logger logger = LoggerFactory.getLogger(com.ruoyi.service.utils.HttpUtils.class);
public HttpUtils() {
}
public static Request createHttpRequest(String url, String jsonContent) {
Request.Builder builder = new Request.Builder();
RequestBody body = RequestBody.create(MediaType.parse("application/json;charset=utf-8"), jsonContent);
return builder.url(url).post(body).build();
}
public static String readBody(Response response) {
String responseBody = "";
if (Tools.isNull(response)) {
return responseBody;
} else {
String var8;
try {
if (!response.isSuccessful()) {
throw new RuntimeException(response.body().string());
}
var8 = response.body().string();
} catch (Exception var6) {
Exception ex = var6;
logger.error("okhttp response error >> ex = {}", ex);
throw new RuntimeException(ex);
} finally {
if (response != null) {
response.close();
}
}
return var8;
}
}
}
package com.ruoyi.service.utils;
import com.ruoyi.service.constants.SignatureMethod;
import com.ruoyi.service.constants.SignatureVersion;
import com.ruoyi.service.domain.AuthInfo;
import java.security.SignatureException;
import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;
import com.ruoyi.service.utils.Tools;
import org.apache.commons.codec.binary.Base64;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class IdentifyTools {
private static final Logger log = LoggerFactory.getLogger(com.ruoyi.service.utils.IdentifyTools.class);
private static final Logger logger = LoggerFactory.getLogger(com.ruoyi.service.utils.IdentifyTools.class);
public IdentifyTools() {
}
public static boolean auth(AuthInfo auth, String params, String solt, String signature) {
try {
if (Tools.isNull(auth.getSignatureVersion())) {
return false;
} else {
String signatureMethod = (SignatureVersion.VERSION2.getCode().equals(auth.getSignatureVersion()) ? SignatureMethod.HmacSHA256 : SignatureMethod.HmacSHA1).getCode();
String signStr = sign(params, solt, signatureMethod, auth.getEncoding());
return signature.equals(signStr);
}
} catch (Exception var6) {
Exception e = var6;
logger.error("认证错误:", e);
return false;
}
}
public static String sign(String data, String key, String signatureMethod, String encoding) throws SignatureException {
byte[] signature;
try {
Mac mac = Mac.getInstance(signatureMethod);
mac.init(new SecretKeySpec(key.getBytes(), signatureMethod));
signature = Base64.encodeBase64(mac.doFinal(data.getBytes(encoding)));
} catch (Exception var6) {
Exception e = var6;
throw new SignatureException("生成签名失败:" + e.getMessage(), e);
}
return new String(signature);
}
}
package com.ruoyi.service.utils;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Map;
public class Tools {
public Tools() {
}
public static boolean isNull(Object obj) {
return obj == null || "null".equals(obj);
}
public static boolean isNull(String str) {
return str == null || "".equals(str.trim());
}
public static boolean isNotNull(String str) {
return str != null && !"".equals(str.trim());
}
public static Calendar getCalendar(Date date) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
return calendar;
}
public static boolean isEmpty(List<?> list) {
return list == null || list.isEmpty();
}
public static boolean isNotEmpty(List<?> list) {
return list != null && !list.isEmpty();
}
public static boolean isEmpty(Map<?, ?> map) {
return map == null || map.isEmpty();
}
public static boolean isNotNull(Object obj) {
return obj != null && !"null".equals(obj) && !"".equals(obj);
}
public static Date string2Date(String date) {
Date returnDate = null;
SimpleDateFormat dateFormat;
if (date.length() == 10) {
dateFormat = new SimpleDateFormat("yyyy-MM-dd");
} else {
dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
}
try {
returnDate = dateFormat.parse(date);
} catch (ParseException var4) {
}
return returnDate;
}
public static String readFile(String filePath) throws Exception {
InputStream in = getFileInputStream(filePath);
StringBuilder xmlSb = new StringBuilder();
byte[] b = new byte[1024];
try {
int i;
try {
while((i = in.read(b)) != -1) {
xmlSb.append(new String(b, 0, i, "UTF-8"));
}
} catch (Exception var13) {
Exception e = var13;
throw e;
}
} finally {
if (null != in) {
try {
in.close();
} catch (Exception var12) {
}
}
}
return xmlSb.toString();
}
public static InputStream getFileInputStream(String fileName) throws IOException {
File file = new File(getlocalPath(fileName));
if (!file.exists()) {
throw new FileNotFoundException("can't found file : " + fileName);
} else {
InputStream in = new FileInputStream(file);
return in;
}
}
private static String getlocalPath(String fileName) {
return com.ruoyi.service.utils.Tools.class.getResource(fileName).getFile();
}
}
Manifest-Version: 1.0 Manifest-Version: 1.0
Main-Class: com.ruoyi.StartApplication Main-Class: com.ruoyi.StartApplication
Class-Path: springfox-schema-2.9.2.jar mysql-connector-java-8.0.21.jar s
pring-boot-starter-jdbc-2.3.3.RELEASE.jar spring-jcl-5.2.8.RELEASE.jar
HikariCP-3.4.5.jar fastjson-1.2.47.jar spring-boot-starter-web-2.3.3.RE
LEASE.jar jackson-datatype-jsr310-2.11.2.jar junit-vintage-engine-5.6.2
.jar jsqlparser-2.1.jar spring-boot-starter-logging-2.3.3.RELEASE.jar o
pentest4j-1.2.0.jar junit-4.13.jar spring-tx-5.2.8.RELEASE.jar mybatis-
plus-boot-starter-3.2.0.jar spring-plugin-metadata-1.2.0.RELEASE.jar ok
io-1.17.2.jar mapstruct-1.2.0.Final.jar log4j-api-2.13.3.jar jul-to-slf
4j-1.7.30.jar springfox-spring-web-2.9.2.jar swagger-annotations-1.5.20
.jar jackson-core-2.11.2.jar guava-20.0.jar commons-codec-1.13.jar myba
tis-plus-3.2.0.jar jakarta.el-3.0.3.jar springfox-spi-2.9.2.jar spring-
boot-devtools-2.3.3.RELEASE.jar swagger-models-1.5.20.jar byte-buddy-1.
10.14.jar spring-boot-autoconfigure-2.3.3.RELEASE.jar spring-aop-5.2.8.
RELEASE.jar hamcrest-2.2.jar spring-core-5.2.8.RELEASE.jar jackson-data
type-jdk8-2.11.2.jar spring-beans-5.2.8.RELEASE.jar spring-boot-2.3.3.R
ELEASE.jar jackson-databind-2.11.2.jar spring-boot-starter-tomcat-2.3.3
.RELEASE.jar jackson-module-parameter-names-2.11.2.jar spring-plugin-co
re-1.2.0.RELEASE.jar tomcat-embed-websocket-9.0.37.jar spring-jdbc-5.2.
8.RELEASE.jar slf4j-api-1.7.30.jar mybatis-plus-annotation-3.2.0.jar to
mcat-embed-core-9.0.37.jar springfox-swagger-ui-2.9.2.jar okhttp-3.14.9
.jar spring-boot-starter-2.3.3.RELEASE.jar springfox-swagger-common-2.9
.2.jar spring-context-5.2.8.RELEASE.jar mybatis-spring-2.0.2.jar hutool
-all-5.8.17.jar lombok-1.18.12.jar mybatis-3.5.2.jar springfox-swagger2
-2.9.2.jar spring-expression-5.2.8.RELEASE.jar logback-classic-1.2.3.ja
r hamcrest-core-2.2.jar jackson-annotations-2.11.2.jar mybatis-plus-cor
e-3.2.0.jar service-invoke-sdk-2.0.0-20240902.045641-2.jar snakeyaml-1.
26.jar spring-web-5.2.8.RELEASE.jar mybatis-plus-extension-3.2.0.jar ju
nit-platform-commons-1.6.2.jar apiguardian-api-1.1.0.jar spring-boot-st
arter-json-2.3.3.RELEASE.jar classmate-1.5.1.jar spring-webmvc-5.2.8.RE
LEASE.jar junit-platform-engine-1.6.2.jar log4j-to-slf4j-2.13.3.jar jak
arta.annotation-api-1.3.5.jar logback-core-1.2.3.jar springfox-core-2.9
.2.jar
...@@ -10,6 +10,4 @@ mybatis-plus: ...@@ -10,6 +10,4 @@ mybatis-plus:
# 搜索指定包别名 # 搜索指定包别名
typeAliasesPackage: com.**.domain typeAliasesPackage: com.**.domain
# 配置mapper的扫描,找到所有的mapper.xml映射文件 # 配置mapper的扫描,找到所有的mapper.xml映射文件
mapperLocations: classpath*:mapper/**/*Mapper.xml mapperLocations: classpath*:mapper/**/*Mapper.xml
# 加载全局的配置文件 \ No newline at end of file
configLocation: classpath:mybatis/mybatis-config.xml
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?> <?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"> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.generator.mapper.getInfoMapper"> <mapper namespace="com.ruoyi.getInfo.mapper.getInfoMapper">
<insert id="addInfo" parameterType="com.ruoyi.generator.domain.getInfoDomain"> <insert id="addInfo" parameterType="com.ruoyi.getInfo.domain.getInfoDomain">
insert into o_t_gxj_yqyd_t_project insert into t_project
(id,create_date,creater,delete_date,deleter,update_date,updater,remark,sort,sts,area_id,company_name,description,great,invest,map_addr,mode,project_addr,project_name,record_code,record_date,stage) (id,create_date,creater,delete_date,deleter,update_date,updater,remark,sort,sts,area_id,company_name,description,great,invest,map_addr,mode,project_addr,project_name,record_code,record_date,stage)
values (#{id},#{createDate},{creater},#{deleteDate},#{deleter},#{updateDate},#{updater},#{remark},#{sort},#{sts},#{areaId},#{companyName},#{description},#{great},#{invest},#{mapAddr},#{mode},#{projectAddr},#{projectName},#{recordCode},#{recordDate},#{stage}) values (#{id},#{createDate},{creater},#{deleteDate},#{deleter},#{updateDate},#{updater},#{remark},#{sort},#{sts},#{areaId},#{companyName},#{description},#{great},#{invest},#{mapAddr},#{mode},#{projectAddr},#{projectName},#{recordCode},#{recordDate},#{stage})
......
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE configuration
PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>
<!-- 全局参数 -->
<settings>
<!-- 使全局的映射器启用或禁用缓存 -->
<setting name="cacheEnabled" value="true" />
<!-- 允许JDBC 支持自动生成主键 -->
<setting name="useGeneratedKeys" value="true" />
<!-- 配置默认的执行器.SIMPLE就是普通执行器;REUSE执行器会重用预处理语句(prepared statements);BATCH执行器将重用语句并执行批量更新 -->
<setting name="defaultExecutorType" value="SIMPLE" />
<!-- 指定 MyBatis 所用日志的具体实现 -->
<setting name="logImpl" value="SLF4J" />
<!-- 使用驼峰命名法转换字段 -->
<!-- <setting name="mapUnderscoreToCamelCase" value="true"/> -->
</settings>
</configuration>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment