master
shihua.lei 2024-10-21 08:03:15 +08:00
commit a714b77e7d
141 changed files with 12673 additions and 0 deletions

33
.gitignore vendored Normal file
View File

@ -0,0 +1,33 @@
HELP.md
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
!**/src/test/**/target/
### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr
### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
!**/src/main/**/build/
!**/src/test/**/build/
### VS Code ###
.vscode/

6
data/xxx-demo.lock.db Normal file
View File

@ -0,0 +1,6 @@
#FileLock
#Fri Oct 18 21:21:17 CST 2024
server=10.30.51.139\:41559
hostName=IT0100300490.super.local
method=file
id=1929fca24482853a181b737e7bf57fab685d7cf744e

BIN
data/xxx-demo.mv.db Normal file

Binary file not shown.

93
data/xxx-demo.trace.db Normal file
View File

@ -0,0 +1,93 @@
2024-10-18 13:05:12 jdbc[3]: exception
org.h2.jdbc.JdbcSQLSyntaxErrorException: Table "CATALOGS" not found (this database is empty); SQL statement:
select catalog_name from information_schema.catalogs [42104-220]
2024-10-18 13:05:43 jdbc[3]: exception
org.h2.jdbc.JdbcSQLSyntaxErrorException: Table "CATALOGS" not found (this database is empty); SQL statement:
select catalog_name from information_schema.catalogs [42104-220]
2024-10-18 21:20:20.404501+08:00 database: flush
org.h2.message.DbException: General error: "org.h2.mvstore.MVStoreException: The file is locked: D:/IdeaProjects/webservice-ui/data/xxx-demo.mv.db [2.3.232/7]" [50000-232]
at org.h2.message.DbException.get(DbException.java:212)
at org.h2.message.DbException.convert(DbException.java:407)
at org.h2.mvstore.db.Store.lambda$new$0(Store.java:122)
at org.h2.mvstore.MVStore.handleException(MVStore.java:1546)
at org.h2.mvstore.MVStore.panic(MVStore.java:371)
at org.h2.mvstore.MVStore.<init>(MVStore.java:291)
at org.h2.mvstore.MVStore$Builder.open(MVStore.java:2035)
at org.h2.mvstore.db.Store.<init>(Store.java:133)
at org.h2.engine.Database.<init>(Database.java:326)
at org.h2.engine.Engine.openSession(Engine.java:92)
at org.h2.engine.Engine.openSession(Engine.java:222)
at org.h2.engine.Engine.createSession(Engine.java:201)
at org.h2.engine.SessionRemote.connectEmbeddedOrServer(SessionRemote.java:344)
at org.h2.jdbc.JdbcConnection.<init>(JdbcConnection.java:124)
at org.h2.Driver.connect(Driver.java:59)
at org.jkiss.dbeaver.model.impl.jdbc.JDBCDataSource.lambda$0(JDBCDataSource.java:176)
at org.jkiss.dbeaver.model.impl.jdbc.JDBCDataSource.openConnection(JDBCDataSource.java:195)
at org.jkiss.dbeaver.ext.generic.model.GenericDataSource.openConnection(GenericDataSource.java:135)
at org.jkiss.dbeaver.ext.h2.model.H2DataSource.openConnection(H2DataSource.java:74)
at org.jkiss.dbeaver.model.impl.jdbc.JDBCExecutionContext.connect(JDBCExecutionContext.java:101)
at org.jkiss.dbeaver.model.impl.jdbc.JDBCRemoteInstance.initializeMainContext(JDBCRemoteInstance.java:100)
at org.jkiss.dbeaver.model.impl.jdbc.JDBCRemoteInstance.<init>(JDBCRemoteInstance.java:59)
at org.jkiss.dbeaver.model.impl.jdbc.JDBCDataSource.initializeRemoteInstance(JDBCDataSource.java:109)
at org.jkiss.dbeaver.ext.generic.model.GenericDataSource.<init>(GenericDataSource.java:107)
at org.jkiss.dbeaver.ext.h2.model.H2DataSource.<init>(H2DataSource.java:43)
at org.jkiss.dbeaver.ext.h2.model.H2MetaModel.createDataSourceImpl(H2MetaModel.java:47)
at org.jkiss.dbeaver.ext.generic.GenericDataSourceProvider.openDataSource(GenericDataSourceProvider.java:106)
at org.jkiss.dbeaver.registry.DataSourceDescriptor.connect(DataSourceDescriptor.java:914)
at org.jkiss.dbeaver.runtime.jobs.ConnectJob.run(ConnectJob.java:70)
at org.jkiss.dbeaver.runtime.jobs.ConnectionTestJob.run(ConnectionTestJob.java:103)
at org.jkiss.dbeaver.model.runtime.AbstractJob.run(AbstractJob.java:105)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)
Caused by: org.h2.jdbc.JdbcSQLNonTransientException: General error: "org.h2.mvstore.MVStoreException: The file is locked: D:/IdeaProjects/webservice-ui/data/xxx-demo.mv.db [2.3.232/7]" [50000-232]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:566)
at org.h2.message.DbException.getJdbcSQLException(DbException.java:489)
... 32 more
Caused by: org.h2.mvstore.MVStoreException: The file is locked: D:/IdeaProjects/webservice-ui/data/xxx-demo.mv.db [2.3.232/7]
at org.h2.mvstore.DataUtils.newMVStoreException(DataUtils.java:996)
at org.h2.mvstore.SingleFileStore.lockFileChannel(SingleFileStore.java:143)
at org.h2.mvstore.SingleFileStore.open(SingleFileStore.java:117)
at org.h2.mvstore.SingleFileStore.open(SingleFileStore.java:81)
at org.h2.mvstore.MVStore.<init>(MVStore.java:286)
... 26 more
2024-10-18 22:06:02.311591+08:00 jdbc[3]: exception
org.h2.jdbc.JdbcSQLSyntaxErrorException: Syntax error in SQL statement "CREATE TABLE IF NOT EXISTS `server_info` (\000d\000a `id` UUID PRIMARY KEY [*]DEFAULT RANDOM_UUID(),\000d\000a `form_json` TEXT NOT NULL\000d\000a)\000d\000a"; expected "HASH, CONSTRAINT, COMMENT, UNIQUE, NOT NULL, CHECK, REFERENCES, ,, )"; SQL statement:
CREATE TABLE IF NOT EXISTS `server_info` (
`id` UUID PRIMARY KEY DEFAULT RANDOM_UUID(),
`form_json` TEXT NOT NULL
)
[42001-232]
2024-10-18 22:06:20.386059+08:00 jdbc[3]: exception
org.h2.jdbc.JdbcSQLSyntaxErrorException: Syntax error in SQL statement "CREATE TABLE IF NOT EXISTS `server_info` (\000d\000a `id` UUID PRIMARY KEY [*]RANDOM_UUID(),\000d\000a `form_json` TEXT NOT NULL\000d\000a)"; expected "HASH, CONSTRAINT, COMMENT, UNIQUE, NOT NULL, CHECK, REFERENCES, ,, )"; SQL statement:
CREATE TABLE IF NOT EXISTS `server_info` (
`id` UUID PRIMARY KEY RANDOM_UUID(),
`form_json` TEXT NOT NULL
) [42001-232]
2024-10-18 22:06:42.672239+08:00 jdbc[3]: exception
org.h2.jdbc.JdbcSQLSyntaxErrorException: Syntax error in SQL statement "CREATE TABLE IF NOT EXISTS `server_info` (\000d\000a `id` UUID PRIMARY KEY [*]DEFAULT RANDOM_UUID(),\000d\000a `form_json` VARCHAR(4096) NOT NULL\000d\000a)"; expected "HASH, CONSTRAINT, COMMENT, UNIQUE, NOT NULL, CHECK, REFERENCES, ,, )"; SQL statement:
CREATE TABLE IF NOT EXISTS `server_info` (
`id` UUID PRIMARY KEY DEFAULT RANDOM_UUID(),
`form_json` VARCHAR(4096) NOT NULL
) [42001-232]
2024-10-18 22:06:57.257134+08:00 jdbc[3]: exception
org.h2.jdbc.JdbcSQLSyntaxErrorException: Syntax error in SQL statement "CREATE TABLE IF NOT EXISTS `server_info` (\000d\000a `id` VARCHAR PRIMARY KEY [*]DEFAULT RANDOM_UUID(),\000d\000a `form_json` VARCHAR NOT NULL\000d\000a)"; expected "HASH, CONSTRAINT, COMMENT, UNIQUE, NOT NULL, CHECK, REFERENCES, ,, )"; SQL statement:
CREATE TABLE IF NOT EXISTS `server_info` (
`id` VARCHAR PRIMARY KEY DEFAULT RANDOM_UUID(),
`form_json` VARCHAR NOT NULL
) [42001-232]
2024-10-18 22:07:18.125705+08:00 jdbc[3]: exception
org.h2.jdbc.JdbcSQLSyntaxErrorException: Syntax error in SQL statement "CREATE TABLE IF NOT EXISTS `server_info` (\000d\000a `id` VARCHAR PRIMARY KEY [*]DEFAULT RANDOM_UUID()\000d\000a)"; expected "HASH, CONSTRAINT, COMMENT, UNIQUE, NOT NULL, CHECK, REFERENCES, ,, )"; SQL statement:
CREATE TABLE IF NOT EXISTS `server_info` (
`id` VARCHAR PRIMARY KEY DEFAULT RANDOM_UUID()
) [42001-232]
2024-10-18 22:07:37.716518+08:00 jdbc[3]: exception
org.h2.jdbc.JdbcSQLSyntaxErrorException: Syntax error in SQL statement "CREATE TABLE IF NOT EXISTS `server_info` (\000d\000a `id` varchar(32) PRIMARY KEY [*]DEFAULT RANDOM_UUID(),\000d\000a `form_json` TEXT NOT NULL\000d\000a)"; expected "HASH, CONSTRAINT, COMMENT, UNIQUE, NOT NULL, CHECK, REFERENCES, ,, )"; SQL statement:
CREATE TABLE IF NOT EXISTS `server_info` (
`id` varchar(32) PRIMARY KEY DEFAULT RANDOM_UUID(),
`form_json` TEXT NOT NULL
) [42001-232]
2024-10-18 22:09:47.904770+08:00 jdbc[3]: exception
org.h2.jdbc.JdbcSQLSyntaxErrorException: Syntax error in SQL statement "CREATE TABLE IF NOT EXISTS `server_info` (\000d\000a id uuid PRIMARY KEY [*]DEFAULT RANDOM_UUID(),\000d\000a form_json TEXT NOT NULL\000d\000a)"; expected "HASH, CONSTRAINT, COMMENT, UNIQUE, NOT NULL, CHECK, REFERENCES, ,, )"; SQL statement:
CREATE TABLE IF NOT EXISTS `server_info` (
id uuid PRIMARY KEY DEFAULT RANDOM_UUID(),
form_json TEXT NOT NULL
) [42001-232]

117
pom.xml Normal file
View File

@ -0,0 +1,117 @@
<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.lsh.webservice.ui</groupId>
<artifactId>webservice-ui</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>webservice-ui</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>1.8</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<spring-boot.version>2.4.2</spring-boot.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jdbc</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>2.1.4</version>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
<version>3.2.6</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
<version>3.2.7</version>
</dependency>
<!-- JSON转换工具 -->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>2.0.35</version>
</dependency>
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-poi</artifactId>
<version>5.8.10</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>${spring-boot.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${spring-boot.version}</version>
<configuration>
<mainClass>org.lsh.webservice.ui.WebserviceUiApplication</mainClass>
<skip>true</skip>
</configuration>
<executions>
<execution>
<id>repackage</id>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

@ -0,0 +1,13 @@
package org.lsh.webservice.ui;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class WebserviceUiApplication {
public static void main(String[] args) {
SpringApplication.run(WebserviceUiApplication.class, args);
}
}

View File

@ -0,0 +1,51 @@
/*
* Copyright (c) 2020 pig4cloud Authors. All Rights Reserved.
*
* 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 org.lsh.webservice.ui.common;
/**
* @Classname CommonConstants
* @Date 2021/5/10 10:07
* @Created by leishihua
*/
public enum CommonConstants {
SUCCESS("SUCCESS",0),
FAIL("FAIL",1);
private String key;
private Integer value;
CommonConstants(String key, Integer value) {
this.key = key;
this.value = value;
}
public String getKey() {
return key;
}
public void setKey(String key) {
this.key = key;
}
public Integer getValue() {
return value;
}
public void setValue(Integer value) {
this.value = value;
}
}

View File

@ -0,0 +1,73 @@
package org.lsh.webservice.ui.common;
/** return body define
* @author leishihua
* @param <T>
*/
public class Result<T> {
private int code;
private T data;
private String msg;
public int getCode() {
return code;
}
public void setCode(int code) {
this.code = code;
}
public T getData() {
return data;
}
public void setData(T data) {
this.data = data;
}
public String getMsg() {
return msg;
}
public void setMsg(String msg) {
this.msg = msg;
}
public static <T> Result<T> ok() {
return restResult(null, CommonConstants.SUCCESS.getValue(), "success");
}
public static <T> Result<T> ok(T data) {
return restResult(data, CommonConstants.SUCCESS.getValue(), null);
}
public static <T> Result<T> ok(T data, String msg) {
return restResult(data, CommonConstants.SUCCESS.getValue(), msg);
}
public static <T> Result<T> failed() {
return restResult(null, CommonConstants.FAIL.getValue(), null);
}
public static <T> Result<T> failed(String msg) {
return restResult(null, CommonConstants.FAIL.getValue(), msg);
}
public static <T> Result<T> failed(T data) {
return restResult(data, CommonConstants.FAIL.getValue(), null);
}
public static <T> Result<T> failed(T data, String msg) {
return restResult(data, CommonConstants.FAIL.getValue(), msg);
}
private static <T> Result<T> restResult(T data, int code, String msg) {
Result<T> apiResult = new Result<>();
apiResult.setCode(code);
apiResult.setData(data);
apiResult.setMsg(msg);
return apiResult;
}
}

View File

@ -0,0 +1,137 @@
package org.lsh.webservice.ui.controller;
import cn.hutool.core.collection.CollectionUtil;
import com.alibaba.fastjson.JSON;
import org.lsh.webservice.ui.common.Result;
import org.lsh.webservice.ui.entity.FormField;
import org.lsh.webservice.ui.entity.FormItemV2;
import org.lsh.webservice.ui.entity.FormV2;
import org.lsh.webservice.ui.entity.dto.ServerInfo;
import org.lsh.webservice.ui.entity.tree.Operation;
import org.lsh.webservice.ui.entity.tree.Project;
import org.lsh.webservice.ui.entity.tree.Webservice;
import org.lsh.webservice.ui.entity.vo.OperationQueryVO;
import org.lsh.webservice.ui.entity.vo.Wsdl;
import org.lsh.webservice.ui.mapper.OperationMapper;
import org.lsh.webservice.ui.mapper.ProjectMapper;
import org.lsh.webservice.ui.mapper.ServerInfoMapper;
import org.lsh.webservice.ui.mapper.WebserviceMapper;
import org.lsh.webservice.ui.utils.ExplainWebservice;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;
@Controller("MainController")
public class MainController {
@Resource
ProjectMapper projectMapper;
@Resource
WebserviceMapper webserviceMapper;
@Resource
OperationMapper operationMapper;
@Resource
ServerInfoMapper serverInfoMapper;
@PostMapping("/add-webservice")
@ResponseBody
public Result<FormV2> addWsdl(
@RequestBody Wsdl wsdl
){
Project project = projectMapper.findById(wsdl.getProjectId());
if(project == null){
return Result.failed("所选项目ID不存在");
}
FormV2 formV2 = null;
try {
formV2 = ExplainWebservice.explainWsdlV2(wsdl.getWsdl());
}catch (Exception e){
return Result.failed("解析wsdl失败" + e.getMessage());
}
Webservice webservice = new Webservice();
webservice.setName(formV2.getServerName());
webservice.setWsdl(wsdl.getWsdl());
webservice.setProjectId(project.getId());
webserviceMapper.insert(webservice);
List<FormItemV2> formItemV2List = formV2.getFormItemV2List();
if(CollectionUtil.isNotEmpty(formItemV2List)){
for (FormItemV2 formItemV2 : formItemV2List) {
Operation operation = new Operation();
operation.setWebserviceId(webservice.getId());
operation.setName(formItemV2.getOperation());
operation.setInput(JSON.toJSONString(formItemV2.getInput()));
operation.setOutput(JSON.toJSONString(formItemV2.getOutput()));
operationMapper.insert(operation);
}
}
return Result.ok();
}
@PostMapping("/explain-wsdl")
@ResponseBody
public Result<FormV2> receiveCheckPlan(
@RequestBody Webservice webservice
){
System.out.println("wsdl:" + webservice.getWsdl());
ServerInfo serverInfo = serverInfoMapper.findByWebserviceId(webservice.getId());
if(serverInfo != null){
String formJson = serverInfo.getFormJson();
FormV2 formV2 = JSON.parseObject(formJson, FormV2.class);
return Result.ok(formV2);
}
return Result.ok();
}
@PostMapping("/query-projects")
@ResponseBody
public Result<List<Project>> queryProjects(
){
//
List<Project> projects = projectMapper.findAll();
for (Project project : projects) {
List<Webservice> webserviceList = webserviceMapper.findByProjectId(project.getId());
project.setChildren(webserviceList);
if(CollectionUtil.isNotEmpty(webserviceList)){
for (Webservice webservice : webserviceList) {
List<Operation> operationList = operationMapper.findByWebserviceId(webservice.getId());
webservice.setChildren(operationList);
}
}
}
return Result.ok(projects);
}
@GetMapping("/query-operation")
@ResponseBody
public Result<OperationQueryVO> queryOperation(
@RequestParam(value = "webserviceId",required = false)Integer webserviceId,
@RequestParam(value = "operationName",required = false)String operationName,
@RequestParam("operationId")Integer operationId
){
OperationQueryVO operationQueryVO = new OperationQueryVO();
Operation operation = operationMapper.findById(operationId);
if(operation != null) {
Webservice webservice = webserviceMapper.findById(operation.getWebserviceId());
operationQueryVO.setOperation(operation.getName());
operationQueryVO.setId(operation.getId());
operationQueryVO.setInput(JSON.parseObject(operation.getInput(), FormField.class));
operationQueryVO.setOutput(JSON.parseObject(operation.getOutput(), FormField.class));
if(webservice != null){
operationQueryVO.setWsdl(webservice.getWsdl());
operationQueryVO.setWebserviceName(webservice.getName());
}
}
return Result.ok(operationQueryVO);
}
@RequestMapping("/index")
public String hello(){
return "index"; // index.html页面
}
}

View File

@ -0,0 +1,44 @@
package org.lsh.webservice.ui.entity;
import java.io.Serializable;
import java.util.List;
public class FormField implements Serializable {
protected String fieldName;
protected String typeName;
protected boolean require;
private List<FormField> fields;
public String getFieldName() {
return fieldName;
}
public void setFieldName(String fieldName) {
this.fieldName = fieldName;
}
public String getTypeName() {
return typeName;
}
public void setTypeName(String typeName) {
this.typeName = typeName;
}
public boolean isRequire() {
return require;
}
public void setRequire(boolean require) {
this.require = require;
}
public List<FormField> getFields() {
return fields;
}
public void setFields(List<FormField> fields) {
this.fields = fields;
}
}

View File

@ -0,0 +1,32 @@
package org.lsh.webservice.ui.entity;
public class FormItemV2 {
private String operation;
private FormField input;
private FormField output;
public String getOperation() {
return operation;
}
public void setOperation(String operation) {
this.operation = operation;
}
public FormField getInput() {
return input;
}
public void setInput(FormField input) {
this.input = input;
}
public FormField getOutput() {
return output;
}
public void setOutput(FormField output) {
this.output = output;
}
}

View File

@ -0,0 +1,24 @@
package org.lsh.webservice.ui.entity;
import java.util.List;
public class FormV2 {
private String serverName;
List<org.lsh.webservice.ui.entity.FormItemV2> formItemV2List;
public String getServerName() {
return serverName;
}
public void setServerName(String serverName) {
this.serverName = serverName;
}
public List<org.lsh.webservice.ui.entity.FormItemV2> getFormItemV2List() {
return formItemV2List;
}
public void setFormItemV2List(List<org.lsh.webservice.ui.entity.FormItemV2> formItemV2List) {
this.formItemV2List = formItemV2List;
}
}

View File

@ -0,0 +1,45 @@
package org.lsh.webservice.ui.entity.dto;
public class ServerInfo {
private String id;
private int id2;
private int webserviceId;
private String formJson;
public ServerInfo(int webserviceId, String formJson) {
this.webserviceId = webserviceId;
this.formJson = formJson;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public int getId2() {
return id2;
}
public void setId2(int id2) {
this.id2 = id2;
}
public int getWebserviceId() {
return webserviceId;
}
public void setWebserviceId(int webserviceId) {
this.webserviceId = webserviceId;
}
public String getFormJson() {
return formJson;
}
public void setFormJson(String formJson) {
this.formJson = formJson;
}
}

View File

@ -0,0 +1,37 @@
package org.lsh.webservice.ui.entity.tree;
public class Operation extends TreeItem{
private int webserviceId;
/** JSON
*
*/
private String input;
/** JSON
*
*/
private String output;
public int getWebserviceId() {
return webserviceId;
}
public void setWebserviceId(int webserviceId) {
this.webserviceId = webserviceId;
}
public String getInput() {
return input;
}
public void setInput(String input) {
this.input = input;
}
public String getOutput() {
return output;
}
public void setOutput(String output) {
this.output = output;
}
}

View File

@ -0,0 +1,4 @@
package org.lsh.webservice.ui.entity.tree;
public class Project extends TreeItem {
}

View File

@ -0,0 +1,35 @@
package org.lsh.webservice.ui.entity.tree;
import org.lsh.webservice.ui.entity.FormItemV2;
import java.util.List;
public class TreeItem {
private Integer id;
private String name;
private List<? extends TreeItem> children;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public List<? extends TreeItem> getChildren() {
return children;
}
public void setChildren(List<? extends TreeItem> children) {
this.children = children;
}
}

View File

@ -0,0 +1,34 @@
package org.lsh.webservice.ui.entity.tree;
import java.util.List;
public class Webservice extends TreeItem {
private String wsdl;
private int projectId;
private List<Operation> operationList;
public String getWsdl() {
return wsdl;
}
public void setWsdl(String wsdl) {
this.wsdl = wsdl;
}
public List<Operation> getOperationList() {
return operationList;
}
public void setOperationList(List<Operation> operationList) {
this.operationList = operationList;
}
public int getProjectId() {
return projectId;
}
public void setProjectId(int projectId) {
this.projectId = projectId;
}
}

View File

@ -0,0 +1,63 @@
package org.lsh.webservice.ui.entity.vo;
import org.lsh.webservice.ui.entity.FormField;
import java.io.Serializable;
public class OperationQueryVO implements Serializable {
private Integer id;
private String operation;
private FormField input;
private FormField output;
private String wsdl;
private String webserviceName;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getOperation() {
return operation;
}
public void setOperation(String operation) {
this.operation = operation;
}
public FormField getInput() {
return input;
}
public void setInput(FormField input) {
this.input = input;
}
public FormField getOutput() {
return output;
}
public void setOutput(FormField output) {
this.output = output;
}
public String getWsdl() {
return wsdl;
}
public void setWsdl(String wsdl) {
this.wsdl = wsdl;
}
public String getWebserviceName() {
return webserviceName;
}
public void setWebserviceName(String webserviceName) {
this.webserviceName = webserviceName;
}
}

View File

@ -0,0 +1,22 @@
package org.lsh.webservice.ui.entity.vo;
public class Wsdl {
private String wsdl;
private int projectId;
public String getWsdl() {
return wsdl;
}
public void setWsdl(String wsdl) {
this.wsdl = wsdl;
}
public int getProjectId() {
return projectId;
}
public void setProjectId(int projectId) {
this.projectId = projectId;
}
}

View File

@ -0,0 +1,27 @@
package org.lsh.webservice.ui.mapper;
import org.apache.ibatis.annotations.*;
import org.lsh.webservice.ui.entity.tree.Operation;
import java.util.List;
@Mapper
public interface OperationMapper {
@Insert("INSERT INTO OPERATION (NAME, WEBSERVICE_ID,INPUT,OUTPUT) VALUES(#{operation.name}, #{operation.webserviceId}, #{operation.input}, #{operation.output});")
int insert(@Param("operation")Operation operation);
@Select("select * from operation where webservice_id=#{webserviceId}")
@Results({
@Result(property = "name", column = "name"), // 指定属性名和列名的映射关系
@Result(property = "webserviceId", column = "webservice_id"), // 指定属性名和列名的映射关系
})
List<Operation> findByWebserviceId(Integer webserviceId);
@Select("select * from operation where id=#{id}")
@Results({
@Result(property = "name", column = "name"), // 指定属性名和列名的映射关系
@Result(property = "webserviceId", column = "webservice_id"), // 指定属性名和列名的映射关系
})
Operation findById(Integer id);
}

View File

@ -0,0 +1,27 @@
package org.lsh.webservice.ui.mapper;
import org.apache.ibatis.annotations.*;
import org.lsh.webservice.ui.entity.tree.Project;
import java.util.List;
@Mapper
public interface ProjectMapper {
@Insert("INSERT INTO PROJECT (NAME) VALUES (#{project.name})")
int insert(@Param("project") Project project);
void deleteById(Integer id);
void update(Project user);
@Select("select * from project where id=#{id}")
Project findById(Integer id);
@Select("select * from project")
@Results({
@Result(property = "name", column = "name"), // 指定属性名和列名的映射关系
})
List<Project> findAll();
}

View File

@ -0,0 +1,21 @@
package org.lsh.webservice.ui.mapper;
import org.apache.ibatis.annotations.*;
import org.lsh.webservice.ui.entity.dto.ServerInfo;
import org.lsh.webservice.ui.entity.tree.Operation;
import java.util.List;
@Mapper
public interface ServerInfoMapper {
@Insert("INSERT INTO SERVER_INFO (WEBSERVICE_ID,FORM_JSON) VALUES (#{serverInfo.webserviceId},#{serverInfo.formJson})")
int insert(@Param("serverInfo")ServerInfo serverInfo);
@Select("select * from SERVER_INFO where webservice_id=#{webserviceId}")
@Results({
@Result(property = "name", column = "name"), // 指定属性名和列名的映射关系
})
ServerInfo findByWebserviceId(Integer webserviceId);
}

View File

@ -0,0 +1,31 @@
package org.lsh.webservice.ui.mapper;
import org.apache.ibatis.annotations.*;
import org.lsh.webservice.ui.entity.dto.ServerInfo;
import org.lsh.webservice.ui.entity.tree.Project;
import org.lsh.webservice.ui.entity.tree.Webservice;
import java.util.List;
@Mapper
public interface WebserviceMapper {
@Insert("INSERT INTO WEBSERVICE (NAME, WSDL, PROJECT_ID) VALUES(#{webservice.name}, #{webservice.wsdl}, #{webservice.projectId})")
@Options(useGeneratedKeys = true, keyProperty = "id")
int insert(@Param("webservice") Webservice webservice);
@Select("select * from webservice where project_id=#{projectId}")
@Results({
@Result(property = "name", column = "name"), // 指定属性名和列名的映射关系
@Result(property = "projectId", column = "PROJECT_ID"), // 指定属性名和列名的映射关系
})
List<Webservice> findByProjectId(Integer projectId);
@Select("select * from webservice where id=#{id}")
@Results({
@Result(property = "name", column = "name"), // 指定属性名和列名的映射关系
@Result(property = "projectId", column = "PROJECT_ID"), // 指定属性名和列名的映射关系
})
Webservice findById(Integer id);
}

View File

@ -0,0 +1,77 @@
package org.lsh.webservice.ui.utils;
import org.lsh.webservice.ui.entity.FormField;
import java.lang.reflect.Array;
import java.lang.reflect.Field;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
public class ExplainField {
public static void explain(Field declaredField, List<FormField> formFieldList) throws ClassNotFoundException {
// 判断Field类型
if(declaredField.getType() == List.class || declaredField.getType() == Array.class){
// 获取List的泛型类型
Type genericType = declaredField.getGenericType();
if(genericType instanceof ParameterizedType){
ParameterizedType parameterizedType = (ParameterizedType)genericType;
Type[] actualTypeArguments = parameterizedType.getActualTypeArguments();
if(actualTypeArguments.length>0){
FormField complexType = new FormField();
complexType.setFieldName(declaredField.getName());
complexType.setTypeName(declaredField.getType().getTypeName());
List<FormField> formFields = new ArrayList<>();
complexType.setFields(formFields);
// 获取List的泛型类型
Type actualTypeArgument = actualTypeArguments[0];
Class classes = (Class) actualTypeArgument;
// 泛型类加载器
if(classes != null) {
Field[] declaredFields2 = classes.getDeclaredFields();
for (Field declaredField2 : declaredFields2) {
explain(declaredField2, formFields);
}
}
formFieldList.add(complexType);
}
}
}else if(
declaredField.getType() == String.class
|| declaredField.getType() == Integer.class
|| declaredField.getType() == Double.class
|| declaredField.getType() == java.util.Date.class
|| declaredField.getType() == Boolean.class
|| declaredField.getType() == Long.class
|| declaredField.getType() == BigDecimal.class
|| declaredField.getType() == LocalDateTime.class
|| declaredField.getType() == LocalDate.class
|| declaredField.getType().getTypeName().equals("int")
|| declaredField.getType().getTypeName().equals("long")){
FormField basic = new FormField();
basic.setFieldName(declaredField.getName());
basic.setTypeName(declaredField.getType().getTypeName());
formFieldList.add(basic);
System.out.println(declaredField);
}else {
// 自定义的数据类型
System.out.println("进入自定义数据类型:" + declaredField.getName() + "====" + declaredField.getType());
// 获取该字段的参数类型
Class class2 = (Class)declaredField.getGenericType();
Field[] declaredFields = class2.getDeclaredFields();
FormField complexType = new FormField();
complexType.setFieldName(declaredField.getName());
complexType.setTypeName(declaredField.getType().getTypeName());
List<FormField> formFields = new ArrayList<>();
complexType.setFields(formFields);
for (Field field : declaredFields) {
explain(field, formFields);
}
formFieldList.add(complexType);
}
}
}

View File

@ -0,0 +1,116 @@
package org.lsh.webservice.ui.utils;
import cn.hutool.core.collection.CollectionUtil;
import com.alibaba.fastjson.JSON;
import org.apache.cxf.endpoint.Client;
import org.apache.cxf.endpoint.Endpoint;
import org.apache.cxf.jaxws.endpoint.dynamic.JaxWsDynamicClientFactory;
import org.apache.cxf.service.model.*;
import org.lsh.webservice.ui.entity.FormItemV2;
import org.lsh.webservice.ui.entity.FormV2;
import org.lsh.webservice.ui.entity.FormField;
import javax.xml.namespace.QName;
import java.lang.reflect.Field;
import java.util.*;
public class ExplainWebservice {
public static FormV2 explainWsdlV2(String wsdlUrl){
FormV2 formV2 = new FormV2();
List<FormItemV2> itemV2s = new ArrayList<>();
formV2.setFormItemV2List(itemV2s);
Map<String,FormField> messageMap = new HashMap<>();
// 创建动态客户端
JaxWsDynamicClientFactory factory = JaxWsDynamicClientFactory.newInstance();
Client client = factory.createClient(wsdlUrl);
/**endpointhttp://172.20.29.51:8180/uniplatform/service/UniNewOrderDataService
* toString{},,getEndpointInfoBindingQNameServiceQNameQName*/
Endpoint endpoint = client.getEndpoint();
/**获取Service*/
ServiceInfo serviceInfo = endpoint.getService().getServiceInfos().get(0);
formV2.setServerName(serviceInfo.getName().getLocalPart());
/**创建Service*/
Collection<BindingInfo> bindings = serviceInfo.getBindings();
Map<QName, Object> extensionAttributes = serviceInfo.getExtensionAttributes();
if(extensionAttributes != null) {
extensionAttributes.forEach((key, val) -> {
System.out.println("key:" + key + " values:" + val);
});
}
// portType
// 对于某个访问入口点类型所支持的操作的抽象集合; ----》服务端SEI
//   指出了这个WebService所有支持的操作就是说有哪些方法可供调用。
Map<QName, MessageInfo> messages = serviceInfo.getMessages();
// message 指明一个操作所用到的数据类型,通信消息的数据结构的抽象类型化定义。
// HelloWorldSoapIn是指HelloWorld的输入操作用到的数据类型
// HelloWorldSoapOut是指HelloWorld的输出操作用到的数据类型。二者的element元素指出了与types中对应到的具体类型。
messages.forEach((key,value)->{
List<MessagePartInfo> messageParts = value.getMessageParts();
for (MessagePartInfo messagePart : messageParts) {
Class<?> typeClass = messagePart.getTypeClass();
String field = "";
if(messagePart.getTypeQName()!=null){
field = messagePart.getTypeQName().getLocalPart();
}else if(messagePart.getElementQName()!=null){
field = messagePart.getElementQName().getLocalPart();
}else if(messagePart.getConcreteName()!=null){
field = messagePart.getConcreteName().getLocalPart();
}
try {
Class<?> aClass = Thread.currentThread().getContextClassLoader().loadClass(typeClass.getName());
FormField complex = new FormField();
complex.setFieldName(field);
List<FormField> formFields = new ArrayList<>();
complex.setFields(formFields);
complex.setTypeName(aClass.getTypeName());
Field[] declaredFields = aClass.getDeclaredFields();
System.out.println("====>"+aClass);
for (Field declaredField : declaredFields) {
System.out.println("declaredField:" + declaredField);
org.lsh.webservice.ui.utils.ExplainField.explain(declaredField, formFields);
}
System.out.println("解析表单结果:" + JSON.toJSONString(complex));
messageMap.put(aClass.getSimpleName(),complex);
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
}
});
// Binding-特定端口类型的具体协议和数据格式规范的绑定。----》对应SEI的实现
//   soap:binding元素的transport指明传输协议这里是http协议。
//   operation 指明要暴露给外界调用的操作。
//   use属性指定输入输出的编码方式。
if(CollectionUtil.isNotEmpty(bindings)){
for (BindingInfo binding : bindings) {
for (BindingOperationInfo operation : binding.getOperations()) {
String function = operation.getName().getLocalPart();
String inputTypeName = "";
String outputTypeName = "";
OperationInfo operationInfo = operation.getOperationInfo();
List<MessagePartInfo> inputMessageParts = operationInfo.getInput().getMessageParts();
for (MessagePartInfo inputMessagePart : inputMessageParts) {
inputTypeName = inputMessagePart.getTypeClass().getSimpleName();
}
List<MessagePartInfo> outputMessageParts = operationInfo.getOutput().getMessageParts();
for (MessagePartInfo outputMessagePart : outputMessageParts) {
outputTypeName = outputMessagePart.getTypeClass().getSimpleName();
}
FormItemV2 itemV2 = new FormItemV2();
itemV2.setOperation(function);
itemV2.setInput(messageMap.get(inputTypeName));
itemV2.setOutput(messageMap.get(outputTypeName));
itemV2s.add(itemV2);
}
}
}
return formV2;
}
}

View File

@ -0,0 +1,28 @@
spring:
application:
name: WebServiceUi
# application.yml 示例
thymeleaf:
prefix: classpath:/templates/
suffix: .html
mode: HTML
encoding: UTF-8
content-type: text/html
cache: false
datasource:
url: jdbc:h2:file:./data/xxx-demo;MODE=MySQL;AUTO_SERVER=TRUE;
driverClassName: org.h2.Driver
username: sa
password: password
platform: h2
h2:
console:
enabled: true
path: /h2-console
sql:
init:
data-locations: classpath:db/data.sql
encoding: utf8
schema-locations: classpath:db/schema.sql
server:
port: 9090

View File

@ -0,0 +1,16 @@
CREATE TABLE `Project` (
`id` int(255) NULL ,
`name` varchar(255) NULL
);
CREATE TABLE `WebService` (
`id` int(255) NULL ,
`name` varchar(255) NULL,
`wsdl` varchar(255) NULL,
`project_id` int(255) NULL
);
CREATE TABLE `operation` (
`id` int(255) NULL ,
`name` varchar(255) NULL
);

View File

@ -0,0 +1,23 @@
CREATE TABLE IF NOT EXISTS Project (
id INT PRIMARY KEY AUTO_INCREMENT,
name VARCHAR(255)
);
CREATE TABLE IF NOT EXISTS `WebService` (
`id` INT PRIMARY KEY AUTO_INCREMENT,
`name` varchar(255) NULL,
`wsdl` varchar(255) NULL,
`project_id` int(255) NULL
);
CREATE TABLE IF NOT EXISTS `operation` (
`id` INT PRIMARY KEY AUTO_INCREMENT,
`name` varchar(255) NOT NULL,
`webservice_id` int(255) NOT NULL
);
CREATE TABLE IF NOT EXISTS `server_info` (
`id` UUID DEFAULT RANDOM_UUID(),
`webservice_id` int(255) NOT NULL,
`form_json` TEXT NOT NULL
);

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,2 @@
/** layui-v2.2.5 MIT License By https://www.layui.com */
html #layuicss-skincodecss{display:none;position:absolute;width:1989px}.layui-code-h3,.layui-code-view{position:relative;font-size:12px}.layui-code-view{display:block;margin:10px 0;padding:0;border:1px solid #e2e2e2;border-left-width:6px;background-color:#F2F2F2;color:#333;font-family:Courier New}.layui-code-h3{padding:0 10px;height:32px;line-height:32px;border-bottom:1px solid #e2e2e2}.layui-code-h3 a{position:absolute;right:10px;top:0;color:#999}.layui-code-view .layui-code-ol{position:relative;overflow:auto}.layui-code-view .layui-code-ol li{position:relative;margin-left:45px;line-height:20px;padding:0 5px;border-left:1px solid #e2e2e2;list-style-type:decimal-leading-zero;*list-style-type:decimal;background-color:#fff}.layui-code-view pre{margin:0}.layui-code-notepad{border:1px solid #0C0C0C;border-left-color:#3F3F3F;background-color:#0C0C0C;color:#C2BE9E}.layui-code-notepad .layui-code-h3{border-bottom:none}.layui-code-notepad .layui-code-ol li{background-color:#3F3F3F;border-left:none}

File diff suppressed because one or more lines are too long

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

File diff suppressed because one or more lines are too long

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 701 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 231 KiB

Binary file not shown.

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 777 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Some files were not shown because too many files have changed in this diff Show More