bgts基本环境搭建
parent
639ac226a6
commit
727df755f0
@ -0,0 +1 @@
|
||||
lombok.var.flagUsage = ALLOW
|
@ -0,0 +1,87 @@
|
||||
<?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>demo</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<name>web service</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>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
<version>8.0.15</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>1.16.14</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.spring4all</groupId>
|
||||
<artifactId>swagger-spring-boot-starter</artifactId>
|
||||
<version>1.9.0.RELEASE</version>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/org.apache.commons/commons-lang3 -->
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
<version>3.4</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-boot-starter</artifactId>
|
||||
<version>3.3.0</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.bgts;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication
|
||||
public class DemoApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(DemoApplication.class, args);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,66 @@
|
||||
package com.docus.bgts.config;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.autoconfigure.MybatisPlusProperties;
|
||||
import com.baomidou.mybatisplus.core.MybatisConfiguration;
|
||||
import com.baomidou.mybatisplus.core.config.GlobalConfig;
|
||||
import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.experimental.var;
|
||||
import org.apache.ibatis.logging.nologging.NoLoggingImpl;
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import java.util.Objects;
|
||||
|
||||
@Configuration
|
||||
@RequiredArgsConstructor
|
||||
@EnableTransactionManagement
|
||||
@MapperScan("com.docus.bgts.mapper")
|
||||
@ConditionalOnClass(value = {PaginationInterceptor.class})
|
||||
public class MybatisPlusConfig {
|
||||
|
||||
|
||||
private final MybatisPlusProperties mybatisPlusProperties;
|
||||
@Bean
|
||||
public PaginationInterceptor paginationInterceptor() {
|
||||
PaginationInterceptor paginationInterceptor = new PaginationInterceptor();
|
||||
return paginationInterceptor;
|
||||
}
|
||||
|
||||
@PostConstruct
|
||||
public void initMybatisConfig(){
|
||||
mybatisPlusProperties.setMapperLocations(new String[]{"classpath*:/mapper/*Mapper.xml"});
|
||||
mybatisPlusProperties.setTypeAliasesPackage("com.docus.bgts.entity");
|
||||
|
||||
MybatisConfiguration configuration = mybatisPlusProperties.getConfiguration();
|
||||
if(Objects.isNull(configuration)){
|
||||
configuration=new MybatisConfiguration();
|
||||
}
|
||||
configuration.setMapUnderscoreToCamelCase(true);
|
||||
configuration.setCacheEnabled(true);
|
||||
configuration.setLogImpl(NoLoggingImpl.class);
|
||||
mybatisPlusProperties.setConfiguration(configuration);
|
||||
|
||||
var globalConfig = mybatisPlusProperties.getGlobalConfig();
|
||||
if(Objects.isNull(globalConfig)){
|
||||
globalConfig=new GlobalConfig();
|
||||
}
|
||||
GlobalConfig.DbConfig dbConfig = globalConfig.getDbConfig();
|
||||
if(Objects.isNull(dbConfig)){
|
||||
dbConfig=new GlobalConfig.DbConfig();
|
||||
}
|
||||
configuration.setCallSettersOnNulls(true);
|
||||
dbConfig.setIdType(IdType.ASSIGN_ID);
|
||||
dbConfig.setTableUnderline(true);
|
||||
dbConfig.setLogicDeleteValue("1");
|
||||
dbConfig.setLogicNotDeleteValue("0");
|
||||
dbConfig.setLogicDeleteField("def_flag");
|
||||
globalConfig.setDbConfig(dbConfig);
|
||||
globalConfig.setBanner(false);
|
||||
}
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
package com.docus.bgts.config;
|
||||
|
||||
|
||||
|
||||
import com.docus.bgts.enums.Codes;
|
||||
import com.docus.bgts.handler.ITBasicWebService;
|
||||
import com.docus.bgts.handler.TBasicWebService;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import javax.xml.ws.Endpoint;
|
||||
|
||||
@Configuration
|
||||
public class WebServiceConfig {
|
||||
//把实现类交给spring管理
|
||||
@Bean
|
||||
public ITBasicWebService tBasicWebService() {
|
||||
return new TBasicWebService();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Endpoint endpoint() {
|
||||
System.out.println("-----------------------web service服务已发布-------------------------");
|
||||
String address = "http://"+"0.0.0.0"+":" + Codes.EXTERNAL.getCode()+"/" + Codes.EXTERNAL.getMessage();
|
||||
Endpoint publish = Endpoint.publish(address, tBasicWebService());
|
||||
System.out.println(" "+address);
|
||||
return publish;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,49 @@
|
||||
package com.docus.bgts.enums;
|
||||
|
||||
/**
|
||||
* 代码库
|
||||
*/
|
||||
public enum Codes {
|
||||
//接口成功
|
||||
SUCCESS("0", "成功"),
|
||||
//接口失败
|
||||
ERROR("1", "失败"),
|
||||
//web service返回根节点
|
||||
RESPONSE("100","Response"),
|
||||
//web service返回二级节点
|
||||
RET_INFO("101","RetInfo"),
|
||||
//web service 返回代码
|
||||
RET_CODE("102","RetCode"),
|
||||
//web service返回描述部分
|
||||
RET_CON("103","RetCon"),
|
||||
//web service 服务名
|
||||
EXTERNAL("9201","docus_tBasic_data"),
|
||||
//静态文件存放位置
|
||||
JSON_ADDRESS("999","\\dataConfig\\homeQualitySet.json"),
|
||||
//接收二级节点
|
||||
MSG("201","Msg"),
|
||||
//错误日志编号
|
||||
ERROR_CODE("500","12"),
|
||||
//接收三级节点
|
||||
// PAT_INFO("202","PatInfo"),
|
||||
//静态文件根元素名
|
||||
SELECT_COLUMNS("10000","selectColumns")
|
||||
;
|
||||
//代码
|
||||
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,10 @@
|
||||
package com.docus.bgts.handler;
|
||||
|
||||
|
||||
import javax.jws.WebService;
|
||||
|
||||
@WebService
|
||||
public interface ITBasicWebService {
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
package com.docus.bgts.handler;
|
||||
|
||||
|
||||
import javax.jws.WebService;
|
||||
|
||||
@WebService
|
||||
public class TBasicWebService implements ITBasicWebService {
|
||||
|
||||
}
|
@ -0,0 +1,84 @@
|
||||
package com.docus.bgts.utils;
|
||||
|
||||
|
||||
import com.docus.bgts.enums.Codes;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.dom4j.Document;
|
||||
import org.dom4j.DocumentHelper;
|
||||
import org.dom4j.Element;
|
||||
|
||||
/**
|
||||
* 返回结果工具类
|
||||
*/
|
||||
public class ResultUtils {
|
||||
/**
|
||||
* 通过document对象返回节点对象
|
||||
* @param response
|
||||
* @return
|
||||
*/
|
||||
public static Element getElement(Document response){
|
||||
Element element = response.getRootElement();
|
||||
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 String 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.asXML();
|
||||
}
|
||||
|
||||
/**
|
||||
* 失败返回
|
||||
* @return
|
||||
*/
|
||||
public static String fail(String message){
|
||||
// 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(StringUtils.isNotBlank(message)?message:Codes.ERROR.getMessage());
|
||||
return document.asXML();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,67 @@
|
||||
package com.docus.bgts.utils;
|
||||
|
||||
|
||||
import com.docus.bgts.enums.Codes;
|
||||
import org.dom4j.Document;
|
||||
import org.dom4j.DocumentException;
|
||||
import org.dom4j.Element;
|
||||
import org.dom4j.io.SAXReader;
|
||||
|
||||
import java.io.InputStream;
|
||||
|
||||
public class XmlUtils {
|
||||
//定义解析器和文档对象
|
||||
private SAXReader saxReader;
|
||||
private Document document;
|
||||
|
||||
public XmlUtils(String path) {
|
||||
//获取解析器
|
||||
saxReader = new SAXReader();
|
||||
try {
|
||||
//获取文档对象
|
||||
document = saxReader.read(path);
|
||||
} catch (DocumentException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public XmlUtils(InputStream path) {
|
||||
//获取解析器
|
||||
saxReader = new SAXReader();
|
||||
try {
|
||||
//获取文档对象
|
||||
document = saxReader.read(path);
|
||||
} catch (DocumentException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据节点名称获取内容
|
||||
*
|
||||
* @param name 节点名称
|
||||
* @return 节点内容
|
||||
*/
|
||||
public String getElementText(String name) {
|
||||
//定位根节点
|
||||
Element root = document.getRootElement();
|
||||
//根据名称定位节点
|
||||
Element msg = root.element(Codes.MSG.getMessage());
|
||||
if(msg==null){
|
||||
throw new RuntimeException("没有"+Codes.MSG.getMessage()+"节点");
|
||||
}
|
||||
// Element patInfo = msg.element(Codes.PAT_INFO.getMessage());
|
||||
// if(patInfo==null){
|
||||
// throw new RuntimeException("没有"+Codes.PAT_INFO.getMessage()+"节点");
|
||||
// }
|
||||
Element element = msg.element(name);
|
||||
if(element==null){
|
||||
return null;
|
||||
}
|
||||
//返回节点内容
|
||||
return element.getText();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
server:
|
||||
port: 9797
|
||||
|
||||
mybatis-plus:
|
||||
configuration:
|
||||
map-underscore-to-camel-case: true
|
||||
call-setters-on-nulls: true
|
||||
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
|
||||
global-config:
|
||||
db-config:
|
||||
field-strategy: NOT_EMPTY
|
||||
db-type: MYSQL
|
||||
|
||||
spring:
|
||||
datasource:
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
username: docus
|
||||
password: docus702
|
||||
url: jdbc:mysql://db.docus.cn:3306/docus_medicalrecord?characterEncoding=utf8&useSSL=false&serverTimezone=UTC&rewriteBatchedStatements=true
|
Loading…
Reference in New Issue