From ae5a68f2382e77a14a697cedb6e57f21735ceb85 Mon Sep 17 00:00:00 2001
From: Administrator <admin>
Date: Tue, 22 Mar 2022 17:15:02 +0800
Subject: [PATCH] 新增docker compose 部署

---
 src/main/java/org/springblade/modules/ureport/config/UreportConfig.java                |   56 +++++++
 docker-compose.yml                                                                     |   11 +
 src/main/java/org/springblade/modules/ureport/mapper/ReportFileMappers.xml             |   36 ++++
 src/main/java/org/springblade/modules/ureport/service/impl/ReportFilesServiceImpl.java |   35 ++++
 src/main/java/org/springblade/modules/ureport/config/MySQLProvider.java                |  140 +++++++++++++++++
 src/main/java/org/springblade/modules/ureport/service/ReportFileService.java           |   21 ++
 src/main/java/org/springblade/modules/ureport/controller/ReportFileController.java     |   42 +++++
 src/main/resources/ureport.properties                                                  |    8 +
 src/main/java/org/springblade/modules/ureport/entity/UReportFile.java                  |   66 ++++++++
 src/main/java/org/springblade/modules/ureport/mapper/ReportFileMappers.java            |   54 ++++++
 pom.xml                                                                                |    6 
 11 files changed, 475 insertions(+), 0 deletions(-)

diff --git a/docker-compose.yml b/docker-compose.yml
new file mode 100644
index 0000000..9fc59f4
--- /dev/null
+++ b/docker-compose.yml
@@ -0,0 +1,11 @@
+version: '3.1'
+services:
+  zhbaw:
+    build: .
+    image: zhbaw:latest
+    depends_on:
+      - redis
+    ports:
+      - "81:81"
+  redis:
+    image: "redis:alpine"
diff --git a/pom.xml b/pom.xml
index aac595d..0511766 100644
--- a/pom.xml
+++ b/pom.xml
@@ -279,6 +279,12 @@
             <groupId>org.springframework.boot</groupId>
             <artifactId>spring-boot-starter-quartz</artifactId>
         </dependency>
+        <!--ureport-->
+<!--        <dependency>-->
+<!--            <groupId>com.syyai.spring.boot</groupId>-->
+<!--            <artifactId>ureport-spring-boot-starter</artifactId>-->
+<!--            <version>2.2.9</version>-->
+<!--        </dependency>-->
 
     </dependencies>
     <profiles>
diff --git a/src/main/java/org/springblade/modules/ureport/config/MySQLProvider.java b/src/main/java/org/springblade/modules/ureport/config/MySQLProvider.java
new file mode 100644
index 0000000..b44c474
--- /dev/null
+++ b/src/main/java/org/springblade/modules/ureport/config/MySQLProvider.java
@@ -0,0 +1,140 @@
+//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;
+//	}
+//}
diff --git a/src/main/java/org/springblade/modules/ureport/config/UreportConfig.java b/src/main/java/org/springblade/modules/ureport/config/UreportConfig.java
new file mode 100644
index 0000000..8a7d67e
--- /dev/null
+++ b/src/main/java/org/springblade/modules/ureport/config/UreportConfig.java
@@ -0,0 +1,56 @@
+//package org.springblade.modules.ureport.config;
+//import com.bstek.ureport.console.UReportServlet;
+//import com.bstek.ureport.definition.datasource.BuildinDatasource;
+//import org.springblade.core.log.exception.ServiceException;
+//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 javax.annotation.Resource;
+//import javax.sql.DataSource;
+//import java.sql.Connection;
+//import java.sql.SQLException;
+//
+///**
+// * ureport 配置类
+// * @author zhongrj
+// * @since 2022-03-21
+// */
+//@ImportResource("classpath:ureport-console-context.xml")//不加项目能够启动但是会导致加载数据源报错或加载不了
+//@Configuration
+//public class UreportConfig implements BuildinDatasource {
+//
+//	@Resource
+//	DataSource dataSource;
+//
+//	/**
+//	 * 定义ureport的启动servlet
+//	 * @return
+//	 */
+//	@Bean
+//	@SuppressWarnings("unchecked")
+//	public ServletRegistrationBean ureportServlet(){
+//		ServletRegistrationBean servletRegistrationBean = new ServletRegistrationBean(new UReportServlet());
+//		servletRegistrationBean.addUrlMappings("/ureport/*");
+//		return servletRegistrationBean;
+//	}
+//
+//
+//	@Override
+//	public String name() {
+//		return "智慧保安数据源";
+//	}
+//
+//	@Override
+//	public Connection getConnection() {
+//		try {
+//			return dataSource.getConnection();
+//		} catch (SQLException e) {
+//			new ServiceException("Ureport 数据源 获取连接失败!");
+//			e.printStackTrace();
+//		}
+//		return null;
+//	}
+//
+//}
diff --git a/src/main/java/org/springblade/modules/ureport/controller/ReportFileController.java b/src/main/java/org/springblade/modules/ureport/controller/ReportFileController.java
new file mode 100644
index 0000000..36d6953
--- /dev/null
+++ b/src/main/java/org/springblade/modules/ureport/controller/ReportFileController.java
@@ -0,0 +1,42 @@
+//package org.springblade.modules.ureport.controller;
+//
+//import com.baomidou.mybatisplus.core.metadata.IPage;
+//import org.springblade.core.mp.support.Condition;
+//import org.springblade.core.mp.support.Query;
+//import org.springblade.core.tool.api.R;
+//import org.springblade.modules.ureport.entity.UReportFile;
+//import org.springblade.modules.ureport.service.ReportFileService;
+//import org.springframework.beans.factory.annotation.Autowired;
+//import org.springframework.web.bind.annotation.GetMapping;
+//import org.springframework.web.bind.annotation.RequestMapping;
+//import org.springframework.web.bind.annotation.RestController;
+//import javax.servlet.http.HttpServletResponse;
+//
+///**
+// * 报表导出控制层
+// * @author zhongrj
+// */
+//@RestController
+//@RequestMapping("/report")
+////@AllArgsConstructor
+//public class ReportFileController {
+//
+//	@Autowired
+//	private ReportFileService reportFileService;
+//
+//
+//	/**
+//	 * 导出数据模板列表
+//	 * @param reportFile 对象
+//	 * @param query  查询页码
+//	 * @param response
+//	 * @return
+//	 */
+//	@GetMapping("/page")
+//	public R<IPage<UReportFile>> page(UReportFile reportFile, Query query, HttpServletResponse response) {
+//		response.setHeader("Access-Control-Allow-Origin", "*");
+//		response.setHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS, DELETE");
+//		response.setHeader("Access-Control-Allow-Credentials","true");
+//		return R.data(reportFileService.selectReportFilePage(Condition.getPage(query), reportFile));
+//	}
+//}
diff --git a/src/main/java/org/springblade/modules/ureport/entity/UReportFile.java b/src/main/java/org/springblade/modules/ureport/entity/UReportFile.java
new file mode 100644
index 0000000..661da95
--- /dev/null
+++ b/src/main/java/org/springblade/modules/ureport/entity/UReportFile.java
@@ -0,0 +1,66 @@
+//package org.springblade.modules.ureport.entity;
+//
+//import com.baomidou.mybatisplus.annotation.IdType;
+//import com.baomidou.mybatisplus.annotation.TableField;
+//import com.baomidou.mybatisplus.annotation.TableId;
+//import com.baomidou.mybatisplus.annotation.TableName;
+//import com.fasterxml.jackson.annotation.JsonFormat;
+//import lombok.Data;
+//import lombok.NoArgsConstructor;
+//import org.springframework.format.annotation.DateTimeFormat;
+//
+//import java.util.Date;
+//
+///**
+// * 报表实体类
+// * @author zhongrj
+// * @since 2022-03-21
+// */
+//@Data
+//@TableName("sys_report_file")
+//public class UReportFile {
+//
+//	public UReportFile() {
+//	}
+//
+//	public UReportFile(String name, Date updateTime) {
+//		this.name = name;
+//		this.updateTime = updateTime;
+//	}
+//
+//	/**
+//	 * 主键id
+//	 */
+//	@TableId(value = "id",type = IdType.AUTO)
+//	private Integer id;
+//
+//	/**
+//	 * 文件名
+//	 */
+//	private String name;
+//
+//	/**
+//	 * 文件内容
+//	 */
+//	private byte[] content;
+//
+//
+//	/**
+//	 * 创建时间
+//	 */
+//	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
+//	@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+//	private Date createTime;
+//
+//	/**
+//	 * 更新时间
+//	 */
+//	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
+//	@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+//	private Date updateTime;
+//
+//	/**
+//	 * 是否删除  0未删除  1 已删除
+//	 */
+//	private Integer isDeleted;
+//}
diff --git a/src/main/java/org/springblade/modules/ureport/mapper/ReportFileMappers.java b/src/main/java/org/springblade/modules/ureport/mapper/ReportFileMappers.java
new file mode 100644
index 0000000..3a32fda
--- /dev/null
+++ b/src/main/java/org/springblade/modules/ureport/mapper/ReportFileMappers.java
@@ -0,0 +1,54 @@
+//package org.springblade.modules.ureport.mapper;
+//
+//import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+//import org.springblade.modules.ureport.entity.UReportFile;
+//
+//import java.util.List;
+//
+///**
+// * 报表导出mapper映射层
+// * @author zhongrj
+// */
+//public interface ReportFileMappers extends BaseMapper<UReportFile> {
+//
+//	/**
+//	 *  根据报表名称检查报表是否存在
+//	 * @param name 报表名称
+//	 * @return
+//	 */
+//	int checkExistByName(String name);
+//
+//	/**
+//	 *  根据报表名称查询报表
+//	 * @param name 报表名称
+//	 * @return
+//	 */
+//	UReportFile queryReportFileEntityByName(String name);
+//
+//	/**
+//	 * 查询全部报表
+//	 * @return
+//	 */
+//	List<UReportFile> queryReportFileList();
+//
+//	/**
+//	 * 根据报表名称删除报表
+//	 * @param name
+//	 * @return
+//	 */
+//	int deleteReportFileByName(String name);
+//
+//
+//	/**
+//	 *  保存报表
+//	 */
+//	int insertReportFile(UReportFile entity);
+//
+//	/**
+//	 *  更新报表
+//	 * @param entity
+//	 * @return
+//	 */
+//	int updateReportFile(UReportFile entity);
+//
+//}
diff --git a/src/main/java/org/springblade/modules/ureport/mapper/ReportFileMappers.xml b/src/main/java/org/springblade/modules/ureport/mapper/ReportFileMappers.xml
new file mode 100644
index 0000000..4d28150
--- /dev/null
+++ b/src/main/java/org/springblade/modules/ureport/mapper/ReportFileMappers.xml
@@ -0,0 +1,36 @@
+<!--<?xml version="1.0" encoding="UTF-8"?>-->
+<!--<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">-->
+<!--<mapper namespace="org.springblade.modules.ureport.mapper.ReportFileMappers">-->
+
+<!--    <select id="checkExistByName" parameterType="java.lang.String" resultType="java.lang.Integer">-->
+<!--		select count(*) from sys_report_file where name = #{name}-->
+<!--	</select>-->
+
+<!--    <select id="queryReportFileList" resultType="org.springblade.modules.ureport.entity.UReportFile">-->
+<!--		select * from sys_report_file-->
+<!--	</select>-->
+
+<!--    <select id="queryReportFileEntityByName" resultType="org.springblade.modules.ureport.entity.UReportFile">-->
+<!--		select * from sys_report_file where name = #{name}-->
+<!--	</select>-->
+
+<!--    <delete id="deleteReportFileByName" parameterType="java.lang.String">-->
+<!--		delete from sys_report_file where name = #{name}-->
+<!--	</delete>-->
+
+<!--    <insert id="insertReportFile" parameterType="org.springblade.modules.ureport.entity.UReportFile">-->
+<!--		insert into sys_report_file (name, content, create_time, update_time) values-->
+<!--		 (#{name}, #{content}, #{createTime}, #{updateTime})-->
+<!--	</insert>-->
+
+
+<!--    <update id="updateReportFile" parameterType="org.springblade.modules.ureport.entity.UReportFile">-->
+<!--		update sys_report_file set-->
+<!--			name = #{name} ,-->
+<!--			content = #{content},-->
+<!--			create_time = #{createTime},-->
+<!--			update_time = #{updateTime}-->
+<!--		    where id = #{id}-->
+<!--	</update>-->
+
+<!--</mapper>-->
diff --git a/src/main/java/org/springblade/modules/ureport/service/ReportFileService.java b/src/main/java/org/springblade/modules/ureport/service/ReportFileService.java
new file mode 100644
index 0000000..b585d0e
--- /dev/null
+++ b/src/main/java/org/springblade/modules/ureport/service/ReportFileService.java
@@ -0,0 +1,21 @@
+//package org.springblade.modules.ureport.service;
+//
+//import com.baomidou.mybatisplus.core.metadata.IPage;
+//import com.baomidou.mybatisplus.extension.service.IService;
+//import org.springblade.modules.ureport.entity.UReportFile;
+//
+///**
+// * 报表导出服务层
+// * @author zhongrj
+// * @since 2022-03-21
+// */
+//public interface ReportFileService extends IService<UReportFile> {
+//
+//	/**
+//	 * 导出数据模板列表
+//	 * @param page
+//	 * @param reportFile 对象
+//	 * @return
+//	 */
+//	IPage<UReportFile> selectReportFilePage(IPage<UReportFile> page, UReportFile reportFile);
+//}
diff --git a/src/main/java/org/springblade/modules/ureport/service/impl/ReportFilesServiceImpl.java b/src/main/java/org/springblade/modules/ureport/service/impl/ReportFilesServiceImpl.java
new file mode 100644
index 0000000..b17e90f
--- /dev/null
+++ b/src/main/java/org/springblade/modules/ureport/service/impl/ReportFilesServiceImpl.java
@@ -0,0 +1,35 @@
+//package org.springblade.modules.ureport.service.impl;
+//
+//import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+//import com.baomidou.mybatisplus.core.metadata.IPage;
+//import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+//import org.springblade.modules.ureport.entity.UReportFile;
+//import org.springblade.modules.ureport.mapper.ReportFileMappers;
+//import org.springblade.modules.ureport.service.ReportFileService;
+//import org.springframework.stereotype.Service;
+//
+//
+///**
+// * 报表导出服务实现层
+// * @author zhongrj
+// */
+//@Service
+//public class ReportFilesServiceImpl extends ServiceImpl<ReportFileMappers, UReportFile> implements ReportFileService {
+//
+//	/**
+//	 * 导出数据模板列表
+//	 * @param page
+//	 * @param reportFile 对象
+//	 * @return
+//	 */
+//	@Override
+//	public IPage<UReportFile> selectReportFilePage(IPage<UReportFile> page, UReportFile reportFile) {
+//		QueryWrapper<UReportFile> queryWrapper = new QueryWrapper<>();
+//		queryWrapper.eq("is_deleted",0);
+//		if (null!=reportFile.getName()) {
+//			queryWrapper.like("name", reportFile.getName());
+//		}
+//		return page.setRecords(baseMapper.selectList(queryWrapper));
+//	}
+//
+//}
diff --git a/src/main/resources/ureport.properties b/src/main/resources/ureport.properties
new file mode 100644
index 0000000..799c5db
--- /dev/null
+++ b/src/main/resources/ureport.properties
@@ -0,0 +1,8 @@
+## ��ureport.disableFileProvider�ij�true,���ɽ���Ĭ���ṩ���ļ��洢����
+#ureport.disableHttpSessionReportCache= false
+#ureport.disableFileProvider= false
+#ureport.fileStoreDir= /WEB-INF/ureportfiles
+#ureport.debug= true
+## ���÷���ǰ׺
+#ureport.mysql.provider.prefix= zhba-
+#ureport.mysql.provider.disabled= false

--
Gitblit v1.9.3