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
3b59d4e7
"eladmin-system/git@ustchcs.com:gujinli1118/eladmin.git" did not exist on "4a6e6953dfc2481acfb185cc6779f5f60a01fc68"
Commit
3b59d4e7
authored
Mar 05, 2018
by
李家智
Browse files
fix bugs
parent
923f246b
Changes
11
Hide whitespace changes
Inline
Side-by-side
admin-console/src/main/java/com/ibeetl/admin/console/service/DictConsoleService.java
View file @
3b59d4e7
package
com.ibeetl.admin.console.service
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
org.beetl.sql.core.engine.PageQuery
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -8,9 +11,11 @@ import org.springframework.stereotype.Service;
import
org.springframework.transaction.annotation.Transactional
;
import
com.ibeetl.admin.console.dao.DictConsoleDao
;
import
com.ibeetl.admin.console.web.dto.DictExcelImportData
;
import
com.ibeetl.admin.core.entity.CoreDict
;
import
com.ibeetl.admin.core.entity.CoreUser
;
import
com.ibeetl.admin.core.service.BaseService
;
import
com.ibeetl.admin.core.util.ExcelError
;
import
com.ibeetl.admin.core.util.PlatformException
;
/**
...
...
@@ -43,10 +48,62 @@ public class DictConsoleService extends BaseService<CoreDict>{
queryListAfter
(
ret
.
getList
());
return
ret
.
getList
();
}
/**
* 参考:dict_mapping.xml
* @param list
* @return
*/
public
void
batchInsert
(
List
<
DictExcelImportData
>
list
)
{
int
dataStartRow
=
3
;
final
Map
<
Integer
,
DictExcelImportData
>
map
=
new
HashMap
<>();
list
.
forEach
((
item
)->
map
.
put
(
item
.
getExcelId
(),
item
));
//逐个按照顺序导入
for
(
DictExcelImportData
item:
list
)
{
CoreDict
dict
=
new
CoreDict
();
dict
.
setName
(
item
.
getName
());
dict
.
setRemark
(
item
.
getRemark
());
dict
.
setType
(
item
.
getType
());
dict
.
setTypeName
(
item
.
getTypeName
());
dict
.
setValue
(
item
.
getValue
());
//导入前先查找是否有此值
CoreDict
template
=
new
CoreDict
();
template
.
setType
(
dict
.
getType
());
template
.
setValue
(
dict
.
getValue
());
CoreDict
dbDict
=
dictDao
.
templateOne
(
template
);
if
(
dbDict
!=
null
)
{
int
row
=
item
.
getExcelId
()+
dataStartRow
;
throwImporError
(
row
,
0
,
"字典数据已经存在"
);
}
//设置父字典
if
(
item
.
getParentExcelId
()!=
0
)
{
DictExcelImportData
parentItem
=
map
.
get
(
item
.
getParentExcelId
());
if
(
parentItem
==
null
)
{
//硬编码,TODO,用reader缺少校验,替换手写导入
int
row
=
item
.
getExcelId
()+
dataStartRow
;
throwImporError
(
row
,
6
,
"未找到父字典"
);
}
if
(
parentItem
.
getId
()==
null
)
{
int
row
=
item
.
getExcelId
()+
dataStartRow
;
throwImporError
(
row
,
6
,
"父字典未被导入,请先导入父字典"
);
}
dict
.
setParent
(
parentItem
.
getId
());
}
dict
.
setCreateTime
(
new
Date
());
dictDao
.
insert
(
dict
);
item
.
setId
(
dict
.
getId
());
}
}
public
void
batchInsert
(
List
<
CoreDict
>
list
)
{
dictDao
.
insertBatch
(
list
);
private
void
throwImporError
(
int
row
,
int
col
,
String
msg
)
{
ExcelError
error
=
new
ExcelError
();
error
.
setRow
(
row
);
error
.
setCol
(
col
);
error
.
setMsg
(
msg
);
throw
new
PlatformException
(
error
.
toString
());
}
...
...
admin-console/src/main/java/com/ibeetl/admin/console/service/UserConsoleService.java
View file @
3b59d4e7
...
...
@@ -13,7 +13,7 @@ import org.springframework.transaction.annotation.Transactional;
import
com.ibeetl.admin.console.dao.UserConsoleDao
;
import
com.ibeetl.admin.console.exception.DeletedException
;
import
com.ibeetl.admin.console.exception.NoResourceException
;
import
com.ibeetl.admin.console.web.dto.UserExcelData
;
import
com.ibeetl.admin.console.web.dto.UserExcel
Export
Data
;
import
com.ibeetl.admin.console.web.query.UserRoleQuery
;
import
com.ibeetl.admin.core.conf.PasswordConfig.PasswordEncryptService
;
import
com.ibeetl.admin.core.entity.CoreDict
;
...
...
@@ -174,13 +174,13 @@ public class UserConsoleService extends BaseService<CoreUser> {
sqlManager
.
insert
(
userRole
);
}
public
List
<
UserExcelData
>
queryExcel
(
PageQuery
<
CoreUser
>
query
)
{
public
List
<
UserExcel
Export
Data
>
queryExcel
(
PageQuery
<
CoreUser
>
query
)
{
PageQuery
<
CoreUser
>
ret
=
userDao
.
queryByCondtion
(
query
);
List
<
CoreUser
>
list
=
ret
.
getList
();
OrgItem
orgRoot
=
platformService
.
buildOrg
();
List
<
UserExcelData
>
items
=
new
ArrayList
<>();
List
<
UserExcel
Export
Data
>
items
=
new
ArrayList
<>();
for
(
CoreUser
user:
list
)
{
UserExcelData
userItem
=
new
UserExcelData
();
UserExcel
Export
Data
userItem
=
new
UserExcel
Export
Data
();
userItem
.
setCode
(
user
.
getCode
());
userItem
.
setId
(
user
.
getId
());
userItem
.
setName
(
user
.
getName
());
...
...
admin-console/src/main/java/com/ibeetl/admin/console/web/DictConsoleController.java
View file @
3b59d4e7
...
...
@@ -30,6 +30,7 @@ import org.springframework.web.multipart.MultipartFile;
import
org.springframework.web.servlet.ModelAndView
;
import
com.ibeetl.admin.console.service.DictConsoleService
;
import
com.ibeetl.admin.console.web.dto.DictExcelImportData
;
import
com.ibeetl.admin.console.web.query.CoreDictQuery
;
import
com.ibeetl.admin.console.web.query.UserQuery
;
import
com.ibeetl.admin.core.annotation.Function
;
...
...
@@ -177,12 +178,18 @@ public class DictConsoleController{
XLSReader
mainReader
=
ReaderBuilder
.
buildFromXML
(
inputXML
);
InputStream
inputXLS
=
ins
;
List
<
Core
Dict
>
dicts
=
new
ArrayList
<
Core
Dict
>();
List
<
Dict
ExcelImportData
>
dicts
=
new
ArrayList
<
Dict
ExcelImportData
>();
Map
beans
=
new
HashMap
();
beans
.
put
(
"list"
,
dicts
);
XLSReadStatus
readStatus
=
mainReader
.
read
(
inputXLS
,
beans
);
System
.
out
.
println
(
dicts
);
return
JsonResult
.
success
();
// this.dictService.batchInsert(dicts);//TODO,为啥这里抛的错误,layui对话框不能正确处理http 500错误,改成下面方式
// return JsonResult.success();
try
{
this
.
dictService
.
batchInsert
(
dicts
);
return
JsonResult
.
success
();
}
catch
(
Exception
ex
)
{
return
JsonResult
.
failMessage
(
ex
.
getMessage
());
}
}
...
...
admin-console/src/main/java/com/ibeetl/admin/console/web/UserConsoleController.java
View file @
3b59d4e7
...
...
@@ -26,7 +26,7 @@ import org.springframework.web.servlet.ModelAndView;
import
com.ibeetl.admin.console.service.OrgConsoleService
;
import
com.ibeetl.admin.console.service.RoleConsoleService
;
import
com.ibeetl.admin.console.service.UserConsoleService
;
import
com.ibeetl.admin.console.web.dto.UserExcelData
;
import
com.ibeetl.admin.console.web.dto.UserExcel
Export
Data
;
import
com.ibeetl.admin.console.web.query.UserQuery
;
import
com.ibeetl.admin.console.web.query.UserRoleQuery
;
import
com.ibeetl.admin.core.annotation.Function
;
...
...
@@ -288,7 +288,7 @@ public class UserConsoleController {
page
.
setPageSize
(
Integer
.
MAX_VALUE
);
page
.
setPageNumber
(
1
);
page
.
setTotalRow
(
Integer
.
MAX_VALUE
);
List
<
UserExcelData
>
users
=
userConsoleService
.
queryExcel
(
page
);
List
<
UserExcel
Export
Data
>
users
=
userConsoleService
.
queryExcel
(
page
);
try
(
InputStream
is
=
Thread
.
currentThread
().
getContextClassLoader
().
getResourceAsStream
(
excelTemplate
))
{
if
(
is
==
null
)
{
throw
new
PlatformException
(
"模板资源不存在:"
+
excelTemplate
);
...
...
admin-console/src/main/java/com/ibeetl/admin/console/web/dto/DictExcelImportData.java
0 → 100644
View file @
3b59d4e7
package
com.ibeetl.admin.console.web.dto
;
import
com.ibeetl.admin.core.entity.CoreDict
;
/**
* 字典数据导入,参考 dict_mapping.xml
* @author xiandafu
*
*/
public
class
DictExcelImportData
extends
CoreDict
{
private
Integer
excelId
;
private
Integer
parentExcelId
;
public
Integer
getExcelId
()
{
return
excelId
;
}
public
void
setExcelId
(
Integer
excelId
)
{
this
.
excelId
=
excelId
;
}
public
Integer
getParentExcelId
()
{
return
parentExcelId
;
}
public
void
setParentExcelId
(
Integer
parentExcelId
)
{
this
.
parentExcelId
=
parentExcelId
;
}
}
admin-console/src/main/java/com/ibeetl/admin/console/web/dto/UserExcelData.java
→
admin-console/src/main/java/com/ibeetl/admin/console/web/dto/UserExcel
Export
Data.java
View file @
3b59d4e7
...
...
@@ -7,10 +7,10 @@ import com.ibeetl.admin.core.annotation.Dict;
/**
* excel导出需要的模板数据
* @author
Administrator
* @author
xiandafu
*
*/
public
class
UserExcelData
{
public
class
UserExcel
Export
Data
{
protected
Long
id
;
private
String
code
;
private
String
name
;
...
...
admin-console/src/main/resources/excelTemplates/admin/dict/dict_mapping.xml
View file @
3b59d4e7
...
...
@@ -4,14 +4,19 @@
<section
startRow=
"0"
endRow=
"2"
>
</section>
<loop
startRow=
"3"
endRow=
"3"
items=
"list"
var=
"dict"
varType=
"com.ibeetl.admin.co
re.entity.CoreDict
"
>
varType=
"com.ibeetl.admin.co
nsole.web.dto.DictExcelImportData
"
>
<section
startRow=
"3"
endRow=
"3"
>
<mapping
row=
"3"
col=
"0"
>
dict.excelId
</mapping>
<mapping
row=
"3"
col=
"1"
>
dict.name
</mapping>
<mapping
row=
"3"
col=
"2"
>
dict.value
</mapping>
<mapping
row=
"3"
col=
"3"
>
dict.typeName
</mapping>
<mapping
row=
"3"
col=
"4"
>
dict.type
</mapping>
<mapping
row=
"3"
col=
"5"
>
dict.parentExcelId
</mapping>
<mapping
row=
"3"
col=
"6"
>
dict.remark
</mapping>
</section>
<loopbreakcondition>
<rowcheck
offset=
"0"
>
<cellcheck
offset=
"
0
"
>
结束
</cellcheck>
<cellcheck
offset=
"
1
"
></cellcheck>
</rowcheck>
</loopbreakcondition>
</loop>
...
...
admin-console/src/main/resources/excelTemplates/admin/dict/dict_upload_template.xls
View file @
3b59d4e7
No preview for this file type
admin-core/src/main/java/com/ibeetl/admin/core/util/ExcelError.java
0 → 100644
View file @
3b59d4e7
package
com.ibeetl.admin.core.util
;
public
class
ExcelError
{
Integer
row
;
Integer
col
;
String
cel
;
String
msg
;
public
Integer
getRow
()
{
return
row
;
}
public
void
setRow
(
Integer
row
)
{
this
.
row
=
row
;
}
public
Integer
getCol
()
{
return
col
;
}
public
void
setCol
(
Integer
col
)
{
this
.
col
=
col
;
}
public
String
getCel
()
{
return
cel
;
}
public
void
setCel
(
String
cel
)
{
this
.
cel
=
cel
;
}
public
String
getMsg
()
{
return
msg
;
}
public
void
setMsg
(
String
msg
)
{
this
.
msg
=
msg
;
}
@Override
public
String
toString
()
{
return
"ExcelError [row="
+
row
+
", col="
+
col
+
", cel="
+
cel
+
", msg="
+
msg
+
"]"
;
}
}
admin-core/src/main/resources/sql/core/coreDict.md
View file @
3b59d4e7
findAllList
===
select
*
from core_
DICT
where del_flag = 0
select
*
from core_
dict
where del_flag = 0
@if(!isEmpty(type)){
and type = #type#
@}
...
...
admin-core/src/main/resources/templates/common/simpleUpload.html
View file @
3b59d4e7
...
...
@@ -27,16 +27,17 @@ layui.use('upload', function(){
,
accept
:
'
${fileType!"file"}
'
//默认所有文件都允许
,
url
:
'
${uploadUrl}
'
,
done
:
function
(
res
){
debugger
;
if
(
res
.
code
==
0
){
Common
.
openConfirm
(
"
上传成功,是否继续上传?
"
,
null
,
function
(){
var
index
=
parent
.
layer
.
getFrameIndex
(
window
.
name
);
//先得到当前iframe层的索引
parent
.
layer
.
close
(
index
);
//再执行关闭
})
}
else
{
Common
.
alert
(
res
.
msg
)
}
}
,
error
:
function
(){
Common
.
error
(
"
系统错误,无法访问服务器
"
)
}
});
});
...
...
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