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
cc0c508e
Commit
cc0c508e
authored
Mar 18, 2020
by
trumansdo
Browse files
用户管理待完成:
1、统一包装上传组件,为了后续前端代码不重复写上传逻辑。 2、下载导出
parent
b64a9584
Changes
18
Hide whitespace changes
Inline
Side-by-side
plus-admin/admin-console/src/main/java/com/ibeetl/admin/console/web/UserConsoleElController.java
View file @
cc0c508e
...
...
@@ -4,15 +4,13 @@ import com.ibeetl.admin.console.service.UserConsoleService;
import
com.ibeetl.admin.console.util.VOUtil
;
import
com.ibeetl.admin.console.web.query.CoreUserElQuery
;
import
com.ibeetl.admin.core.annotation.Function
;
import
com.ibeetl.admin.core.annotation.RequestBodyPlus
;
import
com.ibeetl.admin.core.entity.CoreUser
;
import
com.ibeetl.admin.core.service.CorePlatformService
;
import
com.ibeetl.admin.core.service.CoreUserService
;
import
com.ibeetl.admin.core.service.param.CoreUserParam
;
import
com.ibeetl.admin.core.util.ConvertUtil
;
import
com.ibeetl.admin.core.util.ValidateConfig
;
import
com.ibeetl.admin.core.web.JsonResult
;
import
java.util.Arrays
;
import
java.util.List
;
import
java.util.Map
;
import
org.beetl.sql.core.engine.PageQuery
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -71,7 +69,7 @@ public class UserConsoleElController {
@Function
(
"user.delete"
)
@DeleteMapping
public
JsonResult
delete
(
Long
[]
ids
)
{
public
JsonResult
delete
(
@RequestBodyPlus
(
"ids"
)
Long
[]
ids
)
{
userConsoleService
.
batchDelSysUser
(
Arrays
.
asList
(
ids
));
return
JsonResult
.
success
();
}
...
...
plus-admin/admin-console/src/main/resources/application.properties
View file @
cc0c508e
...
...
@@ -5,6 +5,8 @@ user.id=1
user.orgId
=
1
#\u6253\u5F00\u5BA1\u8BA1\u529F\u80FD\uFF0C\u5F00\u53D1\u6A21\u5F0F\u5E94\u8BE5\u5173\u95ED
audit.enable
=
false
# \u6587\u4EF6\u64CD\u4F5C\u7684\u6839\u76EE\u5F55\u914D\u7F6E \u8BF7\u6839\u636E\u5404\u81EA\u8BA1\u7B97\u673A\u914D\u7F6E
localFile.root
=
E:
\\
code_workspace
\\
temp_space
\\
# --------\u670D\u52A1\u5668undertow\u914D\u7F6E
server.port
=
8080
...
...
plus-admin/admin-console/src/main/resources/static/js/admin/user/index.js
View file @
cc0c508e
layui
.
define
([
'
form
'
,
'
laydate
'
,
'
table
'
,
'
userApi
'
],
function
(
exports
)
{
var
form
=
layui
.
form
;
var
laydate
=
layui
.
laydate
;
var
table
=
layui
.
table
;
var
userApi
=
layui
.
userApi
;
var
userTable
=
null
;
var
view
=
{
init
:
function
(){
this
.
initTable
();
this
.
initSearchForm
();
this
.
initToolBar
();
window
.
dataReload
=
function
(){
Lib
.
doSearchForm
(
$
(
"
#searchForm
"
),
userTable
)
}
},
initTable
:
function
(){
userTable
=
table
.
render
({
elem
:
'
#userTable
'
,
height
:
Lib
.
getTableHeight
(
2
),
method
:
'
post
'
,
url
:
Common
.
ctxPath
+
'
/admin/user/list.json
'
//数据接口
,
page
:
Lib
.
tablePage
//开启分页
,
limit
:
10
,
cols
:
[
[
//表头
{
type
:
'
checkbox
'
,
fixed
:
'
left
'
,
},
{
field
:
'
id
'
,
title
:
'
id
'
,
width
:
80
,
fixed
:
'
left
'
,
sort
:
true
},
{
field
:
'
code
'
,
title
:
'
用户名
'
,
width
:
150
},
{
field
:
'
name
'
,
title
:
'
姓名
'
,
width
:
120
,
sort
:
true
},
{
field
:
'
orgName
'
,
title
:
'
机构
'
,
width
:
120
,
sort
:
true
},
{
field
:
'
stateText
'
,
title
:
'
状态
'
,
width
:
120
,
sort
:
true
},
{
field
:
'
jobType0Text
'
,
title
:
'
职位
'
,
width
:
120
,
sort
:
true
},
{
field
:
'
jobType1Text
'
,
title
:
'
职位明细
'
,
width
:
80
,
sort
:
true
},
{
field
:
'
createTime
'
,
title
:
'
创建时间
'
,
width
:
120
,
templet
:
function
(
d
){
return
Common
.
getDate
(
d
.
createTime
);
},
sort
:
true
}
layui
.
define
([
'
form
'
,
'
laydate
'
,
'
table
'
,
'
userApi
'
],
function
(
exports
)
{
var
form
=
layui
.
form
;
var
laydate
=
layui
.
laydate
;
var
table
=
layui
.
table
;
var
userApi
=
layui
.
userApi
;
var
userTable
=
null
;
]
]
var
view
=
{
});
},
initSearchForm
:
function
(){
Lib
.
initSearchForm
(
$
(
"
#searchForm
"
),
userTable
,
form
);
},
initToolBar
:
function
(){
toolbar
=
{
add
:
function
()
{
//获取选中数据
var
url
=
"
/admin/user/add.do
"
;
Common
.
openDlg
(
url
,
"
用户管理>新增
"
);
},
edit
:
function
()
{
//获取选中数目
var
data
=
Common
.
getOneFromTable
(
table
,
"
userTable
"
);
if
(
data
==
null
){
return
;
}
var
url
=
"
/admin/user/edit.do?id=
"
+
data
.
id
;
Common
.
openDlg
(
url
,
"
用户管理>编辑
"
);
},
del
:
function
()
{
layui
.
use
([
'
del
'
],
function
(){
var
delView
=
layui
.
del
delView
.
delBatch
();
});
},
userRole
:
function
()
{
//获取选中数目
var
data
=
Common
.
getOneFromTable
(
table
,
"
userTable
"
);
if
(
data
==
null
){
return
;
}
var
url
=
"
/admin/user/role/list.do?id=
"
+
data
.
id
;
Common
.
openDlg
(
url
,
"
用户管理>
"
+
data
.
name
+
"
>角色管理
"
);
},
changePassword
:
function
(){
var
data
=
Common
.
getOneFromTable
(
table
,
"
userTable
"
);
if
(
data
==
null
){
return
;
}
var
url
=
"
/admin/user/changePassword.do?id=
"
+
data
.
id
;
Common
.
openDlg
(
url
,
"
用户管理>更改密码
"
);
init
:
function
()
{
this
.
initTable
();
this
.
initSearchForm
();
this
.
initToolBar
();
window
.
dataReload
=
function
()
{
Lib
.
doSearchForm
(
$
(
"
#searchForm
"
),
userTable
)
}
},
exportUsers
:
function
(){
Common
.
openConfirm
(
"
确认要导出这些用户?
"
,
function
(){
userApi
.
exportUsers
(
$
(
"
#searchForm
"
),
function
(
fileId
){
Lib
.
download
(
fileId
);
})
})
},
initTable
:
function
()
{
userTable
=
table
.
render
({
elem
:
'
#userTable
'
,
height
:
Lib
.
getTableHeight
(
2
),
method
:
'
post
'
,
url
:
Common
.
ctxPath
+
'
/admin/user/list.json
'
//数据接口
,
page
:
Lib
.
tablePage
//开启分页
,
limit
:
10
,
cols
:
[[
//表头
{
type
:
'
checkbox
'
,
fixed
:
'
left
'
,
},
{
field
:
'
id
'
,
title
:
'
id
'
,
width
:
80
,
fixed
:
'
left
'
,
sort
:
true
},
{
field
:
'
code
'
,
title
:
'
用户名
'
,
width
:
150
},
{
field
:
'
name
'
,
title
:
'
姓名
'
,
width
:
120
,
sort
:
true
},
{
field
:
'
orgName
'
,
title
:
'
机构
'
,
width
:
120
,
sort
:
true
},
{
field
:
'
stateText
'
,
title
:
'
状态
'
,
width
:
120
,
sort
:
true
},
{
field
:
'
jobType0Text
'
,
title
:
'
职位
'
,
width
:
120
,
sort
:
true
},
{
field
:
'
jobType1Text
'
,
title
:
'
职位明细
'
,
width
:
80
,
sort
:
true
},
{
field
:
'
createTime
'
,
title
:
'
创建时间
'
,
width
:
120
,
templet
:
function
(
d
)
{
return
Common
.
getDate
(
d
.
createTime
);
},
sort
:
true
}
}
};
$
(
'
.ext-toolbar
'
).
on
(
'
click
'
,
function
()
{
var
type
=
$
(
this
).
data
(
'
type
'
);
toolbar
[
type
]
?
toolbar
[
type
].
call
(
this
)
:
''
;
});
}
}
]]
});
},
initSearchForm
:
function
()
{
Lib
.
initSearchForm
(
$
(
"
#searchForm
"
),
userTable
,
form
);
},
initToolBar
:
function
()
{
toolbar
=
{
add
:
function
()
{
//获取选中数据
var
url
=
"
/admin/user/add.do
"
;
Common
.
openDlg
(
url
,
"
用户管理>新增
"
);
},
edit
:
function
()
{
//获取选中数目
var
data
=
Common
.
getOneFromTable
(
table
,
"
userTable
"
);
if
(
data
==
null
)
{
return
;
}
var
url
=
"
/admin/user/edit.do?id=
"
+
data
.
id
;
Common
.
openDlg
(
url
,
"
用户管理>编辑
"
);
},
del
:
function
()
{
layui
.
use
([
'
del
'
],
function
()
{
var
delView
=
layui
.
del
delView
.
delBatch
();
});
},
userRole
:
function
()
{
//获取选中数目
var
data
=
Common
.
getOneFromTable
(
table
,
"
userTable
"
);
if
(
data
==
null
)
{
return
;
}
var
url
=
"
/admin/user/role/list.do?id=
"
+
data
.
id
;
Common
.
openDlg
(
url
,
"
用户管理>
"
+
data
.
name
+
"
>角色管理
"
);
},
changePassword
:
function
()
{
var
data
=
Common
.
getOneFromTable
(
table
,
"
userTable
"
);
if
(
data
==
null
)
{
return
;
}
var
url
=
"
/admin/user/changePassword.do?id=
"
+
data
.
id
;
Common
.
openDlg
(
url
,
"
用户管理>更改密码
"
);
},
exportUsers
:
function
()
{
Common
.
openConfirm
(
"
确认要导出这些用户?
"
,
function
()
{
userApi
.
exportUsers
(
$
(
"
#searchForm
"
),
function
(
fileId
)
{
Lib
.
download
(
fileId
);
})
})
}
};
$
(
'
.ext-toolbar
'
).
on
(
'
click
'
,
function
()
{
var
type
=
$
(
this
).
data
(
'
type
'
);
toolbar
[
type
]
?
toolbar
[
type
].
call
(
this
)
:
''
;
});
}
}
exports
(
'
index
'
,
view
);
exports
(
'
index
'
,
view
);
});
\ No newline at end of file
plus-admin/admin-core/src/main/java/com/ibeetl/admin/core/conf/jackson/serializer/DateToTimestampSerializer.java
View file @
cc0c508e
...
...
@@ -6,11 +6,19 @@ import com.fasterxml.jackson.databind.SerializerProvider;
import
java.io.IOException
;
import
java.util.Date
;
/**
* Class DateToTimestampSerializer : <br>
* 描述:在date序列化时间戳时,默认的jackson会将纳秒一起序列化,但是没必要。
*
* @author 一日看尽长安花 Created on 2020/3/13
*/
public
class
DateToTimestampSerializer
extends
JsonSerializer
<
Date
>
{
private
static
final
long
NANO_MULTIPLE
=
1000L
;
@Override
public
void
serialize
(
Date
value
,
JsonGenerator
gen
,
SerializerProvider
serializers
)
throws
IOException
{
gen
.
writeNumber
(
value
.
getTime
()
/
1000L
);
gen
.
writeNumber
(
value
.
getTime
()
/
NANO_MULTIPLE
);
}
}
plus-admin/admin-core/src/main/java/com/ibeetl/admin/core/entity/CoreFile.java
View file @
cc0c508e
...
...
@@ -33,6 +33,7 @@ public class CoreFile extends BaseEntity {
private
Long
orgId
;
private
String
bizType
;
/*文件批次id,用于其它业务表记录*/
private
String
fileBatchId
;
public
CoreFile
()
{}
...
...
plus-admin/admin-core/src/main/java/com/ibeetl/admin/core/file/FileItem.java
View file @
cc0c508e
package
com.ibeetl.admin.core.file
;
import
java.io.OutputStream
;
import
lombok.Data
;
@Data
public
abstract
class
FileItem
{
protected
Long
id
;
protected
String
name
;
...
...
@@ -13,36 +15,4 @@ public abstract class FileItem {
public
abstract
void
copy
(
OutputStream
os
);
public
abstract
boolean
delete
();
public
String
getName
()
{
return
name
;
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
public
String
getPath
()
{
return
path
;
}
public
void
setPath
(
String
path
)
{
this
.
path
=
path
;
}
public
boolean
isTemp
()
{
return
isTemp
;
}
public
void
setTemp
(
boolean
isTemp
)
{
this
.
isTemp
=
isTemp
;
}
public
Long
getId
()
{
return
id
;
}
public
void
setId
(
Long
id
)
{
this
.
id
=
id
;
}
}
plus-admin/admin-core/src/main/java/com/ibeetl/admin/core/file/LocalFileItem.java
View file @
cc0c508e
package
com.ibeetl.admin.core.file
;
import
com.ibeetl.admin.core.util.PlatformException
;
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
;
/**
* 本地文件系统
*
* @author xiandafu
*/
class
LocalFileItem
extends
PersistFileItem
{
String
root
=
null
;
public
class
LocalFileItem
extends
PersistFileItem
{
String
root
;
public
LocalFileItem
(
String
root
)
{
this
.
root
=
root
;
...
...
@@ -28,7 +27,7 @@ class LocalFileItem extends PersistFileItem {
FileOutputStream
fos
=
new
FileOutputStream
(
file
);
return
fos
;
}
catch
(
IOException
e
)
{
throw
new
PlatformException
(
"Open stream error "
+
path
);
throw
new
PlatformException
(
"Open
file ["
+
path
+
"] output
stream error "
);
}
}
...
...
@@ -45,7 +44,7 @@ class LocalFileItem extends PersistFileItem {
}
}
catch
(
Exception
ex
)
{
throw
new
PlatformException
(
"下载文件失败"
+
ex
);
throw
new
PlatformException
(
"下载
/复制
文件失败"
+
ex
);
}
finally
{
try
{
input
.
close
();
...
...
@@ -56,7 +55,7 @@ class LocalFileItem extends PersistFileItem {
}
}
if
(
path
.
startsWith
(
"t
emp
"
)
)
{
if
(
isT
emp
)
{
this
.
delete
();
}
}
...
...
plus-admin/admin-core/src/main/java/com/ibeetl/admin/core/file/LocalFileService.java
View file @
cc0c508e
package
com.ibeetl.admin.core.file
;
import
java.io.File
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.List
;
import
org.apache.commons.logging.Log
;
import
org.apache.commons.logging.LogFactory
;
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
;
import
com.ibeetl.admin.core.util.PlatformException
;
import
com.ibeetl.admin.core.util.UUIDUtil
;
import
java.io.File
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.List
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.context.ApplicationContext
;
/**
* 一个本地文件系统,管理临时文件和用户文件
*
* @author xiandafu
*/
@Slf4j
public
class
LocalFileService
implements
FileService
{
Log
log
=
LogFactory
.
getLog
(
this
.
getClass
());
DBIndexHelper
dbHelper
=
null
;
String
root
=
null
;
String
root
;
public
LocalFileService
(
ApplicationContext
ctx
,
String
root
)
{
this
.
root
=
root
;
...
...
@@ -104,7 +101,6 @@ public class LocalFileService implements FileService {
item
.
setBizType
(
file
.
getBizType
());
item
.
setId
(
file
.
getId
());
item
.
setOrgId
(
file
.
getOrgId
());
item
.
setId
(
file
.
getId
());
return
item
;
}
...
...
@@ -146,7 +142,7 @@ public class LocalFileService implements FileService {
FileItem
item
=
this
.
getFileItem
(
file
);
boolean
success
=
item
.
delete
();
if
(!
success
)
{
log
.
warn
(
"删除文件
失败
"
+
file
.
getName
()
+
",id="
+
file
.
getId
()
+
" path="
+
file
.
getPath
());
log
.
warn
(
"删除文件
[
"
+
file
.
getName
()
+
"
]失败
,id="
+
file
.
getId
()
+
" path="
+
file
.
getPath
());
throw
new
PlatformException
(
"删除文件失败 "
+
file
.
getName
());
}
dbHelper
.
fileDao
.
deleteById
(
id
);
...
...
plus-admin/admin-core/src/main/java/com/ibeetl/admin/core/util/UUIDUtil.java
View file @
cc0c508e
...
...
@@ -5,7 +5,6 @@ import java.util.UUID;
public
class
UUIDUtil
{
public
static
String
uuid
()
{
UUID
uuid
=
UUID
.
randomUUID
();
String
randomUUIDString
=
uuid
.
toString
();
return
randomUUIDString
;
return
uuid
.
toString
();
}
}
plus-admin/admin-core/src/main/java/com/ibeetl/admin/core/web/FileSystemContorller.java
→
plus-admin/admin-core/src/main/java/com/ibeetl/admin/core/web/FileSystem
El
Contorller.java
View file @
cc0c508e
package
com.ibeetl.admin.core.web
;
import
cn.hutool.core.util.IdUtil
;
import
cn.hutool.core.util.StrUtil
;
import
com.ibeetl.admin.core.entity.CoreOrg
;
import
com.ibeetl.admin.core.entity.CoreUser
;
import
com.ibeetl.admin.core.file.FileItem
;
import
com.ibeetl.admin.core.file.FileService
;
import
com.ibeetl.admin.core.service.CorePlatformService
;
import
com.ibeetl.admin.core.util.FileUtil
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.io.OutputStream
;
import
java.net.URLEncoder
;
import
java.util.List
;
import
javax.servlet.http.HttpServletResponse
;
import
lombok.extern.java.Log
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.logging.LogFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.web.bind.annotation.GetMapping
;
...
...
@@ -19,43 +24,42 @@ import org.springframework.web.bind.annotation.RequestMapping;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
org.springframework.web.multipart.MultipartFile
;
import
org.springframework.web.servlet.ModelAndView
;
import
com.ibeetl.admin.core.entity.CoreOrg
;
import
com.ibeetl.admin.core.entity.CoreUser
;
import
com.ibeetl.admin.core.file.FileItem
;
import
com.ibeetl.admin.core.file.FileService
;
import
com.ibeetl.admin.core.service.CorePlatformService
;
import
com.ibeetl.admin.core.util.FileUtil
;
/**
* Class FileSystemContorller : <br/>
* 描述:业务中有关文件的上传,下载。<br/>
* TODO 待改动计划:
* 改成加上MD5验证,减少重复文件的io
* 补上文件表中有关文件属性(大小,类型,)的信息
* 补上文件上传的临时状态,避免上传文件却中断业务逻辑,产生无用数据以及文件
* @author 一日看尽长安花
* Updated on 2020/3/8
* 描述:文件上传下载操作
*
* @author 一日看尽长安花 Created on 2020/3/16
*/
@Slf4j
@Controller
@RequestMapping
(
"/core/file"
)
public
class
FileSystemContorller
{
public
class
FileSystem
El
Contorller
{
@Autowired
CorePlatformService
platformService
;
@Autowired
FileService
fileService
;
/*附件类操作*/
@PostMapping
(
"/uploadAttachment.json"
)
/**
* 上传文件
*
* @author 一日看尽长安花
* @param fileBatchId 文件批次id,第一次上传应该自动生成一个返回给前端
* @param bizId 有关的业务id
* @param bizType 有关的业务类型type
* @return JsonResult<String> 返回文件操作批次id
* @throws IOException when
*/
@PostMapping
(
"/uploadAttachment"
)
@ResponseBody
public
JsonResult
uploadFile
(
@RequestParam
(
"file"
)
MultipartFile
file
,
String
batchFileUUID
,
String
bizType
,
String
bizId
)
public
JsonResult
<
String
>
uploadFile
(
@RequestParam
(
"file"
)
MultipartFile
file
,
String
fileBatchId
,
String
bizType
,
String
bizId
)
throws
IOException
{
if
(
file
.
isEmpty
())
{
return
JsonResult
.
fail
();
}
if
(
StrUtil
.
isBlank
(
fileBatchId
))
{
fileBatchId
=
IdUtil
.
fastUUID
();
}
CoreUser
user
=
platformService
.
getCurrentUser
();
CoreOrg
org
=
platformService
.
getCurrentOrg
();
FileItem
fileItem
=
...
...
@@ -65,22 +69,30 @@ public class FileSystemContorller {
bizId
,
user
.
getId
(),
org
.
getId
(),
batchFileUUID
,
fileBatchId
,
null
);
OutputStream
os
=
fileItem
.
openOutpuStream
();
FileUtil
.
copy
(
file
.
getInputStream
(),
os
);
return
JsonResult
.
success
(
file
Item
);
return
JsonResult
.
success
(
file
BatchId
);
}
@PostMapping
(
"/deleteAttachment
.json
"
)
@PostMapping
(
"/deleteAttachment"
)
@ResponseBody
public
JsonResult
deleteFile
(
Long
fileId
,
String
batchFileUUID
)
throws
IOException
{
fileService
.
removeFile
(
fileId
,
batchFileUUID
);
return
JsonResult
.
success
();
}
@GetMapping
(
"/download/{fileId}/{batchFileUUID}/{name}"
)
public
ModelAndView
download
(
/**
* 下载多文件中的某一个文件,
*
* @author 一日看尽长安花
* @param batchFileUUID 多文件的文件操作批次id
* @param fileId 多文件中某个文件的id
* @throws IOException when
*/
@GetMapping
(
"/download/{fileId}/{batchFileUUID}"
)
public
void
downloadMutipleFile
(
HttpServletResponse
response
,
@PathVariable
Long
fileId
,
@PathVariable
String
batchFileUUID
)
throws
IOException
{
FileItem
item
=
fileService
.
getFileItemById
(
fileId
,
batchFileUUID
);
...
...
@@ -88,14 +100,19 @@ public class FileSystemContorller {
"Content-Disposition"
,
"attachment; filename="
+
URLEncoder
.
encode
(
item
.
getName
(),
"UTF-8"
));
item
.
copy
(
response
.
getOutputStream
());
return
null
;
}
/*execl 导入导出*/
@GetMapping
(
"/get.do"
)
public
ModelAndView
index
(
HttpServletResponse
response
,
String
id
)
throws
IOException
{
String
path
=
id
;
/**
* 通过路径下载文件
*
* @author 一日看尽长安花
* @param path 文件path路径
* @throws IOException when
*/
@GetMapping
(
"/download"
)
public
void
downloadFileByPath
(
HttpServletResponse
response
,
String
path
)
throws
IOException
{
response
.
setContentType
(
"text/html; charset = UTF-8"
);
FileItem
fileItem
=
fileService
.
loadFileItemByPath
(
path
);
response
.
setHeader
(
...
...
@@ -105,12 +122,10 @@ public class FileSystemContorller {
if
(
fileItem
.
isTemp
())
{
fileItem
.
delete
();
}
return
null
;
}
@GetMapping
(
"/downloadTemplate.do"
)
public
ModelAndView
dowloadTemplate
(
HttpServletResponse
response
,
String
path
)
throws
IOException
{
@GetMapping
(
"/downloadTemplate"
)
public
void
dowloadTemplate
(
HttpServletResponse
response
,
String
path
)
throws
IOException
{
response
.
setContentType
(
"text/html; charset = UTF-8"
);
int
start1
=
path
.
lastIndexOf
(
"\\"
);
int
start2
=
path
.
lastIndexOf
(
"/"
);
...
...
@@ -125,17 +140,21 @@ public class FileSystemContorller {
.
getContextClassLoader
()
.
getResourceAsStream
(
"excelTemplates/"
+
path
);
FileUtil
.
copy
(
input
,
response
.
getOutputStream
());
return
null
;
}
@GetMapping
(
"/simpleUpload.do"
)
public
ModelAndView
simpleUploadPage
(
String
uploadUrl
,
String
templatePath
,
String
fileType
)
throws
IOException
{
ModelAndView
view
=
new
ModelAndView
(
"/common/simpleUpload.html"
);
view
.
addObject
(
"uploadUrl"
,
uploadUrl
);
view
.
addObject
(
"templatePath"
,
templatePath
);
view
.
addObject
(
"fileType"
,
fileType
);
return
view
;
/**
* 通过文件批次操作id,返回文件列表信息
*
* @author 一日看尽长安花
* @return JsonResult<List < LocalFileItem>>
*/
@GetMapping
(
"/items"
)
@ResponseBody
public
JsonResult
<
List
<
FileItem
>>
fileItemList
(
String
fileBatchId
)
{
if
(
StrUtil
.
isBlank
(
fileBatchId
))
{
return
JsonResult
.
success
();
}
List
<
FileItem
>
fileItems
=
fileService
.
queryByBatchId
(
fileBatchId
);
return
JsonResult
.
success
(
fileItems
);
}
}
ve-admin/admin-web/src/api/file.js
0 → 100644
View file @
cc0c508e
/*
* @Author: 一日看尽长安花
* @since: 2020-03-16 11:16:52
* @LastEditTime: 2020-03-16 13:13:31
* @LastEditors: 一日看尽长安花
* @Description:
*/
import
request
from
'
@/utils/request
'
;
/**
* 一些常量
*/
export
const
IMG_MIME
=
'
image/*
'
;
export
const
DOC_MIME
=
'
.doc,.docx,.xml,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document
'
;
/**
* 手动上传附件
*/
export
function
uploadAttachment
(
data
)
{
return
request
({
url
:
'
/core/file/uploadAttachment
'
,
method
:
'
post
'
,
data
});
}
/**
* 下载多附件中的一个附件
* @param {object} params 包含的参数:fileId,batchFileUUID
*/
export
function
downloadMutipleFile
(
params
)
{
const
{
fileId
,
batchFileUUID
}
=
{
...
params
};
return
request
({
url
:
`/core/file/download/
${
fileId
}
/
${
batchFileUUID
}
`
,
method
:
'
get
'
});
}
/**
* 通过path下载单个文件
*
* @param {object} params 包含的参数:path
*/
export
function
download
(
params
)
{
return
request
({
url
:
'
/core/file/download
'
,
method
:
'
get
'
,
params
});
}
/**
* 获取附件信息
* @param {object} params 包含fileBatchId
*/
export
function
getFileList
(
params
)
{
return
request
({
url
:
'
/core/file/items
'
,
method
:
'
get
'
,
params
});
}
ve-admin/admin-web/src/api/user.js
View file @
cc0c508e
/*
* @Author: 一日看尽长安花
* @since: 2019-09-04 20:55:14
* @LastEditTime
: 2020-0
2-04 13:20
:2
9
* @LastEditors
: 一日看尽长安花
* @LastEditTime: 2020-0
3-15 10:59
:2
7
* @LastEditors: 一日看尽长安花
* @Description:
*/
import
request
from
'
@/utils/request
'
;
...
...
@@ -60,3 +60,11 @@ export function updateUserData(data) {
data
});
}
export
function
deleteUserData
(
data
)
{
return
request
({
url
:
'
/users
'
,
method
:
'
delete
'
,
data
});
}
ve-admin/admin-web/src/components/GeneralPage/DataTable.vue
View file @
cc0c508e
<!--
* @Author: 一日看尽长安花
* @since: 2019-10-12 16:14:37
* @LastEditTime
: 2020-0
2-22 17:32:45
* @LastEditors
: 一日看尽长安花
* @LastEditTime: 2020-0
3-16 16:01:20
* @LastEditors: 一日看尽长安花
* @Description:
-->
<
template
>
...
...
@@ -145,7 +145,7 @@ export default {
if
(
valType
===
'
date
'
)
{
val
=
parseTime
(
val
/
1000
,
'
{y}-{m}-{d} {h}:{i}:{s}
'
);
}
else
if
(
valType
===
'
dict
'
)
{
val
=
val
.
name
;
val
=
this
.
$lodash
.
get
(
val
,
'
name
'
)
;
}
return
val
;
},
...
...
ve-admin/admin-web/src/components/GeneralPage/Pagination.vue
View file @
cc0c508e
<!--
* @Author: 一日看尽长安花
* @since: 2019-09-09 12:16:28
* @LastEditTime: 20
19-10-27 00:01:53
* @LastEditTime: 20
20-03-13 16:38:34
* @LastEditors: 一日看尽长安花
* @Description: 这个分页是直接从组件复制的,为了保证以后修改逻辑不影响其它的页面使用公共的分页。
-->
<
template
>
<div
:class=
"
{ hidden: hidden }" class="pagination-container">
<el-pagination
ref=
"paginationGP"
:background=
"background"
:current-page.sync=
"currentPage"
:page-size.sync=
"pageSize"
...
...
ve-admin/admin-web/src/components/GeneralPage/components/DetailPage.vue
View file @
cc0c508e
<!--
* @Author: 一日看尽长安花
* @since: 2019-10-12 16:14:37
* @LastEditTime
: 2020-0
2-05 17:00
:2
1
* @LastEditors
: 一日看尽长安花
* @LastEditTime: 2020-0
3-17 15:46
:2
3
* @LastEditors: 一日看尽长安花
* @Description:
-->
<
template
>
...
...
@@ -12,7 +12,8 @@
<el-dialog
:fullscreen=
"true"
:center=
"true"
:destroy-on-close=
"true"
:destroy-on-close=
"false"
:show-close=
"false"
:title=
"dialogTitle"
:visible=
"dialogVisible"
:close-on-click-modal=
"false"
...
...
@@ -134,17 +135,7 @@ export default {
this
.
$refs
[
'
editForm
'
].
validate
(
valid
=>
{
if
(
valid
)
{
this
.
$emit
(
'
create-data
'
,
this
.
dialogData
);
/* 将回调延迟到下次 DOM 更新循环之后执行。
而数据更新就代表dom更新,所以如果创建成功,数据就会更新 */
this
.
$nextTick
(()
=>
{
this
.
$emit
(
'
update:dialogVisible
'
,
false
);
this
.
$notify
({
title
:
'
成功
'
,
message
:
'
添加成功
'
,
type
:
'
success
'
,
duration
:
2000
});
});
this
.
$emit
(
'
update:dialogVisible
'
,
false
);
}
else
{
this
.
$notify
({
title
:
'
失败
'
,
...
...
@@ -159,15 +150,7 @@ export default {
this
.
$refs
[
'
editForm
'
].
validate
(
valid
=>
{
if
(
valid
)
{
this
.
$emit
(
'
update-data
'
,
this
.
dialogData
);
this
.
$nextTick
(()
=>
{
this
.
$emit
(
'
update:dialogVisible
'
,
false
);
this
.
$notify
({
title
:
'
成功
'
,
message
:
'
修改成功
'
,
type
:
'
success
'
,
duration
:
2000
});
});
this
.
$emit
(
'
update:dialogVisible
'
,
false
);
}
else
{
this
.
$notify
({
title
:
'
失败
'
,
...
...
ve-admin/admin-web/src/components/GeneralPage/index.vue
View file @
cc0c508e
<!--
* @Author: 一日看尽长安花
* @since: 2019-10-12 15:43:18
* @LastEditTime: 2020-03-
06
16:
02
:5
1
* @LastEditTime: 2020-03-
15
16:
36
:5
7
* @LastEditors: 一日看尽长安花
* @Description: 后台管理页面的自动生成,
* 主要暴露了分页方法、数据表格搜索方法、条件查询方法、增删改方法
...
...
@@ -10,6 +10,7 @@
<
template
>
<div>
<search-pane
ref=
"searchPaneGP"
:metadata=
"metadata"
@
filter-search=
"filterSearch"
@
handle-create=
"handleCreate"
...
...
@@ -22,6 +23,7 @@
</
template
>
</search-pane>
<data-table
ref=
"dataTableGP"
:loading=
"loading"
:metadata=
"metadata"
:tabledata=
"tabledata"
...
...
@@ -29,9 +31,10 @@
@
update:tabledata=
"$emit('update:tabledata', $event)"
@
pagination=
"pagination"
@
handle-edit=
"handleEdit"
@
delete-data=
"
$emit('
delete
-d
ata
', $event)
"
@
delete-data=
"delete
D
ata"
></data-table>
<detail-page
ref=
"detailPageGP"
:metadata=
"metadata"
:dialog-visible.sync=
"dialogVisible"
:dialog-title=
"dialogTitle"
...
...
@@ -119,6 +122,9 @@ export default {
this
.
dialogTitle
=
'
修改
'
;
this
.
dialogVisible
=
true
;
this
.
dialogData
=
Object
.
assign
({},
row
);
},
deleteData
(
index
,
row
)
{
this
.
$emit
(
'
delete-data
'
,
index
,
row
);
}
}
};
...
...
ve-admin/admin-web/src/components/Upload/FileUpload.vue
View file @
cc0c508e
<!--
* @Author: 一日看尽长安花
* @since: 2020-03-08 11:03:14
* @LastEditTime: 2020-03-
08 15:32:26
* @LastEditTime: 2020-03-
17 20:54:30
* @LastEditors: 一日看尽长安花
* @Description:
-->
<
template
>
<el-upload
:
ref=
"
refs
"
ref=
"
upload
"
:headers=
"headers"
:multiple=
"multiple"
:data=
"data"
...
...
@@ -26,12 +26,12 @@
:before-remove=
"beforeRemove"
:list-type=
"listType"
:auto-upload=
"autoUpload"
:file-list=
"fileList"
:http-request=
"
httpRequ
es
t
"
:file-list=
"fileList
_d
"
:http-request=
"
updateFil
es"
:disabled=
"disabled"
:limit=
"limit"
:on-exceed=
"onExceed"
action=
"
https://jsonplaceholder.typicode.com/posts/
"
action=
"
/core/file/uploadAttachment
"
>
<template
v-slot:default
>
<slot
name=
"default"
>
</slot>
...
...
@@ -45,13 +45,23 @@
</el-upload>
</template>
<
script
>
import
{
getFileList
}
from
'
@/api/file
'
;
export
default
{
name
:
'
FileUpload
'
,
components
:
{},
props
:
{
refs
:
{
fileBatchId
:
{
type
:
String
,
default
:
'
fileUpload
'
default
:
null
},
bizType
:
{
type
:
String
,
default
:
null
},
bizId
:
{
type
:
String
,
default
:
null
},
headers
:
{
type
:
Object
,
...
...
@@ -66,7 +76,11 @@ export default {
data
:
{
type
:
Object
,
default
()
{
return
undefined
;
return
{
fileBatchId
:
this
.
fileBatchId
,
bizType
:
this
.
bizType
,
bizId
:
this
.
bizId
};
}
},
name
:
{
...
...
@@ -143,17 +157,41 @@ export default {
type
:
Function
,
default
:
undefined
},
httpRequest
:
{
type
:
Function
,
default
:
undefined
},
onExceed
:
{
type
:
Function
,
default
:
undefined
}
},
data
()
{
return
{};
return
{
fileList_d
:
this
.
fileList
};
},
watch
:
{
fileBatchId
:
{
immediate
:
true
,
deep
:
true
,
handler
:
function
(
newVal
,
oldVal
)
{
/** 只有当文件操作批次id与上一次不一样时进入 */
this
.
loadFilelItems
();
}
}
},
methods
:
{
loadFilelItems
()
{
if
(
!
this
.
fileBatchId
||
this
.
fileBatchId
.
trim
().
length
<=
0
)
{
this
.
fileList_d
=
[];
return
;
}
getFileList
({
fileBatchId
:
this
.
fileBatchId
}).
then
(
res
=>
{
const
{
code
,
data
}
=
{
...
res
};
this
.
fileList_d
=
data
||
[];
});
},
updateFiles
(
params
)
{
debugger
;
console
.
log
(
params
);
}
}
};
</
script
>
ve-admin/admin-web/src/views/users/index.vue
View file @
cc0c508e
<!--
* @Author: 一日看尽长安花
* @since: 2019-10-12 15:43:18
* @LastEditTime: 2020-03-1
1
1
5:30:15
* @LastEditTime: 2020-03-1
7
1
8:11:53
* @LastEditors: 一日看尽长安花
* @Description:
-->
...
...
@@ -104,11 +104,20 @@
</el-form-item>
<el-form-item
key=
"fileKey"
label=
"上传文档"
prop=
"file"
>
<file-upload>
<file-upload
ref=
"fileUpload"
:file-batch-id=
"dialogData.attachment_id"
:on-success=
"onUploadSuccess"
>
<el-button
slot=
"trigger"
size=
"small"
type=
"primary"
>
选取文件
</el-button>
<el-button
style=
"margin-left: 10px;"
size=
"small"
type=
"success"
>
<el-button
style=
"margin-left: 10px;"
size=
"small"
type=
"success"
@
click=
"submitUpload"
>
上传到服务器
</el-button>
<div
slot=
"tip"
class=
"el-upload__tip"
>
...
...
@@ -125,7 +134,13 @@
import
GeneralPage
from
'
@/components/GeneralPage
'
;
import
FileUpload
from
'
@/components/Upload/FileUpload
'
;
import
{
users
,
usersMetadata
,
saveUserData
,
updateUserData
}
from
'
@/api/user
'
;
import
{
users
,
usersMetadata
,
saveUserData
,
updateUserData
,
deleteUserData
}
from
'
@/api/user
'
;
import
{
immaditeLoadDicts
}
from
'
@/api/dict
'
;
import
{
immaditeLoadOrgs
}
from
'
@/api/org
'
;
import
{
layzyLoadDictTree
,
handleCascaderValue
}
from
'
@/services/dict
'
;
...
...
@@ -205,6 +220,7 @@ export default {
'
job_type1
'
]);
queryParams
=
handleCascaderValue
(
queryParams
,
'
state
'
,
[
'
state
'
]);
const
_lodash
=
this
.
$lodash
;
users
(
queryParams
)
.
then
(
result
=>
{
const
{
code
,
data
}
=
{
...
result
};
...
...
@@ -213,15 +229,14 @@ export default {
* 所以将其处理为一级节点
*/
for
(
let
i
in
result
.
data
)
{
result
.
data
[
i
][
'
org_id_value
'
]
=
result
.
data
[
i
]
[
'
org
'
][
'
id
'
]
;
result
.
data
[
i
][
'
state_value
'
]
=
result
.
data
[
i
][
'
state
'
][
'
value
'
]
;
i
f
(
result
.
data
[
i
][
'
job_type0
'
])
{
result
.
data
[
i
][
'
job_type_value
'
]
=
result
.
data
[
i
][
'
job_type0
'
][
'
value
'
]
;
let
item
=
result
.
data
[
i
];
item
[
'
org_id_value
'
]
=
_lodash
.
get
(
item
,
'
org.id
'
)
;
i
tem
[
'
state_value
'
]
=
_lodash
.
get
(
item
,
'
state.value
'
);
if
(
item
[
'
job_type0
'
])
{
item
[
'
job_type_value
'
]
=
_lodash
.
get
(
item
,
'
job_type0
.
value
'
)
;
}
if
(
result
.
data
[
i
][
'
job_type1
'
])
{
result
.
data
[
i
][
'
job_type_value
'
]
=
result
.
data
[
i
][
'
job_type1
'
][
'
value
'
];
if
(
item
[
'
job_type1
'
])
{
item
[
'
job_type_value
'
]
=
_lodash
.
get
(
item
,
'
job_type1.value
'
);
}
}
this
.
tabledata
=
Object
.
assign
({},
result
);
...
...
@@ -243,18 +258,20 @@ export default {
this
.
obtainData
(
Object
.
assign
({
page
:
1
,
limit
:
10
},
queryParams
));
},
createData
(
dialogData
)
{
this
.
handleEditorDataObject
(
dialogData
,
'
org_id_value
'
,
{
dialogData
=
this
.
handleEditorDataObject
(
dialogData
,
'
org_id_value
'
,
{
org_id
:
'
org.id
'
});
this
.
handleEditorDataObject
(
dialogData
,
'
state_value
'
,
{
dialogData
=
this
.
handleEditorDataObject
(
dialogData
,
'
state_value
'
,
{
state
:
'
state.value
'
});
this
.
handleEditorDataObject
(
dialogData
,
'
job_type_value
'
,
{
dialogData
=
this
.
handleEditorDataObject
(
dialogData
,
'
job_type_value
'
,
{
job_type0
:
'
job_type0.value
'
,
job_type1
:
'
job_type1.value
'
});
const
Vue
=
this
;
saveUserData
(
dialogData
)
.
then
(
result
=>
{
Vue
.
$children
[
0
].
$refs
.
searchPaneGP
.
$refs
.
searchButton
.
$emit
(
'
click
'
);
this
.
$nextTick
(()
=>
{
this
.
$notify
({
title
:
'
成功
'
,
...
...
@@ -276,23 +293,29 @@ export default {
});
},
updateData
(
dialogData
)
{
this
.
handleEditorDataObject
(
dialogData
,
'
org_id_value
'
,
{
dialogData
=
this
.
handleEditorDataObject
(
dialogData
,
'
org_id_value
'
,
{
org_id
:
'
org.id
'
});
this
.
handleEditorDataObject
(
dialogData
,
'
state_value
'
,
{
dialogData
=
this
.
handleEditorDataObject
(
dialogData
,
'
state_value
'
,
{
state
:
'
state.value
'
});
this
.
handleEditorDataObject
(
dialogData
,
'
job_type_value
'
,
{
dialogData
=
this
.
handleEditorDataObject
(
dialogData
,
'
job_type_value
'
,
{
job_type0
:
'
job_type0.value
'
,
job_type1
:
'
job_type1.value
'
});
const
Vue
=
this
;
updateUserData
(
dialogData
)
.
then
(
result
=>
{
this
.
$refs
[
'
searchButton
'
].
click
();
/** 刷新数据表格数据,懒得重新写个方法挂载在组件上了 */
Vue
.
$children
[
0
].
$refs
.
searchPaneGP
.
$refs
.
searchButton
.
$emit
(
'
click
'
);
/**
* 将回调延迟到下次 DOM 更新循环之后执行。
* 而数据更新就代表dom更新,所以如果创建成功,数据就会更新
*/
this
.
$nextTick
(()
=>
{
this
.
$notify
({
title
:
'
成功
'
,
message
:
'
修改成功
'
,
message
:
'
修改成功
1
'
,
type
:
'
success
'
,
duration
:
2000
});
...
...
@@ -302,7 +325,7 @@ export default {
this
.
$nextTick
(()
=>
{
this
.
$notify
({
title
:
'
失败
'
,
message
:
'
修改失败
'
,
message
:
'
修改
用户
失败
'
,
type
:
'
error
'
,
duration
:
2000
});
...
...
@@ -322,16 +345,43 @@ export default {
dialogData
[
key
]
=
this
.
$lodash
.
get
(
dialogData
,
keyPathMap
[
key
]);
}
}
return
dialogData
;
},
deleteData
(
index
,
row
)
{
this
.
$nextTick
(()
=>
{
this
.
$notify
({
title
:
'
成功
'
,
message
:
'
删除成功
'
,
type
:
'
success
'
,
duration
:
2000
deleteUserData
({
ids
:
[
row
.
id
]
})
.
then
(
result
=>
{
/** 刷新数据表格数据,懒得重新写个方法挂载在组件上了 */
Vue
.
$children
[
0
].
$refs
.
searchPaneGP
.
$refs
.
searchButton
.
$emit
(
'
click
'
);
/**
* 将回调延迟到下次 DOM 更新循环之后执行。
* 而数据更新就代表dom更新,所以如果创建成功,数据就会更新
*/
this
.
$nextTick
(()
=>
{
this
.
$notify
({
title
:
'
成功
'
,
message
:
'
删除用户成功
'
,
type
:
'
success
'
,
duration
:
2000
});
});
})
.
catch
(
err
=>
{
this
.
$nextTick
(()
=>
{
this
.
$notify
({
title
:
'
失败
'
,
message
:
'
删除用户失败
'
,
type
:
'
error
'
,
duration
:
2000
});
});
});
});
},
submitUpload
()
{
debugger
;
this
.
$refs
.
fileUpload
.
$refs
.
upload
.
submit
();
},
onUploadSuccess
(
response
,
file
,
fileList
)
{
debugger
;
}
}
};
...
...
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