mirror of
https://github.com/chillzhuang/blade-tool
synced 2024-11-05 18:19:29 +08:00
🎉 2.8.0.RELEASE 新增在线报表模块
This commit is contained in:
parent
5b9a64338f
commit
0134dc660c
@ -1,7 +1,7 @@
|
|||||||
<p align="center">
|
<p align="center">
|
||||||
<img src="https://img.shields.io/badge/license-LGPL%20v3-blue.svg" alt="Build Status">
|
<img src="https://img.shields.io/badge/license-LGPL%20v3-blue.svg" alt="Build Status">
|
||||||
<img src="https://img.shields.io/badge/Spring%20Cloud-Hoxton.SR7-blue.svg" alt="Coverage Status">
|
<img src="https://img.shields.io/badge/Spring%20Cloud-Hoxton.SR8-blue.svg" alt="Coverage Status">
|
||||||
<img src="https://img.shields.io/badge/Spring%20Boot-2.2.9.RELEASE-blue.svg" alt="Downloads">
|
<img src="https://img.shields.io/badge/Spring%20Boot-2.2.11.RELEASE-blue.svg" alt="Downloads">
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
## SpringBlade微服务开发平台
|
## SpringBlade微服务开发平台
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>org.springblade</groupId>
|
<groupId>org.springblade</groupId>
|
||||||
<artifactId>blade-tool</artifactId>
|
<artifactId>blade-tool</artifactId>
|
||||||
<version>2.7.3</version>
|
<version>2.8.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
@ -88,7 +88,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.alibaba</groupId>
|
<groupId>com.alibaba</groupId>
|
||||||
<artifactId>druid-spring-boot-starter</artifactId>
|
<artifactId>druid-spring-boot-starter</artifactId>
|
||||||
<version>1.1.22</version>
|
<version>1.2.1</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- MySQL -->
|
<!-- MySQL -->
|
||||||
<dependency>
|
<dependency>
|
||||||
|
@ -97,7 +97,7 @@ mybatis-plus:
|
|||||||
swagger:
|
swagger:
|
||||||
title: SpringBlade 接口文档系统
|
title: SpringBlade 接口文档系统
|
||||||
description: SpringBlade 接口文档系统
|
description: SpringBlade 接口文档系统
|
||||||
version: 2.7.3
|
version: 2.8.0
|
||||||
license: Powered By SpringBlade
|
license: Powered By SpringBlade
|
||||||
licenseUrl: https://bladex.vip
|
licenseUrl: https://bladex.vip
|
||||||
terms-of-service-url: https://bladex.vip
|
terms-of-service-url: https://bladex.vip
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>blade-tool</artifactId>
|
<artifactId>blade-tool</artifactId>
|
||||||
<groupId>org.springblade</groupId>
|
<groupId>org.springblade</groupId>
|
||||||
<version>2.7.3</version>
|
<version>2.8.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
@ -86,7 +86,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.alibaba</groupId>
|
<groupId>com.alibaba</groupId>
|
||||||
<artifactId>fastjson</artifactId>
|
<artifactId>fastjson</artifactId>
|
||||||
<version>1.2.73</version>
|
<version>1.2.74</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>blade-tool</artifactId>
|
<artifactId>blade-tool</artifactId>
|
||||||
<groupId>org.springblade</groupId>
|
<groupId>org.springblade</groupId>
|
||||||
<version>2.7.3</version>
|
<version>2.8.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>blade-tool</artifactId>
|
<artifactId>blade-tool</artifactId>
|
||||||
<groupId>org.springblade</groupId>
|
<groupId>org.springblade</groupId>
|
||||||
<version>2.7.3</version>
|
<version>2.8.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
@ -25,7 +25,7 @@ public interface AppConstant {
|
|||||||
/**
|
/**
|
||||||
* 应用版本
|
* 应用版本
|
||||||
*/
|
*/
|
||||||
String APPLICATION_VERSION = "2.7.3";
|
String APPLICATION_VERSION = "2.8.0";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 基础包
|
* 基础包
|
||||||
@ -76,6 +76,10 @@ public interface AppConstant {
|
|||||||
* 链路追踪模块名称
|
* 链路追踪模块名称
|
||||||
*/
|
*/
|
||||||
String APPLICATION_ZIPKIN_NAME = APPLICATION_NAME_PREFIX + "zipkin";
|
String APPLICATION_ZIPKIN_NAME = APPLICATION_NAME_PREFIX + "zipkin";
|
||||||
|
/**
|
||||||
|
* 报表系统名称
|
||||||
|
*/
|
||||||
|
String APPLICATION_REPORT_NAME = APPLICATION_NAME_PREFIX + "report";
|
||||||
/**
|
/**
|
||||||
* 测试模块名称
|
* 测试模块名称
|
||||||
*/
|
*/
|
||||||
|
@ -22,7 +22,7 @@ package org.springblade.core.launch.constant;
|
|||||||
*/
|
*/
|
||||||
public interface TokenConstant {
|
public interface TokenConstant {
|
||||||
|
|
||||||
String SIGN_KEY = "Blade";
|
String SIGN_KEY = "bladexisapowerfulmicroservicearchitectureupgradedandoptimizedfromacommercialproject";
|
||||||
String AVATAR = "avatar";
|
String AVATAR = "avatar";
|
||||||
String HEADER = "blade-auth";
|
String HEADER = "blade-auth";
|
||||||
String BEARER = "bearer";
|
String BEARER = "bearer";
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>blade-tool</artifactId>
|
<artifactId>blade-tool</artifactId>
|
||||||
<groupId>org.springblade</groupId>
|
<groupId>org.springblade</groupId>
|
||||||
<version>2.7.3</version>
|
<version>2.8.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>blade-tool</artifactId>
|
<artifactId>blade-tool</artifactId>
|
||||||
<groupId>org.springblade</groupId>
|
<groupId>org.springblade</groupId>
|
||||||
<version>2.7.3</version>
|
<version>2.8.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>blade-tool</artifactId>
|
<artifactId>blade-tool</artifactId>
|
||||||
<groupId>org.springblade</groupId>
|
<groupId>org.springblade</groupId>
|
||||||
<version>2.7.3</version>
|
<version>2.8.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
30
blade-core-report/pom.xml
Normal file
30
blade-core-report/pom.xml
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<parent>
|
||||||
|
<artifactId>blade-tool</artifactId>
|
||||||
|
<groupId>org.springblade</groupId>
|
||||||
|
<version>2.8.0</version>
|
||||||
|
</parent>
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<artifactId>blade-core-report</artifactId>
|
||||||
|
<name>${project.artifactId}</name>
|
||||||
|
<version>${blade.tool.version}</version>
|
||||||
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springblade</groupId>
|
||||||
|
<artifactId>blade-core-mybatis</artifactId>
|
||||||
|
<version>${blade.tool.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.bstek.ureport</groupId>
|
||||||
|
<artifactId>ureport2-console</artifactId>
|
||||||
|
<version>2.2.9</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
</project>
|
@ -0,0 +1,65 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
|
||||||
|
* <p>
|
||||||
|
* Licensed under the GNU LESSER GENERAL PUBLIC LICENSE 3.0;
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
* <p>
|
||||||
|
* http://www.gnu.org/licenses/lgpl.html
|
||||||
|
* <p>
|
||||||
|
* 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.springblade.core.report.config;
|
||||||
|
|
||||||
|
import com.bstek.ureport.UReportPropertyPlaceholderConfigurer;
|
||||||
|
import com.bstek.ureport.console.UReportServlet;
|
||||||
|
import com.bstek.ureport.provider.report.ReportProvider;
|
||||||
|
import org.springblade.core.report.props.ReportDatabaseProperties;
|
||||||
|
import org.springblade.core.report.props.ReportProperties;
|
||||||
|
import org.springblade.core.report.provider.DatabaseProvider;
|
||||||
|
import org.springblade.core.report.provider.ReportPlaceholderProvider;
|
||||||
|
import org.springblade.core.report.service.IReportFileService;
|
||||||
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||||
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||||
|
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||||
|
import org.springframework.boot.web.servlet.ServletRegistrationBean;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.context.annotation.ImportResource;
|
||||||
|
import org.springframework.core.annotation.Order;
|
||||||
|
|
||||||
|
import javax.servlet.Servlet;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* UReport配置类
|
||||||
|
*
|
||||||
|
* @author Chill
|
||||||
|
*/
|
||||||
|
@Order
|
||||||
|
@Configuration
|
||||||
|
@ConditionalOnProperty(value = "report.enabled", havingValue = "true", matchIfMissing = true)
|
||||||
|
@EnableConfigurationProperties({ReportProperties.class, ReportDatabaseProperties.class})
|
||||||
|
@ImportResource("classpath:ureport-console-context.xml")
|
||||||
|
public class ReportConfiguration {
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public ServletRegistrationBean<Servlet> registrationBean() {
|
||||||
|
return new ServletRegistrationBean<>(new UReportServlet(), "/ureport/*");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public UReportPropertyPlaceholderConfigurer uReportPropertyPlaceholderConfigurer(ReportProperties properties) {
|
||||||
|
return new ReportPlaceholderProvider(properties);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
@ConditionalOnMissingBean
|
||||||
|
public ReportProvider reportProvider(ReportDatabaseProperties properties, IReportFileService service) {
|
||||||
|
return new DatabaseProvider(properties, service);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,54 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
|
||||||
|
* <p>
|
||||||
|
* Licensed under the GNU LESSER GENERAL PUBLIC LICENSE 3.0;
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
* <p>
|
||||||
|
* http://www.gnu.org/licenses/lgpl.html
|
||||||
|
* <p>
|
||||||
|
* 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.springblade.core.report.datasource;
|
||||||
|
|
||||||
|
import com.bstek.ureport.definition.datasource.BuildinDatasource;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
|
import javax.sql.DataSource;
|
||||||
|
import java.sql.Connection;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* UReport数据源配置
|
||||||
|
*
|
||||||
|
* @author Chill
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class ReportDataSource implements BuildinDatasource {
|
||||||
|
private static final String NAME = "ReportDataSource";
|
||||||
|
|
||||||
|
private final DataSource dataSource;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String name() {
|
||||||
|
return NAME;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Connection getConnection() {
|
||||||
|
try {
|
||||||
|
return dataSource.getConnection();
|
||||||
|
} catch (SQLException e) {
|
||||||
|
log.error("report数据源链接失败");
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,38 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
|
||||||
|
* <p>
|
||||||
|
* Licensed under the GNU LESSER GENERAL PUBLIC LICENSE 3.0;
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
* <p>
|
||||||
|
* http://www.gnu.org/licenses/lgpl.html
|
||||||
|
* <p>
|
||||||
|
* 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.springblade.core.report.endpoint;
|
||||||
|
|
||||||
|
import org.springblade.core.launch.constant.AppConstant;
|
||||||
|
import org.springblade.core.report.service.IReportFileService;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
import springfox.documentation.annotations.ApiIgnore;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* UReport Boot版 API端点
|
||||||
|
*
|
||||||
|
* @author Chill
|
||||||
|
*/
|
||||||
|
@ApiIgnore
|
||||||
|
@RestController
|
||||||
|
@RequestMapping(AppConstant.APPLICATION_REPORT_NAME + "/report/rest")
|
||||||
|
public class ReportBootEndpoint extends ReportEndpoint {
|
||||||
|
|
||||||
|
public ReportBootEndpoint(IReportFileService service) {
|
||||||
|
super(service);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,71 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
|
||||||
|
* <p>
|
||||||
|
* Licensed under the GNU LESSER GENERAL PUBLIC LICENSE 3.0;
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
* <p>
|
||||||
|
* http://www.gnu.org/licenses/lgpl.html
|
||||||
|
* <p>
|
||||||
|
* 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.springblade.core.report.endpoint;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import org.springblade.core.mp.support.Condition;
|
||||||
|
import org.springblade.core.mp.support.Query;
|
||||||
|
import org.springblade.core.report.entity.ReportFileEntity;
|
||||||
|
import org.springblade.core.report.service.IReportFileService;
|
||||||
|
import org.springblade.core.tool.api.R;
|
||||||
|
import org.springblade.core.tool.utils.Func;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import springfox.documentation.annotations.ApiIgnore;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* UReport API端点
|
||||||
|
*
|
||||||
|
* @author Chill
|
||||||
|
*/
|
||||||
|
@ApiIgnore
|
||||||
|
@RestController
|
||||||
|
@AllArgsConstructor
|
||||||
|
@RequestMapping("/report/rest")
|
||||||
|
public class ReportEndpoint {
|
||||||
|
|
||||||
|
private final IReportFileService service;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 详情
|
||||||
|
*/
|
||||||
|
@GetMapping("/detail")
|
||||||
|
public R<ReportFileEntity> detail(ReportFileEntity file) {
|
||||||
|
ReportFileEntity detail = service.getOne(Condition.getQueryWrapper(file));
|
||||||
|
return R.data(detail);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页
|
||||||
|
*/
|
||||||
|
@GetMapping("/list")
|
||||||
|
public R<IPage<ReportFileEntity>> list(@RequestParam Map<String, Object> file, Query query) {
|
||||||
|
IPage<ReportFileEntity> pages = service.page(Condition.getPage(query), Condition.getQueryWrapper(file, ReportFileEntity.class));
|
||||||
|
return R.data(pages);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除
|
||||||
|
*/
|
||||||
|
@PostMapping("/remove")
|
||||||
|
public R remove(@RequestParam String ids) {
|
||||||
|
boolean temp = service.removeByIds(Func.toLongList(ids));
|
||||||
|
return R.status(temp);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,65 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
|
||||||
|
* <p>
|
||||||
|
* Licensed under the GNU LESSER GENERAL PUBLIC LICENSE 3.0;
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
* <p>
|
||||||
|
* http://www.gnu.org/licenses/lgpl.html
|
||||||
|
* <p>
|
||||||
|
* 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.springblade.core.report.entity;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* UReport实体类
|
||||||
|
*
|
||||||
|
* @author Chill
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@TableName("blade_report_file")
|
||||||
|
public class ReportFileEntity implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 主键
|
||||||
|
*/
|
||||||
|
@TableId(value = "id", type = IdType.ASSIGN_ID)
|
||||||
|
private Long id;
|
||||||
|
/**
|
||||||
|
* 文件名
|
||||||
|
*/
|
||||||
|
private String name;
|
||||||
|
/**
|
||||||
|
* 文件内容
|
||||||
|
*/
|
||||||
|
private byte[] content;
|
||||||
|
/**
|
||||||
|
* 创建时间
|
||||||
|
*/
|
||||||
|
private Date createTime;
|
||||||
|
/**
|
||||||
|
* 更新时间
|
||||||
|
*/
|
||||||
|
private Date updateTime;
|
||||||
|
/**
|
||||||
|
* 是否已删除
|
||||||
|
*/
|
||||||
|
@TableLogic
|
||||||
|
private Integer isDeleted;
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,27 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
|
||||||
|
* <p>
|
||||||
|
* Licensed under the GNU LESSER GENERAL PUBLIC LICENSE 3.0;
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
* <p>
|
||||||
|
* http://www.gnu.org/licenses/lgpl.html
|
||||||
|
* <p>
|
||||||
|
* 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.springblade.core.report.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import org.springblade.core.report.entity.ReportFileEntity;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* UReport Mapper
|
||||||
|
*
|
||||||
|
* @author Chill
|
||||||
|
*/
|
||||||
|
public interface ReportFileMapper extends BaseMapper<ReportFileEntity> {
|
||||||
|
}
|
@ -0,0 +1,32 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
|
||||||
|
* <p>
|
||||||
|
* Licensed under the GNU LESSER GENERAL PUBLIC LICENSE 3.0;
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
* <p>
|
||||||
|
* http://www.gnu.org/licenses/lgpl.html
|
||||||
|
* <p>
|
||||||
|
* 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.springblade.core.report.props;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* UReport配置类
|
||||||
|
*
|
||||||
|
* @author Chill
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@ConfigurationProperties(prefix = "report.database.provider")
|
||||||
|
public class ReportDatabaseProperties {
|
||||||
|
private String name = "数据库文件系统";
|
||||||
|
private String prefix = "blade-";
|
||||||
|
private boolean disabled = false;
|
||||||
|
}
|
@ -0,0 +1,35 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
|
||||||
|
* <p>
|
||||||
|
* Licensed under the GNU LESSER GENERAL PUBLIC LICENSE 3.0;
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
* <p>
|
||||||
|
* http://www.gnu.org/licenses/lgpl.html
|
||||||
|
* <p>
|
||||||
|
* 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.springblade.core.report.props;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import org.springblade.core.tool.utils.StringPool;
|
||||||
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* UReport配置类
|
||||||
|
*
|
||||||
|
* @author Chill
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@ConfigurationProperties(prefix = "report")
|
||||||
|
public class ReportProperties {
|
||||||
|
private Boolean enabled = true;
|
||||||
|
private Boolean disableHttpSessionReportCache = false;
|
||||||
|
private Boolean disableFileProvider = true;
|
||||||
|
private String fileStoreDir = StringPool.EMPTY;
|
||||||
|
private Boolean debug = false;
|
||||||
|
}
|
@ -0,0 +1,110 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
|
||||||
|
* <p>
|
||||||
|
* Licensed under the GNU LESSER GENERAL PUBLIC LICENSE 3.0;
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
* <p>
|
||||||
|
* http://www.gnu.org/licenses/lgpl.html
|
||||||
|
* <p>
|
||||||
|
* 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.springblade.core.report.provider;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
|
import com.bstek.ureport.provider.report.ReportFile;
|
||||||
|
import com.bstek.ureport.provider.report.ReportProvider;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import org.springblade.core.report.entity.ReportFileEntity;
|
||||||
|
import org.springblade.core.report.props.ReportDatabaseProperties;
|
||||||
|
import org.springblade.core.report.service.IReportFileService;
|
||||||
|
import org.springblade.core.tool.constant.BladeConstant;
|
||||||
|
import org.springblade.core.tool.utils.DateUtil;
|
||||||
|
|
||||||
|
import java.io.ByteArrayInputStream;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数据库文件处理
|
||||||
|
*
|
||||||
|
* @author Chill
|
||||||
|
*/
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class DatabaseProvider implements ReportProvider {
|
||||||
|
|
||||||
|
private final ReportDatabaseProperties properties;
|
||||||
|
private final IReportFileService service;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public InputStream loadReport(String file) {
|
||||||
|
ReportFileEntity reportFileEntity = service.getOne(Wrappers.<ReportFileEntity>lambdaQuery().eq(ReportFileEntity::getName, getFileName(file)));
|
||||||
|
byte[] content = reportFileEntity.getContent();
|
||||||
|
return new ByteArrayInputStream(content);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void deleteReport(String file) {
|
||||||
|
service.remove(Wrappers.<ReportFileEntity>lambdaUpdate().eq(ReportFileEntity::getName, getFileName(file)));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<ReportFile> getReportFiles() {
|
||||||
|
List<ReportFileEntity> list = service.list();
|
||||||
|
List<ReportFile> reportFiles = new ArrayList<>();
|
||||||
|
list.forEach(reportFileEntity -> reportFiles.add(new ReportFile(reportFileEntity.getName(), reportFileEntity.getUpdateTime())));
|
||||||
|
return reportFiles;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void saveReport(String file, String content) {
|
||||||
|
String fileName = getFileName(file);
|
||||||
|
ReportFileEntity reportFileEntity = service.getOne(Wrappers.<ReportFileEntity>lambdaQuery().eq(ReportFileEntity::getName, fileName));
|
||||||
|
Date now = DateUtil.now();
|
||||||
|
if (reportFileEntity == null) {
|
||||||
|
reportFileEntity = new ReportFileEntity();
|
||||||
|
reportFileEntity.setName(fileName);
|
||||||
|
reportFileEntity.setContent(content.getBytes());
|
||||||
|
reportFileEntity.setCreateTime(now);
|
||||||
|
reportFileEntity.setIsDeleted(BladeConstant.DB_NOT_DELETED);
|
||||||
|
} else {
|
||||||
|
reportFileEntity.setContent(content.getBytes());
|
||||||
|
}
|
||||||
|
reportFileEntity.setUpdateTime(now);
|
||||||
|
service.saveOrUpdate(reportFileEntity);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
return properties.getName();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean disabled() {
|
||||||
|
return properties.isDisabled();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPrefix() {
|
||||||
|
return properties.getPrefix();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取标准格式文件名
|
||||||
|
*
|
||||||
|
* @param name 原文件名
|
||||||
|
*/
|
||||||
|
private String getFileName(String name) {
|
||||||
|
if (name.startsWith(getPrefix())) {
|
||||||
|
name = name.substring(getPrefix().length());
|
||||||
|
}
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,39 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
|
||||||
|
* <p>
|
||||||
|
* Licensed under the GNU LESSER GENERAL PUBLIC LICENSE 3.0;
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
* <p>
|
||||||
|
* http://www.gnu.org/licenses/lgpl.html
|
||||||
|
* <p>
|
||||||
|
* 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.springblade.core.report.provider;
|
||||||
|
|
||||||
|
import com.bstek.ureport.UReportPropertyPlaceholderConfigurer;
|
||||||
|
import org.springblade.core.report.props.ReportProperties;
|
||||||
|
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* UReport自定义配置
|
||||||
|
*
|
||||||
|
* @author Chill
|
||||||
|
*/
|
||||||
|
public class ReportPlaceholderProvider extends UReportPropertyPlaceholderConfigurer {
|
||||||
|
|
||||||
|
public ReportPlaceholderProvider(ReportProperties properties) {
|
||||||
|
Properties props = new Properties();
|
||||||
|
props.setProperty("ureport.disableHttpSessionReportCache", properties.getDisableHttpSessionReportCache().toString());
|
||||||
|
props.setProperty("ureport.disableFileProvider", properties.getDisableFileProvider().toString());
|
||||||
|
props.setProperty("ureport.fileStoreDir", properties.getFileStoreDir());
|
||||||
|
props.setProperty("ureport.debug", properties.getDebug().toString());
|
||||||
|
this.setProperties(props);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,27 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
|
||||||
|
* <p>
|
||||||
|
* Licensed under the GNU LESSER GENERAL PUBLIC LICENSE 3.0;
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
* <p>
|
||||||
|
* http://www.gnu.org/licenses/lgpl.html
|
||||||
|
* <p>
|
||||||
|
* 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.springblade.core.report.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import org.springblade.core.report.entity.ReportFileEntity;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* UReport Service
|
||||||
|
*
|
||||||
|
* @author Chill
|
||||||
|
*/
|
||||||
|
public interface IReportFileService extends IService<ReportFileEntity> {
|
||||||
|
}
|
@ -0,0 +1,31 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
|
||||||
|
* <p>
|
||||||
|
* Licensed under the GNU LESSER GENERAL PUBLIC LICENSE 3.0;
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
* <p>
|
||||||
|
* http://www.gnu.org/licenses/lgpl.html
|
||||||
|
* <p>
|
||||||
|
* 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.springblade.core.report.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import org.springblade.core.report.entity.ReportFileEntity;
|
||||||
|
import org.springblade.core.report.mapper.ReportFileMapper;
|
||||||
|
import org.springblade.core.report.service.IReportFileService;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* UReport Service
|
||||||
|
*
|
||||||
|
* @author Chill
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class ReportFileServiceImpl extends ServiceImpl<ReportFileMapper, ReportFileEntity> implements IReportFileService {
|
||||||
|
}
|
@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>blade-tool</artifactId>
|
<artifactId>blade-tool</artifactId>
|
||||||
<groupId>org.springblade</groupId>
|
<groupId>org.springblade</groupId>
|
||||||
<version>2.7.3</version>
|
<version>2.8.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
@ -19,8 +19,13 @@
|
|||||||
<!-- JWT -->
|
<!-- JWT -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.jsonwebtoken</groupId>
|
<groupId>io.jsonwebtoken</groupId>
|
||||||
<artifactId>jjwt</artifactId>
|
<artifactId>jjwt-impl</artifactId>
|
||||||
<version>0.9.1</version>
|
<version>0.11.2</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.jsonwebtoken</groupId>
|
||||||
|
<artifactId>jjwt-jackson</artifactId>
|
||||||
|
<version>0.11.2</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!--Blade-->
|
<!--Blade-->
|
||||||
<dependency>
|
<dependency>
|
||||||
|
@ -1,37 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2014 jsonwebtoken.io
|
|
||||||
*
|
|
||||||
* 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 io.jsonwebtoken.impl;
|
|
||||||
|
|
||||||
import java.util.Base64;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Base64Codec
|
|
||||||
*
|
|
||||||
* @author jjwt
|
|
||||||
*/
|
|
||||||
public class Base64Codec extends AbstractTextCodec {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String encode(byte[] data) {
|
|
||||||
return Base64.getEncoder().encodeToString(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public byte[] decode(String encoded) {
|
|
||||||
return Base64.getDecoder().decode(encoded);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -38,7 +38,6 @@ public class SecureRegistry {
|
|||||||
public SecureRegistry() {
|
public SecureRegistry() {
|
||||||
this.defaultExcludePatterns.add("/actuator/health/**");
|
this.defaultExcludePatterns.add("/actuator/health/**");
|
||||||
this.defaultExcludePatterns.add("/v2/api-docs/**");
|
this.defaultExcludePatterns.add("/v2/api-docs/**");
|
||||||
this.defaultExcludePatterns.add("/v2/api-docs-ext/**");
|
|
||||||
this.defaultExcludePatterns.add("/auth/**");
|
this.defaultExcludePatterns.add("/auth/**");
|
||||||
this.defaultExcludePatterns.add("/token/**");
|
this.defaultExcludePatterns.add("/token/**");
|
||||||
this.defaultExcludePatterns.add("/log/**");
|
this.defaultExcludePatterns.add("/log/**");
|
||||||
|
@ -53,9 +53,9 @@ public class SecureUtil {
|
|||||||
private final static String TENANT_ID = TokenConstant.TENANT_ID;
|
private final static String TENANT_ID = TokenConstant.TENANT_ID;
|
||||||
private final static String CLIENT_ID = TokenConstant.CLIENT_ID;
|
private final static String CLIENT_ID = TokenConstant.CLIENT_ID;
|
||||||
private final static Integer AUTH_LENGTH = TokenConstant.AUTH_LENGTH;
|
private final static Integer AUTH_LENGTH = TokenConstant.AUTH_LENGTH;
|
||||||
private static String BASE64_SECURITY = Base64.getEncoder().encodeToString(TokenConstant.SIGN_KEY.getBytes(Charsets.UTF_8));
|
private static final String BASE64_SECURITY = Base64.getEncoder().encodeToString(TokenConstant.SIGN_KEY.getBytes(Charsets.UTF_8));
|
||||||
|
|
||||||
private static IClientDetailsService clientDetailsService;
|
private static final IClientDetailsService clientDetailsService;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
clientDetailsService = SpringUtil.getBean(IClientDetailsService.class);
|
clientDetailsService = SpringUtil.getBean(IClientDetailsService.class);
|
||||||
@ -297,8 +297,8 @@ public class SecureUtil {
|
|||||||
*/
|
*/
|
||||||
public static Claims parseJWT(String jsonWebToken) {
|
public static Claims parseJWT(String jsonWebToken) {
|
||||||
try {
|
try {
|
||||||
return Jwts.parser()
|
return Jwts.parserBuilder()
|
||||||
.setSigningKey(Base64.getDecoder().decode(BASE64_SECURITY))
|
.setSigningKey(Base64.getDecoder().decode(BASE64_SECURITY)).build()
|
||||||
.parseClaimsJws(jsonWebToken).getBody();
|
.parseClaimsJws(jsonWebToken).getBody();
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
return null;
|
return null;
|
||||||
@ -339,10 +339,10 @@ public class SecureUtil {
|
|||||||
Key signingKey = new SecretKeySpec(apiKeySecretBytes, signatureAlgorithm.getJcaName());
|
Key signingKey = new SecretKeySpec(apiKeySecretBytes, signatureAlgorithm.getJcaName());
|
||||||
|
|
||||||
//添加构成JWT的类
|
//添加构成JWT的类
|
||||||
JwtBuilder builder = Jwts.builder().setHeaderParam("typ", "JsonWebToken")
|
JwtBuilder builder = Jwts.builder().setHeaderParam("typ", "JWT")
|
||||||
.setIssuer(issuer)
|
.setIssuer(issuer)
|
||||||
.setAudience(audience)
|
.setAudience(audience)
|
||||||
.signWith(signatureAlgorithm, signingKey);
|
.signWith(signingKey);
|
||||||
|
|
||||||
//设置JWT参数
|
//设置JWT参数
|
||||||
user.forEach(builder::claim);
|
user.forEach(builder::claim);
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>blade-tool</artifactId>
|
<artifactId>blade-tool</artifactId>
|
||||||
<groupId>org.springblade</groupId>
|
<groupId>org.springblade</groupId>
|
||||||
<version>2.7.3</version>
|
<version>2.8.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
@ -25,7 +25,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>me.zhyd.oauth</groupId>
|
<groupId>me.zhyd.oauth</groupId>
|
||||||
<artifactId>JustAuth</artifactId>
|
<artifactId>JustAuth</artifactId>
|
||||||
<version>1.15.6</version>
|
<version>1.15.8</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.httpcomponents</groupId>
|
<groupId>org.apache.httpcomponents</groupId>
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>blade-tool</artifactId>
|
<artifactId>blade-tool</artifactId>
|
||||||
<groupId>org.springblade</groupId>
|
<groupId>org.springblade</groupId>
|
||||||
<version>2.7.3</version>
|
<version>2.8.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
@ -0,0 +1,32 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
|
||||||
|
* <p>
|
||||||
|
* Licensed under the GNU LESSER GENERAL PUBLIC LICENSE 3.0;
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
* <p>
|
||||||
|
* http://www.gnu.org/licenses/lgpl.html
|
||||||
|
* <p>
|
||||||
|
* 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.springblade.core.swagger;
|
||||||
|
|
||||||
|
import springfox.documentation.swagger2.annotations.EnableSwagger2WebMvc;
|
||||||
|
|
||||||
|
import java.lang.annotation.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Swagger配置开关
|
||||||
|
*
|
||||||
|
* @author Chill
|
||||||
|
*/
|
||||||
|
@Documented
|
||||||
|
@Target(ElementType.TYPE)
|
||||||
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
@EnableSwagger2WebMvc
|
||||||
|
public @interface EnableSwagger {
|
||||||
|
}
|
@ -16,25 +16,23 @@
|
|||||||
package org.springblade.core.swagger;
|
package org.springblade.core.swagger;
|
||||||
|
|
||||||
|
|
||||||
import com.github.xiaoymin.knife4j.spring.annotations.EnableKnife4j;
|
import com.google.common.collect.Lists;
|
||||||
import com.google.common.base.Predicate;
|
|
||||||
import com.google.common.base.Predicates;
|
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.context.annotation.Import;
|
import org.springframework.context.annotation.Import;
|
||||||
import org.springframework.context.annotation.Profile;
|
|
||||||
import springfox.bean.validators.configuration.BeanValidatorPluginsConfiguration;
|
import springfox.bean.validators.configuration.BeanValidatorPluginsConfiguration;
|
||||||
import springfox.documentation.builders.ApiInfoBuilder;
|
import springfox.documentation.builders.ApiInfoBuilder;
|
||||||
import springfox.documentation.builders.PathSelectors;
|
import springfox.documentation.builders.PathSelectors;
|
||||||
import springfox.documentation.service.*;
|
import springfox.documentation.service.*;
|
||||||
import springfox.documentation.spi.DocumentationType;
|
import springfox.documentation.spi.DocumentationType;
|
||||||
import springfox.documentation.spi.service.contexts.SecurityContext;
|
import springfox.documentation.spi.service.contexts.SecurityContext;
|
||||||
|
import springfox.documentation.spring.web.plugins.ApiSelectorBuilder;
|
||||||
import springfox.documentation.spring.web.plugins.Docket;
|
import springfox.documentation.spring.web.plugins.Docket;
|
||||||
import springfox.documentation.swagger2.annotations.EnableSwagger2;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -44,15 +42,14 @@ import java.util.List;
|
|||||||
* @author Chill
|
* @author Chill
|
||||||
*/
|
*/
|
||||||
@Configuration
|
@Configuration
|
||||||
@EnableKnife4j
|
@EnableSwagger
|
||||||
@EnableSwagger2
|
|
||||||
@Profile({"dev", "test"})
|
|
||||||
@EnableConfigurationProperties(SwaggerProperties.class)
|
@EnableConfigurationProperties(SwaggerProperties.class)
|
||||||
@Import(BeanValidatorPluginsConfiguration.class)
|
@Import(BeanValidatorPluginsConfiguration.class)
|
||||||
public class SwaggerAutoConfiguration {
|
public class SwaggerAutoConfiguration {
|
||||||
|
|
||||||
private static final String DEFAULT_EXCLUDE_PATH = "/error";
|
private static final String DEFAULT_MAPPING_PATH = "/";
|
||||||
private static final String BASE_PATH = "/**";
|
private static final String DEFAULT_BASE_PATH = "/**";
|
||||||
|
private static final List<String> DEFAULT_EXCLUDE_PATH = Arrays.asList("/error", "/actuator/**");
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
@ConditionalOnMissingBean
|
@ConditionalOnMissingBean
|
||||||
@ -64,29 +61,27 @@ public class SwaggerAutoConfiguration {
|
|||||||
public Docket api(SwaggerProperties swaggerProperties) {
|
public Docket api(SwaggerProperties swaggerProperties) {
|
||||||
// base-path处理
|
// base-path处理
|
||||||
if (swaggerProperties.getBasePath().size() == 0) {
|
if (swaggerProperties.getBasePath().size() == 0) {
|
||||||
swaggerProperties.getBasePath().add(BASE_PATH);
|
swaggerProperties.getBasePath().add(DEFAULT_BASE_PATH);
|
||||||
}
|
}
|
||||||
//noinspection unchecked
|
|
||||||
List<Predicate<String>> basePath = new ArrayList();
|
|
||||||
swaggerProperties.getBasePath().forEach(path -> basePath.add(PathSelectors.ant(path)));
|
|
||||||
|
|
||||||
// exclude-path处理
|
// exclude-path处理
|
||||||
if (swaggerProperties.getExcludePath().size() == 0) {
|
if (swaggerProperties.getExcludePath().size() == 0) {
|
||||||
swaggerProperties.getExcludePath().add(DEFAULT_EXCLUDE_PATH);
|
swaggerProperties.getExcludePath().addAll(DEFAULT_EXCLUDE_PATH);
|
||||||
}
|
}
|
||||||
List<Predicate<String>> excludePath = new ArrayList<>();
|
ApiSelectorBuilder apis = new Docket(DocumentationType.SWAGGER_2)
|
||||||
swaggerProperties.getExcludePath().forEach(path -> excludePath.add(PathSelectors.ant(path)));
|
|
||||||
|
|
||||||
//noinspection Guava
|
|
||||||
return new Docket(DocumentationType.SWAGGER_2)
|
|
||||||
.host(swaggerProperties.getHost())
|
.host(swaggerProperties.getHost())
|
||||||
.apiInfo(apiInfo(swaggerProperties)).select()
|
.apiInfo(apiInfo(swaggerProperties)).select()
|
||||||
.apis(SwaggerUtil.basePackages(swaggerProperties.getBasePackages()))
|
.apis(SwaggerUtil.basePackages(swaggerProperties.getBasePackages()));
|
||||||
.paths(Predicates.and(Predicates.not(Predicates.or(excludePath)), Predicates.or(basePath)))
|
|
||||||
.build()
|
swaggerProperties.getBasePath().forEach(p -> apis.paths(PathSelectors.ant(p)));
|
||||||
|
swaggerProperties.getExcludePath().forEach(p -> apis.paths(PathSelectors.ant(p).negate()));
|
||||||
|
|
||||||
|
return apis.build()
|
||||||
.securitySchemes(Collections.singletonList(securitySchema()))
|
.securitySchemes(Collections.singletonList(securitySchema()))
|
||||||
.securityContexts(Collections.singletonList(securityContext()))
|
.securityContexts(Collections.singletonList(securityContext()))
|
||||||
.pathMapping("/");
|
.securityContexts(Lists.newArrayList(securityContext()))
|
||||||
|
.securitySchemes(Collections.singletonList(securitySchema()))
|
||||||
|
.pathMapping(DEFAULT_MAPPING_PATH);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -0,0 +1,43 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
|
||||||
|
* <p>
|
||||||
|
* Licensed under the GNU LESSER GENERAL PUBLIC LICENSE 3.0;
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
* <p>
|
||||||
|
* http://www.gnu.org/licenses/lgpl.html
|
||||||
|
* <p>
|
||||||
|
* 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.springblade.core.swagger;
|
||||||
|
|
||||||
|
import org.springblade.core.launch.constant.AppConstant;
|
||||||
|
import org.springblade.core.launch.service.LauncherService;
|
||||||
|
import org.springframework.boot.builder.SpringApplicationBuilder;
|
||||||
|
import org.springframework.core.Ordered;
|
||||||
|
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 初始化Swagger配置
|
||||||
|
*
|
||||||
|
* @author Chill
|
||||||
|
*/
|
||||||
|
public class SwaggerLauncherServiceImpl implements LauncherService {
|
||||||
|
@Override
|
||||||
|
public void launcher(SpringApplicationBuilder builder, String appName, String profile) {
|
||||||
|
Properties props = System.getProperties();
|
||||||
|
if (profile.equals(AppConstant.PROD_CODE)) {
|
||||||
|
props.setProperty("knife4j.production", "true");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getOrder() {
|
||||||
|
return Ordered.LOWEST_PRECEDENCE;
|
||||||
|
}
|
||||||
|
}
|
@ -55,7 +55,7 @@ public class SwaggerProperties {
|
|||||||
/**
|
/**
|
||||||
* 版本
|
* 版本
|
||||||
**/
|
**/
|
||||||
private String version = "2.7.3";
|
private String version = "2.8.0";
|
||||||
/**
|
/**
|
||||||
* 许可证
|
* 许可证
|
||||||
**/
|
**/
|
||||||
|
@ -17,10 +17,10 @@ package org.springblade.core.swagger;
|
|||||||
|
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
import com.google.common.base.Optional;
|
import com.google.common.base.Optional;
|
||||||
import com.google.common.base.Predicate;
|
|
||||||
import springfox.documentation.RequestHandler;
|
import springfox.documentation.RequestHandler;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.function.Predicate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Swagger工具类
|
* Swagger工具类
|
||||||
|
@ -0,0 +1 @@
|
|||||||
|
org.springblade.core.swagger.SwaggerLauncherServiceImpl
|
@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>org.springblade</groupId>
|
<groupId>org.springblade</groupId>
|
||||||
<artifactId>blade-tool</artifactId>
|
<artifactId>blade-tool</artifactId>
|
||||||
<version>2.7.3</version>
|
<version>2.8.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>org.springblade</groupId>
|
<groupId>org.springblade</groupId>
|
||||||
<artifactId>blade-tool</artifactId>
|
<artifactId>blade-tool</artifactId>
|
||||||
<version>2.7.3</version>
|
<version>2.8.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
@ -31,7 +31,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.google.guava</groupId>
|
<groupId>com.google.guava</groupId>
|
||||||
<artifactId>guava</artifactId>
|
<artifactId>guava</artifactId>
|
||||||
<version>26.0-jre</version>
|
<version>30.0-jre</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- okhttp -->
|
<!-- okhttp -->
|
||||||
<dependency>
|
<dependency>
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>blade-tool</artifactId>
|
<artifactId>blade-tool</artifactId>
|
||||||
<groupId>org.springblade</groupId>
|
<groupId>org.springblade</groupId>
|
||||||
<version>2.7.3</version>
|
<version>2.8.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
26
pom.xml
26
pom.xml
@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
<groupId>org.springblade</groupId>
|
<groupId>org.springblade</groupId>
|
||||||
<artifactId>blade-tool</artifactId>
|
<artifactId>blade-tool</artifactId>
|
||||||
<version>2.7.3</version>
|
<version>2.8.0</version>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
<name>blade-tool</name>
|
<name>blade-tool</name>
|
||||||
<description>
|
<description>
|
||||||
@ -36,22 +36,23 @@
|
|||||||
</scm>
|
</scm>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<blade.tool.version>2.7.3</blade.tool.version>
|
<blade.tool.version>2.8.0</blade.tool.version>
|
||||||
|
|
||||||
<java.version>1.8</java.version>
|
<java.version>1.8</java.version>
|
||||||
<maven.plugin.version>3.8.0</maven.plugin.version>
|
<maven.plugin.version>3.8.0</maven.plugin.version>
|
||||||
<swagger.version>2.9.2</swagger.version>
|
<swagger.version>2.10.5</swagger.version>
|
||||||
<swagger.models.version>1.5.21</swagger.models.version>
|
<swagger.models.version>1.6.2</swagger.models.version>
|
||||||
<knife4j.version>2.0.4</knife4j.version>
|
<knife4j.version>2.0.6</knife4j.version>
|
||||||
<mybatis.plus.version>3.4.0</mybatis.plus.version>
|
<mybatis.plus.version>3.4.0</mybatis.plus.version>
|
||||||
<protostuff.version>1.6.0</protostuff.version>
|
<protostuff.version>1.6.0</protostuff.version>
|
||||||
<disruptor.version>3.4.2</disruptor.version>
|
<disruptor.version>3.4.2</disruptor.version>
|
||||||
<spring.boot.admin.version>2.3.0</spring.boot.admin.version>
|
<spring.boot.admin.version>2.3.0</spring.boot.admin.version>
|
||||||
<mica.auto.version>1.2.5</mica.auto.version>
|
<mica.auto.version>1.2.5</mica.auto.version>
|
||||||
<alibaba.cloud.version>2.2.1.RELEASE</alibaba.cloud.version>
|
<alibaba.cloud.version>2.2.3.RELEASE</alibaba.cloud.version>
|
||||||
<alibaba.seata.version>1.3.0</alibaba.seata.version>
|
<alibaba.seata.version>1.3.0</alibaba.seata.version>
|
||||||
|
<spring.plugin.version>2.0.0.RELEASE</spring.plugin.version>
|
||||||
|
|
||||||
<spring.boot.version>2.2.9.RELEASE</spring.boot.version>
|
<spring.boot.version>2.2.11.RELEASE</spring.boot.version>
|
||||||
<spring.cloud.version>Hoxton.SR8</spring.cloud.version>
|
<spring.cloud.version>Hoxton.SR8</spring.cloud.version>
|
||||||
<spring.platform.version>Cairo-SR8</spring.platform.version>
|
<spring.platform.version>Cairo-SR8</spring.platform.version>
|
||||||
|
|
||||||
@ -73,10 +74,21 @@
|
|||||||
<module>blade-core-tool</module>
|
<module>blade-core-tool</module>
|
||||||
<module>blade-core-oss</module>
|
<module>blade-core-oss</module>
|
||||||
<module>blade-core-transaction</module>
|
<module>blade-core-transaction</module>
|
||||||
|
<module>blade-core-report</module>
|
||||||
</modules>
|
</modules>
|
||||||
|
|
||||||
<dependencyManagement>
|
<dependencyManagement>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.plugin</groupId>
|
||||||
|
<artifactId>spring-plugin-core</artifactId>
|
||||||
|
<version>${spring.plugin.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.plugin</groupId>
|
||||||
|
<artifactId>spring-plugin-metadata</artifactId>
|
||||||
|
<version>${spring.plugin.version}</version>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-dependencies</artifactId>
|
<artifactId>spring-boot-dependencies</artifactId>
|
||||||
|
Loading…
Reference in New Issue
Block a user