Compare commits

...

194 Commits

Author SHA1 Message Date
chenxudong 3639983d59 更改已知问题。 2025-02-20 15:17:34 +08:00
s2042968 1f1266bbee 优化:增加文件后缀名显示 2025-02-19 17:57:28 +08:00
s2042968 086ec057a0 修复:重名文件建立关系 2025-02-19 17:50:08 +08:00
s2042968 3755ce201a 修复2:检验文件名唯一性接口 2025-02-19 17:28:06 +08:00
s2042968 7a55a351cb Merge branch 'test' of http://139.196.179.195:3000/chenxudong/electromagnetic-data-new into test 2025-02-19 17:21:57 +08:00
s2042968 4a80dc3753 修复:检验文件名唯一性接口 2025-02-19 17:21:47 +08:00
chenxudong 1d323e9081 优化代码 2025-02-19 17:18:11 +08:00
chenxudong e34cf51900 层级沿用的问题 2025-02-19 16:51:01 +08:00
chenxudong 634dd42778 解决层级沿用的bug 2025-02-19 16:20:08 +08:00
s2042968 de63dfe9d6 Merge branch 'test' of http://139.196.179.195:3000/chenxudong/electromagnetic-data-new into test 2025-02-19 10:52:48 +08:00
s2042968 c014db1dcf 增加复制/移动时,对于目标文件夹的权限校验 2025-02-19 10:52:36 +08:00
chenxudong d0551b3094 解决层级沿用相关的问题 2025-02-18 17:35:55 +08:00
s2042968 6ec4c66dd2 在token生成时添加唯一标识符jti 2025-02-18 15:18:31 +08:00
s2042968 61e2254a93 加上空集合判断 2025-02-18 14:37:43 +08:00
s2042968 b4f4e1b193 修复筛选语句歧义 2025-02-18 14:21:48 +08:00
s2042968 957769f2d1 层级变动权限问题:层级发布后变动“再发布”时,权限同步 2025-02-18 14:09:35 +08:00
s2042968 c0995be7e7 层级变动权限问题:层级删除但未发布时,权限应仍可以看到 2025-02-18 14:08:47 +08:00
chenxudong cb42bae830 修改已知问题 2025-02-14 16:45:09 +08:00
s2042968 dac0f34565 文件关系模型,增加文件有效标志 2025-02-14 12:04:30 +08:00
s2042968 c72e25f4b0 撤销:逻辑删除文件时,同时删除文件关系 2025-02-14 11:20:18 +08:00
s2042968 f1671264d1 修改:逻辑删除文件时,同时删除文件关系 2025-02-14 10:15:25 +08:00
s2042968 4faab3d89b 逻辑删除文件时,同时删除文件关系 2025-02-14 09:40:35 +08:00
chenxudong 731b920547 修改已知问题 2025-02-13 09:36:11 +08:00
chenxudong 9a626f88cf 修改已知问题 2025-02-10 15:39:36 +08:00
chenxudong d643902747 增强删除相关的逻辑 2025-02-10 14:16:10 +08:00
chenxudong b6597fea45 修改大文件上传的bug 2025-02-10 11:31:55 +08:00
chenxudong a2ffc084d8 Merge branch 'test' of http://139.196.179.195:3000/chenxudong/electromagnetic-data-new into test 2025-02-10 10:34:04 +08:00
chenxudong aeb39d1479 修改bug 2025-02-10 10:33:38 +08:00
s2042968 f217fbb6fb 测试链接 2025-02-08 15:53:02 +08:00
s2042968 f889a6a073 加入是否为层级判断,增加查看权限 2025-02-05 16:41:02 +08:00
chenxudong b58e3bd04a 取消了VIEW的权限 2025-02-05 15:21:53 +08:00
chenxudong 3a090c224f 优化权限相关问题 2025-01-14 15:06:55 +08:00
chenxudong 5dfd2c6800 解决发现的问题 2025-01-14 14:56:21 +08:00
chenxudong da77309df6 clean code 2025-01-14 14:45:58 +08:00
chenxudong c2380336d4 增加权限校验 2025-01-14 14:34:00 +08:00
chenxudong d989e8847f 优化BizException 2025-01-14 14:25:08 +08:00
chenxudong 70a05e23c3 升级日志 2025-01-14 13:48:13 +08:00
chenxudong 73a7d95129 权限优化 2025-01-14 11:34:47 +08:00
s2042968 605ce4ea82 Merge branch 'develop' of http://139.196.179.195:3000/chenxudong/electromagnetic-data-new into develop 2025-01-14 11:15:14 +08:00
s2042968 e0f30ee174 加入查看权限,后端校验逻辑 2025-01-14 11:15:02 +08:00
chenxudong b9f90aa33a 增强权限校验 2025-01-14 10:30:33 +08:00
chenxudong d23916ec6a 新增权限校验 2025-01-14 10:25:24 +08:00
chenxudong ea7732f1b5 文件属性增加了创建者 2025-01-14 09:08:51 +08:00
chenxudong 8c16882780 解决发布问题 2025-01-13 17:36:21 +08:00
chenxudong e7193d3626 解决已知问题 2025-01-13 17:03:51 +08:00
chenxudong 0c8835f2fa 修改上传文件大小为0的bug 2025-01-13 14:42:46 +08:00
chenxudong ec75439749 Merge branch 'develop' of http://139.196.179.195:3000/chenxudong/electromagnetic-data-new into develop 2025-01-13 14:18:41 +08:00
chenxudong d41f0d191a 新增根据id查询其下自定义文件夹的接口 2025-01-13 14:18:31 +08:00
s2042968 a417ec415a Merge branch 'develop' of http://139.196.179.195:3000/chenxudong/electromagnetic-data-new into develop 2025-01-13 14:16:51 +08:00
s2042968 025c66415f 导出权限校验修改 2025-01-13 14:16:40 +08:00
chenxudong 0df3284e21 修改已知问题 2025-01-13 14:09:49 +08:00
chenxudong 840752485b 修改发现的问题 2025-01-13 10:25:22 +08:00
chenxudong 1bdbd42926 clean code 2025-01-10 17:52:54 +08:00
chenxudong 15b45a270d clean code 2025-01-10 17:51:20 +08:00
chenxudong 066ee17887 优化代码 2025-01-10 17:37:58 +08:00
chenxudong 21ceaf4d81 增加用户查询树的校验。 2025-01-10 17:14:20 +08:00
chenxudong a44cac589f Merge branch 'develop' of http://139.196.179.195:3000/chenxudong/electromagnetic-data-new into develop 2025-01-10 15:37:29 +08:00
chenxudong 0e21111c79 优化代码 2025-01-10 15:37:21 +08:00
s2042968 095d742043 后端权限增加校验 2025-01-10 15:30:07 +08:00
chenxudong 7509811d5b Merge branch 'develop' of http://139.196.179.195:3000/chenxudong/electromagnetic-data-new into develop 2025-01-10 10:28:29 +08:00
chenxudong 12b32ae33b 密码设置 2025-01-10 10:28:19 +08:00
chenxudong e4024a2dae 增加导出功能的权限校验。 2025-01-10 10:24:47 +08:00
s2042968 31404333e6 注释修改 2025-01-10 09:53:40 +08:00
s2042968 8dc4c731d0 Merge branch 'develop' of http://139.196.179.195:3000/chenxudong/electromagnetic-data-new into develop 2025-01-10 09:44:50 +08:00
s2042968 eb17cb7b47 后台限制权限新增更改 2025-01-10 09:44:40 +08:00
chenxudong e0d3fc23ed clean code 2025-01-09 16:12:59 +08:00
chenxudong 85cafb7257 对上传文件进行加密处理 2025-01-09 15:34:28 +08:00
chenxudong 02ac23df57 clean code 2025-01-09 14:46:02 +08:00
s2042968 bb2df18f6d 重写获取管理员身份接口 2025-01-09 13:45:10 +08:00
chenxudong b15d2dec57 优化提示 2025-01-09 10:09:29 +08:00
s2042968 54c42132a7 Merge branch 'develop' of http://139.196.179.195:3000/chenxudong/electromagnetic-data-new into develop 2025-01-08 16:43:06 +08:00
s2042968 536c538400 更改目录树筛选 2025-01-08 16:43:00 +08:00
chenxudong 024c5bb9b8 解决文件搜索的问题 2025-01-08 16:20:57 +08:00
chenxudong cbf001cfa5 修复已知问题 2025-01-08 16:03:44 +08:00
s2042968 e2e9349dfa 建立关系bug修改 2025-01-08 15:49:01 +08:00
s2042968 3107173133 Merge branch 'develop' of http://139.196.179.195:3000/chenxudong/electromagnetic-data-new into develop 2025-01-08 14:49:48 +08:00
s2042968 8b38b46e1d 建立关系,校验失败,返回结果修改 2025-01-08 14:49:37 +08:00
chenxudong 46a3e90ecb clean code 2025-01-08 14:31:34 +08:00
chenxudong 8b23fb63d6 增加用户查询目录树的权限校验 2025-01-08 14:20:33 +08:00
chenxudong 8921286146 优化代码 2025-01-07 17:41:59 +08:00
s2042968 11577ecb20 Merge branch 'develop' of http://139.196.179.195:3000/chenxudong/electromagnetic-data-new into develop 2025-01-07 16:49:20 +08:00
s2042968 7f38b45246 角色已绑定后不能作废,功能修改 2025-01-07 16:49:12 +08:00
chenxudong b492520470 删除无用的代码 2025-01-07 16:18:30 +08:00
chenxudong c15261d6d6 增强校验。 2025-01-07 16:03:04 +08:00
chenxudong d738f72db7 Merge branch 'develop' of http://139.196.179.195:3000/chenxudong/electromagnetic-data-new into develop 2025-01-07 15:13:57 +08:00
chenxudong 219908b0ba 解决发现的问题 2025-01-07 15:13:49 +08:00
s2042968 8fe9b3e356 Merge branch 'develop' of http://139.196.179.195:3000/chenxudong/electromagnetic-data-new into develop 2025-01-07 14:59:01 +08:00
s2042968 ff9ad067f5 人员绑定参数修改 2025-01-07 14:58:32 +08:00
chenxudong 16f8f98b64 暂时去掉权限校验 2025-01-07 14:38:43 +08:00
chenxudong 4f826b7f84 解决已知问题 2025-01-07 13:37:09 +08:00
s2042968 35e62a2c71 增加处理空列表情况 2025-01-07 12:42:03 +08:00
chenxudong 5f52e7f020 解决已知问题 2025-01-07 12:01:11 +08:00
chenxudong ad39488e94 解决发现的问题 2025-01-07 11:17:49 +08:00
chenxudong ccb61bfa40 解决部分问题 2025-01-07 10:45:06 +08:00
s2042968 d0187511bc Merge branch 'develop' of http://139.196.179.195:3000/chenxudong/electromagnetic-data-new into develop 2025-01-07 09:38:03 +08:00
s2042968 fa44e8b7da 角色列表,功能权限,英文转换成中文 2025-01-07 09:37:51 +08:00
chenxudong 1acaec87a7 删除无用的代码 2025-01-07 09:36:29 +08:00
chenxudong 6435d002cd 解决已知问题 2025-01-07 09:34:07 +08:00
chenxudong 38f365c2f0 增加系统管理员权限校验 2025-01-07 09:28:51 +08:00
chenxudong a7ef78a56e reformate code 2025-01-07 09:12:09 +08:00
chenxudong 75443f2d78 Merge branch 'develop' of http://139.196.179.195:3000/chenxudong/electromagnetic-data-new into develop 2025-01-06 17:26:32 +08:00
chenxudong 22b4500278 增加项目发布状态查询的接口 2025-01-06 17:26:23 +08:00
s2042968 39e8afee9c Merge branch 'develop' of http://139.196.179.195:3000/chenxudong/electromagnetic-data-new into develop 2025-01-06 17:12:58 +08:00
s2042968 25d0cee750 新建角色,更新角色,前后端连调修改 2025-01-06 17:12:49 +08:00
chenxudong 7ba8c10d34 导入相关功能调通简单场景。 2025-01-06 16:35:20 +08:00
s2042968 1d76327674 角色增加空树接口,删除改为物理删除 2025-01-06 15:28:21 +08:00
chenxudong 0e7a54ba50 上传文件时增加层级结构定义的校验。 2025-01-06 14:34:06 +08:00
chenxudong 71e99ed8e5 Merge branch 'develop' of http://139.196.179.195:3000/chenxudong/electromagnetic-data-new into develop
# Conflicts:
#	electrmangnetic/src/main/java/com/electromagnetic/industry/software/manage/service/serviceimpl/EdFileInfoServiceImpl.java
解决冲突
2025-01-06 14:25:52 +08:00
chenxudong 7d0dd012ac 解决已知问题 2025-01-06 14:24:25 +08:00
s2042968 dbbc7e8699 Merge branch 'develop' of http://139.196.179.195:3000/chenxudong/electromagnetic-data-new into develop 2025-01-06 13:34:56 +08:00
s2042968 b3c6845c9d 更改:本地上传文件并建立关系 2025-01-06 13:34:46 +08:00
chenxudong f0e17b0704 增加工程排序功能 2025-01-03 17:11:32 +08:00
s2042968 ebea20981b Merge branch 'develop' of http://139.196.179.195:3000/chenxudong/electromagnetic-data-new into develop 2025-01-03 15:38:38 +08:00
s2042968 62c0545c9a 本地上传文件并建立关系 2025-01-03 15:38:25 +08:00
chenxudong 80a187ed12 调通了数据库导出接口 2025-01-03 14:40:54 +08:00
chenxudong 52a51c8e1b 查询排序 2025-01-03 14:18:40 +08:00
chenxudong cf40b68ccd Merge branch 'develop' of http://139.196.179.195:3000/chenxudong/electromagnetic-data-new into develop 2025-01-03 10:30:34 +08:00
chenxudong de4f48507c 调通文件导出接口 2025-01-03 10:30:24 +08:00
s2042968 061516f82e 文件关系网状图,增加关系id和描述 2025-01-03 10:11:05 +08:00
s2042968 7151243618 Merge branch 'develop' of http://139.196.179.195:3000/chenxudong/electromagnetic-data-new into develop 2025-01-02 17:26:28 +08:00
s2042968 965222bea2 文件关系网状图 2025-01-02 17:26:16 +08:00
chenxudong dd13bf76e3 update fix 2025-01-02 16:21:26 +08:00
chenxudong eb973e59c0 Merge branch 'develop' of http://139.196.179.195:3000/chenxudong/electromagnetic-data-new into develop 2025-01-02 14:56:18 +08:00
chenxudong f393b585cb 修改调试发现的问题 2025-01-02 14:54:54 +08:00
s2042968 8eb4d76f29 Merge branch 'develop' of http://139.196.179.195:3000/chenxudong/electromagnetic-data-new into develop 2025-01-02 14:46:32 +08:00
s2042968 6d0add8f87 增加管理员类型 2025-01-02 14:46:17 +08:00
chenxudong fe723a7061 新建文件夹增加文件夹备注 2025-01-02 09:53:43 +08:00
chenxudong 396abe435a 发布管理接口更新 2024-12-31 17:26:40 +08:00
chenxudong 916a5a1144 bug fix 2024-12-31 17:22:01 +08:00
chenxudong 4b03e36209 文件上传记录接口 2024-12-31 17:21:14 +08:00
chenxudong 2ee833f8e4 调整完用户查询树的接口 2024-12-31 16:35:46 +08:00
chenxudong 26168a0821 Merge branch 'develop' of http://139.196.179.195:3000/chenxudong/electromagnetic-data-new into develop 2024-12-31 16:03:59 +08:00
chenxudong a508d8d6f3 文件查询相关接口更新 2024-12-31 16:03:51 +08:00
s2042968 b17404393e 解决冲突 2024-12-31 14:42:38 +08:00
s2042968 b3be6c3070 查看关联关系 2024-12-31 14:41:49 +08:00
chenxudong 895bbfc600 修复发现的bug 2024-12-31 14:28:27 +08:00
chenxudong 22e92702d1 解决发现的bug 2024-12-31 11:08:25 +08:00
chenxudong 0ec69f5d8f 调通了层级沿用 2024-12-31 10:16:57 +08:00
chenxudong 5f3af77a5c Merge branch 'develop' of http://139.196.179.195:3000/chenxudong/electromagnetic-data-new into develop 2024-12-30 17:06:51 +08:00
chenxudong ffc4711472 增加文件名校验 2024-12-30 17:06:41 +08:00
s2042968 62e952010e Merge branch 'develop' of http://139.196.179.195:3000/chenxudong/electromagnetic-data-new into develop 2024-12-30 16:35:25 +08:00
s2042968 726f430cca 创建、取消关联关系 2024-12-30 16:35:14 +08:00
chenxudong 26e0038a0c 新增层级定义后的中间状态 2024-12-30 14:43:26 +08:00
chenxudong c126bb3c17 filse size reset 2024-12-30 11:04:05 +08:00
chenxudong b02ae363ab 优化部分接口。 2024-12-30 10:28:48 +08:00
chenxudong 5bcc20782e Merge branch 'develop' of http://139.196.179.195:3000/chenxudong/electromagnetic-data-new into develop 2024-12-30 09:47:30 +08:00
chenxudong a9def54df6 调通了部分接口 2024-12-30 09:47:22 +08:00
s2042968 7553097d1d Merge branch 'develop' of http://139.196.179.195:3000/chenxudong/electromagnetic-data-new into develop 2024-12-27 13:31:23 +08:00
s2042968 8160f909be 增加判断密码是否为默认的标志位 2024-12-27 11:14:10 +08:00
chenxudong 387af49985 增加同名校验 2024-12-27 10:45:32 +08:00
chenxudong 952efbd78d Merge branch 'develop' of http://139.196.179.195:3000/chenxudong/electromagnetic-data-new into develop 2024-12-27 10:29:01 +08:00
chenxudong e2ca481ee5 整理代码和调通了文件更新 2024-12-27 10:27:21 +08:00
s2042968 4bf52c4404 Merge branch 'develop' of http://139.196.179.195:3000/chenxudong/electromagnetic-data-new into develop 2024-12-27 10:26:57 +08:00
s2042968 205fb40864 获取所有角色名返回结果更改 2024-12-27 10:26:31 +08:00
chenxudong 07e9ae9d23 调通了文件复制和移动 2024-12-27 09:57:10 +08:00
chenxudong 28b6c4f772 调通了文件移动 2024-12-27 09:02:39 +08:00
chenxudong d7a818bb3a 修改bug 2024-12-26 17:58:42 +08:00
chenxudong bec5a8d4e0 Merge branch 'develop' of http://139.196.179.195:3000/chenxudong/electromagnetic-data-new into develop 2024-12-26 17:37:07 +08:00
chenxudong 27d1bf7170 修改了部分代码。 2024-12-26 17:36:59 +08:00
s2042968 35a3ee5b77 更换接口名称 2024-12-26 17:00:15 +08:00
s2042968 14b8f9e566 Merge branch 'develop' of http://139.196.179.195:3000/chenxudong/electromagnetic-data-new into develop 2024-12-26 15:19:13 +08:00
s2042968 666292fc9e 重置密码 2024-12-26 15:18:46 +08:00
s2042968 fe7c60b713 权限管理和人员绑定页面接口 2024-12-26 15:03:57 +08:00
chenxudong 822cfcc496 调通了文件上传 2024-12-26 14:44:27 +08:00
chenxudong 89a939a0b2 层级相关的接口调通了 2024-12-26 11:21:08 +08:00
chenxudong 0c6ab12f3f 优化事务和导出的逻辑。 2024-12-25 15:02:06 +08:00
chenxudong b9233d086c 完成了全部接口的开发,待自测。 2024-12-25 14:54:00 +08:00
s2042968 ea0e0948c4 Merge branch 'develop' of http://139.196.179.195:3000/chenxudong/electromagnetic-data-new into develop 2024-12-24 13:34:32 +08:00
s2042968 d7fc388c55 日期不识别bug修复 2024-12-24 13:34:25 +08:00
chenxudong 4cd57f64b4 完成文件上传、复制和移动的接口,其余待完成。 2024-12-23 16:46:14 +08:00
chenxudong 3275ed51b4 Merge branch 'develop' of http://139.196.179.195:3000/chenxudong/electromagnetic-data-new into develop 2024-12-20 14:16:10 +08:00
chenxudong 12a4d198a6 实现了部分接口,提交备份。 2024-12-20 14:15:07 +08:00
s2042968 a839b0c866 解决冲突 2024-12-19 17:33:30 +08:00
s2042968 0612e81e1a 新增角色,更新角色,角色姓名校验,删除角色功能 2024-12-19 17:27:12 +08:00
chenxudong 926f0ae96e 开发了一部分的文件相关接口。 2024-12-19 17:16:20 +08:00
chenxudong 877fc5f557 rename file 2024-12-19 10:30:21 +08:00
chenxudong 88e6f8f9d6 修改测试的bug 2024-12-19 10:26:05 +08:00
chenxudong 0c1062f9b8 clean and formate code 2024-12-18 17:53:43 +08:00
chenxudong be51f2d250 clean dependency 2024-12-18 17:50:26 +08:00
chenxudong 1f5a7620ad clean properties 2024-12-18 17:41:31 +08:00
chenxudong 44b0666657 Merge branch 'develop' of http://139.196.179.195:3000/chenxudong/electromagnetic-data-new into develop 2024-12-18 17:30:53 +08:00
chenxudong dc4a7d4337 自测通了创建工程,查询工程和添加子集的接口。 2024-12-18 17:30:42 +08:00
s2042968 3299aa7804 合并冲突处理 2024-12-18 17:09:52 +08:00
s2042968 94b735fe5d 获取当前目录下用户操作权限功能,获取用户有权限访问的目录集合方法,人员绑定功能 2024-12-18 17:08:43 +08:00
chenxudong 1b4492e812 增加异常处理相关逻辑。 2024-12-18 16:03:05 +08:00
chenxudong e76449212e 开发完成层级定义相关的接口,还没自测。 2024-12-18 15:34:18 +08:00
chenxudong 7f50349104 整理日志输出 2024-12-18 09:42:36 +08:00
chenxudong 8cb8c4c834 重新整理日志相关依赖。 2024-12-18 09:36:05 +08:00
chenxudong 744eca6e4e Merge branch 'develop' of http://139.196.179.195:3000/chenxudong/electromagnetic-data-new into develop 2024-12-18 08:55:57 +08:00
chenxudong 25ee4a5fa2 实现部分功能 2024-12-18 08:55:48 +08:00
s2042968 3ec5a7d993 角色,权限,关系,Mybatis-plus 2024-12-17 15:03:59 +08:00
chenxudong 18c72d0d08 部分初始化。 2024-12-17 09:06:23 +08:00
chenxudong 4ad81053fb reformat code 2024-12-13 16:12:27 +08:00
chenxudong 7360a4d1fa 修改启动端口 2024-12-13 15:31:02 +08:00
134 changed files with 6400 additions and 2836 deletions

View File

@ -1,6 +1,6 @@
<?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"
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
@ -23,26 +23,6 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
<exclusions>
<exclusion>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
</exclusion>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-to-slf4j</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
@ -81,47 +61,19 @@
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper</artifactId>
<exclusions>
<exclusion>
<groupId>com.github.jsqlparser</groupId>
<artifactId>jsqlparser</artifactId>
</exclusion>
</exclusions>
<version>5.1.2</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.8.1</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid</artifactId>
<version>1.1.10</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.11.2</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.11.2</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-jcl</artifactId>
<version>2.11.2</version>
</dependency>
<!--使⽤log4j2的AsyncLogger,包含disruptor-->
<dependency>
<groupId>com.lmax</groupId>
<artifactId>disruptor</artifactId>
<version>3.4.2</version>
</dependency>
<!-- slf4j依赖-->
<!--与slf4j保持桥接-->
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
<version>2.11.2</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>

View File

@ -0,0 +1,81 @@
package com.electromagnetic.industry.software.manage.aop;
import com.electromagnetic.industry.software.common.annotations.RequiredPermission;
import com.electromagnetic.industry.software.common.cons.ElectromagneticConstants;
import com.electromagnetic.industry.software.common.enums.FilePermission;
import com.electromagnetic.industry.software.common.exception.PermissionDeniedException;
import com.electromagnetic.industry.software.common.util.UserThreadLocal;
import com.electromagnetic.industry.software.manage.pojo.req.FileInfoQueryDTO;
import com.electromagnetic.industry.software.manage.pojo.req.UpdateFileInfoDTO;
import com.electromagnetic.industry.software.manage.service.EdFileInfoService;
import com.electromagnetic.industry.software.manage.service.PermissionService;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.Map;
@Aspect
@Component
public class FilePermissionCheckAspect {
@Resource
PermissionService permissionService;
@Resource
EdFileInfoService edFileInfoService;
@Around("@annotation(requiredPermission)")
public Object requirePermission(ProceedingJoinPoint joinPoint, RequiredPermission requiredPermission) throws Throwable{
Object[] args = joinPoint.getArgs();
if (args.length == 0) {
return joinPoint.proceed();
}
FilePermission filePermission = requiredPermission.value();
String userId = UserThreadLocal.getUserId();
String id = extractId(args[0]); // 提取ID逻辑封装成方法减少冗余代码
// 特殊处理 FileInfoQueryDTO
if (args[0] instanceof FileInfoQueryDTO) {
if (id.length() > ElectromagneticConstants.PRJ_ID_LENGTH) {
return joinPoint.proceed();
}
}
// 先判断是否有权限避免不必要的 `if` 嵌套
if (!permissionService.isPermitted(filePermission.getCode(), userId, id)) {
throw new PermissionDeniedException("用户无权限执行此操作");
}
// 如果是 MOVE 操作还需要检查目标文件夹权限
if (filePermission.equals(FilePermission.MOVE)) {
if (args.length < 2 || !(args[1] instanceof String)) {
throw new IllegalArgumentException("MOVE 操作需要提供目标文件夹 ID");
}
String targetId = edFileInfoService.getCategoryId(args[1].toString());
if (!permissionService.isPermitted(filePermission.getCode(), userId, targetId)) {
throw new PermissionDeniedException("用户无权限对目标文件夹执行此操作");
}
}
return joinPoint.proceed();
}
/**
* 提取参数中的 ID避免重复代码
*/
private String extractId(Object arg) {
if (arg instanceof String) {
return edFileInfoService.getCategoryId(arg.toString());
} else if (arg instanceof UpdateFileInfoDTO) {
return edFileInfoService.getCategoryId(((UpdateFileInfoDTO) arg).getId());
} else if (arg instanceof FileInfoQueryDTO) {
return ((FileInfoQueryDTO) arg).getParentId();
}
throw new IllegalArgumentException("不支持的参数类型:" + arg.getClass().getName());
}
}

View File

@ -0,0 +1,28 @@
package com.electromagnetic.industry.software.manage.aop;
import com.electromagnetic.industry.software.common.annotations.RequiredRole;
import com.electromagnetic.industry.software.common.exception.PermissionDeniedException;
import com.electromagnetic.industry.software.common.util.UserThreadLocal;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.stereotype.Component;
@Component
@Aspect
public class RoleCheckAspect {
@Around("@annotation(requiredRole)")
public Object checkRole(ProceedingJoinPoint joinPoint, RequiredRole requiredRole) throws Throwable {
// 获取当前用户角色
String currentRole = UserThreadLocal.getAdminType();
// 检查角色
if (requiredRole.value().getValue().equals(currentRole)) {
return joinPoint.proceed(); // 用户角色匹配执行方法
}
// 如果角色不匹配抛出异常或返回无权限响应
throw new PermissionDeniedException("用户无权限执行此操作");
}
}

View File

@ -51,7 +51,7 @@ public class ServiceAspect {
}
paramInfo = JSONUtil.toJsonStr(list);
} catch (Exception e) {
log.warn("切面异常", e.getMessage());
log.warn("切面异常--->{}", e.getMessage());
}
}
}

View File

@ -0,0 +1,43 @@
package com.electromagnetic.industry.software.manage.common;
import com.electromagnetic.industry.software.common.exception.BizException;
import com.electromagnetic.industry.software.common.exception.PermissionDeniedException;
import com.electromagnetic.industry.software.common.resp.ElectromagneticResult;
import com.electromagnetic.industry.software.common.util.ElectromagneticResultUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.ResponseStatus;
import java.nio.file.AccessDeniedException;
@Slf4j
@ControllerAdvice
public class GlobalExceptionHandler {
@ExceptionHandler(RuntimeException.class)
@ResponseStatus(HttpStatus.OK)
@ResponseBody
public ElectromagneticResult<?> runTimeError(Throwable e) {
log.error(e.getMessage(), e);
return ElectromagneticResultUtil.fail("-1", e.getMessage());
}
@ExceptionHandler(BizException.class)
@ResponseStatus(HttpStatus.OK)
@ResponseBody
public ElectromagneticResult<?> bizError(BizException e) {
log.error(e.getMessage(), e);
return ElectromagneticResultUtil.fail("-1", e.getMessage());
}
@ExceptionHandler(PermissionDeniedException.class)
@ResponseStatus(HttpStatus.OK)
@ResponseBody
public ElectromagneticResult<?> accessDeniedError(PermissionDeniedException e) {
log.error(e.getMessage(), e);
return ElectromagneticResultUtil.fail("-1", e.getMessage());
}
}

View File

@ -0,0 +1,38 @@
package com.electromagnetic.industry.software.manage.config;
import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;
import java.util.Date;
@Component
public class EdMetaObjectHandler implements MetaObjectHandler {
@Override
public void insertFill(MetaObject metaObject) {
if (metaObject.hasSetter("gmtCreate")) {
this.strictInsertFill(metaObject, "gmtCreate", Date.class, new Date());
}
if (metaObject.hasGetter("createdAt")) {
this.strictInsertFill(metaObject, "createdAt", Date.class, new Date());
}
if (metaObject.hasSetter("gmtModified")) {
this.strictUpdateFill(metaObject, "gmtModified", Date.class, new Date());
}
if (metaObject.hasGetter("updatedAt")) {
this.strictUpdateFill(metaObject, "updatedAt", Date.class, new Date());
}
}
@Override
public void updateFill(MetaObject metaObject) {
if (metaObject.hasSetter("gmtModified")) {
this.strictUpdateFill(metaObject, "gmtModified", Date.class, new Date());
}
if (metaObject.hasGetter("updatedAt")) {
this.strictUpdateFill(metaObject, "updatedAt", Date.class, new Date());
}
}
}

View File

@ -2,6 +2,7 @@ package com.electromagnetic.industry.software.manage.config;
import cn.hutool.core.date.SystemClock;
import com.electromagnetic.industry.software.common.cons.UserConstants;
import com.electromagnetic.industry.software.common.enums.AdminTypeEnum;
import com.electromagnetic.industry.software.common.pojo.UserLoginInfo;
import com.electromagnetic.industry.software.common.util.TokenUtil;
import com.electromagnetic.industry.software.common.util.UserThreadLocal;
@ -27,11 +28,29 @@ public class LoginInterceptor implements HandlerInterceptor {
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
// 首先校验token
boolean isTokenValid = checkToken(request, response);
if (!isTokenValid) {
return false;
}
return checkSysAdminOperation(request, response);
}
private boolean checkSysAdminOperation(HttpServletRequest request, HttpServletResponse response) {
String requestURI = request.getRequestURI();
if (requestURI.startsWith("/data/ed/prj") && !UserThreadLocal.getAdminType().equals(AdminTypeEnum.SYSTEM.getValue())) {
log.warn("{}没有层级操作权限,当前用户类型是{}", UserThreadLocal.getUsername(), UserThreadLocal.getAdminType());
response.setStatus(HttpServletResponse.SC_FORBIDDEN);
return false;
}
return true;
}
private boolean checkToken(HttpServletRequest request, HttpServletResponse response) {
String token = request.getHeader("Authorization");
if (token==null) {
if (token == null) {
log.error("Authorization header is null");
response.setStatus(401);
response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
return false;
} else {
token = token.substring(7);
@ -39,19 +58,20 @@ public class LoginInterceptor implements HandlerInterceptor {
boolean result = isTokenValid(token);
if (!result) {
log.error("Invalid token");
response.setStatus(401);
response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
return false;
} else {
Claims claims = TokenUtil.getLoginInfo(token);
if (claims==null) {
if (claims == null) {
log.error("User info is missing");
response.setStatus(401);
response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
return false;
} else {
UserLoginInfo userLoginInfo = new UserLoginInfo();
userLoginInfo.setUserId(claims.get(UserConstants.LOGIN_USER_ID, String.class));
userLoginInfo.setUsername(claims.get(UserConstants.LOGIN_USER_NAME, String.class));
userLoginInfo.setWorkNumber(claims.get(UserConstants.LOGIN_WORK_NUMBER, String.class));
userLoginInfo.setAdminType(claims.get(UserConstants.LOGIN_ADMIN_TYPE, String.class));
UserThreadLocal.set(userLoginInfo);
}
return true;
@ -68,7 +88,7 @@ public class LoginInterceptor implements HandlerInterceptor {
UserThreadLocal.remove();
}
public Boolean isTokenValid(String tokenStr){
public Boolean isTokenValid(String tokenStr) {
Token token = tokenMapper.selectToken(tokenStr);
Date now = new Date(SystemClock.now());
return token != null && now.before(token.getExpireAt());

View File

@ -0,0 +1,17 @@
package com.electromagnetic.industry.software.manage.config;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
public class MybatisPlusConfig {
@Bean
public MybatisPlusInterceptor mybatisPlusInterceptor() {
MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
interceptor.addInnerInterceptor(new PaginationInnerInterceptor()); // 添加分页插件
return interceptor;
}
}

View File

@ -18,7 +18,6 @@ public class WebMvcConfig implements WebMvcConfigurer {
private LoginInterceptor loginInterceptor;
/**
*
* @param registry registry
*/
@Override

View File

@ -1,27 +0,0 @@
package com.electromagnetic.industry.software.manage.controller;
import com.electromagnetic.industry.software.common.resp.ElectromagneticResult;
import com.electromagnetic.industry.software.manage.service.CategoryService;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
@RequestMapping("/data/ed/category")
@RestController
public class CategoryController {
@Resource
private CategoryService categoryService;
/**
* 目录树查询
*/
@ApiOperation(value = "目录树查询", notes = "")
@RequestMapping(value = "/tree", method = RequestMethod.GET)
public ElectromagneticResult<?> categoryTree() {
return categoryService.getAllCategories();
}
}

View File

@ -1,106 +0,0 @@
package com.electromagnetic.industry.software.manage.controller;
import com.electromagnetic.industry.software.common.resp.*;
import com.electromagnetic.industry.software.manage.pojo.req.EDDataRequest;
import com.electromagnetic.industry.software.manage.pojo.req.FileChunkDTO;
import com.electromagnetic.industry.software.manage.service.EDDataService;
import io.swagger.annotations.ApiOperation;
import org.springframework.core.io.InputStreamResource;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Date;
@RequestMapping("/data/ed/file")
@RestController
public class EDDataController {
@Resource
private EDDataService edDataService;
@ApiOperation(value = "新建文件夹",notes = "")
@RequestMapping(value = "/createFolder",method = RequestMethod.POST)
public ElectromagneticResult<?> createFolder(@RequestBody EDDataRequest request){
return edDataService.createFolder(request);
}
@ApiOperation(value = "获取文件信息列表",notes = "")
@RequestMapping(value = "/getFileInfoList",method = RequestMethod.POST)
public ElectromagneticResult<?> getFileInfoList(@RequestBody EDDataRequest request){
return edDataService.getDataInfoList(request);
}
@ApiOperation(value = "更新文件信息",notes = "")
@RequestMapping(value = "/updateFileInfo",method = RequestMethod.POST)
public ElectromagneticResult<?> updateFileInfo(@RequestBody EDDataRequest request){
return edDataService.updateFileInfo(request);
}
@ApiOperation(value = "获取子文件数量",notes = "")
@RequestMapping(value = "/getChildFileCount",method = RequestMethod.POST)
public ElectromagneticResult<?> getChildFileCount(@RequestBody EDDataRequest request){
return edDataService.getChildFileCount(request);
}
@ApiOperation(value = "上传",notes = "")
@RequestMapping(value = "/upload", consumes = "multipart/form-data",method = RequestMethod.POST)
public ElectromagneticResult<?> upload(@RequestParam("parentId") String parentId,
@RequestParam("file") MultipartFile file,
@RequestParam("gmtBatchUpload") Long gmtBatchUpload){
EDDataRequest request = new EDDataRequest();
request.setParentId(parentId);
request.setFileData(file);
request.setGmtBatchUpload(new Date(gmtBatchUpload));
return edDataService.uploadFile(request);
}
@ApiOperation(value = "下载",notes = "")
@RequestMapping(value = "/download",method = RequestMethod.GET)
public ResponseEntity<InputStreamResource> download(@RequestParam String dataId, HttpServletResponse response) throws IOException {
return edDataService.download(dataId, response);
}
@ApiOperation(value = "数据导出",notes = "")
@RequestMapping(value = "/batchExport",method = RequestMethod.GET)
public ResponseEntity<InputStreamResource> batchExport(@RequestParam String dataIdArr, HttpServletResponse response) throws IOException {
return edDataService.batchExport(dataIdArr, response);
}
@ApiOperation(value = "获取已经上传的分片",notes = "")
@RequestMapping(value = "/getUploadedChunkNums",method = RequestMethod.GET)
public ElectromagneticResult<?> getUploadedChunkNums(@RequestParam String identifier) {
return edDataService.getUploadedChunkNums(identifier);
}
@ApiOperation(value = "合并分片",notes = "")
@RequestMapping(value = "/mergeChunks",method = RequestMethod.GET)
public ElectromagneticResult<?> mergeChunks(@RequestParam String identifier,
@RequestParam String fileName,
@RequestParam Integer totalChunks) {
return edDataService.mergeChunks(identifier, fileName, totalChunks);
}
@ApiOperation(value = "分片上传",notes = "")
@RequestMapping(value = "/batchImport",method = RequestMethod.POST)
public ElectromagneticResult<?> batchImport(FileChunkDTO fileChunkDTO) {
return edDataService.batchImport(fileChunkDTO);
}
@ApiOperation(value = "检查分片是否存在",notes = "")
@RequestMapping(value = "/batchImport",method = RequestMethod.GET)
public ElectromagneticResult<?> checkChunkExist(FileChunkDTO fileChunkDTO) {
return edDataService.checkChunkExist(fileChunkDTO);
}
}

View File

@ -0,0 +1,135 @@
package com.electromagnetic.industry.software.manage.controller;
import com.electromagnetic.industry.software.common.annotations.RequiredPermission;
import com.electromagnetic.industry.software.common.enums.FilePermission;
import com.electromagnetic.industry.software.common.resp.ElectromagneticResult;
import com.electromagnetic.industry.software.manage.pojo.req.CreateFolderDTO;
import com.electromagnetic.industry.software.manage.pojo.req.FileChunkDTO;
import com.electromagnetic.industry.software.manage.pojo.req.FileInfoQueryDTO;
import com.electromagnetic.industry.software.manage.pojo.req.UpdateFileInfoDTO;
import com.electromagnetic.industry.software.manage.service.EdFileInfoService;
import org.springframework.core.io.InputStreamResource;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
@RestController
@RequestMapping("/data/ed/file")
public class EdFileInfoController {
@Resource
private EdFileInfoService edFileInfoService;
@RequestMapping("tree")
public ElectromagneticResult<?> tree() {
return edFileInfoService.tree();
}
@RequestMapping("createFolder")
public ElectromagneticResult<?> createFolder(@RequestBody CreateFolderDTO createFolderDTO) {
return edFileInfoService.createFolder(createFolderDTO);
}
@RequiredPermission(value = FilePermission.DELETE)
@RequestMapping("delete")
public ElectromagneticResult<?> delete(@RequestParam String id) {
return edFileInfoService.delete(id);
}
@RequiredPermission(value = FilePermission.VIEW)
@RequestMapping("info")
public ElectromagneticResult<?> info(@RequestBody FileInfoQueryDTO fileInfoQueryDTO) {
return edFileInfoService.queryEdFileInfo(fileInfoQueryDTO);
}
@RequiredPermission(value = FilePermission.UPLOAD)
@RequestMapping("upload")
public ElectromagneticResult<?> upload(@RequestParam("parentId") String parentId,
@RequestParam("file") MultipartFile file,
@RequestParam("strategy") Integer strategy) {
return edFileInfoService.upload(parentId, file, strategy);
}
@RequiredPermission(value = FilePermission.DOWNLOAD)
@RequestMapping("download")
public ResponseEntity<InputStreamResource> download(@RequestParam String id, HttpServletResponse response) {
return edFileInfoService.download(id, response);
}
@RequiredPermission(value = FilePermission.EDIT)
@RequestMapping("updateFileInfo")
public ElectromagneticResult<?> updateFileInfo(@RequestBody UpdateFileInfoDTO updateFileInfoDTO) {
return edFileInfoService.updateFileInfo(updateFileInfoDTO);
}
@RequiredPermission(value = FilePermission.MOVE)
@RequestMapping("moveFile")
public ElectromagneticResult<?> moveFile(@RequestParam("id") String id,
@RequestParam("targetFolderId") String targetFolderId,
@RequestParam("strategy") Integer strategy) {
return edFileInfoService.moveFile(id, targetFolderId, strategy);
}
@RequiredPermission(value = FilePermission.MOVE)
@RequestMapping("copyFile")
public ElectromagneticResult<?> copyFile(@RequestParam("id") String id,
@RequestParam("targetFolderId") String targetFolderId,
@RequestParam("strategy") Integer strategy) {
return edFileInfoService.copyFile(id, targetFolderId, strategy);
}
@RequiredPermission(value = FilePermission.VIEW)
@RequestMapping("versionView")
public ElectromagneticResult<?> versionView(@RequestParam String fileId) {
return edFileInfoService.versionView(fileId);
}
@RequiredPermission(value = FilePermission.EDIT)
@RequestMapping("versionBack")
public ElectromagneticResult<?> versionBack(@RequestParam String fileId, @RequestParam int targetVersion) {
return edFileInfoService.versionBack(fileId, targetVersion);
}
@RequestMapping("batchExport")
public ResponseEntity<InputStreamResource> batchExport(@RequestParam String fileIds, HttpServletResponse response) throws IOException {
return edFileInfoService.batchExport(fileIds, response);
}
@RequestMapping(value = "/mergeChunks", method = RequestMethod.GET)
public ElectromagneticResult<?> mergeChunks(@RequestParam String identifier,
@RequestParam String fileName,
@RequestParam Integer totalChunks) {
return edFileInfoService.mergeChunks(identifier, fileName, totalChunks);
}
@RequestMapping(value = "/batchImport", method = RequestMethod.POST)
public ElectromagneticResult<?> batchImport(FileChunkDTO fileChunkDTO) {
return edFileInfoService.batchImport(fileChunkDTO);
}
@RequestMapping(value = "/batchImport", method = RequestMethod.GET)
public ElectromagneticResult<?> checkChunkExist(FileChunkDTO fileChunkDTO) {
return edFileInfoService.checkChunkExist(fileChunkDTO);
}
@RequestMapping(value = "/uploadRecord", method = RequestMethod.GET)
public ElectromagneticResult<?> uploadRecord(@RequestParam int pageNum, @RequestParam int pageSize) {
return edFileInfoService.uploadRecord(pageNum, pageSize);
}
@RequiredPermission(value = FilePermission.VIEW)
@RequestMapping(value = "/fileDetail", method = RequestMethod.GET)
public ElectromagneticResult<?> detail(@RequestParam String id) {
return edFileInfoService.detail(id);
}
@RequiredPermission(value = FilePermission.VIEW)
@RequestMapping(value = "/queryChildFolder", method = RequestMethod.GET)
public ElectromagneticResult<?> queryChildFolder(@RequestParam String parentId) {
return edFileInfoService.queryChildFolder(parentId);
}
}

View File

@ -0,0 +1,89 @@
package com.electromagnetic.industry.software.manage.controller;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.electromagnetic.industry.software.common.exception.BizException;
import com.electromagnetic.industry.software.common.resp.ElectromagneticResult;
import com.electromagnetic.industry.software.common.util.ElectromagneticResultUtil;
import com.electromagnetic.industry.software.manage.pojo.models.EdFileRelation;
import com.electromagnetic.industry.software.manage.pojo.req.CheckNameUniqueRequest;
import com.electromagnetic.industry.software.manage.pojo.req.UpdateRelationDTO;
import com.electromagnetic.industry.software.manage.service.serviceimpl.EdFileRelationServiceImpl;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
@RestController
@RequestMapping("/data/ed/relation")
public class EdFileRelationController {
@Resource
EdFileRelationServiceImpl edFileRelationService;
/**
* 创建文件关系
*
* @param relation
* @return
*/
@RequestMapping(value = "/create", method = RequestMethod.POST)
public ElectromagneticResult<?> createRelation(@RequestBody EdFileRelation relation) {
try {
Boolean res = edFileRelationService.createRelation(relation);
return ElectromagneticResultUtil.success(res);
} catch (BizException e) {
return ElectromagneticResultUtil.fail("500", e.getMessage());
}
}
/**
* 创建文件关系
*
* @param updateRelation
* @return
*/
@RequestMapping(value = "/update", method = RequestMethod.POST)
public ElectromagneticResult<?> updateRelation(@RequestBody UpdateRelationDTO updateRelation) {
LambdaUpdateWrapper<EdFileRelation> wrapper = new LambdaUpdateWrapper<>();
wrapper.eq(EdFileRelation::getId, updateRelation.getRelationId()).set(EdFileRelation::getRelationship, updateRelation.getRelationship());
return ElectromagneticResultUtil.success(edFileRelationService.update(wrapper));
}
/**
* 取消文件关系
*
* @param relationId 关系主键id
* @return
*/
@RequestMapping(value = "/cancel/{relationId}", method = RequestMethod.GET)
public ElectromagneticResult<?> cancelRelation(@PathVariable("relationId") String relationId) {
return ElectromagneticResultUtil.success(edFileRelationService.cancelRelation(relationId));
}
/**
* 展示文件关系
*/
@RequestMapping(value = "listRelations/{id}", method = RequestMethod.GET)
public ElectromagneticResult<?> listRelations(@PathVariable("id") String id) {
return ElectromagneticResultUtil.success(edFileRelationService.listRelations(id));
}
/**
* 检验文件名是否唯一
*/
@RequestMapping(value = "/checkFileNameExist", method = RequestMethod.POST)
public ElectromagneticResult<?> checkFileNameExist(@RequestBody CheckNameUniqueRequest checkNameUniqueRequest) {
return ElectromagneticResultUtil.success(edFileRelationService.checkNameExist(checkNameUniqueRequest));
}
/**
* 本地上传并建立关系
*/
@RequestMapping(value = "/upload", method = RequestMethod.POST)
public ElectromagneticResult<?> uploadRelation(@RequestParam("parentId") String parentId,
@RequestParam("file") MultipartFile file,
@RequestParam("description") String description,
@RequestParam("id") String id) {
return ElectromagneticResultUtil.success(edFileRelationService.uploadFileAndRelation(parentId, id, file, description));
}
}

View File

@ -0,0 +1,29 @@
package com.electromagnetic.industry.software.manage.controller;
import com.electromagnetic.industry.software.common.resp.ElectromagneticResult;
import com.electromagnetic.industry.software.common.util.ElectromagneticResultUtil;
import com.electromagnetic.industry.software.common.util.UserThreadLocal;
import com.electromagnetic.industry.software.manage.service.PermissionService;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
@RestController
@RequestMapping("/data/ed/permission")
public class PermissionController {
@Resource
private PermissionService permissionService;
@ApiOperation(value = "查询当前用户在当前目录的功能权限", notes = "")
@GetMapping(value = "/{id}")
public ElectromagneticResult<?> getUserPermission(@PathVariable("id") String id) {
String userId = UserThreadLocal.getUserId();
return ElectromagneticResultUtil.success(permissionService.getUserPermission(userId, id, false));
}
}

View File

@ -0,0 +1,83 @@
package com.electromagnetic.industry.software.manage.controller;
import com.electromagnetic.industry.software.common.resp.ElectromagneticResult;
import com.electromagnetic.industry.software.manage.pojo.req.FolderResortDTO;
import com.electromagnetic.industry.software.manage.pojo.req.QueryPublishStatus;
import com.electromagnetic.industry.software.manage.service.EdPrjService;
import com.electromagnetic.industry.software.manage.service.PermissionService;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.util.List;
@RestController
@RequestMapping("/data/ed/prj")
public class ProjectController {
@Resource
private EdPrjService edPrjService;
@Resource
private PermissionService permissionService;
@RequestMapping("create")
public ElectromagneticResult<?> create(@RequestParam String prjName) {
return edPrjService.createNewPrj(prjName);
}
@RequestMapping("delete")
public ElectromagneticResult<?> delete(@RequestParam String prjId) {
return edPrjService.delete(prjId);
}
@RequestMapping("modify")
public ElectromagneticResult<?> modifyPrjName(@RequestParam String newPrjName, @RequestParam String prjId) {
return edPrjService.modifyPrjName(prjId, newPrjName);
}
@RequestMapping("queryAll")
public ElectromagneticResult<?> queryAll() {
return edPrjService.queryAllPrjInfo();
}
@RequestMapping("addFolder")
public ElectromagneticResult<?> addFolder(@RequestParam String folderName, @RequestParam String parentId) {
return edPrjService.addFolder(parentId, folderName);
}
@RequestMapping("modifyFolder")
public ElectromagneticResult<?> modifyFolder(@RequestParam String newFolderName, @RequestParam String id) {
return edPrjService.modifyFolder(id, newFolderName);
}
@RequestMapping("deleteFolder")
public ElectromagneticResult<?> deleteFolder(@RequestParam String id) {
return edPrjService.deleteFolder(id);
}
@RequestMapping("folderResort")
public ElectromagneticResult<?> folderResort(@RequestBody List<FolderResortDTO> folderResortDTOList) {
return edPrjService.folderResort(folderResortDTOList);
}
@RequestMapping("publish")
public ElectromagneticResult<?> publish(@RequestParam String prjId) {
ElectromagneticResult<?> result = edPrjService.publish(prjId);
// 更新项目权限
permissionService.syncPermissions(prjId);
return result;
}
@RequestMapping("follow")
public ElectromagneticResult<?> follow(@RequestParam String sourceId, @RequestParam String targetId) {
return edPrjService.follow(sourceId, targetId);
}
@RequestMapping("publishStatus")
public ElectromagneticResult<?> publishStatus(@RequestBody QueryPublishStatus queryPublishStatus) {
return edPrjService.publishStatus(queryPublishStatus);
}
}

View File

@ -0,0 +1,88 @@
package com.electromagnetic.industry.software.manage.controller;
import com.electromagnetic.industry.software.common.annotations.RequiredRole;
import com.electromagnetic.industry.software.common.enums.AdminTypeEnum;
import com.electromagnetic.industry.software.common.exception.BizException;
import com.electromagnetic.industry.software.common.resp.ElectromagneticResult;
import com.electromagnetic.industry.software.common.util.ElectromagneticResultUtil;
import com.electromagnetic.industry.software.manage.pojo.req.RoleDTO;
import com.electromagnetic.industry.software.manage.pojo.req.RolePageDTO;
import com.electromagnetic.industry.software.manage.service.RoleService;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
@RestController
@RequestMapping("/data/ed/role")
public class RoleController {
@Resource
private RoleService roleService;
@ApiOperation(value = "新建角色", notes = "")
@RequiredRole(AdminTypeEnum.SECURITY)
@RequestMapping(value = "/createRole", method = RequestMethod.POST)
public ElectromagneticResult<?> createRole(@RequestBody RoleDTO roleDTO) {
try {
Boolean res = roleService.createRole(roleDTO);
return ElectromagneticResultUtil.success(res);
} catch (BizException e) {
return ElectromagneticResultUtil.fail("400", e.getMessage());
}
}
@ApiOperation(value = "更新角色", notes = "")
@RequiredRole(AdminTypeEnum.SECURITY)
@RequestMapping(value = "/updateRole", method = RequestMethod.POST)
public ElectromagneticResult<?> updateRole(@RequestBody RoleDTO roleDTO) {
try {
Boolean res = roleService.updateRole(roleDTO);
return ElectromagneticResultUtil.success(res);
} catch (BizException e) {
return ElectromagneticResultUtil.fail("400", e.getMessage());
}
}
@ApiOperation(value = "删除角色", notes = "")
@RequiredRole(AdminTypeEnum.SECURITY)
@GetMapping(value = "/deleteRole/{roleId}")
public ElectromagneticResult<?> deleteRole(@PathVariable("roleId") String roleId) {
return ElectromagneticResultUtil.success(roleService.deleteRole(roleId));
}
@ApiOperation(value = "查看角色", notes = "")
@RequiredRole(AdminTypeEnum.SECURITY)
@GetMapping(value = "/getSingleRole/{roleId}")
public ElectromagneticResult<?> getRole(@PathVariable("roleId") String roleId) {
return ElectromagneticResultUtil.success(roleService.getRole(roleId));
}
@ApiOperation(value = "获取角色列表", notes = "")
@RequiredRole(AdminTypeEnum.SECURITY)
@RequestMapping(value = "/list", method = RequestMethod.POST)
public ElectromagneticResult<?> getRoles(@RequestBody RolePageDTO rolePageDTO) {
return ElectromagneticResultUtil.success(roleService.getRoles(rolePageDTO));
}
@ApiOperation(value = "通过角色名查看角色权限", notes = "")
@RequiredRole(AdminTypeEnum.SECURITY)
@GetMapping(value = "/getRoleByName")
public ElectromagneticResult<?> getRoleByName(@RequestParam("roleName") String roleName) {
return ElectromagneticResultUtil.success(roleService.getRoleByName(roleName));
}
@ApiOperation(value = "角色名列表", notes = "")
@RequiredRole(AdminTypeEnum.SECURITY)
@GetMapping(value = "/getRoleNames")
public ElectromagneticResult<?> getRoleNames() {
return ElectromagneticResultUtil.success(roleService.getAllRoleNames());
}
@ApiOperation(value = "获得角色配置模版", notes = "")
@RequiredRole(AdminTypeEnum.SECURITY)
@GetMapping(value = "/getRoleTemplate")
public ElectromagneticResult<?> getRoleTemplate() {
return ElectromagneticResultUtil.success(roleService.getRoleTemplate());
}
}

View File

@ -1,12 +1,18 @@
package com.electromagnetic.industry.software.manage.controller;
import com.electromagnetic.industry.software.common.annotations.RequiredRole;
import com.electromagnetic.industry.software.common.enums.AdminTypeEnum;
import com.electromagnetic.industry.software.common.enums.PublishEnum;
import com.electromagnetic.industry.software.common.resp.ElectromagneticResult;
import com.electromagnetic.industry.software.common.util.ElectromagneticResultUtil;
import com.electromagnetic.industry.software.common.util.UserThreadLocal;
import com.electromagnetic.industry.software.manage.pojo.req.*;
import com.electromagnetic.industry.software.manage.service.UserService;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;
@RequestMapping("/data/ed/user")
@RestController
@ -22,30 +28,35 @@ public class UserController {
}
@ApiOperation(value = "新增用户信息", notes = "")
@RequiredRole(AdminTypeEnum.SYSTEM)
@PostMapping("/createUser")
public ElectromagneticResult<?> createUser(@RequestBody UserRequest userRequest) {
return userService.createUser(userRequest);
}
@ApiOperation(value="编辑用户信息",notes = "")
@ApiOperation(value = "编辑用户信息", notes = "")
@RequiredRole(AdminTypeEnum.SYSTEM)
@PutMapping("/updateUser")
public ElectromagneticResult<?> updateUser(@RequestBody UserModiRequest userModiRequest){
public ElectromagneticResult<?> updateUser(@RequestBody UserModiRequest userModiRequest) {
return userService.modifyUser(userModiRequest);
}
@ApiOperation(value = "发布用户信息", notes = "")
@RequiredRole(AdminTypeEnum.SYSTEM)
@RequestMapping(value = "/publish", method = RequestMethod.POST)
public ElectromagneticResult<?> publishUser(@RequestBody UserPublishRequest userPublishRequest) {
return userService.publishUser(userPublishRequest);
}
@ApiOperation(value = "获取单条用户信息", notes = "")
@RequiredRole(AdminTypeEnum.SYSTEM)
@RequestMapping(value = "/getInfo", method = RequestMethod.GET)
public ElectromagneticResult<?> getSingleUser(GetSingleUserRequest getSingleUserRequest) {
return userService.getSingleUser(getSingleUserRequest);
}
@ApiOperation(value = "查询用户信息", notes = "")
@RequiredRole(AdminTypeEnum.SYSTEM)
@RequestMapping(value = "/list", method = RequestMethod.POST)
public ElectromagneticResult<?> searchUser(@RequestBody SearchUserRequest searchUserRequest) {
return userService.searchUser(searchUserRequest);
@ -57,15 +68,53 @@ public class UserController {
return userService.validateWorkNum(userWorkNumRequest);
}
@ApiOperation(value="删除用户信息",notes="")
@ApiOperation(value = "删除用户信息", notes = "")
@RequiredRole(AdminTypeEnum.SYSTEM)
@PostMapping(value = "/deleteUser")
public ElectromagneticResult<?> deleteUser(@RequestBody UserDeleteRequest userDeleteRequest) {
return userService.deleteUser(userDeleteRequest);
}
@ApiOperation(value="登出", notes = "")
@ApiOperation(value = "登出", notes = "")
@RequestMapping(value = "/logout", method = RequestMethod.POST)
public ElectromagneticResult<?> logout(@RequestHeader("Authorization") String token) {
return userService.logout(token);
}
@ApiOperation(value = "人员绑定界面查询用户", notes = "")
@RequiredRole(AdminTypeEnum.SECURITY)
@RequestMapping(value = "/bindRole/list", method = RequestMethod.POST)
public ElectromagneticResult<?> getPublishedUsers(@RequestBody SearchUserRequest searchUserRequest) {
searchUserRequest.setIsPublished(PublishEnum.PUBLISHED.getCode().toString());
return userService.searchUser(searchUserRequest);
}
@ApiOperation(value = "人员绑定", notes = "")
@RequiredRole(AdminTypeEnum.SECURITY)
@RequestMapping(value = "/bindRoles", method = RequestMethod.POST)
public ElectromagneticResult<?> bindRoles(@RequestBody List<UserBindRoleDTO> list) {
if (userService.bindRoles(list)) {
return ElectromagneticResultUtil.success(true);
} else {
return ElectromagneticResultUtil.fail("500", "不可绑定空用户");
}
}
@ApiOperation(value = "密码重置", notes = "")
@RequiredRole(AdminTypeEnum.SECURITY)
@GetMapping(value = "/resetPassword/{userId}")
public ElectromagneticResult<?> resetPassword(@PathVariable("userId") String userId) {
return ElectromagneticResultUtil.success(userService.resetPassword(userId));
}
@ApiOperation(value = "获取当前用户管理员类型")
@GetMapping(value = "/getAdminType")
public ElectromagneticResult<?> getAdminType() {
String adminType = UserThreadLocal.getAdminType();
if (adminType == null || adminType.isEmpty()) {
return ElectromagneticResultUtil.fail("500","当前用户未登录");
} else {
return ElectromagneticResultUtil.success(adminType);
}
}
}

View File

@ -1,43 +0,0 @@
package com.electromagnetic.industry.software.manage.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.electromagnetic.industry.software.manage.pojo.models.Category;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
@Mapper
public interface CategoryMapper extends BaseMapper<Category> {
/**
* 获取顶级节点
* @return
*/
List<Category> selectTopCategories();
/**
* 获取所有节点
* @return
*/
List<Category> selectAllCategories();
/**
* 获取节点通过编码ID
* @return
*/
List<Category> selectCategories(Category category);
/**
* 获取子节点通过父ID
* @return
*/
List<Category> selectChildCategories(Category category);
/**
* 创建目录树节点数据
* @return
*/
Boolean createCategory(Category category);
}

View File

@ -1,33 +0,0 @@
package com.electromagnetic.industry.software.manage.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.electromagnetic.industry.software.manage.pojo.models.EDDataInfo;
import com.electromagnetic.industry.software.manage.pojo.other.EDDataParams;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
@Mapper
public interface EDDataMapper extends BaseMapper<EDDataInfo> {
/**
* 创建文件/文件夹数据信息
* @param edDataInfo
* @return
*/
Boolean createDataInfo(EDDataInfo edDataInfo);
/**
* 获取文件信息列表
* @param parames
* @return
*/
List<EDDataInfo> getDataInfoList(EDDataParams parames);
/**
* 更新文件信息
* @param parames
* @return
*/
Boolean updateFileInfo(EDDataParams parames);
}

View File

@ -1,35 +0,0 @@
package com.electromagnetic.industry.software.manage.mapper;
import com.electromagnetic.industry.software.manage.pojo.models.EDDataInfo;
import com.electromagnetic.industry.software.manage.pojo.other.EDDataPage;
import com.electromagnetic.industry.software.manage.pojo.other.EDDataParams;
import com.electromagnetic.industry.software.manage.pojo.req.EDDataRequest;
import com.electromagnetic.industry.software.manage.pojo.resp.EDDataPageResponse;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
@Mapper
public interface EDDataMappers {
EDDataMappers INSTANCE= Mappers.getMapper(EDDataMappers.class);
/**
* 文件数据扩展模型入参转换
* @param request
* @return
*/
EDDataParams getEDDataParames(EDDataRequest request);
/**
* 文件数据扩展模型入参转换
* @param request
* @return
*/
EDDataInfo getEDDataInfo(EDDataRequest request);
/**
* 指标卡扩展模型返回
* @param edDataPage
* @return
*/
EDDataPageResponse getEDDataInfoToModel(EDDataPage edDataPage);
}

View File

@ -0,0 +1,12 @@
package com.electromagnetic.industry.software.manage.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.electromagnetic.industry.software.manage.pojo.models.EdFileInfo;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface EdFileInfoMapper extends BaseMapper<EdFileInfo> {
String maxPrjId();
}

View File

@ -0,0 +1,10 @@
package com.electromagnetic.industry.software.manage.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.electromagnetic.industry.software.manage.pojo.models.EdFileRelation;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface EdFileRelationMapper extends BaseMapper<EdFileRelation> {
}

View File

@ -0,0 +1,47 @@
package com.electromagnetic.industry.software.manage.mapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.electromagnetic.industry.software.manage.pojo.models.Role;
import com.electromagnetic.industry.software.manage.pojo.req.RoleDTO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
@Mapper
public interface RoleMapper extends BaseMapper<Role> {
@Select("<script>" +
"SELECT " +
" r.role_id AS roleId, " +
" r.role_name AS roleName, " +
" r.role_desc AS roleDesc, " +
" GROUP_CONCAT(DISTINCT f.file_name) AS dataScope, " +
" GROUP_CONCAT(DISTINCT rp.permission_code) AS allowedActions, " +
" CASE " +
" WHEN MAX(u.is_activated) = 1 THEN 1 " +
" ELSE 0 " +
" END AS isBind " +
"FROM " +
" ed_role r " +
"LEFT JOIN " +
" ed_role_permission rp ON r.role_id = rp.role_id " +
"LEFT JOIN " +
" ed_file_info f ON rp.file_id = f.id " +
"LEFT JOIN" +
" ed_user_role ur ON r.role_id = ur.role_id " +
"LEFT JOIN" +
" ed_users u ON ur.user_id = u.user_id " +
"WHERE " +
" 1=1 " +
"<if test=\"ew != null and ew.sqlSegment != null and ew.sqlSegment != ''\">" +
" AND ${ew.sqlSegment} " +
"</if>" +
"GROUP BY " +
" r.role_id" +
"</script>")
Page<RoleDTO> getPageRoleDTO(Page<RoleDTO> page, @Param(Constants.WRAPPER) QueryWrapper<Role> queryWrapper);
}

View File

@ -0,0 +1,15 @@
package com.electromagnetic.industry.software.manage.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.electromagnetic.industry.software.manage.pojo.models.RolePermission;
import com.electromagnetic.industry.software.manage.pojo.req.PublishedFileDTO;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
@Mapper
public interface RolePermissionMapper extends BaseMapper<RolePermission> {
List<RolePermission> getCurrentPermission(PublishedFileDTO publishedFileDTO);
}

View File

@ -9,6 +9,7 @@ public interface TokenMapper extends BaseMapper<Token> {
/**
* 插入
*
* @param token
* @return
*/
@ -16,6 +17,7 @@ public interface TokenMapper extends BaseMapper<Token> {
/**
* 查询
*
* @param token
* @return Token
*/
@ -23,6 +25,7 @@ public interface TokenMapper extends BaseMapper<Token> {
/**
* 删除token
*
* @param token
* @return
*/

View File

@ -13,6 +13,7 @@ public interface UserMapper {
/**
* 插入
*
* @param user
* @return
*/
@ -20,6 +21,7 @@ public interface UserMapper {
/**
* 编辑
*
* @param user
* @return
*/
@ -27,6 +29,7 @@ public interface UserMapper {
/**
* 发布
*
* @param publishParam
* @return
*/
@ -34,6 +37,7 @@ public interface UserMapper {
/**
* 通过工号查询用户
*
* @param workNumber
* @return
*/
@ -41,6 +45,7 @@ public interface UserMapper {
/**
* 通过用户编码查询用户
*
* @param userId
* @return
*/
@ -48,6 +53,7 @@ public interface UserMapper {
/**
* 通过用户编码查询用户
*
* @param searchKeywords
* @return
*/
@ -55,16 +61,25 @@ public interface UserMapper {
/**
* 查询数据总条目数
*
* @param searchKeywords
* @return
*/
int getTotalCount (SearchKeyWords searchKeywords);
int getTotalCount(SearchKeyWords searchKeywords);
/**
* 通过用户ID删除用户
* @param userId
*
* @param userDeleteKeyWords
* @return
*/
int deleteUser(UserDeleteKeyWords userDeleteKeyWords);
/**
* 查找用户角色名称
*
* @param userId
* @return
*/
List<String> selectUserRoles(String userId);
}

View File

@ -14,10 +14,11 @@ import java.util.List;
@Mapper
public interface UserMappers {
UserMappers INSTANCE= Mappers.getMapper(UserMappers.class);
UserMappers INSTANCE = Mappers.getMapper(UserMappers.class);
/**
* 用户Request转用户模型
*
* @param userRequest
* @return
*/
@ -25,6 +26,7 @@ public interface UserMappers {
/**
* 用户登录Request转用户登录模型
*
* @param loginRequest
* @return
*/
@ -32,6 +34,7 @@ public interface UserMappers {
/**
* 获取单条用户信息Request转用户模型
*
* @param user
* @return
*/
@ -40,6 +43,7 @@ public interface UserMappers {
/**
* 用户发布request转用户发布参数模型
*
* @param userPublishRequest
* @return
*/
@ -47,6 +51,7 @@ public interface UserMappers {
/**
* 获取单条用户信息Request转用户模型
*
* @param searchUserRequest
* @return
*/
@ -54,6 +59,7 @@ public interface UserMappers {
/**
* 获取用户列表转response列表
*
* @param users
* @return
*/
@ -61,6 +67,7 @@ public interface UserMappers {
/**
* 编辑用户Request转用户模型
*
* @param userModiRequest
* @return
*/
@ -68,6 +75,7 @@ public interface UserMappers {
/**
* 校验工号唯一性Request转用户模型
*
* @param userWorkNumRequest
* @return
*/
@ -75,6 +83,7 @@ public interface UserMappers {
/**
* 删除单条用户信息Request转用户模型
*
* @param userDeleteRequest
* @return
*/

View File

@ -0,0 +1,10 @@
package com.electromagnetic.industry.software.manage.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.electromagnetic.industry.software.manage.pojo.models.UserRole;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface UserRoleMapper extends BaseMapper<UserRole> {
}

View File

@ -0,0 +1,35 @@
package com.electromagnetic.industry.software.manage.pojo.models;
import com.baomidou.mybatisplus.annotation.TableField;
import lombok.Data;
import lombok.experimental.Accessors;
import java.util.Date;
@Accessors(chain = true)
@Data
public class BaseModel {
/**
* 创建时间
*/
@TableField(value = "created_time")
private Date createdTime;
/**
* 创建人
*/
@TableField(value = "created_by")
private String createdBy;
/**
* 最后更新时间
*/
@TableField(value = "updated_time")
private Date updatedTime;
/**
* 最后更新人
*/
@TableField(value = "updated_by")
private String updatedBy;
}

View File

@ -1,84 +0,0 @@
package com.electromagnetic.industry.software.manage.pojo.models;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@Data
@TableName("ed_category")
public class Category {
/**
* 主键ID
*/
private Long id;
/**
* 目录类型ID
*/
private String categoryTypeId;
/**
* 上级编码为空则为一级
*/
private String parentId;
/**
* 目录编码
*/
private String categoryId;
/**
* 目录名称
*/
private String categoryName;
/**
* 目录状态
*/
private String categoryStatus;
/**
* 创建人
*/
private String creator;
/**
* 创建人姓名
*/
private String creatorName;
/**
* 创建时间
*/
private Date gmtCreate;
/**
* 编辑人
*/
private String modifier;
/**
* 编辑人姓名
*/
private String modifierName;
/**
* 编辑时间
*/
private Date gmtModified;
/**
* 是否有效0-无效 1-有效
*/
private int effectFlag;
/**
* 子目录
*/
@TableField(exist = false)
private List<Category> children = new ArrayList<>();
}

View File

@ -1,99 +0,0 @@
package com.electromagnetic.industry.software.manage.pojo.models;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.util.Date;
@TableName("ed_data_info")
@Data
public class EDDataInfo {
/**
* 主键ID
*/
private Long id;
/**
* 目录编码
*/
private String categoryId;
/**
* 数据编码
*/
private String dataId;
/**
* 数据可视化码
*/
private String dataNo;
/**
* 数据名称
*/
private String dataName;
/**
* 数据类型folder文件夹file文件
*/
private String dataType;
/**
* 文件类型
*/
private String fileType;
/**
* 当前版本
*/
private String version;
/**
* 富文本内容
*/
private String content;
/**
* 文件地址JSON
*/
private String implantJson;
/**
* 状态publish:发布occupy:占用
*/
private String dataStatus;
/**
* 备注
*/
private String note;
/**
* 编辑人
*/
private String editor;
/**
* 批量上传时间
*/
private Date gmtBatchUpload;
/**
* 保存状态
*/
private String saveStatus;
/**
* 创建人
*/
private String creator;
/**
* 创建人姓名
*/
private String creatorName;
/**
* 创建时间
*/
private Date gmtCreate;
/**
* 更新人
*/
private String modifier;
/**
* 更新人姓名
*/
private String modifierName;
/**
* 更新时间
*/
private Date gmtModified;
/**
* 是否有效:0-无效 1-有效
*/
private Integer effectFlag;
}

View File

@ -0,0 +1,143 @@
package com.electromagnetic.industry.software.manage.pojo.models;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.electromagnetic.industry.software.common.enums.EffectFlagEnum;
import com.electromagnetic.industry.software.common.util.EleCommonUtil;
import com.electromagnetic.industry.software.common.util.IdWorker;
import com.electromagnetic.industry.software.common.util.UserThreadLocal;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import lombok.experimental.FieldNameConstants;
import java.util.Date;
@EqualsAndHashCode(callSuper = true)
@TableName("ed_file_info")
@Accessors(chain = true)
@Data
@FieldNameConstants
public class EdFileInfo extends BaseModel {
/**
* 主键ID
*/
@TableField(value = "id")
private String id;
/**
* 文件id如果是第一个版本则和id一致同一个文件不同版本file_id是一致的
*/
@TableField(value = "file_id")
private String fileId;
/**
* 父目录id
*/
@TableField(value = "parent_id")
private String parentId;
/**
* 文件类型
*/
@TableField(value = "file_type")
private String fileType;
/**
* 文件名
*/
@TableField(value = "file_name")
private String fileName;
/**
* 文件备注
*/
@TableField(value = "file_note")
private String fileNote;
/**
* 文件内容
*/
@TableField(value = "file_content")
private String fileContent;
/**
* 文件当前版本文件版本号默认从100开始
*/
@TableField(value = "file_version")
private Integer fileVersion;
/**
* 文件时间文件编号的最后15位精确到毫秒
*/
@TableField(value = "file_time")
private String fileTime;
/**
* 文件路径指到文件的父目录有各个父目录的id加下划线组成
*/
@TableField(value = "file_path")
private String filePath;
/**
* 数据类型0-文件夹 1-文件
*/
@TableField(value = "data_type")
private Integer dataType;
/**
* 数据状态0-发布 1-占用
*/
@TableField(value = "data_status")
private Integer dataStatus;
/**
* 文件的上一个版本号
*/
@TableField(value = "pre_version")
private Integer preVersion;
/**
* 是否有效 0-无效 1-有效
*/
@TableField(value = "effect_flag")
private Integer effectFlag;
/**
* 保存状态0-上传中 1-上传成功 2-上传失败
*/
@TableField(value = "save_status")
private Integer saveStatus;
/**
* 文件大小
*/
@TableField(value = "file_size")
private Long fileSize;
/**
* 文件夹顺序
*/
@TableField(value = "sort")
private Integer sort;
/**
* 文件编码
*/
@TableField(value = "file_code")
private String fileCode;
/**
* 是否是管理员定义的系统层级目录
*/
@TableField(value = "prj_dir")
private Boolean prjDir;
/** 当一个文件作废时其所有的历史文件也会跟着作废此时该文件及其历史文件的all_deleted=true**/
@TableField(value = "all_deleted")
private Boolean allDeleted;
/**
* 当文件被管理员永久物理删除此时为true
*/
@TableField(value = "permanent_deleted")
private Boolean permanentDeleted;
public void newInit() {
String userId = UserThreadLocal.getUserId();
String newFileDbId = IdWorker.getSnowFlakeIdString();
String fileTime = EleCommonUtil.getNowTimeStr();
Date now = new Date();
this.setUpdatedBy(userId);
this.setId(newFileDbId);
this.setUpdatedTime(now);
this.setCreatedTime(now);
this.setFileTime(fileTime);
this.setCreatedBy(userId);
this.setFileId(newFileDbId);
this.setEffectFlag(EffectFlagEnum.EFFECT.code);
}
}

View File

@ -0,0 +1,50 @@
package com.electromagnetic.industry.software.manage.pojo.models;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.util.Date;
@Data
@TableName("ed_file_relation")
public class EdFileRelation {
private String id;
/**
* 文件1 主键id
*/
@TableField(value = "file_id_1")
private String id1;
/**
* 文件2 主键id
*/
@TableField(value = "file_id_2")
private String id2;
/**
* 关系描述
*/
private String relationship;
/**
* 创建者 用户id
*/
@TableField(value = "created_by")
private String createdBy;
@TableField(value = "created_at", fill = FieldFill.INSERT)
private Date createdAt;
/**
* 更新者 用户id
*/
@TableField(value = "updated_by")
private String updatedBy;
@TableField(value = "updated_at", fill = FieldFill.UPDATE)
private Date updatedAt;
}

View File

@ -0,0 +1,20 @@
package com.electromagnetic.industry.software.manage.pojo.models;
import lombok.Data;
import lombok.Getter;
@Data
@Getter
public class Edge {
String source; // 起点
String target; // 终点
String relationId; //关系id
String relationship; //关系描述
public Edge(String source, String target, String relationId, String relationship) {
this.source = source;
this.target = target;
this.relationId = relationId;
this.relationship = relationship;
}
}

View File

@ -0,0 +1,67 @@
package com.electromagnetic.industry.software.manage.pojo.models;
import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;
import java.util.Date;
@Data
@TableName("ed_role") // 指定表名
public class Role {
@TableId(type = IdType.AUTO)
private Long id;
/**
* 角色编码
*/
@TableField(value = "role_id")
private String roleId;
/**
* 角色名称
*/
@TableField(value = "role_name")
private String roleName;
/**
* 角色描述
*/
@TableField(value = "role_desc")
private String roleDesc;
/**
* 创建者用户编码
*/
private String creator;
/**
* 创建者姓名
*/
@TableField(value = "creator_name")
private String creatorName;
/**
* 创建时间
*/
@TableField(value = "gmt_create", fill = FieldFill.INSERT)
private Date gmtCreate;
/**
* 编辑者用户编码
*/
private String modifier;
/**
* 编辑者姓名
*/
@TableField(value = "modifier_name")
private String modifierName;
/**
* 编辑时间
*/
@TableField(value = "gmt_modified", fill = FieldFill.INSERT_UPDATE)
private Date gmtModified;
}

View File

@ -0,0 +1,43 @@
package com.electromagnetic.industry.software.manage.pojo.models;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.AllArgsConstructor;
import lombok.Data;
@Data
@TableName("ed_role_permission")
@AllArgsConstructor
public class RolePermission {
/**
* 主键id
*/
@TableField(value = "id")
private Long id;
/**
* 角色编码
*/
@TableField(value = "role_id")
private String roleId;
/**
* 文件编码
*/
@TableField(value = "file_id")
private String fileId;
/**
* 权限标识
*/
@TableField(value = "permission_code")
private String permissionCode;
public RolePermission(String roleId, String fileId, String permissionCode) {
this.roleId = roleId;
this.fileId = fileId;
this.permissionCode = permissionCode;
}
}

View File

@ -44,6 +44,11 @@ public class User {
*/
private String userTitle;
/**
* 账户
*/
private String userAccount;
/**
* 登录密码
*/
@ -65,10 +70,20 @@ public class User {
private Date internshipEndDate;
/**
* 是否已发布
* 管理员类型
*/
private String adminType;
/**
* 是否已发布系统管理员
*/
private Integer isPublished;
/**
* 是否已激活安全管理员
*/
private Integer isActivated;
/**
*
*/

View File

@ -0,0 +1,22 @@
package com.electromagnetic.industry.software.manage.pojo.models;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
@Data
@TableName("ed_user_role")
public class UserRole {
/**
* 用户编码
*/
@TableField(value = "user_id")
private String userId;
/**
* 角色编码
*/
@TableField(value = "role_id")
private String roleId;
}

View File

@ -1,23 +0,0 @@
package com.electromagnetic.industry.software.manage.pojo.other;
import com.electromagnetic.industry.software.manage.pojo.models.EDDataInfo;
import com.github.pagehelper.PageInfo;
import lombok.Data;
import java.io.Serializable;
/**
* 分页综合返回
* @author
* @version $Id: IndicatorCardPage.java, v 0.1 2024-08-14 17:30
*/
@Data
public class EDDataPage implements Serializable {
private static final long serialVersionUID = -6207631048120337133L;
/**
* 电磁数据-文件数据列表
*/
private PageInfo<EDDataInfo> edDataInfo;
}

View File

@ -1,80 +0,0 @@
package com.electromagnetic.industry.software.manage.pojo.other;
import lombok.Data;
import org.springframework.web.multipart.MultipartFile;
import java.io.Serializable;
import java.util.Date;
@Data
public class EDDataParams implements Serializable {
private static final long serialVersionUID = -4835122199589863011L;
/**
* 当前页
*/
private Integer pageIndex = 1;
/**
* 每页数据
*/
private Integer pageSize = 10;
/**
* 操作用户id
*/
private String userId;
/**
* 用户名
*/
private String userName;
/**
* 上级文件夹数据码,为空是顶级
*/
private String parentId;
/**
* 文件数据编码
*/
private String dataId;
/**
* 文件夹名称
*/
private String name;
/**
* 文件类型
*/
private String dataType;
/**
* 创建日期排序
*/
private String gmtCreate;
/**
* 文件数据状态
*/
private String dataStatus;
/**
* 备注
*/
private String note;
/**
* 是否有效
*/
private String effectFlag;
/**
* 关键词
*/
private String keyWord;
/**
* 批量上传时间
*/
private Date gmtBatchUpload;
/**
* 保存状态
*/
private String saveStatus;
/**
* 文件数据编码数组
*/
private String[] dataIdArr;
/**
* 文件数据
*/
private MultipartFile fileData;
}

View File

@ -0,0 +1,44 @@
package com.electromagnetic.industry.software.manage.pojo.other;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import java.util.Date;
@Data
public class FileInfoVO {
private String id;
private String fileId;
private String fileType;
private String fileName;
private String fileNote;
private Integer fileVersion;
private String parentId;
private Integer dataType;
private Integer dataStatus;
private Integer saveStatus;
private long fileSize;
private String fileSizeShow;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date updatedTime;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date createdTime;
private String fileCode;
private String createdBy;
}

View File

@ -19,6 +19,11 @@ public class SearchKeyWords {
*/
private String isPublished;
/**
* 用户激活状态
*/
private String isActivated;
/**
* 排序方式: "asc" "desc"
*/

View File

@ -4,6 +4,7 @@ import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import java.util.Date;
import java.util.List;
@Data
public class SingleUserResponse {
@ -45,10 +46,25 @@ public class SingleUserResponse {
*/
private String userTitle;
/**
* 账户
*/
private String userAccount;
/**
* 登录密码
*/
private String userPwd;
// private String userPwd;
/**
* 角色名称拼接字符串
*/
private String roles;
/**
* 角色名称列表
*/
private List<String> roleList;
/**
* 入职日期
@ -72,10 +88,20 @@ public class SingleUserResponse {
*/
private Integer isPublished;
/**
* 是否已激活
*/
private Integer isActivated;
/**
* 是否和默认密码相同
*/
private Integer isDefaultPwd;
/**
*
*/
private String salt;
// private String salt;
/**
* 创建人

View File

@ -0,0 +1,17 @@
package com.electromagnetic.industry.software.manage.pojo.other;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import java.util.Date;
@Data
public class UploadRecordDTO {
private String id;
private String fileName;
private Integer saveStatus;
private String fileType;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date createdTime;
}

View File

@ -5,7 +5,7 @@ import lombok.Data;
import java.io.Serializable;
@Data
public class BaseRequest implements Serializable {
public class BaseRequest implements Serializable {
private static final long serialVersionUID = -9017146892952264211L;
@ -34,15 +34,15 @@ public class BaseRequest implements Serializable {
*/
private String appName;
/**
*人员编码
* 人员编码
*/
private String personNo;
/**
*人员姓名
* 人员姓名
*/
private String personName;
/**
* 权限码
* 权限码
*/
private String permissionCode;

View File

@ -0,0 +1,22 @@
package com.electromagnetic.industry.software.manage.pojo.req;
import lombok.Data;
@Data
public class CheckNameUniqueRequest {
/**
* 目录id
*/
private String parentId;
/**
* 文件名称
*/
private String fileName;
/**
* 文件后缀
*/
private String fileType;
}

View File

@ -0,0 +1,14 @@
package com.electromagnetic.industry.software.manage.pojo.req;
import lombok.Data;
@Data
public class CreateFolderDTO {
private String parentId;
private String newFolderName;
private String fileNote;
}

View File

@ -0,0 +1,68 @@
package com.electromagnetic.industry.software.manage.pojo.req;
import lombok.Data;
@Data
public class FileInfoQueryDTO {
/**
* 父文件夹id
*/
private String parentId;
/**
* 当前页码
*/
private Integer pageNum;
/**
* 每页的数量
*/
private Integer pageSize;
/**
* 搜索关键词
*/
private String keyword;
/**
* 文件名排序 0-升序1-降序
*/
private Integer fileNameSort;
/**
* 文件类型 0-升序1-降序
*/
private Integer fileTypeSort;
/**
* 文件类型过滤
*/
private String fileType;
/**
* 上传时间0-升序1-降序
*/
private Integer createdTime;
/**
* 修改时间0-升序1-降序
*/
private Integer updatedTime;
/**
* 版本号0-升序1-降序
*/
private Integer fileVersion;
/**
* 文件大小0-升序1-降序
*/
private Integer fileSizeSort;
/**
* 状态0-未发布 1-已发布 2-占用
*/
private Integer dataStatus;
}

View File

@ -0,0 +1,9 @@
package com.electromagnetic.industry.software.manage.pojo.req;
import lombok.Data;
@Data
public class FolderResortDTO {
private String id;
private int sort;
}

View File

@ -0,0 +1,25 @@
package com.electromagnetic.industry.software.manage.pojo.req;
import com.electromagnetic.industry.software.common.enums.EffectFlagEnum;
import com.electromagnetic.industry.software.common.enums.PublishEnum;
import lombok.Data;
@Data
public class PublishedFileDTO {
private String fileId;
private Integer dataStatus;
private Integer effectFlag;
private Boolean prjDir;
public void newInit() {
this.setPrjDir(Boolean.TRUE);
this.setDataStatus(PublishEnum.PUBLISHED.getCode());
this.setEffectFlag(EffectFlagEnum.EFFECT.code);
}
}

View File

@ -0,0 +1,10 @@
package com.electromagnetic.industry.software.manage.pojo.req;
import lombok.Data;
import java.util.List;
@Data
public class QueryPublishStatus {
private List<String> prjIds;
}

View File

@ -0,0 +1,44 @@
package com.electromagnetic.industry.software.manage.pojo.req;
import lombok.Data;
import java.util.List;
@Data
public class RoleDTO {
/**
* 角色编号
*/
private String roleId;
/**
* 角色姓名
*/
private String roleName;
/**
* 角色描述
*/
private String roleDesc;
/**
* 数据权限
*/
private String dataScope;
/**
* 功能权限
*/
private String allowedActions;
/**
* 是否绑定用户
*/
private Boolean isBind;
/**
* 权限数据
*/
private List<RolePermissionDTO> data;
}

View File

@ -0,0 +1,26 @@
package com.electromagnetic.industry.software.manage.pojo.req;
import lombok.Data;
@Data
public class RolePageDTO {
/**
* 角色编号
*/
private String roleId;
/**
* 角色姓名
*/
private String roleName;
/**
* 页码
*/
private Integer pageIndex;
/**
* 页数据量
*/
private Integer pageSize;
}

View File

@ -0,0 +1,40 @@
package com.electromagnetic.industry.software.manage.pojo.req;
import lombok.Data;
import java.util.List;
import java.util.Map;
@Data
public class RolePermissionDTO {
/**
* 目录文件主键
*/
private String id;
/**
* 父ID
*/
private String parentId;
/**
* 目录文件名称
*/
private String fileName;
/**
* 数据权限
*/
private Map<String, Boolean> dataAuth;
/**
* 权限哈希
*/
private Map<String, Boolean> permission;
/**
* 子目录
*/
private List<RolePermissionDTO> children;
}

View File

@ -24,6 +24,11 @@ public class SearchUserRequest extends BaseRequest implements Serializable {
*/
private String isPublished;
/**
* 用户激活状态
*/
private String isActivated;
/**
* 排序方式: "asc" "desc"
*/

View File

@ -0,0 +1,12 @@
package com.electromagnetic.industry.software.manage.pojo.req;
import lombok.Data;
@Data
public class UpdateFileInfoDTO {
private String id;
private String fileName;
private String fileNote;
}

View File

@ -0,0 +1,11 @@
package com.electromagnetic.industry.software.manage.pojo.req;
import lombok.Data;
@Data
public class UpdateRelationDTO {
private String relationId;
private String relationship;
}

View File

@ -0,0 +1,20 @@
package com.electromagnetic.industry.software.manage.pojo.req;
import lombok.Data;
import java.util.List;
@Data
public class UserBindRoleDTO {
/**
* 用户编号
*/
String userId;
/**
* 角色名称列表角色名称唯一
*/
List<String> roleList;
}

View File

@ -39,7 +39,7 @@ public class UserRequest extends BaseRequest implements Serializable {
/**
* 入职日期
*/
@JsonFormat(pattern="yyyy-MM-dd")
@JsonFormat(pattern = "yyyy-MM-dd")
private Date joinTime;
/**
@ -50,7 +50,7 @@ public class UserRequest extends BaseRequest implements Serializable {
/**
* 实习截止日期
*/
@JsonFormat(pattern="yyyy-MM-dd")
@JsonFormat(pattern = "yyyy-MM-dd")
private Date internshipEndDate;
}

View File

@ -0,0 +1,9 @@
package com.electromagnetic.industry.software.manage.pojo.resp;
import lombok.Data;
@Data
public class ChildFolderVO {
private String id;
private String fileName;
}

View File

@ -0,0 +1,19 @@
package com.electromagnetic.industry.software.manage.pojo.resp;
import com.electromagnetic.industry.software.manage.pojo.other.FileInfoVO;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.ArrayList;
import java.util.List;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class FileInfoQueryPageVO {
private long total;
private List<FileInfoVO> records = new ArrayList<>();
}

View File

@ -0,0 +1,19 @@
package com.electromagnetic.industry.software.manage.pojo.resp;
import lombok.Data;
import lombok.experimental.FieldNameConstants;
import java.util.ArrayList;
import java.util.List;
@FieldNameConstants
@Data
public class FileProjectVO {
private String categoryId;
private String categoryName;
private String parentId;
private Integer dataStatus;
private Integer sort;
private List<FileProjectVO> children = new ArrayList<>();
}

View File

@ -0,0 +1,20 @@
package com.electromagnetic.industry.software.manage.pojo.resp;
import com.electromagnetic.industry.software.manage.pojo.models.Edge;
import lombok.Data;
import java.util.List;
@Data
public class FileRelationViewVO {
/**
* 关联文件
*/
List<FileSimpleInfoVO> nodes;
/**
*
*/
List<Edge> edges;
}

View File

@ -0,0 +1,37 @@
package com.electromagnetic.industry.software.manage.pojo.resp;
import lombok.Data;
@Data
public class FileSimpleInfoVO {
/**
* 主键id
*/
private String id;
/**
* 文件名称
*/
private String fileName;
/**
* 文件类型
*/
private String fileType;
/**
* 文件编号
*/
private String fileCode;
/**
* 文件版本
*/
private Integer fileVersion;
/**
* 是否有效
*/
private Integer effectFlag;
}

View File

@ -0,0 +1,15 @@
package com.electromagnetic.industry.software.manage.pojo.resp;
import lombok.Data;
@Data
public class FileVersionViewVO {
private String id;
private String fileName;
private Integer fileVersion;
private Integer preVersion;
private String fileCode;
private Integer effectFlag;
private String parentId;
private String fileId;
}

View File

@ -0,0 +1,21 @@
package com.electromagnetic.industry.software.manage.pojo.resp;
import lombok.Data;
import lombok.experimental.FieldNameConstants;
import java.util.ArrayList;
import java.util.List;
@FieldNameConstants
@Data
public class ProjectVO {
private String id;
private String fileName;
private String parentId;
private int sort;
private Integer dataStatus;
private String title;
private List<ProjectVO> children = new ArrayList<>();
}

View File

@ -0,0 +1,19 @@
package com.electromagnetic.industry.software.manage.pojo.resp;
import com.electromagnetic.industry.software.manage.pojo.other.UploadRecordDTO;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.ArrayList;
import java.util.List;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class UploadRecordVO {
private long total;
private List<UploadRecordDTO> records = new ArrayList<>();
}

View File

@ -10,4 +10,5 @@ public class UserLoginResponse implements Serializable {
private String token;
private String userId;
}

View File

@ -1,9 +0,0 @@
package com.electromagnetic.industry.software.manage.service;
import com.electromagnetic.industry.software.common.resp.ElectromagneticResult;
public interface CategoryService {
ElectromagneticResult<?> getAllCategories();
}

View File

@ -1,99 +0,0 @@
package com.electromagnetic.industry.software.manage.service;
import com.electromagnetic.industry.software.common.resp.ElectromagneticResult;
import com.electromagnetic.industry.software.manage.pojo.req.EDDataRequest;
import com.electromagnetic.industry.software.manage.pojo.req.FileChunkDTO;
import com.electromagnetic.industry.software.manage.pojo.req.FileChunkResultDTO;
import com.electromagnetic.industry.software.manage.pojo.resp.EDDataPageResponse;
import org.springframework.core.io.InputStreamResource;
import org.springframework.http.ResponseEntity;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
import java.util.Map;
public interface EDDataService {
/**
* 创建文件夹
* @param request
* @return
*/
ElectromagneticResult<Boolean> createFolder(EDDataRequest request);
/**
* 获取文件信息列表
* @param request
* @return
*/
ElectromagneticResult<EDDataPageResponse> getDataInfoList(EDDataRequest request);
/**
* 更新文件信息
* @param request
* @return
*/
ElectromagneticResult<Boolean> updateFileInfo(EDDataRequest request);
/**
* 获取子文件数量
* @param request
* @return
*/
ElectromagneticResult<Map<String, Integer>> getChildFileCount(EDDataRequest request);
/**
* 上传
* @param request
* @return
*/
ElectromagneticResult<Boolean> uploadFile(EDDataRequest request);
/**
* 下载
*
* @param dataId
* @return
*/
ResponseEntity<InputStreamResource> download(String dataId, HttpServletResponse response) throws IOException;
/**
* 导出数据
* @param dataIdArr
* @return
*/
ResponseEntity<InputStreamResource> batchExport(String dataIdArr, HttpServletResponse response) throws IOException;
/**
* 导入数据
* @param fileChunkDTO
* @return
*/
ElectromagneticResult<?> batchImport(FileChunkDTO fileChunkDTO);
/**
* 获取已经上传的分片
* @param identifier
* @return
*/
ElectromagneticResult<List<Integer>> getUploadedChunkNums(String identifier);
/**
* 合并分片
* @param identifier
* @param fileName
* @param totalChunks
* @return
*/
ElectromagneticResult<?> mergeChunks(String identifier, String fileName, Integer totalChunks);
/**
* 检查分片是否存在
* @param fileChunkDTO
* @return
*/
ElectromagneticResult<FileChunkResultDTO> checkChunkExist(FileChunkDTO fileChunkDTO);
}

View File

@ -0,0 +1,174 @@
package com.electromagnetic.industry.software.manage.service;
import com.electromagnetic.industry.software.common.resp.ElectromagneticResult;
import com.electromagnetic.industry.software.manage.pojo.models.EdFileInfo;
import com.electromagnetic.industry.software.manage.pojo.req.CreateFolderDTO;
import com.electromagnetic.industry.software.manage.pojo.req.FileChunkDTO;
import com.electromagnetic.industry.software.manage.pojo.req.FileInfoQueryDTO;
import com.electromagnetic.industry.software.manage.pojo.req.UpdateFileInfoDTO;
import org.springframework.core.io.InputStreamResource;
import org.springframework.http.ResponseEntity;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
public interface EdFileInfoService {
/**
* 查询文件列表
*
* @param fileInfoQueryDTO
* @return
*/
ElectromagneticResult<?> queryEdFileInfo(FileInfoQueryDTO fileInfoQueryDTO);
/**
* 新建文件夹
*
* @return
*/
ElectromagneticResult<?> createFolder(CreateFolderDTO createFolderDTO);
/**
* 项目层级结构查询
*
* @return
*/
ElectromagneticResult<?> tree();
/**
* 删除目录
*
* @param id
* @return
*/
ElectromagneticResult<?> delete(String id);
/**
* 下载文件
*
* @param id
* @return
*/
ResponseEntity<InputStreamResource> download(String id, HttpServletResponse response);
/**
* 更新文件信息
*
* @param updateFileInfoDTO
*/
ElectromagneticResult<?> updateFileInfo(UpdateFileInfoDTO updateFileInfoDTO);
/**
* 版本回退
*
* @param fileId
* @param targetVersion
* @return
*/
ElectromagneticResult<?> versionBack(String fileId, int targetVersion);
/**
* 查看分片是否存在
*
* @param fileChunkDTO
* @return
*/
ElectromagneticResult<?> checkChunkExist(FileChunkDTO fileChunkDTO);
/**
* 批量导入
*
* @param fileChunkDTO
* @return
*/
ElectromagneticResult<?> batchImport(FileChunkDTO fileChunkDTO);
/**
* 合并分片
*
* @param identifier
* @param fileName
* @param totalChunks
* @return
*/
ElectromagneticResult<?> mergeChunks(String identifier, String fileName, Integer totalChunks);
/**
* 导出
*
* @param dataIdArr
* @return
*/
ResponseEntity<InputStreamResource> batchExport(String dataIdArr, HttpServletResponse response) throws IOException;
/**
* 文件上传
*
* @param parentId
* @param file
* @param strategy
* @return
*/
ElectromagneticResult<?> upload(String parentId, MultipartFile file, Integer strategy);
/**
* 版本查看
*
* @param fileId
* @return
*/
ElectromagneticResult<?> versionView(String fileId);
/**
* 移动文件
*
* @param id
* @param targetFolderId
* @return
*/
ElectromagneticResult<?> moveFile(String id, String targetFolderId, Integer strategy);
/**
* 复制文件
*
* @param id
* @param targetFolderId
* @return
*/
ElectromagneticResult<?> copyFile(String id, String targetFolderId, Integer strategy);
/**
* 发布管理
*
* @return
*/
ElectromagneticResult<?> uploadRecord(int pageNum, int pageSize);
/**
* 查询文件详情
*
* @param id
* @return
*/
ElectromagneticResult<?> detail(String id);
/**
* 获取文件的层级Id
*/
String getCategoryId (String id);
/**
* 根据父id查询其下自定义的文件夹
* @param parentId
* @return
*/
ElectromagneticResult<?> queryChildFolder(String parentId);
/**
* 处理重名文件文件名后+_1
* @param fileInfo
*/
void resetFileInfoName(EdFileInfo fileInfo);
}

View File

@ -0,0 +1,52 @@
package com.electromagnetic.industry.software.manage.service;
import com.electromagnetic.industry.software.common.resp.ElectromagneticResult;
import com.electromagnetic.industry.software.manage.pojo.models.EdFileRelation;
import com.electromagnetic.industry.software.manage.pojo.req.CheckNameUniqueRequest;
import com.electromagnetic.industry.software.manage.pojo.resp.FileRelationViewVO;
import org.springframework.web.multipart.MultipartFile;
public interface EdFileRelationService {
/**
* 创建文件关系
*
* @param edFileRelation
* @return
*/
Boolean createRelation(EdFileRelation edFileRelation);
/**
* 取消文件关系
*
* @param id
* @return
*/
Boolean cancelRelation(String id);
/**
* 获取关系展示数据
*
* @param id
* @return
*/
FileRelationViewVO listRelations(String id);
/**
* 检查文件名是否唯一
*
* @return
*/
Boolean checkNameExist(CheckNameUniqueRequest checkNameUniqueRequest);
/**
* 文件上传并建立关系
*
* @param parentId
* @param id 主文件Id
* @param file
* @param descrption 关系描述
* @return
*/
ElectromagneticResult<?> uploadFileAndRelation(String parentId, String id, MultipartFile file, String descrption);
}

View File

@ -0,0 +1,100 @@
package com.electromagnetic.industry.software.manage.service;
import com.electromagnetic.industry.software.common.resp.ElectromagneticResult;
import com.electromagnetic.industry.software.manage.pojo.req.FolderResortDTO;
import com.electromagnetic.industry.software.manage.pojo.req.QueryPublishStatus;
import java.util.List;
public interface EdPrjService {
/**
* 创建一个新的工程
*
* @param prjName 新的工程名
*/
ElectromagneticResult<?> createNewPrj(String prjName);
/**
* 修改项目名称
*
* @param prjId
* @param newPrjName
* @return
*/
ElectromagneticResult<?> modifyPrjName(String prjId, String newPrjName);
/**
* 删除一个项目做逻辑删除
*
* @param prjId
* @return
*/
ElectromagneticResult<?> delete(String prjId);
/**
* 添加子集
*
* @param parentId
* @param folderName
* @return
*/
ElectromagneticResult<?> addFolder(String parentId, String folderName);
/**
* 查询所有项目
*
* @return
*/
ElectromagneticResult<?> queryAllPrjInfo();
/**
* 子集拖拽重排序
*
* @param folderResortDTOList
* @return
*/
ElectromagneticResult<?> folderResort(List<FolderResortDTO> folderResortDTOList);
/**
* 项目发布
*
* @param prjId
* @return
*/
ElectromagneticResult<?> publish(String prjId);
/**
* 删除子集
*
* @param id
* @return
*/
ElectromagneticResult<?> deleteFolder(String id);
/**
* 层级沿用
*
* @param sourceId
* @param targetId
* @return
*/
ElectromagneticResult<?> follow(String sourceId, String targetId);
/**
* 修改子集名称
*
* @param id
* @param newFolderName
* @return
*/
ElectromagneticResult<?> modifyFolder(String id, String newFolderName);
/**
* 获取项目的发布状态
*
* @param queryPublishStatus
* @return
*/
ElectromagneticResult<?> publishStatus(QueryPublishStatus queryPublishStatus);
}

View File

@ -0,0 +1,24 @@
package com.electromagnetic.industry.software.manage.service;
import java.io.InputStream;
public interface FileSystemService {
void createDirectory(String path);
void copyFile(String source, String destination);
void moveFile(String source, String destination);
void save(InputStream inputStream, String destination);
void renameFile(String sourcePath, String newName);
void renameFile(String sourcePath, String sourceName, String newName);
boolean checkFolderExist(String newPath);
boolean writeStringToFile(String filePath, String contents);
boolean deleteFile(String... filePaths);
}

View File

@ -0,0 +1,60 @@
package com.electromagnetic.industry.software.manage.service;
import java.util.List;
import java.util.Map;
public interface PermissionService {
/**
* 查询当前用户在当前目录的功能权限
*
* @param userId
* @param id
* @return
*/
Map<String, Boolean> getUserPermission(String userId, String id, Boolean includeView);
/**
* 获取当前用户有权限访问的目录id
*
* @return
*/
List<String> getAccessibleTree();
/**
* 获得当前角色权限
*
* @param roleId
* @param fileId
* @return
*/
List<String> getPermissionCodes(String roleId, String fileId);
/**
* 用户权限列表 转换为 哈希
*
* @param permissionCodes
* @return
*/
Map<String, Boolean> transToMap(List<String> permissionCodes, Boolean includeView);
/**
* 过滤有导出权限的文件id
* @param ids
*/
Map<String, Boolean> filterExportIds(String[] ids);
/**
* 同步权限
*/
void syncPermissions (String prjId);
/**
* 判断用户有无权限
* @param permissionCode 权限
* @param userId 用户编码
* @param fileId 文件编码
* @return
*/
boolean isPermitted (String permissionCode, String userId, String fileId);
}

View File

@ -0,0 +1,33 @@
package com.electromagnetic.industry.software.manage.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.electromagnetic.industry.software.manage.pojo.models.EdFileInfo;
import com.electromagnetic.industry.software.manage.pojo.models.RolePermission;
import com.electromagnetic.industry.software.manage.pojo.req.PublishedFileDTO;
import org.apache.ibatis.annotations.Param;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
public interface RolePermissionService extends IService<RolePermission> {
/**
* 同步新权限
* @param currentPermission
* @param infoId
*/
void syncNewPermissions (List<RolePermission> currentPermission, String infoId);
/**
* 获取新权限
* @param publishedFileDTO
* @return
*/
List<RolePermission> getCurrentPermission(PublishedFileDTO publishedFileDTO);
/**
* 在树形结构变动后同步权限
* @param prjId
*/
void syncPermissionsAfterTreeUpdate (List<EdFileInfo> files, String prjId);
}

View File

@ -0,0 +1,76 @@
package com.electromagnetic.industry.software.manage.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import com.electromagnetic.industry.software.manage.pojo.models.Role;
import com.electromagnetic.industry.software.manage.pojo.req.RoleDTO;
import com.electromagnetic.industry.software.manage.pojo.req.RolePageDTO;
import java.util.HashMap;
import java.util.List;
public interface RoleService extends IService<Role> {
/**
* 新建角色
*
* @param roleDTO
* @return
*/
Boolean createRole(RoleDTO roleDTO);
/**
* 更新角色
*
* @param roleDTO
* @return
*/
Boolean updateRole(RoleDTO roleDTO);
/**
* 删除角色
*
* @param roleId
* @return
*/
Boolean deleteRole(String roleId);
/**
* 查看角色
*
* @param roleId
* @return
*/
RoleDTO getRole(String roleId);
/**
* 查看角色列表
*
* @param rolePageDTO
* @return
*/
IPage<RoleDTO> getRoles(RolePageDTO rolePageDTO);
/**
* 获取所有角色名
*
* @return
*/
List<HashMap<String, String>> getAllRoleNames();
/**
* 通过角色名称查看角色权限
*
* @param roleName
* @return
*/
RoleDTO getRoleByName(String roleName);
/**
* 空树
*
* @return
*/
RoleDTO getRoleTemplate();
}

View File

@ -8,6 +8,7 @@ public interface TokenService {
/**
* 创建令牌
*
* @param loginInfo
* @return 令牌
*/
@ -15,6 +16,7 @@ public interface TokenService {
/**
* 创建用户令牌
*
* @param user
* @param tokenStr
* @return

View File

@ -0,0 +1,7 @@
package com.electromagnetic.industry.software.manage.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.electromagnetic.industry.software.manage.pojo.models.UserRole;
public interface UserRoleService extends IService<UserRole> {
}

View File

@ -3,10 +3,13 @@ package com.electromagnetic.industry.software.manage.service;
import com.electromagnetic.industry.software.common.resp.ElectromagneticResult;
import com.electromagnetic.industry.software.manage.pojo.req.*;
import java.util.List;
public interface UserService {
/**
* 用户登录
*
* @param loginRequest
* @return
*/
@ -14,6 +17,7 @@ public interface UserService {
/**
* 新增用户信息
*
* @param userRequest
* @return
*/
@ -21,6 +25,7 @@ public interface UserService {
/**
* 编辑用户信息
*
* @param userModiRequest
* @return
*/
@ -29,6 +34,7 @@ public interface UserService {
/**
* 发布用户
*
* @param userPublishRequest
* @return
*/
@ -36,6 +42,7 @@ public interface UserService {
/**
* 校验工号唯一性
*
* @param workNumberRequest
* @return
*/
@ -43,6 +50,7 @@ public interface UserService {
/**
* 通过用户编码获取单条用户信息
*
* @param getSingleUserRequest
* @return
*/
@ -50,6 +58,7 @@ public interface UserService {
/**
* 查询用户信息
*
* @param searchUserRequest
* @return
*/
@ -57,6 +66,7 @@ public interface UserService {
/**
* 刪除用戶逻辑删除
*
* @param userDeleteRequest
* @return
*/
@ -64,9 +74,21 @@ public interface UserService {
/**
* 用户登出
*
* @param token
* @return
*/
ElectromagneticResult<?> logout(String token);
/**
* 人员绑定
*/
Boolean bindRoles(List<UserBindRoleDTO> list);
/**
* 重置密码
*
* @param userId
*/
Boolean resetPassword(String userId);
}

View File

@ -1,82 +0,0 @@
package com.electromagnetic.industry.software.manage.service.serviceimpl;
import com.electromagnetic.industry.software.common.resp.ElectromagneticResult;
import com.electromagnetic.industry.software.common.util.ElectromagneticResultUtil;
import com.electromagnetic.industry.software.manage.mapper.CategoryMapper;
import com.electromagnetic.industry.software.manage.pojo.models.Category;
import com.electromagnetic.industry.software.manage.service.CategoryService;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.stream.Collectors;
@Service
public class CategoryServiceImpl implements CategoryService {
@Resource
private CategoryMapper categoryMapper;
@Override
public ElectromagneticResult<?> getAllCategories() {
List<Category> categories = categoryMapper.selectAllCategories();
List<Category> returnList = new ArrayList<>();
List<String> tempList = categories.stream().map(Category::getCategoryId).collect(Collectors.toList());
for (Category category : categories) {
if (!tempList.contains(category.getParentId())) {
recursionFn(categories, category);
returnList.add(category);
}
}
if (returnList.isEmpty()) {
returnList = categories;
}
return ElectromagneticResultUtil.success(returnList);
}
/**
* 递归列表
* @param list
* @param category
*/
private void recursionFn (List<Category> list, Category category) {
List<Category> childList = getChildList(list, category);
category.setChildren(childList);
for (Category child : childList) {
if (hasChild(list, child)) {
recursionFn(list, child);
}
}
}
/**
* 得到子节点列表
* @param list
* @param category
* @return
*/
private List<Category> getChildList(List<Category> list, Category category) {
List<Category> childList = new ArrayList<>();
Iterator<Category> it = list.iterator();
while (it.hasNext()) {
Category child = it.next();
if (!StringUtils.isEmpty(child.getParentId()) && child.getParentId().equals(category.getCategoryId())) {
childList.add(child);
}
}
return childList;
}
/**
* 判断是否有子节点
* @param list
* @param category
* @return
*/
private boolean hasChild(List<Category> list, Category category) {
return !getChildList(list, category).isEmpty();
}
}

View File

@ -0,0 +1,395 @@
package com.electromagnetic.industry.software.manage.service.serviceimpl;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.lang.Assert;
import cn.hutool.core.lang.tree.Tree;
import cn.hutool.core.lang.tree.TreeNodeConfig;
import cn.hutool.core.lang.tree.TreeUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.electromagnetic.industry.software.common.enums.EffectFlagEnum;
import com.electromagnetic.industry.software.common.enums.EleDataSaveStatusEnum;
import com.electromagnetic.industry.software.common.enums.EleDataStatusEnum;
import com.electromagnetic.industry.software.common.enums.EleDataTypeEnum;
import com.electromagnetic.industry.software.common.exception.BizException;
import com.electromagnetic.industry.software.common.resp.ElectromagneticResult;
import com.electromagnetic.industry.software.common.util.EleCommonUtil;
import com.electromagnetic.industry.software.common.util.EleLog;
import com.electromagnetic.industry.software.common.util.ElectromagneticResultUtil;
import com.electromagnetic.industry.software.common.util.UserThreadLocal;
import com.electromagnetic.industry.software.manage.mapper.EdFileInfoMapper;
import com.electromagnetic.industry.software.manage.pojo.models.EdFileInfo;
import com.electromagnetic.industry.software.manage.pojo.resp.FileProjectVO;
import com.electromagnetic.industry.software.manage.pojo.resp.ProjectVO;
import com.electromagnetic.industry.software.manage.service.FileSystemService;
import lombok.Getter;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import java.io.File;
import java.util.*;
import java.util.stream.Collectors;
import static com.electromagnetic.industry.software.common.cons.ElectromagneticConstants.*;
@Component
public class CommonService {
private static final Map<String, String> FILE_TYPE_ENUM = new HashMap<>();
static {
FILE_TYPE_ENUM.put(EleDataTypeEnum.FOLDER.desc, "01");
FILE_TYPE_ENUM.put("py", "02");
FILE_TYPE_ENUM.put("zip", "03");
FILE_TYPE_ENUM.put("jpg", "04");
FILE_TYPE_ENUM.put("jpeg", "05");
FILE_TYPE_ENUM.put("png", "06");
FILE_TYPE_ENUM.put("gif", "07");
FILE_TYPE_ENUM.put("bmp", "08");
FILE_TYPE_ENUM.put("tif", "09");
FILE_TYPE_ENUM.put("tiff", "10");
FILE_TYPE_ENUM.put("svg", "11");
FILE_TYPE_ENUM.put("psd", "12");
FILE_TYPE_ENUM.put("pdf", "13");
FILE_TYPE_ENUM.put("doc", "14");
FILE_TYPE_ENUM.put("docx", "15");
FILE_TYPE_ENUM.put("xls", "16");
FILE_TYPE_ENUM.put("xlsx", "17");
FILE_TYPE_ENUM.put("ppt", "18");
FILE_TYPE_ENUM.put("pptx", "19");
}
private final EleLog log = new EleLog(CommonService.class);
@Value("${prj.folder.max.length}")
private int prjFolderMaxLength;
@Getter
private String eleDataPath;
@Resource
private Environment environment;
@Resource
private EdFileInfoMapper edFileInfoMapper;
@Resource
private FileSystemService fileSystemService;
@PostConstruct
public void init() {
String osName = System.getProperty("os.name").toLowerCase();
eleDataPath = osName.startsWith("win") ? environment.getProperty("data.windows.path") : environment.getProperty("data.linux.path");
}
/**
* 检查同层级是否有同名的文件夹
*/
public boolean notExistSameFolder(String parentId, String newFolderName) {
Long count = edFileInfoMapper.selectCount(Wrappers.lambdaQuery(EdFileInfo.class)
.eq(EdFileInfo::getDataType, EleDataTypeEnum.FOLDER.code)
.eq(EdFileInfo::getParentId, parentId)
.eq(EdFileInfo::getEffectFlag, EffectFlagEnum.EFFECT.code)
.eq(EdFileInfo::getFileName, newFolderName));
return count == 0;
}
public String getFileSysPath(String dbPath) {
ArrayList<String> paths = CollUtil.newArrayList(dbPath.split(MYSQL_FILE_PATH_SPLIT));
String path = getDbPath(paths);
return eleDataPath + File.separator + path;
}
public String getDbPath(String dbPath) {
List<String> paths = CollUtil.newArrayList(dbPath.split(MYSQL_FILE_PATH_SPLIT));
return getDbPath(paths);
}
private String getDbPath(List<String> ids) {
LambdaQueryWrapper<EdFileInfo> queryWrapper = Wrappers.lambdaQuery(EdFileInfo.class)
.select(EdFileInfo::getId, EdFileInfo::getFileName, EdFileInfo::getDataType, EdFileInfo::getFileType, EdFileInfo::getFileCode)
.in(EdFileInfo::getId, ids);
List<EdFileInfo> edFileInfos = edFileInfoMapper.selectList(queryWrapper);
Map<String, EdFileInfo> map = edFileInfos.stream().collect(Collectors.toMap(EdFileInfo::getId, e -> e));
StringBuilder path = new StringBuilder();
for (String id : ids) {
EdFileInfo fileInfo = map.get(id);
String tmp;
if (fileInfo.getDataType().equals(EleDataTypeEnum.FILE.code)) {
tmp = fileInfo.getFileName() + "." + fileInfo.getFileType() + "." + fileInfo.getFileCode();
} else {
tmp = fileInfo.getFileName() + File.separator;
}
path.append(tmp);
}
return path.toString();
}
public String createFileCode(String parentId, String fileType, int version, String timeStr) {
return parentId + FILE_TYPE_ENUM.getOrDefault(fileType, "00") + version + timeStr;
}
public List<EdFileInfo> selectAllAdminFolder(String id, boolean isAdminQuery, List<String> accessableIds) {
LambdaQueryWrapper<EdFileInfo> queryWrapper = Wrappers.lambdaQuery(EdFileInfo.class)
.eq(EdFileInfo::getEffectFlag, EffectFlagEnum.EFFECT.code)
.eq(EdFileInfo::getDataType, EleDataTypeEnum.FOLDER.code)
.eq(EdFileInfo::getPrjDir, true)
.likeRight(EdFileInfo::getFilePath, id);
if (!isAdminQuery) {
queryWrapper.in(EdFileInfo::getId, accessableIds);
}
return edFileInfoMapper.selectList(queryWrapper);
}
@Transactional(rollbackFor = Exception.class)
public ElectromagneticResult<?> addFolder(String parentId, String folderName, boolean maxLengthCheck, boolean isPrjDir, String folderId, String fileNote) {
// 验证名称是否合法
Assert.isTrue(EleCommonUtil.isFileNameValid(folderName), NAME_VALID_MSG);
// 检查名称是否存在
Assert.isTrue(notExistSameFolder(parentId, folderName), "该名称已存在");
LambdaQueryWrapper<EdFileInfo> queryWrapper = Wrappers.lambdaQuery(EdFileInfo.class)
.select(EdFileInfo::getId, EdFileInfo::getFilePath)
.eq(EdFileInfo::getId, parentId);
EdFileInfo edFileInfo = edFileInfoMapper.selectOne(queryWrapper);
String currentPath = edFileInfo.getFilePath();
List<String> paths = CollUtil.newArrayList(edFileInfo.getFilePath().split(MYSQL_FILE_PATH_SPLIT));
if (maxLengthCheck) {
if (paths.size() >= prjFolderMaxLength) {
String info = "当前子集已达到最大层级,禁止创建子集。";
log.error(info);
return ElectromagneticResultUtil.fail("-1", info);
}
}
List<EdFileInfo> edFileInfos = edFileInfoMapper.selectList(Wrappers.lambdaQuery(EdFileInfo.class)
.select(EdFileInfo::getId, EdFileInfo::getFileName)
.eq(EdFileInfo::getEffectFlag, EffectFlagEnum.EFFECT.code)
.eq(EdFileInfo::getDataType, EleDataTypeEnum.FOLDER.code)
.eq(EdFileInfo::getParentId, parentId));
List<String> names = edFileInfos.stream().map(EdFileInfo::getFileName).collect(Collectors.toList());
try {
Date now = new Date();
String currentUserId = UserThreadLocal.getUserId();
String path = currentPath + MYSQL_FILE_PATH_SPLIT + folderId;
EdFileInfo fileInfo = new EdFileInfo();
String nowTimeStr = EleCommonUtil.getNowTimeStr();
fileInfo.setId(folderId)
.setFileId(folderId)
.setFileName(folderName)
.setFileVersion(FILE_START_VERSION)
.setParentId(parentId)
.setFileType("文件夹")
.setFileCode(createFileCode(parentId, EleDataTypeEnum.FOLDER.desc, FILE_START_VERSION, nowTimeStr))
.setFileTime(nowTimeStr)
.setPrjDir(isPrjDir)
.setDataType(EleDataTypeEnum.FOLDER.code)
.setDataStatus(isPrjDir ? EleDataStatusEnum.NOT_PUBLISHED.code : EleDataStatusEnum.PUBLISHED.code)
.setEffectFlag(EffectFlagEnum.EFFECT.code)
.setSaveStatus(EleDataSaveStatusEnum.SUCCESS.code)
.setFilePath(path)
.setSort(names.size() + 1)
.setFileNote(fileNote)
.setCreatedTime(now)
.setUpdatedTime(now)
.setCreatedBy(currentUserId)
.setUpdatedBy(currentUserId);
edFileInfoMapper.insert(fileInfo);
// 保存到文件系统
String targetFilePath = getEleDataPath() + File.separator + getDbPath(paths) + File.separator + folderName;
fileSystemService.createDirectory(targetFilePath);
return ElectromagneticResultUtil.success(true);
} catch (Exception e) {
String info = "添加失败";
log.error(info, e);
throw new BizException(info);
}
}
public List<String> queryAllPrjInfo(boolean isAdminQuery, List<String> prjIds) {
try {
LambdaQueryWrapper<EdFileInfo> queryWrapper = Wrappers.lambdaQuery(EdFileInfo.class)
.select(EdFileInfo::getId)
.eq(EdFileInfo::getParentId, PRJ_PARENT_ID)
.eq(EdFileInfo::getEffectFlag, EffectFlagEnum.EFFECT.code);
if (!isAdminQuery) {
queryWrapper.eq(EdFileInfo::getDataStatus, EleDataStatusEnum.PUBLISHED.code).in(EdFileInfo::getId, prjIds);
}
List<String> ids = edFileInfoMapper.selectList(queryWrapper).stream().map(EdFileInfo::getId).collect(Collectors.toList());
List<String> projectVOS = new ArrayList<>();
for (String id : ids) {
List<EdFileInfo> edFileInfos = selectAllAdminFolder(id, isAdminQuery, prjIds);
if (!isAdminQuery) {
edFileInfos = edFileInfos.stream().filter(e -> e.getDataStatus().equals(EleDataStatusEnum.PUBLISHED.code)
|| e.getDataStatus().equals(EleDataStatusEnum.DELETED.code))
.collect(Collectors.toList());
} else {
edFileInfos = edFileInfos.stream().filter(e -> !e.getDataStatus().equals(EleDataStatusEnum.DELETED.code)).collect(Collectors.toList());
}
// 转换为树
if (isAdminQuery) {
TreeNodeConfig config = new TreeNodeConfig();
config.setIdKey(EdFileInfo.Fields.id);
config.setParentIdKey(EdFileInfo.Fields.parentId);
config.setWeightKey(EdFileInfo.Fields.sort);
List<Tree<String>> trees = TreeUtil.build(edFileInfos, PRJ_PARENT_ID, config, ((obj, treeNode) -> {
treeNode.putExtra(ProjectVO.Fields.id, obj.getId());
treeNode.putExtra(ProjectVO.Fields.parentId, obj.getParentId());
treeNode.putExtra(ProjectVO.Fields.sort, obj.getSort());
treeNode.putExtra(ProjectVO.Fields.fileName, obj.getFileName());
treeNode.putExtra(ProjectVO.Fields.title, obj.getFileName());
treeNode.putExtra(ProjectVO.Fields.dataStatus, obj.getDataStatus());
}));
String jsonStr = JSONUtil.toJsonStr(trees);
projectVOS.add(jsonStr);
} else {
TreeNodeConfig config = new TreeNodeConfig();
config.setIdKey(FileProjectVO.Fields.categoryId);
config.setParentIdKey(FileProjectVO.Fields.parentId);
config.setWeightKey(FileProjectVO.Fields.sort);
List<Tree<String>> trees = TreeUtil.build(edFileInfos, PRJ_PARENT_ID, config, ((obj, treeNode) -> {
treeNode.putExtra(FileProjectVO.Fields.categoryId, obj.getId());
treeNode.putExtra(FileProjectVO.Fields.parentId, obj.getParentId());
treeNode.putExtra(FileProjectVO.Fields.sort, obj.getSort());
treeNode.putExtra(FileProjectVO.Fields.categoryName, obj.getFileName());
treeNode.putExtra(FileProjectVO.Fields.dataStatus, obj.getDataStatus());
}));
String jsonStr = JSONUtil.toJsonStr(trees);
projectVOS.add(jsonStr);
}
}
return projectVOS;
} catch (Exception e) {
String info = "查询项目失败";
log.error(info, e);
throw new BizException(info);
}
}
public ElectromagneticResult<?> deleteFolder(String id) {
// 如果文件夹下存在文件包括文件夹和已经逻辑删除的文件则不允许删除后面管理员选择会有物理删除文件夹和文件的功能此时MySQL和文件系统则会进行物理删除该文件
Date now = new Date();
String currentUserId = UserThreadLocal.getUserId();
try {
// 这里要分两种情况1是删除层级目录2是删除用户创建的文件夹
EdFileInfo fileInfo = edFileInfoMapper.selectOne(Wrappers.<EdFileInfo>lambdaQuery().eq(EdFileInfo::getId, id));
String parentId = fileInfo.getParentId();
if (fileInfo.getPrjDir()) { // 删除的是层级目录
long count = edFileInfoMapper.selectCount(Wrappers.<EdFileInfo>lambdaQuery()
.eq(EdFileInfo::getPrjDir, false)
.eq(EdFileInfo::getEffectFlag, EffectFlagEnum.EFFECT.code)
.like(EdFileInfo::getFilePath, MYSQL_FILE_PATH_SPLIT + id + MYSQL_FILE_PATH_SPLIT));
if (count > 0) {
String info = "禁止删除非空文件夹";
log.info(info);
return ElectromagneticResultUtil.fail("-1", info);
} else {
// 先设置dataStatus状态为删除状态
edFileInfoMapper.update(null, Wrappers.<EdFileInfo>lambdaUpdate()
.like(EdFileInfo::getFilePath, id)
.set(EdFileInfo::getSort, -1)
.set(EdFileInfo::getUpdatedBy, currentUserId)
.set(EdFileInfo::getUpdatedTime, now)
.set(EdFileInfo::getDataStatus, EleDataStatusEnum.DELETED.code));
// 层级文件夹重排序
List<EdFileInfo> edFileInfos1 = edFileInfoMapper.selectList(Wrappers.lambdaQuery(EdFileInfo.class)
.select(EdFileInfo::getId, EdFileInfo::getSort)
.eq(EdFileInfo::getEffectFlag, EffectFlagEnum.EFFECT.code)
.ne(EdFileInfo::getDataStatus, EleDataStatusEnum.DELETED.code)
.eq(EdFileInfo::getParentId, parentId)
.orderByAsc(EdFileInfo::getSort));
for (int i = 0; i < edFileInfos1.size(); i++) {
String tmp = edFileInfos1.get(i).getId();
edFileInfoMapper.update(null, Wrappers.lambdaUpdate(EdFileInfo.class)
.set(EdFileInfo::getSort, i + 1)
.set(EdFileInfo::getUpdatedBy, currentUserId)
.set(EdFileInfo::getUpdatedTime, now)
.eq(EdFileInfo::getId, tmp));
}
}
} else { // 删除的是用户自己创建的文件夹
// 检查该文件夹下是否有没有被废除的文件
long count = edFileInfoMapper.selectCount(Wrappers.<EdFileInfo>lambdaQuery()
.eq(EdFileInfo::getParentId, id)
.eq(EdFileInfo::getEffectFlag, EffectFlagEnum.EFFECT.code));
if (count > 0) {
String info = "禁止删除非空文件夹";
log.info(info);
return ElectromagneticResultUtil.fail("-1", info);
} else {
// 逻辑文件夹重排序
edFileInfoMapper.update(null, Wrappers.<EdFileInfo>lambdaUpdate()
.eq(EdFileInfo::getId, id)
.set(EdFileInfo::getUpdatedBy, currentUserId)
.set(EdFileInfo::getUpdatedTime, now)
.set(EdFileInfo::getEffectFlag, EffectFlagEnum.NOT_EFFECTIVE.code));
}
}
return ElectromagneticResultUtil.success(true);
} catch (Exception e) {
String info = "删除子集异常";
log.error(info, e);
throw new BizException(info);
}
}
public String getCodePathByDbPath(String dbPath) {
List<String> paths = StrUtil.split(dbPath, MYSQL_FILE_PATH_SPLIT);
List<String> reversePaths = CollUtil.reverse(paths);
for (String path : reversePaths) {
if (path.length() == 6) {
return path;
}
}
return null;
}
public String getPrjNameByDbPath(String dbPath) {
List<String> paths = StrUtil.split(dbPath, MYSQL_FILE_PATH_SPLIT);
String prjId = paths.get(0);
return edFileInfoMapper.selectById(prjId).getFileName();
}
public Set<String> selectPrjLeafs() {
List<String> prjInfo = queryAllPrjInfo(true, null);
Set<String> res = new HashSet<>();
prjInfo.forEach(e -> {
ProjectVO projectVO = JSONUtil.toList(e, ProjectVO.class).get(0);
Set<String> leafIds = getLeafNodes(projectVO).stream().map(ProjectVO::getId).collect(Collectors.toSet());
res.addAll(leafIds);
});
return res;
}
private static List<ProjectVO> getLeafNodes(ProjectVO root) {
List<ProjectVO> leafNodes = new ArrayList<>();
if (root == null) {
return leafNodes;
}
findLeafNodes(root, leafNodes);
return leafNodes;
}
private static void findLeafNodes(ProjectVO node, List<ProjectVO> leafNodes) {
if (node.getChildren().isEmpty()) {
leafNodes.add(node);
} else {
for (ProjectVO child : node.getChildren()) {
findLeafNodes(child, leafNodes);
}
}
}
}

View File

@ -1,923 +0,0 @@
package com.electromagnetic.industry.software.manage.service.serviceimpl;
import cn.hutool.core.codec.Base64;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.io.FileUtil;
import cn.hutool.core.io.IoUtil;
import cn.hutool.core.lang.Assert;
import cn.hutool.core.util.StrUtil;
import cn.hutool.core.util.ZipUtil;
import cn.hutool.crypto.SecureUtil;
import cn.hutool.crypto.symmetric.AES;
import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONUtil;
import com.electromagnetic.industry.software.common.cons.ElectromagneticConstants;
import com.electromagnetic.industry.software.common.resp.ElectromagneticResult;
import com.electromagnetic.industry.software.common.util.EleCommonUtil;
import com.electromagnetic.industry.software.common.util.ElectromagneticResultUtil;
import com.electromagnetic.industry.software.common.util.IdWorker;
import com.electromagnetic.industry.software.common.util.UserThreadLocal;
import com.electromagnetic.industry.software.manage.mapper.CategoryMapper;
import com.electromagnetic.industry.software.manage.mapper.EDDataMapper;
import com.electromagnetic.industry.software.manage.mapper.EDDataMappers;
import com.electromagnetic.industry.software.manage.pojo.models.Category;
import com.electromagnetic.industry.software.manage.pojo.models.EDDataInfo;
import com.electromagnetic.industry.software.manage.pojo.other.EDDataPage;
import com.electromagnetic.industry.software.manage.pojo.other.EDDataParams;
import com.electromagnetic.industry.software.manage.pojo.req.EDDataRequest;
import com.electromagnetic.industry.software.manage.pojo.req.FileChunkDTO;
import com.electromagnetic.industry.software.manage.pojo.req.FileChunkResultDTO;
import com.electromagnetic.industry.software.manage.pojo.resp.EDDataPageResponse;
import com.electromagnetic.industry.software.manage.service.EDDataService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.io.FileSystemResource;
import org.springframework.core.io.InputStreamResource;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;
@Service
@Slf4j
public class EDDataServiceImpl implements EDDataService {
@Resource
private EDDataMapper edDataMapper;
@Resource
private CategoryMapper categoryMapper;
@Value("${data.windows.path}")
private String uploadFilePath;
@Value("${data.file.storage.dir}")
private String fileStorageDir;
@Value("${data.import.cache.dir}")
private String importCacheDir;
@Value("${file.encode.passwd}")
private String encodePasswd;
@Value("${data.type.folder}")
private String dataTypeFolder;
@Value("${data.windows.path}")
private String windowsDir;
@Value("${data.file.cache.dir}")
private String fileCacheDir;
@Value("${data.upload.cache.dir}")
private String uploadCacheDir;
@Value("${data.export.cache.dir}")
private String exportCacheDir;
@Value("${data.type.file}")
private String dataTypeFile;
private static final String UPLOAD_FILE_CHUNK_SUFFIX = ".part";
// 文件夹名称分隔符
private static final String FOLDER_NAME_SEPARATOR = "_";
@Override
public ElectromagneticResult<Boolean> createFolder(EDDataRequest request) {
EDDataInfo edDataInfo = EDDataMappers.INSTANCE.getEDDataInfo(request);
edDataInfo.setCreator(UserThreadLocal.getUserId());
edDataInfo.setCreatorName(UserThreadLocal.getUsername());
edDataInfo.setModifier(UserThreadLocal.getUserId());
edDataInfo.setModifierName(UserThreadLocal.getUsername());
edDataInfo.setCategoryId(request.getParentId());
edDataInfo.setDataName(request.getName());
edDataInfo.setNote(request.getNote());
edDataInfo.setGmtBatchUpload(new Date());
edDataInfo.setDataId(IdWorker.getSnowFlakeIdString());
edDataInfo.setDataNo(edDataInfo.getDataId());
edDataInfo.setDataType(dataTypeFolder);
edDataInfo.setVersion("1.0.0");
edDataInfo.setDataStatus("publish");
edDataInfo.setSaveStatus("success");
try {
return ElectromagneticResultUtil.success(createDataInfo(edDataInfo));
} catch (Exception e) {
log.error("创建文件夹失败。。。", e);
return ElectromagneticResultUtil.fail("500", e.getMessage());
}
}
public Boolean createDataInfo(EDDataInfo edDataInfo) throws Exception
{
// 获取上级目录的名称
String fileName = edDataInfo.getDataName();
Assert.isTrue(EleCommonUtil.isFileNameValid(fileName), "文件名不符合规范只能包含中文字符、下划线、连字符、加号、数字和英文字符且长度小于32。");
Category categoryParent = new Category();
categoryParent.setCategoryId(edDataInfo.getCategoryId());
List<Category> categoryParentList = categoryMapper.selectCategories(categoryParent);
if(categoryParentList.size() < 1) {
throw new Exception("上级文件夹不存在");
}
else
{
// 获取新文件夹路径信息
categoryParent = categoryParentList.get(0);
String dataStoragePath = getDataStoragePath();
String folderParent = categoryParent.getCategoryId() + FOLDER_NAME_SEPARATOR + categoryParent.getCategoryName() ;
String folderNew = dataStoragePath + File.separator + folderParent + File.separator + edDataInfo.getDataName();
// 判断文件夹名称是否存在
EDDataParams folderParames = new EDDataParams();
folderParames.setParentId(edDataInfo.getCategoryId());
List<EDDataInfo> childFileInfoList = edDataMapper.getDataInfoList(folderParames);
for(EDDataInfo fileInfo : childFileInfoList)
{
if(fileInfo.getDataName().equals(edDataInfo.getDataName())){
throw new Exception("文件夹已存在");
}
}
// 将文件夹数据写到数据库中
if(edDataMapper.createDataInfo(edDataInfo)) {
if (!FileUtil.exist(folderNew)){
FileUtil.mkdir(folderNew);
}
}
}
return Boolean.TRUE;
}
/**
* 获取数据存储目录
* @return
*/
public String getDataStoragePath() {
String osName = System.getProperty("os.name").toLowerCase();
return osName.startsWith("win") ? windowsDir + fileStorageDir : fileStorageDir;
}
@Override
public ElectromagneticResult<EDDataPageResponse> getDataInfoList(EDDataRequest request) {
EDDataParams parames= EDDataMappers.INSTANCE.getEDDataParames(request);
//获取中支指标配置列表
PageHelper.startPage(parames.getPageIndex(), parames.getPageSize());
List<EDDataInfo> edDataInfoList = edDataMapper.getDataInfoList(parames);
PageInfo<EDDataInfo> pageInfo = new PageInfo<>(edDataInfoList);
EDDataPage edDataPage = new EDDataPage();
edDataPage.setEdDataInfo(pageInfo);
//模型转换
EDDataPageResponse edDataPageResponse = EDDataMappers.INSTANCE.getEDDataInfoToModel(edDataPage);
return ElectromagneticResultUtil.success(edDataPageResponse);
}
@Override
public ElectromagneticResult<Boolean> updateFileInfo(EDDataRequest request) {
try {
EDDataParams parames = EDDataMappers.INSTANCE.getEDDataParames(request);
parames.setUserId(UserThreadLocal.getUserId());
parames.setUserName(UserThreadLocal.getUsername());
return ElectromagneticResultUtil.success(updateFileInfo(parames));
} catch (Exception e) {
log.error("文件信息更新失败。。。", e);
return ElectromagneticResultUtil.fail("500", e.getMessage());
}
}
public Boolean updateFileInfo(EDDataParams parames) throws Exception {
String dataStoragePath = getDataStoragePath();
if (!FileUtil.exist(dataStoragePath)){
throw new Exception("数据存储文件夹不存在");
}
EDDataParams paramesFind = new EDDataParams();
paramesFind.setDataId(parames.getDataId());
List<EDDataInfo> edDataInfoList = edDataMapper.getDataInfoList(paramesFind);
if(edDataInfoList.size() < 1) {
throw new Exception("文件信息不存在");
}
EDDataInfo edDataInfo = edDataInfoList.get(0);
String filePathOfFolder = getFilePathOfFolder(edDataInfo.getCategoryId());
String fileType = StrUtil.isEmpty(edDataInfo.getFileType()) ? "" : "." + edDataInfo.getFileType();
String fileStorageFullPath = dataStoragePath + filePathOfFolder + File.separator + edDataInfo.getDataName() + fileType;
if (!FileUtil.exist(fileStorageFullPath)){
throw new Exception("文件不存在");
}
String fileNameNew = parames.getName() + fileType;
if(fileNameNew != null && fileNameNew != "" && !fileNameNew.equals(edDataInfo.getDataName())) {
FileUtil.rename(Paths.get(fileStorageFullPath) ,fileNameNew,true);
}
// 修改文件夹
edDataMapper.updateFileInfo(parames);
// 修改文件夹中的文件
if(edDataInfo.getDataType().equals(dataTypeFolder) && parames.getEffectFlag() != null) {
EDDataParams paramesChild = new EDDataParams();
paramesChild.setParentId(edDataInfo.getDataId());
paramesChild.setEffectFlag(parames.getEffectFlag());
edDataMapper.updateFileInfo(paramesChild);
}
return Boolean.TRUE;
}
public String getFilePathOfFolder(String categoryId) {
String filePathOfFolder = ""; //文件存放在文件夹的路径
String categoryIdHighest = categoryId; //最高级的目录编码
EDDataParams folderParames = new EDDataParams();
folderParames.setDataId(categoryId);
List<EDDataInfo> edDataInfoList = edDataMapper.getDataInfoList(folderParames);
EDDataInfo edDataInfoParent = null;
if(CollUtil.isNotEmpty(edDataInfoList)) {
categoryIdHighest = edDataInfoList.get(0).getCategoryId();
edDataInfoParent = edDataInfoList.get(0);
}
Category categoryParent = new Category();
categoryParent.setCategoryId(categoryIdHighest);
List<Category> categoryParentList = categoryMapper.selectCategories(categoryParent);
if(categoryParentList.size() > 0){
categoryParent = categoryParentList.get(0);
filePathOfFolder = categoryParent.getCategoryId() + FOLDER_NAME_SEPARATOR + categoryParent.getCategoryName();
if(edDataInfoParent != null) {
String fileType = StrUtil.isEmpty(edDataInfoParent.getFileType()) ? "" : "." + edDataInfoParent.getFileType();
filePathOfFolder = filePathOfFolder + File.separator + edDataInfoParent.getDataName() + fileType;
}
}
return filePathOfFolder;
}
@Override
public ElectromagneticResult<Map<String, Integer>> getChildFileCount(EDDataRequest request) {
EDDataParams parames= EDDataMappers.INSTANCE.getEDDataParames(request);
Integer fileCount = getChildFileCount(parames);
Map<String, Integer> result = new HashMap<>();
result.put("fileCount", fileCount);
return ElectromagneticResultUtil.success(result);
}
public Integer getChildFileCount(EDDataParams parames) {
Integer childFileCount = 0;
List<EDDataInfo> edDataInfoList = edDataMapper.getDataInfoList(parames);
parames.setDataId(null);
for (EDDataInfo edDataInfo : edDataInfoList) {
if(edDataInfo.getDataType().equals(dataTypeFolder))
{
parames.setParentId(edDataInfo.getDataId());
childFileCount += getChildFileCount(parames);
}
else if(edDataInfo.getDataType().equals(dataTypeFile) && edDataInfo.getEffectFlag().equals(1))
{
++childFileCount;
}
}
return childFileCount;
}
@Override
public ElectromagneticResult<Boolean> uploadFile(EDDataRequest request) {
try {
EDDataParams parames= EDDataMappers.INSTANCE.getEDDataParames(request);
parames.setUserId(UserThreadLocal.getUserId());
parames.setUserName(UserThreadLocal.getUsername());
return ElectromagneticResultUtil.success(upload(parames));
} catch (Exception e) {
log.error("上传文件失败。。。", e);
return ElectromagneticResultUtil.fail("500", e.getMessage());
}
}
private Boolean upload(EDDataParams parames) throws Exception {
// 获取目录编码ID
String categoryId = parames.getParentId();
// 获取要上传的文件
MultipartFile fileInput = parames.getFileData();
// 检查文件是否为空
if (fileInput == null || fileInput.isEmpty()) {
throw new Exception("上传的文件为空");
}
// 获取文件名
String fileFullName = fileInput.getOriginalFilename();
// 获取文件类型
String fileType = EleCommonUtil.getFileType(fileFullName);
// 获取文件名称
String fileName = EleCommonUtil.getFileName(fileFullName);
Assert.isTrue(EleCommonUtil.isFileNameValid(fileName), "文件名不符合规范只能包含中文字符、下划线、连字符、加号、数字和英文字符且长度小于32。");
// 判断文件名称是否存在
EDDataParams folderParames = new EDDataParams();
folderParames.setParentId(categoryId);
List<EDDataInfo> childFileInfoList = edDataMapper.getDataInfoList(folderParames);
for(EDDataInfo fileInfo : childFileInfoList)
{
if(fileInfo.getDataName().equals(fileFullName)){
throw new Exception("上传的文件已存在");
}
}
String dataStoragePath = getDataStoragePath();
if (!FileUtil.exist(dataStoragePath)){
FileUtil.mkdir(dataStoragePath);
}
//获取文件存放在文件夹的路径
String filePathOfFolder = getFilePathOfFolder(categoryId);
// 将文件数据信息写到数据库
EDDataInfo edDataInfo = new EDDataInfo();
// 创建新文件数据
edDataInfo.setCreator(parames.getUserId());
edDataInfo.setCreatorName(parames.getUserName());
edDataInfo.setModifier(parames.getUserId());
edDataInfo.setModifierName(parames.getUserName());
edDataInfo.setCategoryId(parames.getParentId());
edDataInfo.setDataName(fileName);
edDataInfo.setNote(parames.getNote());
edDataInfo.setFileType(fileType);
edDataInfo.setGmtBatchUpload(parames.getGmtBatchUpload());
edDataInfo.setDataId(IdWorker.getSnowFlakeIdString());
edDataInfo.setDataNo(edDataInfo.getDataId());
edDataInfo.setDataType(dataTypeFile);
edDataInfo.setVersion("1.0.0");
edDataInfo.setDataStatus("publish");
edDataInfo.setSaveStatus("saving");
boolean isSuccess = edDataMapper.createDataInfo(edDataInfo);
log.info("文件开始保存.");
// 保存文件数据 文件存储目录
// 文件保存目录路径
String fileSavePath = dataStoragePath + File.separator + filePathOfFolder;
String newFileName = edDataInfo.getDataId() + FOLDER_NAME_SEPARATOR + fileFullName;
if (!FileUtil.exist(fileSavePath)){
FileUtil.mkdir(fileSavePath);
}
String dataCachePath = getDataCachePath();
String uploadFileCachePath = dataCachePath + uploadCacheDir + FOLDER_NAME_SEPARATOR + getTimeStampString();
if (!FileUtil.exist(uploadFileCachePath)){
FileUtil.mkdir(uploadFileCachePath);
}
String fileCacheFullPath = uploadFileCachePath + File.separator + newFileName;
String fileSaveFullPath = fileSavePath + File.separator + fileFullName;
log.info("文件缓存路径为: " + fileCacheFullPath);
// 这里可以添加将文件保存到本地磁盘或其他存储介质的逻辑
File saveFile = new File(fileCacheFullPath);
// 将文件保存到硬盘
EDDataParams fileParames = new EDDataParams();
try {
fileInput.transferTo(saveFile);
fileParames.setDataId(edDataInfo.getDataId());
if(fileInput.getSize() == saveFile.length())
{
Path source = Paths.get(fileCacheFullPath);
Path target = Paths.get(fileSaveFullPath);
Files.move(source, target);
fileParames.setSaveStatus("success");
}
else
{
saveFile.delete();
fileParames.setSaveStatus("failure");
}
isSuccess = edDataMapper.updateFileInfo(fileParames);
FileUtil.del(uploadFileCachePath);//删除临时目录
log.info("文件保存成功: " + fileSaveFullPath);
return Boolean.TRUE;
} catch (IOException e) {
fileParames.setSaveStatus("failure");
edDataMapper.updateFileInfo(fileParames);
log.info("文件保存失败: " + fileSaveFullPath);
throw new Exception(e.getMessage());
}
}
/**
* 获取时间戳字符串
* @return
*/
public String getTimeStampString() {
long timestamp = System.currentTimeMillis();
return String.valueOf(timestamp);
}
/**
* 获取数据缓存目录
* @return
*/
public String getDataCachePath() {
String osName = System.getProperty("os.name").toLowerCase();
return osName.startsWith("win") ? windowsDir + fileCacheDir : fileCacheDir;
}
@Override
public ResponseEntity<InputStreamResource> download(String dataId, HttpServletResponse response) throws IOException {
// 获取文件存储的文件夹路径
String osName = System.getProperty("os.name").toLowerCase();
String storageFilePath = osName.startsWith("win") ? uploadFilePath + fileStorageDir : fileStorageDir;
EDDataParams parames = new EDDataParams();
parames.setDataId(dataId);
List<EDDataInfo> edDataInfos = edDataMapper.getDataInfoList(parames);
Assert.isTrue(CollUtil.isNotEmpty(edDataInfos), "没有找到该下载文件");
EDDataInfo edDataInfo = edDataInfos.get(0);
String filePathOfFolder = getFilePathOfFolder1(edDataInfo.getCategoryId());
String fileType = StrUtil.isEmpty(edDataInfo.getFileType()) ? "" : "." + edDataInfo.getFileType();
String filePath = storageFilePath + "/" + filePathOfFolder + "/" + edDataInfo.getDataName() + fileType;
Assert.isTrue(FileUtil.exist(filePath), "下载文件不存在。");
FileSystemResource fileSystemResource = new FileSystemResource(filePath);
HttpHeaders headers = new HttpHeaders();
headers.add("Cache-Control", "no-cache, no-store, must-revalidate");
headers.add("Pragma", "no-cache");
headers.add("Expires", "0");
String fileName = Base64.encode(fileSystemResource.getFilename());
response.setHeader("content-disposition","attachment;filename=" + fileName);
// 构建响应实体(可以返回<byte[]或Resource返回类型取决body入参类型)
return ResponseEntity
.ok()
.headers(headers)
.contentLength(fileSystemResource.contentLength())
.contentType(MediaType.parseMediaType("application/octet-stream;charset=UTF-8"))
.body(new InputStreamResource(fileSystemResource.getInputStream()));
}
private String getFilePathOfFolder1(String categoryId)
{
String filePathOfFolder = ""; //文件存放在文件夹的路径
String categoryIdHighest = categoryId; //最高级的目录编码
EDDataParams folderParames = new EDDataParams();
folderParames.setDataId(categoryId);
List<EDDataInfo> edDataInfoList = edDataMapper.getDataInfoList(folderParames);
EDDataInfo edDataInfoParent = null;
if(CollUtil.isNotEmpty(edDataInfoList)) {
categoryIdHighest = edDataInfoList.get(0).getCategoryId();
edDataInfoParent = edDataInfoList.get(0);
}
Category categoryParent = new Category();
categoryParent.setCategoryId(categoryIdHighest);
List<Category> categoryParentList = categoryMapper.selectCategories(categoryParent);
if(categoryParentList.size() > 0){
categoryParent = categoryParentList.get(0);
filePathOfFolder = categoryParent.getCategoryId() + FOLDER_NAME_SEPARATOR + categoryParent.getCategoryName();
if(edDataInfoParent != null) {
String fileType = StrUtil.isEmpty(edDataInfoParent.getFileType()) ? "" : "." + edDataInfoParent.getFileType();
filePathOfFolder = filePathOfFolder + File.separator + edDataInfoParent.getDataName() + fileType;
}
}
return filePathOfFolder;
}
@Override
public ResponseEntity<InputStreamResource> batchExport(String dataIdArr, HttpServletResponse response) throws IOException {
//1根据用户选择层级树编码查出所有文件和文件夹list
//2循环list将每个文件复制到新建目录并进行重命名命名规则目录树编码+,+文件夹编码有则填写无则为空+,+文件编码
//3打包新建为zip并根据生产下载地址域名+文件路径+文件
//4返回前端下载的地址
// **********在导出的过程中可能会出现有用户上传文件的情况
Map<String, String> result = new HashMap<>();
List<String> dataIdList = Arrays.asList(dataIdArr.split(","));
if(!dataIdList.isEmpty()) {
String filePath = exportData(dataIdList);
Assert.isTrue(FileUtil.exist(filePath), "下载文件不存在。");
File file = new File(filePath);
FileSystemResource fileSystemResource = new FileSystemResource(file);
HttpHeaders headers = new HttpHeaders();
headers.add("Cache-Control", "no-cache, no-store, must-revalidate");
String fileName = Base64.encode(fileSystemResource.getFilename());
headers.add("Pragma", "no-cache");
headers.add("Expires", "0");
response.setHeader("content-disposition","attachment;filename=" + fileName);
// 构建响应实体(可以返回<byte[]或Resource返回类型取决body入参类型)
return ResponseEntity
.ok()
.headers(headers)
.contentLength(fileSystemResource.contentLength())
.contentType(MediaType.parseMediaType("application/octet-stream"))
.body(new InputStreamResource(fileSystemResource.getInputStream()));
}
return null;
}
public String exportData(List<String> dataIdList) {
String zipPathFileName = "";
String exportDataCachePath = "";
String enCodeZipPathFileName = "";
try {
// 获取文件夹编码ID数组
List<String> categoryIdInputList = dataIdList;
String dataCachePath = getDataCachePath();
// 导出数据时的临时存放目录
exportDataCachePath = dataCachePath + exportCacheDir + FOLDER_NAME_SEPARATOR + getTimeStampString();
if (!FileUtil.exist(exportDataCachePath)) {
FileUtil.mkdir(exportDataCachePath);
}
List<Category> categoryAllList = categoryMapper.selectAllCategories();
Map<String, Category> categoryAllMap = new HashMap(); //所有目录数组map
for (Category category : categoryAllList) {
categoryAllMap.put(category.getCategoryId(), category);
}
EDDataParams folderParames = new EDDataParams();
List<EDDataInfo> fileAllList = edDataMapper.getDataInfoList(folderParames); //获取所有文件信息数据
Map<String, EDDataInfo> fileAllMap = new HashMap(); //所有文件数组map
for (EDDataInfo fileFinfo : fileAllList) {
fileAllMap.put(fileFinfo.getDataId(), fileFinfo);
}
List<Category> categoryInputList = new ArrayList(); //客户端输入的目录数组
Map<String, Category> categoryInputMap = new HashMap(); //客户端输入的目录数组map
for (String categoryId : categoryIdInputList) {
Category category = categoryAllMap.get(categoryId);
if (category != null) {
categoryInputList.add(category);
categoryInputMap.put(categoryId, category);
}
}
// 将List<Category>转换为JSON字符串
String jsonStringCategory = JSONUtil.toJsonStr(categoryInputList);
String categoryListFileFullPath = exportDataCachePath + "/categoryList.json";
FileUtil.writeString(jsonStringCategory, categoryListFileFullPath, "utf-8");
log.info("目录树数据已成功导出为JSON文件。" + categoryListFileFullPath);
// 导出文件信息数据和文件数据
List<EDDataInfo> fileExportList = new ArrayList(); //需要导出的文件信息数据数组
Map<String, EDDataInfo> fileExportMap = new HashMap(); //需要导出的文件信息数据数组map
for (EDDataInfo fileFinfo : fileAllList) {
if (categoryInputMap.get(fileFinfo.getCategoryId()) != null) {
fileExportList.add(fileFinfo);
fileExportMap.put(fileFinfo.getDataId(), fileFinfo);
}
}
// 找出子文件夹下的文件
for (EDDataInfo fileFinfo : fileAllList) {
if (fileExportMap.get(fileFinfo.getCategoryId()) != null) {
fileExportList.add(fileFinfo);
}
}
// 将文件信息数据导出为json文件
String jsonStringFile = JSONUtil.toJsonStr(fileExportList);
String fileListFileFullPath = exportDataCachePath + "/fileInfoList.json";
FileUtil.writeString(jsonStringFile, fileListFileFullPath, "utf-8");
log.info("文件数据已成功导出为JSON文件。" + fileListFileFullPath);
// 将文件 复制到 数据导出的缓存目录中
String dataStoragePath = getDataStoragePath();
String needExportfolder = "";
for (Category category : categoryInputList) {
needExportfolder = dataStoragePath + category.getCategoryId() + FOLDER_NAME_SEPARATOR + category.getCategoryName();
if (FileUtil.exist(needExportfolder)) {
Path source = Paths.get(needExportfolder);
Path target = Paths.get(exportDataCachePath);
FileUtil.copy(source, target); // StandardCopyOption.REPLACE_EXISTING
}
}
log.info("文件数据已成功复制到目标目录。");
// 将目录树数据 文件夹及文件夹内数据 进行压缩打包
Date date = new Date();
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd-HHmmss");
String dateString = sdf.format(date);
zipPathFileName = dataCachePath + "/exportData_" + dateString;
enCodeZipPathFileName = dataCachePath + "/exportData_" + dateString + ElectromagneticConstants.EXPORT_FILE_SUFFIX;
ZipUtil.zip(exportDataCachePath, zipPathFileName);
AES aes = SecureUtil.aes(encodePasswd.getBytes()); // aesKey是加密密钥
try (
InputStream inputStream = new FileInputStream(zipPathFileName);
OutputStream outputStream = new FileOutputStream(enCodeZipPathFileName);
) {
aes.encrypt(inputStream, outputStream, true);
} catch (Exception e) {
log.error("文件加密错误..", e);
}
log.info("目录树数据+文件数据已成功复制到目标目录。" + enCodeZipPathFileName);
}
catch (Exception e) {
log.error("导出数据异常..", e);
}
finally {
// 删除 导出数据的 缓存目录
FileUtil.del(exportDataCachePath);
}
return enCodeZipPathFileName;
}
@Override
public ElectromagneticResult<?> batchImport(FileChunkDTO fileChunkDTO) {
String identifier = fileChunkDTO.getIdentifier();
String fileName = fileChunkDTO.getFileName();
String dataCachePath = getDataCachePath();
String importDataCachePath = dataCachePath + importCacheDir;
// 首先检查文件是否存在如果存在则不允许重复上传
String destZipPath = importDataCachePath + identifier + File.separator + fileName;
boolean existFile = FileUtil.exist(new File(destZipPath));
if (existFile) {
return ElectromagneticResultUtil.fail("-1", "文件已经存在,请勿重复上传。");
}
// 检查该分片有没被上传过
String destChunkPath = importDataCachePath + identifier + File.separator + fileChunkDTO.getChunkNumber() + UPLOAD_FILE_CHUNK_SUFFIX;
boolean existChunk = FileUtil.exist(new File(destChunkPath));
if (existChunk) {
return ElectromagneticResultUtil.success(true);
}
File dir = new File(importDataCachePath + identifier + File.separator);
if (!dir.exists()) {
dir.mkdir();
}
try (
InputStream inputStream = fileChunkDTO.getFile().getInputStream();
FileOutputStream fileOutputStream = new FileOutputStream(destChunkPath);
) {
IoUtil.copy(inputStream, fileOutputStream);
} catch (IOException ioException) {
log.error("上传文件错误...", ioException);
}
return ElectromagneticResultUtil.success(fileChunkDTO.getIdentifier());
}
@Override
public ElectromagneticResult<List<Integer>> getUploadedChunkNums(String identifier) {
return ElectromagneticResultUtil.success(getUploadedChunks(identifier));
}
private List<Integer> getUploadedChunks(String identifier) {
String dataCachePath = getDataCachePath();
String importDataCachePath = dataCachePath + importCacheDir;
String destPath = importDataCachePath + identifier;
if (!FileUtil.exist(new File(destPath))) {
return new ArrayList<>();
}
return FileUtil.listFileNames(destPath)
.stream()
.filter(e -> !e.endsWith(ElectromagneticConstants.EXPORT_FILE_SUFFIX))
.map(e -> e.replace(UPLOAD_FILE_CHUNK_SUFFIX, ""))
.map(Integer::parseInt)
.collect(Collectors.toList());
}
@Override
public ElectromagneticResult<?> mergeChunks(String identifier, String fileName, Integer totalChunks) {
String dataCachePath = getDataCachePath();
String importDataCachePath = dataCachePath + importCacheDir;
// 检查所有分片是否已经上传完成分片编号从1开始
for (int i = 1; i <= totalChunks; i++) {
String tmpPath = importDataCachePath + identifier + File.separator + i + UPLOAD_FILE_CHUNK_SUFFIX;
if (!FileUtil.exist(new File(tmpPath))) {
log.error("第{}个分片没有上传完成,请上传完成后再合并。", i);
ElectromagneticResultUtil.fail("-1", "文件尚未上传完成。");
}
}
// 合并分片
String destZipPath = importDataCachePath + identifier + File.separator + fileName;
File mergedFile = new File(destZipPath);
try {
RandomAccessFile targetFile = new RandomAccessFile(mergedFile, "rw");
byte[] buffer = new byte[1024];
for (int i = 1; i <= totalChunks; i++) {
String tmpPath = importDataCachePath + identifier + File.separator + i + UPLOAD_FILE_CHUNK_SUFFIX;
RandomAccessFile tmp = new RandomAccessFile(new File(tmpPath), "r");
int len;
while ((len = tmp.read(buffer)) != -1) {
targetFile.write(buffer, 0, len);
}
tmp.close();
}
targetFile.close();
} catch (IOException ioException) {
ElectromagneticResultUtil.fail("-1", "文件合并失败");
}
// 删除分片
for (int i = 1; i <= totalChunks; i++) {
String tmpPath = importDataCachePath + identifier + File.separator + i + UPLOAD_FILE_CHUNK_SUFFIX;
FileUtil.del(tmpPath);
}
// 检验文件的MD5值
// 解密文件
String decryptFilePath = destZipPath + "_decrypted";
AES aes = SecureUtil.aes(encodePasswd.getBytes()); // aesKey是加密密钥
try(
InputStream inputStream = new FileInputStream(destZipPath);
OutputStream outputStream = new FileOutputStream(decryptFilePath);
) {
aes.decrypt(inputStream, outputStream, true);
} catch (Exception e) {
log.error("文件加密错误..", e);
}
// 解压文件
String unzipFileOutputPath = importDataCachePath + identifier + File.separator;
ZipUtil.unzip(decryptFilePath, unzipFileOutputPath);
// 文件信息存入数据库
Map<String, List<String>> result = importData(importDataCachePath + identifier);
// 删除 解压数据的 缓存目录
FileUtil.del(unzipFileOutputPath);
return ElectromagneticResultUtil.success(result);
}
public Map<String, List<String>> importData(String folderPath) {
// 获取所有目录树节点数据
List<Category> categoryAllList = categoryMapper.selectAllCategories();
Map<String, Category> categoryAllMap = new HashMap(); //所有目录数组map
for (Category category : categoryAllList) {
categoryAllMap.put(category.getCategoryId(), category);
}
// 获取所有文件信息数据
EDDataParams parames = new EDDataParams();
List<EDDataInfo> fileInfoAllList = edDataMapper.getDataInfoList(parames);
Map<String, EDDataInfo> fileInfoAllMap = new HashMap(); //所有文件数组map
for (EDDataInfo fileInfo : fileInfoAllList) {
fileInfoAllMap.put(fileInfo.getDataId(), fileInfo);
}
// 读取并反序列化目录树的JSON文件数据为List<Category>然后写入到数据库中
String jsonStringCategory = FileUtil.readString(folderPath + "/categoryList.json", StandardCharsets.UTF_8);
JSONArray jsonArrayCategory = JSONUtil.parseArray(jsonStringCategory);
List<Category> categoryImportList = JSONUtil.toList(jsonArrayCategory, Category.class);
if (categoryImportList == null) {
log.error("读取并反序列化JSON文件数据为List<Category>失败!");
return null;
}
// 将目录树数据写入到数据库中
for (Category category : categoryImportList) {
if (categoryAllMap.get(category.getCategoryId()) == null) {
categoryMapper.createCategory(category);
}
}
// 读取并反序列化文件信息的JSON文件数据为List<EDDataInfo>然后写入到数据库中
String jsonStringFile = FileUtil.readString(folderPath + "/fileInfoList.json", StandardCharsets.UTF_8);
JSONArray jsonArrayFile = JSONUtil.parseArray(jsonStringFile);
List<EDDataInfo> fileInfoImportList = JSONUtil.toList(jsonArrayFile, EDDataInfo.class);
if (fileInfoImportList == null) {
log.error("读取并反序列化JSON文件数据为List<EDDataInfo>失败!");
return null;
}
// 将文件信息数据写入到数据库中
for (EDDataInfo fileInfo : fileInfoImportList) {
if (fileInfoAllMap.get(fileInfo.getDataId()) == null) {
edDataMapper.createDataInfo(fileInfo);
}
}
// 将解压后的文件夹和文件 移动到 上传文件的存储目录中
List<String> importFileSuccess = new ArrayList();
List<String> importFileFail = new ArrayList();
String dataStoragePath = getDataStoragePath();
if (!FileUtil.exist(dataStoragePath)){
FileUtil.mkdir(dataStoragePath);
}
String importDataCachePath = folderPath; //导入数据时 数据文件解压后的目录
String importFileCachePath = ""; //需要导入的文件的缓存路径
String importFileCacheFullPath = ""; //需要导入的文件的全路径
String fileStorageFolder = ""; //文件存储的文件夹
String fileStoragePath = ""; //文件存储的文件夹路径
String fileStorageFullPath = ""; //文件存储的文件全路径
for (EDDataInfo fileInfo : fileInfoImportList) {
fileStorageFolder = getFilePathOfFolder(fileInfo.getCategoryId());
importFileCachePath = importDataCachePath + File.separator + fileStorageFolder;
importFileCacheFullPath = importFileCachePath + File.separator + fileInfo.getDataName();
fileStoragePath = dataStoragePath + File.separator + fileStorageFolder;
fileStorageFullPath = fileStoragePath + File.separator + fileInfo.getDataName();
if (fileInfoAllMap.get(fileInfo.getDataId()) == null
&& !fileStorageFolder.isEmpty()
&& FileUtil.exist(importFileCachePath)
&& FileUtil.exist(importFileCacheFullPath)
&& !FileUtil.exist(fileStorageFullPath)
)
{
if(fileInfo.getDataType().equals(dataTypeFolder)) {
if (!FileUtil.exist(fileStorageFullPath)) {
FileUtil.mkdir(fileStorageFullPath);
}
} else if(fileInfo.getDataType().equals(dataTypeFile)) {
Path source = Paths.get(importFileCacheFullPath);
Path target = Paths.get(fileStorageFullPath);
FileUtil.move(source,target,true);
}
importFileSuccess.add(fileInfo.getDataId() + FOLDER_NAME_SEPARATOR + fileInfo.getDataName());
}
else
{
importFileFail.add(fileInfo.getDataId() + FOLDER_NAME_SEPARATOR + fileInfo.getDataName());
}
}
Map<String, List<String>> result = new HashMap<>();
result.put("success", importFileSuccess);
result.put("fail", importFileFail);
return result;
}
@Override
public ElectromagneticResult<FileChunkResultDTO> checkChunkExist(FileChunkDTO fileChunkDTO) {
String dataCachePath = getDataCachePath();
String importDataCachePath = dataCachePath + importCacheDir;
// 首先判断zip文件是否存在如果不存在则表示还没有上传完成
String identifier = fileChunkDTO.getIdentifier();
String fileName = fileChunkDTO.getFileName();
String destZipPath = importDataCachePath + identifier + File.separator + fileName;
boolean existFile = FileUtil.exist(new File(destZipPath));
if (existFile) {
return ElectromagneticResultUtil.success(new FileChunkResultDTO(true, new HashSet<>()));
}
List<Integer> uploadedChunks = getUploadedChunks(identifier);
return ElectromagneticResultUtil.success(new FileChunkResultDTO(false, new HashSet<>(uploadedChunks)));
}
}

View File

@ -0,0 +1,274 @@
package com.electromagnetic.industry.software.manage.service.serviceimpl;
import cn.hutool.core.io.FileUtil;
import cn.hutool.core.lang.Assert;
import cn.hutool.crypto.SecureUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.electromagnetic.industry.software.common.enums.EffectFlagEnum;
import com.electromagnetic.industry.software.common.enums.EleDataSaveStatusEnum;
import com.electromagnetic.industry.software.common.enums.EleDataTypeEnum;
import com.electromagnetic.industry.software.common.enums.PublishEnum;
import com.electromagnetic.industry.software.common.exception.BizException;
import com.electromagnetic.industry.software.common.resp.ElectromagneticResult;
import com.electromagnetic.industry.software.common.util.*;
import com.electromagnetic.industry.software.manage.mapper.EdFileInfoMapper;
import com.electromagnetic.industry.software.manage.mapper.EdFileRelationMapper;
import com.electromagnetic.industry.software.manage.pojo.models.EdFileInfo;
import com.electromagnetic.industry.software.manage.pojo.models.EdFileRelation;
import com.electromagnetic.industry.software.manage.pojo.models.Edge;
import com.electromagnetic.industry.software.manage.pojo.req.CheckNameUniqueRequest;
import com.electromagnetic.industry.software.manage.pojo.resp.FileRelationViewVO;
import com.electromagnetic.industry.software.manage.pojo.resp.FileSimpleInfoVO;
import com.electromagnetic.industry.software.manage.service.EdFileRelationService;
import com.electromagnetic.industry.software.manage.service.FileSystemService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import java.util.*;
import static com.electromagnetic.industry.software.common.cons.ElectromagneticConstants.*;
@Service
public class EdFileRelationServiceImpl extends ServiceImpl<EdFileRelationMapper, EdFileRelation> implements EdFileRelationService {
private final EleLog log = new EleLog(EdFileInfoServiceImpl.class);
@Resource
EdFileInfoMapper edFileInfoMapper;
@Resource
EdFileInfoServiceImpl edFileInfoService;
@Resource
private CommonService commonService;
@Resource
private FileSystemService fileSystemService;
@Autowired
private EdFileInfoServiceImpl edFileInfoServiceImpl;
/**
* 创建文件关系
*
* @param edFileRelation
* @return
*/
@Override
public Boolean createRelation(EdFileRelation edFileRelation) throws BizException {
// 无法建立已建立的关系
String queryId1 = edFileRelation.getId1();
String queryId2 = edFileRelation.getId2();
LambdaQueryWrapper<EdFileRelation> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(EdFileRelation::getId1, queryId1).eq(EdFileRelation::getId2, queryId2)
.or()
.eq(EdFileRelation::getId1, queryId2).eq(EdFileRelation::getId2, queryId1);
List<EdFileRelation> list = this.list(queryWrapper);
if (!list.isEmpty()) {
throw new BizException("请勿重复建立关系");
}
edFileRelation.setId(IdWorker.getSnowFlakeIdString());
edFileRelation.setCreatedBy(UserThreadLocal.getUserId());
return this.save(edFileRelation);
}
/**
* 取消文件关系
*
* @param id
* @return
*/
@Override
public Boolean cancelRelation(String id) {
return this.removeById(id);
}
/**
* 获取关系数据
*/
@Override
@Transactional
public FileRelationViewVO listRelations(String startId) {
FileRelationViewVO fileRelationViewVO = new FileRelationViewVO();
List<Edge> visitedEdges = new ArrayList<>();
Set<String> visitedIds = new HashSet<>();
Set<String> uniqueRelationIds = new HashSet<>();
Queue<String> queue = new LinkedList<>();
// 初始化 BFS
queue.add(startId);
visitedIds.add(startId);
while (!queue.isEmpty()) {
String currentId = queue.poll();
List<Edge> neighbors = getEdges(currentId);
for (Edge edge : neighbors) {
// 添加边信息
if (!uniqueRelationIds.contains(edge.getRelationId())) {
visitedEdges.add(edge);
uniqueRelationIds.add(edge.getRelationId());
}
// 如果目标节点未访问记录边并继续搜索
if (!visitedIds.contains(edge.getTarget())) {
visitedIds.add(edge.getTarget()); // 标记目标节点为已访问
queue.add(edge.getTarget());
}
}
}
fileRelationViewVO.setEdges(visitedEdges);
List<FileSimpleInfoVO> nodes = new ArrayList<>();
for (String id : visitedIds) {
FileSimpleInfoVO fileSimpleInfoVO = new FileSimpleInfoVO();
EdFileInfo fileInfo = edFileInfoMapper.selectById(id);
BeanUtils.copyProperties(fileInfo, fileSimpleInfoVO);
nodes.add(fileSimpleInfoVO);
}
fileRelationViewVO.setNodes(nodes);
return fileRelationViewVO;
}
/**
* 检查文件名是否唯一
*
* @return
*/
@Override
@Transactional
public Boolean checkNameExist(CheckNameUniqueRequest checkNameUniqueRequest) {
String mainName = checkNameUniqueRequest.getFileName();
String suffix = checkNameUniqueRequest.getFileType();
String parentId = checkNameUniqueRequest.getParentId();
EdFileInfo newEdFileInfo = new EdFileInfo();
newEdFileInfo.newInit();
// 首先检查是否是同名文件
Assert.isTrue(EleCommonUtil.isFileNameValid(mainName + "." +suffix), NAME_VALID_MSG);
Long count = edFileInfoService.count(Wrappers.lambdaQuery(EdFileInfo.class)
.eq(EdFileInfo::getParentId, parentId)
.eq(EdFileInfo::getFileName, mainName)
.eq(EdFileInfo::getEffectFlag, EffectFlagEnum.EFFECT.code)
.eq(EdFileInfo::getFileType, suffix));
return count > 0;
}
private List<Edge> getEdges(String id) {
LambdaQueryWrapper<EdFileRelation> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(EdFileRelation::getId1, id)
.or()
.eq(EdFileRelation::getId2, id);
List<EdFileRelation> list = this.list(queryWrapper);
List<Edge> edges = new ArrayList<>();
for (EdFileRelation edFileRelation : list) {
if (edFileRelation.getId1().equals(id)) {
edges.add(new Edge(edFileRelation.getId1(), edFileRelation.getId2(), edFileRelation.getId(), edFileRelation.getRelationship()));
} else {
edges.add(new Edge(edFileRelation.getId2(), edFileRelation.getId1(), edFileRelation.getId(), edFileRelation.getRelationship()));
}
}
return edges;
}
/**
* 文件上传
*
* @param parentId
* @param id 主文件Id
* @param file
* @param descrption 关系描述
* @return
*/
@Override
@Transactional(rollbackFor = Exception.class)
public ElectromagneticResult<?> uploadFileAndRelation(String parentId, String id, MultipartFile file, String descrption) {
Assert.isTrue(EleCommonUtil.isFileNameValid(file.getOriginalFilename()), NAME_VALID_MSG);
// 查找下一层看是否存在顶级定义相关文件如果存在则该层属于管理员层级定义的不允许上传文件
long dirCount = edFileInfoService.count(Wrappers.lambdaQuery(EdFileInfo.class)
.eq(EdFileInfo::getParentId, parentId)
.eq(EdFileInfo::getEffectFlag, EffectFlagEnum.EFFECT.code)
.eq(EdFileInfo::getPrjDir, true)
.eq(EdFileInfo::getDataType, EleDataTypeEnum.FOLDER.code));
Assert.isTrue(dirCount == 0, "层级目录不允许上传文件");
String fileName = file.getOriginalFilename();
String mainName = FileUtil.mainName(fileName);
String suffix = FileUtil.getSuffix(fileName);
EdFileInfo newEdFileInfo = new EdFileInfo();
newEdFileInfo.newInit();
try {
Assert.isTrue(EleCommonUtil.isFileNameValid(fileName), NAME_VALID_MSG);
Long count = edFileInfoService.count(Wrappers.lambdaQuery(EdFileInfo.class)
.eq(EdFileInfo::getParentId, parentId)
.eq(EdFileInfo::getFileName, mainName)
.eq(EdFileInfo::getEffectFlag, EffectFlagEnum.EFFECT.code)
.eq(EdFileInfo::getFileType, suffix));
EdFileInfo parentFileInfo = edFileInfoMapper.selectOne(Wrappers.lambdaQuery(EdFileInfo.class)
.eq(EdFileInfo::getId, parentId)
.eq(EdFileInfo::getEffectFlag, EffectFlagEnum.EFFECT.code));
String codePathByDbPath = commonService.getCodePathByDbPath(parentFileInfo.getFilePath());
String fileCode = commonService.createFileCode(codePathByDbPath, suffix, FILE_START_VERSION, newEdFileInfo.getFileTime());
newEdFileInfo.setParentId(parentId)
.setFileCode(fileCode)
.setFileName(mainName)
.setFileType(suffix)
.setFileVersion(FILE_START_VERSION)
.setFileTime(newEdFileInfo.getFileTime())
.setFileSize(file.getSize())
.setFilePath(parentFileInfo.getFilePath() + MYSQL_FILE_PATH_SPLIT + newEdFileInfo.getId())
.setDataType(EleDataTypeEnum.FILE.code)
.setDataStatus(PublishEnum.PUBLISHED.getCode())
.setEffectFlag(EffectFlagEnum.EFFECT.code)
.setFileCode(fileCode)
.setSaveStatus(EleDataSaveStatusEnum.SUCCESS.code)
.setPrjDir(false);
// 文件名加_1存为新文件
if (count > 0) {
edFileInfoService.resetFileInfoName(newEdFileInfo);
}
edFileInfoService.saveOrUpdate(newEdFileInfo);
String fileDestPath = commonService.getFileSysPath(newEdFileInfo.getFilePath());
FileUtil.writeFromStream(file.getInputStream(), fileDestPath);
EleCommonUtil.encryptFile(fileDestPath, SecureUtil.aes(FILE_SEC_PASSWD.getBytes()));
// 创建文件关系
EdFileRelation relation = new EdFileRelation();
relation.setId1(id);
relation.setId2(newEdFileInfo.getId());
relation.setRelationship(descrption);
createRelation(relation);
} catch (Exception e) {
newEdFileInfo.setParentId(parentId)
.setFileName(mainName)
.setFileType(suffix)
.setFileSize(file.getSize())
.setDataType(EleDataTypeEnum.FILE.code)
.setDataStatus(PublishEnum.PUBLISHED.getCode())
.setEffectFlag(EffectFlagEnum.NOT_EFFECTIVE.code)
.setSaveStatus(EleDataSaveStatusEnum.FAIL.code)
.setPrjDir(false);
edFileInfoService.saveOrUpdate(newEdFileInfo);
String info = "上传文件失败";
log.error(info, e);
throw new BizException(info);
}
return ElectromagneticResultUtil.success(true);
}
}

View File

@ -0,0 +1,479 @@
package com.electromagnetic.industry.software.manage.service.serviceimpl;
import cn.hutool.core.lang.Assert;
import cn.hutool.core.text.StrFormatter;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.electromagnetic.industry.software.common.enums.EffectFlagEnum;
import com.electromagnetic.industry.software.common.enums.EleDataSaveStatusEnum;
import com.electromagnetic.industry.software.common.enums.EleDataStatusEnum;
import com.electromagnetic.industry.software.common.enums.EleDataTypeEnum;
import com.electromagnetic.industry.software.common.exception.BizException;
import com.electromagnetic.industry.software.common.resp.ElectromagneticResult;
import com.electromagnetic.industry.software.common.util.EleCommonUtil;
import com.electromagnetic.industry.software.common.util.EleLog;
import com.electromagnetic.industry.software.common.util.ElectromagneticResultUtil;
import com.electromagnetic.industry.software.common.util.UserThreadLocal;
import com.electromagnetic.industry.software.manage.mapper.EdFileInfoMapper;
import com.electromagnetic.industry.software.manage.pojo.models.EdFileInfo;
import com.electromagnetic.industry.software.manage.pojo.req.FolderResortDTO;
import com.electromagnetic.industry.software.manage.pojo.req.QueryPublishStatus;
import com.electromagnetic.industry.software.manage.pojo.resp.ProjectVO;
import com.electromagnetic.industry.software.manage.service.EdPrjService;
import com.electromagnetic.industry.software.manage.service.FileSystemService;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.io.File;
import java.util.*;
import java.util.stream.Collectors;
import static com.electromagnetic.industry.software.common.cons.ElectromagneticConstants.*;
@Service
public class EdPrjServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileInfo> implements EdPrjService {
private final EleLog log = new EleLog(EdPrjServiceImpl.class);
@Resource
private FileSystemService fileSystemService;
@Value("${prj.folder.max.length}")
private int prjFolderMaxLength;
@Resource
private CommonService commonService;
/**
* 创建一个新的工程
*
* @param prjName 新的工程名
*/
@Override
@Transactional(rollbackFor = Exception.class)
public ElectromagneticResult<?> createNewPrj(String prjName) {
Assert.isTrue(EleCommonUtil.isFileNameValid(prjName), NAME_VALID_MSG);
// 首先检查工程是否存在
Long count = this.baseMapper.selectCount(Wrappers.lambdaQuery(EdFileInfo.class)
.eq(EdFileInfo::getParentId, PRJ_PARENT_ID)
.eq(EdFileInfo::getEffectFlag, EffectFlagEnum.EFFECT.code)
.eq(EdFileInfo::getFileName, prjName));
if (count > 0) {
String info = StrFormatter.format("{} 项目已经存在", prjName);
log.info(info);
return ElectromagneticResultUtil.fail("-1", info);
}
try {
// 保存信息到MySQL
String maxPrjId = this.baseMapper.maxPrjId();
int prjCount = this.baseMapper.selectCount(Wrappers.lambdaQuery(EdFileInfo.class).eq(EdFileInfo::getParentId, PRJ_PARENT_ID)).intValue();
int id = Integer.parseInt(StrUtil.isEmpty(maxPrjId) ? "100000" : maxPrjId);
Date now = new Date();
String currentUserId = UserThreadLocal.getUserId();
String newPrjId = String.valueOf(id + 1);
EdFileInfo fileInfo = new EdFileInfo();
String nowTimeStr = EleCommonUtil.getNowTimeStr();
fileInfo.setId(newPrjId)
.setFileId(newPrjId)
.setFileName(prjName)
.setFileVersion(FILE_START_VERSION)
.setParentId(PRJ_PARENT_ID)
.setFileTime(nowTimeStr)
.setPrjDir(true)
.setDataType(EleDataTypeEnum.FOLDER.code)
.setDataStatus(EleDataStatusEnum.NOT_PUBLISHED.code)
.setEffectFlag(EffectFlagEnum.EFFECT.code)
.setSaveStatus(EleDataSaveStatusEnum.SUCCESS.code)
.setFilePath(newPrjId)
.setSort(++prjCount)
.setFileCode(commonService.createFileCode(newPrjId, EleDataTypeEnum.FOLDER.desc, FILE_START_VERSION, nowTimeStr))
.setCreatedTime(now)
.setUpdatedTime(now)
.setCreatedBy(currentUserId)
.setUpdatedBy(currentUserId);
this.save(fileInfo);
// 保存到文件系统
fileSystemService.createDirectory(commonService.getEleDataPath() + File.separator + prjName);
} catch (Exception e) {
String info = StrFormatter.format("文件创建失败,具体为--->{}", e.getMessage());
log.error(info, e);
throw new BizException(info);
}
return ElectromagneticResultUtil.success(true);
}
/**
* 修改项目名称
*
* @param prjId
* @param newPrjName
* @return
*/
@Override
@Transactional(rollbackFor = Exception.class)
public ElectromagneticResult<?> modifyPrjName(String prjId, String newPrjName) {
Assert.isTrue(EleCommonUtil.isFileNameValid(newPrjName), NAME_VALID_MSG);
try {
Long count = this.baseMapper.selectCount(Wrappers.lambdaQuery(EdFileInfo.class)
.eq(EdFileInfo::getParentId, PRJ_PARENT_ID)
.eq(EdFileInfo::getFileName, newPrjName));
if (count > 0) {
String info = StrFormatter.format("{} 项目已经存在", newPrjName);
log.info(info);
return ElectromagneticResultUtil.fail("-1", info);
}
EdFileInfo fileInfo = this.baseMapper.selectOne(Wrappers.lambdaQuery(EdFileInfo.class)
.select(EdFileInfo::getFileName)
.eq(EdFileInfo::getId, prjId));
String oldPrjName = fileInfo.getFileName();
String newPath = commonService.getEleDataPath() + File.separator + newPrjName;
if (fileSystemService.checkFolderExist(newPath)) {
String info = StrFormatter.format("工程名{}已经存在", newPrjName);
log.error(info);
return ElectromagneticResultUtil.fail("-1", info);
}
this.baseMapper.update(null, Wrappers.lambdaUpdate(EdFileInfo.class)
.eq(EdFileInfo::getId, prjId)
.set(EdFileInfo::getFileName, newPrjName)
.set(EdFileInfo::getUpdatedBy, UserThreadLocal.getUserId())
.set(EdFileInfo::getUpdatedTime, new Date()));
fileSystemService.renameFile(commonService.getEleDataPath(), oldPrjName, newPrjName);
} catch (Exception e) {
String info = StrFormatter.format("修改工程名异常--->{}{}", newPrjName, e.getMessage());
log.error(info, e);
throw new BizException(info);
}
return ElectromagneticResultUtil.success(true);
}
/**
* 删除一个项目做逻辑删除
*
* @param prjId
* @return
*/
@Override
@Transactional(rollbackFor = Exception.class)
public ElectromagneticResult<?> delete(String prjId) {
try {
Long count = this.baseMapper.selectCount(Wrappers.lambdaQuery(EdFileInfo.class)
.eq(EdFileInfo::getDataType, EleDataTypeEnum.FILE.code)
.likeRight(EdFileInfo::getFilePath, prjId));
if (count > 0) {
String info = StrFormatter.format("禁止删除非空项目");
log.info(info);
ElectromagneticResultUtil.fail("-1", info);
}
List<String> ids = new ArrayList<>();
ids.add(prjId);
LambdaQueryWrapper<EdFileInfo> queryWrapper = Wrappers.lambdaQuery(EdFileInfo.class)
.select(EdFileInfo::getId)
.likeRight(EdFileInfo::getFilePath, prjId + MYSQL_FILE_PATH_SPLIT);
List<EdFileInfo> edFileInfos = this.baseMapper.selectList(queryWrapper);
edFileInfos.forEach(e -> ids.add(e.getId()));
this.baseMapper.update(null, Wrappers.lambdaUpdate(EdFileInfo.class).set(EdFileInfo::getEffectFlag, EffectFlagEnum.NOT_EFFECTIVE.code).in(EdFileInfo::getId, ids));
return ElectromagneticResultUtil.success(true);
} catch (Exception e) {
String info = "删除项目失败";
log.error(info, e);
throw new BizException(info);
}
}
/**
* 添加子集
*
* @param parentId
* @param folderName
* @return
*/
@Override
@Transactional(rollbackFor = Exception.class)
public ElectromagneticResult<?> addFolder(String parentId, String folderName) {
Assert.isTrue(EleCommonUtil.isFileNameValid(folderName), NAME_VALID_MSG);
// 检查当前目录下有文件如果有则不允许添加
long count = this.baseMapper.selectCount(Wrappers.lambdaQuery(EdFileInfo.class)
.eq(EdFileInfo::getPrjDir, false)
.eq(EdFileInfo::getParentId, parentId)
.eq(EdFileInfo::getEffectFlag, EffectFlagEnum.EFFECT.code));
Assert.isTrue(count == 0, "该层级目录下存在文件,不允许再定义层级目录");
Assert.isTrue(commonService.notExistSameFolder(parentId, folderName), "子集名已经存在");
int id = Integer.parseInt(this.baseMapper.maxPrjId());
String folderId = String.valueOf(id + 1);
return commonService.addFolder(parentId, folderName, true, true, folderId, null);
}
/**
* 查询所有项目
*
* @return
*/
@Override
public ElectromagneticResult<?> queryAllPrjInfo() {
List<String> res = commonService.queryAllPrjInfo(true, null);
List<ProjectVO> projectVOS = new ArrayList<>();
res.forEach(e -> {
ProjectVO projectVO = JSONUtil.toList(e, ProjectVO.class).get(0);
projectVOS.add(projectVO);
});
projectVOS.sort(Comparator.comparing(ProjectVO::getSort));
return ElectromagneticResultUtil.success(projectVOS);
}
/**
* 子集拖拽重排序
*
* @param folderResortDTOList
* @return
*/
@Override
@Transactional(rollbackFor = Exception.class)
public ElectromagneticResult<?> folderResort(List<FolderResortDTO> folderResortDTOList) {
Date now = new Date();
String currentUserId = UserThreadLocal.getUserId();
try {
for (FolderResortDTO folderResortDTO : folderResortDTOList) {
LambdaUpdateWrapper<EdFileInfo> updateWrapper = Wrappers.lambdaUpdate(EdFileInfo.class)
.set(EdFileInfo::getSort, folderResortDTO.getSort())
.set(EdFileInfo::getUpdatedBy, currentUserId)
.set(EdFileInfo::getUpdatedTime, now)
.eq(EdFileInfo::getId, folderResortDTO.getId());
this.update(updateWrapper);
}
return ElectromagneticResultUtil.success(true);
} catch (Exception e) {
String info = "子集重排序异常";
log.error(info, e);
throw new BizException(info);
}
}
/**
* 项目发布
*
* @param prjId
* @return
*/
@Override
@Transactional(rollbackFor = Exception.class)
public ElectromagneticResult<?> publish(String prjId) {
try {
Date now = new Date();
String currentUserId = UserThreadLocal.getUserId();
// 将已经处于删除状态设置成逻辑删除
this.update(Wrappers.lambdaUpdate(EdFileInfo.class)
.eq(EdFileInfo::getDataStatus, EleDataStatusEnum.DELETED.code)
.set(EdFileInfo::getEffectFlag, EffectFlagEnum.NOT_EFFECTIVE.code)
.set(EdFileInfo::getUpdatedBy, currentUserId)
.set(EdFileInfo::getUpdatedTime, now)
.likeRight(EdFileInfo::getFilePath, prjId));
// 其余置为发布状态
LambdaUpdateWrapper<EdFileInfo> updateWrapper = Wrappers.lambdaUpdate(EdFileInfo.class)
.set(EdFileInfo::getDataStatus, EleDataStatusEnum.PUBLISHED.code)
.eq(EdFileInfo::getDataStatus, EleDataStatusEnum.NOT_PUBLISHED.code)
.set(EdFileInfo::getUpdatedBy, currentUserId)
.set(EdFileInfo::getUpdatedTime, now)
.likeRight(EdFileInfo::getFilePath, prjId);
this.update(updateWrapper);
return ElectromagneticResultUtil.success(true);
} catch (Exception e) {
String info = "项目发布异常";
log.error(info, e);
throw new BizException(info);
}
}
/**
* 删除子集
*
* @param fileId
* @return
*/
@Override
@Transactional(rollbackFor = Exception.class)
public ElectromagneticResult<?> deleteFolder(String fileId) {
return commonService.deleteFolder(fileId);
}
/**
* 层级沿用
*
* @param sourceId
* @param targetId
* @return
*/
@Override
@Transactional(rollbackFor = Exception.class)
public ElectromagneticResult<?> follow(String sourceId, String targetId) {
try {
String currentUserId = UserThreadLocal.getUserId();
// 把source工程的层级结构copy到目标工程
// 查找source的全部目录
List<EdFileInfo> sourceEdFileInfos = commonService.selectAllAdminFolder(sourceId, true, null);
List<String> needSavePaths = new ArrayList<>();
// 确定层级最大为prjFolderMaxLength层现在逐层来处理
for (int i = 1; i <= prjFolderMaxLength; ++i) {
List<EdFileInfo> targetEdFileInfos = commonService.selectAllAdminFolder(targetId, true, null);
// 先查找source第i层下有那些子集
final int count = i;
// 取source当前层
List<EdFileInfo> sourceTmpEdFiles = sourceEdFileInfos.stream()
.filter(e -> StrUtil.count(e.getFilePath(), MYSQL_FILE_PATH_SPLIT) == count)
.collect(Collectors.toList());
// 取target父层
List<EdFileInfo> targetTmpEdFiles = targetEdFileInfos.stream()
.filter(e -> StrUtil.count(e.getFilePath(), MYSQL_FILE_PATH_SPLIT) == count - 1)
.collect(Collectors.toList());
// 获取source名称的map
Map<String, EdFileInfo> sourceFileNameMap = sourceTmpEdFiles.stream()
.collect(Collectors.toMap(EdFileInfo::getFileName, e -> e));
// 获取target当前层级的子集名称
List<String> targetFileNames = targetEdFileInfos.stream()
.filter(e -> StrUtil.count(e.getFilePath(), MYSQL_FILE_PATH_SPLIT) == count)
.map(EdFileInfo::getFileName)
.collect(Collectors.toList());
int sort = targetTmpEdFiles.size();
for (EdFileInfo edFileInfo : sourceTmpEdFiles) {
String sourceFileName = edFileInfo.getFileName();
String sourceFileParentName = sourceEdFileInfos.stream().filter(e -> e.getId().equals(edFileInfo.getParentId())).findFirst().get().getFileName();
EdFileInfo targetParentFile = i == 1 ? targetTmpEdFiles.stream().filter(e -> e.getId().equals(targetId)).findFirst().get() : targetTmpEdFiles.stream().filter(e -> e.getFileName().equals(sourceFileParentName)).findFirst().get();
if (!targetFileNames.contains(sourceFileName)) {
EdFileInfo sourceFile = sourceFileNameMap.get(sourceFileName);
EdFileInfo targetFile = new EdFileInfo();
int maxFolderId = Integer.parseInt(this.baseMapper.maxPrjId());
String newFolderId = String.valueOf(maxFolderId + 1);
String nowTimeStr = EleCommonUtil.getNowTimeStr();
String fileCode = commonService.createFileCode(targetParentFile.getId(), EleDataTypeEnum.FOLDER.desc, FILE_START_VERSION, nowTimeStr);
Date now = new Date();
targetFile.setId(newFolderId)
.setFileId(newFolderId)
.setFileName(sourceFile.getFileName())
.setFileVersion(FILE_START_VERSION)
.setPrjDir(true)
.setParentId(targetParentFile.getId())
.setFileTime(nowTimeStr)
.setDataType(EleDataTypeEnum.FOLDER.code)
.setDataStatus(EleDataStatusEnum.NOT_PUBLISHED.code)
.setEffectFlag(EffectFlagEnum.EFFECT.code)
.setFileCode(fileCode)
.setFileType("文件夹")
.setSaveStatus(EleDataSaveStatusEnum.SUCCESS.code)
.setFilePath(targetParentFile.getFilePath() + MYSQL_FILE_PATH_SPLIT + newFolderId)
.setSort(++sort)
.setCreatedTime(now)
.setUpdatedTime(now)
.setCreatedBy(currentUserId)
.setUpdatedBy(currentUserId);
this.save(targetFile);
targetEdFileInfos.add(targetFile);
String targetSysFilePath = commonService.getFileSysPath(targetFile.getFilePath());
needSavePaths.add(targetSysFilePath);
} else {
String info = "存在相同子集";
log.error(info);
throw new BizException(info);
}
}
}
for (String path : needSavePaths) {
fileSystemService.createDirectory(path);
}
return ElectromagneticResultUtil.success(true);
} catch (Exception e) {
String info;
if (e instanceof BizException) {
info = StrFormatter.format("层级沿用失败,{}", e.getMessage());
} else {
info = "层级沿用失败";
}
log.error(info, e);
throw new BizException(info);
}
}
/**
* 修改子集名称
*
* @param id
* @param newFolderName
* @return
*/
@Override
@Transactional(rollbackFor = Exception.class)
public ElectromagneticResult<?> modifyFolder(String id, String newFolderName) {
Assert.isTrue(EleCommonUtil.isFileNameValid(newFolderName), NAME_VALID_MSG);
try {
String parentId = this.baseMapper.selectById(id).getParentId();
// 首先检查同层是否有同名目录
Assert.isTrue(commonService.notExistSameFolder(parentId, newFolderName), "子集名已经存在");
String currentUserId = UserThreadLocal.getUserId();
Date now = new Date();
EdFileInfo fileInfo = this.baseMapper.selectOne(Wrappers.lambdaQuery(EdFileInfo.class)
.eq(EdFileInfo::getId, id));
String sysFilePath = commonService.getFileSysPath(fileInfo.getFilePath());
this.baseMapper.update(null, Wrappers.lambdaUpdate(EdFileInfo.class)
.set(EdFileInfo::getUpdatedTime, now)
.set(EdFileInfo::getUpdatedBy, currentUserId)
.eq(EdFileInfo::getId, id)
.set(EdFileInfo::getFileName, newFolderName));
fileSystemService.renameFile(sysFilePath, newFolderName);
return ElectromagneticResultUtil.success(true);
} catch (Exception e) {
String info = StrFormatter.format("修改子集名称为{}失败", newFolderName);
log.error(info, e);
throw new BizException(info);
}
}
/**
* 获取项目的发布状态
*
* @param queryPublishStatus
* @return
*/
@Override
public ElectromagneticResult<?> publishStatus(QueryPublishStatus queryPublishStatus) {
Map<String, Integer> res = new HashMap<>();
List<String> prjIds = queryPublishStatus.getPrjIds();
List<EdFileInfo> edFileInfos = this.baseMapper.selectList(Wrappers.lambdaQuery(EdFileInfo.class).select(EdFileInfo::getFilePath)
.eq(EdFileInfo::getEffectFlag, EffectFlagEnum.EFFECT.code)
.eq(EdFileInfo::getPrjDir, true)
.and(qr -> qr
.eq(EdFileInfo::getDataStatus, EleDataStatusEnum.NOT_PUBLISHED.code)
.or()
.eq(EdFileInfo::getDataStatus, EleDataStatusEnum.DELETED.code)));
Set<String> unpublishFiles = new HashSet<>();
for (EdFileInfo edFileInfo : edFileInfos) {
String filePath = edFileInfo.getFilePath();
String prjId = filePath.split(MYSQL_FILE_PATH_SPLIT)[0];
unpublishFiles.add(prjId);
}
for (String prjId : prjIds) {
res.put(prjId, EleDataStatusEnum.PUBLISHED.code);
if (unpublishFiles.contains(prjId)) {
res.put(prjId, EleDataStatusEnum.NOT_PUBLISHED.code);
}
}
return ElectromagneticResultUtil.success(res);
}
}

View File

@ -0,0 +1,70 @@
package com.electromagnetic.industry.software.manage.service.serviceimpl;
import cn.hutool.core.io.FileUtil;
import com.electromagnetic.industry.software.manage.service.FileSystemService;
import org.springframework.stereotype.Service;
import java.io.File;
import java.io.InputStream;
import java.nio.charset.Charset;
@Service
public class FileSystemServiceImpl implements FileSystemService {
@Override
public void createDirectory(String path) {
FileUtil.mkdir(path);
}
@Override
public void copyFile(String source, String destination) {
FileUtil.copy(source, destination, true);
}
@Override
public void moveFile(String source, String destination) {
String destParentDir = FileUtil.getParent(destination, 1);
if (!FileUtil.exist(destParentDir)) {
FileUtil.mkdir(destParentDir);
}
if (FileUtil.exist(destination)) {
return;
}
FileUtil.move(new File(source), new File(destination), false);
}
@Override
public void save(InputStream inputStream, String destination) {
FileUtil.writeFromStream(inputStream, destination);
}
@Override
public void renameFile(String sourcePath, String newName) {
FileUtil.rename(new File(sourcePath), newName, true);
}
@Override
public void renameFile(String sourcePath, String oldName, String newName) {
File sourceFile = new File(sourcePath + File.separator + oldName);
FileUtil.rename(sourceFile, newName, true);
}
@Override
public boolean checkFolderExist(String newPath) {
return FileUtil.exist(newPath);
}
@Override
public boolean writeStringToFile(String filePath, String contents) {
FileUtil.writeString(contents, filePath, Charset.defaultCharset());
return true;
}
@Override
public boolean deleteFile(String... filePaths) {
for (String filePath : filePaths) {
FileUtil.del(filePath);
}
return false;
}
}

View File

@ -0,0 +1,230 @@
package com.electromagnetic.industry.software.manage.service.serviceimpl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.electromagnetic.industry.software.common.enums.*;
import com.electromagnetic.industry.software.common.util.UserThreadLocal;
import com.electromagnetic.industry.software.manage.mapper.EdFileInfoMapper;
import com.electromagnetic.industry.software.manage.mapper.UserRoleMapper;
import com.electromagnetic.industry.software.manage.pojo.models.EdFileInfo;
import com.electromagnetic.industry.software.manage.pojo.models.RolePermission;
import com.electromagnetic.industry.software.manage.pojo.models.UserRole;
import com.electromagnetic.industry.software.manage.service.PermissionService;
import com.electromagnetic.industry.software.manage.service.RolePermissionService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.*;
import java.util.stream.Collectors;
@Slf4j
@Service
public class PermissionServiceImpl implements PermissionService {
@Resource
UserRoleMapper userRoleMapper;
@Resource
RolePermissionService rolePermissionService;
@Resource
EdFileInfoMapper edFileInfoMapper;
/**
* 查询当前用户在当前目录的功能权限
*
* @param userId
* @param id
* @return
*/
@Override
@Transactional
public Map<String, Boolean> getUserPermission(String userId, String id, Boolean includeView) {
List<String> roleIds = getRoles(userId);
// 只有当 roleIds 不为空且不为 null 才添加 in 条件
if (roleIds.isEmpty()) {
return new HashMap<>();
}
LambdaQueryWrapper<RolePermission> queryWrapper1 = new LambdaQueryWrapper<>();
queryWrapper1.select(RolePermission::getPermissionCode)
.eq(RolePermission::getFileId, id)
.in(RolePermission::getRoleId, roleIds);
List<String> permissionCodes = rolePermissionService.listObjs(queryWrapper1).stream().map(Object::toString).collect(Collectors.toList());
return transToMap(permissionCodes, includeView);
}
/**
* 获取当前用户有权限访问的目录id
*
* @return
*/
@Override
public List<String> getAccessibleTree() {
String userId = UserThreadLocal.getUserId();
List<String> roleIds = getRoles(userId);
if (roleIds ==null || roleIds.isEmpty()) {
return new ArrayList<>();
}
LambdaQueryWrapper<RolePermission> queryWrapper1 = new LambdaQueryWrapper<>();
queryWrapper1.select(RolePermission::getFileId)
.in(RolePermission::getRoleId, roleIds)
.eq(RolePermission::getPermissionCode, FilePermission.VIEW);
List<String> ids = rolePermissionService.listObjs(queryWrapper1).stream().map(Object::toString).collect(Collectors.toList());
Set<String> result = new HashSet<>();
// 把父亲节点加上
for (String id : ids) {
EdFileInfo file = edFileInfoMapper.selectById(id);
String[] parentIds = file.getFilePath().split("_");
result.addAll(Arrays.asList(parentIds));
}
return new ArrayList<>(result);
}
/**
* 根据用户获得角色
*
* @param userId
* @return
*/
private List<String> getRoles(String userId) {
LambdaQueryWrapper<UserRole> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.select(UserRole::getRoleId).eq(UserRole::getUserId, userId);
return userRoleMapper.selectObjs(queryWrapper).stream().map(Object::toString).collect(Collectors.toList());
}
/**
* 获得角色权限
*
* @param roleId
* @param fileId
* @return
*/
@Override
public List<String> getPermissionCodes(String roleId, String fileId) {
LambdaQueryWrapper<RolePermission> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.select(RolePermission::getPermissionCode)
.eq(RolePermission::getFileId, fileId)
.eq(RolePermission::getRoleId, roleId);
return rolePermissionService.listObjs(queryWrapper).stream().map(Object::toString).collect(Collectors.toList());
}
/**
* 用户权限列表 转换为 哈希
*
* @param permissionCodes
* @return
*/
@Override
public Map<String, Boolean> transToMap(List<String> permissionCodes, Boolean includeView) {
Map<String, Boolean> result = new HashMap<>();
List<String> allCodes = new ArrayList<>();
if (includeView.equals(Boolean.TRUE)) {
allCodes = FilePermission.getAllCodes();
} else {
allCodes = FilePermission.getAllCodesExcludeView();
}
for (String code : allCodes) {
if (permissionCodes.contains(code)) {
result.put(code, true);
} else {
result.put(code, false);
}
}
return result;
}
/**
* 过滤有导出权限的文件id
* @param ids
*/
@Override
public Map<String, Boolean> filterExportIds(String[] ids) {
Map<String, Boolean> map = new HashMap<>();
if (ids.length==0) {
return map;
}
String userId=UserThreadLocal.getUserId();
List<String> roleIds = getRoles(userId);
for (String id : ids) {
LambdaQueryWrapper<RolePermission> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(RolePermission::getFileId, id)
.eq(RolePermission::getPermissionCode, FilePermission.EXPORT.getCode())
.in(RolePermission::getRoleId, roleIds);
long count = rolePermissionService.count(queryWrapper);
map.put(id, count>0);
// 添加父节点
if ( count>0 ) {
EdFileInfo file = edFileInfoMapper.selectById(id);
String[] parentIds = file.getFilePath().split("_");
for (String parentId : parentIds) {
map.put(parentId, true);
}
}
}
return map;
}
/**
* 同步权限
*/
@Override
public void syncPermissions (String prjId) {
// 获取当前项目所有已逻辑删除的节点删除其权限
LambdaQueryWrapper<EdFileInfo> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(EdFileInfo::getDataStatus, EleDataStatusEnum.DELETED.code)
.eq(EdFileInfo::getEffectFlag, EffectFlagEnum.NOT_EFFECTIVE.code)
.likeRight(EdFileInfo::getFilePath, prjId);
List<String> deletedIds = edFileInfoMapper.selectList(queryWrapper).stream().map(EdFileInfo::getId).collect(Collectors.toList());
LambdaQueryWrapper<RolePermission> deleteWrapper = new LambdaQueryWrapper<>();
if (!deletedIds.isEmpty()) {
deleteWrapper.in(RolePermission::getFileId, deletedIds);
rolePermissionService.remove(deleteWrapper);
}
// 获取当前项目所有已发布的节点
LambdaQueryWrapper<EdFileInfo> infoWrapper = new LambdaQueryWrapper<>();
infoWrapper.likeRight(EdFileInfo::getFilePath, prjId)
.eq(EdFileInfo::getEffectFlag, EffectFlagEnum.EFFECT.code)
.eq(EdFileInfo::getDataStatus, EleDataStatusEnum.PUBLISHED.code)
.eq(EdFileInfo::getPrjDir, true);
List<EdFileInfo> files = edFileInfoMapper.selectList(infoWrapper);
// 同步权限
rolePermissionService.syncPermissionsAfterTreeUpdate(files, prjId);
}
/**
* 判断用户有无权限
* @param permissionCode 权限
* @param userId 用户编码
* @param fileId 文件编码
* @return
*/
@Override
public boolean isPermitted (String permissionCode, String userId, String fileId) {
LambdaQueryWrapper<UserRole> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(UserRole::getUserId, userId);
List<String> roleIds = Optional.ofNullable(userRoleMapper.selectList(queryWrapper))
.orElse(Collections.emptyList())
.stream().map(UserRole::getRoleId).collect(Collectors.toList());
if (roleIds.isEmpty()) {
return false;
}
LambdaQueryWrapper<RolePermission> queryWrapper1 = new LambdaQueryWrapper<>();
queryWrapper1.eq(RolePermission::getPermissionCode, permissionCode)
.eq(RolePermission::getFileId, fileId)
.in(RolePermission::getRoleId, roleIds);
return rolePermissionService.count(queryWrapper1)>0;
}
}

View File

@ -0,0 +1,133 @@
package com.electromagnetic.industry.software.manage.service.serviceimpl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.electromagnetic.industry.software.manage.mapper.RolePermissionMapper;
import com.electromagnetic.industry.software.manage.pojo.models.EdFileInfo;
import com.electromagnetic.industry.software.manage.pojo.models.RolePermission;
import com.electromagnetic.industry.software.manage.pojo.req.PublishedFileDTO;
import com.electromagnetic.industry.software.manage.service.RolePermissionService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import java.util.TreeMap;
import java.util.stream.Collectors;
@Slf4j
@Service
public class RolePermissionServiceImpl extends ServiceImpl<RolePermissionMapper, RolePermission> implements RolePermissionService {
@Resource
private RolePermissionMapper rolePermissionMapper;
/**
* 同步新权限
* @param currentPermission
* @param infoId
*/
@Transactional
@Override
public void syncNewPermissions (List<RolePermission> currentPermission, String infoId) {
if (currentPermission == null) {
throw new IllegalArgumentException("currentPermission must not be null");
}
LambdaQueryWrapper<RolePermission> deleteWrapper = new LambdaQueryWrapper<>();
deleteWrapper.eq(RolePermission::getFileId, infoId);
List<RolePermission> oldPermissions = this.list(deleteWrapper);
Set<String> newPermissionSet = currentPermission.stream()
.map(p -> p.getRoleId() + "_" + p.getPermissionCode())
.collect(Collectors.toSet());
List<RolePermission> permissionsToDelete = oldPermissions.stream()
.filter(p -> !newPermissionSet.contains(p.getRoleId() + "_" + p.getPermissionCode()))
.collect(Collectors.toList());
log.info ("删除旧权限: {}", permissionsToDelete);
// 删除不需要的权限
if (!permissionsToDelete.isEmpty()) {
List<Long> idsToDelete = permissionsToDelete.stream()
.map(RolePermission::getId)
.collect(Collectors.toList());
this.removeBatchByIds(idsToDelete);
}
// 批量插入/更新新权限使用 ON DUPLICATE KEY UPDATE 机制
if (!currentPermission.isEmpty()) {
for (RolePermission rp : currentPermission) {
RolePermission exist = this.getOne(new LambdaQueryWrapper<RolePermission>()
.eq(RolePermission::getFileId, rp.getFileId())
.eq(RolePermission::getRoleId, rp.getRoleId())
.eq(RolePermission::getPermissionCode, rp.getPermissionCode()));
if (exist != null) {
rp.setId(exist.getId()); // 赋值已有 ID避免重复插入
}
}
this.saveOrUpdateBatch(currentPermission);
}
}
/**
* 获取新权限
* @param publishedFileDTO
* @return
*/
@Override
public List<RolePermission> getCurrentPermission(PublishedFileDTO publishedFileDTO) {
return rolePermissionMapper.getCurrentPermission(publishedFileDTO);
}
/**
* 在树形结构变动后同步权限
* @param prjId
*/
@Transactional
@Override
public void syncPermissionsAfterTreeUpdate (List<EdFileInfo> files, String prjId) {
log.info("开始同步项目权限:{}", prjId);
// 对files分层
TreeMap<Integer, List<EdFileInfo>> levelMap = new TreeMap<>();
for (EdFileInfo file : files) {
int len = file.getFilePath().split("_").length;
levelMap.computeIfAbsent(len, k -> new ArrayList<>()).add(file);
}
System.out.println("levelMap:"+levelMap);
// 获取叶子节点
int maxLen = levelMap.lastKey();
// 从最底层的叶子节点的上级节点开始遍历,更新权限
for (int i=maxLen-1; i>0;i--) {
for (EdFileInfo fileInfo : levelMap.get(i)) {
String infoId = fileInfo.getId();
if (isLeafNode(infoId, files)) {
continue;
}
PublishedFileDTO publishedFileDTO = new PublishedFileDTO();
publishedFileDTO.newInit();
publishedFileDTO.setFileId(infoId);
List<RolePermission> currentPermission = getCurrentPermission(publishedFileDTO);
syncNewPermissions(currentPermission, infoId);
}
}
log.info("同步项目权限结束:{}", prjId);
}
private boolean isLeafNode(String id, List<EdFileInfo> files) {
Set<String> parentIdSet = files.stream()
.map(EdFileInfo::getParentId)
.collect(Collectors.toSet());
return !parentIdSet.contains(id);
}
}

View File

@ -0,0 +1,388 @@
package com.electromagnetic.industry.software.manage.service.serviceimpl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.electromagnetic.industry.software.common.enums.EffectFlagEnum;
import com.electromagnetic.industry.software.common.enums.EleDataStatusEnum;
import com.electromagnetic.industry.software.common.enums.EleDataTypeEnum;
import com.electromagnetic.industry.software.common.enums.FilePermission;
import com.electromagnetic.industry.software.common.exception.BizException;
import com.electromagnetic.industry.software.common.util.EleLog;
import com.electromagnetic.industry.software.common.util.IdWorker;
import com.electromagnetic.industry.software.common.util.UserThreadLocal;
import com.electromagnetic.industry.software.manage.mapper.EdFileInfoMapper;
import com.electromagnetic.industry.software.manage.mapper.RoleMapper;
import com.electromagnetic.industry.software.manage.pojo.models.EdFileInfo;
import com.electromagnetic.industry.software.manage.pojo.models.Role;
import com.electromagnetic.industry.software.manage.pojo.models.RolePermission;
import com.electromagnetic.industry.software.manage.pojo.models.UserRole;
import com.electromagnetic.industry.software.manage.pojo.req.RoleDTO;
import com.electromagnetic.industry.software.manage.pojo.req.RolePageDTO;
import com.electromagnetic.industry.software.manage.pojo.req.RolePermissionDTO;
import com.electromagnetic.industry.software.manage.service.PermissionService;
import com.electromagnetic.industry.software.manage.service.RolePermissionService;
import com.electromagnetic.industry.software.manage.service.RoleService;
import com.electromagnetic.industry.software.manage.service.UserRoleService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.*;
import java.util.stream.Collectors;
import static com.electromagnetic.industry.software.common.cons.ElectromagneticConstants.PRJ_PARENT_ID;
@Service
public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role> implements RoleService {
@Resource
private RolePermissionService rolePermissionService;
@Resource
private UserRoleService userRoleService;
@Resource
private PermissionService permissionService;
private EleLog log = new EleLog(RoleServiceImpl.class);
@Resource
private RoleMapper roleMapper;
@Resource
private EdFileInfoMapper edFileInfoMapper;
/**
* 新建角色
*
* @param roleDTO
* @return
*/
@Transactional
@Override
public Boolean createRole(RoleDTO roleDTO) {
if (!checkRoleNameUnique(roleDTO)) {
String info = "当前角色名称已存在:" + roleDTO.getRoleName();
log.error(info);
throw new BizException(info);
}
// 创建角色
Role role = new Role();
// 创建角色编号
String roleId = IdWorker.getSnowFlakeIdString();
role.setRoleId(roleId);
role.setRoleName(roleDTO.getRoleName());
role.setRoleDesc(roleDTO.getRoleDesc());
role.setCreator(UserThreadLocal.getUserId());
role.setCreatorName(UserThreadLocal.getUsername());
this.save(role);
// 创建权限
List<RolePermissionDTO> data = roleDTO.getData();
List<RolePermission> list = flattenTree(data, roleId);
rolePermissionService.saveBatch(list);
return true;
}
/**
* 更新角色
*
* @param roleDTO
* @return
*/
@Transactional
@Override
public Boolean updateRole(RoleDTO roleDTO) {
if (!checkRoleNameUnique(roleDTO)) {
String info = "当前角色名称已存在:" + roleDTO.getRoleName();
log.error(info);
throw new BizException(info);
}
// 更新角色信息
LambdaUpdateWrapper<Role> updateWrapper = new LambdaUpdateWrapper<>();
updateWrapper.eq(Role::getRoleId, roleDTO.getRoleId())
.set(Role::getRoleName, roleDTO.getRoleName())
.set(Role::getRoleDesc, roleDTO.getRoleDesc())
.set(Role::getModifier, UserThreadLocal.getUserId())
.set(Role::getModifierName, UserThreadLocal.getUsername());
this.update(updateWrapper);
// 删除旧权限信息
LambdaQueryWrapper<RolePermission> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(RolePermission::getRoleId, roleDTO.getRoleId());
rolePermissionService.remove(queryWrapper);
// 插入新权限信息
List<RolePermissionDTO> data = roleDTO.getData();
List<RolePermission> list = flattenTree(data, roleDTO.getRoleId());
rolePermissionService.saveBatch(list);
return true;
}
/**
* 删除角色
*
* @param roleId
* @return
*/
@Transactional
@Override
public Boolean deleteRole(String roleId) {
// 删除角色权限关联表
LambdaQueryWrapper<RolePermission> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(RolePermission::getRoleId, roleId);
rolePermissionService.remove(queryWrapper);
// 删除用户角色关联表
LambdaQueryWrapper<UserRole> queryWrapper1 = new LambdaQueryWrapper<>();
queryWrapper1.eq(UserRole::getRoleId, roleId);
userRoleService.remove(queryWrapper1);
// 删除角色
LambdaQueryWrapper<Role> queryWrapper2 = new LambdaQueryWrapper<>();
queryWrapper2.eq(Role::getRoleId, roleId);
return this.remove(queryWrapper2);
}
/**
* 查看角色
*
* @param roleId
* @return
*/
@Transactional
@Override
public RoleDTO getRole(String roleId) {
RoleDTO roleDTO = new RoleDTO();
QueryWrapper<Role> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("role_id", roleId);
Role role = this.getOne(queryWrapper);
roleDTO.setRoleId(role.getRoleId());
roleDTO.setRoleName(role.getRoleName());
roleDTO.setRoleDesc(role.getRoleDesc());
List<EdFileInfo> infos = getFiles();
List<RolePermissionDTO> nodes = new ArrayList<>();
for (EdFileInfo info : infos) {
RolePermissionDTO rolePermissionDTO = new RolePermissionDTO();
rolePermissionDTO.setId(info.getId());
rolePermissionDTO.setParentId(info.getParentId());
rolePermissionDTO.setFileName(info.getFileName());
List<String> permissionCodes = permissionService.getPermissionCodes(roleId, info.getId());
if (!permissionCodes.isEmpty()) {
Map<String, Boolean> dataAuth = new HashMap<>();
dataAuth.put("data", true);
rolePermissionDTO.setDataAuth(dataAuth);
} else {
Map<String, Boolean> dataAuth = new HashMap<>();
dataAuth.put("data", false);
rolePermissionDTO.setDataAuth(dataAuth);
}
rolePermissionDTO.setPermission(permissionService.transToMap(permissionCodes,false));
nodes.add(rolePermissionDTO);
}
roleDTO.setData(buildTree(nodes));
return roleDTO;
}
/**
* 通过角色名查看角色
*
* @param roleName
* @return
*/
@Transactional
@Override
public RoleDTO getRoleByName(String roleName) {
LambdaQueryWrapper<Role> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(Role::getRoleName, roleName);
Role role = this.getOne(queryWrapper);
return getRole(role.getRoleId());
}
/**
* 查看角色列表
*
* @param rolePageDTO
* @return
*/
@Transactional
@Override
public IPage<RoleDTO> getRoles(RolePageDTO rolePageDTO) {
// 创建分页对象
Page<RoleDTO> page = new Page<>(rolePageDTO.getPageIndex(), rolePageDTO.getPageSize());
QueryWrapper<Role> queryWrapper = new QueryWrapper<>();
if (StringUtils.isNotBlank(rolePageDTO.getRoleId())) {
queryWrapper.eq("r.role_id", rolePageDTO.getRoleId());
}
if (StringUtils.isNotBlank(rolePageDTO.getRoleName())) {
queryWrapper.eq("r.role_name", rolePageDTO.getRoleName());
}
IPage<RoleDTO> result = roleMapper.getPageRoleDTO(page, queryWrapper);
for (RoleDTO roleDTO : result.getRecords()) {
if (roleDTO.getAllowedActions() != null ) {
String chineseString = Arrays.stream(roleDTO.getAllowedActions().split(",")).map(FilePermission::toDescription).collect(Collectors.joining(","));
roleDTO.setAllowedActions(chineseString);
}
}
return result;
}
/**
* 获取所有角色名
*
* @return
*/
@Transactional
@Override
public List<HashMap<String, String>> getAllRoleNames() {
LambdaQueryWrapper<Role> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.select(Role::getRoleName);
List<String> roleNames = this.listObjs(queryWrapper).stream().map(Object::toString).collect(Collectors.toList());
List<HashMap<String, String>> result = new ArrayList<>();
for (String roleName : roleNames) {
HashMap<String, String> map = new HashMap<>();
map.put("value", roleName);
map.put("label", roleName);
result.add(map);
}
return result;
}
/**
* 空树
*
* @return
*/
@Transactional
@Override
public RoleDTO getRoleTemplate() {
RoleDTO roleDTO = new RoleDTO();
List<EdFileInfo> infos = getFiles();
List<RolePermissionDTO> nodes = new ArrayList<>();
for (EdFileInfo info : infos) {
RolePermissionDTO rolePermissionDTO = new RolePermissionDTO();
rolePermissionDTO.setId(info.getId());
rolePermissionDTO.setParentId(info.getParentId());
rolePermissionDTO.setFileName(info.getFileName());
List<String> permissionCodes = new ArrayList<>();
Map<String, Boolean> dataAuth = new HashMap<>();
dataAuth.put("data", false);
rolePermissionDTO.setDataAuth(dataAuth);
rolePermissionDTO.setPermission(permissionService.transToMap(permissionCodes,false));
nodes.add(rolePermissionDTO);
}
roleDTO.setData(buildTree(nodes));
return roleDTO;
}
/**
* 校验当前角色名称是否唯一
*
* @param roleDTO
* @return
*/
private Boolean checkRoleNameUnique(RoleDTO roleDTO) {
QueryWrapper<Role> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("role_name", roleDTO.getRoleName());
Role role = this.getOne(queryWrapper);
return role == null || role.getRoleId().equals(roleDTO.getRoleId());
}
/**
* 权限层级数据扁平化
*
* @param nodes
* @param roleId
* @return
*/
private List<RolePermission> flattenTree(List<RolePermissionDTO> nodes, String roleId) {
List<RolePermission> flatList = new ArrayList<>();
for (RolePermissionDTO node : nodes) {
flattenNode(node, flatList, roleId);
}
return flatList;
}
private void flattenNode(RolePermissionDTO node, List<RolePermission> flatList, String roleId) {
node.getPermission().forEach((code, hasPermission) -> {
if (Boolean.TRUE.equals(hasPermission)) { // 检查权限值是否为 true
flatList.add(new RolePermission(roleId, node.getId(), code));
}
});
if (node.getDataAuth().get("data").equals(Boolean.TRUE)) {
flatList.add(new RolePermission(roleId, node.getId(), FilePermission.VIEW.getCode()));
}
// 添加当前节点
if (node.getChildren() != null && !node.getChildren().isEmpty()) {
for (RolePermissionDTO child : node.getChildren()) {
flattenNode(child, flatList, roleId); // 递归处理子节点
}
}
}
// 构建层级结构
private List<RolePermissionDTO> buildTree(List<RolePermissionDTO> nodes) {
// 找到所有的根节点
List<RolePermissionDTO> rootNodes = nodes.stream()
.filter(node -> node.getParentId().equals(PRJ_PARENT_ID))
.collect(Collectors.toList());
// 递归设置子节点
for (RolePermissionDTO rootNode : rootNodes) {
rootNode.setChildren(findChildren(rootNode, nodes));
}
return rootNodes;
}
// 递归查找子节点
private List<RolePermissionDTO> findChildren(RolePermissionDTO parent, List<RolePermissionDTO> nodes) {
return nodes.stream()
.filter(node -> parent.getId().equals(node.getParentId())) // 匹配父子关系
.peek(node -> node.setChildren(findChildren(node, nodes))) // 递归设置子节点
.collect(Collectors.toList());
}
/**
* 获取层级树结构
*
* @return
*/
private List<EdFileInfo> getFiles() {
return edFileInfoMapper.selectList(Wrappers.lambdaQuery(EdFileInfo.class)
.eq(EdFileInfo::getEffectFlag, EffectFlagEnum.EFFECT.code)
.eq(EdFileInfo::getDataType, EleDataTypeEnum.FOLDER.code)
.eq(EdFileInfo::getPrjDir, true)
.and(wrapper -> wrapper.eq(EdFileInfo::getDataStatus, EleDataStatusEnum.PUBLISHED.code)
.or()
.eq(EdFileInfo::getDataStatus, EleDataStatusEnum.DELETED.code)));
}
}

View File

@ -1,27 +0,0 @@
package com.electromagnetic.industry.software.manage.service.serviceimpl;
import com.electromagnetic.industry.software.common.pojo.UserLoginInfo;
import com.electromagnetic.industry.software.manage.pojo.models.User;
import com.electromagnetic.industry.software.manage.service.TokenService;
public class TokenServiceImpl implements TokenService {
@Override
public String createToken(UserLoginInfo loginInfo) {
return "";
}
@Override
public Boolean createUserToken(User user, String tokenStr) {
return null;
}
@Override
public Boolean isTokenValid(String tokenStr) {
return null;
}
@Override
public int deleteToken(String tokenStr) {
return 0;
}
}

View File

@ -0,0 +1,11 @@
package com.electromagnetic.industry.software.manage.service.serviceimpl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.electromagnetic.industry.software.manage.mapper.UserRoleMapper;
import com.electromagnetic.industry.software.manage.pojo.models.UserRole;
import com.electromagnetic.industry.software.manage.service.UserRoleService;
import org.springframework.stereotype.Service;
@Service
public class UserRoleServiceImpl extends ServiceImpl<UserRoleMapper, UserRole> implements UserRoleService {
}

View File

@ -2,18 +2,23 @@ package com.electromagnetic.industry.software.manage.service.serviceimpl;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.SystemClock;
import cn.hutool.core.util.RandomUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.electromagnetic.industry.software.common.cons.UserConstants;
import com.electromagnetic.industry.software.common.enums.ActiveEnum;
import com.electromagnetic.industry.software.common.enums.EffectFlagEnum;
import com.electromagnetic.industry.software.common.enums.ElectromagneticErrorEnum;
import com.electromagnetic.industry.software.common.enums.PublishEnum;
import com.electromagnetic.industry.software.common.exception.BizException;
import com.electromagnetic.industry.software.common.pojo.UserLoginInfo;
import com.electromagnetic.industry.software.common.resp.ElectromagneticResult;
import com.electromagnetic.industry.software.common.util.*;
import com.electromagnetic.industry.software.manage.mapper.TokenMapper;
import com.electromagnetic.industry.software.manage.mapper.UserMapper;
import com.electromagnetic.industry.software.manage.mapper.UserMappers;
import com.electromagnetic.industry.software.manage.mapper.*;
import com.electromagnetic.industry.software.manage.pojo.models.Role;
import com.electromagnetic.industry.software.manage.pojo.models.Token;
import com.electromagnetic.industry.software.manage.pojo.models.User;
import com.electromagnetic.industry.software.manage.pojo.models.UserRole;
import com.electromagnetic.industry.software.manage.pojo.other.PublishParam;
import com.electromagnetic.industry.software.manage.pojo.other.SearchKeyWords;
import com.electromagnetic.industry.software.manage.pojo.other.SingleUserResponse;
@ -24,14 +29,12 @@ import com.electromagnetic.industry.software.manage.pojo.resp.UserSearchResponse
import com.electromagnetic.industry.software.manage.service.UserService;
import io.jsonwebtoken.Jwts;
import io.jsonwebtoken.SignatureAlgorithm;
import org.apache.commons.lang3.RandomStringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import static cn.hutool.core.date.DateTime.now;
@ -42,9 +45,14 @@ public class UserServiceImpl implements UserService {
private UserMapper userMapper;
@Resource
private TokenMapper tokenMapper;
@Resource
private UserRoleMapper userRoleMapper;
@Resource
private RoleMapper roleMapper;
/**
* 用户登录
*
* @param loginRequest
* @return
*/
@ -55,7 +63,8 @@ public class UserServiceImpl implements UserService {
User user = userMapper.selectUserByWorkNumber(info.getWorkNumber());
info.setUserId(user.getUserId());
info.setUsername(user.getUserName());
if ( checkUserValid(user) && matchPassword(user, decodePwd)) {
info.setAdminType(user.getAdminType());
if (checkUserValid(user) && matchPassword(user, decodePwd)) {
String tokenStr = createToken(info);
createUserToken(user, tokenStr);
UserLoginResponse userLoginResponse = new UserLoginResponse();
@ -63,49 +72,50 @@ public class UserServiceImpl implements UserService {
userLoginResponse.setUserId(user.getUserId());
return ElectromagneticResultUtil.success(userLoginResponse);
}
return ElectromagneticResultUtil.fail("500","用户不存在/密码错误");
return ElectromagneticResultUtil.fail("500", "用户不存在/密码错误");
}
public Boolean createUserToken (User user, String tokenStr){
public Boolean createUserToken(User user, String tokenStr) {
Token token = new Token();
token.setUserId(user.getUserId());
token.setToken(tokenStr);
token.setExpireAt(new DateTime(SystemClock.now()+ UserConstants.DEFAULT_EXPIRE_TIME));
return tokenMapper.insert(token)>0;
token.setExpireAt(new DateTime(SystemClock.now() + UserConstants.DEFAULT_EXPIRE_TIME));
return tokenMapper.insert(token) > 0;
}
public Boolean checkUserValid(User user){
if ( user == null
|| user.getIsPublished() == PublishEnum.UNPUBLISHED.getCode()
|| user.getEffectFlag() == EffectFlagEnum.EFFECT_FLAG_0.getCode()
public Boolean checkUserValid(User user) {
if (user == null
|| Objects.equals(user.getIsPublished(), PublishEnum.UNPUBLISHED.getCode())
|| Objects.equals(user.getIsActivated(), ActiveEnum.UNACTIVATED.getCode())
|| Objects.equals(user.getEffectFlag(), EffectFlagEnum.NOT_EFFECTIVE.code)
) {
return false;
} else if( user.getInternshipEndDate()!=null && user.getInternshipEndDate().before(now())) {
return false;
}
return true;
} else return user.getInternshipEndDate() == null || !user.getInternshipEndDate().before(now());
}
public String createToken(UserLoginInfo loginInfo){
public String createToken(UserLoginInfo loginInfo) {
Map<String, Object> claims = new HashMap<>();
claims.put(UserConstants.LOGIN_USER_ID, loginInfo.getUserId());
claims.put(UserConstants.LOGIN_USER_NAME, loginInfo.getUsername());
claims.put(UserConstants.LOGIN_WORK_NUMBER, loginInfo.getWorkNumber());
claims.put(UserConstants.LOGIN_ADMIN_TYPE, loginInfo.getAdminType());
return Jwts.builder()
.addClaims(claims)
.setId(UUID.randomUUID().toString())
.setIssuedAt(DateTime.now())
.signWith(SignatureAlgorithm.HS512, UserConstants.SECRET_KEY)
.compact();
}
public Boolean matchPassword(User user, String password){
public Boolean matchPassword(User user, String password) {
String salt = user.getSalt();
String encodePwd = SignUtils.MD5(password+salt);
String encodePwd = SignUtils.MD5(password + salt);
return user.getUserPwd().equals(encodePwd);
}
/**
* 新增用户信息
*
* @param userRequest
* @return
*/
@ -113,10 +123,15 @@ public class UserServiceImpl implements UserService {
public ElectromagneticResult<?> createUser(UserRequest userRequest) {
User user = UserMappers.INSTANCE.getUserRequestToModel(userRequest);
user.setSalt(RandomStringUtils.randomAlphanumeric(16));
user.setSalt(RandomUtil.randomString(16));
user.setUserId(IdWorker.getSnowFlakeIdString());
user.setUserPwd(SignUtils.MD5(UserConstants.DEFAULT_PASSWORD+user.getSalt()));
user.setUserPwd(SignUtils.MD5(UserConstants.DEFAULT_PASSWORD + user.getSalt()));
user.setIsPublished(UserConstants.DEFAULT_PUBLISH_STATUS);
user.setIsActivated(UserConstants.DEFAULT_ACTIVE_STATUS);
// 暂时将账户设置为工号
user.setUserAccount(user.getWorkNumber());
user.setCreator(UserThreadLocal.getUserId());
user.setCreatorName(UserThreadLocal.getUsername());
return ElectromagneticResultUtil.success(userMapper.insert(user) > 0);
@ -124,6 +139,7 @@ public class UserServiceImpl implements UserService {
/**
* 修改用户信息
*
* @param userModiRequest
* @return
*/
@ -137,6 +153,7 @@ public class UserServiceImpl implements UserService {
/**
* 发布用户信息
*
* @param userPublishRequest
* @return
*/
@ -145,7 +162,7 @@ public class UserServiceImpl implements UserService {
PublishParam model = UserMappers.INSTANCE.getUserPublishRequestToModel(userPublishRequest);
model.setModifier(UserThreadLocal.getUserId());
model.setModifierName(UserThreadLocal.getUsername());
return ElectromagneticResultUtil.success(userMapper.publish(model) > 0 );
return ElectromagneticResultUtil.success(userMapper.publish(model) > 0);
}
@Override
@ -154,30 +171,30 @@ public class UserServiceImpl implements UserService {
User user = UserMappers.INSTANCE.getUserWorkNumRequestToModel(workNumberRequest);
//根据请求对象的userId判断当前处于什么状态
if(user.getUserId()==null){
if (user.getUserId() == null) {
//userId为空表示是新增用户阶段
//判断数据库中有无该工号对应的用户
User existingUser = userMapper.selectUserByWorkNumber(user.getWorkNumber());
//如果有该用户就返回false,如果没有(==null)就返回true
boolean isWorkNumberUnique = (existingUser == null);
return ElectromagneticResultUtil.success(isWorkNumberUnique);
}else{
} else {
//userId不为空表示是编辑用户阶段
//请求对象的userWordNum在数据库中对应的user
User existingUser = userMapper.selectUserByWorkNumber(user.getWorkNumber());
//判断请求对象的userId对应的user和请求对象的userWordNum在数据库中对应的user是否为用一个
if(existingUser!=null){
if (existingUser != null) {
//请求对象的userWordNum在数据库中对应的user与请求对象的userId对应的user是否为同一个
if(user.getUserId().equals(existingUser.getUserId())){
if (user.getUserId().equals(existingUser.getUserId())) {
// 如果获取到的用户ID与当前编辑的用户ID相同说明工号未改变直接返回true
return ElectromagneticResultUtil.success(true);
}else{
} else {
// 如果获取到的用户ID与当前编辑的用户ID不同说明工号已改变需要判断新工号是否唯一
// 如果根据新工号获取不到用户说明新工号唯一
boolean isWorkNumberUnique = (userMapper.selectUserByWorkNumber(user.getWorkNumber()) == null);
return ElectromagneticResultUtil.success(isWorkNumberUnique);
}
}else{
} else {
//请求对象的userWordNum在数据库中不存在对应的user
return ElectromagneticResultUtil.success(true);
}
@ -194,13 +211,32 @@ public class UserServiceImpl implements UserService {
@Override
public ElectromagneticResult<?> searchUser(SearchUserRequest searchUserRequest) {
searchUserRequest.setPageIndex((searchUserRequest.getPageIndex()-1)*searchUserRequest.getPageSize());
SearchKeyWords model = UserMappers.INSTANCE.getSearchKeywordsRequestToModel(searchUserRequest);
List<User> userList = userMapper.search(model);
searchUserRequest.setPageIndex((searchUserRequest.getPageIndex() - 1) * searchUserRequest.getPageSize());
SearchKeyWords model = new SearchKeyWords();
BeanUtils.copyProperties(searchUserRequest, model);
List<User> userList = userMapper.search(model);
int totalCount = userMapper.getTotalCount(model);
List<SingleUserResponse> singleUserResponseList = UserMappers.INSTANCE.userListToResponseList(userList);
UserSearchResponse userSearchResponse = new UserSearchResponse();
userSearchResponse.setUserList(singleUserResponseList);
List<SingleUserResponse> list = new ArrayList<>();
for (User user : userList) {
SingleUserResponse singleUserResponse = new SingleUserResponse();
BeanUtils.copyProperties(user, singleUserResponse);
List<String> roleList = userMapper.selectUserRoles(user.getUserId());
String roles = String.join(",", roleList);
singleUserResponse.setRoles(roles);
singleUserResponse.setRoleList(roleList);
// 检查密码是否和初始密码相同
if (user.getUserPwd().equals(SignUtils.MD5(UserConstants.DEFAULT_PASSWORD + user.getSalt()))) {
singleUserResponse.setIsDefaultPwd(1);
} else {
singleUserResponse.setIsDefaultPwd(0);
}
list.add(singleUserResponse);
}
UserSearchResponse userSearchResponse = new UserSearchResponse();
userSearchResponse.setUserList(list);
userSearchResponse.setTotalCount(totalCount);
return ElectromagneticResultUtil.success(userSearchResponse);
}
@ -215,15 +251,15 @@ public class UserServiceImpl implements UserService {
// 检查用户是否已经被逻辑删除
User existingUser = userMapper.getSingleUser(userDeleteKeyWords.getUserId());
if(existingUser != null && existingUser.getEffectFlag()==0){
if (existingUser != null && existingUser.getEffectFlag() == 0) {
// 如果用户已经被逻辑删除在这个假设中0 表示已删除则不进行任何操作或返回错误
return ElectromagneticResultUtil.fail(ElectromagneticErrorEnum. FINE_DELETE_USER_ERROR);
return ElectromagneticResultUtil.fail(ElectromagneticErrorEnum.FINE_DELETE_USER_ERROR);
}
if(existingUser!=null && existingUser.getEffectFlag()==1){// 在这个假设中1 表示未删除
if (existingUser != null && existingUser.getEffectFlag() == 1) {// 在这个假设中1 表示未删除
return ElectromagneticResultUtil.success(userMapper.deleteUser(userDeleteKeyWords));
}else{
} else {
// 如果用户不存在理论上不应该发生除非数据库状态不一致则返回错误
return ElectromagneticResultUtil.fail(ElectromagneticErrorEnum. FINE_DELETE_USER_ERROR);
return ElectromagneticResultUtil.fail(ElectromagneticErrorEnum.FINE_DELETE_USER_ERROR);
}
}
@ -233,4 +269,63 @@ public class UserServiceImpl implements UserService {
token = token.substring(7);
return ElectromagneticResultUtil.success(tokenMapper.deleteToken(token));
}
/**
* 人员绑定
*/
@Override
public Boolean bindRoles(List<UserBindRoleDTO> list) {
if (list == null || list.isEmpty()) {
throw new BizException("请勿发布空数据");
}
for (UserBindRoleDTO dto : list) {
activeRole(dto);
bindRole(dto);
}
return Boolean.TRUE;
}
/**
* 重置密码
*
* @param userId
*/
@Override
@Transactional
public Boolean resetPassword(String userId) {
User user = userMapper.getSingleUser(userId);
user.setUserPwd(SignUtils.MD5(UserConstants.DEFAULT_PASSWORD + user.getSalt()));
return userMapper.modify(user) > 0;
}
private void activeRole(UserBindRoleDTO dto) {
User user = userMapper.getSingleUser(dto.getUserId());
if (user.getIsActivated().equals(ActiveEnum.UNACTIVATED.getCode())) {
user.setIsActivated(ActiveEnum.ACTIVATED.getCode());
userMapper.modify(user);
}
}
private void bindRole(UserBindRoleDTO dto) {
String userId = dto.getUserId();
List<String> roleNames = dto.getRoleList();
// 删除当前用户原绑定角色
QueryWrapper<UserRole> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("user_id", userId);
userRoleMapper.delete(queryWrapper);
if (roleNames != null) {
for (String roleName : roleNames) {
LambdaQueryWrapper<Role> roleQueryWrapper = new LambdaQueryWrapper<>();
roleQueryWrapper.select(Role::getRoleId)
.eq(Role::getRoleName, roleName);
String roleId = roleMapper.selectOne(roleQueryWrapper).getRoleId();
UserRole userRole = new UserRole();
userRole.setUserId(userId);
userRole.setRoleId(roleId);
userRoleMapper.insert(userRole);
}
}
}
}

View File

@ -1,45 +1,24 @@
#required
spring.application.name=electromagnetic-data
# security
run.mode=NORMAL
com.alipay.env=shared
#log
logging.file.path=./logs
loggerPath=electromagnetic-data
logging.level.com.aliyun.fsi.insurance=${LOG_LEVEL:INFO}
#日志配置
logging.config=classpath:${LOG_CONFIG:log4j2-spring.xml}
spring.datasource.typd=com.alibaba.druid.pool.DruidDataSource
spring.datasource.url=jdbc:mysql://139.224.43.89:3306/em_data?serverTimezone=UTC&useUnicode=true&characterEncoding=utf-8&useSSL=true&serverTimezone=GMT%2B8&allowMultiQueries=true&rewriteBatchedStatements=true
spring.datasource.username=comac
spring.datasource.password=2024*Comac
spring.servlet.multipart.max-file-size=500MB
spring.servlet.multipart.max-request-size=10MB
spring.datasource.url=jdbc:mysql://139.196.179.195:3306/em_data_test?serverTimezone=UTC&useUnicode=true&characterEncoding=utf-8&useSSL=true&serverTimezone=GMT%2B8&allowMultiQueries=true&rewriteBatchedStatements=true
spring.datasource.username=em_user_test
spring.datasource.password=Szsd#2O25$test
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.type=com.alibaba.druid.pool.DruidDataSource
mybatis-plus.mapper-locations=classpath:sqlmapper/*.xml
mybatis-plus.configuration.log-impl=org.apache.ibatis.logging.stdout.StdOutImpl
spring.servlet.multipart.max-file-size=500MB
spring.servlet.multipart.max-request-size=10MB
pagehelper.helperDialect=mysql
pagehelper.reasonable=false
server.port=12365
server.port=12395
file.security.passwd=adknfhkj87654knd
data.windows.path=D:/tmp/eleData/project/
data.linux.path=/szsd/data/eleData/project/
data.upload.windows.tmp.path=D:/tmp/eleData/upload/
data.upload.linux.tmp.path=/szsd/data/eleData/upload/
data.download.windows.tmp.path=D:/tmp/eleData/download/
data.download.linux.tmp.path=/szsd/data/eleData/download/
prj.folder.max.length=6
#windows文件存储目录
data.windows.path=E:/comacFileStorage/
#文件缓存路径
data.file.cache.dir=/szsd/cache/
#文件存储路径
data.file.storage.dir=/szsd/fileStorage/
#上传文件时文件的缓存文件夹名称
data.upload.cache.dir=upload
#导出数据时文件的缓存文件夹名称
data.export.cache.dir=export
#导入数据时文件的缓存文件夹名称
data.import.cache.dir=import
file.encode.passwd=adknfhkj87654knd
#数据类型中的文件类型为file
data.type.file=file
#数据类型中的文件夹类型为folder
data.type.folder=folder

View File

@ -1,5 +0,0 @@
log4j.rootLogger=DEBUG, stdout
# Console output...
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%5p [%t] - %m%n

View File

@ -1,205 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<Configuration>
<properties>
<property name="LOG_LEVEL" value="INFO"/>
<property name="APP_NAME" value="electromagnetic-data"/>
<property name="LOG_HOME" value="./logs/${APP_NAME}"/>
<property name="LOG_LAYOUT" value="%d{yyyy-MM-dd HH:mm:ss.SSS},%t,%r,%-5p,%X{SOFA-TraceId},%X{SOFA-SpanId},%c{2},%m%n%throwable"/>
<property name="SIMPLE_LAYOUT" value="%d{yyyy-MM-dd HH:mm:ss.SSS} %m%n%"/>
</properties>
<Appenders>
<Console name="STDOUT-APPENDER" target="SYSTEM_OUT">
<PatternLayout pattern="${LOG_LAYOUT}" charset="UTF-8"/>
</Console>
<Console name="STDERR-APPENDER" target="SYSTEM_ERR">
<PatternLayout pattern="${LOG_LAYOUT}" charset="UTF-8"/>
</Console>
<!-- 错误节点日志 -->
<RollingFile name="ERROR-APPENDER" fileName="${LOG_HOME}/common-error.log"
filePattern="${LOG_HOME}/common-error-%d{yyyy-MM-dd}_%i.log" append="true">
<Filters>
<ThresholdFilter level="ERROR" onMatch="ACCEPT" onMismatch="DENY"/>
</Filters>
<PatternLayout pattern="${LOG_LAYOUT}" charset="UTF-8"/>
<Policies>
<SizeBasedTriggeringPolicy size="500MB"/>
<TimeBasedTriggeringPolicy interval="1" modulate="true"/>
</Policies>
<DefaultRolloverStrategy max="300">
<Delete basePath="${LOG_HOME}" maxDepth="1">
<IfLastModified age="15d"/>
<IfFileName glob="${LOG_HOME}*.log"/>
</Delete>
</DefaultRolloverStrategy>
</RollingFile>
<!-- 业务日常节点日志-->
<RollingFile name="COMMON-APPENDER" fileName="${LOG_HOME}/common-default.log"
filePattern="${LOG_HOME}/common-default-%d{yyyy-MM-dd}_%i.log" append="true">
<PatternLayout pattern="${LOG_LAYOUT}" charset="UTF-8"/>
<Policies>
<SizeBasedTriggeringPolicy size="500MB"/>
<TimeBasedTriggeringPolicy interval="1" modulate="true"/>
</Policies>
<DefaultRolloverStrategy max="300">
<Delete basePath="${LOG_HOME}" maxDepth="1">
<IfLastModified age="15d"/>
<IfFileName glob="${LOG_HOME}*.log"/>
</Delete>
</DefaultRolloverStrategy>
</RollingFile>
<!-- 业务日常节点日志-->
<RollingFile name="DOMAIN-CALL-APPENDER" fileName="${LOG_HOME}/domain-call.log"
filePattern="${LOG_HOME}/domain-call-%d{yyyy-MM-dd}_%i.log" append="true">
<PatternLayout pattern="${SIMPLE_LAYOUT}" charset="UTF-8"/>
<Policies>
<SizeBasedTriggeringPolicy size="500MB"/>
<TimeBasedTriggeringPolicy interval="1" modulate="true"/>
</Policies>
<DefaultRolloverStrategy max="300">
<Delete basePath="${LOG_HOME}" maxDepth="1">
<IfLastModified age="15d"/>
<IfFileName glob="${LOG_HOME}*.log"/>
</Delete>
</DefaultRolloverStrategy>
</RollingFile>
<!-- 消息监听日志 -->
<RollingFile name="MSG-LISTEN-APPENDER" fileName="${LOG_HOME}/msg-listen.log"
filePattern="${LOG_HOME}/msg-listen-%d{yyyy-MM-dd}_%i.log" append="true">
<PatternLayout pattern="${LOG_LAYOUT}" charset="UTF-8"/>
<Policies>
<SizeBasedTriggeringPolicy size="500MB"/>
<TimeBasedTriggeringPolicy interval="1" modulate="true"/>
</Policies>
<DefaultRolloverStrategy max="300">
<Delete basePath="${LOG_HOME}" maxDepth="1">
<IfLastModified age="15d"/>
<IfFileName glob="${LOG_HOME}*.log"/>
</Delete>
</DefaultRolloverStrategy>
</RollingFile>
<!-- 异步任务日志 -->
<RollingFile name="TASK-SCHEDULER-APPENDER" fileName="${LOG_HOME}/task-scheduler.log"
filePattern="${LOG_HOME}/task-scheduler-%d{yyyy-MM-dd}_%i.log" append="true">
<PatternLayout pattern="${LOG_LAYOUT}" charset="UTF-8"/>
<Policies>
<SizeBasedTriggeringPolicy size="500MB"/>
<TimeBasedTriggeringPolicy interval="1" modulate="true"/>
</Policies>
<DefaultRolloverStrategy max="300">
<Delete basePath="${LOG_HOME}" maxDepth="1">
<IfLastModified age="15d"/>
<IfFileName glob="${LOG_HOME}*.log"/>
</Delete>
</DefaultRolloverStrategy>
</RollingFile>
<!-- SOFA日常节点日志 -->
<RollingFile name="SOFA-DEFAULT-APPENDER" fileName="${LOG_HOME}/sofa-default.log"
filePattern="${LOG_HOME}/sofa-default-%d{yyyy-MM-dd}_%i.log" append="true">
<PatternLayout pattern="${LOG_LAYOUT}" charset="UTF-8"/>
<Policies>
<SizeBasedTriggeringPolicy size="500MB"/>
<TimeBasedTriggeringPolicy interval="1" modulate="true"/>
</Policies>
<DefaultRolloverStrategy max="300">
<Delete basePath="${LOG_HOME}" maxDepth="1">
<IfLastModified age="15d"/>
<IfFileName glob="${LOG_HOME}*.log"/>
</Delete>
</DefaultRolloverStrategy>
</RollingFile>
<!-- 调用外部系统日志 -->
<RollingFile name="INTEGRATION-APPENDER" fileName="${LOG_HOME}/integration.log"
filePattern="${LOG_HOME}/integration-%d{yyyy-MM-dd}_%i.log" append="true">
<PatternLayout pattern="${LOG_LAYOUT}" charset="UTF-8"/>
<Policies>
<SizeBasedTriggeringPolicy size="500MB"/>
<TimeBasedTriggeringPolicy interval="1" modulate="true"/>
</Policies>
<DefaultRolloverStrategy max="300">
<Delete basePath="${LOG_HOME}" maxDepth="1">
<IfLastModified age="15d"/>
<IfFileName glob="${LOG_HOME}*.log"/>
</Delete>
</DefaultRolloverStrategy>
</RollingFile>
<RollingFile name="COMMON-MONITOR-APPENDER" fileName="${LOG_HOME}/common-monitor.log"
filePattern="${LOG_HOME}/common-monitor-%d{yyyy-MM-dd}_%i.log" append="true">
<PatternLayout pattern="${LOG_LAYOUT}" charset="UTF-8"/>
<Policies>
<SizeBasedTriggeringPolicy size="500MB"/>
<TimeBasedTriggeringPolicy interval="1" modulate="true"/>
</Policies>
<DefaultRolloverStrategy max="300">
<Delete basePath="${LOG_HOME}" maxDepth="1">
<IfLastModified age="15d"/>
<IfFileName glob="${LOG_HOME}*.log"/>
</Delete>
</DefaultRolloverStrategy>
</RollingFile>
</Appenders>
<Loggers>
<AsyncRoot includeLocation="true" level="${LOG_LEVEL}">
<AppenderRef ref="ERROR-APPENDER"/>
<AppenderRef ref="COMMON-APPENDER"/>
</AsyncRoot>
<AsyncLogger name="com.alipay.sofa" additivity="false" level="${LOG_LEVEL}">
<AppenderRef ref="ERROR-APPENDER"/>
<AppenderRef ref="SOFA-DEFAULT-APPENDER"/>
</AsyncLogger>
<AsyncLogger name="com.aliyun.fsi.insurance" additivity="false" level="${LOG_LEVEL}">
<AppenderRef ref="ERROR-APPENDER"/>
<AppenderRef ref="COMMON-APPENDER"/>
</AsyncLogger>
<Logger name="INTEGRATION" additivity="false" includeLocation="true" level="${LOG_LEVEL}">
<AppenderRef ref="ERROR-APPENDER"/>
<AppenderRef ref="INTEGRATION-APPENDER"/>
</Logger>
<Logger name="SERIOUS-ALERT" additivity="false" includeLocation="true" level="${LOG_LEVEL}">
<AppenderRef ref="ERROR-APPENDER"/>
<AppenderRef ref="COMMON-APPENDER"/>
</Logger>
<Logger name="DOMAIN-ERROR" additivity="false" includeLocation="true" level="${LOG_LEVEL}">
<AppenderRef ref="ERROR-APPENDER"/>
<AppenderRef ref="COMMON-APPENDER"/>
</Logger>
<Logger name="DOMAIN-DIGEST" additivity="false" includeLocation="true" level="${LOG_LEVEL}">
<AppenderRef ref="ERROR-APPENDER"/>
<AppenderRef ref="COMMON-APPENDER"/>
</Logger>
<Logger name="DOMAIN-CALL" additivity="false" includeLocation="true" level="${LOG_LEVEL}">
<AppenderRef ref="DOMAIN-CALL-APPENDER"/>
</Logger>
<Logger name="DOMAIN-SERVICE" additivity="false" includeLocation="true" level="${LOG_LEVEL}">
<AppenderRef ref="ERROR-APPENDER"/>
<AppenderRef ref="COMMON-APPENDER"/>
</Logger>
<Logger name="TASK-SCHEDULER" additivity="false" includeLocation="true" level="${LOG_LEVEL}">
<AppenderRef ref="ERROR-APPENDER"/>
<AppenderRef ref="TASK-SCHEDULER-APPENDER"/>
</Logger>
<Logger name="MSG-LISTEN" additivity="false" includeLocation="true" level="${LOG_LEVEL}">
<AppenderRef ref="ERROR-APPENDER"/>
<AppenderRef ref="MSG-LISTEN-APPENDER"/>
</Logger>
<Logger name="AbstractMessageListenerXFlush" additivity="false" includeLocation="true" level="${LOG_LEVEL}">
<AppenderRef ref="ERROR-APPENDER"/>
<AppenderRef ref="MSG-LISTEN-APPENDER"/>
</Logger>
<Logger name="COMMON-MONITOR" includeLocation="true" additivity="false" level="${LOG_LEVEL}">
<AppenderRef ref="ERROR-APPENDER"/>
<AppenderRef ref="COMMON-MONITOR-APPENDER"/>
<AppenderRef ref="STDOUT-APPENDER"/>
</Logger>
</Loggers>
</Configuration>

View File

@ -1,217 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<Configuration>
<properties>
<property name="LOG_LEVEL" value="DEBUG"/>
<property name="APP_NAME" value="electromagnetic-data"/>
<property name="LOG_HOME" value="./logs/${APP_NAME}"/>
<property name="LOG_LAYOUT" value="%d{yyyy-MM-dd HH:mm:ss.SSS},%t,%r,%-5p,%X{SOFA-TraceId},%X{SOFA-SpanId},%c{2},%m%n%throwable"/>
<property name="SIMPLE_LAYOUT" value="%d{yyyy-MM-dd HH:mm:ss.SSS} %m%n%"/>
</properties>
<Appenders>
<Console name="STDOUT-APPENDER" target="SYSTEM_OUT">
<PatternLayout pattern="${LOG_LAYOUT}" charset="UTF-8"/>
</Console>
<Console name="STDERR-APPENDER" target="SYSTEM_ERR">
<PatternLayout pattern="${LOG_LAYOUT}" charset="UTF-8"/>
</Console>
<!-- 错误节点日志 -->
<RollingFile name="ERROR-APPENDER" fileName="${LOG_HOME}/common-error.log"
filePattern="${LOG_HOME}/common-error-%d{yyyy-MM-dd}_%i.log" append="true">
<Filters>
<ThresholdFilter level="ERROR" onMatch="ACCEPT" onMismatch="DENY"/>
</Filters>
<PatternLayout pattern="${LOG_LAYOUT}" charset="UTF-8"/>
<Policies>
<SizeBasedTriggeringPolicy size="500MB"/>
<TimeBasedTriggeringPolicy interval="1" modulate="true"/>
</Policies>
<DefaultRolloverStrategy max="300">
<Delete basePath="${LOG_HOME}" maxDepth="1">
<IfLastModified age="15d"/>
<IfFileName glob="${LOG_HOME}*.log"/>
</Delete>
</DefaultRolloverStrategy>
</RollingFile>
<!-- 业务日常节点日志-->
<RollingFile name="COMMON-APPENDER" fileName="${LOG_HOME}/common-default.log"
filePattern="${LOG_HOME}/common-default-%d{yyyy-MM-dd}_%i.log" append="true">
<PatternLayout pattern="${LOG_LAYOUT}" charset="UTF-8"/>
<Policies>
<SizeBasedTriggeringPolicy size="500MB"/>
<TimeBasedTriggeringPolicy interval="1" modulate="true"/>
</Policies>
<DefaultRolloverStrategy max="300">
<Delete basePath="${LOG_HOME}" maxDepth="1">
<IfLastModified age="15d"/>
<IfFileName glob="${LOG_HOME}*.log"/>
</Delete>
</DefaultRolloverStrategy>
</RollingFile>
<!-- 业务日常节点日志-->
<RollingFile name="DOMAIN-CALL-APPENDER" fileName="${LOG_HOME}/domain-call.log"
filePattern="${LOG_HOME}/domain-call-%d{yyyy-MM-dd}_%i.log" append="true">
<PatternLayout pattern="${SIMPLE_LAYOUT}" charset="UTF-8"/>
<Policies>
<SizeBasedTriggeringPolicy size="500MB"/>
<TimeBasedTriggeringPolicy interval="1" modulate="true"/>
</Policies>
<DefaultRolloverStrategy max="300">
<Delete basePath="${LOG_HOME}" maxDepth="1">
<IfLastModified age="15d"/>
<IfFileName glob="${LOG_HOME}*.log"/>
</Delete>
</DefaultRolloverStrategy>
</RollingFile>
<!-- 消息监听日志 -->
<RollingFile name="MSG-LISTEN-APPENDER" fileName="${LOG_HOME}/msg-listen.log"
filePattern="${LOG_HOME}/msg-listen-%d{yyyy-MM-dd}_%i.log" append="true">
<PatternLayout pattern="${LOG_LAYOUT}" charset="UTF-8"/>
<Policies>
<SizeBasedTriggeringPolicy size="500MB"/>
<TimeBasedTriggeringPolicy interval="1" modulate="true"/>
</Policies>
<DefaultRolloverStrategy max="300">
<Delete basePath="${LOG_HOME}" maxDepth="1">
<IfLastModified age="15d"/>
<IfFileName glob="${LOG_HOME}*.log"/>
</Delete>
</DefaultRolloverStrategy>
</RollingFile>
<!-- 异步任务日志 -->
<RollingFile name="TASK-SCHEDULER-APPENDER" fileName="${LOG_HOME}/task-scheduler.log"
filePattern="${LOG_HOME}/task-scheduler-%d{yyyy-MM-dd}_%i.log" append="true">
<PatternLayout pattern="${LOG_LAYOUT}" charset="UTF-8"/>
<Policies>
<SizeBasedTriggeringPolicy size="500MB"/>
<TimeBasedTriggeringPolicy interval="1" modulate="true"/>
</Policies>
<DefaultRolloverStrategy max="300">
<Delete basePath="${LOG_HOME}" maxDepth="1">
<IfLastModified age="15d"/>
<IfFileName glob="${LOG_HOME}*.log"/>
</Delete>
</DefaultRolloverStrategy>
</RollingFile>
<!-- SOFA日常节点日志 -->
<RollingFile name="SOFA-DEFAULT-APPENDER" fileName="${LOG_HOME}/sofa-default.log"
filePattern="${LOG_HOME}/sofa-default-%d{yyyy-MM-dd}_%i.log" append="true">
<PatternLayout pattern="${LOG_LAYOUT}" charset="UTF-8"/>
<Policies>
<SizeBasedTriggeringPolicy size="500MB"/>
<TimeBasedTriggeringPolicy interval="1" modulate="true"/>
</Policies>
<DefaultRolloverStrategy max="300">
<Delete basePath="${LOG_HOME}" maxDepth="1">
<IfLastModified age="15d"/>
<IfFileName glob="${LOG_HOME}*.log"/>
</Delete>
</DefaultRolloverStrategy>
</RollingFile>
<!-- 调用外部系统日志 -->
<RollingFile name="INTEGRATION-APPENDER" fileName="${LOG_HOME}/integration.log"
filePattern="${LOG_HOME}/integration-%d{yyyy-MM-dd}_%i.log" append="true">
<PatternLayout pattern="${LOG_LAYOUT}" charset="UTF-8"/>
<Policies>
<SizeBasedTriggeringPolicy size="500MB"/>
<TimeBasedTriggeringPolicy interval="1" modulate="true"/>
</Policies>
<DefaultRolloverStrategy max="300">
<Delete basePath="${LOG_HOME}" maxDepth="1">
<IfLastModified age="15d"/>
<IfFileName glob="${LOG_HOME}*.log"/>
</Delete>
</DefaultRolloverStrategy>
</RollingFile>
<RollingFile name="COMMON-MONITOR-APPENDER" fileName="${LOG_HOME}/common-monitor.log"
filePattern="${LOG_HOME}/common-monitor-%d{yyyy-MM-dd}_%i.log" append="true">
<PatternLayout pattern="${LOG_LAYOUT}" charset="UTF-8"/>
<Policies>
<SizeBasedTriggeringPolicy size="500MB"/>
<TimeBasedTriggeringPolicy interval="1" modulate="true"/>
</Policies>
<DefaultRolloverStrategy max="300">
<Delete basePath="${LOG_HOME}" maxDepth="1">
<IfLastModified age="15d"/>
<IfFileName glob="${LOG_HOME}*.log"/>
</Delete>
</DefaultRolloverStrategy>
</RollingFile>
</Appenders>
<Loggers>
<AsyncRoot includeLocation="true" level="INFO">
<AppenderRef ref="ERROR-APPENDER"/>
<AppenderRef ref="COMMON-APPENDER"/>
<AppenderRef ref="STDOUT-APPENDER"/>
</AsyncRoot>
<AsyncLogger name="com.alipay.sofa" additivity="false" level="${LOG_LEVEL}">
<AppenderRef ref="ERROR-APPENDER"/>
<AppenderRef ref="SOFA-DEFAULT-APPENDER"/>
<AppenderRef ref="STDOUT-APPENDER"/>
</AsyncLogger>
<AsyncLogger name="com.aliyun.fsi.insurance" additivity="false" level="${LOG_LEVEL}">
<AppenderRef ref="ERROR-APPENDER"/>
<AppenderRef ref="COMMON-APPENDER"/>
<AppenderRef ref="STDOUT-APPENDER"/>
</AsyncLogger>
<Logger name="INTEGRATION" includeLocation="true" additivity="false" level="${LOG_LEVEL}">
<AppenderRef ref="ERROR-APPENDER"/>
<AppenderRef ref="INTEGRATION-APPENDER"/>
<AppenderRef ref="STDOUT-APPENDER"/>
</Logger>
<Logger name="SERIOUS-ALERT" includeLocation="true" additivity="false" level="${LOG_LEVEL}">
<AppenderRef ref="ERROR-APPENDER"/>
<AppenderRef ref="COMMON-APPENDER"/>
<AppenderRef ref="STDERR-APPENDER"/>
</Logger>
<Logger name="DOMAIN-CALL" additivity="false" includeLocation="true" level="${LOG_LEVEL}">
<AppenderRef ref="DOMAIN-CALL-APPENDER"/>
</Logger>
<Logger name="DOMAIN-ERROR" includeLocation="true" additivity="false" level="${LOG_LEVEL}">
<AppenderRef ref="ERROR-APPENDER"/>
<AppenderRef ref="COMMON-APPENDER"/>
<AppenderRef ref="STDERR-APPENDER"/>
</Logger>
<Logger name="DOMAIN-DIGEST" includeLocation="true" additivity="false" level="${LOG_LEVEL}">
<AppenderRef ref="ERROR-APPENDER"/>
<AppenderRef ref="COMMON-APPENDER"/>
<AppenderRef ref="STDOUT-APPENDER"/>
</Logger>
<Logger name="DOMAIN-SERVICE" includeLocation="true" additivity="false" level="${LOG_LEVEL}">
<AppenderRef ref="ERROR-APPENDER"/>
<AppenderRef ref="COMMON-APPENDER"/>
<AppenderRef ref="STDOUT-APPENDER"/>
</Logger>
<Logger name="TASK-SCHEDULER" includeLocation="true" additivity="false" level="${LOG_LEVEL}">
<AppenderRef ref="ERROR-APPENDER"/>
<AppenderRef ref="TASK-SCHEDULER-APPENDER"/>
<AppenderRef ref="STDOUT-APPENDER"/>
</Logger>
<Logger name="MSG-LISTEN" includeLocation="true" additivity="false" level="${LOG_LEVEL}">
<AppenderRef ref="ERROR-APPENDER"/>
<AppenderRef ref="MSG-LISTEN-APPENDER"/>
<AppenderRef ref="STDOUT-APPENDER"/>
</Logger>
<Logger name="AbstractMessageListenerXFlush" includeLocation="true" additivity="false" level="${LOG_LEVEL}">
<AppenderRef ref="ERROR-APPENDER"/>
<AppenderRef ref="MSG-LISTEN-APPENDER"/>
<AppenderRef ref="STDOUT-APPENDER"/>
</Logger>
<Logger name="COMMON-MONITOR" includeLocation="true" additivity="false" level="${LOG_LEVEL}">
<AppenderRef ref="ERROR-APPENDER"/>
<AppenderRef ref="COMMON-MONITOR-APPENDER"/>
<AppenderRef ref="STDOUT-APPENDER"/>
</Logger>
</Loggers>
</Configuration>

View File

@ -1,67 +0,0 @@
<?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="com.electromagnetic.industry.software.manage.mapper.CategoryMapper">
<resultMap id="CategoryResultMap" type="com.electromagnetic.industry.software.manage.pojo.models.Category">
<id column="id" jdbcType="BIGINT" property="id" />
<result column="category_type_id" jdbcType="VARCHAR" property="categoryTypeId" />
<result column="parent_id" jdbcType="VARCHAR" property="parentId" />
<result column="category_id" jdbcType="VARCHAR" property="categoryId" />
<result column="category_name" jdbcType="VARCHAR" property="categoryName" />
<result column="category_status" jdbcType="VARCHAR" property="categoryStatus" />
<result column="creator" jdbcType="VARCHAR" property="creator" />
<result column="creator_name" jdbcType="VARCHAR" property="creatorName" />
<result column="gmt_create" jdbcType="TIMESTAMP" property="gmtCreate" />
<result column="modifier" jdbcType="VARCHAR" property="modifier" />
<result column="modifier_name" jdbcType="VARCHAR" property="modifierName" />
<result column="gmt_modified" jdbcType="TIMESTAMP" property="gmtModified" />
<result column="effect_flag" jdbcType="TINYINT" property="effectFlag" />
</resultMap>
<sql id="selectUserVo">
select category_type_id, parent_id, category_id, category_name, category_status,
creator, creator_name, gmt_create, modifier, modifier_name, gmt_modified, effect_flag
from ed_category
</sql>
<select id="selectTopCategories" resultMap="CategoryResultMap">
<include refid="selectUserVo" />
where parent_id = 0 and category_status="available"
</select>
<select id="selectAllCategories" resultMap="CategoryResultMap">
<include refid="selectUserVo" />
where category_status="available"
</select>
<select id="selectCategories" resultMap="CategoryResultMap"
parameterType="com.electromagnetic.industry.software.manage.pojo.models.Category">
<include refid="selectUserVo" />
where category_id = #{categoryId,jdbcType=VARCHAR} and category_status="available"
</select>
<select id="selectChildCategories" resultMap="CategoryResultMap"
parameterType="com.electromagnetic.industry.software.manage.pojo.models.Category">
<include refid="selectUserVo" />
where parent_id = #{parentId,jdbcType=VARCHAR} and category_status="available"
</select>
<insert id="createCategory" parameterType="com.electromagnetic.industry.software.manage.pojo.models.Category">
<selectKey keyProperty="id" order="AFTER" resultType="java.lang.Long">
SELECT LAST_INSERT_ID()
</selectKey>
replace into ed_data_info (id,
category_type_id, parent_id, category_id,
category_name, category_status,
creator, creator_name, gmt_create,
modifier, modifier_name, gmt_modified,
effect_flag
)
values (#{id,jdbcType=VARCHAR}, #{categoryTypeId,jdbcType=VARCHAR},
#{parentId,jdbcType=VARCHAR}, #{categoryId,jdbcType=VARCHAR},
#{categoryName,jdbcType=VARCHAR}, #{categoryStatus,jdbcType=VARCHAR},
#{creator,jdbcType=VARCHAR}, #{creatorName,jdbcType=VARCHAR}, now(), #{modifier,jdbcType=VARCHAR},
#{modifierName,jdbcType=VARCHAR},now(),1
)
</insert>
</mapper>

View File

@ -1,132 +0,0 @@
<?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="com.electromagnetic.industry.software.manage.mapper.EDDataMapper">
<resultMap id="BaseResultMap" type="com.electromagnetic.industry.software.manage.pojo.models.EDDataInfo">
<id column="id" jdbcType="BIGINT" property="id" />
<result column="category_id" jdbcType="VARCHAR" property="categoryId" />
<result column="data_id" jdbcType="VARCHAR" property="dataId" />
<result column="data_no" jdbcType="VARCHAR" property="dataNo" />
<result column="data_name" jdbcType="VARCHAR" property="dataName" />
<result column="data_type" jdbcType="VARCHAR" property="dataType" />
<result column="file_type" jdbcType="VARCHAR" property="fileType" />
<result column="version" jdbcType="VARCHAR" property="version" />
<result column="content" jdbcType="VARCHAR" property="content" />
<result column="implant_json" jdbcType="VARCHAR" property="implantJson" />
<result column="data_status" jdbcType="VARCHAR" property="dataStatus" />
<result column="note" jdbcType="VARCHAR" property="note" />
<result column="editor" jdbcType="VARCHAR" property="editor" />
<result column="gmt_batch_upload" jdbcType="TIMESTAMP" property="gmtBatchUpload" />
<result column="save_status" jdbcType="VARCHAR" property="saveStatus" />
<result column="creator" jdbcType="VARCHAR" property="creator" />
<result column="creator_name" jdbcType="VARCHAR" property="creatorName" />
<result column="gmt_create" jdbcType="TIMESTAMP" property="gmtCreate" />
<result column="modifier" jdbcType="VARCHAR" property="modifier" />
<result column="modifier_name" jdbcType="VARCHAR" property="modifierName" />
<result column="gmt_modified" jdbcType="TIMESTAMP" property="gmtModified" />
<result column="effect_flag" jdbcType="TINYINT" property="effectFlag" />
</resultMap>
<sql id="Base_Column_list">
id,category_id,data_id,data_no,data_name,data_type,file_type,version,content,
implant_json,data_status,note,editor,gmt_batch_upload,save_status,creator,creator_name,gmt_create,modifier,modifier_name,
gmt_modified,effect_flag
</sql>
<insert id="createDataInfo" parameterType="com.electromagnetic.industry.software.manage.pojo.models.EDDataInfo">
<selectKey keyProperty="id" order="AFTER" resultType="java.lang.Long">
SELECT LAST_INSERT_ID()
</selectKey>
replace into ed_data_info (category_id,
data_id, data_no, data_name,
data_type, file_type, version,
content, implant_json, data_status,
note, editor, gmt_batch_upload, save_status,
creator, creator_name, gmt_create,
modifier, modifier_name, gmt_modified,
effect_flag
)
values (#{categoryId,jdbcType=VARCHAR},
#{dataId,jdbcType=VARCHAR}, #{dataNo,jdbcType=VARCHAR}, #{dataName,jdbcType=VARCHAR},
#{dataType,jdbcType=VARCHAR}, #{fileType,jdbcType=VARCHAR},#{version,jdbcType=VARCHAR},
#{content,jdbcType=VARCHAR}, #{implantJson,jdbcType=VARCHAR}, #{dataStatus,jdbcType=VARCHAR},
#{note,jdbcType=VARCHAR}, #{editor,jdbcType=VARCHAR}, #{gmtBatchUpload,jdbcType=TIMESTAMP}, #{saveStatus,jdbcType=VARCHAR},
#{creator,jdbcType=VARCHAR}, #{creatorName,jdbcType=VARCHAR}, now(), #{modifier,jdbcType=VARCHAR},
#{modifierName,jdbcType=VARCHAR},now(),1
)
</insert>
<select id="getDataInfoList" resultMap="BaseResultMap"
parameterType="com.electromagnetic.industry.software.manage.pojo.other.EDDataParams">
SELECT
<include refid="Base_Column_list"/>
FROM
ed_data_info
where
effect_flag = 1
<if test="parentId!=null and parentId!=''">
and category_id='${parentId}'
</if>
<if test="dataId!=null and dataId!=''">
and data_id='${dataId}'
</if>
<if test="keyWord!=null and keyWord!=''">
and data_name LIKE '%${keyWord}%'
</if>
<if test="dataType != null and dataType!=''">
and data_type = '${dataType}'
</if>
<if test="saveStatus!=null and saveStatus!=''">
and save_status='${saveStatus}'
</if>
GROUP BY id
<if test="gmtCreate == 'asc' or gmtCreate =='desc'">
order by gmt_create ${gmtCreate}
</if>
<if test = "gmtCreate == null or gmtCreate == ''">
order by gmt_create desc
</if>
</select>
<update id="updateFileInfo" parameterType="com.electromagnetic.industry.software.manage.pojo.other.EDDataParams">
update ed_data_info
<set>
<if test="name != null and name!=''">
data_name = #{name,jdbcType=VARCHAR},
</if>
<if test="dataStatus != null and dataStatus!=''">
data_status = #{dataStatus,jdbcType=VARCHAR},
</if>
<if test="note != null and note!=''">
note = #{note,jdbcType=VARCHAR},
</if>
<if test="saveStatus != null and note!=''">
save_status = #{saveStatus,jdbcType=VARCHAR},
</if>
<if test="effectFlag != null and effectFlag!=''">
effect_flag = #{effectFlag,jdbcType=VARCHAR},
</if>
<if test="userId != null and userId!=''">
modifier = #{userId,jdbcType=VARCHAR},
</if>
<if test="userName != null and userName!=''">
modifier_name = #{userName,jdbcType=VARCHAR},
</if>
gmt_modified = now()
</set>
<where>
<!-- 条件 1按数据编码修改 -->
<if test="dataId != null and dataId != ''">
data_id = #{dataId,jdbcType=VARCHAR}
</if>
<!-- 条件 2按目录编码修改 -->
<if test="parentId != null and parentId != ''">
category_id = #{parentId,jdbcType=VARCHAR}
</if>
</where>
</update>
</mapper>

View File

@ -0,0 +1,11 @@
<?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="com.electromagnetic.industry.software.manage.mapper.EdFileInfoMapper">
<select id="maxPrjId" resultType="java.lang.String">
select max(id)
from ed_file_info
where prj_dir = true
</select>
</mapper>

Some files were not shown because too many files have changed in this diff Show More