Compare commits

...

107 Commits

Author SHA1 Message Date
thinkgem
36242663f2 Merge branch 'v5.springboot2.dev' into v5.springboot2 2025-10-27 18:18:02 +08:00
thinkgem
1e6b304583 update README.md 2025-10-27 17:50:50 +08:00
thinkgem
63b689ecfd update Dockerfile 2025-10-27 12:05:37 +08:00
thinkgem
3afa11272f 5.14.0 2025-10-27 10:02:33 +08:00
thinkgem
5e01b22fb9 优化 Upload 文件上传组件一些参数,默认从后台获取 2025-10-27 09:15:11 +08:00
thinkgem
c88a576219 默认文档上传类型增加.dmg格式 2025-10-27 09:14:47 +08:00
thinkgem
a8c9b60052 新增一个参数的调度任务测试方法 2025-10-23 11:39:07 +08:00
thinkgem
e413c4ce4f 将root/pom移动到根目录下 2025-10-22 14:06:19 +08:00
thinkgem
1da65bcf3f 新增Excel导入导出实体单元测试类 2025-10-22 10:48:54 +08:00
thinkgem
46514450d6 修正ExcelField声明在get方法上时提示wrong number of arguments 2025-10-22 10:48:14 +08:00
thinkgem
68d6c09b94 任务调度目标串,增加 JobContext 对象接收,可获取 JobExecutionContext、任务中断状态、任务中断回调等;当当暂停或运行一次的时候,会发起中断任务通知; 2025-10-21 12:52:03 +08:00
thinkgem
5050c20534 代码优化 2025-10-21 12:46:27 +08:00
thinkgem
80d918c3a1 update README.md 2025-10-20 16:08:10 +08:00
thinkgem
b90f1252b1 优化 Application 启动完成输出的提示信息 2025-10-19 13:24:10 +08:00
thinkgem
e43e4f7567 update productName 2025-10-18 00:21:06 +08:00
thinkgem
17d83bdc1c 合并 PostConstruct 2025-10-16 20:18:54 +08:00
thinkgem
53546e1527 update README.md 2025-10-16 16:34:08 +08:00
thinkgem
73fe81dde6 update logger-core.xml 2025-10-16 16:34:03 +08:00
thinkgem
bf969042d4 remove config mvc.pathmatch.matching-strategy 2025-10-16 13:33:26 +08:00
thinkgem
f57f7a9762 删除或保留 ueditor.json 配置文件,删除后将使用默认 ueditor-core.json 2025-10-16 10:54:07 +08:00
thinkgem
a422fd5441 默认加载 mybatis-default.xml,可通过 mybatis.configLocation 参数指定 mybatis-config.xml 文件 2025-10-16 10:52:06 +08:00
thinkgem
fc2e5e10c2 application-prod.yml 增加 mybatis.mapper.refresh.enabled: false 2025-10-16 10:41:50 +08:00
thinkgem
23d9258577 update application.yml 2025-10-16 10:37:54 +08:00
thinkgem
9e33b5c894 给迷你服务去掉一些依赖,缩减打包大小 2025-10-15 21:13:38 +08:00
thinkgem
6a41db0efc update pom.xml 2025-10-15 20:03:47 +08:00
thinkgem
66f7ead680 增加 logger-default-cloud.xml 默认配置,可自定义覆盖默认参数 2025-10-15 16:29:20 +08:00
thinkgem
75ed6bc847 增加 beetl-default.properties 默认配置,可自定义覆盖默认参数 2025-10-15 16:24:11 +08:00
thinkgem
e15227525c update logger 2025-10-15 12:30:47 +08:00
thinkgem
b936d3fba6 增加默认文件 logger-default.xml、mybatis-default.xml 方便 junit、mini服务引用 2025-10-15 11:30:23 +08:00
thinkgem
55000e9d6c update logback config 2025-10-15 11:22:51 +08:00
thinkgem
332711969d update robust 2025-10-13 15:28:09 +08:00
thinkgem
f7d3b4cd95 update version 2025-10-13 12:16:10 +08:00
thinkgem
2454cb8037 更改为构造注入并完善方法注释 2025-10-12 20:34:34 +08:00
thinkgem
06e88b5bad 更改为构造注入并完善方法注释 2025-10-12 14:42:05 +08:00
thinkgem
4538ce0050 登录成功和退出成功接口,增加返回值 2025-10-12 14:07:16 +08:00
thinkgem
901540f9a5 错误提示页面,增加 刷新页面 按钮 2025-10-11 21:56:08 +08:00
thinkgem
3698ec07bc 小窗口下,侧边栏未完全展开问题 2025-10-11 21:55:40 +08:00
thinkgem
28e5f18c4c 优化体验,当关闭多地登录,且被挤下时,给予用户提示,而不是直接跳转登录页 2025-10-11 21:55:01 +08:00
thinkgem
e4d406b864 优化登录逻辑,性能提升 2025-10-11 21:52:54 +08:00
thinkgem
fd328a9e9b 系统缓存 sysCache 延长存活时间 2025-10-11 08:42:14 +08:00
thinkgem
741c1b8592 登录设备合法性验证(根据业务需要自行添加) 2025-10-10 21:03:33 +08:00
thinkgem
28c8c571cd 代码优化 2025-10-10 20:55:58 +08:00
thinkgem
26907c348e 登录优化 2025-10-10 20:54:35 +08:00
thinkgem
57e947e985 登录 subject.isPermitted("user") 调用2次,优化为1次 2025-10-10 20:52:06 +08:00
thinkgem
07b24e3685 CMS 给 Category 栏目添加缓存 2025-10-10 16:45:13 +08:00
thinkgem
d981e643f4 update clearCache 2025-10-10 16:43:55 +08:00
thinkgem
f5d1546e85 update logger 2025-10-10 16:43:26 +08:00
thinkgem
777655f09c CMS 当栏目为显示第一篇文章的时候,点击保存,不关闭窗口 2025-10-10 16:40:52 +08:00
thinkgem
899c477448 缓存工具 CacheUtils 增加 computeIfAbsent 简化方法 2025-10-10 11:12:50 +08:00
thinkgem
7e83d139c5 code optimization 2025-10-09 23:34:49 +08:00
thinkgem
195d2ee06e SpringUtils 增加 getBeanIfAvailable 方法,如果可用则返回Bean,不抛出异常 2025-10-09 22:52:08 +08:00
thinkgem
839511b48c 优化 FeignClient 生成的 Bean 名称,直接使用 类名 小写开头 2025-10-09 18:00:34 +08:00
thinkgem
669bc979f8 update nacos config 2025-10-09 17:54:06 +08:00
thinkgem
bb490f8051 微服务下取不到bootstrap.yml影响版本5.13.boot2 2025-10-09 17:47:43 +08:00
thinkgem
fd44134a61 修正微服务下取不到bootstrap.yml影响版本5.13.boot2 2025-10-09 17:46:44 +08:00
thinkgem
4888081778 update logger-core.xml 2025-10-09 17:05:00 +08:00
thinkgem
91caf04bcb lazy-initialization: true 2025-10-09 17:01:24 +08:00
thinkgem
f5af89bef8 新增 分组聚合查询 sqlMap.getGroup().setGroupBy(分组字段).setHaving(分组条件);优化 字段权限排除方法 setExcludeAttrNames,支持设置 * 排除所有列; 2025-09-29 11:38:24 +08:00
thinkgem
0d9980e4ca 新增 toOrderSql() 和 toGroupSql() 方法,当为空的时候不输出 ORDER BY 和 GROUP BY 关键字 2025-09-29 11:37:56 +08:00
thinkgem
b7c69ae981 next version 2025-09-27 19:52:37 +08:00
thinkgem
6bf2550412 update README.md 2025-09-27 19:50:37 +08:00
thinkgem
fbadd0960f 幂等注解 Idempotent 增加 sessionId(是否为会话级别的幂等验证)和 cacheName(可以自定义缓存名)参数 2025-09-27 19:50:37 +08:00
thinkgem
1b5808afa1 优化 ThreadUtils.sleep 增加 currentThread().interrupt(); 2025-09-27 19:50:37 +08:00
thinkgem
f33f07e8fc 新增 锁管理器,支持本地锁和分布式锁,当开启集群时,自动使用分布式锁 2025-09-27 19:50:37 +08:00
thinkgem
84f42a27e5 当指定语言和时区的时候再进行更改默认 2025-09-27 19:50:37 +08:00
thinkgem
862568c919 update README.md 2025-09-27 19:47:32 +08:00
thinkgem
00b94000e1 初始化isShow为空问题修复 2025-09-27 19:38:59 +08:00
thinkgem
736b687196 5.13.1 2025-09-22 21:46:57 +08:00
thinkgem
4e6e499ba7 新增 -Dspring.config.additional-location 方式读取配置文件 2025-09-22 09:54:03 +08:00
thinkgem
b712522c8e 启动脚本 startup.sh(bat) 支持接受参数 2025-09-22 09:35:13 +08:00
thinkgem
d0695b0f45 update README.md 2025-09-20 19:19:03 +08:00
thinkgem
2777e42196 update docker plugin 2025-09-20 19:11:39 +08:00
thinkgem
fa8a8c5235 poi 5.4.1 2025-09-19 19:57:00 +08:00
thinkgem
94c907ae2a 移除用不到的文件h5fix.min.js 2025-09-18 21:58:27 +08:00
thinkgem
0c7d946ef6 驼峰命名法工具优化,使用下划线开头的时候忽略它 2025-09-18 21:47:18 +08:00
thinkgem
94f85a8854 update yml 2025-09-18 13:40:47 +08:00
thinkgem
27ae67dc28 5.13.1 2025-09-15 08:48:44 +08:00
thinkgem
c2ab70275b 解决 ExcelImport 数值类型为负数的时候小数问题 2025-09-13 16:01:28 +08:00
thinkgem
cd2156b2b0 新增 QueryType.BETWEEN、QueryType.NOT_BETWEEN 查询类型 2025-09-12 09:51:01 +08:00
thinkgem
263030fc47 update 2025-09-10 23:23:07 +08:00
thinkgem
419c1870ff IpAddrFilter重命名为GlobalFilter全局过滤器,并将MDC移动到进来 2025-09-08 11:21:59 +08:00
thinkgem
079bfcf845 候还是后,稍后:说明后面还需有动作,需再进行尝试;稍候:说明只需等待就可以了 2025-09-05 10:47:27 +08:00
thinkgem
a06850a9e9 update upbw 2025-09-02 10:08:26 +08:00
thinkgem
b250c9cf2b 没有生成导入功能时,缺少 ref 导入 2025-09-02 10:07:49 +08:00
thinkgem
975ee600c0 更新名称 生成模块代码(Maven) 2025-08-29 20:51:36 +08:00
thinkgem
d58920f75d TestData 子表增加图片上传组件 2025-08-27 23:52:23 +08:00
thinkgem
0850e4c877 代码优化 2025-08-27 23:52:15 +08:00
thinkgem
c9b580500a @Idempotent 幂等注解,支持 key 指定多个,使用逗号分隔 2025-08-26 15:45:45 +08:00
thinkgem
7c4431d1cd 更新vue实例菜单 2025-08-25 15:08:40 +08:00
thinkgem
821f35e28e 改进单元测试类配置 2025-08-25 10:37:49 +08:00
thinkgem
a08ac0c536 优化界面 2025-08-22 18:40:58 +08:00
thinkgem
5df4152d6e Merge branch 'v5.springboot2' into v5.springboot2.temp 2025-08-22 18:39:28 +08:00
thinkgem
151f07d25c update README.md 2025-08-19 00:26:12 +08:00
thinkgem
5e3c704499 完善xss过滤表达式,避免出现data: 2025-08-18 23:05:44 +08:00
thinkgem
3859f26df7 Merge branch 'v5.springboot2' into v5.springboot2.temp 2025-08-18 17:15:18 +08:00
thinkgem
c09bd95406 5.13.0 2025-08-18 17:09:57 +08:00
thinkgem
0d51714f49 5.13.0 2025-08-18 11:45:32 +08:00
thinkgem
f1df1749f0 优化 toArray 预设大小的数组替换为零长度数组 2025-08-14 21:51:54 +08:00
thinkgem
84accda86e update logger 2025-08-14 21:13:19 +08:00
thinkgem
75d15fa5ae 取消 sys:stste 权限 2025-08-14 12:52:39 +08:00
thinkgem
f8ef574260 拼写更正 Templete to Template 2025-08-14 12:47:30 +08:00
thinkgem
155d59449d 增加子表类型生成;表格组件和表单组件,完善泛型支持; 2025-08-13 21:48:44 +08:00
thinkgem
1a6d1b2a2e 代码优化 2025-08-08 13:48:20 +08:00
thinkgem
abb63bf547 form:fileupload 组件 preview 参数优化,默认使用 file.preview 配置文件参数,方便全局设置。 2025-08-07 18:14:50 +08:00
thinkgem
32f5be3b28 update productVersion 2025-08-05 18:09:15 +08:00
thinkgem
b15b514543 next version 2025-07-30 22:17:29 +08:00
thinkgem
f01d4674b4 模版生成增加application.assistant.yml文件 2025-07-21 18:54:10 +08:00
282 changed files with 2632 additions and 3237 deletions

137
README.md
View File

@@ -4,7 +4,7 @@
</p>
<h3 align="center" style="margin:30px 0 30px;font-weight:bold;font-size:30px;">快速开发平台 - Spring Boot</h3>
<p align="center">
<a href="https://spring.io/projects/spring-boot" target="__blank"><img alt="SpringBoot-V2.7/3.4" src="https://img.shields.io/badge/SpringBoot-V2.7/3.4-blue.svg"></a>
<a href="https://spring.io/projects/spring-boot" target="__blank"><img alt="SpringBoot-V3.5 or 2.7" src="https://img.shields.io/badge/SpringBoot-V3.5 or 2.7-blue.svg"></a>
<a href="https://v3.cn.vuejs.org/" target="__blank"><img alt="TypeScript-Vue3" src="https://img.shields.io/badge/TypeScript-Vue3-green.svg"></a>
<a href="https://jeesite.com/docs/upgrade/" target="__blank"><img alt="JeeSite-V5.x" src="https://img.shields.io/badge/JeeSite-V5.x-success.svg"></a>
<a href="https://gitee.com/thinkgem/jeesite5" target="__blank"><img alt="star" src="https://gitee.com/thinkgem/jeesite5/badge/star.svg?theme=dark"></a>
@@ -42,17 +42,17 @@
</p>
* 源码仓库地址:
[Gitee](https://gitee.com/thinkgem/jeesite5)、
[GitCode](https://gitcode.com/thinkgem/jeesite5)、
[GitHub](https://github.com/thinkgem/jeesite5)
[Gitee](https://gitee.com/thinkgem/jeesite5/tree/v5.springboot2)、
[GitCode](https://gitcode.com/thinkgem/jeesite5/tree/v5.springboot2)、
[GitHub](https://github.com/thinkgem/jeesite5/tree/v5.springboot2)
* 分离版源码仓库地址:
[Gitee](https://gitee.com/thinkgem/jeesite-vue)、
[GitCode](https://gitcode.com/thinkgem/jeesite-vue)、
[GitHub](https://github.com/thinkgem/jeesite-vue)
* 源码合集仓库地址:
[GVP](https://gitee.com/thinkgem/jeesite/tree/v5.springboot3)、
[G-Star](https://gitcode.com/thinkgem/jeesite/overview?ref=v5.springboot3)、
[GitHub](https://github.com/thinkgem/jeesite/tree/v5.springboot3)
[GVP](https://gitee.com/thinkgem/jeesite/tree/v5.springboot2)、
[G-Star](https://gitcode.com/thinkgem/jeesite/tree/v5.springboot2)、
[GitHub](https://github.com/thinkgem/jeesite/tree/v5.springboot2)
## 平台介绍
@@ -70,7 +70,11 @@
* 2021 年终发布 Vue3 的前后分离版本,使得 JeeSite 拥有同一个后台服务 Web 来支撑分离版和全栈版两套前端技术栈。
* 支持国产化软硬件环境,如国产芯片、操作系统、数据库、中间件、国密算法等
* 对接 OpenAPI、Ollama、DeepSeek 等热门 AI 大模型,凭借检索增强生成 RAG 技术,为企业知识库打造专属智能对话
* 提供大模型 Tool 本地工具调用及 MCP 服务端和客户端工具调用,助力大模型与您的业务深度融合,实现高效交互。
* 支持国产化软件和硬件环境,如国产芯片、操作系统、数据库、中间件、国密算法等。
## 核心优势
@@ -88,48 +92,35 @@
* 至今 JeeSite 平台架构已经非常稳定,我们持续升级,并不失架构的先进性。
* JeeSite 精益求精,用心打磨每一个细节,界面 UI 操作便捷,体验性好。
* JeeSite 是一个专业的平台,是一个可以让您使用放心的平台。
* JeeSite 是一个专业的平台,是一个可以让您,用着省心的平台。
* 社区版基于 Apache License 2.0 开源协议,永久免费使用。
### 架构特点及安全方面的优势:<https://jeesite.com/docs/feature/>
## 技术选型
* 主框架Spring Boot 2.7、Spring Framework 5.3、Apache Shiro 1.12、J2Cache
* 主框架Spring Boot 2.7、Spring Framework 5.3、Apache Shiro 1.13、J2Cache
* 持久层Apache MyBatis 3.5、Hibernate Validator 6.2、Alibaba Druid 1.2
* 视图层Spring MVC 5.3、Beetl 3.10替换JSP、Bootstrap 3.3、AdminLTE 2.4
* 前端组件jQuery 3.7、jqGrid 4.7、layer 3.5、zTree 3.5、jQuery Validation
* 分离前端版Node.js、TypeScript、Vue3、Vite、Ant Design Vue、Vue Vben Admin
* 分离版Node.js、TypeScript、Vue3、Vite、Ant Design Vue、Vue Vben Admin
* 经典版Beetl 3.10HTML、jQuery 3.7、Bootstrap 3.3、AdminLTE 2.4
* 分离版:支持所有现代浏览器,如:谷歌 Chrome 87+、微软 Edge、火狐、国产浏览器 等
* 经典版:支持 IE10 和以上版本,以及其他所有现代浏览器,如:谷歌、火狐、国产浏览器 等
* 工作流引擎Flowable 6.6、符合 BPMN 规范、在线流程设计器、中国式流程、退回、撤回、自由流
* Bootstrap 版 支持 IE10 及以上版本及其他所有现代浏览器,如:谷歌、火狐、国产浏览器 等
* Vue3 版 支持现代浏览器,如:谷歌 Chrome 86+、火狐、国产浏览器 等
* 技术选型(详细):<http://jeesite.com/docs/technology/>
* 技术选型(详细)已支持数据库:<http://jeesite.com/docs/technology/>
* JeeSite Vue 版本:<https://gitee.com/thinkgem/jeesite-vue>
* Spring Boot 3.x 版本:<https://gitee.com/thinkgem/jeesite5/tree/v5.springboot3>
* Spring Boot 2.x 版本:<https://gitee.com/thinkgem/jeesite5/tree/v5.springboot2>
## 更多介绍
* 内置功能:<https://jeesite.com/docs/function/>
* 目录结构:<https://jeesite.com/docs/catalog/>
* 内置功能:<https://jeesite.com/docs/function/>
* 架构特点:<https://jeesite.com/docs/feature/>
* 参数配置:<https://jeesite.com/docs/config/>
* 开发规范:<https://jeesite.com/docs/standard/>
* 数表设计:<https://jeesite.com/docs/treetable/>
* 代码生成:<https://jeesite.com/docs/code-gen/>
## 生态系统
* 分布式微服务Spring Cloud<https://gitee.com/thinkgem/jeesite-cloud>
* Flowable业务流程引擎BPM<http://jeesite.com/docs/bpm/>
* 多站点内容管理模块CMS<https://jeesite.com/docs/cms/>
* 手机端移动端:<https://gitee.com/thinkgem/jeesite-uniapp>
* PC客户端程序<https://gitee.com/thinkgem/jeesite-client>
* Vue3分离版本<https://gitee.com/thinkgem/jeesite-vue>
* JeeSite统一认证<https://jeesite.com/docs/oauth2-server>
* JFlow工作流引擎<https://gitee.com/thinkgem/jeesite-jflow>
* Mybatis-Plus: <https://gitee.com/thinkgem/jeesite-mybatisplus>
* Magic接口快速开发<https://gitee.com/thinkgem/jeesite-magic-api>
* 内外网中间件:<https://my.oschina.net/thinkgem/blog/4624519>
## 快速体验
### 在线演示
@@ -137,10 +128,21 @@
1. 分离版地址:<https://vue.jeesite.com>
2. 经典版地址:<https://demo.jeesite.com>
### 快速运行
1. 免安装数据库,使用内嵌 H2 DB、包含 Vue 和 全栈双版本
2. 环境准备:`JDK 1.8 or 11、17``Maven 3.6+`、无需准备数据库
3. 下载源码:<https://gitee.com/thinkgem/jeesite5/repository/archive/v5.springboot2.zip> 并解压
4. 执行脚本:`/web-fast/bin/run-tomcat.bat` 启动服务即可(自动初始化库)
5. Vue分离版本地址<http://127.0.0.1:8980/vue/login>
6. 全栈版本地址:<http://127.0.0.1:8980/a/login>
7. 初始登录账号超级管理员system 密码admin
8. 部署常见问题:<https://jeesite.com/docs/faq/>
### 本地运行
1. 环境准备:`JDK 1.8 or 11、17``Maven 3.6+`、使用 `MySQL 5.7 or 8.0` 数据库、[其它数据库](https://jeesite.com/docs/technology/#_8、已支持数据库)
2. 下载源码:<https://gitee.com/thinkgem/jeesite5/repository/archive/v5.9.zip> 并解压
2. 下载源码:<https://gitee.com/thinkgem/jeesite5/repository/archive/v5.springboot2.zip> 并解压
3. 打开文件:`/web/src/main/resources/config/application.yml` 配置JDBC连接
4. 执行脚本:`/web/bin/init-data.bat` 初始化数据库
5. 执行脚本:`/web/bin/run-tomcat.bat` 启动服务即可
@@ -149,28 +151,21 @@
8. 分离端安装:<https://jeesite.com/docs/vue-install-deploy/>
9. 分离端常见问题:<https://jeesite.com/docs/vue-faq/>
### 快速运行
1. 环境准备:`JDK 1.8 or 11、17``Maven 3.6+`、无需准备数据库(使用内嵌 H2 DB、包含 Vue 和 全栈双版本)
2. 下载源码:<https://gitee.com/thinkgem/jeesite5/repository/archive/v5.9.zip> 并解压
3. 执行脚本:`/web-fast/bin/run-tomcat.bat` 启动服务即可(自动初始化库)
4. Vue分离版本地址<http://127.0.0.1:8980/vue/login>
5. 全栈版本地址:<http://127.0.0.1:8980/a/login>
6. 初始登录账号超级管理员system 密码admin
7. 部署常见问题:<https://jeesite.com/docs/faq/>
### 容器运行
- 拉取 Docker 镜像JeeSite版本不是最新
```sh
docker pull thinkgem/jeesite-web
docker pull crpi-u3zm0t8trv68xpyx.cn-qingdao.personal.cr.aliyuncs.com/thinkgem/jeesite:latest
```
- 启动脚本
- 启动镜像
```sh
docker run --name jeesite-web -p 8980:8980 -d --restart unless-stopped \
-v ~/:/data thinkgem/jeesite-web && docker logs -f jeesite-web
docker run --name js5 -p 8980:8980 -d crpi-u3zm0t8trv68xpyx.cn-qingdao.personal.cr.aliyuncs.com/thinkgem/jeesite:latest
```
- 浏览器访问:<http://127.0.0.1:8980/js/> 账号 system 密码 admin
- 查看日志:
```sh
docker logs -f js5
```
- 浏览器访问:<http://127.0.0.1:8980/js> 账号 system 密码 admin
### 开发环境
@@ -179,9 +174,9 @@ docker run --name jeesite-web -p 8980:8980 -d --restart unless-stopped \
3. 分离端运行文档:<https://jeesite.com/docs/vue-install-deploy/>
4. 分离端常见问题:<https://jeesite.com/docs/vue-faq/>
## 技术文章
## 学习文档
* 库表生成、代码生成https://jeesite.com/docs/code-gen/>
* 库表生成、代码生成:<https://jeesite.com/docs/code-gen/>
* 菜单权限、按钮权限:<https://jeesite.com/docs/permi-shiro/>
* 数据权限、库事务:<https://jeesite.com/docs/service-datascope/#数据权限>
* 表结构、数据字典:<https://jeesite.com/docs/code-gen/#表结构数据字典>
@@ -208,36 +203,34 @@ docker run --name jeesite-web -p 8980:8980 -d --restart unless-stopped \
* 常用工具:<https://jeesite.com/docs/jeesite-js/>
* 自定义主题:<https://jeesite.com/docs/custom-views/>
## 专题文章
## 更多文档
* 系统接口文档<https://jeesite.com/docs/mobile-rest-api/>
* 多语言国际化<https://jeesite.com/docs/i18n-locale/>
* BPM工作流引擎<https://jeesite.com/docs/bpm/>
* CMS内容管理<https://jeesite.com/docs/cms/>
* AI知识库助手<https://jeesite.com/docs/cms-ai/>
* 用户类型<https://jeesite.com/docs/user-type/>
* 消息推送<https://jeesite.com/docs/msg-push-use/>
* 单点登录:<https://jeesite.com/docs/sso-cas/>
* AI、CMS、RAG、Tool、MCP 人工智能助手<https://jeesite.com/docs/ai-cms>
* BPM 业务流程引擎Flowable<http://jeesite.com/docs/bpm/>
* CMS 多站点内容管理模块<https://jeesite.com/docs/cms/>
* 消息推送消息提醒<https://jeesite.com/docs/msg-push-use/>
* 对象存储模块<https://jeesite.com/docs/oss-client>
* 单点登录模块<https://jeesite.com/docs/sso-cas>
* 在线任务调度:<https://jeesite.com/docs/job/>
* 对象存储:<https://jeesite.com/docs/oss-client/>
* 大屏设计器:<https://jeesite.com/docs/visual/>
* 报表设计器:<https://jeesite.com/docs/ureport/>
* 文件管理分享:<https://jeesite.com/docs/filemanager/>
* 文件在线预览:<https://jeesite.com/docs/filepreview/>
* 三员管理员:<https://jeesite.com/docs/manager3/>
* 手机端框架:<https://jeesite.com/docs/uniapp/>
* 统一认证服务:<https://jeesite.com/docs/oauth2-server/>
* 树表结构设计:<https://jeesite.com/docs/tree-table-use/>
## 云服务架构
* 多租户、SaaS服务<https://jeesite.com/docs/saas-corp-use/>
* 集群、负载均衡、高可用<https://jeesite.com/docs/cluster/>
* Spring Cloud 微服务:<https://jeesite.com/docs/springcloud/>
* 分布式事务 Seata<https://jeesite.com/docs/springcloud-seata/>
* 读写分离、分库分表:<https://jeesite.com/docs/sharding/>
* 监控系统集成:<https://jeesite.com/docs/webadmin/>
* 集群、高可用架构:<https://jeesite.com/docs/cluster/>
* SaaS 多租户架构:<https://jeesite.com/docs/saas-corp-use/>
* 读写分离分片分表<https://jeesite.com/docs/sharding/>
* Spring监控系统<https://jeesite.com/docs/webadmin/>
* 分布式跨应用事务:<https://jeesite.com/docs/seata/>
* 追踪系统集成:<https://jeesite.com/docs/skywalking/>
* ELK日志收集<https://jeesite.com/docs/elk-log/>
* ELK 日志收集:<https://jeesite.com/docs/elk-log/>
* MybatisPlus: <https://gitee.com/thinkgem/jeesite-mybatisplus>
* 接口快速开发:<https://gitee.com/thinkgem/jeesite-magic-api>
* 内外网中间件:<https://my.oschina.net/thinkgem/blog/4624519>
* 统一认证平台:<https://jeesite.com/docs/oauth2-server>
## 授权协议声明

View File

@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="UTF-8"?><!--suppress VulnerableLibrariesLocal -->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
@@ -6,7 +6,7 @@
<parent>
<groupId>com.jeesite</groupId>
<artifactId>jeesite-parent</artifactId>
<version>5.12.1-SNAPSHOT</version>
<version>5.14.0-SNAPSHOT</version>
<relativePath>../parent/pom.xml</relativePath>
</parent>

View File

@@ -61,7 +61,6 @@ public class DigestUtils {
* @param algorithm 散列算法("SHA-1"、"MD5"、"SM3"
* @param salt 可为空
* @param iterations 迭代次数
* @return
*/
public static byte[] digest(byte[] input, String algorithm, byte[] salt, int iterations) {
try {

View File

@@ -32,7 +32,7 @@ import java.util.regex.Pattern;
* 4. JDK 提供的 URLEncoder
* 5. XSS、SQL、orderBy 过滤器
* @author calvin、ThinkGem
* @version 2022-2-17
* @version 2025-7-9
*/
public class EncodeUtils {
@@ -191,7 +191,7 @@ public class EncodeUtils {
// 预编译XSS过滤正则表达式
private static final List<Pattern> xssPatterns = ListUtils.newArrayList(
Pattern.compile("(<\\s*(script|link|style|iframe)([\\s\\S]*?)(>|<\\/\\s*\\1\\s*>))|(</\\s*(script|link|style|iframe)\\s*>)", Pattern.CASE_INSENSITIVE),
Pattern.compile("\\s*(href|src)\\s*=\\s*(\"\\s*(javascript|vbscript):[^\"]+\"|'\\s*(javascript|vbscript):[^']+'|(javascript|vbscript):[^\\s]+)\\s*(?=>)", Pattern.CASE_INSENSITIVE),
Pattern.compile("\\s*(href|src)\\s*=\\s*(\"\\s*(javascript|vbscript|data):[^\"]+\"|'\\s*(javascript|vbscript|data):[^']+'|(javascript|vbscript|data):[^\\s]+)\\s*(?=>)", Pattern.CASE_INSENSITIVE),
Pattern.compile("\\s*/?\\s*on[a-zA-Z]+\\s*=\\s*(['\"]?)(.*?)\\1(?=\\s|>|/>)", Pattern.CASE_INSENSITIVE),
Pattern.compile("(eval\\((.*?)\\)|expression\\((.*?)\\))", Pattern.CASE_INSENSITIVE),
Pattern.compile("^(javascript:|vbscript:)", Pattern.CASE_INSENSITIVE)

View File

@@ -24,20 +24,20 @@ public class CommandUtils {
public static String execute(String command, String charsetName) throws IOException {
Process process = Runtime.getRuntime().exec(command);
// 记录dos命令的返回信息
StringBuffer stringBuffer = new StringBuffer();
StringBuilder sb = new StringBuilder();
// 获取返回信息的流
InputStream in = process.getInputStream();
Reader reader = new InputStreamReader(in, charsetName);
BufferedReader bReader = new BufferedReader(reader);
String res = bReader.readLine();
while (res != null) {
stringBuffer.append(res);
stringBuffer.append("\n");
sb.append(res);
sb.append("\n");
res = bReader.readLine();
}
bReader.close();
reader.close();
return stringBuffer.toString();
return sb.toString();
}
}

View File

@@ -4,26 +4,21 @@
*/
package com.jeesite.common.image;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.io.OutputStream;
import java.util.Random;
import org.patchca.background.BackgroundFactory;
import org.patchca.color.ColorFactory;
import org.patchca.filter.predefined.CurvesRippleFilterFactory;
import org.patchca.filter.predefined.DiffuseRippleFilterFactory;
import org.patchca.filter.predefined.DoubleRippleFilterFactory;
import org.patchca.filter.predefined.MarbleRippleFilterFactory;
import org.patchca.filter.predefined.WobbleRippleFilterFactory;
import org.patchca.filter.predefined.*;
import org.patchca.font.RandomFontFactory;
import org.patchca.service.ConfigurableCaptchaService;
import org.patchca.text.renderer.BestFitTextRenderer;
import org.patchca.utils.encoder.EncoderHelper;
import org.patchca.word.RandomWordFactory;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.io.OutputStream;
import java.util.Random;
/**
* 验证码工具
* @author ThinkGem
@@ -31,7 +26,7 @@ import org.patchca.word.RandomWordFactory;
*/
public class CaptchaUtils {
private static Random random = new Random();
private static final Random random = new Random();
private volatile static ConfigurableCaptchaService ccs;
private static WobbleRippleFilterFactory wrff; // 摆波纹
private static DoubleRippleFilterFactory doff; // 双波纹
@@ -135,9 +130,6 @@ public class CaptchaUtils {
/**
* 生成验证码
* @param request
* @param response
* @throws IOException
* @return 验证码字符
*/
public static String generateCaptcha(OutputStream outputStream) throws IOException{

View File

@@ -11,7 +11,7 @@
//import com.drew.metadata.exif.GpsDirectory;
//
///**
// * 图片地理信息获取
// * 图片地理信息获取pom.xml 中打开 com.drewnoakes 依赖)
// * @author ThinkGem
// */
//public class ImageGeo {
@@ -45,7 +45,7 @@
// if (easting.equalsIgnoreCase("W")) {
// lonsign = -1.0d;
// }
//
//
// lat = (Math.abs(latpart[0].doubleValue()) + latpart[1].doubleValue() / 60.0d + latpart[2].doubleValue() / 3600.0d) * latsign;
// lon = (Math.abs(lonpart[0].doubleValue()) + lonpart[1].doubleValue() / 60.0d + lonpart[2].doubleValue() / 3600.0d) * lonsign;
//

View File

@@ -68,7 +68,7 @@ public class ImageUtils {
bilder.toFile(targetFile);
}
}catch(IOException e){
logger.error("图片压缩失败:" + imageFile.getAbsoluteFile(), e);
logger.error("图片压缩失败:{}", imageFile.getAbsoluteFile(), e);
}
}

View File

@@ -10,6 +10,8 @@ import com.google.zxing.client.j2se.MatrixToImageWriter;
import com.google.zxing.common.BitMatrix;
import com.google.zxing.common.HybridBinarizer;
import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
@@ -23,13 +25,14 @@ import java.util.Hashtable;
*/
public class ZxingUtils {
private static final Logger logger = LoggerFactory.getLogger(ZxingUtils.class);
/**
* 条形码编码
*
* @param contents
* @param width
* @param height
* @param imgPath
* @param contents 内容
* @param width 宽度
* @param height 高度
* @param imgPath 图片路径
*/
public static void encode(String contents, int width, int height, String imgPath) {
int codeWidth = 3 + // start guard
@@ -42,14 +45,13 @@ public class ZxingUtils {
BitMatrix bitMatrix = new MultiFormatWriter().encode(contents, BarcodeFormat.EAN_13, codeWidth, height, null);
MatrixToImageWriter.writeToPath(bitMatrix, "png", new File(imgPath).toPath());
} catch (Exception e) {
e.printStackTrace();
logger.error(e.getMessage(), e);
}
}
/**
* 条形码解码
*
* @param imgPath
* @param imgPath 图片路径
* @return String
*/
public static String decode(String imgPath) {
@@ -58,25 +60,24 @@ public class ZxingUtils {
try {
image = ImageIO.read(new File(imgPath));
if (image == null) {
System.out.println("the decode image may be not exit.");
logger.debug("the decode image may be not exit.");
}
LuminanceSource source = new BufferedImageLuminanceSource(image);
BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source));
result = new MultiFormatReader().decode(bitmap, null);
return result.getText();
} catch (Exception e) {
e.printStackTrace();
logger.error(e.getMessage(), e);
}
return null;
}
/**
* 二维码编码
*
* @param contents
* @param width
* @param height
* @param imgPath
* @param contents 内容
* @param width 宽度
* @param height 高度
* @param imgPath 图片路径
*/
public static void encode2(String contents, int width, int height, String imgPath) {
Hashtable<EncodeHintType, Object> hints = new Hashtable<EncodeHintType, Object>();
@@ -88,14 +89,13 @@ public class ZxingUtils {
BitMatrix bitMatrix = new MultiFormatWriter().encode(contents, BarcodeFormat.QR_CODE, width, height, hints);
MatrixToImageWriter.writeToPath(bitMatrix, "png", new File(imgPath).toPath());
} catch (Exception e) {
e.printStackTrace();
logger.error(e.getMessage(), e);
}
}
/**
* 二维码解码
*
* @param imgPath
* @param imgPath 图片路径
* @return String
*/
public static String decode2(String imgPath) {
@@ -104,7 +104,7 @@ public class ZxingUtils {
try {
image = ImageIO.read(new File(imgPath));
if (image == null) {
System.out.println("the decode image may be not exit.");
logger.debug("the decode image may be not exit.");
}
LuminanceSource source = new BufferedImageLuminanceSource(image);
BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source));
@@ -113,7 +113,7 @@ public class ZxingUtils {
result = new MultiFormatReader().decode(bitmap, hints);
return result.getText();
} catch (Exception e) {
e.printStackTrace();
logger.error(e.getMessage(), e);
}
return null;
}

View File

@@ -19,6 +19,8 @@ import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.util.Enumeration;
import java.util.List;
import java.util.Objects;
@@ -30,7 +32,7 @@ import java.util.zip.ZipOutputStream;
* 文件操作工具类
* 实现文件的创建、删除、复制、压缩、解压以及目录的创建、删除、复制、压缩解压等功能
* @author ThinkGem
* @version 2015-3-16
* @version 2025-08-08
*/
@SuppressWarnings("deprecation")
public class FileUtils extends org.apache.commons.io.FileUtils {
@@ -57,17 +59,16 @@ public class FileUtils extends org.apache.commons.io.FileUtils {
* @param coverlay 如果目标文件已存在,是否覆盖
* @return 如果复制成功则返回true否则返回false
*/
public static boolean copyFileCover(String srcFileName,
String descFileName, boolean coverlay) {
public static boolean copyFileCover(String srcFileName, String descFileName, boolean coverlay) {
File srcFile = new File(srcFileName);
// 判断源文件是否存在
if (!srcFile.exists()) {
logger.debug("复制文件失败,源文件 " + srcFileName + " 不存在!");
logger.debug("复制文件失败,源文件 {} 不存在!", srcFileName);
return false;
}
// 判断源文件是否是合法的文件
else if (!srcFile.isFile()) {
logger.debug("复制文件失败," + srcFileName + " 不是一个文件!");
logger.debug("复制文件失败,{} 不是一个文件!", srcFileName);
return false;
}
File descFile = new File(descFileName);
@@ -77,11 +78,11 @@ public class FileUtils extends org.apache.commons.io.FileUtils {
if (coverlay) {
logger.debug("目标文件已存在,准备删除!");
if (!FileUtils.delFile(descFileName)) {
logger.debug("删除目标文件 " + descFileName + " 失败!");
logger.debug("删除目标文件 {} 失败!", descFileName);
return false;
}
} else {
logger.debug("复制文件失败,目标文件 " + descFileName + " 已存在!");
logger.debug("复制文件失败,目标文件 {} 已存在!", descFileName);
return false;
}
} else {
@@ -95,45 +96,26 @@ public class FileUtils extends org.apache.commons.io.FileUtils {
}
}
}
// 准备复制文件
// 读取的位数
int readByte = 0;
InputStream ins = null;
OutputStream outs = null;
try {
try (
// 打开源文件
ins = new FileInputStream(srcFile);
InputStream ins = Files.newInputStream(srcFile.toPath());
// 打开目标文件的输出流
outs = new FileOutputStream(descFile);
byte[] buf = new byte[1024];
OutputStream outs = Files.newOutputStream(descFile.toPath());
) {
// 读取的位数
int readByte = 0;
// 一次读取1024个字节当readByte为-1时表示文件已经读取完毕
byte[] buf = new byte[1024];
while ((readByte = ins.read(buf)) != -1) {
// 将读取的字节流写入到输出流
outs.write(buf, 0, readByte);
}
logger.debug("复制单个文件 " + srcFileName + "" + descFileName
+ "成功!");
logger.debug("复制单个文件 {} 到{}成功!", srcFileName, descFileName);
return true;
} catch (Exception e) {
logger.debug("复制文件失败:" + e.getMessage());
logger.debug("复制文件失败:{}", e.getMessage());
return false;
} finally {
// 关闭输入输出流,首先关闭输出流,然后再关闭输入流
if (outs != null) {
try {
outs.close();
} catch (IOException oute) {
oute.printStackTrace();
}
}
if (ins != null) {
try {
ins.close();
} catch (IOException ine) {
ine.printStackTrace();
}
}
}
}
@@ -144,8 +126,7 @@ public class FileUtils extends org.apache.commons.io.FileUtils {
* @return 如果复制成功返回true否则返回false
*/
public static boolean copyDirectory(String srcDirName, String descDirName) {
return FileUtils.copyDirectoryCover(srcDirName, descDirName,
false);
return FileUtils.copyDirectoryCover(srcDirName, descDirName, false);
}
/**
@@ -155,17 +136,16 @@ public class FileUtils extends org.apache.commons.io.FileUtils {
* @param coverlay 如果目标目录存在,是否覆盖
* @return 如果复制成功返回true否则返回false
*/
public static boolean copyDirectoryCover(String srcDirName,
String descDirName, boolean coverlay) {
public static boolean copyDirectoryCover(String srcDirName, String descDirName, boolean coverlay) {
File srcDir = new File(srcDirName);
// 判断源目录是否存在
if (!srcDir.exists()) {
logger.debug("复制目录失败,源目录 " + srcDirName + " 不存在!");
logger.debug("复制目录失败,源目录 {} 不存在!", srcDirName);
return false;
}
// 判断源目录是否是目录
else if (!srcDir.isDirectory()) {
logger.debug("复制目录失败," + srcDirName + " 不是一个目录!");
logger.debug("复制目录失败,{} 不是一个目录!", srcDirName);
return false;
}
// 如果目标文件夹名不以文件分隔符结尾,自动添加文件分隔符
@@ -180,11 +160,11 @@ public class FileUtils extends org.apache.commons.io.FileUtils {
// 允许覆盖目标目录
logger.debug("目标目录已存在,准备删除!");
if (!FileUtils.delFile(descDirNames)) {
logger.debug("删除目录 " + descDirNames + " 失败!");
logger.debug("删除目录 {} 失败!", descDirNames);
return false;
}
} else {
logger.debug("目标目录复制失败,目标目录 " + descDirNames + " 已存在!");
logger.debug("目标目录复制失败,目标目录 {} 已存在!", descDirNames);
return false;
}
} else {
@@ -200,32 +180,31 @@ public class FileUtils extends org.apache.commons.io.FileUtils {
boolean flag = true;
// 列出源目录下的所有文件名和子目录名
File[] files = srcDir.listFiles();
for (int i = 0; i < files.length; i++) {
// 如果是一个单个文件,则直接复制
if (files[i].isFile()) {
flag = FileUtils.copyFile(files[i].getAbsolutePath(),
descDirName + files[i].getName());
// 如果拷贝文件失败,则退出循环
if (!flag) {
break;
if (files != null) {
for (File file : files) {
// 如果是一个单个文件,则直接复制
if (file.isFile()) {
flag = FileUtils.copyFile(file.getAbsolutePath(), descDirName + file.getName());
// 如果拷贝文件失败,则退出循环
if (!flag) {
break;
}
}
}
// 如果是子目录,则继续复制目录
if (files[i].isDirectory()) {
flag = FileUtils.copyDirectory(files[i]
.getAbsolutePath(), descDirName + files[i].getName());
// 如果拷贝目录失败,则退出循环
if (!flag) {
break;
// 如果是子目录,则继续复制目录
if (file.isDirectory()) {
flag = FileUtils.copyDirectory(file.getAbsolutePath(), descDirName + file.getName());
// 如果拷贝目录失败,则退出循环
if (!flag) {
break;
}
}
}
}
if (!flag) {
logger.debug("复制目录 " + srcDirName + "" + descDirName + " 失败!");
logger.debug("复制目录 {} 到 {} 失败!", srcDirName, descDirName);
return false;
}
logger.debug("复制目录 " + srcDirName + "" + descDirName + " 成功!");
logger.debug("复制目录 {} 到 {} 成功!", srcDirName, descDirName);
return true;
}
@@ -238,7 +217,7 @@ public class FileUtils extends org.apache.commons.io.FileUtils {
*/
public static String readFileToString(String classResourcePath){
try (InputStream in = new ClassPathResource(classResourcePath).getInputStream()){
return IOUtils.toString(in, EncodeUtils.UTF_8);
return IOUtils.toString(in, StandardCharsets.UTF_8);
} catch (IOException e) {
logger.warn("Error file convert: {}", e.getMessage());
}
@@ -246,16 +225,14 @@ public class FileUtils extends org.apache.commons.io.FileUtils {
}
/**
*
* 删除文件,可以删除单个文件或文件夹
*
* @param fileName 被删除的文件名
* @return 如果删除成功则返回true否是返回false
*/
public static boolean delFile(String fileName) {
File file = new File(fileName);
if (!file.exists()) {
logger.debug(fileName + " 文件不存在!");
logger.debug("{} 文件不存在!", fileName);
return true;
} else {
if (file.isFile()) {
@@ -267,9 +244,7 @@ public class FileUtils extends org.apache.commons.io.FileUtils {
}
/**
*
* 删除单个文件
*
* @param fileName 被删除的文件名
* @return 如果删除成功则返回true否则返回false
*/
@@ -277,22 +252,20 @@ public class FileUtils extends org.apache.commons.io.FileUtils {
File file = new File(fileName);
if (file.exists() && file.isFile()) {
if (file.delete()) {
logger.debug("删除文件 " + fileName + " 成功!");
logger.debug("删除文件 {} 成功!", fileName);
return true;
} else {
logger.debug("删除文件 " + fileName + " 失败!");
logger.debug("删除文件 {} 失败!", fileName);
return false;
}
} else {
logger.debug(fileName + " 文件不存在!");
logger.debug("{} 文件不存在!", fileName);
return true;
}
}
/**
*
* 删除目录及目录下的文件
*
* @param dirName 被删除的目录所在的文件路径
* @return 如果目录删除成功则返回true否则返回false
*/
@@ -309,36 +282,36 @@ public class FileUtils extends org.apache.commons.io.FileUtils {
boolean flag = true;
// 列出全部文件及子目录
File[] files = dirFile.listFiles();
for (int i = 0; i < files.length; i++) {
// 删除子文件
if (files[i].isFile()) {
flag = FileUtils.deleteFile(files[i].getAbsolutePath());
// 如果删除文件失败,则退出循环
if (!flag) {
break;
if (files != null) {
for (File file : files) {
// 删除子文件
if (file.isFile()) {
flag = FileUtils.deleteFile(file.getAbsolutePath());
// 如果删除文件失败,则退出循环
if (!flag) {
break;
}
}
}
// 删除子目录
else if (files[i].isDirectory()) {
flag = FileUtils.deleteDirectory(files[i]
.getAbsolutePath());
// 如果删除子目录失败,则退出循环
if (!flag) {
break;
// 删除子目录
else if (file.isDirectory()) {
flag = FileUtils.deleteDirectory(file.getAbsolutePath());
// 如果删除子目录失败,则退出循环
if (!flag) {
break;
}
}
}
}
if (!flag) {
logger.debug("删除目录失败!");
return false;
}
// 删除当前目录
if (dirFile.delete()) {
logger.debug("删除目录 " + dirName + " 成功!");
logger.debug("删除目录 {} 成功!", dirName);
return true;
} else {
logger.debug("删除目录 " + dirName + " 失败!");
logger.debug("删除目录 {} 失败!", dirName);
return false;
}
@@ -352,11 +325,11 @@ public class FileUtils extends org.apache.commons.io.FileUtils {
public static boolean createFile(String descFileName) {
File file = new File(descFileName);
if (file.exists()) {
logger.debug("文件 " + descFileName + " 已存在!");
logger.debug("文件 {} 已存在!", descFileName);
return false;
}
if (descFileName.endsWith(File.separator)) {
logger.debug(descFileName + " 为目录,不能创建目录!");
logger.debug("{} 为目录,不能创建目录!", descFileName);
return false;
}
if (!file.getParentFile().exists()) {
@@ -366,22 +339,19 @@ public class FileUtils extends org.apache.commons.io.FileUtils {
return false;
}
}
// 创建文件
try {
if (file.createNewFile()) {
logger.debug(descFileName + " 文件创建成功!");
logger.debug("{} 文件创建成功!", descFileName);
return true;
} else {
logger.debug(descFileName + " 文件创建失败!");
logger.debug("{} 文件创建失败!", descFileName);
return false;
}
} catch (Exception e) {
e.printStackTrace();
logger.debug(descFileName + " 文件创建失败!");
logger.debug("{} 文件创建失败!", descFileName, e);
return false;
}
}
/**
@@ -396,15 +366,15 @@ public class FileUtils extends org.apache.commons.io.FileUtils {
}
File descDir = new File(descDirNames);
if (descDir.exists()) {
logger.debug("目录 " + descDirNames + " 已存在!");
logger.debug("目录 {} 已存在!", descDirNames);
return false;
}
// 创建目录
if (descDir.mkdirs()) {
logger.debug("目录 " + descDirNames + " 创建成功!");
logger.debug("目录 {} 创建成功!", descDirNames);
return true;
} else {
logger.debug("目录 " + descDirNames + " 创建失败!");
logger.debug("目录 {} 创建失败!", descDirNames);
return false;
}
@@ -417,9 +387,9 @@ public class FileUtils extends org.apache.commons.io.FileUtils {
public static void writeToFile(String fileName, String content, boolean append) {
try {
FileUtils.write(new File(fileName), content, EncodeUtils.UTF_8, append);
logger.debug("文件 " + fileName + " 写入成功!");
logger.debug("文件 {} 写入成功!", fileName);
} catch (IOException e) {
logger.debug("文件 " + fileName + " 写入失败! " + e.getMessage());
logger.debug("文件 {} 写入失败!", fileName, e);
}
}
@@ -430,9 +400,9 @@ public class FileUtils extends org.apache.commons.io.FileUtils {
public static void writeToFile(String fileName, String content, String encoding, boolean append) {
try {
FileUtils.write(new File(fileName), content, encoding, append);
logger.debug("文件 " + fileName + " 写入成功!");
logger.debug("文件 {} 写入成功!", fileName);
} catch (IOException e) {
logger.debug("文件 " + fileName + " 写入失败! " + e.getMessage());
logger.debug("文件 {} 写入失败!", fileName, e);
}
}
@@ -447,12 +417,11 @@ public class FileUtils extends org.apache.commons.io.FileUtils {
return;
}
byte[] data = EncodeUtils.decodeBase64(base64);
File file = new File(fileName);
try {
FileUtils.writeByteArrayToFile(file, data);
} catch (IOException e) {
e.printStackTrace();
logger.error("文件 {} 写入失败!", fileName, e);
}
}
@@ -470,33 +439,30 @@ public class FileUtils extends org.apache.commons.io.FileUtils {
public static void zipFiles(String srcDirName, String fileName, String descFileName) {
// 判断目录是否存在
if (srcDirName == null) {
logger.debug("文件压缩失败,目录 " + srcDirName + " 不存在!");
logger.debug("文件压缩失败,目录 {} 不存在!", srcDirName);
return;
}
File fileDir = new File(srcDirName);
if (!fileDir.exists() || !fileDir.isDirectory()) {
logger.debug("文件压缩失败,目录 " + srcDirName + " 不存在!");
logger.debug("文件压缩失败,目录 {} 不存在!", srcDirName);
return;
}
String dirPath = fileDir.getAbsolutePath();
File descFile = new File(descFileName);
try {
ZipOutputStream zouts = new ZipOutputStream(new FileOutputStream(descFile));
try (ZipOutputStream outs = new ZipOutputStream(new FileOutputStream(descFile));) {
if ("*".equals(fileName) || StringUtils.EMPTY.equals(fileName)) {
FileUtils.zipDirectoryToZipFile(dirPath, fileDir, zouts);
FileUtils.zipDirectoryToZipFile(dirPath, fileDir, outs);
} else {
File file = new File(fileDir, fileName);
if (file.isFile()) {
FileUtils.zipFilesToZipFile(dirPath, file, zouts);
FileUtils.zipFilesToZipFile(dirPath, file, outs);
} else {
FileUtils.zipDirectoryToZipFile(dirPath, file, zouts);
FileUtils.zipDirectoryToZipFile(dirPath, file, outs);
}
}
zouts.close();
logger.debug(descFileName + " 文件压缩成功!");
logger.debug("{} 文件压缩成功!", descFileName);
} catch (Exception e) {
logger.debug("文件压缩失败" + e.getMessage());
e.printStackTrace();
logger.error("文件压缩失败!", e);
}
}
@@ -510,10 +476,11 @@ public class FileUtils extends org.apache.commons.io.FileUtils {
String descFileNames = descFileName;
if (!descFileNames.endsWith(File.separator)) {
descFileNames = descFileNames + File.separator;
}
try {
}
try (
// 根据ZIP文件创建ZipFile对象
ZipFile zipFile = new ZipFile(zipFileName);
) {
ZipEntry entry = null;
String entryName = null;
String descFileDir = null;
@@ -537,21 +504,21 @@ public class FileUtils extends org.apache.commons.io.FileUtils {
new File(descFileDir).getParentFile().mkdirs();
}
File file = new File(descFileDir);
// 打开文件输出流
OutputStream os = new FileOutputStream(file);
// 从ZipFile对象中打开entry的输入流
InputStream is = zipFile.getInputStream(entry);
while ((readByte = is.read(buf)) != -1) {
os.write(buf, 0, readByte);
try (
// 打开文件输出流
OutputStream os = new FileOutputStream(file);
// 从ZipFile对象中打开entry的输入流
InputStream is = zipFile.getInputStream(entry);
) {
while ((readByte = is.read(buf)) != -1) {
os.write(buf, 0, readByte);
}
}
os.close();
is.close();
}
zipFile.close();
logger.debug("文件解压成功!");
return true;
} catch (Exception e) {
logger.debug("文件解压失败" + e.getMessage());
logger.error("文件解压失败!", e);
return false;
}
}
@@ -566,25 +533,26 @@ public class FileUtils extends org.apache.commons.io.FileUtils {
if (fileDir.isDirectory()) {
File[] files = fileDir.listFiles();
// 空的文件夹
if (files.length == 0) {
if (files != null && files.length == 0) {
// 目录信息
ZipEntry entry = new ZipEntry(getEntryName(dirPath, fileDir));
try {
zouts.putNextEntry(entry);
zouts.closeEntry();
} catch (Exception e) {
e.printStackTrace();
logger.error("压缩失败!", e);
}
return;
}
for (int i = 0; i < files.length; i++) {
if (files[i].isFile()) {
// 如果是文件,则调用文件压缩方法
FileUtils.zipFilesToZipFile(dirPath, files[i], zouts);
} else {
// 如果是目录,则递归调用
FileUtils.zipDirectoryToZipFile(dirPath, files[i], zouts);
if (files != null) {
for (File file : files) {
if (file.isFile()) {
// 如果是文件,则调用文件压缩方法
FileUtils.zipFilesToZipFile(dirPath, file, zouts);
} else {
// 如果是目录,则递归调用
FileUtils.zipDirectoryToZipFile(dirPath, file, zouts);
}
}
}
}
@@ -597,17 +565,16 @@ public class FileUtils extends org.apache.commons.io.FileUtils {
* @param zouts 输出流
*/
public static void zipFilesToZipFile(String dirPath, File file, ZipOutputStream zouts) {
FileInputStream fin = null;
ZipEntry entry = null;
// 创建复制缓冲区
byte[] buf = new byte[4096];
int readByte = 0;
if (file.isFile()) {
try {
try (
// 创建一个文件输入流
fin = new FileInputStream(file);
FileInputStream fin = new FileInputStream(file);
) {
// 创建一个ZipEntry
entry = new ZipEntry(getEntryName(dirPath, file));
ZipEntry entry = new ZipEntry(getEntryName(dirPath, file));
// 存储信息到压缩文件
zouts.putNextEntry(entry);
// 复制字节到压缩文件
@@ -615,10 +582,9 @@ public class FileUtils extends org.apache.commons.io.FileUtils {
zouts.write(buf, 0, readByte);
}
zouts.closeEntry();
fin.close();
logger.debug("添加文件 " + file.getAbsolutePath() + " 到zip文件中!");
logger.debug("添加文件 {} 到zip文件中!", file.getAbsolutePath());
} catch (Exception e) {
e.printStackTrace();
logger.error("添加文件失败!", e);
}
}
}
@@ -627,7 +593,7 @@ public class FileUtils extends org.apache.commons.io.FileUtils {
* 获取待压缩文件在ZIP文件中entry的名字即相对于跟目录的相对路径名
* @param dirPath 目录名
* @param file entry文件名
* @return
* @return entry名字
*/
private static String getEntryName(String dirPath, File file) {
String dirPaths = dirPath;
@@ -842,8 +808,8 @@ public class FileUtils extends org.apache.commons.io.FileUtils {
/**
* 根据图片Base64获取文件扩展名
* @param imageBase64
* @return
* @param imageBase64 图片编码内容
* @return 图片文件的扩展名
* @author ThinkGem
*/
public static String getFileExtensionByImageBase64(String imageBase64){
@@ -861,33 +827,28 @@ public class FileUtils extends org.apache.commons.io.FileUtils {
/**
* 获取工程源文件所在路径
* @return
*/
public static String getProjectPath(){
String projectPath = "";
try {
File file = ResourceUtils.getResource("").getFile();
if (file != null){
while(true){
File f = new File(path(file.getPath() + "/src/main"));
if (f.exists()){
break;
}
f = new File(path(file.getPath() + "/target/classes"));
if (f.exists()){
break;
}
File p = file.getParentFile();
if (p != null){
file = p;
}else{
break;
}
while (true) {
File f = new File(path(file.getPath() + "/src/main"));
if (f.exists()) {
break;
}
f = new File(path(file.getPath() + "/target/classes"));
if (f.exists()) {
break;
}
File p = file.getParentFile();
if (p != null) {
file = p;
} else {
break;
}
projectPath = file.toString();
}
} catch (FileNotFoundException e) {
// 忽略异常
projectPath = file.toString();
} catch (IOException e) {
// 忽略异常
}
@@ -900,33 +861,28 @@ public class FileUtils extends org.apache.commons.io.FileUtils {
/**
* 获取工程源文件所在路径
* @return
*/
public static String getWebappPath(){
String webappPath = "";
try {
File file = ResourceUtils.getResource("").getFile();
if (file != null){
while(true){
File f = new File(path(file.getPath() + "/WEB-INF/classes"));
if (f.exists()){
break;
}
f = new File(path(file.getPath() + "/src/main/webapp"));
if (f.exists()){
return f.getPath();
}
File p = file.getParentFile();
if (p != null){
file = p;
}else{
break;
}
while (true) {
File f = new File(path(file.getPath() + "/WEB-INF/classes"));
if (f.exists()) {
break;
}
f = new File(path(file.getPath() + "/src/main/webapp"));
if (f.exists()) {
return f.getPath();
}
File p = file.getParentFile();
if (p != null) {
file = p;
} else {
break;
}
webappPath = file.toString();
}
} catch (FileNotFoundException e) {
// 忽略异常
webappPath = file.toString();
} catch (IOException e) {
// 忽略异常
}

View File

@@ -4,6 +4,9 @@
*/
package com.jeesite.common.io;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.Closeable;
import java.io.File;
import java.io.FileInputStream;
@@ -15,71 +18,70 @@ import java.io.InputStream;
/**
* 数据流工具类
* @author ThinkGem
* @version 2025-08-08
*/
public class IOUtils extends org.apache.commons.io.IOUtils {
private static final Logger logger = LoggerFactory.getLogger(IOUtils.class);
/**
* 根据文件路径创建文件输入流处理 以字节为单位(非 unicode
* @param filePath
* @return
* @param filePath 文件路径
* @return 文件流
*/
public static FileInputStream getFileInputStream(String filePath) {
FileInputStream fileInputStream = null;
try {
fileInputStream = new FileInputStream(filePath);
} catch (FileNotFoundException e) {
System.out.println("错误信息:文件不存在");
e.printStackTrace();
logger.error("文件不存在!", e);
}
return fileInputStream;
}
/**
* 根据文件对象创建文件输入流处理 以字节为单位(非 unicode
* @param file
* @return
* @param file 文件对象
* @return 文件流
*/
public static FileInputStream getFileInputStream(File file) {
FileInputStream fileInputStream = null;
try {
fileInputStream = new FileInputStream(file);
} catch (FileNotFoundException e) {
System.out.println("错误信息:文件不存在");
e.printStackTrace();
logger.error("文件不存在!", e);
}
return fileInputStream;
}
/**
* 根据文件对象创建文件输出流处理 以字节为单位(非 unicode
* @param file
* @param file 文件对象
* @param append true:文件以追加方式打开,false:则覆盖原文件的内容
* @return
* @return 文件流
*/
public static FileOutputStream getFileOutputStream(File file, boolean append) {
FileOutputStream fileOutputStream = null;
try {
fileOutputStream = new FileOutputStream(file, append);
} catch (FileNotFoundException e) {
System.out.println("错误信息:文件不存在");
e.printStackTrace();
logger.error("文件不存在!", e);
}
return fileOutputStream;
}
/**
* 根据文件路径创建文件输出流处理 以字节为单位(非 unicode
* @param filePath
* @param filePath 文件路径
* @param append true:文件以追加方式打开,false:则覆盖原文件的内容
* @return
* @return 文件流
*/
public static FileOutputStream getFileOutputStream(String filePath, boolean append) {
FileOutputStream fileOutputStream = null;
try {
fileOutputStream = new FileOutputStream(filePath, append);
} catch (FileNotFoundException e) {
System.out.println("错误信息:文件不存在");
e.printStackTrace();
logger.error("文件不存在!", e);
}
return fileOutputStream;
}

View File

@@ -30,7 +30,7 @@ import java.util.regex.Pattern;
* 相同的属性在最后载入的文件中的值将会覆盖之前的值,
* 取不到从System.getProperty()获取。
* @author ThinkGem
* @version 2017-12-30
* @version 2025-4-17
*/
public class PropertiesUtils {
@@ -66,8 +66,11 @@ public class PropertiesUtils {
// 获取全局设置默认的配置文件(以下是支持环境配置的属性文件)
Set<String> set = SetUtils.newLinkedHashSet();
set.addAll(Arrays.asList(DEFAULT_CONFIG_FILE));
// 获取 spring.config.location 外部自定义的配置文件
// 获取 spring.config.location、spring.config.additional-location 外部自定义的配置文件
String customConfigs = System.getProperty("spring.config.location");
if (StringUtils.isBlank(customConfigs)){
customConfigs = System.getProperty("spring.config.additional-location");
}
if (StringUtils.isNotBlank(customConfigs)){
for (String customConfig : StringUtils.splitComma(customConfigs)){
if (!customConfig.contains("$")){

View File

@@ -4,7 +4,6 @@
*/
package com.jeesite.common.io;
import com.jeesite.common.codec.EncodeUtils;
import com.jeesite.common.lang.ExceptionUtils;
import org.springframework.core.io.DefaultResourceLoader;
import org.springframework.core.io.Resource;
@@ -14,6 +13,7 @@ import org.springframework.core.io.support.ResourcePatternResolver;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
/**
* 资源供给类
@@ -53,9 +53,7 @@ public class ResourceUtils extends org.springframework.util.ResourceUtils {
/**
* 获取资源文件流(用后记得关闭)
* @param location
* @author ThinkGem
* @throws IOException
*/
public static InputStream getResourceFileStream(String location) throws IOException{
Resource resource = resourceLoader.getResource(location);
@@ -64,12 +62,11 @@ public class ResourceUtils extends org.springframework.util.ResourceUtils {
/**
* 获取资源文件内容
* @param location
* @author ThinkGem
*/
public static String getResourceFileContent(String location){
try(InputStream is = ResourceUtils.getResourceFileStream(location)){
return IOUtils.toString(is, EncodeUtils.UTF_8);
return IOUtils.toString(is, StandardCharsets.UTF_8);
}catch (IOException e) {
throw ExceptionUtils.unchecked(e);
}
@@ -77,13 +74,11 @@ public class ResourceUtils extends org.springframework.util.ResourceUtils {
/**
* Spring 搜索资源文件
* @param locationPattern
* @author ThinkGem
*/
public static Resource[] getResources(String locationPattern){
try {
Resource[] resources = resourceResolver.getResources(locationPattern);
return resources;
return resourceResolver.getResources(locationPattern);
} catch (IOException e) {
throw ExceptionUtils.unchecked(e);
}

View File

@@ -15,7 +15,6 @@ public class ByteUtils {
/**
* @param byteSize 字节
* @return
*/
public static String formatByteSize(long byteSize) {

View File

@@ -15,7 +15,7 @@ import java.util.Date;
/**
* 日期工具类, 继承org.apache.commons.lang.time.DateUtils类
* @author ThinkGem
* @version 2017-1-4
* @version 2025-08-08
*/
public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
@@ -84,7 +84,6 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
* @param pattern 格式yyyy-MM-dd pattern可以为"yyyy-MM-dd" "HH:mm:ss" "E"
* @param amont 数量,前为负数,后为正数
* @param type 类型可参考Calendar的常量(如Calendar.HOUR、Calendar.MINUTE、Calendar.SECOND)
* @return
*/
public static String getDate(String pattern, int amont, int type) {
Calendar calendar = Calendar.getInstance(LocaleUtils.getTimeZone(), LocaleUtils.getLocale());
@@ -179,8 +178,7 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
/**
* 获取过去的天数
* @param date
* @return
* @param date 日期
*/
public static long pastDays(Date date) {
long t = System.currentTimeMillis()-date.getTime();
@@ -189,8 +187,7 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
/**
* 获取过去的小时
* @param date
* @return
* @param date 日期
*/
public static long pastHour(Date date) {
long t = System.currentTimeMillis()-date.getTime();
@@ -199,8 +196,7 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
/**
* 获取过去的分钟
* @param date
* @return
* @param date 日期
*/
public static long pastMinutes(Date date) {
long t = System.currentTimeMillis()-date.getTime();
@@ -209,15 +205,13 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
/**
* 获取两个日期之间的天数
*
* @param before
* @param after
* @return
* @param before 开始日期
* @param after 结束日期
*/
public static double getDistanceOfTwoDate(Date before, Date after) {
long beforeTime = before.getTime();
long afterTime = after.getTime();
return (afterTime - beforeTime) / (1000 * 60 * 60 * 24);
return (double) (afterTime - beforeTime) / (1000 * 60 * 60 * 24);
}
/**
@@ -250,8 +244,7 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
/**
* 获取日期是当年的第几周
* @param date
* @return
* @param date 日期
*/
public static int getWeekOfYear(Date date){
Calendar cal = Calendar.getInstance(LocaleUtils.getTimeZone(), LocaleUtils.getLocale());
@@ -262,7 +255,6 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
/**
* 获取一天的开始时间2015-11-3 00:00:00.000
* @param date 日期
* @return
*/
public static Date getOfDayFirst(Date date) {
if (date == null){
@@ -280,7 +272,6 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
/**
* 获取一天的最后时间2015-11-3 23:59:59.999
* @param date 日期
* @return
*/
public static Date getOfDayLast(Date date) {
if (date == null){
@@ -297,7 +288,6 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
/**
* 获取服务器启动时间
* @return
*/
public static Date getServerStartDate(){
long time = ManagementFactory.getRuntimeMXBean().getStartTime();

View File

@@ -19,8 +19,7 @@ public class ExceptionUtils {
/**
* 在request中获取异常类
* @param request
* @return
* @param request 请求对象
*/
public static Throwable getThrowable(HttpServletRequest request){
Throwable ex = null;

View File

@@ -79,7 +79,6 @@ public class NumberUtils extends org.apache.commons.lang3.math.NumberUtils {
/**
* 格式化双精度,保留两个小数
* @return
*/
public static String formatDouble(Double b) {
BigDecimal bg = new BigDecimal(b);
@@ -88,7 +87,6 @@ public class NumberUtils extends org.apache.commons.lang3.math.NumberUtils {
/**
* 百分比计算
* @return
*/
public static String formatScale(double one, long total) {
BigDecimal bg = new BigDecimal(one * 100 / total);
@@ -97,8 +95,6 @@ public class NumberUtils extends org.apache.commons.lang3.math.NumberUtils {
/**
* 格式化数值类型
* @param data
* @param pattern
*/
public static String formatNumber(Object data, String pattern) {
if (data == null){

View File

@@ -31,7 +31,7 @@ public class ObjectUtils extends org.apache.commons.lang3.ObjectUtils {
String[] ver = StringUtils.split(System.getProperty("java.version"), StringUtils.DOT);
isJavaSerialize = ver.length > 0 && Integer.parseInt(ver[0]) > 1;
}
/**
* 转换为 Double 类型
*/
@@ -150,8 +150,8 @@ public class ObjectUtils extends org.apache.commons.lang3.ObjectUtils {
/**
* 拷贝一个对象(但是子对象无法拷贝)
* @param source
* @param ignoreProperties
* @param source 原对象
* @param ignoreProperties 忽略的属性
*/
public static Object copyBean(Object source, String... ignoreProperties){
if (source == null){
@@ -169,7 +169,7 @@ public class ObjectUtils extends org.apache.commons.lang3.ObjectUtils {
/**
* 克隆一个对象(完全拷贝)
* @param source
* @param source 原对象
*/
public static Object cloneBean(Object source){
if (source == null){
@@ -181,8 +181,6 @@ public class ObjectUtils extends org.apache.commons.lang3.ObjectUtils {
/**
* 序列化对象
* @param object
* @return
*/
public static byte[] serialize(Object object) {
try {
@@ -199,8 +197,6 @@ public class ObjectUtils extends org.apache.commons.lang3.ObjectUtils {
/**
* 反序列化对象
* @param bytes
* @return
*/
public static Object unserialize(byte[] bytes) {
try {
@@ -217,8 +213,6 @@ public class ObjectUtils extends org.apache.commons.lang3.ObjectUtils {
/**
* 序列化对象
* @param object
* @return
*/
public static byte[] serializeJava(Object object) {
if (object == null){
@@ -242,8 +236,6 @@ public class ObjectUtils extends org.apache.commons.lang3.ObjectUtils {
/**
* 反序列化对象
* @param bytes
* @return
*/
public static Object unserializeJava(byte[] bytes) {
if (bytes == null){

View File

@@ -270,7 +270,7 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
}
/**
* 驼峰命名法工具
* 转换为驼峰命名法
* @return
* camelCase("hello_world") == "helloWorld"
* capCamelCase("hello_world") == "HelloWorld"
@@ -283,37 +283,35 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
s = s.toLowerCase();
StringBuilder sb = new StringBuilder(s.length());
boolean upperCase = false;
for (int i = 0; i < s.length(); i++) {
for (int i = 0, j = 0; i < s.length(); i++) {
char c = s.charAt(i);
if (c == UNDERLINE.charAt(0) || c == MINUS.charAt(0)) {
upperCase = i != 1; // 不允许第二个字符是大写
upperCase = j > 1; // 不允许第二个字符是大写
} else if (upperCase) {
sb.append(Character.toUpperCase(c));
upperCase = false;
j++;
} else {
sb.append(c);
j++;
}
}
return sb.toString();
}
/**
* 驼峰命名法工具
* 转换为驼峰命名法(首字母大写)
* @return
* camelCase("hello_world") == "helloWorld"
* capCamelCase("hello_world") == "HelloWorld"
* uncamelCase("helloWorld") = "hello_world"
*/
public static String capCamelCase(String s) {
if (s == null) {
return null;
}
s = camelCase(s);
return s.substring(0, 1).toUpperCase() + s.substring(1);
return cap(camelCase(s));
}
/**
* 驼峰命名法工具
* 取消驼峰命名
* @return
* camelCase("hello_world") == "helloWorld"
* capCamelCase("hello_world") == "HelloWorld"

View File

@@ -10,9 +10,6 @@ public class WorkDayUtils {
/**
* 获取日期之间的天数
* @param d1
* @param d2
* @return
*/
public int getDaysBetween(java.util.Calendar d1, java.util.Calendar d2) {
if (d1.after(d2)) { // swap dates so that d1 is start and d2 is end
@@ -35,9 +32,6 @@ public class WorkDayUtils {
/**
* 获取工作日
* @param d1
* @param d2
* @return
*/
public int getWorkingDay(java.util.Calendar d1, java.util.Calendar d2) {
int result = -1;
@@ -72,8 +66,6 @@ public class WorkDayUtils {
/**
* 获取中文日期
* @param date
* @return
*/
public String getChineseWeek(Calendar date) {
final String[] dayNames = { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
@@ -84,8 +76,6 @@ public class WorkDayUtils {
/**
* 获得日期的下一个星期一的日期
* @param date
* @return
*/
public Calendar getNextMonday(Calendar date) {
Calendar result = null;
@@ -99,9 +89,6 @@ public class WorkDayUtils {
/**
* 获取休息日
* @param d1
* @param d2
* @return
*/
public int getHolidays(Calendar d1, Calendar d2) {
return this.getDaysBetween(d1, d2) - this.getWorkingDay(d1, d2);

View File

@@ -28,10 +28,7 @@ import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder;
import java.io.IOException;
import java.lang.reflect.AnnotatedElement;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.TimeZone;
import java.util.*;
/**
* 封装 Jackson实现 JSON String 与 Java Object 互转
@@ -73,10 +70,15 @@ public class JsonMapper extends ObjectMapper {
* @author ThinkGem
*/
public JsonMapper setLocaleTimeZoneDateFormat(){
this.setLocale(LocaleUtils.toLocale(PropertiesUtils.getInstance()
.getProperty("lang.defaultLocale", "zh_CN")));
this.setTimeZone(TimeZone.getTimeZone(PropertiesUtils.getInstance()
.getProperty("lang.defaultTimeZone", "GMT+08:00")));
PropertiesUtils props = PropertiesUtils.getInstance();
// 设置默认语言环境
props.getPropertyIfNotBlank("lang.defaultLocale", (defaultLocale) -> {
this.setLocale(LocaleUtils.toLocale(defaultLocale));
});
// 设置默认时区
props.getPropertyIfNotBlank("lang.defaultTimeZone", (defaultTimeZone) -> {
this.setTimeZone(TimeZone.getTimeZone(defaultTimeZone));
});
this.setAnnotationIntrospector(new JacksonAnnotationIntrospector() {
private static final long serialVersionUID = 1L;
@Override

View File

@@ -4,8 +4,8 @@
*/
package com.jeesite.common.mapper;
import com.fasterxml.jackson.databind.JavaType;
import com.jeesite.common.io.PropertiesUtils;
import org.apache.commons.lang3.LocaleUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -20,7 +20,7 @@ import java.util.TimeZone;
* @version 2016-9-2
*/
public class XmlMapper extends com.fasterxml.jackson.dataformat.xml.XmlMapper{
private static final long serialVersionUID = 1L;
private static final Logger logger = LoggerFactory.getLogger(XmlMapper.class);
@@ -36,11 +36,17 @@ public class XmlMapper extends com.fasterxml.jackson.dataformat.xml.XmlMapper{
* 构造方法
*/
public XmlMapper() {
PropertiesUtils props = PropertiesUtils.getInstance();
// 设置默认语言环境
props.getPropertyIfNotBlank("lang.defaultLocale", (defaultLocale) -> {
this.setLocale(LocaleUtils.toLocale(defaultLocale));
});
// 设置默认时区
props.getPropertyIfNotBlank("lang.defaultTimeZone", (defaultTimeZone) -> {
this.setTimeZone(TimeZone.getTimeZone(defaultTimeZone));
});
// Spring ObjectMapper 初始化配置,支持 @JsonView
new Jackson2ObjectMapperBuilder().configure(this);
// 设置默认时区
this.setTimeZone(TimeZone.getTimeZone(PropertiesUtils.getInstance()
.getProperty("lang.defaultTimeZone", "GMT+08:00")));
}
/**
@@ -50,7 +56,7 @@ public class XmlMapper extends com.fasterxml.jackson.dataformat.xml.XmlMapper{
try {
return this.writeValueAsString(object);
} catch (IOException e) {
logger.warn("write to xml string error:" + object, e);
logger.warn("write to xml string error: {}", object, e);
return null;
}
}
@@ -62,14 +68,14 @@ public class XmlMapper extends com.fasterxml.jackson.dataformat.xml.XmlMapper{
try {
return this.writerWithView(jsonView).writeValueAsString(object);
} catch (IOException e) {
logger.warn("write to xml string error:" + object, e);
logger.warn("write to xml string error: {}", object, e);
return null;
}
}
/**
* 反序列化POJO或简单Collection如List<String>.
* @see #fromJson(String, JavaType)
* @see #fromXml(String, Class)
*/
public <T> T fromXmlString(String xmlString, Class<T> clazz) {
if (StringUtils.isEmpty(xmlString) || "<CLOB>".equals(xmlString)) {
@@ -78,7 +84,7 @@ public class XmlMapper extends com.fasterxml.jackson.dataformat.xml.XmlMapper{
try {
return this.readValue(xmlString, clazz);
} catch (IOException e) {
logger.warn("parse xml string error:" + xmlString, e);
logger.warn("parse xml string error: {}", xmlString, e);
return null;
}
}

View File

@@ -21,7 +21,7 @@ import java.util.List;
*/
public class VideoUtils {
private static final Logger log = LoggerFactory.getLogger(VideoUtils.class);
private static final Logger logger = LoggerFactory.getLogger(VideoUtils.class);
private static String ffmpegFile; // ffmpeg.exe所放的路径
private static String mencoderFile; // mencoder.exe所放的路径
private static String qtFaststartFile; // qt-faststart.exe所放的路径
@@ -111,10 +111,10 @@ public class VideoUtils {
}
} catch (Exception e) {
statusTemp = false;
log.error("视频剪切图片失败", e);
logger.error("视频剪切图片失败", e);
}
}
log.debug("视频剪切图片" + (statusTemp ? "成功" : "失败") + ",用时:" + TimeUtils.formatTime(System.currentTimeMillis() - startTime));
logger.debug("视频剪切图片" + (statusTemp ? "成功" : "失败") + ",用时:" + TimeUtils.formatTime(System.currentTimeMillis() - startTime));
return statusTemp;
}
@@ -128,31 +128,30 @@ public class VideoUtils {
int type = checkContentType();
String tempFile = outputFile + ".tmp";
if (statusTemp && type == 0) {
log.debug("使用ffmpage进行视频转换");
logger.debug("使用ffmpage进行视频转换");
statusTemp = processFfmpeg(inputFile, tempFile);
} else if (statusTemp && type == 1) {
log.debug("使用mencoder进行视频转换");
logger.debug("使用mencoder进行视频转换");
statusTemp = processMencoder(inputFile, tempFile);
}
if (statusTemp){
log.debug("将mp4视频的元数据信息转到视频第一帧");
logger.debug("将mp4视频的元数据信息转到视频第一帧");
statusTemp = processQtFaststart(tempFile, outputFile);
}
log.debug("删除临时文件");
logger.debug("删除临时文件");
FileUtils.deleteFile(tempFile);
log.debug("视频转换" + (statusTemp ? "成功" : "失败") + ",用时:" + TimeUtils.formatTime(System.currentTimeMillis() - startTime));
logger.debug("视频转换{},用时:{}", statusTemp ? "成功" : "失败", TimeUtils.formatTime(System.currentTimeMillis() - startTime));
return statusTemp;
}
/**
* 检查文件是否存在
* @param inputFile
* @return boolean
*/
public boolean checkfile(String inputFile) {
File file = new File(inputFile);
if (!file.isFile() || !file.exists()) {
log.warn("文件不存在!");
logger.warn("文件不存在!");
return false;
}
return true;
@@ -160,8 +159,7 @@ public class VideoUtils {
/**
* ffmpeg 截取缩略图
* @param inputFile
* @return boolean
* @return boolean
*/
public boolean processFfmpegCutpic(String inputFile, String outputFile) {
List<String> command = new java.util.ArrayList<String>();
@@ -274,23 +272,22 @@ public class VideoUtils {
/**
* 执行命令
* @param command
* @return boolean
* @return boolean
*/
private boolean process(List<String> command) {
try {
log.debug(StringUtils.join(command, StringUtils.SPACE));
logger.debug(StringUtils.join(command, StringUtils.SPACE));
// Process process = new ProcessBuilder(command).redirectErrorStream(true).start();
Process process = Runtime.getRuntime().exec(command.toArray(new String[command.size()]));
Process process = Runtime.getRuntime().exec(command.toArray(new String[0]));
new PrintErrorReader(process.getErrorStream()).start();
new PrintInputStream(process.getInputStream()).start();
process.waitFor();
return true;
} catch (Exception e) {
if (StringUtils.contains(e.getMessage(), "CreateProcess error=2")){
log.error("缺少视频转换工具请配置video.ffmpegFile相关参数。" + e.getMessage());
logger.error("缺少视频转换工具请配置video.ffmpegFile相关参数。{}", e.getMessage());
}else{
log.error(e.getMessage(), e);
logger.error(e.getMessage(), e);
}
return false;
}
@@ -406,10 +403,10 @@ public class VideoUtils {
BufferedReader br = new BufferedReader(new InputStreamReader(__is));
String line = null;
while ((line = br.readLine()) != null) {
log.debug(line);
logger.debug(line);
}
} catch (Exception e) {
e.printStackTrace();
logger.error(e.getMessage(), e);
}
}
}
@@ -427,10 +424,10 @@ public class VideoUtils {
BufferedReader br = new BufferedReader(new InputStreamReader(__is));
String line = null;
while ((line = br.readLine()) != null) {
log.error(line);
logger.error(line);
}
} catch (Exception e) {
e.printStackTrace();
logger.error(e.getMessage(), e);
}
}
}

View File

@@ -13,6 +13,7 @@ import com.jeesite.common.io.PropertiesUtils;
/**
* 发送电子邮件
* @author ThinkGem
*/
public class EmailUtils {
@@ -20,7 +21,6 @@ public class EmailUtils {
/**
* 发送邮件
* @return
*/
public static boolean send(String toAddress, String subject, String content) {
PropertiesUtils props = PropertiesUtils.getInstance();
@@ -51,7 +51,6 @@ public class EmailUtils {
* @param toAddress 接收地址
* @param subject 标题
* @param content 内容
* @return
*/
public static boolean send(String fromAddress, String fromPassword, String fromHostName, Integer smtpPort,
String sslOnConnect, String sslSmtpPort, String toAddress, String subject, String content) {

View File

@@ -1,3 +1,7 @@
/**
* Copyright (c) 2013-Now http://jeesite.com All rights reserved.
* No deletion without permission, or be held responsible to law.
*/
package com.jeesite.common.msg;
import org.slf4j.Logger;
@@ -5,6 +9,7 @@ import org.slf4j.LoggerFactory;
/**
* 发送短信请实现send方法
* @author ThinkGem
*/
public class SmsUtils {

View File

@@ -1,3 +1,7 @@
/**
* Copyright (c) 2013-Now http://jeesite.com All rights reserved.
* No deletion without permission, or be held responsible to law.
*/
package com.jeesite.common.network;
import com.jeesite.common.codec.EncodeUtils;
@@ -6,12 +10,15 @@ import com.jeesite.common.lang.StringUtils;
import javax.servlet.http.HttpServletRequest;
/**
* IP 地址工具
* @author ThinkGem
*/
public class IpUtils {
/**
* 获取客户端IP地址
* @param request
* @return
* @param request 请求对象
*/
public static String getRemoteAddr(HttpServletRequest request) {
if (request == null) {
@@ -38,8 +45,7 @@ public class IpUtils {
/**
* 是否是本地地址
* @param ip
* @return
* @param ip 地址
*/
public static boolean isLocalAddr(String ip){
return StringUtils.inString(ip, "127.0.0.1", "0:0:0:0:0:0:0:1");
@@ -47,14 +53,12 @@ public class IpUtils {
/**
* 判断IP地址为内网IP还是公网IP
*
* <br>
* tcp/ip协议中专门保留了三个IP地址区域作为私有地址其地址范围如下
* 10.0.0.0/810.0.0.010.255.255.255
* 172.16.0.0/12172.16.0.0172.31.255.255
* 192.168.0.0/16192.168.0.0192.168.255.255
*
* @param ip
* @return
* @param ip 地址
*/
public static boolean isInternalAddr(String ip) {

View File

@@ -4,18 +4,22 @@
*/
package com.jeesite.common.network;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
/**
* MAC地址工具
*
* @author ThinkGem
* @version 2014-6-18
*/
public class MacUtils {
private static final Logger logger = LoggerFactory.getLogger(MacUtils.class);
/**
* 获取当前操作系统名称. return 操作系统名称 例如:windows,Linux,Unix等.
*/
@@ -25,7 +29,6 @@ public class MacUtils {
/**
* 获取Unix网卡的mac地址.
*
* @return mac地址
*/
public static String getUnixMACAddress() {
@@ -33,39 +36,31 @@ public class MacUtils {
BufferedReader bufferedReader = null;
Process process = null;
try {
/**
* Unix下的命令一般取eth0作为本地主网卡 显示信息中包含有mac地址信息
*/
// Unix下的命令一般取eth0作为本地主网卡 显示信息中包含有mac地址信息
process = Runtime.getRuntime().exec("ifconfig eth0");
bufferedReader = new BufferedReader(new InputStreamReader(
process.getInputStream()));
String line = null;
int index = -1;
while ((line = bufferedReader.readLine()) != null) {
/**
* 寻找标示字符串[hwaddr]
*/
// 寻找标示字符串[hwaddr]
index = line.toLowerCase().indexOf("hwaddr");
/**
* 找到了
*/
// 找到了
if (index != -1) {
/**
* 取出mac地址并去除2边空格
*/
// 取出mac地址并去除2边空格
mac = line.substring(index + "hwaddr".length() + 1).trim();
break;
}
}
} catch (IOException e) {
e.printStackTrace();
logger.error(e.getMessage());
} finally {
try {
if (bufferedReader != null) {
bufferedReader.close();
}
} catch (IOException e1) {
e1.printStackTrace();
// ignore
}
bufferedReader = null;
process = null;
@@ -84,9 +79,7 @@ public class MacUtils {
BufferedReader bufferedReader = null;
Process process = null;
try {
/**
* linux下的命令一般取eth0作为本地主网卡 显示信息中包含有mac地址信息
*/
// linux下的命令一般取eth0作为本地主网卡 显示信息中包含有mac地址信息
process = Runtime.getRuntime().exec("ifconfig eth0");
bufferedReader = new BufferedReader(new InputStreamReader(
process.getInputStream()));
@@ -94,26 +87,22 @@ public class MacUtils {
int index = -1;
while ((line = bufferedReader.readLine()) != null) {
index = line.toLowerCase().indexOf("硬件地址");
/**
* 找到了
*/
// 找到了
if (index != -1) {
/**
* 取出mac地址并去除2边空格
*/
// 取出mac地址并去除2边空格
mac = line.substring(index + 4).trim();
break;
}
}
} catch (IOException e) {
e.printStackTrace();
logger.error(e.getMessage());
} finally {
try {
if (bufferedReader != null) {
bufferedReader.close();
}
} catch (IOException e1) {
e1.printStackTrace();
// ignore
}
bufferedReader = null;
process = null;
@@ -129,7 +118,6 @@ public class MacUtils {
/**
* 获取widnows网卡的mac地址.
*
* @return mac地址
*/
public static String getWindowsMACAddress() {
@@ -137,37 +125,31 @@ public class MacUtils {
BufferedReader bufferedReader = null;
Process process = null;
try {
/**
* windows下的命令显示信息中包含有mac地址信息
*/
// windows下的命令显示信息中包含有mac地址信息
process = Runtime.getRuntime().exec("ipconfig /all");
bufferedReader = new BufferedReader(new InputStreamReader(process.getInputStream()));
String line = null;
int index = -1;
while ((line = bufferedReader.readLine()) != null) {
/**
* 寻找标示字符串[physical address 或 物理地址]
*/
// 寻找标示字符串[physical address 或 物理地址]
if (line.split("-").length == 6){
index = line.indexOf(":");
if (index != -1) {
/**
* 取出mac地址并去除2边空格
*/
// 取出mac地址并去除2边空格
mac = line.substring(index + 1).trim();
}
break;
}
}
} catch (IOException e) {
e.printStackTrace();
logger.error(e.getMessage());
} finally {
try {
if (bufferedReader != null) {
bufferedReader.close();
}
} catch (IOException e1) {
e1.printStackTrace();
// ignore
}
bufferedReader = null;
process = null;

View File

@@ -21,7 +21,7 @@ import java.util.Map;
/**
* 反射工具类. 提供调用getter/setter方法, 访问私有变量, 调用私有方法, 获取泛型类型Class, 被AOP过的真实类等工具函数.
* @author calvin、ThinkGem
* @version 2023-2-6
* @version 2025-08-08
*/
@SuppressWarnings("rawtypes")
public class ReflectUtils {
@@ -112,7 +112,7 @@ public class ReflectUtils {
if (field == null) {
//throw new IllegalArgumentException("在 [" + obj.getClass() + "] 中,没有找到 [" + fieldName + "] 字段 ");
if (obj != null) {
logger.debug("在 [" + obj.getClass() + "] 中,没有找到 [" + fieldName + "] 字段 ");
logger.debug("在 [{}] 中,没有找到 [{}] 字段 ", obj.getClass(), fieldName);
}
return null;
}
@@ -132,7 +132,7 @@ public class ReflectUtils {
Field field = getAccessibleField(obj, fieldName);
if (field == null) {
//throw new IllegalArgumentException("在 [" + obj.getClass() + "] 中,没有找到 [" + fieldName + "] 字段 ");
logger.debug("在 [" + obj.getClass() + "] 中,没有找到 [" + fieldName + "] 字段 ");
logger.debug("在 [{}] 中,没有找到 [{}] 字段 ", obj.getClass(), fieldName);
return;
}
try {
@@ -157,9 +157,7 @@ public class ReflectUtils {
Method method = getAccessibleMethod(obj, methodName, parameterTypes);
if (method == null) {
//throw new IllegalArgumentException("在 [" + obj.getClass() + "] 中,没有找到 [" + methodName + "] 方法 ");
if (obj != null) {
logger.debug("在 [" + (obj.getClass() == Class.class ? obj : obj.getClass()) + "] 中,没有找到 [" + methodName + "] 方法 ");
}
logger.debug("在 [{}] 中,没有找到 [{}] 方法 ", obj.getClass() == Class.class ? obj : obj.getClass(), methodName);
return null;
}
try {
@@ -182,7 +180,7 @@ public class ReflectUtils {
if (method == null) {
// 如果为空不报错,直接返回空。 throw new IllegalArgumentException("在 [" + obj.getClass() + "] 中,没有找到 [" + methodName + "] 方法 ");
if (obj != null) {
logger.debug("在 [" + (obj.getClass() == Class.class ? obj : obj.getClass()) + "] 中,没有找到 [" + methodName + "] 方法 ");
logger.debug("在 [{}] 中,没有找到 [{}] 方法 ", obj.getClass() == Class.class ? obj : obj.getClass(), methodName);
}
return null;
}
@@ -252,7 +250,7 @@ public class ReflectUtils {
args[i] = DateUtil.getJavaDate((Double) args[i]);
}
}else{
System.out.println(cs[i] + " " + args[i]);
logger.debug("class: {}, args: {}", cs[i], args[i]);
}
}
}
@@ -405,17 +403,16 @@ public class ReflectUtils {
public static Class getClassGenricType(final Class clazz, final int index) {
Type genType = clazz.getGenericSuperclass();
if (!(genType instanceof ParameterizedType)) {
logger.debug(clazz.getSimpleName() + "'s superclass not ParameterizedType");
logger.debug("{}'s superclass not ParameterizedType", clazz.getSimpleName());
return Object.class;
}
Type[] params = ((ParameterizedType) genType).getActualTypeArguments();
if (index >= params.length || index < 0) {
logger.debug("Index: " + index + ", Size of " + clazz.getSimpleName() + "'s Parameterized Type: "
+ params.length);
logger.debug("Index: {}, Size of {}'s Parameterized Type: {}", index, clazz.getSimpleName(), params.length);
return Object.class;
}
if (!(params[index] instanceof Class)) {
logger.debug(clazz.getSimpleName() + " not set the actual class on superclass generic parameter");
logger.debug("{} not set the actual class on superclass generic parameter", clazz.getSimpleName());
return Object.class;
}
return (Class) params[index];
@@ -429,7 +426,7 @@ public class ReflectUtils {
throw new RuntimeException("Instance must not be null");
}
Class clazz = instance.getClass();
if (clazz != null && clazz.getName().contains(CGLIB_CLASS_SEPARATOR)) {
if (clazz.getName().contains(CGLIB_CLASS_SEPARATOR)) {
Class<?> superClass = clazz.getSuperclass();
if (superClass != null && !Object.class.equals(superClass)) {
return superClass;

View File

@@ -1,3 +1,7 @@
/**
* Copyright (c) 2013-Now http://jeesite.com All rights reserved.
* No deletion without permission, or be held responsible to law.
*/
package com.jeesite.common.text;
import net.sourceforge.pinyin4j.PinyinHelper;
@@ -6,6 +10,8 @@ import net.sourceforge.pinyin4j.format.HanyuPinyinOutputFormat;
import net.sourceforge.pinyin4j.format.HanyuPinyinToneType;
import net.sourceforge.pinyin4j.format.HanyuPinyinVCharType;
import net.sourceforge.pinyin4j.format.exception.BadHanyuPinyinOutputFormatCombination;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.regex.Pattern;
@@ -14,10 +20,12 @@ import java.util.regex.Pattern;
* @author ThinkGem
*/
public class PinyinUtils {
private static final Logger logger = LoggerFactory.getLogger(PinyinUtils.class);
private static class Static{
private static Pattern idPatt = Pattern.compile("\\W");
private static HanyuPinyinOutputFormat defaultFormat;
private static final Pattern idPat = Pattern.compile("\\W");
private static final HanyuPinyinOutputFormat defaultFormat;
static{
defaultFormat = new HanyuPinyinOutputFormat();
defaultFormat.setCaseType(HanyuPinyinCaseType.LOWERCASE);
@@ -46,28 +54,28 @@ public class PinyinUtils {
if (chinese == null){
return null;
}
StringBuffer pybf = new StringBuffer();
StringBuilder sb = new StringBuilder();
char[] arr = chinese.toCharArray();
for (int i = 0; i < arr.length; i++) {
if (arr[i] > 128) {
for (char c : arr) {
if (c > 128) {
try {
String[] temp = PinyinHelper.toHanyuPinyinStringArray(arr[i], Static.defaultFormat);
String[] temp = PinyinHelper.toHanyuPinyinStringArray(c, Static.defaultFormat);
if (temp != null && temp.length > 0) {
pybf.append(temp[0].charAt(0));
}else{
pybf.append(String.valueOf(arr[i]));
sb.append(temp[0].charAt(0));
} else {
sb.append(String.valueOf(c));
}
} catch (BadHanyuPinyinOutputFormatCombination e) {
e.printStackTrace();
logger.error(e.getMessage(), e);
}
} else {
pybf.append(arr[i]);
sb.append(c);
}
}
if (isId){
return Static.idPatt.matcher(pybf.toString()).replaceAll("").trim();
return Static.idPat.matcher(sb.toString()).replaceAll("").trim();
}
return pybf.toString();
return sb.toString();
}
/**
@@ -90,28 +98,28 @@ public class PinyinUtils {
if (chinese == null){
return null;
}
StringBuffer pybf = new StringBuffer();
StringBuilder sb = new StringBuilder();
char[] arr = chinese.toCharArray();
for (int i = 0; i < arr.length; i++) {
if (arr[i] > 128) {
for (char c : arr) {
if (c > 128) {
try {
String[] ss = PinyinHelper.toHanyuPinyinStringArray(arr[i], Static.defaultFormat);
if (ss != null && ss.length > 0){
pybf.append(ss[0]);
}else{
pybf.append(String.valueOf(arr[i]));
String[] ss = PinyinHelper.toHanyuPinyinStringArray(c, Static.defaultFormat);
if (ss != null && ss.length > 0) {
sb.append(ss[0]);
} else {
sb.append(String.valueOf(c));
}
} catch (BadHanyuPinyinOutputFormatCombination e) {
e.printStackTrace();
logger.error(e.getMessage(), e);
}
} else {
pybf.append(arr[i]);
sb.append(c);
}
}
if (isId){
return Static.idPatt.matcher(pybf.toString()).replaceAll("").trim();
return Static.idPat.matcher(sb.toString()).replaceAll("").trim();
}
return pybf.toString();
return sb.toString();
}
/**
@@ -143,7 +151,7 @@ public class PinyinUtils {
if (input == null){
return null;
}
char c[] = input.toCharArray();
char[] c = input.toCharArray();
for (int i = 0; i < c.length; i++) {
if (c[i] == '\u3000') {
c[i] = ' ';

View File

@@ -27,11 +27,11 @@ public class IdcardUtils {
"62", "63", "64", "65", "71", "81", "82", "91" };
/** 每位加权因子 */
public static final int power[] = { 7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9,
public static final int[] power = { 7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9,
10, 5, 8, 4, 2 };
/** 第18位校检码 */
public static final String verifyCode[] = { "1", "0", "X", "9", "8", "7",
public static final String[] verifyCode = { "1", "0", "X", "9", "8", "7",
"6", "5", "4", "3", "2" };
/** 最低年限 */
public static final int MIN = 1930;
@@ -116,9 +116,7 @@ public class IdcardUtils {
/**
* 将15位身份证号码转换为18位
*
* @param idCard
* 15位身份编码
* @param idCard 15位身份编码
* @return 18位身份编码
*/
public static String conver15CardTo18(String idCard) {

View File

@@ -21,8 +21,7 @@ public class ThreadUtils {
try {
Thread.sleep(millis);
} catch (InterruptedException e) {
// Ignore.
return;
Thread.currentThread().interrupt();
}
}
@@ -33,8 +32,7 @@ public class ThreadUtils {
try {
Thread.sleep(unit.toMillis(duration));
} catch (InterruptedException e) {
// Ignore.
return;
Thread.currentThread().interrupt();
}
}

View File

@@ -509,7 +509,7 @@ public class ExcelExport implements Closeable{
cell.setCellStyle(style);
// }
} catch (Exception ex) {
log.info("Set cell value ["+row.getRowNum()+","+column+"] error: " + ex.toString());
log.info("Set cell value [{},{}] error: {}", row.getRowNum(), column, ex.toString());
cell.setCellValue(ObjectUtils.toString(val));
}
return cell;
@@ -581,7 +581,7 @@ public class ExcelExport implements Closeable{
this.addCell(row, colunm++, val, ef.align(), ef.fieldType(), ef.dataFormat());
sb.append(val + ", ");
}
log.debug("Write success: ["+row.getRowNum()+"] "+sb.toString());
log.debug("Write success: [{}] {}", row.getRowNum(), sb.toString());
}
return this;
}
@@ -633,7 +633,7 @@ public class ExcelExport implements Closeable{
// try {
// this.close();
// } catch (Exception e) {
// e.printStackTrace();
// log.error(e.getMessage(), e);
// }
// return this;
// }
@@ -647,7 +647,7 @@ public class ExcelExport implements Closeable{
try {
wb.close();
} catch (IOException e) {
e.printStackTrace();
log.error(e.getMessage(), e);
}
}

View File

@@ -235,7 +235,6 @@ public class ExcelImport implements Closeable {
/**
* 获取行对象
* @param rownum
* @return 返回Row对象如果空行返回null
*/
public Row getRow(int rownum){
@@ -262,7 +261,6 @@ public class ExcelImport implements Closeable {
/**
* 获取数据行号
* @return
*/
public int getDataRowNum(){
return headerNum;
@@ -270,7 +268,6 @@ public class ExcelImport implements Closeable {
/**
* 获取最后一个数据行号
* @return
*/
public int getLastDataRowNum(){
//return this.sheet.getLastRowNum() + headerNum;
@@ -279,7 +276,6 @@ public class ExcelImport implements Closeable {
/**
* 获取最后一个列号
* @return
*/
public int getLastCellNum(){
Row row = this.getRow(headerNum);
@@ -305,7 +301,7 @@ public class ExcelImport implements Closeable {
if (DateUtil.isCellDateFormatted(cell)) {
val = DateUtil.getJavaDate((Double) val); // POI Excel 日期格式转换
}else{
if ((Double) val % 1 > 0){
if (Math.abs((double)val % 1) > 1E-10){
val = new DecimalFormat("0.00").format(val);
}else{
val = new DecimalFormat("0").format(val);
@@ -465,7 +461,7 @@ public class ExcelImport implements Closeable {
//val = DictUtils.getDictValue(val.toString(), ef.dictType(), "");
//log.debug("Dictionary type value: ["+i+","+colunm+"] " + val);
} catch (Exception ex) {
log.info("Get cell value ["+i+","+column+"] error: " + ex.toString());
log.info("Get cell value [{},{}] error: {}", i, column, ex.toString());
val = null;
}
}
@@ -542,22 +538,20 @@ public class ExcelImport implements Closeable {
ReflectUtils.invokeSetter(e, ef.attrName(), val);
}else{
if (os[1] instanceof Field){
//ReflectUtils.invokeSetter(e, ((Field)os[1]).getName(), val);
((Field)os[1]).set(e, val);
ReflectUtils.invokeSetter(e, ((Field)os[1]).getName(), val);
}else if (os[1] instanceof Method){
//String mthodName = ((Method)os[1]).getName();
//if ("get".equals(mthodName.substring(0, 3))){
// mthodName = "set"+StringUtils.substringAfter(mthodName, "get");
//}
//ReflectUtils.invokeMethod(e, mthodName, new Class[] {valType}, new Object[] {val});
((Method)os[1]).invoke(e, val);
String mthodName = ((Method)os[1]).getName();
if ("get".equals(mthodName.substring(0, 3))){
mthodName = "set"+mthodName.substring(3);
}
ReflectUtils.invokeMethodByAsm(e, mthodName, val);
}
}
}
sb.append(val+", ");
}
dataList.add(e);
log.debug("Read success: ["+i+"] "+sb.toString());
log.debug("Read success: [{}] {}", i, sb.toString());
}
return dataList;
}
@@ -577,7 +571,7 @@ public class ExcelImport implements Closeable {
try {
wb.close();
} catch (IOException e) {
e.printStackTrace();
log.error(e.getMessage(), e);
}
}

View File

@@ -8,7 +8,6 @@ import org.apache.commons.lang3.StringUtils;
import java.math.BigDecimal;
/**
* BigDecimal类型转换
* @author ThinkGem

View File

@@ -9,7 +9,6 @@ import java.text.NumberFormat;
import org.apache.commons.lang3.StringUtils;
/**
* 金额类型转换(保留两位)
* @author ThinkGem

View File

@@ -59,8 +59,6 @@ public class BookMark {
/**
* 构造函数
* @param ctBookmark
* @param para
*/
public BookMark(CTBookmark ctBookmark, XWPFParagraph para) {
this._ctBookmark = ctBookmark;
@@ -72,9 +70,6 @@ public class BookMark {
/**
* 构造函数,用于表格中的标签
* @param ctBookmark
* @param para
* @param tableCell
*/
public BookMark(CTBookmark ctBookmark, XWPFParagraph para, XWPFTableCell tableCell) {
this(ctBookmark, para);

View File

@@ -1,10 +1,17 @@
package com.jeesite.common.utils.word;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import com.jeesite.common.io.ResourceUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import org.apache.poi.openxml4j.opc.OPCPackage;
import org.apache.poi.xwpf.usermodel.*;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTHeight;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTrPr;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.w3c.dom.Node;
import java.io.*;
import java.math.BigInteger;
import java.util.HashMap;
import java.util.Iterator;
@@ -12,22 +19,6 @@ import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import org.apache.poi.openxml4j.opc.OPCPackage;
import org.apache.poi.xwpf.usermodel.ParagraphAlignment;
import org.apache.poi.xwpf.usermodel.XWPFDocument;
import org.apache.poi.xwpf.usermodel.XWPFParagraph;
import org.apache.poi.xwpf.usermodel.XWPFRun;
import org.apache.poi.xwpf.usermodel.XWPFTable;
import org.apache.poi.xwpf.usermodel.XWPFTableCell;
import org.apache.poi.xwpf.usermodel.XWPFTableRow;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTHeight;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTrPr;
import org.w3c.dom.Node;
import com.jeesite.common.io.ResourceUtils;
/**
* 使用POI,进行Word相关的操作
* @author xuyu
@@ -38,6 +29,8 @@ import com.jeesite.common.io.ResourceUtils;
*/
public class WordExport {
private static final Logger log = LoggerFactory.getLogger(WordExport.class);
/** 内部使用的文档对象 **/
private XWPFDocument document;
@@ -57,7 +50,7 @@ public class WordExport {
}
bookMarks = new BookMarks(document);
} catch (IOException | InvalidFormatException e) {
e.printStackTrace();
log.error(e.getMessage(), e);
}
}
@@ -224,10 +217,8 @@ public class WordExport {
try {
fos = new FileOutputStream(newFile);
this.document.write(fos);
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
log.error(e.getMessage(), e);
} finally {
try {
if (fos != null){
@@ -237,7 +228,7 @@ public class WordExport {
fos.close();
}
} catch (IOException e) {
e.printStackTrace();
log.error(e.getMessage(), e);
}
}
}

View File

@@ -15,12 +15,10 @@ import javax.servlet.http.HttpServletResponse;
*/
public class ResultUtils {
private static final boolean isDefaultResult = PropertiesUtils.getInstance()
.getPropertyToBoolean("web.isDefaultResult", "false");
private static final String resultParamName = PropertiesUtils.getInstance()
.getProperty("web.resultParamName", "__data");
private static final String headerParamName = PropertiesUtils.getInstance()
.getProperty("web.headerParamName", "x-data");
private static final PropertiesUtils props = PropertiesUtils.getInstance();
private static final boolean isDefaultResult = props.getPropertyToBoolean("web.isDefaultResult", "false");
private static final String resultParamName = props.getProperty("web.resultParamName", "__data");
private static final String headerParamName = props.getProperty("web.headerParamName", "x-data");
/**
* 设置 web.isResult 参数可强制全局使用统一结果输出,否则,传递 __data=true 参数,或 x-data 请求头为 true 时启用

View File

@@ -13,6 +13,8 @@ import com.jeesite.common.lang.StringUtils;
import com.jeesite.common.mapper.JsonMapper;
import com.jeesite.common.mapper.XmlMapper;
import org.apache.commons.lang3.Validate;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.MediaType;
import org.springframework.util.AntPathMatcher;
import org.springframework.web.context.request.RequestContextHolder;
@@ -32,6 +34,8 @@ import java.util.Map.Entry;
*/
public class ServletUtils {
private static final Logger logger = LoggerFactory.getLogger(ServletUtils.class);
public static final String EXT_PARAMS_PREFIX = "param_"; // 扩展参数前缀
// 定义静态文件后缀静态文件排除URI地址
@@ -107,7 +111,7 @@ public class ServletUtils {
}
}
} catch (Exception e) {
e.printStackTrace();
logger.error(e.getMessage(), e);
}
}
@@ -121,7 +125,7 @@ public class ServletUtils {
throw new Exception("检测到“application.yml”中没有配置“web.staticFile”属性。配置示例\n#静态文件后缀\nweb.staticFile=" +
".css,.js,.map,.png,.jpg,.gif,.jpeg,.webp,.bmp,.ico,.swf,.psd,.htc,.crx,.xpi,.exe,.ipa,.apk,.otf,.eot,.svg,.ttf,.woff,.woff2");
} catch (Exception e) {
e.printStackTrace();
logger.error(e.getMessage(), e);
}
}
if (StringUtils.containsAny(uri, STATIC_FILE_EXCLUDE_URI)) {
@@ -363,7 +367,7 @@ public class ServletUtils {
}
response.getWriter().print(string);
} catch (IOException e) {
e.printStackTrace();
logger.error(e.getMessage(), e);
}
return null;
}

View File

@@ -19,8 +19,6 @@ public class UserAgentUtils {
/**
* 获取用户代理对象
* @param request
* @return
*/
public static UserAgent getUserAgent(HttpServletRequest request){
return UserAgent.parseUserAgentString(request.getHeader("User-Agent"));
@@ -28,8 +26,6 @@ public class UserAgentUtils {
/**
* 获取设备类型
* @param request
* @return
*/
public static DeviceType getDeviceType(HttpServletRequest request){
return getUserAgent(request).getOperatingSystem().getDeviceType();
@@ -37,8 +33,6 @@ public class UserAgentUtils {
/**
* 是否是PC
* @param request
* @return
*/
public static boolean isComputer(HttpServletRequest request){
return DeviceType.COMPUTER.equals(getDeviceType(request));
@@ -46,8 +40,6 @@ public class UserAgentUtils {
/**
* 是否是手机
* @param request
* @return
*/
public static boolean isMobile(HttpServletRequest request){
return DeviceType.MOBILE.equals(getDeviceType(request));
@@ -55,8 +47,6 @@ public class UserAgentUtils {
/**
* 是否是平板
* @param request
* @return
*/
public static boolean isTablet(HttpServletRequest request){
return DeviceType.TABLET.equals(getDeviceType(request));
@@ -64,8 +54,6 @@ public class UserAgentUtils {
/**
* 是否是手机和平板
* @param request
* @return
*/
public static boolean isMobileOrTablet(HttpServletRequest request){
DeviceType deviceType = getDeviceType(request);
@@ -74,8 +62,6 @@ public class UserAgentUtils {
/**
* 获取浏览类型
* @param request
* @return
*/
public static Browser getBrowser(HttpServletRequest request){
return getUserAgent(request).getBrowser();
@@ -83,8 +69,6 @@ public class UserAgentUtils {
/**
* 是否IE版本是否小于等于IE8
* @param request
* @return
*/
public static boolean isLteIE8(HttpServletRequest request){
Browser browser = getBrowser(request);

View File

@@ -1,7 +0,0 @@
/*! Respond.js v1.4.2: min/max-width media query polyfill Copyright 2014 Scott Jehl Licensed under MIT http://j.mp/respondjs */
//https://oss.maxcdn.com/respond/1.4.2/respond.min.js
!function(a){"use strict";a.matchMedia=a.matchMedia||function(a){var b,c=a.documentElement,d=c.firstElementChild||c.firstChild,e=a.createElement("body"),f=a.createElement("div");return f.id="mq-test-1",f.style.cssText="position:absolute;top:-100em",e.style.background="none",e.appendChild(f),function(a){return f.innerHTML='&shy;<style media="'+a+'"> #mq-test-1 { width: 42px; }</style>',c.insertBefore(e,d),b=42===f.offsetWidth,c.removeChild(e),{matches:b,media:a}}}(a.document)}(this),function(a){"use strict";function b(){v(!0)}var c={};a.respond=c,c.update=function(){};var d=[],e=function(){var b=!1;try{b=new a.XMLHttpRequest}catch(c){b=new a.ActiveXObject("Microsoft.XMLHTTP")}return function(){return b}}(),f=function(a,b){var c=e();c&&(c.open("GET",a,!0),c.onreadystatechange=function(){4!==c.readyState||200!==c.status&&304!==c.status||b(c.responseText)},4!==c.readyState&&c.send(null))},g=function(a){return a.replace(c.regex.minmaxwh,"").match(c.regex.other)};if(c.ajax=f,c.queue=d,c.unsupportedmq=g,c.regex={media:/@media[^\{]+\{([^\{\}]*\{[^\}\{]*\})+/gi,keyframes:/@(?:\-(?:o|moz|webkit)\-)?keyframes[^\{]+\{(?:[^\{\}]*\{[^\}\{]*\})+[^\}]*\}/gi,comments:/\/\*[^*]*\*+([^/][^*]*\*+)*\//gi,urls:/(url\()['"]?([^\/\)'"][^:\)'"]+)['"]?(\))/g,findStyles:/@media *([^\{]+)\{([\S\s]+?)$/,only:/(only\s+)?([a-zA-Z]+)\s?/,minw:/\(\s*min\-width\s*:\s*(\s*[0-9\.]+)(px|em)\s*\)/,maxw:/\(\s*max\-width\s*:\s*(\s*[0-9\.]+)(px|em)\s*\)/,minmaxwh:/\(\s*m(in|ax)\-(height|width)\s*:\s*(\s*[0-9\.]+)(px|em)\s*\)/gi,other:/\([^\)]*\)/g},c.mediaQueriesSupported=a.matchMedia&&null!==a.matchMedia("only all")&&a.matchMedia("only all").matches,!c.mediaQueriesSupported){var h,i,j,k=a.document,l=k.documentElement,m=[],n=[],o=[],p={},q=30,r=k.getElementsByTagName("head")[0]||l,s=k.getElementsByTagName("base")[0],t=r.getElementsByTagName("link"),u=function(){var a,b=k.createElement("div"),c=k.body,d=l.style.fontSize,e=c&&c.style.fontSize,f=!1;return b.style.cssText="position:absolute;font-size:1em;width:1em",c||(c=f=k.createElement("body"),c.style.background="none"),l.style.fontSize="100%",c.style.fontSize="100%",c.appendChild(b),f&&l.insertBefore(c,l.firstChild),a=b.offsetWidth,f?l.removeChild(c):c.removeChild(b),l.style.fontSize=d,e&&(c.style.fontSize=e),a=j=parseFloat(a)},v=function(b){var c="clientWidth",d=l[c],e="CSS1Compat"===k.compatMode&&d||k.body[c]||d,f={},g=t[t.length-1],p=(new Date).getTime();if(b&&h&&q>p-h)return a.clearTimeout(i),i=a.setTimeout(v,q),void 0;h=p;for(var s in m)if(m.hasOwnProperty(s)){var w=m[s],x=w.minw,y=w.maxw,z=null===x,A=null===y,B="em";x&&(x=parseFloat(x)*(x.indexOf(B)>-1?j||u():1)),y&&(y=parseFloat(y)*(y.indexOf(B)>-1?j||u():1)),w.hasquery&&(z&&A||!(z||e>=x)||!(A||y>=e))||(f[w.media]||(f[w.media]=[]),f[w.media].push(n[w.rules]))}for(var C in o)o.hasOwnProperty(C)&&o[C]&&o[C].parentNode===r&&r.removeChild(o[C]);o.length=0;for(var D in f)if(f.hasOwnProperty(D)){var E=k.createElement("style"),F=f[D].join("\n");E.type="text/css",E.media=D,r.insertBefore(E,g.nextSibling),E.styleSheet?E.styleSheet.cssText=F:E.appendChild(k.createTextNode(F)),o.push(E)}},w=function(a,b,d){var e=a.replace(c.regex.comments,"").replace(c.regex.keyframes,"").match(c.regex.media),f=e&&e.length||0;b=b.substring(0,b.lastIndexOf("/"));var h=function(a){return a.replace(c.regex.urls,"$1"+b+"$2$3")},i=!f&&d;b.length&&(b+="/"),i&&(f=1);for(var j=0;f>j;j++){var k,l,o,p;i?(k=d,n.push(h(a))):(k=e[j].match(c.regex.findStyles)&&RegExp.$1,n.push(RegExp.$2&&h(RegExp.$2))),o=k.split(","),p=o.length;for(var q=0;p>q;q++)l=o[q],g(l)||m.push({media:l.split("(")[0].match(c.regex.only)&&RegExp.$2||"all",rules:n.length-1,hasquery:l.indexOf("(")>-1,minw:l.match(c.regex.minw)&&parseFloat(RegExp.$1)+(RegExp.$2||""),maxw:l.match(c.regex.maxw)&&parseFloat(RegExp.$1)+(RegExp.$2||"")})}v()},x=function(){if(d.length){var b=d.shift();f(b.href,function(c){w(c,b.href,b.media),p[b.href]=!0,a.setTimeout(function(){x()},0)})}},y=function(){for(var b=0;b<t.length;b++){var c=t[b],e=c.href,f=c.media,g=c.rel&&"stylesheet"===c.rel.toLowerCase();e&&g&&!p[e]&&(c.styleSheet&&c.styleSheet.rawCssText?(w(c.styleSheet.rawCssText,e,f),p[e]=!0):(!/^([a-zA-Z:]*\/\/)/.test(e)&&!s||e.replace(RegExp.$1,"").split("/")[0]===a.location.host)&&("//"===e.substring(0,2)&&(e=a.location.protocol+e),d.push({href:e,media:f})))}x()};y(),c.update=y,c.getEmValue=u,a.addEventListener?a.addEventListener("resize",b,!1):a.attachEvent&&a.attachEvent("onresize",b)}}(this);
/*! @preserve HTML5 Shiv 3.7.3 | @afarkas @jdalton @jon_neal @rem | MIT/GPL2 Licensed */
//https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js
!function(a,b){function c(a,b){var c=a.createElement("p"),d=a.getElementsByTagName("head")[0]||a.documentElement;return c.innerHTML="x<style>"+b+"</style>",d.insertBefore(c.lastChild,d.firstChild)}function d(){var a=t.elements;return"string"==typeof a?a.split(" "):a}function e(a,b){var c=t.elements;"string"!=typeof c&&(c=c.join(" ")),"string"!=typeof a&&(a=a.join(" ")),t.elements=c+" "+a,j(b)}function f(a){var b=s[a[q]];return b||(b={},r++,a[q]=r,s[r]=b),b}function g(a,c,d){if(c||(c=b),l)return c.createElement(a);d||(d=f(c));var e;return e=d.cache[a]?d.cache[a].cloneNode():p.test(a)?(d.cache[a]=d.createElem(a)).cloneNode():d.createElem(a),!e.canHaveChildren||o.test(a)||e.tagUrn?e:d.frag.appendChild(e)}function h(a,c){if(a||(a=b),l)return a.createDocumentFragment();c=c||f(a);for(var e=c.frag.cloneNode(),g=0,h=d(),i=h.length;i>g;g++)e.createElement(h[g]);return e}function i(a,b){b.cache||(b.cache={},b.createElem=a.createElement,b.createFrag=a.createDocumentFragment,b.frag=b.createFrag()),a.createElement=function(c){return t.shivMethods?g(c,a,b):b.createElem(c)},a.createDocumentFragment=Function("h,f","return function(){var n=f.cloneNode(),c=n.createElement;h.shivMethods&&("+d().join().replace(/[\w\-:]+/g,function(a){return b.createElem(a),b.frag.createElement(a),'c("'+a+'")'})+");return n}")(t,b.frag)}function j(a){a||(a=b);var d=f(a);return!t.shivCSS||k||d.hasCSS||(d.hasCSS=!!c(a,"article,aside,dialog,figcaption,figure,footer,header,hgroup,main,nav,section{display:block}mark{background:#FF0;color:#000}template{display:none}")),l||i(a,d),a}var k,l,m="3.7.3",n=a.html5||{},o=/^<|^(?:button|map|select|textarea|object|iframe|option|optgroup)$/i,p=/^(?:a|b|code|div|fieldset|h1|h2|h3|h4|h5|h6|i|label|li|ol|p|q|span|strong|style|table|tbody|td|th|tr|ul)$/i,q="_html5shiv",r=0,s={};!function(){try{var a=b.createElement("a");a.innerHTML="<xyz></xyz>",k="hidden"in a,l=1==a.childNodes.length||function(){b.createElement("a");var a=b.createDocumentFragment();return"undefined"==typeof a.cloneNode||"undefined"==typeof a.createDocumentFragment||"undefined"==typeof a.createElement}()}catch(c){k=!0,l=!0}}();var t={elements:n.elements||"abbr article aside audio bdi canvas data datalist details dialog figcaption figure footer header hgroup main mark meter nav output picture progress section summary template time video",version:m,shivCSS:n.shivCSS!==!1,supportsUnknownElements:l,shivMethods:n.shivMethods!==!1,type:"default",shivDocument:j,createElement:g,createDocumentFragment:h,addElements:e};a.html5=t,j(b),"object"==typeof module&&module.exports&&(module.exports=t)}("undefined"!=typeof window?window:this,document);

View File

@@ -16,8 +16,8 @@ span{display:block;font-size:12px;line-height:12px;}
.clean{clear:both;}
</style></head><body>
<h1>浏览器版本过低,是时候升级您的浏览器了</h1>
<p>本系统 <a href="http://jeesite.com">JeeSite</a> 支持 IE9 及以上版本及其他所有现代浏览器,如:谷歌浏览器、火狐浏览器、国产浏览器 等。</p>
<p>您正在使用 Internet Explorer 的过期版本IE6、IE7、IE8 内核的浏览器)。这意味着在升级浏览器前,您将无法继续访问。</p>
<p>本系统 <a href="http://jeesite.com">JeeSite</a> 支持 IE10 及以上版本及其他所有现代浏览器,如:谷歌浏览器、火狐浏览器、国产浏览器 等。</p>
<p>您正在使用 Internet Explorer 的过期版本IE6、IE7、IE8、IE9 内核的浏览器)。这意味着在升级浏览器前,您将无法继续访问。</p>
<hr>
<h2>为什么会出现这个页面?</h2>
<p>如果您不知道升级浏览器是什么意思请请教一些熟练电脑操作的朋友。如果您使用的不是Internet Explorer而是360、QQ、搜狗等双核浏览器出现这个页面可能是您切换到了兼容模式<strong style="color:#f00;">切换到极速模式</strong>下,如果还不行请升级至最新版浏览器。</p>
@@ -29,10 +29,10 @@ span{display:block;font-size:12px;line-height:12px;}
<h2>您可以选择更先进的浏览器</h2>
<p>推荐使用以下浏览器的最新版本。如果您的电脑已有以下浏览器的最新版本则直接使用该浏览器访问 <b id="url"></b>即可。</p>
<div class="browser"><ul>
<li><img src="img/chrome360.jpg"><a href="http://chrome.360.cn/"> 360极速浏览器<span>360 Chrome</span></a></li>
<li><img src="img/chrome.jpg"><a href="http://www.google.cn/intl/zh-CN/chrome/browser/desktop/index.html"> 谷歌浏览器<span>Google Chrome</span></a></li>
<li><img src="img/firefox.jpg"><a href="http://www.firefox.com.cn/download/"> 火狐浏览器<span>Mozilla Firefox</span></a></li>
<li><img src="img/edge.png"><a href="https://www.microsoft.com/zh-cn/edge"> Edge 浏览器<span>Microsoft Edge</span></a></li>
<li><img src="img/chrome.jpg"><a href="http://www.google.cn/intl/zh-CN/chrome/browser/desktop/index.html"> 谷歌浏览器<span>Google Chrome</span></a></li>
<li><img src="img/chrome360.jpg"><a href="http://chrome.360.cn/"> 360极速浏览器<span>360 Chrome</span></a></li>
<li><img src="img/firefox.jpg"><a href="https://www.firefox.com/zh-CN/"> 火狐浏览器<span>Mozilla Firefox</span></a></li>
</ul><div class="clean"></div></div>
<hr><br/>
<script>

View File

@@ -48,8 +48,6 @@ public class CodeStatistic {
/**
* 获得目录下的文件和子目录下的文件
* @param f
* @return
*/
public static ArrayList<File> getFile(File f) {
File[] ff = f.listFiles();
@@ -66,7 +64,6 @@ public class CodeStatistic {
/**
* 统计方法
* @param f
*/
private static void count(File f) {
FileReader fr = null;

View File

@@ -41,6 +41,7 @@ public class EncodeUtilsTest {
xssFilter(i++, "<!--HTML-->你好 ?abc=def&hello=123&world={\"a\":1}我还在。");
xssFilter(i++, "<!--HTML-->你好 ?abc=def&hello=123&world={'a':1}我还在。");
xssFilter(i++, "<!--HTML-->\"><svg/ONLOAD=confirm(3) />");
xssFilter(i++, "<!--HTML-->XSS<embed src=\"data:text/html;base64,PHNjcmlwdD5hbGVydCg5KTwvc2NyaXB0Pgo=\">");
sqlFilter(i++, "你好 select * from xxx where abc=def and 1=1我还在。", "common");
sqlFilter(i++, "你好 insert into xxx values(1,2,3,4,5)我还在。", "common");
sqlFilter(i++, "你好 delete from xxx我还在。", "common");

View File

@@ -18,7 +18,7 @@ public class ZxingUtilsTest {
String baseDir = FileUtils.getProjectPath();
// 条形码
String imgPath = baseDir + "\\target\\zxing_EAN13.png";
String imgPath = baseDir + "/target/zxing_EAN13.png";
String contents = "6923450657713";
int width = 105, height = 50;
@@ -30,7 +30,7 @@ public class ZxingUtilsTest {
System.out.println("finished zxing EAN-13 decode.");
// 二维码
String imgPath2 = baseDir + "\\target\\zxing.png";
String imgPath2 = baseDir + "/target/zxing.png";
String contents2 = "Hello Gem, welcome to Zxing!\nEMail [ thinkgem@163.com ]";
int width2 = 300, height2 = 300;

View File

@@ -0,0 +1,32 @@
/**
* Copyright (c) 2013-Now http://jeesite.com All rights reserved.
* No deletion without permission, or be held responsible to law.
*/
package com.jeesite.test.lang;
import com.jeesite.common.lang.StringUtils;
import java.text.ParseException;
/**
* 字符串工具测试类
* @author ThinkGem
* @version 2025-09-18
*/
public class StringUtilsTest {
public static void main(String[] args) throws ParseException {
System.out.println(StringUtils.camelCase("id_name") + " = idName");
System.out.println(StringUtils.camelCase("_id_name") + " = idName");
System.out.println(StringUtils.camelCase("__id_name") + " = idName");
System.out.println(StringUtils.camelCase("a_id") + " = aid");
System.out.println(StringUtils.camelCase("a_b_id") + " = abId");
System.out.println(StringUtils.camelCase("__a_id") + " = aid");
System.out.println(StringUtils.camelCase("__a_b_id") + " = abId");
System.out.println(StringUtils.capCamelCase("id_name") + " = IdName");
System.out.println(StringUtils.capCamelCase("a_b_id_name") + " = AbIdName");
System.out.println(StringUtils.uncamelCase("abIdName") + " = ab_id_name");
System.out.println(StringUtils.uncamelCase("AbIdName") + " = ab_id_name");
}
}

View File

@@ -0,0 +1,47 @@
/**
* Copyright (c) 2013-Now http://jeesite.com All rights reserved.
* No deletion without permission, or be held responsible to law.
*/
package com.jeesite.test.utils.excel;
import com.jeesite.common.collect.ListUtils;
import com.jeesite.common.utils.excel.ExcelExport;
import java.io.File;
import java.math.BigDecimal;
import java.util.List;
/**
* 导出Excel文件测试类
* @author ThinkGem
* @version 2025-10-21
*/
public class ExcelExportEntityTest {
/**
* 导出测试
*/
public static void main(String[] args) throws Throwable {
List<ExcelTestEntity> list = ListUtils.newArrayList();
for (int i = 1; i <= 50; i++) {
ExcelTestEntity e = new ExcelTestEntity();
e.setField1("test"+i);
e.setField2(123+i);
e.setField3(BigDecimal.valueOf(12345+i));
list.add(e);
}
File classPath = new File(ExcelExportEntityTest.class.getResource("/").getFile());
String fileName = classPath.getParentFile().getAbsoluteFile() + "/export_entity.xlsx";
// 创建一个Sheet表并导入数据
try(ExcelExport ee = new ExcelExport("表格1", ExcelTestEntity.class)){
ee.setDataList(list).writeFile(fileName);
}
System.out.println("Export success.");
}
}

View File

@@ -0,0 +1,39 @@
/**
* Copyright (c) 2013-Now http://jeesite.com All rights reserved.
* No deletion without permission, or be held responsible to law.
*/
package com.jeesite.test.utils.excel;
import com.jeesite.common.utils.excel.ExcelImport;
import java.io.File;
import java.util.List;
/**
* 导入Excel文件测试类
* @author ThinkGem
* @version 2025-10-21
*/
public class ExcelImportEntityTest {
/**
* 导入测试
*/
public static void main(String[] args) throws Throwable {
File classPath = new File(ExcelExportTest.class.getResource("/").getFile());
String fileName = classPath.getParentFile().getAbsoluteFile() + "/export_entity.xlsx";
try(ExcelImport ei = new ExcelImport(fileName, 2, 0)){
List<ExcelTestEntity> list = ei.getDataList(ExcelTestEntity.class);
for (ExcelTestEntity e : list) {
System.out.print(e.getField1()+", ");
System.out.print(e.getField2()+", ");
System.out.print(e.getField3()+", ");
System.out.println();
}
}
System.out.println("Import success.");
}
}

View File

@@ -6,8 +6,6 @@ package com.jeesite.test.utils.excel;
import com.jeesite.common.utils.excel.ExcelImport;
import org.apache.poi.ss.usermodel.Row;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;

View File

@@ -0,0 +1,55 @@
/**
* Copyright (c) 2013-Now http://jeesite.com All rights reserved.
* No deletion without permission, or be held responsible to law.
*/
package com.jeesite.test.utils.excel;
import com.jeesite.common.utils.excel.annotation.ExcelField;
import com.jeesite.common.utils.excel.annotation.ExcelFields;
import java.math.BigDecimal;
/**
* Excel 测试数据实体
* @author ThinkGem
*/
public class ExcelTestEntity {
// 方式1声明在字段上
@ExcelField(title = "字段1", align = ExcelField.Align.CENTER, sort = 10)
private String field1;
private Integer field2;
private BigDecimal field3;
// 方式2声明在构造上
@ExcelFields({
@ExcelField(title = "字段2", attrName = "field2", align = ExcelField.Align.CENTER, sort = 20),
})
public ExcelTestEntity() {}
public String getField1() {
return field1;
}
public void setField1(String field1) {
this.field1 = field1;
}
public Integer getField2() {
return field2;
}
public void setField2(Integer field2) {
this.field2 = field2;
}
// 方式3声明在方法上
@ExcelField(title = "字段3", align = ExcelField.Align.CENTER, sort = 30)
public BigDecimal getField3() {
return field3;
}
public void setField3(BigDecimal field3) {
this.field3 = field3;
}
}

View File

@@ -1,3 +1,7 @@
/**
* Copyright (c) 2013-Now http://jeesite.com All rights reserved.
* No deletion without permission, or be held responsible to law.
*/
package com.jeesite.test.utils.word;
import com.jeesite.common.io.FileUtils;

View File

@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="UTF-8"?><!--suppress VulnerableLibrariesLocal -->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
@@ -6,7 +6,7 @@
<parent>
<groupId>com.jeesite</groupId>
<artifactId>jeesite-parent</artifactId>
<version>5.12.1-SNAPSHOT</version>
<version>5.14.0-SNAPSHOT</version>
<relativePath>../../parent/pom.xml</relativePath>
</parent>

View File

@@ -4,12 +4,6 @@
*/
package com.jeesite.modules.app.db;
import java.util.Date;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.stereotype.Component;
import com.jeesite.common.config.Global;
import com.jeesite.common.tests.BaseInitDataTests;
import com.jeesite.modules.app.entity.AppComment;
@@ -17,6 +11,10 @@ import com.jeesite.modules.app.entity.AppUpgrade;
import com.jeesite.modules.app.service.AppCommentService;
import com.jeesite.modules.app.service.AppUpgradeService;
import com.jeesite.modules.gen.utils.GenUtils;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.stereotype.Component;
import java.util.Date;
/**
* 初始化APP表及数据
@@ -27,6 +25,11 @@ import com.jeesite.modules.gen.utils.GenUtils;
@ConditionalOnProperty(name="jeesite.initdata", havingValue="true", matchIfMissing=false)
public class InitAppData extends BaseInitDataTests {
public InitAppData(AppUpgradeService appUpgradeService, AppCommentService appCommentService) {
this.appUpgradeService = appUpgradeService;
this.appCommentService = appCommentService;
}
@Override
public boolean initData() throws Exception {
if (GenUtils.isTableExists(Global.getTablePrefix() + "app_upgrade")) {
@@ -41,8 +44,7 @@ public class InitAppData extends BaseInitDataTests {
return true;
}
@Autowired
private AppUpgradeService appUpgradeService;
private final AppUpgradeService appUpgradeService;
public void initAppUpgrade() throws Exception{
// clearTable(AppUpgrade.class);
initExcelData(AppUpgrade.class, params -> {
@@ -57,8 +59,7 @@ public class InitAppData extends BaseInitDataTests {
});
}
@Autowired
private AppCommentService appCommentService;
private final AppCommentService appCommentService;
public void initAppComment() throws Exception{
// clearTable(AppComment.class);
initExcelData(AppComment.class, params -> {

View File

@@ -23,8 +23,7 @@ public class AppCommentService extends CrudService<AppCommentDao, AppComment> {
/**
* 获取单条数据
* @param appComment
* @return
* @param appComment 主键
*/
@Override
public AppComment get(AppComment appComment) {
@@ -35,7 +34,6 @@ public class AppCommentService extends CrudService<AppCommentDao, AppComment> {
* 查询分页数据
* @param appComment 查询条件
* @param appComment page 分页对象
* @return
*/
@Override
public Page<AppComment> findPage(AppComment appComment) {
@@ -44,7 +42,7 @@ public class AppCommentService extends CrudService<AppCommentDao, AppComment> {
/**
* 保存数据(插入或更新)
* @param appComment
* @param appComment 查询条件
*/
@Override
@Transactional
@@ -56,7 +54,7 @@ public class AppCommentService extends CrudService<AppCommentDao, AppComment> {
/**
* 更新状态
* @param appComment
* @param appComment 数据对象
*/
@Override
@Transactional
@@ -66,7 +64,7 @@ public class AppCommentService extends CrudService<AppCommentDao, AppComment> {
/**
* 删除数据
* @param appComment
* @param appComment 数据对象
*/
@Override
@Transactional

View File

@@ -22,8 +22,7 @@ public class AppUpgradeService extends CrudService<AppUpgradeDao, AppUpgrade> {
/**
* 获取单条数据
* @param appUpgrade
* @return
* @param appUpgrade 主键
*/
@Override
public AppUpgrade get(AppUpgrade appUpgrade) {
@@ -34,7 +33,6 @@ public class AppUpgradeService extends CrudService<AppUpgradeDao, AppUpgrade> {
* 查询分页数据
* @param appUpgrade 查询条件
* @param appUpgrade page 分页对象
* @return
*/
@Override
public Page<AppUpgrade> findPage(AppUpgrade appUpgrade) {
@@ -43,7 +41,7 @@ public class AppUpgradeService extends CrudService<AppUpgradeDao, AppUpgrade> {
/**
* 保存数据(插入或更新)
* @param appUpgrade
* @param appUpgrade 数据对象
*/
@Override
@Transactional
@@ -53,7 +51,7 @@ public class AppUpgradeService extends CrudService<AppUpgradeDao, AppUpgrade> {
/**
* 更新状态
* @param appUpgrade
* @param appUpgrade 数据对象
*/
@Override
@Transactional
@@ -63,7 +61,7 @@ public class AppUpgradeService extends CrudService<AppUpgradeDao, AppUpgrade> {
/**
* 删除数据
* @param appUpgrade
* @param appUpgrade 数据对象
*/
@Override
@Transactional

View File

@@ -9,9 +9,10 @@ import com.jeesite.common.entity.Page;
import com.jeesite.common.web.BaseController;
import com.jeesite.modules.app.entity.AppComment;
import com.jeesite.modules.app.service.AppCommentService;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.validation.annotation.Validated;
@@ -20,8 +21,6 @@ import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Date;
/**
@@ -33,9 +32,12 @@ import java.util.Date;
@RequestMapping(value = "${adminPath}/app/appComment")
public class AppCommentController extends BaseController {
@Autowired
private AppCommentService appCommentService;
private final AppCommentService appCommentService;
public AppCommentController(AppCommentService appCommentService) {
this.appCommentService = appCommentService;
}
/**
* 获取数据
*/

View File

@@ -4,21 +4,19 @@
*/
package com.jeesite.modules.app.web;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.jeesite.common.config.Global;
import com.jeesite.common.web.BaseController;
import com.jeesite.modules.app.entity.AppComment;
import com.jeesite.modules.app.entity.AppUpgrade;
import com.jeesite.modules.app.service.AppCommentService;
import com.jeesite.modules.app.service.AppUpgradeService;
import org.springframework.stereotype.Controller;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.List;
/**
* APP公共服务 Controller
@@ -29,12 +27,14 @@ import com.jeesite.modules.app.service.AppUpgradeService;
@RequestMapping(value = "/app")
public class AppPublicServiceController extends BaseController {
@Autowired
private AppUpgradeService appUpgradeService;
private final AppUpgradeService appUpgradeService;
private final AppCommentService appCommentService;
public AppPublicServiceController(AppUpgradeService appUpgradeService, AppCommentService appCommentService) {
this.appUpgradeService = appUpgradeService;
this.appCommentService = appCommentService;
}
@Autowired
private AppCommentService appCommentService;
/**
* 升级检测
*/

View File

@@ -4,11 +4,14 @@
*/
package com.jeesite.modules.app.web;
import com.jeesite.common.config.Global;
import com.jeesite.common.entity.Page;
import com.jeesite.common.web.BaseController;
import com.jeesite.modules.app.entity.AppUpgrade;
import com.jeesite.modules.app.service.AppUpgradeService;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.validation.annotation.Validated;
@@ -17,12 +20,6 @@ import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.jeesite.common.config.Global;
import com.jeesite.common.entity.Page;
import com.jeesite.common.web.BaseController;
import com.jeesite.modules.app.entity.AppUpgrade;
import com.jeesite.modules.app.service.AppUpgradeService;
/**
* APP版本管理Controller
* @author ThinkGem
@@ -32,9 +29,12 @@ import com.jeesite.modules.app.service.AppUpgradeService;
@RequestMapping(value = "${adminPath}/app/appUpgrade")
public class AppUpgradeController extends BaseController {
@Autowired
private AppUpgradeService appUpgradeService;
private final AppUpgradeService appUpgradeService;
public AppUpgradeController(AppUpgradeService appUpgradeService) {
this.appUpgradeService = appUpgradeService;
}
/**
* 获取数据
*/

View File

@@ -28,4 +28,7 @@
5.11.0
5.11.1
5.12.0
5.12.1
5.12.1
5.13.0
5.13.1
5.14.0

View File

@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="UTF-8"?><!--suppress VulnerableLibrariesLocal -->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
@@ -6,7 +6,7 @@
<parent>
<groupId>com.jeesite</groupId>
<artifactId>jeesite-parent</artifactId>
<version>5.12.1-SNAPSHOT</version>
<version>5.14.0-SNAPSHOT</version>
<relativePath>../../parent/pom.xml</relativePath>
</parent>

View File

@@ -10,7 +10,7 @@ import com.jeesite.modules.cms.entity.Article;
/**
* 文章表DAO接口
* @author 长春叭哥
* @author 长春叭哥、ThinkGem
* @version 2018-10-15
*/
@MyBatisDao

View File

@@ -10,7 +10,7 @@ import com.jeesite.modules.cms.entity.ArticleData;
/**
* 文章详情表DAO接口
* @author 长春叭哥
* @author 长春叭哥、ThinkGem
* @version 2018-10-15
*/
@MyBatisDao

View File

@@ -10,7 +10,7 @@ import com.jeesite.modules.cms.entity.ArticlePosid;
/**
* 文章推荐位DAO接口
* @author 长春叭哥
* @author 长春叭哥、ThinkGem
* @version 2018-10-15
*/
@MyBatisDao

View File

@@ -10,7 +10,7 @@ import com.jeesite.modules.cms.entity.ArticleTag;
/**
* 文章与标签关系DAO接口
* @author 长春叭哥
* @author 长春叭哥、ThinkGem
* @version 2018-10-15
*/
@MyBatisDao

View File

@@ -10,7 +10,7 @@ import com.jeesite.modules.cms.entity.Category;
/**
* 栏目表DAO接口
* @author 长春叭哥
* @author 长春叭哥、ThinkGem
* @version 2018-10-15
*/
@MyBatisDao

View File

@@ -10,7 +10,7 @@ import com.jeesite.modules.cms.entity.Comment;
/**
* 文章评论表DAO接口
* @author 长春叭哥
* @author 长春叭哥、ThinkGem
* @version 2018-10-15
*/
@MyBatisDao

View File

@@ -10,7 +10,7 @@ import com.jeesite.modules.cms.entity.Report;
/**
* 内容举报表DAO接口
* @author 长春叭哥
* @author 长春叭哥、ThinkGem
* @version 2018-10-15
*/
@MyBatisDao

View File

@@ -10,7 +10,7 @@ import com.jeesite.modules.cms.entity.Site;
/**
* 站点表DAO接口
* @author 长春叭哥
* @author 长春叭哥、ThinkGem
* @version 2018-10-15
*/
@MyBatisDao

View File

@@ -10,7 +10,7 @@ import com.jeesite.modules.cms.entity.Tag;
/**
* 内容标签DAO接口
* @author 长春叭哥
* @author 长春叭哥、ThinkGem
* @version 2018-10-15
*/
@MyBatisDao

View File

@@ -10,7 +10,7 @@ import com.jeesite.modules.cms.entity.VisitLog;
/**
* 访问日志表DAO接口
* @author 长春叭哥
* @author 长春叭哥、ThinkGem
* @version 2018-10-15
*/
@MyBatisDao

View File

@@ -15,7 +15,6 @@ import com.jeesite.modules.cms.entity.Site;
import com.jeesite.modules.cms.service.CategoryService;
import com.jeesite.modules.cms.service.SiteService;
import com.jeesite.modules.gen.utils.GenUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.stereotype.Component;
@@ -28,6 +27,14 @@ import org.springframework.stereotype.Component;
@ConditionalOnProperty(name="jeesite.initdata", havingValue="true", matchIfMissing=false)
public class InitCmsData extends BaseInitDataTests {
public InitCmsData(SiteService siteService, CategoryService categoryService,
ArticleDao articleDao, ArticleDataDao articleDataDao) {
this.siteService = siteService;
this.categoryService = categoryService;
this.articleDao = articleDao;
this.articleDataDao = articleDataDao;
}
@Override
public boolean initData() throws Exception {
if (GenUtils.isTableExists(Global.getTablePrefix() + "cms_article")) {
@@ -44,8 +51,7 @@ public class InitCmsData extends BaseInitDataTests {
return true;
}
@Autowired
private SiteService siteService;
private final SiteService siteService;
public void initSite() throws Exception{
initExcelData(Site.class, params -> {
String action = (String)params[0];
@@ -59,8 +65,7 @@ public class InitCmsData extends BaseInitDataTests {
});
}
@Autowired
private CategoryService categoryService;
private final CategoryService categoryService;
public void initCategory() throws Exception{
initExcelData(Category.class, params -> {
String action = (String)params[0];
@@ -74,8 +79,7 @@ public class InitCmsData extends BaseInitDataTests {
});
}
@Autowired
private ArticleDao articleDao;
private final ArticleDao articleDao;
public void initArticle() throws Exception{
initExcelData(Article.class, params -> {
String action = (String)params[0];
@@ -89,8 +93,7 @@ public class InitCmsData extends BaseInitDataTests {
});
}
@Autowired
private ArticleDataDao articleDataDao;
private final ArticleDataDao articleDataDao;
public void initArticleData() throws Exception{
initExcelData(ArticleData.class, params -> {
String action = (String)params[0];

View File

@@ -16,6 +16,7 @@ import com.jeesite.modules.cms.utils.CmsUtils;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.util.Date;
/**
@@ -280,7 +281,6 @@ public class Article extends DataEntity<Article> {
/**
* 是否查询文章内容
* @return
*/
public Boolean getIsQueryArticleData() {
return isQueryArticleData;

View File

@@ -4,19 +4,17 @@
*/
package com.jeesite.modules.cms.entity;
import java.util.Date;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.jeesite.common.entity.BaseEntity;
import com.jeesite.common.entity.DataEntity;
import com.jeesite.common.mybatis.annotation.Column;
import com.jeesite.common.mybatis.annotation.Table;
import com.jeesite.common.mybatis.mapper.query.QueryType;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.util.Date;
/**
* 文章评论表Entity
@@ -45,7 +43,7 @@ public class Comment extends DataEntity<Comment> {
private static final long serialVersionUID = 1L;
private Category category;// 分类编号
private Category category; // 分类编号
private String categoryCode; // 栏目编码
private String articleId; // 内容编号 Article.id、Photo.id、Download.id

View File

@@ -7,6 +7,7 @@ package com.jeesite.modules.cms.entity;
import java.io.IOException;
import java.io.InputStream;
import java.io.Serializable;
import java.nio.charset.StandardCharsets;
import java.util.Objects;
import org.springframework.core.io.Resource;
@@ -21,16 +22,16 @@ import com.jeesite.common.lang.ExceptionUtils;
* @author 长春叭哥ThinkGem
* @version 2020-7-7
*/
public class FileTemplete implements Comparable<FileTemplete>, Serializable {
public class FileTemplate implements Comparable<FileTemplate>, Serializable {
private static final long serialVersionUID = 1L;
private Resource resource;
private final Resource resource;
private String fileName;
private String fileExtension;
private String filePath;
private boolean isDirectory;
public FileTemplete(Resource resource, String path) {
public FileTemplate(Resource resource, String path) {
this.resource = resource;
this.fileName = resource.getFilename();
this.fileExtension = FileUtils.getFileExtension(this.fileName);
@@ -41,22 +42,22 @@ public class FileTemplete implements Comparable<FileTemplete>, Serializable {
beginIndex = filePath.indexOf(path);
}
int endIndex = filePath.length();
if (this.fileName.contains(".")){
if (this.fileName != null && this.fileName.contains(".")) {
endIndex = filePath.lastIndexOf('/');
}else if (filePath.endsWith("/")) {
endIndex -= 1;
}
}
this.filePath = filePath.substring(beginIndex, endIndex);
// System.out.println(this.filePath);
} catch (IOException e) {
throw ExceptionUtils.unchecked(e);
}
this.isDirectory = !this.fileName.contains(".");
if (this.fileName != null) {
this.isDirectory = !this.fileName.contains(".");
}
// System.out.println(filePath);
// System.out.println(fileName);
}
public FileTemplete(FileTemplete source) {
public FileTemplate(FileTemplate source) {
int index = source.filePath.lastIndexOf('/');
this.fileName = source.filePath.substring(index+1);
this.filePath = source.filePath.substring(0, index);
@@ -109,14 +110,14 @@ public class FileTemplete implements Comparable<FileTemplete>, Serializable {
return null;
}
try(InputStream is = resource.getInputStream()){
return IOUtils.toString(is, EncodeUtils.UTF_8);
return IOUtils.toString(is, StandardCharsets.UTF_8);
}catch (IOException e) {
throw ExceptionUtils.unchecked(e);
}
}
@Override
public int compareTo(FileTemplete o) {
public int compareTo(FileTemplate o) {
return this.getFileName().compareTo(o.getFileName());
}
@@ -128,7 +129,7 @@ public class FileTemplete implements Comparable<FileTemplete>, Serializable {
if (o == null || getClass() != o.getClass()) {
return false;
}
FileTemplete e = (FileTemplete) o;
FileTemplate e = (FileTemplate) o;
return Objects.equals(this.fileName, e.fileName)
&& Objects.equals(this.fileExtension, e.fileExtension)
&& Objects.equals(this.filePath, e.filePath)

View File

@@ -16,6 +16,7 @@ import com.jeesite.modules.sys.utils.UserUtils;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Size;
import java.util.List;
/**
@@ -47,7 +48,7 @@ public class Site extends DataEntity<Site> {
/**
* 模板路径
*/
public static final String TEMPLETE_BASE_DIRECTION = "views/modules/cmsfront/themes";
public static final String TEMPLATE_BASE_DIRECTION = "views/modules/cmsfront/themes";
/**
* 默认模版
*/
@@ -186,10 +187,9 @@ public class Site extends DataEntity<Site> {
/**
* 获得模板方案路径。如:/WEB-INF/views/modules/cmsfront/themes/jeesite
* @return
*/
public String getSolutionPath() {
return TEMPLETE_BASE_DIRECTION + "/" + getTheme();
return TEMPLATE_BASE_DIRECTION + "/" + getTheme();
}
public List<String> getCategoryCodes() {

View File

@@ -19,7 +19,7 @@ import com.jeesite.modules.cms.utils.CmsUtils;
import com.jeesite.modules.file.utils.FileUploadUtils;
import com.jeesite.modules.sys.utils.UserUtils;
import io.netty.util.concurrent.DefaultThreadFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.ObjectProvider;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -32,19 +32,24 @@ import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
/**
* 文章Service
* @author 长春叭哥、ThinkGem
* @version 2023-4-10
* 文章Service
* @author ThinkGem
* @version 2025-10-12
*/
@Service
public class ArticleService extends CrudService<ArticleDao, Article> {
@Autowired
private ArticleDataDao articleDataDao;
@Autowired(required = false)
private ArticleIndexService articleIndexService;
@Autowired(required = false)
private PageCacheService pageCacheService;
private final ArticleDataDao articleDataDao;
private final ArticleIndexService articleIndexService;
private final PageCacheService pageCacheService;
public ArticleService(ArticleDataDao articleDataDao,
ObjectProvider<ArticleIndexService> articleIndexService,
ObjectProvider<PageCacheService> pageCacheService) {
this.articleDataDao = articleDataDao;
this.articleIndexService = articleIndexService.getIfAvailable();
this.pageCacheService = pageCacheService.getIfAvailable();
}
private static final ExecutorService updateExpiredWeightThreadPool = new ThreadPoolExecutor(5, 20,
60L, TimeUnit.SECONDS, new LinkedBlockingQueue<>(),
@@ -52,8 +57,7 @@ public class ArticleService extends CrudService<ArticleDao, Article> {
/**
* 获取单条数据
* @param article
* @return
* @param article 主键
*/
@Override
public Article get(Article article) {
@@ -84,7 +88,6 @@ public class ArticleService extends CrudService<ArticleDao, Article> {
* 查询分页数据
* @param article 查询条件
* @param article page 分页对象
* @return
*/
@Override
public Page<Article> findPage(Article article) {
@@ -94,6 +97,7 @@ public class ArticleService extends CrudService<ArticleDao, Article> {
/**
* 通过编号获取内容标题
* @param ids 主键,使用逗号分隔
* @return new Object[]{栏目Id,内容Id,内容标题}
*/
public List<Object[]> findByIds(String ids) {
@@ -111,15 +115,14 @@ public class ArticleService extends CrudService<ArticleDao, Article> {
/**
* 权重更新
* @param article
* @param article 数据对象
* @author ThinkGem
*/
@Transactional
public void updateExpiredWeight(Article article) {
// 更新过期的权重间隔为“6”个小时
Date updateExpiredWeightDate = CmsUtils.getCache("updateExpiredWeightDateByArticle");
if (updateExpiredWeightDate == null || (updateExpiredWeightDate != null
&& updateExpiredWeightDate.getTime() < System.currentTimeMillis())) {
if (updateExpiredWeightDate == null || updateExpiredWeightDate.getTime() < System.currentTimeMillis()) {
article.setWeightDate(new Date());
dao.updateExpiredWeight(article);
CmsUtils.putCache("updateExpiredWeightDateByArticle", DateUtils.addHours(new Date(), 6));
@@ -128,7 +131,7 @@ public class ArticleService extends CrudService<ArticleDao, Article> {
/**
* 保存数据(插入或更新)
* @param article
* @param article 数据对象
*/
@Override
@Transactional
@@ -174,7 +177,7 @@ public class ArticleService extends CrudService<ArticleDao, Article> {
/**
* 更新状态
* @param article
* @param article 数据对象
*/
@Override
@Transactional
@@ -211,7 +214,7 @@ public class ArticleService extends CrudService<ArticleDao, Article> {
/**
* 删除数据
* @param article
* @param article 文章
*/
@Override
@Transactional

View File

@@ -10,29 +10,31 @@ import com.jeesite.modules.cms.entity.Article;
import com.jeesite.modules.cms.entity.Category;
import com.jeesite.modules.cms.utils.CmsUtils;
import com.jeesite.modules.file.utils.FileUploadUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.ObjectProvider;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
/**
* 栏目Service
* @author 长春叭哥、ThinkGem
* @version 2023-4-10
* 栏目Service
* @author ThinkGem
* @version 2025-10-12
*/
@Service
public class CategoryService extends TreeService<CategoryDao, Category> {
@Autowired(required = false)
private ArticleIndexService articleIndexService;
@Autowired(required = false)
private PageCacheService pageCacheService;
private final ArticleIndexService articleIndexService;
private final PageCacheService pageCacheService;
public CategoryService(ObjectProvider<ArticleIndexService> articleIndexService,
ObjectProvider<PageCacheService> pageCacheService) {
this.articleIndexService = articleIndexService.getIfAvailable();
this.pageCacheService = pageCacheService.getIfAvailable();
}
/**
* 获取单条数据
* @param category
* @return
*/
@Override
public Category get(Category category) {
@@ -50,8 +52,6 @@ public class CategoryService extends TreeService<CategoryDao, Category> {
/**
* 查询列表数据
* @param category
* @return
*/
@Override
public List<Category> findList(Category category) {
@@ -60,19 +60,15 @@ public class CategoryService extends TreeService<CategoryDao, Category> {
/**
* 保存数据(插入或更新)
* @param category
*/
@Override
@Transactional
public void save(Category category) {
super.save(category);
CmsUtils.removeCache("mainNavList_"+category.getSite().getId());
// 保存上传图片
FileUploadUtils.saveFileUpload(category, category.getId(), "category_image");
// 清理首页、栏目和文章页面缓存
if (pageCacheService != null) {
pageCacheService.clearCache(category);
}
// 清理栏目缓存
clearCache(category);
}
/**
@@ -87,27 +83,37 @@ public class CategoryService extends TreeService<CategoryDao, Category> {
/**
* 更新状态
* @param category
*/
@Override
@Transactional
public void updateStatus(Category category) {
super.updateStatus(category);
// 清理首页、栏目和文章页面缓存
if (pageCacheService != null) {
pageCacheService.clearCache(category);
}
// 清理栏目缓存
clearCache(category);
}
/**
* 删除数据
* @param category
*/
@Override
@Transactional
public void delete(Category category) {
category.sqlMap().markIdDelete();
super.delete(category);
// 清理栏目缓存
clearCache(category);
}
/**
* 清理栏目缓存
*/
public void clearCache(Category category) {
// 清理栏目缓存
CmsUtils.removeCache("category_" + category.getId());
// 清理栏目列表缓存
CmsUtils.removeCacheByKeyPrefix("categoryList_" + category.getSite().getId() + "_" + category.getParentCode() + "_");
// 清理主导航缓存
CmsUtils.removeCache("mainNavList_" + category.getSite().getId());
// 清理首页、栏目和文章页面缓存
if (pageCacheService != null) {
pageCacheService.clearCache(category);

View File

@@ -23,8 +23,7 @@ public class CommentService extends CrudService<CommentDao, Comment> {
/**
* 获取单条数据
* @param comment
* @return
* @param comment 主键
*/
@Override
public Comment get(Comment comment) {
@@ -35,7 +34,6 @@ public class CommentService extends CrudService<CommentDao, Comment> {
* 查询分页数据
* @param comment 查询条件
* @param comment page 分页对象
* @return
*/
@Override
public Page<Comment> findPage(Comment comment) {
@@ -44,7 +42,7 @@ public class CommentService extends CrudService<CommentDao, Comment> {
/**
* 保存数据(插入或更新)
* @param comment
* @param comment 数据对象
*/
@Override
@Transactional
@@ -58,7 +56,7 @@ public class CommentService extends CrudService<CommentDao, Comment> {
/**
* 更新状态
* @param comment
* @param comment 数据对象
*/
@Override
@Transactional
@@ -68,7 +66,7 @@ public class CommentService extends CrudService<CommentDao, Comment> {
/**
* 删除数据
* @param comment
* @param comment 数据对象
*/
@Override
@Transactional

View File

@@ -0,0 +1,59 @@
/**
* Copyright (c) 2013-Now http://jeesite.com All rights reserved.
* No deletion without permission, or be held responsible to law.
*/
package com.jeesite.modules.cms.service;
import com.jeesite.common.collect.ListUtils;
import com.jeesite.modules.cms.entity.FileTemplate;
import com.jeesite.modules.cms.entity.Site;
import com.jeesite.modules.cms.utils.CmsUtils;
import com.jeesite.modules.cms.utils.FileTemplateUtils;
import com.jeesite.modules.sys.entity.DictData;
import org.springframework.stereotype.Service;
import java.io.IOException;
import java.util.List;
/**
* 模版文件Service
* @author 长春叭哥、ThinkGem
* @version 2020-7-7
*/
@Service
public class FileTemplateService {
/**
* 获取对应视图模板列表,兼容 Select 字典
* @param prefix 路径前缀
*/
public List<DictData> getTemplateContentDict(String prefix) throws IOException {
List<DictData> listSite = ListUtils.newArrayList();
String solutionPath = CmsUtils.getSite(Site.getCurrentSiteCode()).getSolutionPath();
List<FileTemplate> tplList = FileTemplateUtils.getFileTemplateListByPath(solutionPath);
for (FileTemplate tpl : tplList) {
if (tpl.getFileName().startsWith(prefix)) {
listSite.add(new DictData(tpl.getFileName()
.substring(0, tpl.getFileName().indexOf("."))));
}
}
return listSite;
}
/**
* 获取编辑文件列表
* @param path 模板路径
*/
public List<FileTemplate> getFileTemplateListForEdit(String path) throws IOException {
return FileTemplateUtils.getFileTemplateListForEdit(path);
}
/**
* 获取模版文件内容
* @param fileName 模板文件
*/
public FileTemplate getFileTemplate(String fileName) throws IOException {
return FileTemplateUtils.getFileTemplateByResource(fileName);
}
}

View File

@@ -1,88 +0,0 @@
/**
* Copyright (c) 2013-Now http://jeesite.com All rights reserved.
* No deletion without permission, or be held responsible to law.
*/
package com.jeesite.modules.cms.service;
import com.jeesite.common.collect.ListUtils;
import com.jeesite.modules.cms.entity.FileTemplete;
import com.jeesite.modules.cms.entity.Site;
import com.jeesite.modules.cms.utils.CmsUtils;
import com.jeesite.modules.cms.utils.FileTempleteUtils;
import com.jeesite.modules.sys.entity.DictData;
import org.springframework.stereotype.Service;
import java.io.IOException;
import java.util.List;
/**
* 模版文件Service
* @author 长春叭哥、ThinkGem
* @version 2020-7-7
*/
@Service
public class FileTempleteService {
// public List<String> getTempleteContent(String prefix) throws IOException {
// List<String> tplList = getFileTempleteNameListByPrefix(CmsUtils.getSite(Site.getCurrentSiteCode()).getSolutionPath());
// tplList = FilesTempleteUtils.templeteTrim(tplList, prefix, "");
// return tplList;
// }
/**
* 获取对应视图模板列表,兼容 Select 字典
* @param prefix
*/
public List<DictData> getTempleteContentDict(String prefix) throws IOException {
List<DictData> listSite = ListUtils.newArrayList();
String solutionPath = CmsUtils.getSite(Site.getCurrentSiteCode()).getSolutionPath();
List<FileTemplete> tplList = FileTempleteUtils.getFileTempleteListByPath(solutionPath);
for (FileTemplete tpl : tplList) {
if (tpl.getFileName().startsWith(prefix)) {
listSite.add(new DictData(tpl.getFileName()
.substring(0, tpl.getFileName().indexOf("."))));
}
}
return listSite;
}
// /**
// * 通过前缀获取文件名集合
// * @param filePath
// * @return List<String> 文件名集合
// * @author 长春叭哥
// * @throws IOException
// */
// public List<String> getFileTempleteNameListByPrefix(String filePath) throws IOException {
// return FilesTempleteUtils.getFileTempleteNameListByPrefix(filePath);
// }
// /**
// * 获取模版文件列表
// * @param path 路径
// * @param directory
// * @return List<FileTemplete> 模版文件集合
// * @author 长春叭哥
// * @throws IOException
// */
// public List<FileTemplete> getFileTempleteListByPath(String path, boolean directory) throws IOException {
// return FilesTempleteUtils.getFileTempleteListByPath(path, directory);
// }
/**
* 获取编辑文件列表
* @param path 模板路径
*/
public List<FileTemplete> getFileTempleteListForEdit(String path) throws IOException {
return FileTempleteUtils.getFileTempleteListForEdit(path);
}
/**
* 获取模版文件内容
* @param fileName 模板文件
*/
public FileTemplete getFileTemplete(String fileName) throws IOException {
return FileTempleteUtils.getFileTempleteByResource(fileName);
}
}

View File

@@ -23,8 +23,7 @@ public class ReportService extends CrudService<ReportDao, Report> {
/**
* 获取单条数据
* @param report
* @return
* @param report 主键
*/
@Override
public Report get(Report report) {
@@ -35,7 +34,6 @@ public class ReportService extends CrudService<ReportDao, Report> {
* 查询分页数据
* @param report 查询条件
* @param report page 分页对象
* @return
*/
@Override
public Page<Report> findPage(Report report) {
@@ -44,7 +42,7 @@ public class ReportService extends CrudService<ReportDao, Report> {
/**
* 保存数据(插入或更新)
* @param report
* @param report 数据对象
*/
@Override
@Transactional
@@ -58,7 +56,7 @@ public class ReportService extends CrudService<ReportDao, Report> {
/**
* 更新状态
* @param report
* @param report 数据对象
*/
@Override
@Transactional
@@ -68,7 +66,7 @@ public class ReportService extends CrudService<ReportDao, Report> {
/**
* 删除数据
* @param report
* @param report 数据对象
*/
@Override
@Transactional

View File

@@ -12,27 +12,30 @@ import com.jeesite.modules.cms.entity.Category;
import com.jeesite.modules.cms.entity.Site;
import com.jeesite.modules.cms.utils.CmsUtils;
import com.jeesite.modules.file.utils.FileUploadUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.ObjectProvider;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
/**
* 站点Service
* @author 长春叭哥、ThinkGem
* @version 2023-4-10
* 站点Service
* @author ThinkGem
* @version 2025-10-12
*/
@Service
public class SiteService extends CrudService<SiteDao, Site> {
@Autowired(required = false)
private ArticleIndexService articleIndexService;
@Autowired(required = false)
private PageCacheService pageCacheService;
private final ArticleIndexService articleIndexService;
private final PageCacheService pageCacheService;
public SiteService(ObjectProvider<ArticleIndexService> articleIndexService,
ObjectProvider<PageCacheService> pageCacheService) {
this.articleIndexService = articleIndexService.getIfAvailable();
this.pageCacheService = pageCacheService.getIfAvailable();
}
/**
* 获取单条数据
* @param site
* @return
* @param site 主键
*/
@Override
public Site get(Site site) {
@@ -43,7 +46,6 @@ public class SiteService extends CrudService<SiteDao, Site> {
* 查询分页数据
* @param site 查询条件
* @param site page 分页对象
* @return
*/
@Override
public Page<Site> findPage(Site site) {
@@ -52,45 +54,55 @@ public class SiteService extends CrudService<SiteDao, Site> {
/**
* 保存数据(插入或更新)
* @param site
* @param site 数据对象
*/
@Override
@Transactional
public void save(Site site) {
super.save(site);
CmsUtils.removeCache("siteList");
// 保存logo
FileUploadUtils.saveFileUpload(site, site.getId(), "site_logo");
// 清理首页、栏目和文章页面缓存
if (pageCacheService != null) {
pageCacheService.clearCache(site);
}
// 清理站点缓存
clearCache(site);
}
/**
* 更新状态
* @param site
* @param site 数据对象
*/
@Override
@Transactional
public void updateStatus(Site site) {
super.updateStatus(site);
CmsUtils.removeCache("siteList");
// 清理首页、栏目和文章页面缓存
if (pageCacheService != null) {
pageCacheService.clearCache(site);
}
// 清理站点缓存
clearCache(site);
}
/**
* 删除数据
* @param site
* @param site 数据对象
*/
@Override
@Transactional
public void delete(Site site) {
site.sqlMap().markIdDelete();
super.delete(site);
// 清理站点缓存
clearCache(site);
}
/**
* 清理站点缓存
*/
public void clearCache(Site site) {
// 清理栏目缓存
CmsUtils.removeCacheByKeyPrefix("category_");
// 清理栏目列表缓存
CmsUtils.removeCacheByKeyPrefix("categoryList_" + site.getId() + "_");
// 清理主导航缓存
CmsUtils.removeCache("mainNavList_" + site.getId());
// 清理站点缓存
CmsUtils.removeCache("site_" + site.getId());
// 清理站点列表缓存
CmsUtils.removeCache("siteList");
// 清理首页、栏目和文章页面缓存
if (pageCacheService != null) {
@@ -98,18 +110,6 @@ public class SiteService extends CrudService<SiteDao, Site> {
}
}
// /**
// * 删除站点
// * @param site
// * @param isRe
// */
// @Transactional
// public void delete(Site site, Boolean isRe) {
// site.setStatus(isRe != null && isRe ? Site.STATUS_NORMAL : Site.STATUS_DELETE);
// super.delete(site);
// CmsUtils.removeCache("siteList");
// }
/**
* 重建索引
* @author ThinkGem

View File

@@ -22,8 +22,7 @@ public class TagService extends CrudService<TagDao, Tag> {
/**
* 获取单条数据
* @param tag
* @return
* @param tag 主键
*/
@Override
public Tag get(Tag tag) {
@@ -34,7 +33,6 @@ public class TagService extends CrudService<TagDao, Tag> {
* 查询分页数据
* @param tag 查询条件
* @param tag page 分页对象
* @return
*/
@Override
public Page<Tag> findPage(Tag tag) {
@@ -43,7 +41,7 @@ public class TagService extends CrudService<TagDao, Tag> {
/**
* 保存数据(插入或更新)
* @param tag
* @param tag 数据对象
*/
@Override
@Transactional
@@ -53,7 +51,7 @@ public class TagService extends CrudService<TagDao, Tag> {
/**
* 更新状态
* @param tag
* @param tag 数据对象
*/
@Override
@Transactional
@@ -63,7 +61,7 @@ public class TagService extends CrudService<TagDao, Tag> {
/**
* 删除数据
* @param tag
* @param tag 数据对象
*/
@Override
@Transactional

View File

@@ -23,8 +23,7 @@ public class VisitLogService extends CrudService<VisitLogDao, VisitLog> {
/**
* 获取单条数据
* @param visitLog
* @return
* @param visitLog 主键
*/
@Override
public VisitLog get(VisitLog visitLog) {
@@ -35,7 +34,6 @@ public class VisitLogService extends CrudService<VisitLogDao, VisitLog> {
* 查询分页数据
* @param visitLog 查询条件
* @param visitLog page 分页对象
* @return
*/
@Override
public Page<VisitLog> findPage(VisitLog visitLog) {
@@ -44,7 +42,7 @@ public class VisitLogService extends CrudService<VisitLogDao, VisitLog> {
/**
* 保存数据(插入或更新)
* @param visitLog
* @param visitLog 数据对象
*/
@Override
@Transactional
@@ -58,7 +56,7 @@ public class VisitLogService extends CrudService<VisitLogDao, VisitLog> {
/**
* 更新状态
* @param visitLog
* @param visitLog 数据对象
*/
@Override
@Transactional
@@ -68,7 +66,7 @@ public class VisitLogService extends CrudService<VisitLogDao, VisitLog> {
/**
* 删除数据
* @param visitLog
* @param visitLog 数据对象
*/
@Override
@Transactional

View File

@@ -5,6 +5,7 @@
package com.jeesite.modules.cms.utils;
import com.jeesite.common.cache.CacheUtils;
import com.jeesite.common.codec.Md5Utils;
import com.jeesite.common.collect.ListUtils;
import com.jeesite.common.config.Global;
import com.jeesite.common.entity.Page;
@@ -20,10 +21,10 @@ import com.jeesite.modules.cms.service.CategoryService;
import com.jeesite.modules.cms.service.SiteService;
import org.springframework.ui.Model;
import javax.servlet.ServletContext;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
/**
* CmsUtils
@@ -52,30 +53,22 @@ public class CmsUtils {
* @param siteCode 站点编号
*/
public static Site getSite(String siteCode) {
String code = Site.MAIN_SITE_CODE;
if (StringUtils.isNotBlank(siteCode)) {
code = siteCode;
}
// 根据编码获取站点
for (Site site : getSiteList()) {
if (site.getSiteCode().equals(code)) {
return site;
String code = StringUtils.isNotBlank(siteCode) ? siteCode : Site.MAIN_SITE_CODE;
return CmsUtils.computeIfAbsentCache("site_" + code, k -> {
Site site = Static.siteService.get(code);
if (site == null) {
site = new Site(code);
}
}
return new Site(code);
return site;
});
}
/**
* 获得站点列表
*/
public static List<Site> getSiteList() {
@SuppressWarnings("unchecked")
List<Site> siteList = (List<Site>) getCache("siteList");
if (siteList == null) {
siteList = Static.siteService.findList(new Site());
putCache("siteList", siteList);
}
return siteList;
return CmsUtils.computeIfAbsentCache("siteList", k ->
Static.siteService.findList(new Site()));
}
/**
@@ -83,26 +76,22 @@ public class CmsUtils {
* @param siteCode 站点编号
*/
public static List<Category> getMainNavList(String siteCode) {
@SuppressWarnings("unchecked")
List<Category> mainNavList = (List<Category>) getCache("mainNavList_" + siteCode);
if (mainNavList == null) {
return CmsUtils.computeIfAbsentCache("mainNavList_" + siteCode, k -> {
Category category = new Category();
category.setSite(new Site(siteCode));
category.setParent(new Category(Category.ROOT_CODE));
category.setInMenu(Global.SHOW);
mainNavList = Static.categoryService.findList(category);
putCache("mainNavList_" + siteCode, mainNavList);
}
return mainNavList;
return Static.categoryService.findList(category);
});
}
/**
* 获取栏目
* @param categoryCode 栏目编号
* @return
*/
public static Category getCategory(String categoryCode) {
return Static.categoryService.get(categoryCode);
return CmsUtils.computeIfAbsentCache("category_" + categoryCode, k ->
Static.categoryService.get(categoryCode));
}
/**
@@ -123,46 +112,49 @@ public class CmsUtils {
if (StringUtils.isBlank(siteCode) || StringUtils.isBlank(parentCode)) {
return ListUtils.newArrayList();
}
Page<Category> page = new Page<>(1, number, -1);
Category category = new Category();
category.setSite(new Site(siteCode));
category.setParentCode(parentCode);
Boolean isChildList = false; // 是否进行childList转换
if (StringUtils.isNotBlank(params)) {
@SuppressWarnings({ "rawtypes" })
Map map = JsonMapper.fromJson("{" + params.trim() + "}", Map.class);
String key = "categoryList_" + siteCode + "_" + parentCode + "_" + Md5Utils.md5(number + "_" + params);
return CmsUtils.computeIfAbsentCache(key, k -> {
Page<Category> page = new Page<>(1, number, -1);
Category category = new Category();
category.setSite(new Site(siteCode));
category.setParentCode(parentCode);
boolean isChildList = false; // 是否进行childList转换
if (StringUtils.isNotBlank(params)) {
@SuppressWarnings({ "rawtypes" })
Map map = JsonMapper.fromJson("{" + params.trim() + "}", Map.class);
// 获取的层级级别
String sortGrades = ObjectUtils.toString(map.get("sortGrades"));
if (StringUtils.isNotBlank(sortGrades)) {
// 获取的层级级别
String sortGrades = ObjectUtils.toString(map.get("sortGrades"));
if (StringUtils.isNotBlank(sortGrades)) {
// 如果设置了级别则清理ParentCode并使用ParentCodes进行查询
category.setParentCode(null);
// 如果设置了级别则清理ParentCode并使用ParentCodes进行查询
category.setParentCode(null);
// 如果是跟节点则不加入条件,代表查询全部,不是跟节点的时候获取指定节点的所有下级
if (!Category.ROOT_CODE.equals(parentCode)) {
category.setParentCodes("%," + parentCode + ",%");
// 如果是跟节点则不加入条件,代表查询全部,不是跟节点的时候获取指定节点的所有下级
if (!Category.ROOT_CODE.equals(parentCode)) {
category.setParentCodes("%," + parentCode + ",%");
}
// 增加获取层次级别条件
List<Integer> sortGradeList = ListUtils.newArrayList();
for (String s : StringUtils.splitComma(sortGrades)) {
sortGradeList.add(ObjectUtils.toInteger(s));
}
category.setSortGradeList(sortGradeList);
}
// 增加获取层次级别条件
List<Integer> sortGradeList = ListUtils.newArrayList();
for (String s : StringUtils.splitComma(sortGrades)) {
sortGradeList.add(ObjectUtils.toInteger(s));
}
category.setSortGradeList(sortGradeList);
// 是否进行childList转换
isChildList = ObjectUtils.toBoolean(map.get("isChildList"));
}
// 是否进行childList转换
isChildList = ObjectUtils.toBoolean(map.get("isChildList"));
}
category.setPage(page);
page = Static.categoryService.findPage(category);
// 进行childList转换
if (isChildList) {
List<Category> sourceList = page.getList();
List<Category> targetList = Static.categoryService.convertTreeList(sourceList, parentCode);
page.setList(targetList);
}
return page.getList();
category.setPage(page);
page = Static.categoryService.findPage(category);
// 进行childList转换
if (isChildList) {
List<Category> sourceList = page.getList();
List<Category> targetList = Static.categoryService.convertTreeList(sourceList, parentCode);
page.setList(targetList);
}
return page.getList();
});
}
/**
@@ -237,8 +229,6 @@ public class CmsUtils {
/**
* 获得文章动态URL地址
* @param article
* @return url
*/
public static String getUrlDynamic(Article article) {
StringBuilder str = new StringBuilder();
@@ -259,8 +249,6 @@ public class CmsUtils {
/**
* 获得栏目动态URL地址
* @param category
* @return url
*/
public static String getUrlDynamic(Category category) {
StringBuilder str = new StringBuilder();
@@ -279,8 +267,6 @@ public class CmsUtils {
/**
* 获得站点动态URL地址
* @param site
* @return url
*/
public static String getUrlDynamic(Site site) {
StringBuilder str = new StringBuilder();
@@ -299,8 +285,6 @@ public class CmsUtils {
/**
* 获得栏目动态URL地址
* @param category
* @return url
*/
public static String getAdminUrlDynamic(Category category) {
StringBuilder str = new StringBuilder();
@@ -381,8 +365,6 @@ public class CmsUtils {
/**
* 从图片地址中去除ContextPath地址
* @param src
* @return
*/
public static String formatImageSrcToDb(String src) {
if (StringUtils.isBlank(src)) {
@@ -397,8 +379,6 @@ public class CmsUtils {
/**
* 从图片地址中加入ContextPath地址
* @param src
* @return
*/
public static String formatImageSrcToWeb(String src) {
if (StringUtils.isBlank(src)) {
@@ -413,8 +393,6 @@ public class CmsUtils {
/**
* 获取文章视图
* @param article
* @return
*/
public static String getArticleView(Article article) {
if (StringUtils.isBlank(article.getCustomContentView())) {
@@ -441,8 +419,6 @@ public class CmsUtils {
/**
* 视图配置属性设置
* @param model
* @param params
*/
public static void addViewConfigAttribute(Model model, String params) {
if (StringUtils.isNotBlank(params)) {
@@ -458,8 +434,6 @@ public class CmsUtils {
/**
* 视图配置属性设置
* @param model
* @param category
*/
public static void addViewConfigAttribute(Model model, Category category) {
List<Category> categoryList = ListUtils.newArrayList();
@@ -481,33 +455,77 @@ public class CmsUtils {
}
}
/**
* 获取站点服务
*/
public static SiteService getSiteService() {
return Static.siteService;
}
/**
* 获取栏目服务
*/
public static CategoryService getCategoryService() {
return Static.categoryService;
}
/**
* 获取文章服务
*/
public static ArticleService getArticleService() {
return Static.articleService;
}
/**
* 获取缓存值
* @param key 缓存键
*/
public static <V> V getCache(String key) {
return CacheUtils.get(CMS_CACHE, key);
}
/**
* 获取缓存值
* @param key 缓存键
* @param defaultValue 默认值
*/
public static <V> V getCache(String key, V defaultValue) {
V value = CacheUtils.get(CMS_CACHE, key);
return value != null ? value : defaultValue;
}
/**
* 设置缓存值
* @param key 缓存键
* @param value 缓存值
*/
public static void putCache(String key, Object value) {
CacheUtils.put(CMS_CACHE, key, value);
}
/**
* 获取缓存,如果不存在,则设置新值
* @param key 缓存键
* @param mappingFunction 新值
*/
public static <V> V computeIfAbsentCache(String key, Function<String, V> mappingFunction) {
return CacheUtils.computeIfAbsent(CMS_CACHE, key, mappingFunction);
}
/**
* 移除缓存值
* @param key 缓存键
*/
public static void removeCache(String key) {
CacheUtils.remove(CMS_CACHE, key);
}
/**
* 根据key前缀从缓存中移除
* @param key 缓存键
*/
public static void removeCacheByKeyPrefix(String key) {
CacheUtils.removeByKeyPrefix(CMS_CACHE, key);
}
}

View File

@@ -8,7 +8,7 @@ import com.jeesite.common.collect.ListUtils;
import com.jeesite.common.collect.SetUtils;
import com.jeesite.common.io.ResourceUtils;
import com.jeesite.common.lang.StringUtils;
import com.jeesite.modules.cms.entity.FileTemplete;
import com.jeesite.modules.cms.entity.FileTemplate;
import org.springframework.core.io.Resource;
import java.io.IOException;
@@ -20,30 +20,30 @@ import java.util.Set;
* @author 长春叭哥ThinkGem
* @version 2020-7-7
*/
public class FileTempleteUtils {
public class FileTemplateUtils {
/**
* 获取模版文件
* @param fileName
* @param fileName 模块名称
*/
public static FileTemplete getFileTempleteByResource(String fileName) {
public static FileTemplate getFileTemplateByResource(String fileName) {
if (!StringUtils.startsWith(fileName, "views/modules/cmsfront")) {
fileName = "views/modules/cmsfront/themes/default/index.html";
}
Resource resource = ResourceUtils.getResource(fileName);
return new FileTemplete(resource, fileName);
return new FileTemplate(resource, fileName);
}
/**
* 获取模板文件集合
* @param path 前缀路径
*/
public static List<FileTemplete> getFileTempleteListByPath(String path) throws IOException {
List<FileTemplete> list = ListUtils.newArrayList();
public static List<FileTemplate> getFileTemplateListByPath(String path) throws IOException {
List<FileTemplate> list = ListUtils.newArrayList();
Resource[] resources = ResourceUtils.getResources("classpath*:" + path + "/**/*.html");
for (Resource resource : resources) {
if (resource.exists()) {
list.add(new FileTemplete(resource, path));
list.add(new FileTemplate(resource, path));
}
}
return list;
@@ -53,14 +53,14 @@ public class FileTempleteUtils {
* 获取模板文件相关属性含目录
* @param path 前缀路径
*/
public static List<FileTemplete> getFileTempleteListForEdit(String path) throws IOException {
public static List<FileTemplate> getFileTemplateListForEdit(String path) throws IOException {
List<FileTemplete> list = getFileTempleteListByPath(path);
Set<FileTemplete> set = SetUtils.newLinkedHashSet();
List<FileTemplate> list = getFileTemplateListByPath(path);
Set<FileTemplate> set = SetUtils.newLinkedHashSet();
// 获取目录
list.forEach(e -> {
set.add(new FileTemplete(e));
set.add(new FileTemplate(e));
});
set.addAll(list);

View File

@@ -14,11 +14,12 @@ import com.jeesite.modules.cms.entity.Category;
import com.jeesite.modules.cms.entity.Site;
import com.jeesite.modules.cms.service.ArticleService;
import com.jeesite.modules.cms.service.CategoryService;
import com.jeesite.modules.cms.service.FileTempleteService;
import com.jeesite.modules.cms.service.FileTemplateService;
import com.jeesite.modules.cms.utils.CmsUtils;
import com.jeesite.modules.sys.utils.UserUtils;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.validation.annotation.Validated;
@@ -27,8 +28,6 @@ import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
@@ -41,12 +40,15 @@ import java.util.List;
@RequestMapping(value = "${adminPath}/cms/article")
public class ArticleController extends BaseController {
@Autowired
private ArticleService articleService;
@Autowired
private CategoryService categoryService;
@Autowired
private FileTempleteService fileTempleteService;
private final ArticleService articleService;
private final CategoryService categoryService;
private final FileTemplateService fileTemplateService;
public ArticleController(ArticleService articleService, CategoryService categoryService, FileTemplateService fileTemplateService) {
this.articleService = articleService;
this.categoryService = categoryService;
this.fileTemplateService = fileTemplateService;
}
/**
* 获取数据
@@ -58,7 +60,6 @@ public class ArticleController extends BaseController {
/**
* 查询列表
* @throws IOException
*/
@RequiresPermissions("cms:article:view")
@RequestMapping(value = { "list", "" })
@@ -73,7 +74,7 @@ public class ArticleController extends BaseController {
Page<Article> page = new Page<>(1, 1, -1);
article.setPage(page);
page = articleService.findPage(article);
if (page.getList().size() > 0) {
if (!page.getList().isEmpty()) {
article = page.getList().get(0);
article.setArticleData(articleService.get(new ArticleData(article.getId())));
}
@@ -116,7 +117,6 @@ public class ArticleController extends BaseController {
/**
* 查看编辑表单
* @throws IOException
*/
@RequiresPermissions("cms:article:view")
@RequestMapping(value = "form")
@@ -126,7 +126,7 @@ public class ArticleController extends BaseController {
categoryParam.setSite(new Site(Site.getCurrentSiteCode()));
categoryParam.setParentCode(article.getCategory().getCategoryCode());
List<Category> list = categoryService.findList(categoryParam);
if (list.size() > 0) {
if (!list.isEmpty()) {
article.setCategory(null); // 不允许在父节点上添加文章
} else {
article.setCategory(CmsUtils.getCategory(article.getCategory().getCategoryCode()));
@@ -135,7 +135,7 @@ public class ArticleController extends BaseController {
if (StringUtils.isBlank(article.getId())) {
article.setStatus(Article.STATUS_DRAFT);
}
model.addAttribute("contentViewList", fileTempleteService.getTempleteContentDict(Article.DEFAULT_TEMPLATE));
model.addAttribute("contentViewList", fileTemplateService.getTemplateContentDict(Article.DEFAULT_TEMPLATE));
model.addAttribute("article_DEFAULT_TEMPLATE", Article.DEFAULT_TEMPLATE);
model.addAttribute("article", article);
CmsUtils.addViewConfigAttribute(model, article.getCategory());

View File

@@ -14,12 +14,12 @@ import com.jeesite.modules.cms.entity.Article;
import com.jeesite.modules.cms.entity.Category;
import com.jeesite.modules.cms.entity.Site;
import com.jeesite.modules.cms.service.CategoryService;
import com.jeesite.modules.cms.service.FileTempleteService;
import com.jeesite.modules.cms.service.FileTemplateService;
import com.jeesite.modules.cms.utils.CmsUtils;
import com.jeesite.modules.sys.utils.DictUtils;
import javax.servlet.http.HttpServletRequest;
import org.apache.shiro.authz.annotation.Logical;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.validation.annotation.Validated;
@@ -28,7 +28,6 @@ import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.util.List;
import java.util.Map;
@@ -42,11 +41,13 @@ import java.util.Map;
@RequestMapping(value = "${adminPath}/cms/category")
public class CategoryController extends BaseController {
@Autowired
private CategoryService categoryService;
private final CategoryService categoryService;
private final FileTemplateService fileTemplateService;
@Autowired
private FileTempleteService fileTempleteService;
public CategoryController(CategoryService categoryService, FileTemplateService fileTemplateService) {
this.categoryService = categoryService;
this.fileTemplateService = fileTemplateService;
}
/**
* 获取数据
@@ -108,7 +109,6 @@ public class CategoryController extends BaseController {
/**
* 查看编辑表单
* @throws IOException
*/
@RequiresPermissions("cms:category:view")
@RequestMapping(value = "form")
@@ -121,7 +121,7 @@ public class CategoryController extends BaseController {
Category categoryChild = new Category();
categoryChild.setParent(new Category(category.getParentCode()));
List<Category> list = categoryService.findList(category);
if (list.size() > 0) {
if (!list.isEmpty()) {
category.setTreeSort(list.get(list.size() - 1).getTreeSort());
if (category.getTreeSort() != null) {
category.setTreeSort(category.getTreeSort() + 30);
@@ -157,9 +157,9 @@ public class CategoryController extends BaseController {
if (category.getIsNeedAudit() == null) {
category.setIsNeedAudit(Global.NO);
}
model.addAttribute("listViewList", fileTempleteService.getTempleteContentDict(Category.DEFAULT_TEMPLATE));
model.addAttribute("listViewList", fileTemplateService.getTemplateContentDict(Category.DEFAULT_TEMPLATE));
model.addAttribute("category_DEFAULT_TEMPLATE", Category.DEFAULT_TEMPLATE);
model.addAttribute("contentViewList", fileTempleteService.getTempleteContentDict(Article.DEFAULT_TEMPLATE));
model.addAttribute("contentViewList", fileTemplateService.getTemplateContentDict(Article.DEFAULT_TEMPLATE));
model.addAttribute("article_DEFAULT_TEMPLATE", Article.DEFAULT_TEMPLATE);
model.addAttribute("category", category);
return "modules/cms/categoryForm";
@@ -274,7 +274,6 @@ public class CategoryController extends BaseController {
* 获取树结构数据
* @param excludeCode 排除的Code
* @param isShowCode 是否显示编码true or 1显示在左侧2显示在右侧false or null不显示
* @return
*/
@RequiresPermissions(value = {"cms:category:view", "cms:article:view"}, logical = Logical.OR)
@RequestMapping(value = "treeData")

View File

@@ -19,19 +19,28 @@ import com.jeesite.common.web.BaseController;
@Controller
@RequestMapping(value = "${adminPath}/cms")
public class CmsIndexController extends BaseController {
/**
* 管理内容页
*/
@RequiresPermissions("cms:view")
@RequestMapping(value = "index")
public String index() {
return "modules/cms/cmsIndex";
}
/**
* 查看内容页
*/
@RequiresPermissions("cms:view")
@RequestMapping(value = "view")
public String view(Model model) {
return "modules/cms/cmsView";
}
/**
* 空内容页面
*/
@RequiresPermissions("cms:view")
@RequestMapping(value = "none")
public String none() {

View File

@@ -4,11 +4,14 @@
*/
package com.jeesite.modules.cms.web;
import com.jeesite.common.config.Global;
import com.jeesite.common.entity.Page;
import com.jeesite.common.web.BaseController;
import com.jeesite.modules.cms.entity.Comment;
import com.jeesite.modules.cms.service.CommentService;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.validation.annotation.Validated;
@@ -17,12 +20,6 @@ import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.jeesite.common.config.Global;
import com.jeesite.common.entity.Page;
import com.jeesite.common.web.BaseController;
import com.jeesite.modules.cms.entity.Comment;
import com.jeesite.modules.cms.service.CommentService;
/**
* 文章评论表Controller
* @author 长春叭哥、ThinkGem
@@ -32,9 +29,12 @@ import com.jeesite.modules.cms.service.CommentService;
@RequestMapping(value = "${adminPath}/cms/comment")
public class CommentController extends BaseController {
@Autowired
private CommentService commentService;
private final CommentService commentService;
public CommentController(CommentService commentService) {
this.commentService = commentService;
}
/**
* 获取数据
*/
@@ -120,5 +120,5 @@ public class CommentController extends BaseController {
commentService.delete(comment);
return renderResult(Global.TRUE, text("删除文章评论表成功!"));
}
}

View File

@@ -4,33 +4,21 @@
*/
package com.jeesite.modules.cms.web;
import java.io.File;
import java.io.IOException;
import java.util.List;
import java.util.Map;
import com.jeesite.common.codec.EncodeUtils;
import com.jeesite.common.config.Global;
import com.jeesite.common.io.FileUtils;
import com.jeesite.common.io.ResourceUtils;
import com.jeesite.common.lang.DateUtils;
import com.jeesite.common.lang.StringUtils;
import com.jeesite.modules.gen.entity.GenTable;
import com.jeesite.modules.gen.utils.GenTableUtils;
import com.jeesite.modules.gen.utils.GenUtils;
import com.jeesite.common.collect.ListUtils;
import com.jeesite.common.collect.MapUtils;
import com.jeesite.common.web.BaseController;
import com.jeesite.modules.cms.entity.FileTemplate;
import com.jeesite.modules.cms.entity.Site;
import com.jeesite.modules.cms.service.FileTemplateService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.jeesite.common.collect.ListUtils;
import com.jeesite.common.collect.MapUtils;
import com.jeesite.common.web.BaseController;
import com.jeesite.modules.cms.entity.FileTemplete;
import com.jeesite.modules.cms.entity.Site;
import com.jeesite.modules.cms.service.FileTempleteService;
import java.io.IOException;
import java.util.List;
import java.util.Map;
/**
* 模板管理
@@ -41,28 +29,28 @@ import com.jeesite.modules.cms.service.FileTempleteService;
@RequestMapping(value = "${adminPath}/cms/template")
public class FileTemplateController extends BaseController {
@Autowired
private FileTempleteService fileTempleteService;
private final FileTemplateService fileTemplateService;
public FileTemplateController(FileTemplateService fileTemplateService) {
this.fileTemplateService = fileTemplateService;
}
/**
* 模版管理页
*/
@RequiresPermissions("cms:template:edit")
@RequestMapping(value = { "list", "" })
public String index() {
return "modules/cms/tplIndex";
}
// @RequiresPermissions("cms:template:edit")
// @RequestMapping(value = "tree")
// public String tree(Model model) throws IOException {
// //根据系统默认的主题获取模板地址
// model.addAttribute("templateList", fileTempleteService
// .getFileTempleteListForEdit(Site.TEMPLETE_BASE_DIRECTION + "/" + "default"));
// return "modules/cms/tplTree";
// }
/**
* 模版查看页
*/
@RequiresPermissions("cms:template:edit")
@RequestMapping(value = "form")
public String form(String name, Model model) throws IOException {
model.addAttribute("template", fileTempleteService.getFileTemplete(name));
model.addAttribute("template", fileTemplateService.getFileTemplate(name));
return "modules/cms/tplForm";
}
@@ -70,7 +58,7 @@ public class FileTemplateController extends BaseController {
@RequestMapping(value = "saveFileTemplate")
@ResponseBody
public String saveFileTemplate(String fileName, String fileContent) throws IOException {
FileTemplete template = fileTempleteService.getFileTemplete(fileName);
FileTemplate template = fileTemplateService.getFileTemplate(fileName);
String newFileName = FileUtils.path(FileUtils.getWebappPath() + "/WEB-INF/classes/" + fileName);
File templateFile = template.resource().getFile();
if (templateFile.getAbsoluteFile().exists()) {
@@ -86,7 +74,7 @@ public class FileTemplateController extends BaseController {
@RequestMapping(value = "deleteFileTemplate")
@ResponseBody
public String deleteFileTemplate(String fileName) throws IOException {
FileTemplete template = fileTempleteService.getFileTemplete(fileName);
FileTemplate template = fileTemplateService.getFileTemplate(fileName);
File templateFile = template.resource().getFile();
if (templateFile.getAbsoluteFile().exists()) {
FileUtils.deleteFile(templateFile.getAbsolutePath());
@@ -95,6 +83,9 @@ public class FileTemplateController extends BaseController {
return renderResult(Global.FALSE, "模版文件不存在!");
}*/
/**
* 模版帮助页
*/
@RequiresPermissions("cms:template:edit")
@RequestMapping(value = "help")
public String help() {
@@ -109,9 +100,9 @@ public class FileTemplateController extends BaseController {
@ResponseBody
public List<Map<String, Object>> treeData() throws IOException {
List<Map<String, Object>> mapList = ListUtils.newArrayList();
List<FileTemplete> listFileTemplete = fileTempleteService.getFileTempleteListForEdit(Site.TEMPLETE_BASE_DIRECTION);
for (int i = 0; i < listFileTemplete.size(); i++) {
FileTemplete e = listFileTemplete.get(i);
List<FileTemplate> listFileTemplate = fileTemplateService.getFileTemplateListForEdit(Site.TEMPLATE_BASE_DIRECTION);
for (int i = 0; i < listFileTemplate.size(); i++) {
FileTemplate e = listFileTemplate.get(i);
Map<String, Object> map = MapUtils.newHashMap();
map.put("id", e.getFilePath() + "/" + e.getFileName());
map.put("isDirectory", e.isDirectory());

View File

@@ -4,11 +4,14 @@
*/
package com.jeesite.modules.cms.web;
import com.jeesite.common.config.Global;
import com.jeesite.common.entity.Page;
import com.jeesite.common.web.BaseController;
import com.jeesite.modules.cms.entity.Report;
import com.jeesite.modules.cms.service.ReportService;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.validation.annotation.Validated;
@@ -17,12 +20,6 @@ import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.jeesite.common.config.Global;
import com.jeesite.common.entity.Page;
import com.jeesite.common.web.BaseController;
import com.jeesite.modules.cms.entity.Report;
import com.jeesite.modules.cms.service.ReportService;
/**
* 内容举报表Controller
* @author 长春叭哥、ThinkGem
@@ -32,9 +29,12 @@ import com.jeesite.modules.cms.service.ReportService;
@RequestMapping(value = "${adminPath}/cms/report")
public class ReportController extends BaseController {
@Autowired
private ReportService reportService;
private final ReportService reportService;
public ReportController(ReportService reportService) {
this.reportService = reportService;
}
/**
* 获取数据
*/
@@ -120,5 +120,5 @@ public class ReportController extends BaseController {
reportService.delete(report);
return renderResult(Global.TRUE, text("删除内容举报表成功!"));
}
}

View File

@@ -8,14 +8,11 @@ import com.jeesite.common.config.Global;
import com.jeesite.common.entity.Page;
import com.jeesite.common.lang.StringUtils;
import com.jeesite.common.web.BaseController;
import com.jeesite.common.web.CookieUtils;
import com.jeesite.modules.cms.entity.Site;
import com.jeesite.modules.cms.service.FileTempleteService;
import com.jeesite.modules.cms.service.FileTemplateService;
import com.jeesite.modules.cms.service.SiteService;
import com.jeesite.modules.sys.utils.CorpUtils;
import com.jeesite.modules.sys.utils.UserUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.validation.annotation.Validated;
@@ -37,11 +34,13 @@ import java.io.IOException;
@RequestMapping(value = "${adminPath}/cms/site")
public class SiteController extends BaseController {
@Autowired
private SiteService siteService;
private final SiteService siteService;
private final FileTemplateService fileTemplateService;
@Autowired
private FileTempleteService fileTempleteService;
public SiteController(SiteService siteService, FileTemplateService fileTemplateService) {
this.siteService = siteService;
this.fileTemplateService = fileTemplateService;
}
/**
* 获取数据
@@ -81,7 +80,7 @@ public class SiteController extends BaseController {
@RequiresPermissions("cms:site:view")
@RequestMapping(value = "form")
public String form(Site site, Model model) throws IOException {
model.addAttribute("indexViewList", fileTempleteService.getTempleteContentDict(Site.DEFAULT_TEMPLATE));
model.addAttribute("indexViewList", fileTemplateService.getTemplateContentDict(Site.DEFAULT_TEMPLATE));
model.addAttribute("site_DEFAULT_TEMPLATE", Site.DEFAULT_TEMPLATE);
model.addAttribute("site", site);
model.addAttribute("demos", site);

View File

@@ -16,13 +16,12 @@ import com.jeesite.modules.cms.service.CategoryService;
import com.jeesite.modules.cms.service.CommentService;
import com.jeesite.modules.cms.utils.CmsUtils;
import com.jeesite.modules.sys.utils.ValidCodeUtils;
import org.springframework.beans.factory.annotation.Autowired;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Date;
import java.util.List;
@@ -35,12 +34,15 @@ import java.util.List;
@RequestMapping(value = "${frontPath}")
public class FrontController extends BaseController {
@Autowired
private CategoryService categoryService;
@Autowired
private ArticleService articleService;
@Autowired
private CommentService commentService;
private final CategoryService categoryService;
private final ArticleService articleService;
private final CommentService commentService;
public FrontController(CategoryService categoryService, ArticleService articleService, CommentService commentService) {
this.categoryService = categoryService;
this.articleService = articleService;
this.commentService = commentService;
}
/**
* 主站首页
@@ -75,7 +77,7 @@ public class FrontController extends BaseController {
// 否则显示子站第一个栏目
List<Category> mainNavList = CmsUtils.getMainNavList(siteCode);
if (mainNavList.size() > 0) {
if (!mainNavList.isEmpty()) {
String firstCategoryCode = CmsUtils.getMainNavList(siteCode).get(0).getId();
return REDIRECT + frontPath + "/list-" + firstCategoryCode + ".html";
}
@@ -142,7 +144,7 @@ public class FrontController extends BaseController {
if (Category.SHOW_MODES_CENTENT_LIST.equals(category.getShowModes()) || categoryList.size() <= 1) {
// 有子栏目并展现方式为2则获取第一个子栏目无子栏目则获取同级分类列表。
if (categoryList.size() > 0) {
if (!categoryList.isEmpty()) {
category = categoryList.get(0);
}
@@ -231,15 +233,15 @@ public class FrontController extends BaseController {
// 文章模型
if ("article".equals(category.getModuleType())) {
// // 获取当前级别的栏目列表
// List<Category> categoryList = Lists.newArrayList();
//// if (category.getIsRoot()){
//// categoryList.add(category);
//// }else{
//// categoryList = categoryService.findListByParentCode(category.getParentCode(), category.getSite().getId());
// categoryList = CmsUtils.getCategoryList(category.getSite().getSiteCode(), category.getParentCode(), -1, null);
//// }
// model.addAttribute("categoryList", categoryList);
/*// 获取当前级别的栏目列表
List<Category> categoryList = ListUtils.newArrayList();
// if (category.getIsRoot()){
// categoryList.add(category);
// }else{
// categoryList = categoryService.findListByParentCode(category.getParentCode(), category.getSite().getId());
categoryList = CmsUtils.getCategoryList(category.getSite().getSiteCode(), category.getParentCode(), -1, null);
// }
model.addAttribute("categoryList", categoryList);*/
// 获取文章
Article article = null;
@@ -254,7 +256,7 @@ public class FrontController extends BaseController {
Article entity = new Article(category);
entity.setPage(page);
page = articleService.findPage(entity);
if (page.getList().size() > 0) {
if (!page.getList().isEmpty()) {
article = page.getList().get(0);
article.setArticleData(articleService.get(new ArticleData(article.getId())));
}

View File

@@ -4,16 +4,6 @@
*/
package com.jeesite.modules.cmsfront.web;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import com.jeesite.common.collect.MapUtils;
import com.jeesite.common.entity.Page;
import com.jeesite.common.lang.StringUtils;
@@ -22,6 +12,13 @@ import com.jeesite.common.web.BaseController;
import com.jeesite.modules.cms.entity.Site;
import com.jeesite.modules.cms.service.ArticleService;
import com.jeesite.modules.cms.utils.CmsUtils;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import java.util.Map;
/**
* 网站搜索Controller
@@ -32,9 +29,12 @@ import com.jeesite.modules.cms.utils.CmsUtils;
@RequestMapping(value = "${frontPath}/search")
public class FrontSearchController extends BaseController{
@Autowired
private ArticleService articleService;
private final ArticleService articleService;
public FrontSearchController(ArticleService articleService) {
this.articleService = articleService;
}
/**
* 全站搜索
* @param t 搜索类型(article、guestbook)

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