Commit 8bcc732c33957a48b58cb03a0ca6267dd91ebd96
Committed by
Gitee
!744 【新增】ureport2 集成
Merge pull request !744 from souvc/master
Showing
24 changed files
with
1071 additions
and
0 deletions
sql/mysql/Ureport.sql
0 → 100644
| 1 | +-- 菜单 SQL | ||
| 2 | +INSERT INTO system_menu( | ||
| 3 | + name, permission, type, sort, parent_id, | ||
| 4 | + path, icon, component, status, component_name | ||
| 5 | +) | ||
| 6 | +VALUES ( | ||
| 7 | + 'Ureport2报表', '', 2, 0, 1281, | ||
| 8 | + 'ureport-file', '', 'report/ureport/index', 0, 'UreportFile' | ||
| 9 | + ); | ||
| 10 | + | ||
| 11 | +-- 按钮父菜单ID | ||
| 12 | +-- 暂时只支持 MySQL。如果你是 Oracle、PostgreSQL、SQLServer 的话,需要手动修改 @parentId 的部分的代码 | ||
| 13 | +SELECT @parentId := LAST_INSERT_ID(); | ||
| 14 | + | ||
| 15 | +-- 按钮 SQL | ||
| 16 | +INSERT INTO system_menu( | ||
| 17 | + name, permission, type, sort, parent_id, | ||
| 18 | + path, icon, component, status | ||
| 19 | +) | ||
| 20 | +VALUES ( | ||
| 21 | + 'Ureport2报表查询', 'report:ureport-file:query', 3, 1, @parentId, | ||
| 22 | + '', '', '', 0 | ||
| 23 | + ); | ||
| 24 | +INSERT INTO system_menu( | ||
| 25 | + name, permission, type, sort, parent_id, | ||
| 26 | + path, icon, component, status | ||
| 27 | +) | ||
| 28 | +VALUES ( | ||
| 29 | + 'Ureport2报表创建', 'report:ureport-file:create', 3, 2, @parentId, | ||
| 30 | + '', '', '', 0 | ||
| 31 | + ); | ||
| 32 | +INSERT INTO system_menu( | ||
| 33 | + name, permission, type, sort, parent_id, | ||
| 34 | + path, icon, component, status | ||
| 35 | +) | ||
| 36 | +VALUES ( | ||
| 37 | + 'Ureport2报表更新', 'report:ureport-file:update', 3, 3, @parentId, | ||
| 38 | + '', '', '', 0 | ||
| 39 | + ); | ||
| 40 | +INSERT INTO system_menu( | ||
| 41 | + name, permission, type, sort, parent_id, | ||
| 42 | + path, icon, component, status | ||
| 43 | +) | ||
| 44 | +VALUES ( | ||
| 45 | + 'Ureport2报表删除', 'report:ureport-file:delete', 3, 4, @parentId, | ||
| 46 | + '', '', '', 0 | ||
| 47 | + ); | ||
| 48 | +INSERT INTO system_menu( | ||
| 49 | + name, permission, type, sort, parent_id, | ||
| 50 | + path, icon, component, status | ||
| 51 | +) | ||
| 52 | +VALUES ( | ||
| 53 | + 'Ureport2报表导出', 'report:ureport-file:export', 3, 5, @parentId, | ||
| 54 | + '', '', '', 0 | ||
| 55 | + ); | ||
| 56 | + | ||
| 57 | + | ||
| 58 | +-- 创建数据库表 | ||
| 59 | +DROP TABLE IF EXISTS `ureport_file`; | ||
| 60 | +CREATE TABLE `ureport_file` ( | ||
| 61 | + `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'ID', | ||
| 62 | + `file_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '文件名称', | ||
| 63 | + `status` tinyint(4) NOT NULL COMMENT '状态', | ||
| 64 | + `file_content` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL COMMENT '文件内容', | ||
| 65 | + `remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '备注', | ||
| 66 | + `creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '创建者', | ||
| 67 | + `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', | ||
| 68 | + `updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '更新者', | ||
| 69 | + `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', | ||
| 70 | + `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除', | ||
| 71 | + `tenant_id` bigint(20) NOT NULL DEFAULT 0 COMMENT '租户编号', | ||
| 72 | + PRIMARY KEY (`id`) USING BTREE | ||
| 73 | +) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = 'Ureport2报表' ROW_FORMAT = Dynamic; | ||
| 74 | + | ||
| 75 | + | ||
| 76 | +-- 插入测试报表 | ||
| 77 | +INSERT INTO `ureport_file` (`id`, `file_name`, `status`, `file_content`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (7, '角色对应的用户列表.ureport.xml', 0, '<?xml version=\"1.0\" encoding=\"UTF-8\"?><ureport><cell expand=\"None\" name=\"A1\" row=\"1\" col=\"1\"><cell-style font-size=\"10\" font-family=\"黑体\" bold=\"true\" align=\"center\" valign=\"middle\"><left-border width=\"1\" style=\"solid\" color=\"0,0,0\"/><right-border width=\"1\" style=\"solid\" color=\"0,0,0\"/><top-border width=\"1\" style=\"solid\" color=\"0,0,0\"/><bottom-border width=\"1\" style=\"solid\" color=\"0,0,0\"/></cell-style><simple-value><![CDATA[角色名称]]></simple-value></cell><cell expand=\"None\" name=\"B1\" row=\"1\" col=\"2\"><cell-style font-size=\"10\" font-family=\"黑体\" bold=\"true\" align=\"center\" valign=\"middle\"><left-border width=\"1\" style=\"solid\" color=\"0,0,0\"/><right-border width=\"1\" style=\"solid\" color=\"0,0,0\"/><top-border width=\"1\" style=\"solid\" color=\"0,0,0\"/><bottom-border width=\"1\" style=\"solid\" color=\"0,0,0\"/></cell-style><simple-value><![CDATA[角色编码]]></simple-value></cell><cell expand=\"None\" name=\"C1\" row=\"1\" col=\"3\"><cell-style font-size=\"10\" font-family=\"黑体\" bold=\"true\" align=\"center\" valign=\"middle\"><left-border width=\"1\" style=\"solid\" color=\"0,0,0\"/><right-border width=\"1\" style=\"solid\" color=\"0,0,0\"/><top-border width=\"1\" style=\"solid\" color=\"0,0,0\"/><bottom-border width=\"1\" style=\"solid\" color=\"0,0,0\"/></cell-style><simple-value><![CDATA[昵称]]></simple-value></cell><cell expand=\"None\" name=\"D1\" row=\"1\" col=\"4\"><cell-style font-size=\"10\" font-family=\"黑体\" bold=\"true\" align=\"center\" valign=\"middle\"><left-border width=\"1\" style=\"solid\" color=\"0,0,0\"/><right-border width=\"1\" style=\"solid\" color=\"0,0,0\"/><top-border width=\"1\" style=\"solid\" color=\"0,0,0\"/><bottom-border width=\"1\" style=\"solid\" color=\"0,0,0\"/></cell-style><simple-value><![CDATA[邮箱]]></simple-value></cell><cell expand=\"None\" name=\"E1\" row=\"1\" col=\"5\"><cell-style font-size=\"9\" forecolor=\"0,0,0\" font-family=\"黑体\" bold=\"true\" align=\"center\" valign=\"middle\"><left-border width=\"1\" style=\"solid\" color=\"0,0,0\"/><right-border width=\"1\" style=\"solid\" color=\"0,0,0\"/><top-border width=\"1\" style=\"solid\" color=\"0,0,0\"/><bottom-border width=\"1\" style=\"solid\" color=\"0,0,0\"/></cell-style><simple-value><![CDATA[手机]]></simple-value></cell><cell expand=\"None\" name=\"F1\" row=\"1\" col=\"6\"><cell-style font-size=\"9\" forecolor=\"0,0,0\" font-family=\"宋体\" align=\"center\" valign=\"middle\"></cell-style><simple-value><![CDATA[]]></simple-value></cell><cell expand=\"Down\" name=\"A2\" row=\"2\" col=\"1\"><cell-style font-size=\"10\" font-family=\"黑体\" align=\"center\" valign=\"middle\"><left-border width=\"1\" style=\"solid\" color=\"0,0,0\"/><right-border width=\"1\" style=\"solid\" color=\"0,0,0\"/><top-border width=\"1\" style=\"solid\" color=\"0,0,0\"/><bottom-border width=\"1\" style=\"solid\" color=\"0,0,0\"/></cell-style><dataset-value dataset-name=\"sys_role\" aggregate=\"group\" property=\"role_name\" order=\"none\" mapping-type=\"simple\"></dataset-value></cell><cell expand=\"Down\" name=\"B2\" row=\"2\" col=\"2\"><cell-style font-size=\"10\" font-family=\"黑体\" align=\"center\" valign=\"middle\"><left-border width=\"1\" style=\"solid\" color=\"0,0,0\"/><right-border width=\"1\" style=\"solid\" color=\"0,0,0\"/><top-border width=\"1\" style=\"solid\" color=\"0,0,0\"/><bottom-border width=\"1\" style=\"solid\" color=\"0,0,0\"/></cell-style><dataset-value dataset-name=\"sys_role\" aggregate=\"group\" property=\"role_code\" order=\"none\" mapping-type=\"simple\"></dataset-value></cell><cell expand=\"Down\" name=\"C2\" row=\"2\" col=\"3\"><cell-style font-size=\"10\" font-family=\"黑体\" align=\"center\" valign=\"middle\"><left-border width=\"1\" style=\"solid\" color=\"0,0,0\"/><right-border width=\"1\" style=\"solid\" color=\"0,0,0\"/><top-border width=\"1\" style=\"solid\" color=\"0,0,0\"/><bottom-border width=\"1\" style=\"solid\" color=\"0,0,0\"/></cell-style><dataset-value dataset-name=\"sys_role\" aggregate=\"group\" property=\"nickname\" order=\"none\" mapping-type=\"simple\"></dataset-value></cell><cell expand=\"Down\" name=\"D2\" row=\"2\" col=\"4\"><cell-style font-size=\"10\" font-family=\"黑体\" align=\"center\" valign=\"middle\"><left-border width=\"1\" style=\"solid\" color=\"0,0,0\"/><right-border width=\"1\" style=\"solid\" color=\"0,0,0\"/><top-border width=\"1\" style=\"solid\" color=\"0,0,0\"/><bottom-border width=\"1\" style=\"solid\" color=\"0,0,0\"/></cell-style><dataset-value dataset-name=\"sys_role\" aggregate=\"group\" property=\"email\" order=\"none\" mapping-type=\"simple\"></dataset-value></cell><cell expand=\"Down\" name=\"E2\" row=\"2\" col=\"5\"><cell-style font-size=\"9\" forecolor=\"0,0,0\" font-family=\"黑体\" align=\"center\" valign=\"middle\"><left-border width=\"1\" style=\"solid\" color=\"0,0,0\"/><right-border width=\"1\" style=\"solid\" color=\"0,0,0\"/><top-border width=\"1\" style=\"solid\" color=\"0,0,0\"/><bottom-border width=\"1\" style=\"solid\" color=\"0,0,0\"/></cell-style><dataset-value dataset-name=\"sys_role\" aggregate=\"group\" property=\"mobile\" order=\"none\" mapping-type=\"simple\"></dataset-value></cell><cell expand=\"None\" name=\"F2\" row=\"2\" col=\"6\"><cell-style font-size=\"9\" forecolor=\"0,0,0\" font-family=\"宋体\" align=\"center\" valign=\"middle\"></cell-style><simple-value><![CDATA[]]></simple-value></cell><cell expand=\"None\" name=\"A3\" row=\"3\" col=\"1\"><cell-style font-size=\"10\" align=\"center\" valign=\"middle\"></cell-style><simple-value><![CDATA[]]></simple-value></cell><cell expand=\"None\" name=\"B3\" row=\"3\" col=\"2\"><cell-style font-size=\"10\" align=\"center\" valign=\"middle\"></cell-style><simple-value><![CDATA[]]></simple-value></cell><cell expand=\"None\" name=\"C3\" row=\"3\" col=\"3\"><cell-style font-size=\"10\" align=\"center\" valign=\"middle\"></cell-style><simple-value><![CDATA[]]></simple-value></cell><cell expand=\"None\" name=\"D3\" row=\"3\" col=\"4\"><cell-style font-size=\"10\" align=\"center\" valign=\"middle\"></cell-style><simple-value><![CDATA[]]></simple-value></cell><cell expand=\"None\" name=\"E3\" row=\"3\" col=\"5\"><cell-style font-size=\"9\" forecolor=\"0,0,0\" font-family=\"宋体\" align=\"center\" valign=\"middle\"></cell-style><simple-value><![CDATA[]]></simple-value></cell><cell expand=\"None\" name=\"F3\" row=\"3\" col=\"6\"><cell-style font-size=\"9\" forecolor=\"0,0,0\" font-family=\"宋体\" align=\"center\" valign=\"middle\"></cell-style><simple-value><![CDATA[]]></simple-value></cell><row row-number=\"1\" height=\"18\"/><row row-number=\"2\" height=\"18\"/><row row-number=\"3\" height=\"18\"/><column col-number=\"1\" width=\"80\"/><column col-number=\"2\" width=\"80\"/><column col-number=\"3\" width=\"80\"/><column col-number=\"4\" width=\"80\"/><column col-number=\"5\" width=\"74\"/><column col-number=\"6\" width=\"74\"/><datasource name=\"UreportDataSource\" type=\"buildin\"><dataset name=\"sys_role\" type=\"sql\"><sql><![CDATA[SELECT sr.name as role_name ,sr.code as role_code,su.username ,su.nickname ,su.email,su.mobile \nFROM system_role sr\nLEFT JOIN system_user_role sur ON sr.id = sur.role_id\nLEFT JOIN system_users su ON sur.user_id = su.id]]></sql><field name=\"role_name\"/><field name=\"role_code\"/><field name=\"username\"/><field name=\"nickname\"/><field name=\"email\"/><field name=\"mobile\"/></dataset></datasource><paper type=\"A4\" left-margin=\"90\" right-margin=\"90\"\n top-margin=\"72\" bottom-margin=\"72\" paging-mode=\"fitpage\" fixrows=\"0\"\n width=\"595\" height=\"842\" orientation=\"portrait\" html-report-align=\"left\" bg-image=\"\" html-interval-refresh-value=\"0\" column-enabled=\"false\"></paper></ureport>', NULL, NULL, '2023-11-22 22:02:44', NULL, '2023-11-22 22:06:51', b'0', 0); |
yudao-dependencies/pom.xml
| @@ -74,6 +74,7 @@ | @@ -74,6 +74,7 @@ | ||
| 74 | <jimureport.version>1.6.1</jimureport.version> | 74 | <jimureport.version>1.6.1</jimureport.version> |
| 75 | <xercesImpl.version>2.12.2</xercesImpl.version> | 75 | <xercesImpl.version>2.12.2</xercesImpl.version> |
| 76 | <weixin-java.version>4.5.0</weixin-java.version> | 76 | <weixin-java.version>4.5.0</weixin-java.version> |
| 77 | + <ureport2.version>2.2.9</ureport2.version> | ||
| 77 | </properties> | 78 | </properties> |
| 78 | 79 | ||
| 79 | <dependencyManagement> | 80 | <dependencyManagement> |
| @@ -651,6 +652,14 @@ | @@ -651,6 +652,14 @@ | ||
| 651 | <artifactId>spring-boot-starter-websocket</artifactId> | 652 | <artifactId>spring-boot-starter-websocket</artifactId> |
| 652 | <version>${spring.boot.version}</version> | 653 | <version>${spring.boot.version}</version> |
| 653 | </dependency> | 654 | </dependency> |
| 655 | + | ||
| 656 | + <!--ureport2 报表--> | ||
| 657 | + <dependency> | ||
| 658 | + <groupId>com.bstek.ureport</groupId> | ||
| 659 | + <artifactId>ureport2-console</artifactId> | ||
| 660 | + <version>${ureport2.version}</version> | ||
| 661 | + </dependency> | ||
| 662 | + | ||
| 654 | </dependencies> | 663 | </dependencies> |
| 655 | </dependencyManagement> | 664 | </dependencyManagement> |
| 656 | 665 |
yudao-module-report/yudao-module-report-api/src/main/java/cn/iocoder/yudao/module/report/enums/ErrorCodeConstants.java
| @@ -12,4 +12,6 @@ public interface ErrorCodeConstants { | @@ -12,4 +12,6 @@ public interface ErrorCodeConstants { | ||
| 12 | // ========== AUTH 模块 1-003-000-000 ========== | 12 | // ========== AUTH 模块 1-003-000-000 ========== |
| 13 | ErrorCode GO_VIEW_PROJECT_NOT_EXISTS = new ErrorCode(1_003_000_000, "GoView 项目不存在"); | 13 | ErrorCode GO_VIEW_PROJECT_NOT_EXISTS = new ErrorCode(1_003_000_000, "GoView 项目不存在"); |
| 14 | 14 | ||
| 15 | + ErrorCode UREPORT_FILE_NOT_EXISTS = new ErrorCode(1_003_001_000, "打印文件不存在,请检查Ureport报表文件"); | ||
| 16 | + ErrorCode UREPORT_FILE_EXISTS = new ErrorCode(1_003_001_001, "报表名字已存在,请修改后再保存"); | ||
| 15 | } | 17 | } |
yudao-module-report/yudao-module-report-biz/pom.xml
| @@ -74,5 +74,15 @@ | @@ -74,5 +74,15 @@ | ||
| 74 | <artifactId>xercesImpl</artifactId> | 74 | <artifactId>xercesImpl</artifactId> |
| 75 | </dependency> | 75 | </dependency> |
| 76 | 76 | ||
| 77 | + <dependency> | ||
| 78 | + <groupId>com.bstek.ureport</groupId> | ||
| 79 | + <artifactId>ureport2-console</artifactId> | ||
| 80 | + </dependency> | ||
| 81 | + | ||
| 82 | + <dependency> | ||
| 83 | + <groupId>cn.iocoder.boot</groupId> | ||
| 84 | + <artifactId>yudao-spring-boot-starter-excel</artifactId> | ||
| 85 | + </dependency> | ||
| 86 | + | ||
| 77 | </dependencies> | 87 | </dependencies> |
| 78 | </project> | 88 | </project> |
yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/controller/admin/ureport/UreportFileController.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.report.controller.admin.ureport; | ||
| 2 | + | ||
| 3 | +import org.springframework.web.bind.annotation.*; | ||
| 4 | +import javax.annotation.Resource; | ||
| 5 | +import org.springframework.validation.annotation.Validated; | ||
| 6 | +import org.springframework.security.access.prepost.PreAuthorize; | ||
| 7 | +import io.swagger.v3.oas.annotations.tags.Tag; | ||
| 8 | +import io.swagger.v3.oas.annotations.Parameter; | ||
| 9 | +import io.swagger.v3.oas.annotations.Operation; | ||
| 10 | + | ||
| 11 | +import javax.validation.constraints.*; | ||
| 12 | +import javax.validation.*; | ||
| 13 | +import javax.servlet.http.*; | ||
| 14 | +import java.util.*; | ||
| 15 | +import java.io.IOException; | ||
| 16 | + | ||
| 17 | +import cn.iocoder.yudao.framework.common.pojo.PageParam; | ||
| 18 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 19 | +import cn.iocoder.yudao.framework.common.pojo.CommonResult; | ||
| 20 | +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | ||
| 21 | +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | ||
| 22 | + | ||
| 23 | +import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; | ||
| 24 | + | ||
| 25 | +import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; | ||
| 26 | +import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.*; | ||
| 27 | + | ||
| 28 | +import cn.iocoder.yudao.module.report.controller.admin.ureport.vo.*; | ||
| 29 | +import cn.iocoder.yudao.module.report.dal.dataobject.ureport.UreportFileDO; | ||
| 30 | +import cn.iocoder.yudao.module.report.service.ureport.UreportFileService; | ||
| 31 | + | ||
| 32 | +@Tag(name = "管理后台 - Ureport2报表") | ||
| 33 | +@RestController | ||
| 34 | +@RequestMapping("/report/ureport-file") | ||
| 35 | +@Validated | ||
| 36 | +public class UreportFileController { | ||
| 37 | + | ||
| 38 | + @Resource | ||
| 39 | + private UreportFileService ureportFileService; | ||
| 40 | + | ||
| 41 | + @PostMapping("/create") | ||
| 42 | + @Operation(summary = "创建Ureport2报表") | ||
| 43 | + @PreAuthorize("@ss.hasPermission('report:ureport-file:create')") | ||
| 44 | + public CommonResult<Long> createUreportFile(@Valid @RequestBody UreportFileSaveReqVO createReqVO) { | ||
| 45 | + return success(ureportFileService.createUreportFile(createReqVO)); | ||
| 46 | + } | ||
| 47 | + | ||
| 48 | + @PutMapping("/update") | ||
| 49 | + @Operation(summary = "更新Ureport2报表") | ||
| 50 | + @PreAuthorize("@ss.hasPermission('report:ureport-file:update')") | ||
| 51 | + public CommonResult<Boolean> updateUreportFile(@Valid @RequestBody UreportFileSaveReqVO updateReqVO) { | ||
| 52 | + ureportFileService.updateUreportFile(updateReqVO); | ||
| 53 | + return success(true); | ||
| 54 | + } | ||
| 55 | + | ||
| 56 | + @DeleteMapping("/delete") | ||
| 57 | + @Operation(summary = "删除Ureport2报表") | ||
| 58 | + @Parameter(name = "id", description = "编号", required = true) | ||
| 59 | + @PreAuthorize("@ss.hasPermission('report:ureport-file:delete')") | ||
| 60 | + public CommonResult<Boolean> deleteUreportFile(@RequestParam("id") Long id) { | ||
| 61 | + ureportFileService.deleteUreportFile(id); | ||
| 62 | + return success(true); | ||
| 63 | + } | ||
| 64 | + | ||
| 65 | + @GetMapping("/get") | ||
| 66 | + @Operation(summary = "获得Ureport2报表") | ||
| 67 | + @Parameter(name = "id", description = "编号", required = true, example = "1024") | ||
| 68 | + @PreAuthorize("@ss.hasPermission('report:ureport-file:query')") | ||
| 69 | + public CommonResult<UreportFileRespVO> getUreportFile(@RequestParam("id") Long id) { | ||
| 70 | + UreportFileDO ureportFile = ureportFileService.getUreportFile(id); | ||
| 71 | + return success(BeanUtils.toBean(ureportFile, UreportFileRespVO.class)); | ||
| 72 | + } | ||
| 73 | + | ||
| 74 | + @GetMapping("/page") | ||
| 75 | + @Operation(summary = "获得Ureport2报表分页") | ||
| 76 | + @PreAuthorize("@ss.hasPermission('report:ureport-file:query')") | ||
| 77 | + public CommonResult<PageResult<UreportFileRespVO>> getUreportFilePage(@Valid UreportFilePageReqVO pageReqVO) { | ||
| 78 | + PageResult<UreportFileDO> pageResult = ureportFileService.getUreportFilePage(pageReqVO); | ||
| 79 | + return success(BeanUtils.toBean(pageResult, UreportFileRespVO.class)); | ||
| 80 | + } | ||
| 81 | + | ||
| 82 | + @GetMapping("/export-excel") | ||
| 83 | + @Operation(summary = "导出Ureport2报表 Excel") | ||
| 84 | + @PreAuthorize("@ss.hasPermission('report:ureport-file:export')") | ||
| 85 | + @OperateLog(type = EXPORT) | ||
| 86 | + public void exportUreportFileExcel(@Valid UreportFilePageReqVO pageReqVO, | ||
| 87 | + HttpServletResponse response) throws IOException { | ||
| 88 | + pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); | ||
| 89 | + List<UreportFileDO> list = ureportFileService.getUreportFilePage(pageReqVO).getList(); | ||
| 90 | + // 导出 Excel | ||
| 91 | + ExcelUtils.write(response, "Ureport2报表.xls", "数据", UreportFileRespVO.class, | ||
| 92 | + BeanUtils.toBean(list, UreportFileRespVO.class)); | ||
| 93 | + } | ||
| 94 | + | ||
| 95 | +} | ||
| 0 | \ No newline at end of file | 96 | \ No newline at end of file |
yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/controller/admin/ureport/vo/UreportFilePageReqVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.report.controller.admin.ureport.vo; | ||
| 2 | + | ||
| 3 | +import lombok.*; | ||
| 4 | +import java.util.*; | ||
| 5 | +import io.swagger.v3.oas.annotations.media.Schema; | ||
| 6 | +import cn.iocoder.yudao.framework.common.pojo.PageParam; | ||
| 7 | +import org.springframework.format.annotation.DateTimeFormat; | ||
| 8 | +import java.time.LocalDateTime; | ||
| 9 | + | ||
| 10 | +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; | ||
| 11 | + | ||
| 12 | +@Schema(description = "管理后台 - Ureport2报表分页 Request VO") | ||
| 13 | +@Data | ||
| 14 | +@EqualsAndHashCode(callSuper = true) | ||
| 15 | +@ToString(callSuper = true) | ||
| 16 | +public class UreportFilePageReqVO extends PageParam { | ||
| 17 | + | ||
| 18 | + @Schema(description = "文件名称", example = "赵六") | ||
| 19 | + private String fileName; | ||
| 20 | + | ||
| 21 | + @Schema(description = "状态", example = "1") | ||
| 22 | + private Integer status; | ||
| 23 | + | ||
| 24 | + @Schema(description = "备注", example = "随便") | ||
| 25 | + private String remark; | ||
| 26 | + | ||
| 27 | + @Schema(description = "创建时间") | ||
| 28 | + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | ||
| 29 | + private LocalDateTime[] createTime; | ||
| 30 | + | ||
| 31 | +} | ||
| 0 | \ No newline at end of file | 32 | \ No newline at end of file |
yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/controller/admin/ureport/vo/UreportFileRespVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.report.controller.admin.ureport.vo; | ||
| 2 | + | ||
| 3 | +import io.swagger.v3.oas.annotations.media.Schema; | ||
| 4 | +import lombok.*; | ||
| 5 | +import java.util.*; | ||
| 6 | +import java.util.*; | ||
| 7 | +import org.springframework.format.annotation.DateTimeFormat; | ||
| 8 | +import java.time.LocalDateTime; | ||
| 9 | +import com.alibaba.excel.annotation.*; | ||
| 10 | + | ||
| 11 | +@Schema(description = "管理后台 - Ureport2报表 Response VO") | ||
| 12 | +@Data | ||
| 13 | +@ExcelIgnoreUnannotated | ||
| 14 | +public class UreportFileRespVO { | ||
| 15 | + | ||
| 16 | + @Schema(description = "ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "9948") | ||
| 17 | + @ExcelProperty("ID") | ||
| 18 | + private Long id; | ||
| 19 | + | ||
| 20 | + @Schema(description = "文件名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "赵六") | ||
| 21 | + @ExcelProperty("文件名称") | ||
| 22 | + private String fileName; | ||
| 23 | + | ||
| 24 | + @Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | ||
| 25 | + @ExcelProperty("状态") | ||
| 26 | + private Integer status; | ||
| 27 | + | ||
| 28 | + @Schema(description = "备注", example = "随便") | ||
| 29 | + @ExcelProperty("备注") | ||
| 30 | + private String remark; | ||
| 31 | + | ||
| 32 | + @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) | ||
| 33 | + @ExcelProperty("创建时间") | ||
| 34 | + private LocalDateTime createTime; | ||
| 35 | + | ||
| 36 | +} | ||
| 0 | \ No newline at end of file | 37 | \ No newline at end of file |
yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/controller/admin/ureport/vo/UreportFileSaveReqVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.report.controller.admin.ureport.vo; | ||
| 2 | + | ||
| 3 | +import io.swagger.v3.oas.annotations.media.Schema; | ||
| 4 | +import lombok.*; | ||
| 5 | +import java.util.*; | ||
| 6 | +import javax.validation.constraints.*; | ||
| 7 | +import java.util.*; | ||
| 8 | + | ||
| 9 | +@Schema(description = "管理后台 - Ureport2报表新增/修改 Request VO") | ||
| 10 | +@Data | ||
| 11 | +public class UreportFileSaveReqVO { | ||
| 12 | + | ||
| 13 | + @Schema(description = "ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "9948") | ||
| 14 | + private Long id; | ||
| 15 | + | ||
| 16 | + @Schema(description = "文件名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "赵六") | ||
| 17 | + @NotEmpty(message = "文件名称不能为空") | ||
| 18 | + private String fileName; | ||
| 19 | + | ||
| 20 | + @Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | ||
| 21 | + @NotNull(message = "状态不能为空") | ||
| 22 | + private Integer status; | ||
| 23 | + | ||
| 24 | + @Schema(description = "文件内容") | ||
| 25 | + private String fileContent; | ||
| 26 | + | ||
| 27 | + @Schema(description = "备注", example = "随便") | ||
| 28 | + private String remark; | ||
| 29 | + | ||
| 30 | +} |
yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/dal/dataobject/ureport/UreportFileDO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.report.dal.dataobject.ureport; | ||
| 2 | + | ||
| 3 | +import lombok.*; | ||
| 4 | +import java.util.*; | ||
| 5 | +import java.time.LocalDateTime; | ||
| 6 | +import java.time.LocalDateTime; | ||
| 7 | +import com.baomidou.mybatisplus.annotation.*; | ||
| 8 | +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; | ||
| 9 | + | ||
| 10 | +/** | ||
| 11 | + * Ureport2报表 DO | ||
| 12 | + * | ||
| 13 | + * @author 芋道源码 | ||
| 14 | + */ | ||
| 15 | +@TableName("ureport_file") | ||
| 16 | +@KeySequence("ureport_file_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 | ||
| 17 | +@Data | ||
| 18 | +@EqualsAndHashCode(callSuper = true) | ||
| 19 | +@ToString(callSuper = true) | ||
| 20 | +@Builder | ||
| 21 | +@NoArgsConstructor | ||
| 22 | +@AllArgsConstructor | ||
| 23 | +public class UreportFileDO extends BaseDO { | ||
| 24 | + | ||
| 25 | + /** | ||
| 26 | + * ID | ||
| 27 | + */ | ||
| 28 | + @TableId | ||
| 29 | + private Long id; | ||
| 30 | + /** | ||
| 31 | + * 文件名称 | ||
| 32 | + */ | ||
| 33 | + private String fileName; | ||
| 34 | + /** | ||
| 35 | + * 状态 | ||
| 36 | + */ | ||
| 37 | + private Integer status; | ||
| 38 | + /** | ||
| 39 | + * 文件内容 | ||
| 40 | + */ | ||
| 41 | + private byte[] fileContent; | ||
| 42 | + /** | ||
| 43 | + * 备注 | ||
| 44 | + */ | ||
| 45 | + private String remark; | ||
| 46 | + | ||
| 47 | +} |
yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/dal/mysql/ureport/UreportFileMapper.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.report.dal.mysql.ureport; | ||
| 2 | + | ||
| 3 | +import java.util.*; | ||
| 4 | + | ||
| 5 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 6 | +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; | ||
| 7 | +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; | ||
| 8 | +import cn.iocoder.yudao.module.report.dal.dataobject.ureport.UreportFileDO; | ||
| 9 | +import org.apache.ibatis.annotations.Mapper; | ||
| 10 | +import cn.iocoder.yudao.module.report.controller.admin.ureport.vo.*; | ||
| 11 | + | ||
| 12 | +/** | ||
| 13 | + * Ureport2报表 Mapper | ||
| 14 | + * | ||
| 15 | + * @author 芋道源码 | ||
| 16 | + */ | ||
| 17 | +@Mapper | ||
| 18 | +public interface UreportFileMapper extends BaseMapperX<UreportFileDO> { | ||
| 19 | + | ||
| 20 | + default PageResult<UreportFileDO> selectPage(UreportFilePageReqVO reqVO) { | ||
| 21 | + return selectPage(reqVO, new LambdaQueryWrapperX<UreportFileDO>() | ||
| 22 | + .likeIfPresent(UreportFileDO::getFileName, reqVO.getFileName()) | ||
| 23 | + .eqIfPresent(UreportFileDO::getStatus, reqVO.getStatus()) | ||
| 24 | + .eqIfPresent(UreportFileDO::getRemark, reqVO.getRemark()) | ||
| 25 | + .betweenIfPresent(UreportFileDO::getCreateTime, reqVO.getCreateTime()) | ||
| 26 | + .orderByDesc(UreportFileDO::getId)); | ||
| 27 | + } | ||
| 28 | + | ||
| 29 | +} | ||
| 0 | \ No newline at end of file | 30 | \ No newline at end of file |
yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/framework/security/config/SecurityConfiguration.java
| @@ -20,6 +20,7 @@ public class SecurityConfiguration { | @@ -20,6 +20,7 @@ public class SecurityConfiguration { | ||
| 20 | public void customize(ExpressionUrlAuthorizationConfigurer<HttpSecurity>.ExpressionInterceptUrlRegistry registry) { | 20 | public void customize(ExpressionUrlAuthorizationConfigurer<HttpSecurity>.ExpressionInterceptUrlRegistry registry) { |
| 21 | //积木报表 | 21 | //积木报表 |
| 22 | registry.antMatchers("/jmreport/**").permitAll(); | 22 | registry.antMatchers("/jmreport/**").permitAll(); |
| 23 | + registry.antMatchers("/ureport/**").permitAll(); | ||
| 23 | } | 24 | } |
| 24 | 25 | ||
| 25 | }; | 26 | }; |
yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/framework/ureport/config/UreportConfiguration.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.report.framework.ureport.config; | ||
| 2 | + | ||
| 3 | +import com.bstek.ureport.console.UReportServlet; | ||
| 4 | +import org.springframework.boot.web.servlet.ServletRegistrationBean; | ||
| 5 | +import org.springframework.context.annotation.Bean; | ||
| 6 | +import org.springframework.context.annotation.Configuration; | ||
| 7 | +import org.springframework.context.annotation.ImportResource; | ||
| 8 | +import org.springframework.context.annotation.PropertySource; | ||
| 9 | + | ||
| 10 | +import javax.servlet.Servlet; | ||
| 11 | + | ||
| 12 | +/** | ||
| 13 | + * Ureport 配置类 | ||
| 14 | + * 加载ureport对应的xml配置文件 | ||
| 15 | + * @author 赤焰 | ||
| 16 | + */ | ||
| 17 | +@Configuration | ||
| 18 | +@ImportResource({"classpath:ureport-console-context.xml"}) | ||
| 19 | +@PropertySource(value = {"classpath:ureport.properties"}) | ||
| 20 | +public class UreportConfiguration { | ||
| 21 | + | ||
| 22 | + @Bean | ||
| 23 | + public ServletRegistrationBean<Servlet> registrationBean() { | ||
| 24 | + return new ServletRegistrationBean<>(new UReportServlet(), "/ureport/*"); | ||
| 25 | + } | ||
| 26 | + | ||
| 27 | +} |
yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/framework/ureport/config/UreportDataSource.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.report.framework.ureport.config; | ||
| 2 | + | ||
| 3 | +import com.bstek.ureport.definition.datasource.BuildinDatasource; | ||
| 4 | +import lombok.extern.slf4j.Slf4j; | ||
| 5 | +import org.springframework.stereotype.Component; | ||
| 6 | + | ||
| 7 | +import javax.annotation.Resource; | ||
| 8 | +import javax.sql.DataSource; | ||
| 9 | +import java.sql.Connection; | ||
| 10 | +import java.sql.SQLException; | ||
| 11 | + | ||
| 12 | +/** | ||
| 13 | + * ureport内置数据源 | ||
| 14 | + */ | ||
| 15 | +@Slf4j | ||
| 16 | +@Component | ||
| 17 | +public class UreportDataSource implements BuildinDatasource { | ||
| 18 | + | ||
| 19 | + private static final String NAME = "UreportDataSource"; | ||
| 20 | + | ||
| 21 | + @Resource | ||
| 22 | + private DataSource dataSource; | ||
| 23 | + | ||
| 24 | + /** | ||
| 25 | + * 数据源名称 | ||
| 26 | + * | ||
| 27 | + **/ | ||
| 28 | + @Override | ||
| 29 | + public String name() { | ||
| 30 | + return NAME; | ||
| 31 | + } | ||
| 32 | + | ||
| 33 | + /** | ||
| 34 | + * * 获取连接 | ||
| 35 | + * | ||
| 36 | + **/ | ||
| 37 | + @Override | ||
| 38 | + public Connection getConnection() { | ||
| 39 | + try { | ||
| 40 | + return dataSource.getConnection(); | ||
| 41 | + } catch (SQLException e) { | ||
| 42 | + log.error("Ureport 数据源 获取连接失败!"); | ||
| 43 | + e.printStackTrace(); | ||
| 44 | + } | ||
| 45 | + return null; | ||
| 46 | + } | ||
| 47 | + | ||
| 48 | +} |
yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/framework/ureport/provider/UreportDatabaseProvider.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.report.framework.ureport.provider; | ||
| 2 | + | ||
| 3 | +import cn.hutool.core.bean.BeanUtil; | ||
| 4 | +import cn.hutool.core.collection.CollUtil; | ||
| 5 | +import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; | ||
| 6 | +import cn.iocoder.yudao.module.report.controller.admin.ureport.vo.UreportFileSaveReqVO; | ||
| 7 | +import cn.iocoder.yudao.module.report.dal.dataobject.ureport.UreportFileDO; | ||
| 8 | +import cn.iocoder.yudao.module.report.service.ureport.UreportFileService; | ||
| 9 | +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | ||
| 10 | +import com.bstek.ureport.provider.report.ReportFile; | ||
| 11 | +import com.bstek.ureport.provider.report.ReportProvider; | ||
| 12 | +import lombok.Setter; | ||
| 13 | +import lombok.extern.slf4j.Slf4j; | ||
| 14 | +import org.springframework.boot.context.properties.ConfigurationProperties; | ||
| 15 | +import org.springframework.stereotype.Component; | ||
| 16 | + | ||
| 17 | +import javax.annotation.Resource; | ||
| 18 | +import java.io.ByteArrayInputStream; | ||
| 19 | +import java.io.InputStream; | ||
| 20 | +import java.time.LocalDateTime; | ||
| 21 | +import java.time.ZoneId; | ||
| 22 | +import java.time.ZonedDateTime; | ||
| 23 | +import java.util.ArrayList; | ||
| 24 | +import java.util.Date; | ||
| 25 | +import java.util.List; | ||
| 26 | + | ||
| 27 | +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | ||
| 28 | +import static cn.iocoder.yudao.module.report.enums.ErrorCodeConstants.UREPORT_FILE_EXISTS; | ||
| 29 | +import static cn.iocoder.yudao.module.report.enums.ErrorCodeConstants.UREPORT_FILE_NOT_EXISTS; | ||
| 30 | + | ||
| 31 | +/** | ||
| 32 | + * 提供数据库的存储方式 | ||
| 33 | + * @author 赤焰 | ||
| 34 | + */ | ||
| 35 | +@Slf4j | ||
| 36 | +@Setter | ||
| 37 | +@Component | ||
| 38 | +@ConfigurationProperties(prefix = "ureport.provider.database") | ||
| 39 | +public class UreportDatabaseProvider implements ReportProvider{ | ||
| 40 | + | ||
| 41 | + private static final String NAME = "mysql-provider"; | ||
| 42 | + | ||
| 43 | + private String prefix = "mysql:"; | ||
| 44 | + | ||
| 45 | + private boolean disabled = false; | ||
| 46 | + @Resource | ||
| 47 | + private UreportFileService ureportFileService; | ||
| 48 | + | ||
| 49 | + @Override | ||
| 50 | + public InputStream loadReport(String file) { | ||
| 51 | + Long reportDo = ureportFileService.checkExistByName(getCorrectName(file)); | ||
| 52 | + if (reportDo <=0) { | ||
| 53 | + throw exception(UREPORT_FILE_NOT_EXISTS); | ||
| 54 | + } | ||
| 55 | + UreportFileDO ureportFileDO = ureportFileService.queryUreportFileDoByName(getCorrectName(file)); | ||
| 56 | + byte[] content = ureportFileDO.getFileContent(); | ||
| 57 | + return new ByteArrayInputStream(content); | ||
| 58 | + } | ||
| 59 | + | ||
| 60 | + @Override | ||
| 61 | + public void deleteReport(String file) { | ||
| 62 | + ureportFileService.deleteReportFileByName(getCorrectName(file)); | ||
| 63 | + } | ||
| 64 | + | ||
| 65 | + @Override | ||
| 66 | + public List<ReportFile> getReportFiles() { | ||
| 67 | + List<UreportFileDO> list = ureportFileService.queryReportFileList(); | ||
| 68 | + List<ReportFile> reportList = new ArrayList<>(); | ||
| 69 | + if(CollUtil.isEmpty(list)){ | ||
| 70 | + return reportList; | ||
| 71 | + } | ||
| 72 | + for (UreportFileDO reportFile : list) { | ||
| 73 | + LocalDateTime updateTime = reportFile.getUpdateTime(); | ||
| 74 | + ZonedDateTime zdt = updateTime.atZone(ZoneId.systemDefault()); | ||
| 75 | + Date date = Date.from(zdt.toInstant()); | ||
| 76 | + reportList.add(new ReportFile(reportFile.getFileName(),date)); | ||
| 77 | + } | ||
| 78 | + return reportList; | ||
| 79 | + | ||
| 80 | + } | ||
| 81 | + | ||
| 82 | + @Override | ||
| 83 | + public void saveReport(String file, String content) { | ||
| 84 | + file = getCorrectName(file); | ||
| 85 | + LambdaQueryWrapper<UreportFileDO> queryWrapper = new LambdaQueryWrapper<>(); | ||
| 86 | + queryWrapper.eq(UreportFileDO::getFileName, file); | ||
| 87 | + Long count = ureportFileService.checkExistByName(file); | ||
| 88 | + if(count>1){ | ||
| 89 | + throw exception(UREPORT_FILE_EXISTS); | ||
| 90 | + } | ||
| 91 | + UreportFileDO ureportFileDO = ureportFileService.queryUreportFileDoByName(file); | ||
| 92 | + UreportFileSaveReqVO saveReqVO = new UreportFileSaveReqVO(); | ||
| 93 | + if (ureportFileDO == null) { | ||
| 94 | + saveReqVO.setFileName(file); | ||
| 95 | + saveReqVO.setFileContent(content); | ||
| 96 | + saveReqVO.setStatus(CommonStatusEnum.ENABLE.getStatus()); | ||
| 97 | + ureportFileService.createUreportFile(saveReqVO); | ||
| 98 | + } else { | ||
| 99 | + saveReqVO.setId(ureportFileDO.getId()); | ||
| 100 | + saveReqVO.setFileName(file); | ||
| 101 | + saveReqVO.setFileContent(content); | ||
| 102 | + saveReqVO.setStatus(CommonStatusEnum.ENABLE.getStatus()); | ||
| 103 | + ureportFileService.updateUreportFile(saveReqVO); | ||
| 104 | + } | ||
| 105 | + } | ||
| 106 | + | ||
| 107 | + @Override | ||
| 108 | + public String getName() { | ||
| 109 | + return NAME; | ||
| 110 | + } | ||
| 111 | + | ||
| 112 | + @Override | ||
| 113 | + public boolean disabled() { | ||
| 114 | + return disabled; | ||
| 115 | + } | ||
| 116 | + | ||
| 117 | + @Override | ||
| 118 | + public String getPrefix() { | ||
| 119 | + return prefix; | ||
| 120 | + } | ||
| 121 | + | ||
| 122 | + private String getCorrectName(String name) { | ||
| 123 | + if (name.startsWith(getPrefix())) { | ||
| 124 | + name = name.substring(getPrefix().length()); | ||
| 125 | + } | ||
| 126 | + return name; | ||
| 127 | + } | ||
| 128 | +} |
yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/framework/ureport/provider/UreportFileReportProvider.java
0 → 100644
| 1 | +/* | ||
| 2 | +package cn.iocoder.yudao.module.report.framework.ureport.provider; | ||
| 3 | + | ||
| 4 | +import com.bstek.ureport.exception.ReportException; | ||
| 5 | +import com.bstek.ureport.provider.report.ReportFile; | ||
| 6 | +import com.bstek.ureport.provider.report.ReportProvider; | ||
| 7 | +import lombok.extern.slf4j.Slf4j; | ||
| 8 | +import org.apache.commons.io.IOUtils; | ||
| 9 | +import org.springframework.boot.context.properties.ConfigurationProperties; | ||
| 10 | +import org.springframework.stereotype.Component; | ||
| 11 | + | ||
| 12 | +import java.io.*; | ||
| 13 | +import java.util.ArrayList; | ||
| 14 | +import java.util.Calendar; | ||
| 15 | +import java.util.List; | ||
| 16 | +import java.util.Objects; | ||
| 17 | + | ||
| 18 | +*/ | ||
| 19 | +/** | ||
| 20 | + * 自定义文件存储,可接入oss等 | ||
| 21 | + * @author 赤焰 | ||
| 22 | + *//* | ||
| 23 | + | ||
| 24 | +@Slf4j | ||
| 25 | +@Component | ||
| 26 | +@ConfigurationProperties(prefix = "ureport.provider.file") | ||
| 27 | +public class UreportFileReportProvider implements ReportProvider{ | ||
| 28 | + | ||
| 29 | + private String prefix="reportFile:"; | ||
| 30 | + private String fileStoreDir; | ||
| 31 | + private boolean disabled; | ||
| 32 | + | ||
| 33 | + @Override | ||
| 34 | + public InputStream loadReport(String file) { | ||
| 35 | + if(file.startsWith(prefix)){ | ||
| 36 | + file=file.substring(prefix.length(),file.length()); | ||
| 37 | + } | ||
| 38 | + String fullPath=fileStoreDir+"/"+file; | ||
| 39 | + try { | ||
| 40 | + return new FileInputStream(fullPath); | ||
| 41 | + } catch (FileNotFoundException e) { | ||
| 42 | + throw new ReportException(e); | ||
| 43 | + } | ||
| 44 | + } | ||
| 45 | + | ||
| 46 | + @Override | ||
| 47 | + public void deleteReport(String file) { | ||
| 48 | + if(file.startsWith(prefix)){ | ||
| 49 | + file=file.substring(prefix.length(),file.length()); | ||
| 50 | + } | ||
| 51 | + String fullPath=fileStoreDir+"/"+file; | ||
| 52 | + File f=new File(fullPath); | ||
| 53 | + if(f.exists()){ | ||
| 54 | + f.delete(); | ||
| 55 | + } | ||
| 56 | + } | ||
| 57 | + | ||
| 58 | + @Override | ||
| 59 | + public List<ReportFile> getReportFiles() { | ||
| 60 | + File file=new File(fileStoreDir); | ||
| 61 | + List<ReportFile> list= new ArrayList<>(); | ||
| 62 | + for(File f: Objects.requireNonNull(file.listFiles())){ | ||
| 63 | + Calendar calendar=Calendar.getInstance(); | ||
| 64 | + calendar.setTimeInMillis(f.lastModified()); | ||
| 65 | + list.add(new ReportFile(f.getName(),calendar.getTime())); | ||
| 66 | + } | ||
| 67 | + list.sort((f1, f2) -> f2.getUpdateDate().compareTo(f1.getUpdateDate())); | ||
| 68 | + return list; | ||
| 69 | + } | ||
| 70 | + | ||
| 71 | + @Override | ||
| 72 | + public String getName() { | ||
| 73 | + return "文件存储系统"; | ||
| 74 | + } | ||
| 75 | + | ||
| 76 | + @Override | ||
| 77 | + public void saveReport(String file,String content) { | ||
| 78 | + if(file.startsWith(prefix)){ | ||
| 79 | + file=file.substring(prefix.length(),file.length()); | ||
| 80 | + } | ||
| 81 | + String fullPath=fileStoreDir+"/"+file; | ||
| 82 | + FileOutputStream outStream=null; | ||
| 83 | + try{ | ||
| 84 | + outStream=new FileOutputStream(new File(fullPath)); | ||
| 85 | + IOUtils.write(content, outStream,"utf-8"); | ||
| 86 | + }catch(Exception ex){ | ||
| 87 | + throw new ReportException(ex); | ||
| 88 | + }finally{ | ||
| 89 | + if(outStream!=null){ | ||
| 90 | + try { | ||
| 91 | + outStream.close(); | ||
| 92 | + } catch (IOException e) { | ||
| 93 | + e.printStackTrace(); | ||
| 94 | + } | ||
| 95 | + } | ||
| 96 | + } | ||
| 97 | + | ||
| 98 | + } | ||
| 99 | + | ||
| 100 | + @Override | ||
| 101 | + public boolean disabled() { | ||
| 102 | + return disabled; | ||
| 103 | + } | ||
| 104 | + | ||
| 105 | + public void setDisabled(boolean disabled) { | ||
| 106 | + this.disabled = disabled; | ||
| 107 | + } | ||
| 108 | + | ||
| 109 | + public void setFileStoreDir(String fileStoreDir) { | ||
| 110 | + this.fileStoreDir = fileStoreDir; | ||
| 111 | + } | ||
| 112 | + | ||
| 113 | + @Override | ||
| 114 | + public String getPrefix() { | ||
| 115 | + return prefix; | ||
| 116 | + } | ||
| 117 | + | ||
| 118 | +} | ||
| 119 | +*/ |
yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/service/ureport/UreportFileService.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.report.service.ureport; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 4 | +import cn.iocoder.yudao.module.report.controller.admin.ureport.vo.UreportFilePageReqVO; | ||
| 5 | +import cn.iocoder.yudao.module.report.controller.admin.ureport.vo.UreportFileSaveReqVO; | ||
| 6 | +import cn.iocoder.yudao.module.report.dal.dataobject.ureport.UreportFileDO; | ||
| 7 | + | ||
| 8 | +import javax.validation.Valid; | ||
| 9 | +import java.util.List; | ||
| 10 | + | ||
| 11 | +/** | ||
| 12 | + * Ureport2报表 Service 接口 | ||
| 13 | + * | ||
| 14 | + * @author 芋道源码 | ||
| 15 | + */ | ||
| 16 | +public interface UreportFileService { | ||
| 17 | + | ||
| 18 | + /** | ||
| 19 | + * 创建Ureport2报表 | ||
| 20 | + * | ||
| 21 | + * @param createReqVO 创建信息 | ||
| 22 | + * @return 编号 | ||
| 23 | + */ | ||
| 24 | + Long createUreportFile(@Valid UreportFileSaveReqVO createReqVO); | ||
| 25 | + | ||
| 26 | + /** | ||
| 27 | + * 更新Ureport2报表 | ||
| 28 | + * | ||
| 29 | + * @param updateReqVO 更新信息 | ||
| 30 | + */ | ||
| 31 | + void updateUreportFile(@Valid UreportFileSaveReqVO updateReqVO); | ||
| 32 | + | ||
| 33 | + /** | ||
| 34 | + * 删除Ureport2报表 | ||
| 35 | + * | ||
| 36 | + * @param id 编号 | ||
| 37 | + */ | ||
| 38 | + void deleteUreportFile(Long id); | ||
| 39 | + | ||
| 40 | + /** | ||
| 41 | + * 获得Ureport2报表 | ||
| 42 | + * | ||
| 43 | + * @param id 编号 | ||
| 44 | + * @return Ureport2报表 | ||
| 45 | + */ | ||
| 46 | + UreportFileDO getUreportFile(Long id); | ||
| 47 | + | ||
| 48 | + /** | ||
| 49 | + * 获得Ureport2报表分页 | ||
| 50 | + * | ||
| 51 | + * @param pageReqVO 分页查询 | ||
| 52 | + * @return Ureport2报表分页 | ||
| 53 | + */ | ||
| 54 | + PageResult<UreportFileDO> getUreportFilePage(UreportFilePageReqVO pageReqVO); | ||
| 55 | + | ||
| 56 | + | ||
| 57 | + /** | ||
| 58 | + * 根据报表名称检查报表是否存在 | ||
| 59 | + * @param name 报表名称 | ||
| 60 | + * @return | ||
| 61 | + */ | ||
| 62 | + Long checkExistByName(String name); | ||
| 63 | + | ||
| 64 | + /** | ||
| 65 | + * 根据报表名称查询报表 | ||
| 66 | + * @param name 报表名称 | ||
| 67 | + * @return | ||
| 68 | + */ | ||
| 69 | + UreportFileDO queryUreportFileDoByName(String name); | ||
| 70 | + | ||
| 71 | + | ||
| 72 | + /** | ||
| 73 | + * 查询全部报表 | ||
| 74 | + * @return | ||
| 75 | + */ | ||
| 76 | + List<UreportFileDO> queryReportFileList(); | ||
| 77 | + | ||
| 78 | + | ||
| 79 | + /** | ||
| 80 | + * 根据报表名称删除报表 | ||
| 81 | + * @param name | ||
| 82 | + * @return | ||
| 83 | + */ | ||
| 84 | + int deleteReportFileByName(String name); | ||
| 85 | + | ||
| 86 | +} |
yudao-module-report/yudao-module-report-biz/src/main/java/cn/iocoder/yudao/module/report/service/ureport/UreportFileServiceImpl.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.report.service.ureport; | ||
| 2 | + | ||
| 3 | +import cn.hutool.core.collection.CollectionUtil; | ||
| 4 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 5 | +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | ||
| 6 | +import cn.iocoder.yudao.module.report.controller.admin.ureport.vo.UreportFilePageReqVO; | ||
| 7 | +import cn.iocoder.yudao.module.report.controller.admin.ureport.vo.UreportFileSaveReqVO; | ||
| 8 | +import cn.iocoder.yudao.module.report.dal.dataobject.ureport.UreportFileDO; | ||
| 9 | +import cn.iocoder.yudao.module.report.dal.mysql.ureport.UreportFileMapper; | ||
| 10 | +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | ||
| 11 | +import org.springframework.stereotype.Service; | ||
| 12 | +import org.springframework.validation.annotation.Validated; | ||
| 13 | + | ||
| 14 | +import javax.annotation.Resource; | ||
| 15 | +import java.util.List; | ||
| 16 | + | ||
| 17 | +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | ||
| 18 | +import static cn.iocoder.yudao.module.report.enums.ErrorCodeConstants.UREPORT_FILE_NOT_EXISTS; | ||
| 19 | + | ||
| 20 | +/** | ||
| 21 | + * Ureport2报表 Service 实现类 | ||
| 22 | + * | ||
| 23 | + * @author 芋道源码 | ||
| 24 | + */ | ||
| 25 | +@Service | ||
| 26 | +@Validated | ||
| 27 | +public class UreportFileServiceImpl implements UreportFileService { | ||
| 28 | + | ||
| 29 | + @Resource | ||
| 30 | + private UreportFileMapper ureportFileMapper; | ||
| 31 | + | ||
| 32 | + @Override | ||
| 33 | + public Long createUreportFile(UreportFileSaveReqVO createReqVO) { | ||
| 34 | + // 插入 | ||
| 35 | + UreportFileDO ureportFile = BeanUtils.toBean(createReqVO, UreportFileDO.class); | ||
| 36 | + ureportFileMapper.insert(ureportFile); | ||
| 37 | + // 返回 | ||
| 38 | + return ureportFile.getId(); | ||
| 39 | + } | ||
| 40 | + | ||
| 41 | + @Override | ||
| 42 | + public void updateUreportFile(UreportFileSaveReqVO updateReqVO) { | ||
| 43 | + // 校验存在 | ||
| 44 | + validateUreportFileExists(updateReqVO.getId()); | ||
| 45 | + // 更新 | ||
| 46 | + UreportFileDO updateObj = BeanUtils.toBean(updateReqVO, UreportFileDO.class); | ||
| 47 | + ureportFileMapper.updateById(updateObj); | ||
| 48 | + } | ||
| 49 | + | ||
| 50 | + @Override | ||
| 51 | + public void deleteUreportFile(Long id) { | ||
| 52 | + // 校验存在 | ||
| 53 | + validateUreportFileExists(id); | ||
| 54 | + // 删除 | ||
| 55 | + ureportFileMapper.deleteById(id); | ||
| 56 | + } | ||
| 57 | + | ||
| 58 | + private void validateUreportFileExists(Long id) { | ||
| 59 | + if (ureportFileMapper.selectById(id) == null) { | ||
| 60 | + throw exception(UREPORT_FILE_NOT_EXISTS); | ||
| 61 | + } | ||
| 62 | + } | ||
| 63 | + | ||
| 64 | + @Override | ||
| 65 | + public UreportFileDO getUreportFile(Long id) { | ||
| 66 | + return ureportFileMapper.selectById(id); | ||
| 67 | + } | ||
| 68 | + | ||
| 69 | + @Override | ||
| 70 | + public PageResult<UreportFileDO> getUreportFilePage(UreportFilePageReqVO pageReqVO) { | ||
| 71 | + return ureportFileMapper.selectPage(pageReqVO); | ||
| 72 | + } | ||
| 73 | + | ||
| 74 | + @Override | ||
| 75 | + public Long checkExistByName(String name) { | ||
| 76 | + LambdaQueryWrapper<UreportFileDO> queryWrapper = new LambdaQueryWrapper<>(); | ||
| 77 | + queryWrapper.eq(UreportFileDO::getFileName,name); | ||
| 78 | + return ureportFileMapper.selectCount(queryWrapper); | ||
| 79 | + } | ||
| 80 | + | ||
| 81 | + @Override | ||
| 82 | + public UreportFileDO queryUreportFileDoByName(String name) { | ||
| 83 | + LambdaQueryWrapper<UreportFileDO> queryWrapper = new LambdaQueryWrapper<>(); | ||
| 84 | + queryWrapper.eq(UreportFileDO::getFileName,name); | ||
| 85 | + List<UreportFileDO> list = ureportFileMapper.selectList(queryWrapper); | ||
| 86 | + if(CollectionUtil.isNotEmpty(list)){ | ||
| 87 | + return list.get(0); | ||
| 88 | + } | ||
| 89 | + return null; | ||
| 90 | + } | ||
| 91 | + | ||
| 92 | + @Override | ||
| 93 | + public List<UreportFileDO> queryReportFileList() { | ||
| 94 | + LambdaQueryWrapper<UreportFileDO> queryWrapper = new LambdaQueryWrapper<>(); | ||
| 95 | + return ureportFileMapper.selectList(queryWrapper); | ||
| 96 | + } | ||
| 97 | + | ||
| 98 | + @Override | ||
| 99 | + public int deleteReportFileByName(String name) { | ||
| 100 | + LambdaQueryWrapper<UreportFileDO> queryWrapper = new LambdaQueryWrapper<>(); | ||
| 101 | + queryWrapper.eq(UreportFileDO::getFileName,name); | ||
| 102 | + return ureportFileMapper.delete(queryWrapper); | ||
| 103 | + } | ||
| 104 | +} |
yudao-module-report/yudao-module-report-biz/src/main/resources/mapper/ureport/UreportFileMapper.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="UTF-8"?> | ||
| 2 | +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | ||
| 3 | +<mapper namespace="cn.iocoder.yudao.module.report.dal.mysql.ureport.UreportFileMapper"> | ||
| 4 | + | ||
| 5 | + <!-- | ||
| 6 | + 一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。 | ||
| 7 | + 无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。 | ||
| 8 | + 代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。 | ||
| 9 | + 文档可见:https://www.iocoder.cn/MyBatis/x-plugins/ | ||
| 10 | + --> | ||
| 11 | + | ||
| 12 | +</mapper> | ||
| 0 | \ No newline at end of file | 13 | \ No newline at end of file |
yudao-module-report/yudao-module-report-biz/src/main/resources/ureport.properties
0 → 100644
yudao-module-report/yudao-module-report-biz/src/test/java/cn/iocoder/yudao/module/report/service/ureport/UreportFileServiceImplTest.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.report.service.ureport; | ||
| 2 | + | ||
| 3 | +import org.junit.jupiter.api.Disabled; | ||
| 4 | +import org.junit.jupiter.api.Test; | ||
| 5 | +import org.springframework.boot.test.mock.mockito.MockBean; | ||
| 6 | + | ||
| 7 | +import javax.annotation.Resource; | ||
| 8 | + | ||
| 9 | +import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; | ||
| 10 | + | ||
| 11 | +import cn.iocoder.yudao.module.report.controller.admin.ureport.vo.*; | ||
| 12 | +import cn.iocoder.yudao.module.report.dal.dataobject.ureport.UreportFileDO; | ||
| 13 | +import cn.iocoder.yudao.module.report.dal.mysql.ureport.UreportFileMapper; | ||
| 14 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 15 | + | ||
| 16 | +import javax.annotation.Resource; | ||
| 17 | +import org.springframework.context.annotation.Import; | ||
| 18 | +import java.util.*; | ||
| 19 | +import java.time.LocalDateTime; | ||
| 20 | + | ||
| 21 | +import static cn.hutool.core.util.RandomUtil.*; | ||
| 22 | +import static cn.iocoder.yudao.module.report.enums.ErrorCodeConstants.*; | ||
| 23 | +import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.*; | ||
| 24 | +import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; | ||
| 25 | +import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.*; | ||
| 26 | +import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.*; | ||
| 27 | +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.*; | ||
| 28 | +import static org.junit.jupiter.api.Assertions.*; | ||
| 29 | +import static org.mockito.Mockito.*; | ||
| 30 | + | ||
| 31 | +/** | ||
| 32 | + * {@link UreportFileServiceImpl} 的单元测试类 | ||
| 33 | + * | ||
| 34 | + * @author 芋道源码 | ||
| 35 | + */ | ||
| 36 | +@Import(UreportFileServiceImpl.class) | ||
| 37 | +public class UreportFileServiceImplTest extends BaseDbUnitTest { | ||
| 38 | + | ||
| 39 | + @Resource | ||
| 40 | + private UreportFileServiceImpl ureportFileService; | ||
| 41 | + | ||
| 42 | + @Resource | ||
| 43 | + private UreportFileMapper ureportFileMapper; | ||
| 44 | + | ||
| 45 | + @Test | ||
| 46 | + public void testCreateUreportFile_success() { | ||
| 47 | + // 准备参数 | ||
| 48 | + UreportFileSaveReqVO createReqVO = randomPojo(UreportFileSaveReqVO.class).setId(null); | ||
| 49 | + | ||
| 50 | + // 调用 | ||
| 51 | + Long ureportFileId = ureportFileService.createUreportFile(createReqVO); | ||
| 52 | + // 断言 | ||
| 53 | + assertNotNull(ureportFileId); | ||
| 54 | + // 校验记录的属性是否正确 | ||
| 55 | + UreportFileDO ureportFile = ureportFileMapper.selectById(ureportFileId); | ||
| 56 | + assertPojoEquals(createReqVO, ureportFile, "id"); | ||
| 57 | + } | ||
| 58 | + | ||
| 59 | + @Test | ||
| 60 | + public void testUpdateUreportFile_success() { | ||
| 61 | + // mock 数据 | ||
| 62 | + UreportFileDO dbUreportFile = randomPojo(UreportFileDO.class); | ||
| 63 | + ureportFileMapper.insert(dbUreportFile);// @Sql: 先插入出一条存在的数据 | ||
| 64 | + // 准备参数 | ||
| 65 | + UreportFileSaveReqVO updateReqVO = randomPojo(UreportFileSaveReqVO.class, o -> { | ||
| 66 | + o.setId(dbUreportFile.getId()); // 设置更新的 ID | ||
| 67 | + }); | ||
| 68 | + | ||
| 69 | + // 调用 | ||
| 70 | + ureportFileService.updateUreportFile(updateReqVO); | ||
| 71 | + // 校验是否更新正确 | ||
| 72 | + UreportFileDO ureportFile = ureportFileMapper.selectById(updateReqVO.getId()); // 获取最新的 | ||
| 73 | + assertPojoEquals(updateReqVO, ureportFile); | ||
| 74 | + } | ||
| 75 | + | ||
| 76 | + @Test | ||
| 77 | + public void testUpdateUreportFile_notExists() { | ||
| 78 | + // 准备参数 | ||
| 79 | + UreportFileSaveReqVO updateReqVO = randomPojo(UreportFileSaveReqVO.class); | ||
| 80 | + | ||
| 81 | + // 调用, 并断言异常 | ||
| 82 | + assertServiceException(() -> ureportFileService.updateUreportFile(updateReqVO), UREPORT_FILE_NOT_EXISTS); | ||
| 83 | + } | ||
| 84 | + | ||
| 85 | + @Test | ||
| 86 | + public void testDeleteUreportFile_success() { | ||
| 87 | + // mock 数据 | ||
| 88 | + UreportFileDO dbUreportFile = randomPojo(UreportFileDO.class); | ||
| 89 | + ureportFileMapper.insert(dbUreportFile);// @Sql: 先插入出一条存在的数据 | ||
| 90 | + // 准备参数 | ||
| 91 | + Long id = dbUreportFile.getId(); | ||
| 92 | + | ||
| 93 | + // 调用 | ||
| 94 | + ureportFileService.deleteUreportFile(id); | ||
| 95 | + // 校验数据不存在了 | ||
| 96 | + assertNull(ureportFileMapper.selectById(id)); | ||
| 97 | + } | ||
| 98 | + | ||
| 99 | + @Test | ||
| 100 | + public void testDeleteUreportFile_notExists() { | ||
| 101 | + // 准备参数 | ||
| 102 | + Long id = randomLongId(); | ||
| 103 | + | ||
| 104 | + // 调用, 并断言异常 | ||
| 105 | + assertServiceException(() -> ureportFileService.deleteUreportFile(id), UREPORT_FILE_NOT_EXISTS); | ||
| 106 | + } | ||
| 107 | + | ||
| 108 | + @Test | ||
| 109 | + @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 | ||
| 110 | + public void testGetUreportFilePage() { | ||
| 111 | + // mock 数据 | ||
| 112 | + UreportFileDO dbUreportFile = randomPojo(UreportFileDO.class, o -> { // 等会查询到 | ||
| 113 | + o.setFileName(null); | ||
| 114 | + o.setStatus(null); | ||
| 115 | + o.setRemark(null); | ||
| 116 | + o.setCreateTime(null); | ||
| 117 | + }); | ||
| 118 | + ureportFileMapper.insert(dbUreportFile); | ||
| 119 | + // 测试 fileName 不匹配 | ||
| 120 | + ureportFileMapper.insert(cloneIgnoreId(dbUreportFile, o -> o.setFileName(null))); | ||
| 121 | + // 测试 status 不匹配 | ||
| 122 | + ureportFileMapper.insert(cloneIgnoreId(dbUreportFile, o -> o.setStatus(null))); | ||
| 123 | + // 测试 remark 不匹配 | ||
| 124 | + ureportFileMapper.insert(cloneIgnoreId(dbUreportFile, o -> o.setRemark(null))); | ||
| 125 | + // 测试 createTime 不匹配 | ||
| 126 | + ureportFileMapper.insert(cloneIgnoreId(dbUreportFile, o -> o.setCreateTime(null))); | ||
| 127 | + // 准备参数 | ||
| 128 | + UreportFilePageReqVO reqVO = new UreportFilePageReqVO(); | ||
| 129 | + reqVO.setFileName(null); | ||
| 130 | + reqVO.setStatus(null); | ||
| 131 | + reqVO.setRemark(null); | ||
| 132 | + reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); | ||
| 133 | + | ||
| 134 | + // 调用 | ||
| 135 | + PageResult<UreportFileDO> pageResult = ureportFileService.getUreportFilePage(reqVO); | ||
| 136 | + // 断言 | ||
| 137 | + assertEquals(1, pageResult.getTotal()); | ||
| 138 | + assertEquals(1, pageResult.getList().size()); | ||
| 139 | + assertPojoEquals(dbUreportFile, pageResult.getList().get(0)); | ||
| 140 | + } | ||
| 141 | + | ||
| 142 | +} | ||
| 0 | \ No newline at end of file | 143 | \ No newline at end of file |
yudao-module-report/yudao-module-report-biz/src/test/resources/sql/clean.sql
yudao-module-report/yudao-module-report-biz/src/test/resources/sql/create_tables.sql
| @@ -12,3 +12,16 @@ CREATE TABLE IF NOT EXISTS "report_go_view_project" ( | @@ -12,3 +12,16 @@ CREATE TABLE IF NOT EXISTS "report_go_view_project" ( | ||
| 12 | "deleted" bit NOT NULL DEFAULT FALSE, | 12 | "deleted" bit NOT NULL DEFAULT FALSE, |
| 13 | PRIMARY KEY ("id") | 13 | PRIMARY KEY ("id") |
| 14 | ) COMMENT 'GoView 项目表'; | 14 | ) COMMENT 'GoView 项目表'; |
| 15 | +CREATE TABLE IF NOT EXISTS "ureport_file" ( | ||
| 16 | + "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, | ||
| 17 | + "file_name" varchar NOT NULL, | ||
| 18 | + "status" int NOT NULL, | ||
| 19 | + "file_content" varchar, | ||
| 20 | + "remark" varchar, | ||
| 21 | + "creator" varchar DEFAULT '', | ||
| 22 | + "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
| 23 | + "updater" varchar DEFAULT '', | ||
| 24 | + "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, | ||
| 25 | + "deleted" bit NOT NULL DEFAULT FALSE, | ||
| 26 | + PRIMARY KEY ("id") | ||
| 27 | +) COMMENT 'Ureport2报表'; |
yudao-server/src/main/resources/application-local.yaml
| @@ -264,3 +264,16 @@ justauth: | @@ -264,3 +264,16 @@ justauth: | ||
| 264 | prefix: 'social_auth_state:' # 缓存前缀,目前只对 Redis 缓存生效,默认 JUSTAUTH::STATE:: | 264 | prefix: 'social_auth_state:' # 缓存前缀,目前只对 Redis 缓存生效,默认 JUSTAUTH::STATE:: |
| 265 | timeout: 24h # 超时时长,目前只对 Redis 缓存生效,默认 3 分钟 | 265 | timeout: 24h # 超时时长,目前只对 Redis 缓存生效,默认 3 分钟 |
| 266 | 266 | ||
| 267 | +#ureport配置 | ||
| 268 | +#ureport: | ||
| 269 | +# disableHttpSessionReportCache: true #是否禁用 | ||
| 270 | +# disableFileProvider: true #是否禁用 | ||
| 271 | +# debug: true | ||
| 272 | +# fileStoreDir: D://ureport//files | ||
| 273 | +# provider: | ||
| 274 | +# database: | ||
| 275 | +# disabled: true | ||
| 276 | +# file: | ||
| 277 | +# disabled: true | ||
| 278 | + | ||
| 279 | + |
yudao-server/src/main/resources/application.yaml
| @@ -182,6 +182,7 @@ yudao: | @@ -182,6 +182,7 @@ yudao: | ||
| 182 | - /admin-api/system/sms/callback/* # 短信回调接口,无法带上租户编号 | 182 | - /admin-api/system/sms/callback/* # 短信回调接口,无法带上租户编号 |
| 183 | - /admin-api/pay/notify/** # 支付回调通知,不携带租户编号 | 183 | - /admin-api/pay/notify/** # 支付回调通知,不携带租户编号 |
| 184 | - /jmreport/* # 积木报表,无法携带租户编号 | 184 | - /jmreport/* # 积木报表,无法携带租户编号 |
| 185 | + - /ureport/* # ureport报表,无法携带租户编号 | ||
| 185 | - /admin-api/mp/open/** # 微信公众号开放平台,微信回调接口,无法携带租户编号 | 186 | - /admin-api/mp/open/** # 微信公众号开放平台,微信回调接口,无法携带租户编号 |
| 186 | ignore-tables: | 187 | ignore-tables: |
| 187 | - system_tenant | 188 | - system_tenant |
| @@ -220,6 +221,7 @@ yudao: | @@ -220,6 +221,7 @@ yudao: | ||
| 220 | - jimu_report_link | 221 | - jimu_report_link |
| 221 | - jimu_report_map | 222 | - jimu_report_map |
| 222 | - jimu_report_share | 223 | - jimu_report_share |
| 224 | + - ureport_file | ||
| 223 | - rep_demo_dxtj | 225 | - rep_demo_dxtj |
| 224 | - rep_demo_employee | 226 | - rep_demo_employee |
| 225 | - rep_demo_gongsi | 227 | - rep_demo_gongsi |
| @@ -253,3 +255,8 @@ debug: false | @@ -253,3 +255,8 @@ debug: false | ||
| 253 | minidao : | 255 | minidao : |
| 254 | base-package: org.jeecg.modules.jmreport.desreport.dao* | 256 | base-package: org.jeecg.modules.jmreport.desreport.dao* |
| 255 | db-type: mysql | 257 | db-type: mysql |
| 258 | +#ureport配置 | ||
| 259 | +ureport: | ||
| 260 | + provider: | ||
| 261 | + database: | ||
| 262 | + disabled: false |