新增可以动态添加项目V1

master
LEI-DESKTOP 2024-11-08 17:27:42 +08:00
parent 91e1a3c640
commit 9846d05690
18 changed files with 169 additions and 42 deletions

View File

@ -0,0 +1,37 @@
package org.lsh.webservice.ui.config;
import org.apache.cxf.Bus;
import org.apache.cxf.bus.spring.SpringBus;
import org.apache.cxf.jaxws.EndpointImpl;
import org.apache.cxf.transport.servlet.CXFServlet;
import org.lsh.webservice.ui.webservice.TestWebservice;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import javax.annotation.Resource;
import javax.xml.ws.Endpoint;
@Configuration
public class WebServiceConfig {
@Resource
TestWebservice testWebservice;
@Bean
public ServletRegistrationBean destoryServlet(){
return new ServletRegistrationBean(new CXFServlet(),"/services/*");
}
@Bean(name = Bus.DEFAULT_BUS_ID)
public SpringBus springBus(){
return new SpringBus();
}
@Bean
public Endpoint endpoint(){
EndpointImpl endpoint = new EndpointImpl(springBus(),testWebservice);
endpoint.publish("/TestWebservice");
return endpoint;
}
}

View File

@ -1,6 +1,7 @@
package org.lsh.webservice.ui.controller;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.StrUtil;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.lsh.webservice.ui.common.Result;
@ -46,7 +47,12 @@ public class MainController {
){
Project project = projectMapper.findById(wsdl.getProjectId());
if(project == null){
return Result.failed("所选项目ID不存在");
project = new Project();
project.setName(wsdl.getProjectId());
projectMapper.insert(project);
}
if(StrUtil.isBlank(project.getId())){
return Result.failed("项目创建失败:" + wsdl.getProjectId());
}
FormV2 formV2 = null;
try {

View File

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

View File

@ -1,19 +1,18 @@
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 id;
private String name;
private List<? extends TreeItem> children;
public Integer getId() {
public String getId() {
return id;
}
public void setId(Integer id) {
public void setId(String id) {
this.id = id;
}

View File

@ -5,7 +5,7 @@ import java.util.List;
public class Webservice extends TreeItem {
private String wsdl;
private int projectId;
private String projectId;
private List<Operation> operationList;
public String getWsdl() {
@ -24,11 +24,11 @@ public class Webservice extends TreeItem {
this.operationList = operationList;
}
public int getProjectId() {
public String getProjectId() {
return projectId;
}
public void setProjectId(int projectId) {
public void setProjectId(String projectId) {
this.projectId = projectId;
}
}

View File

@ -6,18 +6,18 @@ import java.io.Serializable;
public class OperationQueryVO implements Serializable {
private Integer id;
private String id;
private String operation;
private FormField input;
private FormField output;
private String wsdl;
private String webserviceName;
public Integer getId() {
public String getId() {
return id;
}
public void setId(Integer id) {
public void setId(String id) {
this.id = id;
}

View File

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

View File

@ -16,7 +16,7 @@ public interface OperationMapper {
@Result(property = "name", column = "name"), // 指定属性名和列名的映射关系
@Result(property = "webserviceId", column = "webservice_id"), // 指定属性名和列名的映射关系
})
List<Operation> findByWebserviceId(Integer webserviceId);
List<Operation> findByWebserviceId(String webserviceId);
@Select("select * from operation where id=#{id}")
@Results({

View File

@ -9,16 +9,17 @@ import java.util.List;
public interface ProjectMapper {
@Insert("INSERT INTO PROJECT (NAME) VALUES (#{project.name})")
@Options(useGeneratedKeys = true, keyProperty = "id")
int insert(@Param("project") Project project);
void deleteById(Integer id);
void deleteById(String id);
void update(Project user);
@Select("select * from project where id=#{id}")
Project findById(Integer id);
@Select("select * from PROJECT where id=#{id}")
Project findById(String id);
@Select("select * from project")
@Select("select * from PROJECT")
@Results({
@Result(property = "name", column = "name"), // 指定属性名和列名的映射关系
})

View File

@ -17,5 +17,5 @@ public interface ServerInfoMapper {
@Results({
@Result(property = "name", column = "name"), // 指定属性名和列名的映射关系
})
ServerInfo findByWebserviceId(Integer webserviceId);
ServerInfo findByWebserviceId(String webserviceId);
}

View File

@ -19,13 +19,13 @@ public interface WebserviceMapper {
@Result(property = "name", column = "name"), // 指定属性名和列名的映射关系
@Result(property = "projectId", column = "PROJECT_ID"), // 指定属性名和列名的映射关系
})
List<Webservice> findByProjectId(Integer projectId);
List<Webservice> findByProjectId(String projectId);
@Select("select * from webservice where id=#{id}")
@Results({
@Result(property = "name", column = "name"), // 指定属性名和列名的映射关系
@Result(property = "projectId", column = "PROJECT_ID"), // 指定属性名和列名的映射关系
})
Webservice findById(Integer id);
Webservice findById(String id);
}

View File

@ -0,0 +1,18 @@
package org.lsh.webservice.ui.webservice;
import org.lsh.webservice.ui.webservice.dto.Request;
import org.lsh.webservice.ui.webservice.dto.Response;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebService;
import javax.xml.ws.soap.SOAPBinding;
import javax.xml.ws.BindingType;
@WebService(name = "TestWebservice",targetNamespace = "org.lsh.webservice.ui")
@BindingType(SOAPBinding.SOAP12HTTP_BINDING)
public interface TestWebservice {
@WebMethod
Response sayHello(@WebParam(name = "request") Request request);
}

View File

@ -0,0 +1,4 @@
package org.lsh.webservice.ui.webservice.dto;
public class Request {
}

View File

@ -0,0 +1,34 @@
package org.lsh.webservice.ui.webservice.dto;
/**
*
*/
public class Response {
private boolean status;
private int code;
private String message;
public boolean isStatus() {
return status;
}
public void setStatus(boolean status) {
this.status = status;
}
public int getCode() {
return code;
}
public void setCode(int code) {
this.code = code;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
}

View File

@ -0,0 +1,26 @@
package org.lsh.webservice.ui.webservice.impl;
import org.lsh.webservice.ui.webservice.TestWebservice;
import org.lsh.webservice.ui.webservice.dto.Request;
import org.lsh.webservice.ui.webservice.dto.Response;
import org.springframework.stereotype.Component;
import javax.jws.WebService;
@Component
@WebService(
name = "TestWebservice",
targetNamespace = "org.lsh.webservice.ui",
endpointInterface = "org.lsh.webservice.ui.webservice.TestWebservice")
public class TestWebserviceImpl implements TestWebservice {
@Override
public Response sayHello(Request request) {
Response response = new Response();
response.setStatus(true);
response.setCode(1);
response.setMessage("Hello this is message ");
return response;
}
}

View File

@ -10,7 +10,7 @@ spring:
content-type: text/html
cache: false
datasource:
url: jdbc:h2:file:./data/xxx-demo;MODE=MySQL;AUTO_SERVER=TRUE;
url: jdbc:h2:file:./data/xxx-demo;MODE=MySQL;DB_CLOSE_ON_EXIT=FALSE;AUTO_SERVER=TRUE;
driverClassName: org.h2.Driver
username: sa
password: password

View File

@ -1,23 +1,25 @@
CREATE TABLE IF NOT EXISTS Project (
id INT PRIMARY KEY AUTO_INCREMENT,
name VARCHAR(255)
id UUID DEFAULT RANDOM_UUID(),
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
`id` UUID DEFAULT RANDOM_UUID(),
`name` varchar(255) NULL,
`wsdl` varchar(255) NULL,
`project_id` varchar(255) NOT 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 `OPERATION` (
`id` UUID DEFAULT RANDOM_UUID(),
`name` varchar(255) NOT NULL,
`webservice_id` varchar(255) NOT NULL,
`input` varchar(255) NOT NULL,
`output` varchar(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
`id` UUID DEFAULT RANDOM_UUID(),
`webservice_id` varchar(255) NOT NULL,
`form_json` TEXT NOT NULL
);

View File

@ -3,7 +3,7 @@ Vue.component('add-wsdl', {
template: `
<el-form ref="form" :model="form" label-width="80px">
<el-form-item label="项目">
<el-select v-model="form.projectId" placeholder="请选择活动区域">
<el-select v-model="form.projectId" placeholder="请选择或者输入项目名称" allow-create filterable default-first-option>
<el-option v-for="project in projectList" :key="project.id" :label="project.name" :value="project.id"></el-option>
</el-select>
</el-form-item>
@ -23,7 +23,7 @@ Vue.component('add-wsdl', {
projectList: [],
form: {
wsdl: '',
projectId: 1
projectId: ''
}
}
},