//package org.springblade.modules.ureport.config;
|
//
|
//import java.io.ByteArrayInputStream;
|
//import java.io.InputStream;
|
//import java.util.ArrayList;
|
//import java.util.Date;
|
//import java.util.List;
|
//import com.bstek.ureport.provider.report.ReportFile;
|
//import org.springblade.modules.ureport.entity.UReportFile;
|
//import org.springblade.modules.ureport.mapper.ReportFileMappers;
|
//import org.springframework.beans.factory.annotation.Autowired;
|
//import org.springframework.boot.context.properties.ConfigurationProperties;
|
//import org.springframework.stereotype.Component;
|
//import com.bstek.ureport.provider.report.ReportProvider;
|
//import lombok.Setter;
|
//
|
///**
|
// * Mysql 报表存储
|
// * @author zhongrj
|
// * @since 2022-03-21
|
// * @ConfigurationProperties 该注解可以利用其 prefix属性值 + 类的属性名 在yml中配置属性值
|
// * 特定前缀,ureport底层会调用 getPrefix 方法来获取报表操作的Provier类
|
// */
|
//
|
//@Setter
|
//@Component
|
//@ConfigurationProperties(prefix = "ureport.mysql.provider")
|
//public class MySQLProvider implements ReportProvider{
|
//
|
// private static final String NAME = "mysql-provider";
|
//
|
// private String prefix = "mysql:";
|
//
|
// /**
|
// * 是否禁用
|
// */
|
// private boolean disabled;
|
//
|
// @Autowired
|
// private ReportFileMappers reportFileMappers;
|
//
|
// /**
|
// * 加载文件内容
|
// * @param file
|
// * @return
|
// */
|
// @Override
|
// public InputStream loadReport(String file) {
|
// UReportFile reportFile = reportFileMappers.queryReportFileEntityByName(getCorrectName(file));
|
// byte[] content = reportFile.getContent();
|
// ByteArrayInputStream inputStream = new ByteArrayInputStream(content);
|
// return inputStream;
|
// }
|
//
|
// /**
|
// * 删除
|
// * @param file
|
// */
|
// @Override
|
// public void deleteReport(String file) {
|
// reportFileMappers.deleteReportFileByName(getCorrectName(file));
|
// }
|
//
|
// /**
|
// * 查询
|
// * @return
|
// */
|
// @Override
|
// public List<ReportFile> getReportFiles() {
|
// List<UReportFile> list = reportFileMappers.queryReportFileList();
|
// List<ReportFile> reportList = new ArrayList<>();
|
// for (UReportFile ureportFileEntity : list) {
|
// reportList.add(new ReportFile(ureportFileEntity.getName(), ureportFileEntity.getUpdateTime()));
|
// }
|
// return reportList;
|
// }
|
//
|
// /**
|
// * 保存
|
// * @param file
|
// * @param content
|
// */
|
// @Override
|
// public void saveReport(String file, String content) {
|
// file = getCorrectName(file);
|
// UReportFile reportFile = reportFileMappers.queryReportFileEntityByName(file);
|
// Date currentDate = new Date();
|
// if(reportFile == null){
|
// reportFile = new UReportFile();
|
// reportFile.setName(file);
|
// reportFile.setContent(content.getBytes());
|
// reportFile.setCreateTime(currentDate);
|
// reportFile.setUpdateTime(currentDate);
|
// reportFileMappers.insertReportFile(reportFile);
|
// }else{
|
// reportFile.setContent(content.getBytes());
|
// reportFile.setUpdateTime(currentDate);
|
// reportFileMappers.updateReportFile(reportFile);
|
// }
|
// }
|
//
|
// /**
|
// * 获取name
|
// * @return
|
// */
|
// @Override
|
// public String getName() {
|
// return NAME;
|
// }
|
//
|
// /**
|
// * 是否禁用
|
// * @return
|
// */
|
// @Override
|
// public boolean disabled() {
|
// return disabled;
|
// }
|
//
|
// /**
|
// * 获取前缀
|
// * @return
|
// */
|
// @Override
|
// public String getPrefix() {
|
// return prefix;
|
// }
|
//
|
// /**
|
// * 获取没有前缀的文件名
|
// * @param name
|
// * @return
|
// */
|
// private String getCorrectName(String name){
|
// if(name.startsWith(prefix)){
|
// name = name.substring(prefix.length());
|
// }
|
// return name;
|
// }
|
//}
|