Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
jinli gu
Springboot Plus
Commits
fa59b9c0
"...src/main/java/me/git@ustchcs.com:gujinli1118/eladmin.git" did not exist on "e37d485b4b5084528b07f88ade463543dfba16a3"
Commit
fa59b9c0
authored
Mar 10, 2018
by
xiandafu
Browse files
fileservice api
parent
6783adab
Changes
18
Hide whitespace changes
Inline
Side-by-side
admin-console/src/main/java/com/ibeetl/admin/console/web/DictConsoleController.java
View file @
fa59b9c0
...
@@ -159,7 +159,7 @@ public class DictConsoleController{
...
@@ -159,7 +159,7 @@ public class DictConsoleController{
context
.
putVar
(
"dicts"
,
dicts
);
context
.
putVar
(
"dicts"
,
dicts
);
JxlsHelper
.
getInstance
().
processTemplate
(
is
,
os
,
context
);
JxlsHelper
.
getInstance
().
processTemplate
(
is
,
os
,
context
);
//下载参考FileSystemContorller
//下载参考FileSystemContorller
return
JsonResult
.
success
(
item
.
get
Id
());
return
JsonResult
.
success
(
item
.
get
Path
());
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
throw
new
PlatformException
(
e
.
getMessage
());
throw
new
PlatformException
(
e
.
getMessage
());
}
}
...
...
admin-console/src/main/java/com/ibeetl/admin/console/web/UserConsoleController.java
View file @
fa59b9c0
...
@@ -299,7 +299,7 @@ public class UserConsoleController {
...
@@ -299,7 +299,7 @@ public class UserConsoleController {
context
.
putVar
(
"users"
,
users
);
context
.
putVar
(
"users"
,
users
);
JxlsHelper
.
getInstance
().
processTemplate
(
is
,
os
,
context
);
JxlsHelper
.
getInstance
().
processTemplate
(
is
,
os
,
context
);
//下载参考FileSystemContorller
//下载参考FileSystemContorller
return
JsonResult
.
success
(
item
.
get
Id
());
return
JsonResult
.
success
(
item
.
get
Path
());
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
throw
new
PlatformException
(
e
.
getMessage
());
throw
new
PlatformException
(
e
.
getMessage
());
}
}
...
...
admin-console/src/main/resources/application.properties
View file @
fa59b9c0
...
@@ -24,4 +24,5 @@ beetlsql.dbStyle=org.beetl.sql.core.db.MySqlStyle
...
@@ -24,4 +24,5 @@ beetlsql.dbStyle=org.beetl.sql.core.db.MySqlStyle
#beetlsql.basePackage=com.ibeetl,com.xxx.yourpackage
#beetlsql.basePackage=com.ibeetl,com.xxx.yourpackage
beetlsql.basePackage
=
com.ibeetl
beetlsql.basePackage
=
com.ibeetl
app.name
=
Spring Boot开发平台
app.name
=
Spring Boot开发平台
logging.pattern.console
=
%-4relative [%thread] %-5level %logger{256} %M %L - %msg%n
logging.pattern.console
=
%-4relative [%thread] %-5level %logger{256} %M %L - %msg%n
\ No newline at end of file
spring.devtools.restart.exclude
=
templates/**
\ No newline at end of file
admin-core/src/main/java/com/ibeetl/admin/core/conf/FileSystemConfig.java
View file @
fa59b9c0
...
@@ -5,12 +5,13 @@ import java.io.File;
...
@@ -5,12 +5,13 @@ import java.io.File;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean
;
import
org.springframework.context.ApplicationContext
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.core.env.Environment
;
import
org.springframework.core.env.Environment
;
import
com.ibeetl.admin.core.file.FileService
;
import
com.ibeetl.admin.core.file.FileService
;
import
com.ibeetl.admin.core.file.LocaFileService
;
import
com.ibeetl.admin.core.file.Loca
l
FileService
;
@Configuration
@Configuration
@ConditionalOnMissingBean
(
FileService
.
class
)
@ConditionalOnMissingBean
(
FileService
.
class
)
...
@@ -18,7 +19,7 @@ public class FileSystemConfig {
...
@@ -18,7 +19,7 @@ public class FileSystemConfig {
@Autowired
@Autowired
Environment
env
;
Environment
env
;
@Bean
@Bean
public
FileService
getFileService
()
{
public
FileService
getFileService
(
ApplicationContext
ctx
)
{
String
root
=
env
.
getProperty
(
"localFile.root"
);
String
root
=
env
.
getProperty
(
"localFile.root"
);
if
(
StringUtils
.
isEmpty
(
root
))
{
if
(
StringUtils
.
isEmpty
(
root
))
{
String
userDir
=
System
.
getProperty
(
"user.dir"
);
String
userDir
=
System
.
getProperty
(
"user.dir"
);
...
@@ -28,6 +29,6 @@ public class FileSystemConfig {
...
@@ -28,6 +29,6 @@ public class FileSystemConfig {
if
(!
f
.
exists
())
{
if
(!
f
.
exists
())
{
f
.
mkdirs
();
f
.
mkdirs
();
}
}
return
new
LocaFileService
(
root
);
return
new
Loca
l
FileService
(
ctx
,
root
);
}
}
}
}
admin-core/src/main/java/com/ibeetl/admin/core/dao/CoreFileDao.java
0 → 100644
View file @
fa59b9c0
package
com.ibeetl.admin.core.dao
;
import
org.beetl.sql.core.mapper.BaseMapper
;
import
com.ibeetl.admin.core.entity.CoreFile
;
public
interface
CoreFileDao
extends
BaseMapper
<
CoreFile
>
{
}
admin-core/src/main/java/com/ibeetl/admin/core/entity/BaseEntity.java
View file @
fa59b9c0
...
@@ -16,6 +16,7 @@ public class BaseEntity extends TailBean implements java.io.Serializable {
...
@@ -16,6 +16,7 @@ public class BaseEntity extends TailBean implements java.io.Serializable {
protected
final
static
String
ORACLE_CORE_SEQ_NAME
=
"core_seq"
;
protected
final
static
String
ORACLE_CORE_SEQ_NAME
=
"core_seq"
;
protected
final
static
String
ORACLE_AUDIT_SEQ_NAME
=
"audit_seq"
;
protected
final
static
String
ORACLE_AUDIT_SEQ_NAME
=
"audit_seq"
;
protected
final
static
String
ORACLE_FILE_SEQ_NAME
=
"file_seq"
;
@JsonAnyGetter
@JsonAnyGetter
public
Map
<
String
,
Object
>
getTails
(){
public
Map
<
String
,
Object
>
getTails
(){
return
super
.
getTails
();
return
super
.
getTails
();
...
...
admin-core/src/main/java/com/ibeetl/admin/core/entity/CoreFile.java
0 → 100644
View file @
fa59b9c0
package
com.ibeetl.admin.core.entity
;
import
java.util.Date
;
import
javax.validation.constraints.NotBlank
;
import
javax.validation.constraints.NotNull
;
import
javax.validation.constraints.Null
;
import
org.beetl.sql.core.annotatoin.AutoID
;
import
org.beetl.sql.core.annotatoin.SeqID
;
import
com.ibeetl.admin.core.util.ValidateConfig
;
import
org.beetl.sql.core.TailBean
;
import
java.math.*
;
import
com.ibeetl.admin.core.entity.BaseEntity
;
/*
*
* gen by Spring Boot2 Admin 2018-03-08
*/
public
class
CoreFile
extends
BaseEntity
{
@NotNull
(
message
=
"ID不能为空"
,
groups
=
ValidateConfig
.
UPDATE
.
class
)
@SeqID
(
name
=
ORACLE_CORE_SEQ_NAME
)
@AutoID
private
Long
id
;
// 文件名称
private
String
name
;
// 路径
private
String
path
;
// 业务ID
private
String
bizId
;
// 上传人id
private
Long
userId
;
// 创建时间
private
Date
createTime
;
private
Long
orgId
;
private
String
bizType
;
public
CoreFile
()
{
}
public
Long
getId
()
{
return
id
;
}
public
void
setId
(
Long
id
)
{
this
.
id
=
id
;
}
/**
* 文件名称
*
* @return
*/
public
String
getName
()
{
return
name
;
}
/**
* 文件名称
*
* @param name
*/
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
/**
* 路径
*
* @return
*/
public
String
getPath
()
{
return
path
;
}
/**
* 路径
*
* @param path
*/
public
void
setPath
(
String
path
)
{
this
.
path
=
path
;
}
/**
* 业务ID
*
* @return
*/
public
String
getBizId
()
{
return
bizId
;
}
/**
* 业务ID
*
* @param bizId
*/
public
void
setBizId
(
String
bizId
)
{
this
.
bizId
=
bizId
;
}
/**
* 上传人id
*
* @return
*/
public
Long
getUserId
()
{
return
userId
;
}
/**
* 上传人id
*
* @param userId
*/
public
void
setUserId
(
Long
userId
)
{
this
.
userId
=
userId
;
}
/**
* 创建时间
*
* @return
*/
public
Date
getCreateTime
()
{
return
createTime
;
}
/**
* 创建时间
*
* @param createTime
*/
public
void
setCreateTime
(
Date
createTime
)
{
this
.
createTime
=
createTime
;
}
public
Long
getOrgId
()
{
return
orgId
;
}
public
void
setOrgId
(
Long
orgId
)
{
this
.
orgId
=
orgId
;
}
public
String
getBizType
()
{
return
bizType
;
}
public
void
setBizType
(
String
bizType
)
{
this
.
bizType
=
bizType
;
}
}
admin-core/src/main/java/com/ibeetl/admin/core/file/DBIndexHelper.java
0 → 100644
View file @
fa59b9c0
package
com.ibeetl.admin.core.file
;
import
java.util.ArrayList
;
import
java.util.List
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
com.ibeetl.admin.core.dao.CoreFileDao
;
import
com.ibeetl.admin.core.entity.CoreFile
;
/**
* 从数据库搜索文档信息,对应core_file,和core_file_tag,目前先忽略tag功能
* @author xiandafu
*
*/
public
class
DBIndexHelper
{
CoreFileDao
fileDao
;
public
DBIndexHelper
(
CoreFileDao
fileDao
)
{
this
.
fileDao
=
fileDao
;
}
public
CoreFile
getFileItemByPath
(
String
path
)
{
CoreFile
t
=
new
CoreFile
();
t
.
setPath
(
path
);
CoreFile
dbData
=
fileDao
.
templateOne
(
t
);
return
dbData
;
}
public
CoreFile
getFileItemById
(
Long
id
)
{
CoreFile
dbData
=
fileDao
.
unique
(
id
);
return
dbData
;
}
public
void
createFileItem
(
CoreFile
file
,
List
<
FileTag
>
tags
)
{
fileDao
.
insert
(
file
);
if
(
tags
.
isEmpty
())
{
return
;
}
Long
fileId
=
file
.
getId
();
for
(
FileTag
tag:
tags
)
{
tag
.
setFileId
(
fileId
);
}
fileDao
.
getSQLManager
().
insertBatch
(
FileTag
.
class
,
tags
);
}
public
List
<
CoreFile
>
queryByUserId
(
Long
userId
,
List
<
FileTag
>
tags
){
List
<
CoreFile
>
dbDatas
=
fileDao
.
createQuery
().
lambda
().
andEq
(
CoreFile:
:
getUserId
,
userId
).
select
();
return
dbDatas
;
}
public
List
<
CoreFile
>
queryByBiz
(
String
bizType
,
String
bizId
){
CoreFile
template
=
new
CoreFile
();
template
.
setBizType
(
bizType
);
template
.
setBizId
(
bizId
);
List
<
CoreFile
>
dbDatas
=
fileDao
.
template
(
template
);
return
dbDatas
;
}
}
admin-core/src/main/java/com/ibeetl/admin/core/file/FileItem.java
View file @
fa59b9c0
...
@@ -3,23 +3,36 @@ package com.ibeetl.admin.core.file;
...
@@ -3,23 +3,36 @@ package com.ibeetl.admin.core.file;
import
java.io.OutputStream
;
import
java.io.OutputStream
;
public
abstract
class
FileItem
{
public
abstract
class
FileItem
{
String
name
;
protected
String
name
;
String
id
;
protected
String
path
;
boolean
isTemp
=
false
;
public
abstract
OutputStream
openOutpuStream
();
public
abstract
OutputStream
openOutpuStream
();
public
abstract
void
copy
(
OutputStream
os
);
public
abstract
void
delete
();
public
String
getName
()
{
public
String
getName
()
{
return
name
;
return
name
;
}
}
public
void
setName
(
String
name
)
{
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
this
.
name
=
name
;
}
}
public
String
get
Id
()
{
public
String
get
Path
()
{
return
id
;
return
path
;
}
}
public
void
set
Id
(
String
id
)
{
public
void
set
Path
(
String
path
)
{
this
.
id
=
id
;
this
.
path
=
path
;
}
}
public
boolean
isTemp
()
{
return
isTemp
;
}
public
void
setTemp
(
boolean
isTemp
)
{
this
.
isTemp
=
isTemp
;
}
}
}
admin-core/src/main/java/com/ibeetl/admin/core/file/FileService.java
View file @
fa59b9c0
package
com.ibeetl.admin.core.file
;
package
com.ibeetl.admin.core.file
;
import
java.io.InputStream
;
import
java.io.OutputStream
;
import
java.io.OutputStream
;
import
java.util.List
;
/**
/**
* 文件持久化,默认为文件系统,可以扩展到fastfds等
* 文件持久化,默认为文件系统,可以扩展到fastfds等
* @author xiandafu
* @author xiandafu
...
@@ -15,12 +15,26 @@ public interface FileService {
...
@@ -15,12 +15,26 @@ public interface FileService {
*/
*/
public
FileItem
createFileTemp
(
String
name
);
public
FileItem
createFileTemp
(
String
name
);
public
FileItem
getFileItem
(
String
id
);
/**
/**
*
* 创建一个持久的文档
* @param url
* @param name
* @param os
* @param bizType
* @param bizId
* @param userId
* @param orgId
* @param tags
* @return
*/
*/
public
void
copyTemp
(
String
url
,
OutputStream
os
);
public
FileItem
createFileItem
(
String
name
,
String
bizType
,
String
bizId
,
Long
userId
,
Long
orgId
,
List
<
FileTag
>
tags
);
public
FileItem
loadFileItemByPath
(
String
path
);
public
FileItem
getFileItemById
(
Long
id
);
public
List
<
FileItem
>
queryByUserId
(
Long
userId
,
List
<
FileTag
>
tags
);
public
List
<
FileItem
>
queryByBiz
(
String
bizType
,
String
bizId
);
}
}
admin-core/src/main/java/com/ibeetl/admin/core/file/FileTag.java
0 → 100644
View file @
fa59b9c0
package
com.ibeetl.admin.core.file
;
public
class
FileTag
{
String
name
;
String
value
;
Long
fileId
;
public
String
getName
()
{
return
name
;
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
public
String
getValue
()
{
return
value
;
}
public
void
setValue
(
String
value
)
{
this
.
value
=
value
;
}
public
Long
getFileId
()
{
return
fileId
;
}
public
void
setFileId
(
Long
fileId
)
{
this
.
fileId
=
fileId
;
}
}
admin-core/src/main/java/com/ibeetl/admin/core/file/LocaFileService.java
deleted
100644 → 0
View file @
6783adab
package
com.ibeetl.admin.core.file
;
import
java.io.File
;
import
java.io.FileInputStream
;
import
java.io.FileNotFoundException
;
import
java.io.FileOutputStream
;
import
java.io.IOException
;
import
java.io.OutputStream
;
import
java.util.Random
;
import
com.ibeetl.admin.core.util.PlatformException
;
public
class
LocaFileService
implements
FileService
{
String
root
=
null
;
public
LocaFileService
(
String
root
)
{
this
.
root
=
root
;
}
@Override
public
FileItem
getFileItem
(
String
id
)
{
FileItem
item
=
new
LocalFileItem
();
item
.
setId
(
id
);
item
.
setName
(
parseName
(
id
));
return
item
;
}
@Override
public
FileItem
createFileTemp
(
String
name
)
{
FileItem
item
=
new
LocalFileItem
();
String
fileName
=
name
+
"."
+
this
.
suffixTemp
();
item
.
setId
(
fileName
);
item
.
setName
(
name
);
return
item
;
}
@Override
public
void
copyTemp
(
String
id
,
OutputStream
os
)
{
File
file
=
new
File
(
root
+
File
.
separator
+
id
);
FileInputStream
input
=
null
;
try
{
input
=
new
FileInputStream
(
file
);
byte
[]
buf
=
new
byte
[
1024
];
int
bytesRead
;
while
((
bytesRead
=
input
.
read
(
buf
))
>
0
)
{
os
.
write
(
buf
,
0
,
bytesRead
);
}
file
.
delete
();
}
catch
(
Exception
ex
)
{
throw
new
PlatformException
(
"下载文件失败"
+
ex
);
}
finally
{
try
{
input
.
close
();
os
.
close
();
}
catch
(
IOException
e
)
{
// TODO Auto-generated catch block
e
.
printStackTrace
();
}
}
}
private
String
suffixTemp
()
{
// TODO,改成唯一算法
return
System
.
currentTimeMillis
()
+
""
+
new
Random
().
nextInt
(
10000
)+
".temp"
;
}
private
String
parseName
(
String
id
)
{
String
[]
array
=
id
.
split
(
"\\."
);
return
array
[
0
]+
"."
+
array
[
1
];
}
class
LocalFileItem
extends
FileItem
{
public
OutputStream
openOutpuStream
()
{
File
file
=
new
File
(
root
+
File
.
separator
+
id
);
try
{
file
.
createNewFile
();
FileOutputStream
fos
=
new
FileOutputStream
(
file
);
return
fos
;
}
catch
(
IOException
e
)
{
throw
new
PlatformException
(
"Open stream error "
+
id
);
}
}
}
}
admin-core/src/main/java/com/ibeetl/admin/core/file/LocalFileItem.java
0 → 100644
View file @
fa59b9c0
package
com.ibeetl.admin.core.file
;
import
java.io.File
;
import
java.io.FileInputStream
;
import
java.io.FileOutputStream
;
import
java.io.IOException
;
import
java.io.OutputStream
;
import
com.ibeetl.admin.core.util.PlatformException
;
class
LocalFileItem
extends
PersistFileItem
{
String
root
=
null
;
public
LocalFileItem
(
String
root
)
{
this
.
root
=
root
;
}
public
OutputStream
openOutpuStream
()
{
File
file
=
new
File
(
root
+
File
.
separator
+
path
);
try
{
if
(!
file
.
exists
())
{
file
.
createNewFile
();
}
FileOutputStream
fos
=
new
FileOutputStream
(
file
);
return
fos
;
}
catch
(
IOException
e
)
{
throw
new
PlatformException
(
"Open stream error "
+
path
);
}
}
@Override
public
void
copy
(
OutputStream
os
)
{
File
file
=
new
File
(
root
+
File
.
separator
+
path
);
FileInputStream
input
=
null
;
try
{
input
=
new
FileInputStream
(
file
);
byte
[]
buf
=
new
byte
[
1024
];
int
bytesRead
;
while
((
bytesRead
=
input
.
read
(
buf
))
>
0
)
{
os
.
write
(
buf
,
0
,
bytesRead
);
}
}
catch
(
Exception
ex
)
{
throw
new
PlatformException
(
"下载文件失败"
+
ex
);
}
finally
{
try
{
input
.
close
();
os
.
close
();
}
catch
(
IOException
e
)
{
// TODO Auto-generated catch block
e
.
printStackTrace
();
}
}
if
(
path
.
startsWith
(
"temp"
))
{
this
.
delete
();
}
}
@Override
public
void
delete
()
{
File
file
=
new
File
(
root
+
File
.
separator
+
path
);
file
.
delete
();
}
}
admin-core/src/main/java/com/ibeetl/admin/core/file/LocalFileService.java
0 → 100644
View file @
fa59b9c0
package
com.ibeetl.admin.core.file
;
import
java.io.File
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Random
;
import
org.springframework.context.ApplicationContext
;
import
com.ibeetl.admin.core.dao.CoreFileDao
;
import
com.ibeetl.admin.core.entity.CoreFile
;
import
com.ibeetl.admin.core.util.DateUtil
;
/**
* 一个本地文件系统,管理临时文件和用户文件
* @author xiandafu
*
*/
public
class
LocalFileService
implements
FileService
{
DBIndexHelper
dbHelper
=
null
;
String
root
=
null
;
public
LocalFileService
(
ApplicationContext
ctx
,
String
root
)
{
this
.
root
=
root
;
new
File
(
root
,
"temp"
).
mkdir
();
dbHelper
=
new
DBIndexHelper
(
ctx
.
getBean
(
CoreFileDao
.
class
));
}
@Override
public
FileItem
loadFileItemByPath
(
String
path
)
{
CoreFile
coreFile
=
dbHelper
.
getFileItemByPath
(
path
);
if
(
coreFile
!=
null
)
{
return
getFileItem
(
coreFile
);
}
LocalFileItem
item
=
new
LocalFileItem
(
root
);
item
.
setPath
(
path
);
item
.
setName
(
parseName
(
path
));
item
.
setTemp
(
true
);
return
item
;
}
@Override
public
FileItem
createFileTemp
(
String
name
)
{
FileItem
item
=
new
LocalFileItem
(
root
);
String
fileName
=
"temp"
+
File
.
separator
+
name
+
"."
+
this
.
suffix
();
item
.
setPath
(
fileName
);
item
.
setName
(
name
);
item
.
setTemp
(
true
);
return
item
;
}
@Override
public
FileItem
createFileItem
(
String
name
,
String
bizType
,
String
bizId
,
Long
userId
,
Long
orgId
,
List
<
FileTag
>
tags
)
{
CoreFile
coreFile
=
new
CoreFile
();
coreFile
.
setBizId
(
bizId
);
coreFile
.
setBizType
(
bizType
);
coreFile
.
setUserId
(
userId
);
coreFile
.
setOrgId
(
orgId
);
coreFile
.
setName
(
name
);
String
dir
=
DateUtil
.
now
();
File
file
=
new
File
(
root
+
File
.
separator
+
dir
);
if
(!
file
.
exists
())
{
file
.
mkdirs
();
}
String
fileName
=
name
+
"."
+
suffix
();
String
path
=
root
+
File
.
separator
+
dir
+
File
.
separator
+
fileName
;
coreFile
.
setPath
(
path
);
//目前忽略tags
dbHelper
.
createFileItem
(
coreFile
,
tags
);
return
this
.
getFileItem
(
coreFile
);
}
private
String
suffix
()
{
// TODO,改成唯一算法
return
System
.
currentTimeMillis
()
+
""
+
new
Random
().
nextInt
(
10000
);
}
private
String
parseName
(
String
path
)
{
File
file
=
new
File
(
path
);
return
file
.
getName
();
}
protected
FileItem
getFileItem
(
CoreFile
file
)
{
LocalFileItem
item
=
new
LocalFileItem
(
root
);
item
.
setName
(
file
.
getName
());
item
.
setPath
(
file
.
getPath
());
item
.
setBizId
(
file
.
getBizId
());
item
.
setBizType
(
file
.
getBizType
());
item
.
setId
(
file
.
getId
());
item
.
setOrgId
(
file
.
getOrgId
());
return
item
;
}
protected
List
<
FileItem
>
getFileItem
(
List
<
CoreFile
>
files
)
{
List
<
FileItem
>
items
=
new
ArrayList
<>(
files
.
size
());
for
(
CoreFile
file:
files
)
{
items
.
add
(
this
.
getFileItem
(
file
));
}
return
items
;
}
@Override
public
FileItem
getFileItemById
(
Long
id
)
{
return
this
.
getFileItem
(
dbHelper
.
getFileItemById
(
id
));
}
@Override
public
List
<
FileItem
>
queryByUserId
(
Long
userId
,
List
<
FileTag
>
tags
)
{
return
this
.
getFileItem
(
dbHelper
.
queryByUserId
(
userId
,
tags
));
}
@Override
public
List
<
FileItem
>
queryByBiz
(
String
bizType
,
String
bizId
)
{
return
this
.
getFileItem
(
dbHelper
.
queryByBiz
(
bizType
,
bizId
));
}
}
admin-core/src/main/java/com/ibeetl/admin/core/file/PersistFileItem.java
0 → 100644
View file @
fa59b9c0
package
com.ibeetl.admin.core.file
;
import
java.io.OutputStream
;
public
abstract
class
PersistFileItem
extends
FileItem
{
protected
Long
id
;
protected
Long
userId
;
protected
Long
orgId
;
protected
String
bizType
;
protected
String
bizId
;
FileTag
[]
tags
;
public
PersistFileItem
()
{
this
.
isTemp
=
false
;
}
public
Long
getUserId
()
{
return
userId
;
}
public
void
setUserId
(
Long
userId
)
{
this
.
userId
=
userId
;
}
public
Long
getOrgId
()
{
return
orgId
;
}
public
void
setOrgId
(
Long
orgId
)
{
this
.
orgId
=
orgId
;
}
public
FileTag
[]
getTags
()
{
return
tags
;
}
public
void
setTags
(
FileTag
[]
tags
)
{
this
.
tags
=
tags
;
}
public
Long
getId
()
{
return
id
;
}
public
void
setId
(
Long
id
)
{
this
.
id
=
id
;
}
public
String
getBizType
()
{
return
bizType
;
}
public
void
setBizType
(
String
bizType
)
{
this
.
bizType
=
bizType
;
}
public
String
getBizId
()
{
return
bizId
;
}
public
void
setBizId
(
String
bizId
)
{
this
.
bizId
=
bizId
;
}
}
admin-core/src/main/java/com/ibeetl/admin/core/util/DateUtil.java
0 → 100644
View file @
fa59b9c0
package
com.ibeetl.admin.core.util
;
import
java.text.SimpleDateFormat
;
import
java.util.Date
;
public
class
DateUtil
{
public
static
String
now
()
{
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyyy-MM-dd"
);
return
sdf
.
format
(
new
Date
());
}
}
admin-core/src/main/java/com/ibeetl/admin/core/web/FileSystemContorller.java
View file @
fa59b9c0
...
@@ -27,10 +27,14 @@ public class FileSystemContorller {
...
@@ -27,10 +27,14 @@ public class FileSystemContorller {
FileService
fileService
;
FileService
fileService
;
@GetMapping
(
MODEL
+
"/get.do"
)
@GetMapping
(
MODEL
+
"/get.do"
)
public
ModelAndView
index
(
HttpServletResponse
response
,
String
id
)
throws
IOException
{
public
ModelAndView
index
(
HttpServletResponse
response
,
String
id
)
throws
IOException
{
String
path
=
id
;
response
.
setContentType
(
"text/html; charset = UTF-8"
);
response
.
setContentType
(
"text/html; charset = UTF-8"
);
FileItem
fileItem
=
fileService
.
get
FileItem
(
id
);
FileItem
fileItem
=
fileService
.
load
FileItem
ByPath
(
path
);
response
.
setHeader
(
"Content-Disposition"
,
"attachment; filename="
+
fileItem
.
getName
());
response
.
setHeader
(
"Content-Disposition"
,
"attachment; filename="
+
fileItem
.
getName
());
fileService
.
copyTemp
(
id
,
response
.
getOutputStream
());
fileItem
.
copy
(
response
.
getOutputStream
());
if
(
fileItem
.
isTemp
())
{
fileItem
.
delete
();
}
return
null
;
return
null
;
}
}
...
...
admin-core/src/main/resources/codeTemplate/java/pojo.java
View file @
fa59b9c0
...
@@ -23,7 +23,7 @@ public class ${className} extends BaseEntity{
...
@@ -23,7 +23,7 @@ public class ${className} extends BaseEntity{
@for
(
attr
in
attrs
){
@for
(
attr
in
attrs
){
@if
(!
isEmpty
(
attr
.
comment
)){
@if
(!
isEmpty
(
attr
.
comment
)){
//${attr.comment}
//${attr.comment}
@
}
@
}
@if
(
attr
.
isId
)
{
@if
(
attr
.
isId
)
{
\
@NotNull
(
message
=
"ID不能为空"
,
groups
=
ValidateConfig
.
UPDATE
.
class
)
\
@NotNull
(
message
=
"ID不能为空"
,
groups
=
ValidateConfig
.
UPDATE
.
class
)
...
@@ -39,17 +39,17 @@ public class ${className} extends BaseEntity{
...
@@ -39,17 +39,17 @@ public class ${className} extends BaseEntity{
@for
(
attr
in
attrs
){
@for
(
attr
in
attrs
){
@if
(!
isEmpty
(
attr
.
comment
)){
@if
(!
isEmpty
(
attr
.
comment
)){
/**${attr.comment}
/**${attr.comment}
*\@return
*\@return
*/
*/
@
}
@
}
public
$
{
attr
.
type
}
get
$
{
attr
.
methodName
}(){
public
$
{
attr
.
type
}
get
$
{
attr
.
methodName
}(){
return
$
{
attr
.
name
};
return
$
{
attr
.
name
};
}
}
@if
(!
isEmpty
(
attr
.
comment
)){
@if
(!
isEmpty
(
attr
.
comment
)){
/**${attr.comment}
/**${attr.comment}
*\@param ${attr.name}
*\@param ${attr.name}
*/
*/
@
}
@
}
public
void
set
$
{
attr
.
methodName
}(
$
{
attr
.
type
}
$
{
attr
.
name
}){
public
void
set
$
{
attr
.
methodName
}(
$
{
attr
.
type
}
$
{
attr
.
name
}){
this
.
$
{
attr
.
name
}
=
$
{
attr
.
name
};
this
.
$
{
attr
.
name
}
=
$
{
attr
.
name
};
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment