Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
不是太高的手
SPTools
提交
db4d7fb3
S
SPTools
项目概览
不是太高的手
/
SPTools
通知
4
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
SPTools
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
db4d7fb3
编写于
9月 13, 2020
作者:
小
小柒2012
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
✨
简单的文档管理
上级
a91270e0
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
285 addition
and
1 deletion
+285
-1
pom.xml
pom.xml
+39
-0
src/main/java/com/tools/Application.java
src/main/java/com/tools/Application.java
+1
-0
src/main/java/com/tools/module/document/util/OpenOfficeService.java
...ava/com/tools/module/document/util/OpenOfficeService.java
+36
-0
src/main/java/com/tools/module/document/web/ConverterController.java
...va/com/tools/module/document/web/ConverterController.java
+89
-0
src/main/resources/application-dev.properties
src/main/resources/application-dev.properties
+17
-1
src/main/resources/templates/document/list.html
src/main/resources/templates/document/list.html
+103
-0
未找到文件。
pom.xml
浏览文件 @
db4d7fb3
...
...
@@ -9,6 +9,8 @@
<packaging>
war
</packaging>
<properties>
<openoffice.version>
4.1.2
</openoffice.version>
<jodconverter.version>
4.3.0
</jodconverter.version>
<project.build.sourceEncoding>
UTF-8
</project.build.sourceEncoding>
<java.version>
1.8
</java.version>
</properties>
...
...
@@ -196,6 +198,43 @@
<artifactId>
activiti-spring-boot-starter-basic
</artifactId>
<version>
6.0.0
</version>
</dependency>
<!-- openoffice -->
<dependency>
<groupId>
org.openoffice
</groupId>
<artifactId>
unoil
</artifactId>
<version>
${openoffice.version}
</version>
</dependency>
<dependency>
<groupId>
org.openoffice
</groupId>
<artifactId>
ridl
</artifactId>
<version>
${openoffice.version}
</version>
</dependency>
<dependency>
<groupId>
org.openoffice
</groupId>
<artifactId>
jurt
</artifactId>
<version>
${openoffice.version}
</version>
</dependency>
<dependency>
<groupId>
org.openoffice
</groupId>
<artifactId>
juh
</artifactId>
<version>
${openoffice.version}
</version>
</dependency>
<dependency>
<groupId>
org.jodconverter
</groupId>
<artifactId>
jodconverter-local
</artifactId>
<version>
${jodconverter.version}
</version>
</dependency>
<dependency>
<groupId>
org.jodconverter
</groupId>
<artifactId>
jodconverter-core
</artifactId>
<version>
${jodconverter.version}
</version>
</dependency>
<dependency>
<groupId>
org.jodconverter
</groupId>
<artifactId>
jodconverter-spring-boot-starter
</artifactId>
<version>
${jodconverter.version}
</version>
</dependency>
</dependencies>
<build>
<finalName>
picture-bed
</finalName>
...
...
src/main/java/com/tools/Application.java
浏览文件 @
db4d7fb3
...
...
@@ -23,6 +23,7 @@ import springfox.documentation.swagger2.annotations.EnableSwagger2;
@EnableSwagger2
@SpringBootApplication
(
exclude
=
{
SecurityAutoConfiguration
.
class
})
public
class
Application
extends
SpringBootServletInitializer
{
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
Application
.
class
);
public
static
void
main
(
String
[]
args
)
{
...
...
src/main/java/com/tools/module/document/util/OpenOfficeService.java
0 → 100644
浏览文件 @
db4d7fb3
package
com.tools.module.document.util
;
import
org.jodconverter.core.office.OfficeException
;
import
org.jodconverter.core.office.OfficeUtils
;
import
org.jodconverter.local.JodConverter
;
import
org.jodconverter.local.office.LocalOfficeManager
;
import
java.io.File
;
/**
* OpenOffice 文件转换
*/
public
class
OpenOfficeService
{
static
{
LocalOfficeManager
.
builder
()
.
portNumbers
(
2002
)
.
build
();
}
public
static
void
main
(
String
[]
args
)
{
LocalOfficeManager
officeManager
=
LocalOfficeManager
.
install
();
try
{
officeManager
.
start
();
JodConverter
.
convert
(
new
File
(
"F:\\前端.txt"
))
.
to
(
new
File
(
"E:\\home\\1.pdf"
))
.
execute
();
}
catch
(
OfficeException
e
)
{
e
.
printStackTrace
();
}
finally
{
OfficeUtils
.
stopQuietly
(
officeManager
);
}
}
}
\ No newline at end of file
src/main/java/com/tools/module/document/web/ConverterController.java
0 → 100644
浏览文件 @
db4d7fb3
package
com.tools.module.document.web
;
import
cn.hutool.core.date.DateUtil
;
import
cn.hutool.core.io.FileUtil
;
import
cn.hutool.core.util.IdUtil
;
import
com.tools.common.config.AbstractController
;
import
com.tools.common.constant.SystemConstant
;
import
com.tools.common.model.Result
;
import
io.swagger.annotations.Api
;
import
org.jodconverter.core.DocumentConverter
;
import
org.jodconverter.core.office.OfficeException
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.multipart.MultipartFile
;
import
javax.annotation.Resource
;
import
java.io.File
;
@Api
(
tags
=
"文档管理"
)
@RestController
@RequestMapping
(
"document"
)
public
class
ConverterController
extends
AbstractController
{
@Value
(
"${file.path}"
)
private
String
filePath
;
@Resource
private
DocumentConverter
documentConverter
;
/**
* 文件上传
*/
@RequestMapping
(
"/upload"
)
public
Result
upload
(
MultipartFile
file
)
{
try
{
if
(
file
!=
null
){
File
parentFile
=
createParentFile
();
String
fileName
=
file
.
getOriginalFilename
();
String
suffix
=
fileName
.
substring
(
fileName
.
lastIndexOf
(
"."
));
String
uuid
=
IdUtil
.
simpleUUID
();
fileName
=
uuid
+
suffix
;
File
imageFile
=
new
File
(
parentFile
,
fileName
);
FileUtil
.
writeFromStream
(
file
.
getInputStream
(),
imageFile
);
return
Result
.
ok
();
}
else
{
return
Result
.
error
();
}
}
catch
(
Exception
e
)
{
return
Result
.
error
();
}
}
/**
* 文件上传
*/
@RequestMapping
(
"converter"
)
public
Result
converter
()
{
try
{
documentConverter
.
convert
(
new
File
(
"F:\\前端.txt"
))
.
to
(
new
File
(
"E:\\home\\1.pdf"
)).
execute
();
}
catch
(
OfficeException
e
)
{
logger
.
error
(
"转换失败{}"
,
e
);
return
Result
.
error
();
}
return
Result
.
ok
();
}
/**
* 创建多级文件夹
* @return
*/
public
File
createParentFile
(){
File
parentFile
=
new
File
(
filePath
+
SystemConstant
.
SF_FILE_SEPARATOR
+
DateUtil
.
thisYear
());
if
(!
parentFile
.
exists
())
{
parentFile
.
mkdirs
();
}
parentFile
=
new
File
(
parentFile
,(
DateUtil
.
thisMonth
()+
1
)+
""
);
if
(!
parentFile
.
exists
())
{
parentFile
.
mkdirs
();
}
parentFile
=
new
File
(
parentFile
,
DateUtil
.
thisDayOfMonth
()+
""
);
if
(!
parentFile
.
exists
())
{
parentFile
.
mkdirs
();
}
return
parentFile
;
}
}
src/main/resources/application-dev.properties
浏览文件 @
db4d7fb3
...
...
@@ -167,9 +167,25 @@ wx.miniapp.token= **********
wx.miniapp.aesKey
=
**********
wx.miniapp.msgDataFormat
=
JSON
# ===================================
# 工作流
# ===================================
#每次应用启动不检查Activiti数据表是否存在及版本号是否匹配,提升应用启动速度
spring.activiti.database-schema-update
=
true
#保存历史数据级别设置为full最高级别,便于历史数据的追溯
spring.activiti.history-level
=
full
# 检测身份信息表是否存在 默认值即可
spring.activiti.db-identity-used
=
false
\ No newline at end of file
spring.activiti.db-identity-used
=
false
# ===================================
# openOffice
# ===================================
# https://github.com/sbraconnier/jodconverter
jodconverter.local.enabled
=
true
# 设置openOffice主目录 默认会自动读取
jodconverter.local.office-home
=
C:/Program Files (x86)/OpenOffice 4
# 开启多个openOffice进程,每个端口对应一个进程
jodconverter.local.portNumbers
=
8100
# openOffice进程重启前的最大进程数
jodconverter.local.maxTasksPerProcess
=
100
\ No newline at end of file
src/main/resources/templates/document/list.html
0 → 100644
浏览文件 @
db4d7fb3
<!DOCTYPE html>
<html
lang=
"en"
xmlns:th=
"http://www.thymeleaf.org"
>
<head
th:replace=
"common/head :: head(link)"
/>
<style>
.home-container
{
width
:
600px
;
margin
:
0
auto
;
margin-top
:
100px
;
position
:
relative
;
}
</style>
<body>
<div
id=
"wrapper"
v-cloak
>
<div
class=
"home-container"
>
<template>
<tabs>
<tab-pane
@
click=
"tab(0)"
icon=
"md-build"
label=
"缩短网址"
/>
<i-form
ref=
"checkForm"
:model=
"tinyUrl"
:rules=
"ruleValidate"
>
<form-item
prop=
"url"
>
<i-input
search
enter-button=
"缩短网址"
v-model=
"tinyUrl.url"
@
on-search=
"create()"
placeholder=
"请输入长网址"
/>
</form-item>
<form-item
label=
"选择失效时间:"
prop=
"gmtExpire"
>
<radio-group
v-model=
"tinyUrl.expire"
>
<radio
v-for=
"item in expire"
:label=
"item.code"
>
{{item.name}}
</radio>
</radio-group>
</form-item>
</i-form>
</tab-pane>
<tab-pane
@
click=
"tab(1)"
icon=
"ios-redo"
label=
"还原网址"
>
<i-input
search
enter-button=
"还原网址"
@
on-search=
"restore()"
placeholder=
"请输入短网址"
/>
</tab-pane>
</tabs>
<div
v-show=
"keyShow"
>
<i-input
id=
"URL"
v-model=
"tinyUrl.tinykey"
style=
"width: 500px"
></i-input>
<i-button
data-clipboard-target=
"#URL"
class=
"btn"
@
click=
"copy()"
type=
"primary"
>
复制
</i-button>
</div>
</template>
</div>
</div>
<div
th:replace=
"common/foot :: foot(clipboard)"
></div>
<script>
new
ClipboardJS
(
'
.btn
'
);
layui
.
use
([
"
okUtils
"
,
"
okLayer
"
],
function
()
{
var
okUtils
=
layui
.
okUtils
;
var
okLayer
=
layui
.
okLayer
;
var
vm
=
new
Vue
({
el
:
'
#wrapper
'
,
data
:{
tinyUrl
:{
expire
:
0
,
tinykey
:
''
},
keyShow
:
false
,
expire
:[{
"
code
"
:
1
,
"
name
"
:
"
1天
"
},{
"
code
"
:
3
,
"
name
"
:
"
3天
"
},{
"
code
"
:
7
,
"
name
"
:
"
7天
"
},{
"
code
"
:
30
,
"
name
"
:
"
30天
"
},{
"
code
"
:
0
,
"
name
"
:
"
永久
"
}],
ruleValidate
:
{
url
:
[
{
required
:
true
,
message
:
'
地址不能为空
'
,
trigger
:
'
blur
'
}
]
},
},
methods
:
{
create
:
function
()
{
var
that
=
this
;
vm
.
$refs
.
checkForm
.
validate
(
function
(
valid
){
if
(
valid
)
{
if
(
that
.
tinyUrl
.
expire
!=
0
){
that
.
tinyUrl
.
gmtExpire
=
okUtils
.
addData
(
that
.
tinyUrl
.
expire
)
}
else
{
that
.
tinyUrl
.
gmtExpire
=
"
2049-10-01 00:00:00
"
;
}
okUtils
.
ajax
(
"
/app/tinyUrl/save
"
,
"
post
"
,
that
.
tinyUrl
,
false
).
done
(
function
(
response
)
{
okLayer
.
msg
.
greenTick
(
"
生成成功
"
,
function
()
{
that
.
tinyUrl
.
tinykey
=
response
.
msg
;
that
.
keyShow
=
true
;
})
}).
fail
(
function
(
error
)
{
console
.
log
(
error
)
});
}
});
},
restore
:
function
(){
okLayer
.
msg
.
yellowQuestion
(
"
还原是不可能的,这辈子都不可能!!!
"
);
},
copy
:
function
(){
this
.
$Notice
.
success
({
title
:
'
复制成功
'
,
desc
:
'
小伙伴,赶紧尝试一下吧
'
});
},
tab
:
function
(
code
){
}
},
created
:
function
()
{
}
});
});
</script>
</body>
</html>
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录