🎉 2.8.0.RELEASE 新增在线报表模块

This commit is contained in:
smallchill 2020-11-06 17:12:53 +08:00
parent 5b9a64338f
commit 0134dc660c
40 changed files with 779 additions and 101 deletions

View File

@ -1,7 +1,7 @@
<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/Spring%20Cloud-Hoxton.SR7-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%20Cloud-Hoxton.SR8-blue.svg" alt="Coverage Status">
<img src="https://img.shields.io/badge/Spring%20Boot-2.2.11.RELEASE-blue.svg" alt="Downloads">
</p>
## SpringBlade微服务开发平台

View File

@ -5,7 +5,7 @@
<parent>
<groupId>org.springblade</groupId>
<artifactId>blade-tool</artifactId>
<version>2.7.3</version>
<version>2.8.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
@ -88,7 +88,7 @@
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid-spring-boot-starter</artifactId>
<version>1.1.22</version>
<version>1.2.1</version>
</dependency>
<!-- MySQL -->
<dependency>

View File

@ -97,7 +97,7 @@ mybatis-plus:
swagger:
title: SpringBlade 接口文档系统
description: SpringBlade 接口文档系统
version: 2.7.3
version: 2.8.0
license: Powered By SpringBlade
licenseUrl: https://bladex.vip
terms-of-service-url: https://bladex.vip

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>blade-tool</artifactId>
<groupId>org.springblade</groupId>
<version>2.7.3</version>
<version>2.8.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
@ -86,7 +86,7 @@
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.73</version>
<version>1.2.74</version>
</dependency>
</dependencies>

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>blade-tool</artifactId>
<groupId>org.springblade</groupId>
<version>2.7.3</version>
<version>2.8.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>blade-tool</artifactId>
<groupId>org.springblade</groupId>
<version>2.7.3</version>
<version>2.8.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -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_REPORT_NAME = APPLICATION_NAME_PREFIX + "report";
/**
* 测试模块名称
*/

View File

@ -22,7 +22,7 @@ package org.springblade.core.launch.constant;
*/
public interface TokenConstant {
String SIGN_KEY = "Blade";
String SIGN_KEY = "bladexisapowerfulmicroservicearchitectureupgradedandoptimizedfromacommercialproject";
String AVATAR = "avatar";
String HEADER = "blade-auth";
String BEARER = "bearer";

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>blade-tool</artifactId>
<groupId>org.springblade</groupId>
<version>2.7.3</version>
<version>2.8.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>blade-tool</artifactId>
<groupId>org.springblade</groupId>
<version>2.7.3</version>
<version>2.8.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>blade-tool</artifactId>
<groupId>org.springblade</groupId>
<version>2.7.3</version>
<version>2.8.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>

30
blade-core-report/pom.xml Normal file
View 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>

View File

@ -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);
}
}

View File

@ -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;
}
}

View File

@ -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);
}
}

View File

@ -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);
}
}

View File

@ -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;
}

View File

@ -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> {
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}
}

View File

@ -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);
}
}

View File

@ -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> {
}

View File

@ -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 {
}

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>blade-tool</artifactId>
<groupId>org.springblade</groupId>
<version>2.7.3</version>
<version>2.8.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
@ -19,8 +19,13 @@
<!-- JWT -->
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt</artifactId>
<version>0.9.1</version>
<artifactId>jjwt-impl</artifactId>
<version>0.11.2</version>
</dependency>
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt-jackson</artifactId>
<version>0.11.2</version>
</dependency>
<!--Blade-->
<dependency>

View File

@ -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);
}
}

View File

@ -38,7 +38,6 @@ public class SecureRegistry {
public SecureRegistry() {
this.defaultExcludePatterns.add("/actuator/health/**");
this.defaultExcludePatterns.add("/v2/api-docs/**");
this.defaultExcludePatterns.add("/v2/api-docs-ext/**");
this.defaultExcludePatterns.add("/auth/**");
this.defaultExcludePatterns.add("/token/**");
this.defaultExcludePatterns.add("/log/**");

View File

@ -53,9 +53,9 @@ public class SecureUtil {
private final static String TENANT_ID = TokenConstant.TENANT_ID;
private final static String CLIENT_ID = TokenConstant.CLIENT_ID;
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 {
clientDetailsService = SpringUtil.getBean(IClientDetailsService.class);
@ -297,8 +297,8 @@ public class SecureUtil {
*/
public static Claims parseJWT(String jsonWebToken) {
try {
return Jwts.parser()
.setSigningKey(Base64.getDecoder().decode(BASE64_SECURITY))
return Jwts.parserBuilder()
.setSigningKey(Base64.getDecoder().decode(BASE64_SECURITY)).build()
.parseClaimsJws(jsonWebToken).getBody();
} catch (Exception ex) {
return null;
@ -339,10 +339,10 @@ public class SecureUtil {
Key signingKey = new SecretKeySpec(apiKeySecretBytes, signatureAlgorithm.getJcaName());
//添加构成JWT的类
JwtBuilder builder = Jwts.builder().setHeaderParam("typ", "JsonWebToken")
JwtBuilder builder = Jwts.builder().setHeaderParam("typ", "JWT")
.setIssuer(issuer)
.setAudience(audience)
.signWith(signatureAlgorithm, signingKey);
.signWith(signingKey);
//设置JWT参数
user.forEach(builder::claim);

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>blade-tool</artifactId>
<groupId>org.springblade</groupId>
<version>2.7.3</version>
<version>2.8.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
@ -25,7 +25,7 @@
<dependency>
<groupId>me.zhyd.oauth</groupId>
<artifactId>JustAuth</artifactId>
<version>1.15.6</version>
<version>1.15.8</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>blade-tool</artifactId>
<groupId>org.springblade</groupId>
<version>2.7.3</version>
<version>2.8.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -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 {
}

View File

@ -16,25 +16,23 @@
package org.springblade.core.swagger;
import com.github.xiaoymin.knife4j.spring.annotations.EnableKnife4j;
import com.google.common.base.Predicate;
import com.google.common.base.Predicates;
import com.google.common.collect.Lists;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.context.annotation.Profile;
import springfox.bean.validators.configuration.BeanValidatorPluginsConfiguration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.service.*;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spi.service.contexts.SecurityContext;
import springfox.documentation.spring.web.plugins.ApiSelectorBuilder;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
@ -44,15 +42,14 @@ import java.util.List;
* @author Chill
*/
@Configuration
@EnableKnife4j
@EnableSwagger2
@Profile({"dev", "test"})
@EnableSwagger
@EnableConfigurationProperties(SwaggerProperties.class)
@Import(BeanValidatorPluginsConfiguration.class)
public class SwaggerAutoConfiguration {
private static final String DEFAULT_EXCLUDE_PATH = "/error";
private static final String BASE_PATH = "/**";
private static final String DEFAULT_MAPPING_PATH = "/";
private static final String DEFAULT_BASE_PATH = "/**";
private static final List<String> DEFAULT_EXCLUDE_PATH = Arrays.asList("/error", "/actuator/**");
@Bean
@ConditionalOnMissingBean
@ -64,29 +61,27 @@ public class SwaggerAutoConfiguration {
public Docket api(SwaggerProperties swaggerProperties) {
// base-path处理
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处理
if (swaggerProperties.getExcludePath().size() == 0) {
swaggerProperties.getExcludePath().add(DEFAULT_EXCLUDE_PATH);
swaggerProperties.getExcludePath().addAll(DEFAULT_EXCLUDE_PATH);
}
List<Predicate<String>> excludePath = new ArrayList<>();
swaggerProperties.getExcludePath().forEach(path -> excludePath.add(PathSelectors.ant(path)));
//noinspection Guava
return new Docket(DocumentationType.SWAGGER_2)
ApiSelectorBuilder apis = new Docket(DocumentationType.SWAGGER_2)
.host(swaggerProperties.getHost())
.apiInfo(apiInfo(swaggerProperties)).select()
.apis(SwaggerUtil.basePackages(swaggerProperties.getBasePackages()))
.paths(Predicates.and(Predicates.not(Predicates.or(excludePath)), Predicates.or(basePath)))
.build()
.apis(SwaggerUtil.basePackages(swaggerProperties.getBasePackages()));
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()))
.securityContexts(Collections.singletonList(securityContext()))
.pathMapping("/");
.securityContexts(Lists.newArrayList(securityContext()))
.securitySchemes(Collections.singletonList(securitySchema()))
.pathMapping(DEFAULT_MAPPING_PATH);
}
/**

View File

@ -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;
}
}

View File

@ -55,7 +55,7 @@ public class SwaggerProperties {
/**
* 版本
**/
private String version = "2.7.3";
private String version = "2.8.0";
/**
* 许可证
**/

View File

@ -17,10 +17,10 @@ package org.springblade.core.swagger;
import com.google.common.base.Function;
import com.google.common.base.Optional;
import com.google.common.base.Predicate;
import springfox.documentation.RequestHandler;
import java.util.List;
import java.util.function.Predicate;
/**
* Swagger工具类

View File

@ -0,0 +1 @@
org.springblade.core.swagger.SwaggerLauncherServiceImpl

View File

@ -5,7 +5,7 @@
<parent>
<groupId>org.springblade</groupId>
<artifactId>blade-tool</artifactId>
<version>2.7.3</version>
<version>2.8.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -6,7 +6,7 @@
<parent>
<groupId>org.springblade</groupId>
<artifactId>blade-tool</artifactId>
<version>2.7.3</version>
<version>2.8.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
@ -31,7 +31,7 @@
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>26.0-jre</version>
<version>30.0-jre</version>
</dependency>
<!-- okhttp -->
<dependency>

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>blade-tool</artifactId>
<groupId>org.springblade</groupId>
<version>2.7.3</version>
<version>2.8.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>

26
pom.xml
View File

@ -5,7 +5,7 @@
<groupId>org.springblade</groupId>
<artifactId>blade-tool</artifactId>
<version>2.7.3</version>
<version>2.8.0</version>
<packaging>pom</packaging>
<name>blade-tool</name>
<description>
@ -36,22 +36,23 @@
</scm>
<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>
<maven.plugin.version>3.8.0</maven.plugin.version>
<swagger.version>2.9.2</swagger.version>
<swagger.models.version>1.5.21</swagger.models.version>
<knife4j.version>2.0.4</knife4j.version>
<swagger.version>2.10.5</swagger.version>
<swagger.models.version>1.6.2</swagger.models.version>
<knife4j.version>2.0.6</knife4j.version>
<mybatis.plus.version>3.4.0</mybatis.plus.version>
<protostuff.version>1.6.0</protostuff.version>
<disruptor.version>3.4.2</disruptor.version>
<spring.boot.admin.version>2.3.0</spring.boot.admin.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>
<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.platform.version>Cairo-SR8</spring.platform.version>
@ -73,10 +74,21 @@
<module>blade-core-tool</module>
<module>blade-core-oss</module>
<module>blade-core-transaction</module>
<module>blade-core-report</module>
</modules>
<dependencyManagement>
<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>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>