This commit is contained in:
QAIU
2023-05-06 17:38:56 +08:00
parent df10b72787
commit 905004b0ac
19 changed files with 964 additions and 5 deletions

View File

@@ -53,6 +53,12 @@
<artifactId>jsoup</artifactId>
<version>1.15.4</version>
</dependency>
<dependency>
<groupId>cn.qaiu</groupId>
<artifactId>core-database</artifactId>
<version>0.0.1</version>
<scope>compile</scope>
</dependency>
</dependencies>

View File

@@ -0,0 +1,91 @@
/*
* Copyright 2014 Red Hat, Inc.
*
* Red Hat licenses this file to you 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 cn.qaiu.lz.web.service;
import io.vertx.core.eventbus.DeliveryOptions;
import io.vertx.core.Vertx;
import io.vertx.core.Future;
import io.vertx.core.json.JsonObject;
import io.vertx.core.json.JsonArray;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.function.Function;
import io.vertx.serviceproxy.ServiceException;
import io.vertx.serviceproxy.ServiceExceptionMessageCodec;
import io.vertx.serviceproxy.ProxyUtils;
import cn.qaiu.lz.common.model.UserInfo;
import cn.qaiu.vx.core.base.BaseAsyncService;
import io.vertx.core.Future;
/*
Generated Proxy code - DO NOT EDIT
@author Roger the Robot
*/
@SuppressWarnings({"unchecked", "rawtypes"})
public class DbServiceVertxEBProxy implements DbService {
private Vertx _vertx;
private String _address;
private DeliveryOptions _options;
private boolean closed;
public DbServiceVertxEBProxy(Vertx vertx, String address) {
this(vertx, address, null);
}
public DbServiceVertxEBProxy(Vertx vertx, String address, DeliveryOptions options) {
this._vertx = vertx;
this._address = address;
this._options = options;
try {
this._vertx.eventBus().registerDefaultCodec(ServiceException.class, new ServiceExceptionMessageCodec());
} catch (IllegalStateException ex) {
}
}
@Override
public Future<JsonObject> sayOk(String data){
if (closed) return io.vertx.core.Future.failedFuture("Proxy is closed");
JsonObject _json = new JsonObject();
_json.put("data", data);
DeliveryOptions _deliveryOptions = (_options != null) ? new DeliveryOptions(_options) : new DeliveryOptions();
_deliveryOptions.addHeader("action", "sayOk");
_deliveryOptions.getHeaders().set("action", "sayOk");
return _vertx.eventBus().<JsonObject>request(_address, _json, _deliveryOptions).map(msg -> {
return msg.body();
});
}
@Override
public Future<JsonObject> sayOk2(String data, UserInfo holder){
if (closed) return io.vertx.core.Future.failedFuture("Proxy is closed");
JsonObject _json = new JsonObject();
_json.put("data", data);
_json.put("holder", holder != null ? holder.toJson() : null);
DeliveryOptions _deliveryOptions = (_options != null) ? new DeliveryOptions(_options) : new DeliveryOptions();
_deliveryOptions.addHeader("action", "sayOk2");
_deliveryOptions.getHeaders().set("action", "sayOk2");
return _vertx.eventBus().<JsonObject>request(_address, _json, _deliveryOptions).map(msg -> {
return msg.body();
});
}
}

View File

@@ -0,0 +1,140 @@
/*
* Copyright 2014 Red Hat, Inc.
*
* Red Hat licenses this file to you 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 cn.qaiu.lz.web.service;
import cn.qaiu.lz.web.service.DbService;
import io.vertx.core.Vertx;
import io.vertx.core.Handler;
import io.vertx.core.AsyncResult;
import io.vertx.core.eventbus.EventBus;
import io.vertx.core.eventbus.Message;
import io.vertx.core.eventbus.MessageConsumer;
import io.vertx.core.eventbus.DeliveryOptions;
import io.vertx.core.eventbus.ReplyException;
import io.vertx.core.json.JsonObject;
import io.vertx.core.json.JsonArray;
import java.util.Collection;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import java.util.stream.Collectors;
import io.vertx.serviceproxy.ProxyHandler;
import io.vertx.serviceproxy.ServiceException;
import io.vertx.serviceproxy.ServiceExceptionMessageCodec;
import io.vertx.serviceproxy.HelperUtils;
import io.vertx.serviceproxy.ServiceBinder;
import cn.qaiu.lz.common.model.UserInfo;
import cn.qaiu.vx.core.base.BaseAsyncService;
import io.vertx.core.Future;
/*
Generated Proxy code - DO NOT EDIT
@author Roger the Robot
*/
@SuppressWarnings({"unchecked", "rawtypes"})
public class DbServiceVertxProxyHandler extends ProxyHandler {
public static final long DEFAULT_CONNECTION_TIMEOUT = 5 * 60; // 5 minutes
private final Vertx vertx;
private final DbService service;
private final long timerID;
private long lastAccessed;
private final long timeoutSeconds;
private final boolean includeDebugInfo;
public DbServiceVertxProxyHandler(Vertx vertx, DbService service){
this(vertx, service, DEFAULT_CONNECTION_TIMEOUT);
}
public DbServiceVertxProxyHandler(Vertx vertx, DbService service, long timeoutInSecond){
this(vertx, service, true, timeoutInSecond);
}
public DbServiceVertxProxyHandler(Vertx vertx, DbService service, boolean topLevel, long timeoutInSecond){
this(vertx, service, true, timeoutInSecond, false);
}
public DbServiceVertxProxyHandler(Vertx vertx, DbService service, boolean topLevel, long timeoutSeconds, boolean includeDebugInfo) {
this.vertx = vertx;
this.service = service;
this.includeDebugInfo = includeDebugInfo;
this.timeoutSeconds = timeoutSeconds;
try {
this.vertx.eventBus().registerDefaultCodec(ServiceException.class,
new ServiceExceptionMessageCodec());
} catch (IllegalStateException ex) {}
if (timeoutSeconds != -1 && !topLevel) {
long period = timeoutSeconds * 1000 / 2;
if (period > 10000) {
period = 10000;
}
this.timerID = vertx.setPeriodic(period, this::checkTimedOut);
} else {
this.timerID = -1;
}
accessed();
}
private void checkTimedOut(long id) {
long now = System.nanoTime();
if (now - lastAccessed > timeoutSeconds * 1000000000) {
close();
}
}
@Override
public void close() {
if (timerID != -1) {
vertx.cancelTimer(timerID);
}
super.close();
}
private void accessed() {
this.lastAccessed = System.nanoTime();
}
public void handle(Message<JsonObject> msg) {
try{
JsonObject json = msg.body();
String action = msg.headers().get("action");
if (action == null) throw new IllegalStateException("action not specified");
accessed();
switch (action) {
case "sayOk": {
service.sayOk((java.lang.String)json.getValue("data")).onComplete(HelperUtils.createHandler(msg, includeDebugInfo));
break;
}
case "sayOk2": {
service.sayOk2((java.lang.String)json.getValue("data"),
json.getJsonObject("holder") != null ? new cn.qaiu.lz.common.model.UserInfo((JsonObject)json.getJsonObject("holder")) : null).onComplete(HelperUtils.createHandler(msg, includeDebugInfo));
break;
}
default: throw new IllegalStateException("Invalid action: " + action);
}
} catch (Throwable t) {
if (includeDebugInfo) msg.reply(new ServiceException(500, t.getMessage(), HelperUtils.generateDebugInfo(t)));
else msg.reply(new ServiceException(500, t.getMessage()));
throw t;
}
}
}

View File

@@ -0,0 +1,77 @@
/*
* Copyright 2014 Red Hat, Inc.
*
* Red Hat licenses this file to you 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 cn.qaiu.lz.web.service;
import io.vertx.core.eventbus.DeliveryOptions;
import io.vertx.core.Vertx;
import io.vertx.core.Future;
import io.vertx.core.json.JsonObject;
import io.vertx.core.json.JsonArray;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.function.Function;
import io.vertx.serviceproxy.ServiceException;
import io.vertx.serviceproxy.ServiceExceptionMessageCodec;
import io.vertx.serviceproxy.ProxyUtils;
import cn.qaiu.lz.web.model.RealUser;
import cn.qaiu.vx.core.base.BaseAsyncService;
import io.vertx.core.Future;
/*
Generated Proxy code - DO NOT EDIT
@author Roger the Robot
*/
@SuppressWarnings({"unchecked", "rawtypes"})
public class UserServiceVertxEBProxy implements UserService {
private Vertx _vertx;
private String _address;
private DeliveryOptions _options;
private boolean closed;
public UserServiceVertxEBProxy(Vertx vertx, String address) {
this(vertx, address, null);
}
public UserServiceVertxEBProxy(Vertx vertx, String address, DeliveryOptions options) {
this._vertx = vertx;
this._address = address;
this._options = options;
try {
this._vertx.eventBus().registerDefaultCodec(ServiceException.class, new ServiceExceptionMessageCodec());
} catch (IllegalStateException ex) {
}
}
@Override
public Future<String> login(RealUser user){
if (closed) return io.vertx.core.Future.failedFuture("Proxy is closed");
JsonObject _json = new JsonObject();
_json.put("user", user != null ? user.toJson() : null);
DeliveryOptions _deliveryOptions = (_options != null) ? new DeliveryOptions(_options) : new DeliveryOptions();
_deliveryOptions.addHeader("action", "login");
_deliveryOptions.getHeaders().set("action", "login");
return _vertx.eventBus().<String>request(_address, _json, _deliveryOptions).map(msg -> {
return msg.body();
});
}
}

View File

@@ -0,0 +1,135 @@
/*
* Copyright 2014 Red Hat, Inc.
*
* Red Hat licenses this file to you 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 cn.qaiu.lz.web.service;
import cn.qaiu.lz.web.service.UserService;
import io.vertx.core.Vertx;
import io.vertx.core.Handler;
import io.vertx.core.AsyncResult;
import io.vertx.core.eventbus.EventBus;
import io.vertx.core.eventbus.Message;
import io.vertx.core.eventbus.MessageConsumer;
import io.vertx.core.eventbus.DeliveryOptions;
import io.vertx.core.eventbus.ReplyException;
import io.vertx.core.json.JsonObject;
import io.vertx.core.json.JsonArray;
import java.util.Collection;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import java.util.stream.Collectors;
import io.vertx.serviceproxy.ProxyHandler;
import io.vertx.serviceproxy.ServiceException;
import io.vertx.serviceproxy.ServiceExceptionMessageCodec;
import io.vertx.serviceproxy.HelperUtils;
import io.vertx.serviceproxy.ServiceBinder;
import cn.qaiu.lz.web.model.RealUser;
import cn.qaiu.vx.core.base.BaseAsyncService;
import io.vertx.core.Future;
/*
Generated Proxy code - DO NOT EDIT
@author Roger the Robot
*/
@SuppressWarnings({"unchecked", "rawtypes"})
public class UserServiceVertxProxyHandler extends ProxyHandler {
public static final long DEFAULT_CONNECTION_TIMEOUT = 5 * 60; // 5 minutes
private final Vertx vertx;
private final UserService service;
private final long timerID;
private long lastAccessed;
private final long timeoutSeconds;
private final boolean includeDebugInfo;
public UserServiceVertxProxyHandler(Vertx vertx, UserService service){
this(vertx, service, DEFAULT_CONNECTION_TIMEOUT);
}
public UserServiceVertxProxyHandler(Vertx vertx, UserService service, long timeoutInSecond){
this(vertx, service, true, timeoutInSecond);
}
public UserServiceVertxProxyHandler(Vertx vertx, UserService service, boolean topLevel, long timeoutInSecond){
this(vertx, service, true, timeoutInSecond, false);
}
public UserServiceVertxProxyHandler(Vertx vertx, UserService service, boolean topLevel, long timeoutSeconds, boolean includeDebugInfo) {
this.vertx = vertx;
this.service = service;
this.includeDebugInfo = includeDebugInfo;
this.timeoutSeconds = timeoutSeconds;
try {
this.vertx.eventBus().registerDefaultCodec(ServiceException.class,
new ServiceExceptionMessageCodec());
} catch (IllegalStateException ex) {}
if (timeoutSeconds != -1 && !topLevel) {
long period = timeoutSeconds * 1000 / 2;
if (period > 10000) {
period = 10000;
}
this.timerID = vertx.setPeriodic(period, this::checkTimedOut);
} else {
this.timerID = -1;
}
accessed();
}
private void checkTimedOut(long id) {
long now = System.nanoTime();
if (now - lastAccessed > timeoutSeconds * 1000000000) {
close();
}
}
@Override
public void close() {
if (timerID != -1) {
vertx.cancelTimer(timerID);
}
super.close();
}
private void accessed() {
this.lastAccessed = System.nanoTime();
}
public void handle(Message<JsonObject> msg) {
try{
JsonObject json = msg.body();
String action = msg.headers().get("action");
if (action == null) throw new IllegalStateException("action not specified");
accessed();
switch (action) {
case "login": {
service.login(json.getJsonObject("user") != null ? new cn.qaiu.lz.web.model.RealUser((JsonObject)json.getJsonObject("user")) : null).onComplete(HelperUtils.createHandler(msg, includeDebugInfo));
break;
}
default: throw new IllegalStateException("Invalid action: " + action);
}
} catch (Throwable t) {
if (includeDebugInfo) msg.reply(new ServiceException(500, t.getMessage(), HelperUtils.generateDebugInfo(t)));
else msg.reply(new ServiceException(500, t.getMessage()));
throw t;
}
}
}

View File

@@ -1,9 +1,7 @@
package cn.qaiu.lz;
import cn.qaiu.vx.core.Deploy;
import cn.qaiu.vx.core.util.VertxHolder;
import io.vertx.core.json.JsonObject;
import lombok.val;
/**
@@ -15,15 +13,16 @@ import lombok.val;
public class AppMain {
public static void main(String[] args) {
// 注册枚举类型转换器
Deploy.instance().start(args, AppMain::exec);
}
/**
* 初始化数据库
*
* @param jsonObject 配置
*/
private static void exec(JsonObject jsonObject) {
// JDBCPoolInit.builder().config(jsonObject.getJsonObject("dataSource")).build().initPool();
}

View File

@@ -1,5 +1,6 @@
package cn.qaiu.lz.web.model;
import cn.qaiu.db.ddl.Table;
import cn.qaiu.lz.common.ToJson;
import io.vertx.codegen.annotations.DataObject;
import io.vertx.core.json.JsonObject;
@@ -11,7 +12,10 @@ import lombok.NoArgsConstructor;
@NoArgsConstructor
@AllArgsConstructor
@DataObject
@Table("t_user")
public class RealUser implements ToJson {
private String id;
private String username;
private String password;

View File

@@ -35,4 +35,8 @@ https://cowtransfer.com/core/api/transfer/share/download?transferGuid=e4f41b51-b
//https://download.cowcs.com/cowtransfer/cowtransfer/29188/db32e132e69f490eb4a343b398990f4b.docx?auth_key=1682111861-7b9579fbebb84aaba6bca368d083ab12-0-cbf009f3ffbcbb86191b8cdbc103abce&biz_type=1&business_code=COW_TRANSFER&channel_code=COW_CN_WEB&response-content-disposition=attachment%3B%20filename%3D05-CGB-DB-MENU-V1.02.docx%3Bfilename*%3Dutf-8%27%2705-CGB-DB-MENU-V1.02.docx&user_id=1023860921943729188&x-verify=1
#V2 api
###
https://cowtransfer.com/core/api/dam/asset/files/download/23890683765739569/url/v2
authorization: eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJndWlkIjoiMDc1OTMwNGItMDEwZS00MGJiLTlhNDUtZTczY2Q5ODYzMDQwIiwiZXhwIjoxNjgzNzkzOTExfQ.rE9z0vhogPjUC0I92MqU8U_PKe4j_mGn7lGgPFMGt5c

View File

@@ -54,7 +54,7 @@
<logger name="io.netty" level="warn"/>
<logger name="io.vertx" level="info"/>
<root level="debug">
<!-- <appender-ref ref="STDOUT"/>-->
<appender-ref ref="FILE"/>
<appender-ref ref="STDOUT"/>
<!-- <appender-ref ref="FILE"/>-->
</root>
</configuration>