web service服務搭建
commit
de1a8feaa3
@ -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/
|
@ -0,0 +1,56 @@
|
||||
<?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>
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>2.5.6</version>
|
||||
<relativePath/> <!-- lookup parent from repository -->
|
||||
</parent>
|
||||
<groupId>com.docus</groupId>
|
||||
<artifactId>docus-webservice</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<name>docus-webservice</name>
|
||||
<description>Demo project for Spring Boot</description>
|
||||
<properties>
|
||||
<java.version>1.8</java.version>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.dom4j</groupId>
|
||||
<artifactId>dom4j</artifactId>
|
||||
<version>2.1.1</version>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/jaxen/jaxen -->
|
||||
<dependency>
|
||||
<groupId>jaxen</groupId>
|
||||
<artifactId>jaxen</artifactId>
|
||||
<version>1.1.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>fastjson</artifactId>
|
||||
<version>1.2.75</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
@ -0,0 +1,13 @@
|
||||
package com.docus.service;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication
|
||||
public class DocusServiceApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(DocusServiceApplication.class, args);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
package com.docus.service.entity;
|
||||
|
||||
/**
|
||||
* 代码库
|
||||
*/
|
||||
public enum Codes {
|
||||
SUCCESS("0", "成功"),
|
||||
ERROR("1", "失败"),
|
||||
RESPONSE("100","Response"),
|
||||
RET_INFO("101","RetInfo"),
|
||||
RET_CODE("102","RetCode"),
|
||||
RET_CON("103","RetCon");
|
||||
//代码
|
||||
private String code;
|
||||
//描述
|
||||
private String message;
|
||||
|
||||
private Codes(String code, String messgae) {
|
||||
this.code = code;
|
||||
this.message = messgae;
|
||||
}
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
}
|
@ -0,0 +1,62 @@
|
||||
package com.docus.service.entity;
|
||||
|
||||
import org.dom4j.Document;
|
||||
import org.dom4j.DocumentHelper;
|
||||
import org.dom4j.Element;
|
||||
|
||||
/**
|
||||
* 返回结果工具类
|
||||
*/
|
||||
public class ResultUtils {
|
||||
/**
|
||||
* 通过document对象返回节点对象
|
||||
* @param response
|
||||
* @param name
|
||||
* @return
|
||||
*/
|
||||
public static Element getElement(Element response,String name){
|
||||
Element element = response.elementByID(name);
|
||||
return element;
|
||||
}
|
||||
|
||||
/**
|
||||
* 成功返回
|
||||
* @return
|
||||
*/
|
||||
public static Document success(){
|
||||
// 1、创建document对象
|
||||
Document document= DocumentHelper.createDocument();
|
||||
//2.创建根节点
|
||||
Element response=document.addElement(Codes.RESPONSE.getMessage());
|
||||
// 3、生成子节点及子节点内容
|
||||
Element RetInfo = response.addElement(Codes.RET_INFO.getMessage());
|
||||
//4.生成代码和描述节点
|
||||
Element resCode = RetInfo.addElement(Codes.RET_CODE.getMessage());
|
||||
Element retCon = RetInfo.addElement(Codes.RET_CON.getMessage());
|
||||
//赋值
|
||||
resCode.setText(String.valueOf(Codes.SUCCESS.getCode()));
|
||||
retCon.setText(Codes.SUCCESS.getMessage());
|
||||
return document;
|
||||
}
|
||||
|
||||
/**
|
||||
* 失败返回
|
||||
* @return
|
||||
*/
|
||||
public static Document fail(){
|
||||
// 1、创建document对象
|
||||
Document document= DocumentHelper.createDocument();
|
||||
//2.创建根节点
|
||||
Element response=document.addElement(Codes.RESPONSE.getMessage());
|
||||
// 3、生成子节点及子节点内容
|
||||
Element RetInfo = response.addElement(Codes.RET_INFO.getMessage());
|
||||
//4.生成代码和描述节点
|
||||
Element resCode = RetInfo.addElement(Codes.RET_CODE.getMessage());
|
||||
Element retCon = RetInfo.addElement(Codes.RET_CON.getMessage());
|
||||
//赋值
|
||||
resCode.setText(String.valueOf(Codes.ERROR.getCode()));
|
||||
retCon.setText(Codes.ERROR.getMessage());
|
||||
return document;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
package com.docus.webservice;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication
|
||||
public class DocusWebserviceApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(DocusWebserviceApplication.class, args);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
package com.docus.webservice;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
@SpringBootTest
|
||||
class DocusWebserviceApplicationTests {
|
||||
|
||||
@Test
|
||||
void contextLoads() {
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue