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
18144407
Commit
18144407
authored
Sep 04, 2019
by
trumansdo
Browse files
应用codestyle
千万千万要用vscode打开前端项目,或者关闭eslint,移除它 Signed-off-by:
trumansdo
<
1012243881@qq.com
>
parent
9b3d96a6
Changes
178
Hide whitespace changes
Inline
Side-by-side
plus-admin/admin-console/src/main/java/com/ibeetl/admin/CosonleApplication.java
View file @
18144407
...
@@ -10,14 +10,13 @@ import org.springframework.cache.annotation.EnableCaching;
...
@@ -10,14 +10,13 @@ import org.springframework.cache.annotation.EnableCaching;
@EnableCaching
@EnableCaching
public
class
CosonleApplication
extends
SpringBootServletInitializer
{
public
class
CosonleApplication
extends
SpringBootServletInitializer
{
@Override
@Override
protected
SpringApplicationBuilder
configure
(
SpringApplicationBuilder
application
)
{
protected
SpringApplicationBuilder
configure
(
SpringApplicationBuilder
application
)
{
return
application
.
sources
(
CosonleApplication
.
class
);
return
application
.
sources
(
CosonleApplication
.
class
);
}
}
public
static
void
main
(
String
[]
args
)
{
public
static
void
main
(
String
[]
args
)
{
SpringApplication
.
run
(
CosonleApplication
.
class
,
args
);
SpringApplication
.
run
(
CosonleApplication
.
class
,
args
);
}
}
}
}
\ No newline at end of file
plus-admin/admin-console/src/main/java/com/ibeetl/admin/console/dao/AuditConsoleDao.java
View file @
18144407
...
@@ -9,7 +9,5 @@ import com.ibeetl.admin.core.entity.CoreAudit;
...
@@ -9,7 +9,5 @@ import com.ibeetl.admin.core.entity.CoreAudit;
@SqlResource
(
"console.audit"
)
@SqlResource
(
"console.audit"
)
public
interface
AuditConsoleDao
extends
BaseMapper
<
CoreAudit
>
{
public
interface
AuditConsoleDao
extends
BaseMapper
<
CoreAudit
>
{
PageQuery
<
CoreAudit
>
queryByCondtion
(
PageQuery
<
CoreAudit
>
query
);
PageQuery
<
CoreAudit
>
queryByCondtion
(
PageQuery
<
CoreAudit
>
query
);
}
}
plus-admin/admin-console/src/main/java/com/ibeetl/admin/console/dao/DictConsoleDao.java
View file @
18144407
...
@@ -8,11 +8,10 @@ import org.beetl.sql.core.mapper.BaseMapper;
...
@@ -8,11 +8,10 @@ import org.beetl.sql.core.mapper.BaseMapper;
import
com.ibeetl.admin.core.entity.CoreDict
;
import
com.ibeetl.admin.core.entity.CoreDict
;
/**
/** CoreDict Dao */
* CoreDict Dao
*/
@SqlResource
(
"console.dict"
)
@SqlResource
(
"console.dict"
)
public
interface
DictConsoleDao
extends
BaseMapper
<
CoreDict
>{
public
interface
DictConsoleDao
extends
BaseMapper
<
CoreDict
>
{
public
PageQuery
<
CoreDict
>
queryByCondition
(
PageQuery
query
);
public
PageQuery
<
CoreDict
>
queryByCondition
(
PageQuery
query
);
public
void
batchDelCoreDictByIds
(
List
<
Long
>
ids
);
}
public
void
batchDelCoreDictByIds
(
List
<
Long
>
ids
);
\ No newline at end of file
}
plus-admin/admin-console/src/main/java/com/ibeetl/admin/console/dao/FunctionConsoleDao.java
View file @
18144407
...
@@ -9,10 +9,10 @@ import com.ibeetl.admin.core.entity.CoreFunction;
...
@@ -9,10 +9,10 @@ import com.ibeetl.admin.core.entity.CoreFunction;
@SqlResource
(
"console.function"
)
@SqlResource
(
"console.function"
)
public
interface
FunctionConsoleDao
extends
BaseMapper
<
CoreFunction
>
{
public
interface
FunctionConsoleDao
extends
BaseMapper
<
CoreFunction
>
{
/**
/**
* 根据条件查询
* 根据条件查询
*
*
* @param query
* @param query
*/
*/
public
void
queryByCondtion
(
PageQuery
query
);
public
void
queryByCondtion
(
PageQuery
query
);
}
}
plus-admin/admin-console/src/main/java/com/ibeetl/admin/console/dao/MenuConsoleDao.java
View file @
18144407
...
@@ -9,11 +9,10 @@ import com.ibeetl.admin.core.entity.CoreMenu;
...
@@ -9,11 +9,10 @@ import com.ibeetl.admin.core.entity.CoreMenu;
@SqlResource
(
"console.menu"
)
@SqlResource
(
"console.menu"
)
public
interface
MenuConsoleDao
extends
BaseMapper
<
CoreMenu
>
{
public
interface
MenuConsoleDao
extends
BaseMapper
<
CoreMenu
>
{
/**
/**
* 根据条件分页查询
* 根据条件分页查询
* @param query 查询条件
*
*/
* @param query 查询条件
void
queryByCondtion
(
PageQuery
query
);
*/
void
queryByCondtion
(
PageQuery
query
);
}
}
plus-admin/admin-console/src/main/java/com/ibeetl/admin/console/dao/OrgConsoleDao.java
View file @
18144407
...
@@ -15,11 +15,10 @@ import com.ibeetl.admin.core.entity.CoreUser;
...
@@ -15,11 +15,10 @@ import com.ibeetl.admin.core.entity.CoreUser;
@SqlResource
(
"console.org"
)
@SqlResource
(
"console.org"
)
public
interface
OrgConsoleDao
extends
BaseMapper
<
CoreOrg
>
{
public
interface
OrgConsoleDao
extends
BaseMapper
<
CoreOrg
>
{
void
queryByCondtion
(
PageQuery
<
CoreOrg
>
query
);
void
queryByCondtion
(
PageQuery
<
CoreOrg
>
query
);
@SqlStatement
(
type
=
SqlStatementType
.
SELECT
)
@SqlStatement
(
type
=
SqlStatementType
.
SELECT
)
void
queryUserByCondtion
(
PageQuery
<
CoreUser
>
query
);
void
queryUserByCondtion
(
PageQuery
<
CoreUser
>
query
);
void
batchDelByIds
(
@Param
(
value
=
"ids"
)
List
<
Long
>
ids
);
void
batchDelByIds
(
@Param
(
value
=
"ids"
)
List
<
Long
>
ids
);
}
}
plus-admin/admin-console/src/main/java/com/ibeetl/admin/console/dao/RoleConsoleDao.java
View file @
18144407
...
@@ -13,26 +13,25 @@ import com.ibeetl.admin.core.entity.CoreUser;
...
@@ -13,26 +13,25 @@ import com.ibeetl.admin.core.entity.CoreUser;
@SqlResource
(
"console.role"
)
@SqlResource
(
"console.role"
)
public
interface
RoleConsoleDao
extends
BaseMapper
<
CoreRole
>
{
public
interface
RoleConsoleDao
extends
BaseMapper
<
CoreRole
>
{
/**
/**
* 根据条件分页查询
* 根据条件分页查询
* @param query 查询条件
*
*/
* @param query 查询条件
void
queryByCondtion
(
PageQuery
query
);
*/
void
queryByCondtion
(
PageQuery
query
);
/**
* 批量删除角色
/**
* @param ids 角色id
* 批量删除角色
*/
*
void
batchDelByIds
(
List
<
Long
>
ids
);
* @param ids 角色id
*/
void
batchDeleteRoleFunction
(
List
<
Long
>
ids
);
void
batchDelByIds
(
List
<
Long
>
ids
);
void
batchDeleteRoleMenu
(
List
<
Long
>
ids
);
void
batchDeleteUserRole
(
List
<
Long
>
ids
);
void
batchDeleteRoleFunction
(
List
<
Long
>
ids
);
void
batchDeleteRoleMenu
(
List
<
Long
>
ids
);
PageQuery
<
CoreUser
>
queryUser
(
PageQuery
query
);
void
batchDeleteUserRole
(
List
<
Long
>
ids
);
PageQuery
<
CoreUser
>
queryUser
(
PageQuery
query
);
}
}
plus-admin/admin-console/src/main/java/com/ibeetl/admin/console/dao/RoleFunctionConsoleDao.java
View file @
18144407
...
@@ -12,12 +12,9 @@ import com.ibeetl.admin.core.entity.CoreRoleFunction;
...
@@ -12,12 +12,9 @@ import com.ibeetl.admin.core.entity.CoreRoleFunction;
@SqlResource
(
"console.roleFunction"
)
@SqlResource
(
"console.roleFunction"
)
public
interface
RoleFunctionConsoleDao
extends
BaseMapper
<
CoreRoleFunction
>
{
public
interface
RoleFunctionConsoleDao
extends
BaseMapper
<
CoreRoleFunction
>
{
void
deleteRoleFunction
(
List
<
Long
>
ids
);
void
deleteRoleFunction
(
List
<
Long
>
ids
);
List
<
Long
>
getFunctionIdByRole
(
Long
roleId
);
List
<
Long
>
getFunctionIdByRole
(
Long
roleId
);
List
<
RoleDataAccessFunction
>
getQueryFunctionAndRoleData
(
Long
roleId
);
List
<
RoleDataAccessFunction
>
getQueryFunctionAndRoleData
(
Long
roleId
);
}
}
plus-admin/admin-console/src/main/java/com/ibeetl/admin/console/dao/UserConsoleDao.java
View file @
18144407
...
@@ -14,13 +14,11 @@ import java.util.List;
...
@@ -14,13 +14,11 @@ import java.util.List;
@SqlResource
(
"console.user"
)
@SqlResource
(
"console.user"
)
public
interface
UserConsoleDao
extends
BaseMapper
<
CoreUser
>
{
public
interface
UserConsoleDao
extends
BaseMapper
<
CoreUser
>
{
PageQuery
<
CoreUser
>
queryByCondtion
(
PageQuery
<
CoreUser
>
query
);
PageQuery
<
CoreUser
>
queryByCondtion
(
PageQuery
<
CoreUser
>
query
);
void
batchDelUserByIds
(
List
<
Long
>
ids
);
void
batchDelUserByIds
(
List
<
Long
>
ids
);
void
batchUpdateUserState
(
List
<
Long
>
ids
,
GeneralStateEnum
state
);
void
batchUpdateUserState
(
List
<
Long
>
ids
,
GeneralStateEnum
state
);
List
<
CoreUserRole
>
queryUserRole
(
Long
id
,
Long
orgId
,
Long
roleId
);
List
<
CoreUserRole
>
queryUserRole
(
Long
id
,
Long
orgId
,
Long
roleId
);
}
}
plus-admin/admin-console/src/main/java/com/ibeetl/admin/console/exception/DeletedException.java
View file @
18144407
...
@@ -3,16 +3,16 @@ package com.ibeetl.admin.console.exception;
...
@@ -3,16 +3,16 @@ package com.ibeetl.admin.console.exception;
import
com.ibeetl.admin.core.util.PlatformException
;
import
com.ibeetl.admin.core.util.PlatformException
;
/**
/**
* 描述:
已删除异常
* 描述: 已删除异常
*
*
* @author : xiandafu
* @author : xiandafu
*/
*/
public
class
DeletedException
extends
PlatformException
{
public
class
DeletedException
extends
PlatformException
{
public
DeletedException
()
{
public
DeletedException
()
{
super
();
super
();
}
}
public
DeletedException
(
String
message
)
{
public
DeletedException
(
String
message
)
{
super
(
message
);
super
(
message
);
}
}
}
}
plus-admin/admin-console/src/main/java/com/ibeetl/admin/console/exception/NoResourceException.java
View file @
18144407
...
@@ -8,11 +8,11 @@ import com.ibeetl.admin.core.util.PlatformException;
...
@@ -8,11 +8,11 @@ import com.ibeetl.admin.core.util.PlatformException;
* @author : xiandafu
* @author : xiandafu
*/
*/
public
class
NoResourceException
extends
PlatformException
{
public
class
NoResourceException
extends
PlatformException
{
public
NoResourceException
()
{
public
NoResourceException
()
{
super
();
super
();
}
}
public
NoResourceException
(
String
message
)
{
public
NoResourceException
(
String
message
)
{
super
(
message
);
super
(
message
);
}
}
}
}
plus-admin/admin-console/src/main/java/com/ibeetl/admin/console/service/AuditConsoleService.java
View file @
18144407
...
@@ -13,19 +13,15 @@ import com.ibeetl.admin.core.service.CoreBaseService;
...
@@ -13,19 +13,15 @@ import com.ibeetl.admin.core.service.CoreBaseService;
@Transactional
@Transactional
public
class
AuditConsoleService
extends
CoreBaseService
<
CoreAudit
>
{
public
class
AuditConsoleService
extends
CoreBaseService
<
CoreAudit
>
{
@Autowired
@Autowired
AuditConsoleDao
auditConsoleDao
;
AuditConsoleDao
auditConsoleDao
;
/**
* 根据条件查询
*
* @param query
*/
public
void
queryByCondtion
(
PageQuery
<
CoreAudit
>
query
)
{
PageQuery
<
CoreAudit
>
ret
=
auditConsoleDao
.
queryByCondtion
(
query
);
queryListAfter
(
ret
.
getList
());
}
/**
* 根据条件查询
*
* @param query
*/
public
void
queryByCondtion
(
PageQuery
<
CoreAudit
>
query
)
{
PageQuery
<
CoreAudit
>
ret
=
auditConsoleDao
.
queryByCondtion
(
query
);
queryListAfter
(
ret
.
getList
());
}
}
}
plus-admin/admin-console/src/main/java/com/ibeetl/admin/console/service/DictConsoleService.java
View file @
18144407
...
@@ -19,95 +19,89 @@ import com.ibeetl.admin.core.service.CoreBaseService;
...
@@ -19,95 +19,89 @@ import com.ibeetl.admin.core.service.CoreBaseService;
import
com.ibeetl.admin.core.util.ExcelError
;
import
com.ibeetl.admin.core.util.ExcelError
;
import
com.ibeetl.admin.core.util.PlatformException
;
import
com.ibeetl.admin.core.util.PlatformException
;
/**
/** CoreDict Service */
* CoreDict Service
*/
@Service
@Service
@Transactional
@Transactional
public
class
DictConsoleService
extends
CoreBaseService
<
CoreDict
>
{
public
class
DictConsoleService
extends
CoreBaseService
<
CoreDict
>
{
@Autowired
private
DictConsoleDao
dictDao
;
@Autowired
private
DictConsoleDao
dictDao
;
public
PageQuery
<
CoreDict
>
queryByCondition
(
PageQuery
query
)
{
PageQuery
ret
=
dictDao
.
queryByCondition
(
query
);
queryListAfter
(
ret
.
getList
());
return
ret
;
}
public
PageQuery
<
CoreDict
>
queryByCondition
(
PageQuery
query
){
public
void
batchDelCoreDict
(
List
<
Long
>
ids
)
{
PageQuery
ret
=
dictDao
.
queryByCondition
(
query
);
try
{
queryListAfter
(
ret
.
getList
());
// TODO,找到数据字典所有子类,设置删除标记
return
ret
;
dictDao
.
batchDelCoreDictByIds
(
ids
);
}
catch
(
Exception
e
)
{
throw
new
PlatformException
(
"批量删除CoreDict失败"
,
e
);
}
}
}
public
List
<
CoreDict
>
queryExcel
(
PageQuery
<
CoreUser
>
query
)
{
// 同查询,不需要额外数据
PageQuery
ret
=
dictDao
.
queryByCondition
(
query
);
queryListAfter
(
ret
.
getList
());
return
ret
.
getList
();
}
/**
* 参考:dict_mapping.xml
*
* @param list
* @return
*/
public
void
batchInsert
(
List
<
DictExcelImportData
>
list
)
{
int
dataStartRow
=
2
;
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
());
public
void
batchDelCoreDict
(
List
<
Long
>
ids
){
// 设置父字典
try
{
if
(
item
.
getParentExcelId
()
!=
0
)
{
//TODO,找到数据字典所有子类,设置删除标记
DictExcelImportData
parentItem
=
map
.
get
(
item
.
getParentExcelId
());
dictDao
.
batchDelCoreDictByIds
(
ids
);
if
(
parentItem
==
null
)
{
}
catch
(
Exception
e
)
{
// 硬编码,TODO,用reader缺少校验,替换手写导入
throw
new
PlatformException
(
"批量删除CoreDict失败"
,
e
);
int
row
=
item
.
getExcelId
()
+
dataStartRow
;
throwImporError
(
row
,
5
,
"未找到父字典"
);
}
}
if
(
parentItem
.
getId
()
==
null
)
{
int
row
=
item
.
getExcelId
()
+
dataStartRow
;
throwImporError
(
row
,
5
,
"父字典未被导入,请先导入父字典"
);
}
dict
.
setParent
(
parentItem
.
getId
());
}
dict
.
setCreateTime
(
new
Date
());
// 导入前先查找是否有此值
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
,
"字典数据已经存在"
);
}
dictDao
.
insert
(
dict
);
item
.
setId
(
dict
.
getId
());
dataStartRow
++;
}
}
public
List
<
CoreDict
>
queryExcel
(
PageQuery
<
CoreUser
>
query
)
{
}
//同查询,不需要额外数据
PageQuery
ret
=
dictDao
.
queryByCondition
(
query
);
private
void
throwImporError
(
int
row
,
int
col
,
String
msg
)
{
queryListAfter
(
ret
.
getList
());
ExcelError
error
=
new
ExcelError
();
return
ret
.
getList
();
CellReference
cr
=
new
CellReference
(
row
,
col
,
false
,
false
);
error
.
setCell
(
cr
.
formatAsString
());
}
error
.
setMsg
(
msg
);
/**
throw
new
PlatformException
(
"导入错误在:"
+
error
.
getCell
()
+
","
+
msg
);
* 参考:dict_mapping.xml
}
* @param list
}
* @return
*/
public
void
batchInsert
(
List
<
DictExcelImportData
>
list
)
{
int
dataStartRow
=
2
;
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
());
//设置父字典
if
(
item
.
getParentExcelId
()!=
0
)
{
DictExcelImportData
parentItem
=
map
.
get
(
item
.
getParentExcelId
());
if
(
parentItem
==
null
)
{
//硬编码,TODO,用reader缺少校验,替换手写导入
int
row
=
item
.
getExcelId
()+
dataStartRow
;
throwImporError
(
row
,
5
,
"未找到父字典"
);
}
if
(
parentItem
.
getId
()==
null
)
{
int
row
=
item
.
getExcelId
()+
dataStartRow
;
throwImporError
(
row
,
5
,
"父字典未被导入,请先导入父字典"
);
}
dict
.
setParent
(
parentItem
.
getId
());
}
dict
.
setCreateTime
(
new
Date
());
//导入前先查找是否有此值
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
,
"字典数据已经存在"
);
}
dictDao
.
insert
(
dict
);
item
.
setId
(
dict
.
getId
());
dataStartRow
++;
}
}
private
void
throwImporError
(
int
row
,
int
col
,
String
msg
)
{
ExcelError
error
=
new
ExcelError
();
CellReference
cr
=
new
CellReference
(
row
,
col
,
false
,
false
);
error
.
setCell
(
cr
.
formatAsString
());
error
.
setMsg
(
msg
);
throw
new
PlatformException
(
"导入错误在:"
+
error
.
getCell
()+
","
+
msg
);
}
}
\ No newline at end of file
plus-admin/admin-console/src/main/java/com/ibeetl/admin/console/service/FunctionConsoleService.java
View file @
18144407
...
@@ -22,229 +22,208 @@ import com.ibeetl.admin.core.rbac.tree.FunctionItem;
...
@@ -22,229 +22,208 @@ import com.ibeetl.admin.core.rbac.tree.FunctionItem;
import
com.ibeetl.admin.core.service.CoreBaseService
;
import
com.ibeetl.admin.core.service.CoreBaseService
;
import
com.ibeetl.admin.core.service.CorePlatformService
;
import
com.ibeetl.admin.core.service.CorePlatformService
;
import
com.ibeetl.admin.core.util.PlatformException
;
import
com.ibeetl.admin.core.util.PlatformException
;
/**
/** @author lijiazhi */
* @author lijiazhi
*
*/
@Service
@Service
@Transactional
@Transactional
public
class
FunctionConsoleService
extends
CoreBaseService
<
CoreFunction
>
{
public
class
FunctionConsoleService
extends
CoreBaseService
<
CoreFunction
>
{
@Autowired
@Autowired
FunctionConsoleDao
functionDao
;
FunctionConsoleDao
functionDao
;
@Autowired
CoreMenuDao
menuDao
;
@Autowired
@Autowired
RoleFunctionConsoleDao
roleFunctionConsoleDao
;
CoreMenuDao
menuDao
;
@Autowired
CoreRoleMenuDao
sysRoleMenuDao
;
@Autowired
@Autowired
CorePlatformService
platformService
;
RoleFunctionConsoleDao
roleFunctionConsoleDao
;
@Autowired
public
void
queryByCondtion
(
PageQuery
<
CoreFunction
>
query
)
{
CoreRoleMenuDao
sysRoleMenuDao
;
functionDao
.
queryByCondtion
(
query
);
@Autowired
List
<
CoreFunction
>
list
=
query
.
getList
();
CorePlatformService
platformService
;
this
.
queryListAfter
(
list
);
// 处理父功能名称显示
FunctionItem
root
=
platformService
.
buildFunction
();
public
void
queryByCondtion
(
PageQuery
<
CoreFunction
>
query
)
{
for
(
CoreFunction
function
:
list
)
{
functionDao
.
queryByCondtion
(
query
);
Long
parentId
=
function
.
getParentId
();
List
<
CoreFunction
>
list
=
query
.
getList
();
String
name
=
""
;
this
.
queryListAfter
(
list
);
if
(
parentId
!=
0
)
{
//处理父功能名称显示
FunctionItem
item
=
root
.
findChild
(
parentId
);
FunctionItem
root
=
platformService
.
buildFunction
();
name
=
item
!=
null
?
item
.
getName
()
:
""
;
for
(
CoreFunction
function:
list
)
{
}
Long
parentId
=
function
.
getParentId
();
function
.
set
(
"parentFunctionText"
,
name
);
String
name
=
""
;
}
if
(
parentId
!=
0
)
{
}
FunctionItem
item
=
root
.
findChild
(
parentId
);
name
=
item
!=
null
?
item
.
getName
():
""
;
public
Long
saveFunction
(
CoreFunction
function
)
{
}
function
.
set
(
"parentFunctionText"
,
name
);
functionDao
.
insert
(
function
,
true
);
platformService
.
clearFunctionCache
();
return
function
.
getId
();
}
/**
* 删除功能点,跟菜单有关联的无法删除,删除功能点导致所有缓存都需要更新
*
* @param functionId
* @return
*/
public
void
deleteFunction
(
Long
functionId
)
{
deleteFunctionId
(
functionId
);
platformService
.
clearFunctionCache
();
}
public
void
batchDeleteFunction
(
List
<
Long
>
functionIds
)
{
for
(
Long
id
:
functionIds
)
{
deleteFunctionId
(
id
);
}
platformService
.
clearFunctionCache
();
}
public
void
updateFunction
(
CoreFunction
function
)
{
functionDao
.
updateById
(
function
);
platformService
.
clearFunctionCache
();
}
public
CoreFunction
getFunction
(
Long
functionId
)
{
return
functionDao
.
unique
(
functionId
);
}
public
CoreFunction
getFunction
(
String
code
)
{
CoreFunction
query
=
new
CoreFunction
();
query
.
setCode
(
code
);
CoreFunction
db
=
functionDao
.
templateOne
(
query
);
return
db
;
}
/**
* 得到角色对应的所有功能点
*
* @param roleId
* @return
*/
public
List
<
Long
>
getFunctionByRole
(
Long
roleId
)
{
return
this
.
roleFunctionConsoleDao
.
getFunctionIdByRole
(
roleId
);
}
/**
* 得到角色对应的所有数据权限功能点
*
* @param roleId
* @return
*/
public
List
<
RoleDataAccessFunction
>
getQueryFunctionByRole
(
Long
roleId
)
{
return
this
.
roleFunctionConsoleDao
.
getQueryFunctionAndRoleData
(
roleId
);
}
/**
* 更新角色对应的功能点所有,
*
* @param roleId
* @param data,必须包含id,和 dataAcerssType,采用模板更新
*/
public
void
updateFunctionAccessByRole
(
List
<
RoleDataAccessFunction
>
data
)
{
for
(
RoleDataAccessFunction
fun
:
data
)
{
Long
roleId
=
fun
.
getRoleId
();
Long
functionId
=
fun
.
getId
();
int
accessType
=
fun
.
getDataAccessType
();
CoreRoleFunction
template
=
new
CoreRoleFunction
();
template
.
setRoleId
(
roleId
);
template
.
setFunctionId
(
functionId
);
CoreRoleFunction
ret
=
roleFunctionConsoleDao
.
templateOne
(
template
);
if
(
ret
!=
null
)
{
ret
.
setDataAccessType
(
accessType
);
roleFunctionConsoleDao
.
updateById
(
ret
);
}
else
{
template
.
setDataAccessType
(
accessType
);
template
.
setCreateTime
(
new
Date
());
roleFunctionConsoleDao
.
insert
(
template
);
}
}
}
/**
* 给角色赋予功能同时,根据赋予的功能权限,更新能访问的菜单
*
* @param adds
* @param updates
* @param dels
* @return 返回增加的项的id,用于前端
*/
public
void
updateSysRoleFunction
(
Long
roleId
,
List
<
Long
>
adds
,
List
<
Long
>
dels
)
{
for
(
Long
del
:
dels
)
{
// 获得功能关联的菜单
CoreRoleFunction
temp
=
new
CoreRoleFunction
();
temp
.
setRoleId
(
roleId
);
temp
.
setFunctionId
(
del
);
CoreRoleFunction
roleFunction
=
roleFunctionConsoleDao
.
templateOne
(
temp
);
if
(
roleFunction
==
null
)
{
throw
new
PlatformException
(
"已经被删除了RoleId="
+
roleId
+
" functionId="
+
del
);
}
CoreMenu
menu
=
queryFunctionMenu
(
roleFunction
.
getFunctionId
());
roleFunctionConsoleDao
.
deleteById
(
roleFunction
.
getId
());
if
(
menu
!=
null
)
{
// 同时,需要删除与此功能关联的菜单
CoreRoleMenu
sysRoleMenu
=
querySysRoleMenu
(
roleFunction
.
getRoleId
(),
menu
.
getId
());
if
(
sysRoleMenu
!=
null
)
{
sysRoleMenuDao
.
deleteById
(
sysRoleMenu
.
getId
());
}
}
}
}
}
for
(
Long
add
:
adds
)
{
public
Long
saveFunction
(
CoreFunction
function
){
CoreRoleFunction
function
=
new
CoreRoleFunction
();
function
.
setCreateTime
(
new
Date
());
functionDao
.
insert
(
function
,
true
);
function
.
setRoleId
(
roleId
);
platformService
.
clearFunctionCache
();
function
.
setFunctionId
(
add
);
return
function
.
getId
();
this
.
sqlManager
.
insert
(
function
);
}
CoreMenu
menu
=
queryFunctionMenu
(
add
);
if
(
menu
!=
null
)
{
// 同时,需要增加菜单
CoreRoleMenu
roleMenu
=
new
CoreRoleMenu
();
/** 删除功能点,跟菜单有关联的无法删除,删除功能点导致所有缓存都需要更新
roleMenu
.
setMenuId
(
menu
.
getId
());
* @param functionId
roleMenu
.
setRoleId
(
roleId
);
* @return
sysRoleMenuDao
.
insert
(
roleMenu
);
*/
}
public
void
deleteFunction
(
Long
functionId
){
}
deleteFunctionId
(
functionId
);
platformService
.
clearFunctionCache
();
// 清楚缓存
platformService
.
clearFunctionCache
();
}
}
private
CoreMenu
queryFunctionMenu
(
Long
functionId
)
{
public
void
batchDeleteFunction
(
List
<
Long
>
functionIds
){
CoreMenu
query
=
new
CoreMenu
();
for
(
Long
id:
functionIds
){
query
.
setFunctionId
(
functionId
);
deleteFunctionId
(
id
);
List
<
CoreMenu
>
menus
=
menuDao
.
template
(
query
);
}
return
menus
.
isEmpty
()
?
null
:
menus
.
get
(
0
);
platformService
.
clearFunctionCache
();
}
}
private
CoreRoleMenu
querySysRoleMenu
(
Long
roleId
,
Long
menuId
)
{
CoreRoleMenu
query
=
new
CoreRoleMenu
();
query
.
setMenuId
(
menuId
);
public
void
updateFunction
(
CoreFunction
function
){
query
.
setRoleId
(
roleId
);
functionDao
.
updateById
(
function
);
List
<
CoreRoleMenu
>
menus
=
sysRoleMenuDao
.
template
(
query
);
platformService
.
clearFunctionCache
();
return
menus
.
isEmpty
()
?
null
:
menus
.
get
(
0
);
}
}
public
CoreFunction
getFunction
(
Long
functionId
){
/**
return
functionDao
.
unique
(
functionId
);
* 删除某一个功能点及其子功能,对应的role-function 需要删除,菜单对应的function需要设置成空
}
*
* @param functionId
public
CoreFunction
getFunction
(
String
code
){
*/
CoreFunction
query
=
new
CoreFunction
();
private
void
deleteFunctionId
(
Long
functionId
)
{
query
.
setCode
(
code
);
FunctionItem
root
=
platformService
.
buildFunction
();
CoreFunction
db
=
functionDao
.
templateOne
(
query
);
FunctionItem
fun
=
root
.
findChild
(
functionId
);
return
db
;
List
<
FunctionItem
>
all
=
fun
.
findAllItem
();
}
// 也删除自身
all
.
add
(
fun
);
/**
realDeleteFunction
(
all
);
* 得到角色对应的所有功能点
}
* @param roleId
* @return
private
void
realDeleteFunction
(
List
<
FunctionItem
>
all
)
{
*/
List
<
Long
>
ids
=
new
ArrayList
<>(
all
.
size
());
public
List
<
Long
>
getFunctionByRole
(
Long
roleId
){
for
(
FunctionItem
item
:
all
)
{
return
this
.
roleFunctionConsoleDao
.
getFunctionIdByRole
(
roleId
);
ids
.
add
(
item
.
getId
());
}
this
.
functionDao
.
deleteById
(
item
.
getId
());
}
/**
// 删除角色和功能的关系
* 得到角色对应的所有数据权限功能点
this
.
roleFunctionConsoleDao
.
deleteRoleFunction
(
ids
);
* @param roleId
// 设置菜单对应的功能项为空
* @return
menuDao
.
clearMenuFunction
(
ids
);
*/
}
public
List
<
RoleDataAccessFunction
>
getQueryFunctionByRole
(
Long
roleId
){
return
this
.
roleFunctionConsoleDao
.
getQueryFunctionAndRoleData
(
roleId
);
}
/**
* 更新角色对应的功能点所有,
* @param roleId
* @param data,必须包含id,和 dataAcerssType,采用模板更新
*/
public
void
updateFunctionAccessByRole
(
List
<
RoleDataAccessFunction
>
data
){
for
(
RoleDataAccessFunction
fun:
data
){
Long
roleId
=
fun
.
getRoleId
();
Long
functionId
=
fun
.
getId
();
int
accessType
=
fun
.
getDataAccessType
();
CoreRoleFunction
template
=
new
CoreRoleFunction
();
template
.
setRoleId
(
roleId
);
template
.
setFunctionId
(
functionId
);
CoreRoleFunction
ret
=
roleFunctionConsoleDao
.
templateOne
(
template
);
if
(
ret
!=
null
)
{
ret
.
setDataAccessType
(
accessType
);
roleFunctionConsoleDao
.
updateById
(
ret
);
}
else
{
template
.
setDataAccessType
(
accessType
);
template
.
setCreateTime
(
new
Date
());
roleFunctionConsoleDao
.
insert
(
template
);
}
}
}
/** 给角色赋予功能同时,根据赋予的功能权限,更新能访问的菜单
* @param adds
* @param updates
* @param dels
* @return 返回增加的项的id,用于前端
*/
public
void
updateSysRoleFunction
(
Long
roleId
,
List
<
Long
>
adds
,
List
<
Long
>
dels
){
for
(
Long
del:
dels
){
//获得功能关联的菜单
CoreRoleFunction
temp
=
new
CoreRoleFunction
();
temp
.
setRoleId
(
roleId
);
temp
.
setFunctionId
(
del
);
CoreRoleFunction
roleFunction
=
roleFunctionConsoleDao
.
templateOne
(
temp
);
if
(
roleFunction
==
null
){
throw
new
PlatformException
(
"已经被删除了RoleId="
+
roleId
+
" functionId="
+
del
);
}
CoreMenu
menu
=
queryFunctionMenu
(
roleFunction
.
getFunctionId
());
roleFunctionConsoleDao
.
deleteById
(
roleFunction
.
getId
());
if
(
menu
!=
null
){
//同时,需要删除与此功能关联的菜单
CoreRoleMenu
sysRoleMenu
=
querySysRoleMenu
(
roleFunction
.
getRoleId
(),
menu
.
getId
());
if
(
sysRoleMenu
!=
null
){
sysRoleMenuDao
.
deleteById
(
sysRoleMenu
.
getId
());
}
}
}
for
(
Long
add:
adds
){
CoreRoleFunction
function
=
new
CoreRoleFunction
();
function
.
setCreateTime
(
new
Date
());
function
.
setRoleId
(
roleId
);
function
.
setFunctionId
(
add
);
this
.
sqlManager
.
insert
(
function
);
CoreMenu
menu
=
queryFunctionMenu
(
add
);
if
(
menu
!=
null
){
//同时,需要增加菜单
CoreRoleMenu
roleMenu
=
new
CoreRoleMenu
();
roleMenu
.
setMenuId
(
menu
.
getId
());
roleMenu
.
setRoleId
(
roleId
);
sysRoleMenuDao
.
insert
(
roleMenu
);
}
}
//清楚缓存
platformService
.
clearFunctionCache
();
}
private
CoreMenu
queryFunctionMenu
(
Long
functionId
){
CoreMenu
query
=
new
CoreMenu
();
query
.
setFunctionId
(
functionId
);
List
<
CoreMenu
>
menus
=
menuDao
.
template
(
query
);
return
menus
.
isEmpty
()?
null
:
menus
.
get
(
0
);
}
private
CoreRoleMenu
querySysRoleMenu
(
Long
roleId
,
Long
menuId
){
CoreRoleMenu
query
=
new
CoreRoleMenu
();
query
.
setMenuId
(
menuId
);
query
.
setRoleId
(
roleId
);
List
<
CoreRoleMenu
>
menus
=
sysRoleMenuDao
.
template
(
query
);
return
menus
.
isEmpty
()?
null
:
menus
.
get
(
0
);
}
/**
* 删除某一个功能点及其子功能,对应的role-function 需要删除,菜单对应的function需要设置成空
* @param functionId
*/
private
void
deleteFunctionId
(
Long
functionId
){
FunctionItem
root
=
platformService
.
buildFunction
();
FunctionItem
fun
=
root
.
findChild
(
functionId
);
List
<
FunctionItem
>
all
=
fun
.
findAllItem
();
//也删除自身
all
.
add
(
fun
);
realDeleteFunction
(
all
);
}
private
void
realDeleteFunction
(
List
<
FunctionItem
>
all
){
List
<
Long
>
ids
=
new
ArrayList
<>(
all
.
size
());
for
(
FunctionItem
item:
all
){
ids
.
add
(
item
.
getId
());
this
.
functionDao
.
deleteById
(
item
.
getId
());
}
//删除角色和功能的关系
this
.
roleFunctionConsoleDao
.
deleteRoleFunction
(
ids
);
//设置菜单对应的功能项为空
menuDao
.
clearMenuFunction
(
ids
);
}
}
}
plus-admin/admin-console/src/main/java/com/ibeetl/admin/console/service/MenuConsoleService.java
View file @
18144407
...
@@ -20,71 +20,66 @@ import java.util.List;
...
@@ -20,71 +20,66 @@ import java.util.List;
@Transactional
@Transactional
public
class
MenuConsoleService
extends
CoreBaseService
<
CoreMenu
>
{
public
class
MenuConsoleService
extends
CoreBaseService
<
CoreMenu
>
{
@Autowired
@Autowired
MenuConsoleDao
menuDao
;
MenuConsoleDao
menuDao
;
@Autowired
CoreRoleMenuDao
roleMenuDao
;
@Autowired
CoreRoleMenuDao
roleMenuDao
;
@Autowired
@Autowired
CorePlatformService
platformService
;
CorePlatformService
platformService
;
public
void
queryByCondtion
(
PageQuery
<
CoreMenu
>
query
)
{
public
void
queryByCondtion
(
PageQuery
<
CoreMenu
>
query
)
{
menuDao
.
queryByCondtion
(
query
);
menuDao
.
queryByCondtion
(
query
);
queryListAfter
(
query
.
getList
());
queryListAfter
(
query
.
getList
());
}
}
public
Long
saveMenu
(
CoreMenu
menu
)
{
CoreMenu
query
=
new
CoreMenu
();
query
.
setCode
(
menu
.
getCode
());
long
queryCount
=
menuDao
.
templateCount
(
query
);
if
(
queryCount
>
0
)
{
throw
new
PlatformException
(
"菜单编码已存在"
);
}
menuDao
.
insert
(
menu
,
true
);
platformService
.
clearMenuCache
();
return
menu
.
getId
();
}
public
void
deleteMenu
(
Long
menuId
)
{
public
Long
saveMenu
(
CoreMenu
menu
)
{
deleteMenuId
(
menuId
);
CoreMenu
query
=
new
CoreMenu
();
query
.
setCode
(
menu
.
getCode
());
long
queryCount
=
menuDao
.
templateCount
(
query
);
if
(
queryCount
>
0
)
{
throw
new
PlatformException
(
"菜单编码已存在"
);
}
}
menuDao
.
insert
(
menu
,
true
);
platformService
.
clearMenuCache
();
return
menu
.
getId
();
}
public
void
batchDeleteMenuId
(
List
<
Long
>
menuIds
)
{
public
void
deleteMenu
(
Long
menuId
)
{
for
(
Long
id
:
menuIds
)
{
deleteMenuId
(
menuId
);
deleteMenuId
(
id
);
}
}
platformService
.
clearMenuCache
();
}
public
void
updateMenu
(
CoreMenu
menu
)
{
menuDao
.
updateById
(
menu
);
platformService
.
clearMenuCache
();
}
public
CoreMenu
getMenu
(
Long
menuId
)
{
public
void
batchDeleteMenuId
(
List
<
Long
>
menuIds
)
{
CoreMenu
menu
=
menuDao
.
unique
(
menuId
);
for
(
Long
id
:
menuIds
)
{
platformService
.
clearMenuCache
();
deleteMenuId
(
id
);
return
menu
;
}
}
platformService
.
clearMenuCache
();
}
public
void
updateMenu
(
CoreMenu
menu
)
{
menuDao
.
updateById
(
menu
);
platformService
.
clearMenuCache
();
}
private
void
deleteMenuId
(
Long
menuId
)
{
public
CoreMenu
getMenu
(
Long
menuId
)
{
MenuItem
root
=
platformService
.
buildMenu
();
CoreMenu
menu
=
menuDao
.
unique
(
menuId
);
MenuItem
fun
=
root
.
findChild
(
menuId
);
platformService
.
clearMenuCache
();
List
<
MenuItem
>
all
=
fun
.
findAllItem
();
return
menu
;
//也删除自身
}
all
.
add
(
fun
);
realDeleteMenu
(
all
);
}
private
void
realD
eleteMenu
(
List
<
MenuItem
>
all
)
{
private
void
d
eleteMenu
Id
(
Long
menuId
)
{
List
<
Long
>
ids
=
new
ArrayList
<>(
all
.
size
()
);
MenuItem
root
=
platformService
.
buildMenu
(
);
for
(
MenuItem
item
:
all
)
{
MenuItem
fun
=
root
.
findChild
(
menuId
);
ids
.
add
(
item
.
getId
()
);
List
<
MenuItem
>
all
=
fun
.
findAllItem
(
);
this
.
menuDao
.
deleteById
(
item
.
getId
());
// 也删除自身
}
all
.
add
(
fun
);
//删除角色和菜单的关系
realDeleteMenu
(
all
);
roleMenuDao
.
deleteRoleMenu
(
ids
);
}
private
void
realDeleteMenu
(
List
<
MenuItem
>
all
)
{
List
<
Long
>
ids
=
new
ArrayList
<>(
all
.
size
());
for
(
MenuItem
item
:
all
)
{
ids
.
add
(
item
.
getId
());
this
.
menuDao
.
deleteById
(
item
.
getId
());
}
}
// 删除角色和菜单的关系
roleMenuDao
.
deleteRoleMenu
(
ids
);
}
}
}
plus-admin/admin-console/src/main/java/com/ibeetl/admin/console/service/OrgConsoleService.java
View file @
18144407
...
@@ -16,79 +16,71 @@ import com.ibeetl.admin.core.service.CoreBaseService;
...
@@ -16,79 +16,71 @@ import com.ibeetl.admin.core.service.CoreBaseService;
import
com.ibeetl.admin.core.service.CorePlatformService
;
import
com.ibeetl.admin.core.service.CorePlatformService
;
import
com.ibeetl.admin.core.util.PlatformException
;
import
com.ibeetl.admin.core.util.PlatformException
;
/**
/** @author : xiandafu */
*
* @author : xiandafu
*/
@Service
@Service
@Transactional
@Transactional
public
class
OrgConsoleService
extends
CoreBaseService
<
CoreOrg
>
{
public
class
OrgConsoleService
extends
CoreBaseService
<
CoreOrg
>
{
@Autowired
@Autowired
private
OrgConsoleDao
orgDao
;
private
OrgConsoleDao
orgDao
;
@Autowired
@Autowired
private
CorePlatformService
platformService
;
private
CorePlatformService
platformService
;
/**
/**
* 根据条件查询
* 根据条件查询
* @param query
*
*/
* @param query
public
void
queryByCondtion
(
PageQuery
<
CoreOrg
>
query
)
{
*/
orgDao
.
queryByCondtion
(
query
)
;
public
void
queryByCondtion
(
PageQuery
<
CoreOrg
>
query
)
{
List
<
CoreOrg
>
list
=
query
.
getList
(
);
orgDao
.
queryByCondtion
(
query
);
queryListAfter
(
list
);
List
<
CoreOrg
>
list
=
query
.
getList
(
);
OrgItem
root
=
platformService
.
buildOrg
(
);
queryListAfter
(
list
);
//处理父机构名称显示,没有用sql查询是考虑到跨数据库
OrgItem
root
=
platformService
.
buildOrg
();
for
(
CoreOrg
org:
list
)
{
// 处理父机构名称显示,没有用sql查询是考虑到跨数据库
Long
parentId
=
org
.
getParentOrgId
();
for
(
CoreOrg
org
:
list
)
{
OrgItem
item
=
root
.
findChild
(
p
arentId
);
Long
parentId
=
org
.
getP
arent
Org
Id
(
);
String
name
=
item
!=
null
?
item
.
getName
():
""
;
OrgItem
item
=
root
.
findChild
(
parentId
)
;
org
.
set
(
"parentOrgText"
,
name
)
;
String
name
=
item
!=
null
?
item
.
getName
()
:
""
;
}
org
.
set
(
"parentOrgText"
,
name
);
}
}
}
public
void
queryUserByCondition
(
PageQuery
<
CoreUser
>
query
)
{
orgDao
.
queryUserByCondtion
(
query
);
queryListAfter
(
query
.
getList
());
}
/**
public
void
queryUserByCondition
(
PageQuery
<
CoreUser
>
query
)
{
* 获取机构下面的所以机构
orgDao
.
queryUserByCondtion
(
query
);
* @param orgId 机构id
queryListAfter
(
query
.
getList
());
*/
}
public
List
<
Long
>
getAllChildIdsByOrgId
(
Long
orgId
)
{
if
(
orgId
==
null
)
return
null
;
OrgItem
orgItem
=
platformService
.
buildOrg
().
findChild
(
orgId
);
/**
if
(
orgItem
==
null
)
{
* 获取机构下面的所以机构
return
null
;
*
}
* @param orgId 机构id
List
<
Long
>
ids
=
orgItem
.
findAllChildrenId
();
*/
if
(
ids
==
null
)
{
public
List
<
Long
>
getAllChildIdsByOrgId
(
Long
orgId
)
{
ids
=
new
ArrayList
<>();
if
(
orgId
==
null
)
return
null
;
}
ids
.
add
(
orgId
);
return
ids
;
OrgItem
orgItem
=
platformService
.
buildOrg
().
findChild
(
orgId
);
if
(
orgItem
==
null
)
{
return
null
;
}
}
List
<
Long
>
ids
=
orgItem
.
findAllChildrenId
();
@Override
if
(
ids
==
null
)
{
public
boolean
deleteById
(
List
<
Long
>
ids
)
{
ids
=
new
ArrayList
<>();
OrgItem
root
=
platformService
.
buildOrg
();
//检查子节点
for
(
Long
id
:
ids
)
{
OrgItem
child
=
root
.
findChild
(
id
);
if
(
child
.
getChildren
().
size
()!=
0
){
throw
new
PlatformException
(
"不能删除 "
+
child
.
getOrg
().
getName
()+
",还包含子机构"
);
}
}
return
super
.
deleteById
(
ids
);
}
}
ids
.
add
(
orgId
);
return
ids
;
}
@Override
public
boolean
deleteById
(
List
<
Long
>
ids
)
{
OrgItem
root
=
platformService
.
buildOrg
();
// 检查子节点
for
(
Long
id
:
ids
)
{
OrgItem
child
=
root
.
findChild
(
id
);
if
(
child
.
getChildren
().
size
()
!=
0
)
{
throw
new
PlatformException
(
"不能删除 "
+
child
.
getOrg
().
getName
()
+
",还包含子机构"
);
}
}
return
super
.
deleteById
(
ids
);
}
}
}
plus-admin/admin-console/src/main/java/com/ibeetl/admin/console/service/RoleConsoleService.java
View file @
18144407
...
@@ -22,90 +22,83 @@ import com.ibeetl.admin.core.util.enums.RoleTypeEnum;
...
@@ -22,90 +22,83 @@ import com.ibeetl.admin.core.util.enums.RoleTypeEnum;
@Service
@Service
@Transactional
@Transactional
public
class
RoleConsoleService
extends
CoreBaseService
<
CoreRole
>
{
public
class
RoleConsoleService
extends
CoreBaseService
<
CoreRole
>
{
private
static
final
Logger
LOGGER
=
LoggerFactory
.
getLogger
(
RoleConsoleService
.
class
);
private
static
final
Logger
LOGGER
=
LoggerFactory
.
getLogger
(
RoleConsoleService
.
class
);
@Autowired
@Autowired
private
RoleConsoleDao
roleDao
;
private
RoleConsoleDao
roleDao
;
@Autowired
private
SQLManager
sqlManager
;
@Autowired
@Autowired
private
SQLManager
sqlManager
;
CorePlatformService
platformService
;
/**
@Autowired
CorePlatformService
platformService
;
* 获取全部操作角色集合
* @return
*/
public
List
<
CoreRole
>
queryAllPermissionList
()
{
CoreRole
template
=
new
CoreRole
();
template
.
setType
(
RoleTypeEnum
.
ACCESS
.
getValue
());
return
roleDao
.
template
(
template
);
}
/**
/**
* 根据删标记获取全部角色集合
* 获取全部操作角色集合
* @param delFlagEnum 删除标记
*
* @return
* @return
*/
*/
public
List
<
CoreRole
>
queryAllList
()
{
public
List
<
CoreRole
>
queryAllPermissionList
()
{
return
roleDao
.
all
();
CoreRole
template
=
new
CoreRole
();
}
template
.
setType
(
RoleTypeEnum
.
ACCESS
.
getValue
());
return
roleDao
.
template
(
template
);
}
/**
/**
* 根据条件查询
* 根据删标记获取全部角色集合
* @param query
*
*/
* @param delFlagEnum 删除标记
public
void
queryByCondtion
(
PageQuery
query
)
{
* @return
roleDao
.
queryByCondtion
(
query
);
*/
super
.
queryListAfter
(
query
.
getList
());
public
List
<
CoreRole
>
queryAllList
()
{
}
return
roleDao
.
all
();
}
/**
public
PageQuery
<
CoreUser
>
queryRoleUser
(
PageQuery
query
)
{
* 根据条件查询
OrgItem
root
=
platformService
.
buildOrg
();
*
PageQuery
<
CoreUser
>
ret
=
roleDao
.
queryUser
(
query
);
* @param query
List
<
CoreUser
>
list
=
ret
.
getList
();
*/
//从缓存里取出组织机构名称
public
void
queryByCondtion
(
PageQuery
query
)
{
for
(
CoreUser
user:
list
)
{
roleDao
.
queryByCondtion
(
query
);
Long
orgId
=
user
.
getOrgId
();
super
.
queryListAfter
(
query
.
getList
());
Integer
orgId1
=
(
Integer
)
user
.
get
(
"orgId1"
);
}
user
.
set
(
"orgIdText"
,
root
.
findChild
(
orgId
).
getName
());
user
.
set
(
"orgId1Text"
,
root
.
findChild
((
long
)
orgId1
).
getName
());
}
//再次处理数据字典
this
.
queryListAfter
(
list
);
return
ret
;
}
/**
public
PageQuery
<
CoreUser
>
queryRoleUser
(
PageQuery
query
)
{
* 根据编号查询
OrgItem
root
=
platformService
.
buildOrg
();
* @param code 角色编号
PageQuery
<
CoreUser
>
ret
=
roleDao
.
queryUser
(
query
);
* @return
List
<
CoreUser
>
list
=
ret
.
getList
();
*/
// 从缓存里取出组织机构名称
public
CoreRole
queryByCode
(
String
code
)
{
for
(
CoreUser
user
:
list
)
{
CoreRole
queryRole
=
new
CoreRole
();
Long
orgId
=
user
.
getOrgId
();
queryRole
.
setCode
(
code
);
Integer
orgId1
=
(
Integer
)
user
.
get
(
"orgId1"
);
CoreRole
role
=
roleDao
.
templateOne
(
queryRole
);
user
.
set
(
"orgIdText"
,
root
.
findChild
(
orgId
).
getName
()
);
return
role
;
user
.
set
(
"orgId1Text"
,
root
.
findChild
((
long
)
orgId1
).
getName
())
;
}
}
// 再次处理数据字典
this
.
queryListAfter
(
list
);
return
ret
;
}
/**
* 根据编号查询
*
* @param code 角色编号
* @return
*/
public
CoreRole
queryByCode
(
String
code
)
{
CoreRole
queryRole
=
new
CoreRole
();
queryRole
.
setCode
(
code
);
CoreRole
role
=
roleDao
.
templateOne
(
queryRole
);
return
role
;
}
public
boolean
deleteById
(
List
<
Long
>
ids
)
{
public
boolean
deleteById
(
List
<
Long
>
ids
)
{
if
(
ids
==
null
||
ids
.
isEmpty
())
{
if
(
ids
==
null
||
ids
.
isEmpty
())
{
throw
new
PlatformException
(
"删除数据ID不能为空"
);
throw
new
PlatformException
(
"删除数据ID不能为空"
);
}
roleDao
.
batchDelByIds
(
ids
);
roleDao
.
batchDeleteRoleFunction
(
ids
);
roleDao
.
batchDeleteRoleMenu
(
ids
);
roleDao
.
batchDeleteUserRole
(
ids
);
return
true
;
}
}
roleDao
.
batchDelByIds
(
ids
);
roleDao
.
batchDeleteRoleFunction
(
ids
);
roleDao
.
batchDeleteRoleMenu
(
ids
);
roleDao
.
batchDeleteUserRole
(
ids
);
return
true
;
}
}
}
plus-admin/admin-console/src/main/java/com/ibeetl/admin/console/service/UserConsoleService.java
View file @
18144407
...
@@ -34,182 +34,168 @@ import com.ibeetl.admin.core.util.enums.GeneralStateEnum;
...
@@ -34,182 +34,168 @@ import com.ibeetl.admin.core.util.enums.GeneralStateEnum;
@Transactional
@Transactional
public
class
UserConsoleService
extends
CoreBaseService
<
CoreUser
>
{
public
class
UserConsoleService
extends
CoreBaseService
<
CoreUser
>
{
@Autowired
@Autowired
UserConsoleDao
userDao
;
UserConsoleDao
userDao
;
@Autowired
FileService
fileService
;
@Autowired
@Autowired
PasswordEncryptService
passwordEncryptService
;
FileService
fileService
;
@Autowired
CoreDictService
dictService
;
@Autowired
@Autowired
CorePlatformService
platformService
;
PasswordEncryptService
passwordEncryptService
;
/**
@Autowired
* 根据条件查询
CoreDictService
dictService
;
*
* @param query
*/
@Autowired
public
void
queryByCondtion
(
PageQuery
<
CoreUser
>
query
)
{
CorePlatformService
platformService
;
PageQuery
<
CoreUser
>
ret
=
userDao
.
queryByCondtion
(
query
);
/**
queryListAfter
(
ret
.
getList
());
* 根据条件查询
}
*
* @param query
/**
*/
* 插入一条用户数据
public
void
queryByCondtion
(
PageQuery
<
CoreUser
>
query
)
{
*
PageQuery
<
CoreUser
>
ret
=
userDao
.
queryByCondtion
(
query
);
* @param user
queryListAfter
(
ret
.
getList
());
*/
}
public
void
saveUser
(
CoreUser
user
)
{
CoreUser
query
=
new
CoreUser
();
/**
query
.
setCode
(
user
.
getCode
());
* 插入一条用户数据
CoreUser
dbUser
=
userDao
.
templateOne
(
query
);
*
if
(
dbUser
!=
null
)
{
* @param user
throw
new
PlatformException
(
"保存用户信息失败,用户已经存在"
);
*/
}
public
void
saveUser
(
CoreUser
user
)
{
user
.
setCreateTime
(
new
Date
());
CoreUser
query
=
new
CoreUser
();
user
.
setState
(
GeneralStateEnum
.
ENABLE
.
getValue
());
query
.
setCode
(
user
.
getCode
());
user
.
setPassword
(
passwordEncryptService
.
password
(
user
.
getPassword
()));
CoreUser
dbUser
=
userDao
.
templateOne
(
query
);
user
.
setDelFlag
(
DelFlagEnum
.
NORMAL
.
getValue
());
if
(
dbUser
!=
null
)
{
userDao
.
insert
(
user
,
true
);
throw
new
PlatformException
(
"保存用户信息失败,用户已经存在"
);
if
(
StringUtils
.
isNotEmpty
(
user
.
getAttachmentId
()))
{
}
// 更新附件详细信息,关联到这个用户
user
.
setCreateTime
(
new
Date
());
fileService
.
updateFile
(
user
.
setState
(
GeneralStateEnum
.
ENABLE
.
getValue
());
user
.
getAttachmentId
(),
User
.
class
.
getSimpleName
(),
String
.
valueOf
(
user
.
getId
()));
user
.
setPassword
(
passwordEncryptService
.
password
(
user
.
getPassword
()));
}
user
.
setDelFlag
(
DelFlagEnum
.
NORMAL
.
getValue
());
}
userDao
.
insert
(
user
,
true
);
if
(
StringUtils
.
isNotEmpty
(
user
.
getAttachmentId
())){
/**
//更新附件详细信息,关联到这个用户
* 根据用户id查询一条数据
fileService
.
updateFile
(
user
.
getAttachmentId
(),
User
.
class
.
getSimpleName
(),
String
.
valueOf
(
user
.
getId
()));
*
}
* @param userId
*/
public
CoreUser
queryUserById
(
Long
userId
)
{
}
return
userDao
.
unique
(
userId
);
}
/**
* 根据用户id查询一条数据
/**
*
* 更新用户 只更新不为空的字段
* @param userId
*
*/
* @param user
public
CoreUser
queryUserById
(
Long
userId
)
{
* @return
return
userDao
.
unique
(
userId
);
*/
}
public
int
updateSysUser
(
CoreUser
user
)
{
return
userDao
.
updateTemplateById
(
user
);
/**
}
* 更新用户 只更新不为空的字段
*
/**
* @param user
* 删除用户
* @return
*
*/
* @param userId 用户id
public
int
updateSysUser
(
CoreUser
user
)
{
*/
return
userDao
.
updateTemplateById
(
user
);
public
void
delSysUser
(
Long
userId
)
{
}
CoreUser
user
=
queryUserById
(
userId
);
if
(
user
==
null
)
{
/**
throw
new
NoResourceException
(
"用户不存在!"
);
* 删除用户
}
*
if
(
user
.
getDelFlag
()
==
DelFlagEnum
.
DELETED
.
getValue
())
{
* @param userId
throw
new
DeletedException
(
"用户已被删除!"
);
* 用户id
}
*/
user
=
new
CoreUser
();
public
void
delSysUser
(
Long
userId
)
{
user
.
setId
(
userId
);
CoreUser
user
=
queryUserById
(
userId
);
user
.
setDelFlag
(
DelFlagEnum
.
DELETED
.
getValue
());
if
(
user
==
null
)
{
userDao
.
updateTemplateById
(
user
);
throw
new
NoResourceException
(
"用户不存在!"
);
}
}
if
(
user
.
getDelFlag
()
==
DelFlagEnum
.
DELETED
.
getValue
())
{
/**
throw
new
DeletedException
(
"用户已被删除!"
);
* 批量删除用户 <br>
}
* 软删除 标记用户删除状态
user
=
new
CoreUser
();
*
user
.
setId
(
userId
);
* @param userIds 用户id
user
.
setDelFlag
(
DelFlagEnum
.
DELETED
.
getValue
());
*/
userDao
.
updateTemplateById
(
user
);
public
void
batchDelSysUser
(
List
<
Long
>
userIds
)
{
}
try
{
userDao
.
batchDelUserByIds
(
userIds
);
/**
}
catch
(
Exception
e
)
{
* 批量删除用户 <br/>
throw
new
PlatformException
(
"批量删除用户失败"
,
e
);
* 软删除 标记用户删除状态
}
*
}
* @param userIds
* 用户id
/**
*/
* 批量停用用户 <br>
public
void
batchDelSysUser
(
List
<
Long
>
userIds
)
{
* 标记用户状态 停用
try
{
*
userDao
.
batchDelUserByIds
(
userIds
);
* @param userIds 用户id
}
catch
(
Exception
e
)
{
*/
throw
new
PlatformException
(
"批量删除用户失败"
,
e
);
public
void
batchUpdateUserState
(
List
<
Long
>
userIds
,
GeneralStateEnum
stateEnum
)
{
}
userDao
.
batchUpdateUserState
(
userIds
,
stateEnum
);
}
}
/**
/**
* 批量停用用户 <br/>
* 重置用户密码
* 标记用户状态 停用
*
*
* @param uId
* @param userIds
* @param password
* 用户id
*/
*/
public
int
resetPassword
(
Long
id
,
String
password
)
{
public
void
batchUpdateUserState
(
List
<
Long
>
userIds
,
GeneralStateEnum
stateEnum
)
{
CoreUser
user
=
new
CoreUser
();
userDao
.
batchUpdateUserState
(
userIds
,
stateEnum
);
user
.
setId
(
id
);
}
user
.
setPassword
(
passwordEncryptService
.
password
(
password
));
user
.
setUpdateTime
(
new
Date
());
/**
return
userDao
.
updateTemplateById
(
user
);
* 重置用户密码
}
*
* @param uId
public
List
<
CoreUserRole
>
getUserRoles
(
UserRoleQuery
roleQuery
)
{
* @param password
return
userDao
.
queryUserRole
(
*/
roleQuery
.
getUserId
(),
roleQuery
.
getOrgId
(),
roleQuery
.
getRoleId
());
public
int
resetPassword
(
Long
id
,
String
password
)
{
}
CoreUser
user
=
new
CoreUser
();
user
.
setId
(
id
);
public
void
deleteUserRoles
(
List
<
Long
>
ids
)
{
user
.
setPassword
(
passwordEncryptService
.
password
(
password
));
// 考虑到这个操作较少使用,就不做批处理优化了
user
.
setUpdateTime
(
new
Date
());
for
(
Long
id
:
ids
)
{
return
userDao
.
updateTemplateById
(
user
);
sqlManager
.
deleteById
(
CoreUserRole
.
class
,
id
);
}
}
}
public
List
<
CoreUserRole
>
getUserRoles
(
UserRoleQuery
roleQuery
)
{
return
userDao
.
queryUserRole
(
roleQuery
.
getUserId
(),
roleQuery
.
getOrgId
(),
roleQuery
.
getRoleId
());
public
void
saveUserRole
(
CoreUserRole
userRole
)
{
}
long
queryCount
=
sqlManager
.
templateCount
(
userRole
);
public
void
deleteUserRoles
(
List
<
Long
>
ids
)
{
// 考虑到这个操作较少使用,就不做批处理优化了
if
(
queryCount
>
0
)
{
for
(
Long
id
:
ids
)
{
throw
new
PlatformException
(
"已存在用户角色关系"
);
sqlManager
.
deleteById
(
CoreUserRole
.
class
,
id
);
}
}
sqlManager
.
insert
(
userRole
);
}
}
public
List
<
UserExcelExportData
>
queryExcel
(
PageQuery
<
CoreUser
>
query
)
{
public
void
saveUserRole
(
CoreUserRole
userRole
)
{
PageQuery
<
CoreUser
>
ret
=
userDao
.
queryByCondtion
(
query
);
List
<
CoreUser
>
list
=
ret
.
getList
();
long
queryCount
=
sqlManager
.
templateCount
(
userRole
);
OrgItem
orgRoot
=
platformService
.
buildOrg
();
List
<
UserExcelExportData
>
items
=
new
ArrayList
<>();
if
(
queryCount
>
0
)
{
for
(
CoreUser
user
:
list
)
{
throw
new
PlatformException
(
"已存在用户角色关系"
);
UserExcelExportData
userItem
=
new
UserExcelExportData
();
}
userItem
.
setCode
(
user
.
getCode
());
sqlManager
.
insert
(
userRole
);
userItem
.
setId
(
user
.
getId
());
}
userItem
.
setName
(
user
.
getName
());
CoreDict
dict
=
dictService
.
findCoreDict
(
CoreDictType
.
USER_STATE
,
user
.
getState
());
public
List
<
UserExcelExportData
>
queryExcel
(
PageQuery
<
CoreUser
>
query
)
{
userItem
.
setStateText
(
dict
.
getName
());
PageQuery
<
CoreUser
>
ret
=
userDao
.
queryByCondtion
(
query
);
List
<
CoreUser
>
list
=
ret
.
getList
();
if
(
StringUtils
.
isNotEmpty
(
user
.
getJobType1
()))
{
OrgItem
orgRoot
=
platformService
.
buildOrg
();
dict
=
dictService
.
findCoreDict
(
"job_type"
,
user
.
getJobType1
());
List
<
UserExcelExportData
>
items
=
new
ArrayList
<>();
userItem
.
setJobType1Text
(
dict
.
getName
());
for
(
CoreUser
user:
list
)
{
}
UserExcelExportData
userItem
=
new
UserExcelExportData
();
userItem
.
setCode
(
user
.
getCode
());
String
orgName
=
orgRoot
.
findChild
(
user
.
getOrgId
()).
getName
();
userItem
.
setId
(
user
.
getId
());
userItem
.
setOrgText
(
orgName
);
userItem
.
setName
(
user
.
getName
());
items
.
add
(
userItem
);
CoreDict
dict
=
dictService
.
findCoreDict
(
CoreDictType
.
USER_STATE
,
user
.
getState
());
}
userItem
.
setStateText
(
dict
.
getName
());
return
items
;
}
if
(
StringUtils
.
isNotEmpty
(
user
.
getJobType1
())){
dict
=
dictService
.
findCoreDict
(
"job_type"
,
user
.
getJobType1
());
userItem
.
setJobType1Text
(
dict
.
getName
());
}
String
orgName
=
orgRoot
.
findChild
(
user
.
getOrgId
()).
getName
();
userItem
.
setOrgText
(
orgName
);
items
.
add
(
userItem
);
}
return
items
;
}
}
}
plus-admin/admin-console/src/main/java/com/ibeetl/admin/console/web/AuditConsoleController.java
View file @
18144407
package
com.ibeetl.admin.console.web
;
package
com.ibeetl.admin.console.web
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
...
@@ -25,59 +24,52 @@ import com.ibeetl.admin.core.util.AnnotationUtil;
...
@@ -25,59 +24,52 @@ import com.ibeetl.admin.core.util.AnnotationUtil;
import
com.ibeetl.admin.core.web.JsonResult
;
import
com.ibeetl.admin.core.web.JsonResult
;
/**
/**
* 用户管理接口
* 用户管理接口
* @author xiandafu
*
*
* @author xiandafu
*/
*/
@Controller
@Controller
public
class
AuditConsoleController
{
public
class
AuditConsoleController
{
private
final
Log
log
=
LogFactory
.
getLog
(
this
.
getClass
());
private
final
Log
log
=
LogFactory
.
getLog
(
this
.
getClass
());
private
static
final
String
MODEL
=
"/admin/audit"
;
private
static
final
String
MODEL
=
"/admin/audit"
;
@Autowired
AuditConsoleService
auditConsoleService
;
/*页面*/
@GetMapping
(
MODEL
+
"/index.do"
)
@Function
(
"trace"
)
public
ModelAndView
index
()
{
ModelAndView
view
=
new
ModelAndView
(
"/admin/audit/index.html"
);
view
.
addObject
(
"search"
,
AuditQuery
.
class
.
getName
());
return
view
;
}
@Autowired
/*Json*/
AuditConsoleService
auditConsoleService
;
/*页面*/
@GetMapping
(
MODEL
+
"/index.do"
)
@Function
(
"trace"
)
public
ModelAndView
index
()
{
ModelAndView
view
=
new
ModelAndView
(
"/admin/audit/index.html"
);
view
.
addObject
(
"search"
,
AuditQuery
.
class
.
getName
());
return
view
;
}
/*Json*/
@PostMapping
(
MODEL
+
"/view.json"
)
@PostMapping
(
MODEL
+
"/view.json"
)
@ResponseBody
@ResponseBody
@Function
(
"trace"
)
@Function
(
"trace"
)
public
JsonResult
<
CoreAudit
>
view
(
Long
id
)
{
public
JsonResult
<
CoreAudit
>
view
(
Long
id
)
{
CoreAudit
audit
=
auditConsoleService
.
queryById
(
id
);
CoreAudit
audit
=
auditConsoleService
.
queryById
(
id
);
return
JsonResult
.
success
(
audit
);
return
JsonResult
.
success
(
audit
);
}
}
@RequestMapping
(
MODEL
+
"/list.json"
)
@RequestMapping
(
MODEL
+
"/list.json"
)
@Function
(
"trace"
)
@Function
(
"trace"
)
@ResponseBody
@ResponseBody
public
JsonResult
<
PageQuery
<
CoreAudit
>>
list
(
AuditQuery
condtion
)
{
public
JsonResult
<
PageQuery
<
CoreAudit
>>
list
(
AuditQuery
condtion
)
{
PageQuery
<
CoreAudit
>
page
=
condtion
.
getPageQuery
();
auditConsoleService
.
queryByCondtion
(
page
);
return
JsonResult
.
success
(
page
);
}
@PostMapping
(
MODEL
+
"/list/condition.json"
)
@Function
(
"trace"
)
@ResponseBody
public
JsonResult
<
List
<
Map
<
String
,
Object
>>>
listCondtion
()
{
List
<
Map
<
String
,
Object
>>
list
=
AnnotationUtil
.
getInstance
().
getAnnotations
(
Query
.
class
,
AuditQuery
.
class
);
return
JsonResult
.
success
(
list
);
}
PageQuery
<
CoreAudit
>
page
=
condtion
.
getPageQuery
();
auditConsoleService
.
queryByCondtion
(
page
);
return
JsonResult
.
success
(
page
);
}
@PostMapping
(
MODEL
+
"/list/condition.json"
)
@Function
(
"trace"
)
@ResponseBody
public
JsonResult
<
List
<
Map
<
String
,
Object
>>>
listCondtion
()
{
List
<
Map
<
String
,
Object
>>
list
=
AnnotationUtil
.
getInstance
().
getAnnotations
(
Query
.
class
,
AuditQuery
.
class
);
return
JsonResult
.
success
(
list
);
}
}
}
plus-admin/admin-console/src/main/java/com/ibeetl/admin/console/web/DictConsoleController.java
View file @
18144407
...
@@ -45,179 +45,171 @@ import com.ibeetl.admin.core.util.PlatformException;
...
@@ -45,179 +45,171 @@ import com.ibeetl.admin.core.util.PlatformException;
import
com.ibeetl.admin.core.util.ValidateConfig
;
import
com.ibeetl.admin.core.util.ValidateConfig
;
import
com.ibeetl.admin.core.web.JsonResult
;
import
com.ibeetl.admin.core.web.JsonResult
;
/**
/** CoreDict 接口 */
* CoreDict 接口
*/
@Controller
@Controller
public
class
DictConsoleController
{
public
class
DictConsoleController
{
private
final
Log
log
=
LogFactory
.
getLog
(
this
.
getClass
());
private
final
Log
log
=
LogFactory
.
getLog
(
this
.
getClass
());
private
static
final
String
MODEL
=
"/admin/dict"
;
private
static
final
String
MODEL
=
"/admin/dict"
;
@Autowired
private
DictConsoleService
dictService
;
@Autowired
private
DictConsoleService
dictService
;
@Autowired
FileService
fileService
;
@Autowired
FileService
fileService
;
@Autowired
CorePlatformService
platformService
=
null
;
/* 页面 */
@Autowired
CorePlatformService
platformService
=
null
;
@GetMapping
(
MODEL
+
"/index.do"
)
/* 页面 */
@Function
(
"dict.query"
)
public
ModelAndView
index
()
{
@GetMapping
(
MODEL
+
"/index.do"
)
ModelAndView
view
=
new
ModelAndView
(
"/admin/dict/index.html"
);
@Function
(
"dict.query"
)
view
.
addObject
(
"search"
,
CoreDictQuery
.
class
.
getName
());
public
ModelAndView
index
()
{
return
view
;
ModelAndView
view
=
new
ModelAndView
(
"/admin/dict/index.html"
)
;
}
view
.
addObject
(
"search"
,
CoreDictQuery
.
class
.
getName
());
return
view
;
@GetMapping
(
MODEL
+
"/edit.do"
)
@Function
(
"dict.edit"
)
public
ModelAndView
edit
(
Long
id
)
{
ModelAndView
view
=
new
ModelAndView
(
"/admin/dict/edit.html"
);
CoreDict
dict
=
dictService
.
queryById
(
id
);
view
.
addObject
(
"dict"
,
dict
);
return
view
;
}
@GetMapping
(
MODEL
+
"/add.do"
)
@Function
(
"dict.add"
)
public
ModelAndView
add
()
{
ModelAndView
view
=
new
ModelAndView
(
"/admin/dict/add.html"
);
return
view
;
}
/* ajax json */
@PostMapping
(
MODEL
+
"/list.json"
)
@Function
(
"dict.query"
)
@ResponseBody
public
JsonResult
<
PageQuery
>
list
(
CoreDictQuery
condtion
)
{
PageQuery
page
=
condtion
.
getPageQuery
();
dictService
.
queryByCondition
(
page
);
return
JsonResult
.
success
(
page
);
}
@PostMapping
(
MODEL
+
"/add.json"
)
@Function
(
"dict.add"
)
@ResponseBody
public
JsonResult
add
(
@Validated
(
ValidateConfig
.
ADD
.
class
)
CoreDict
dict
)
{
dict
.
setCreateTime
(
new
Date
());
dictService
.
save
(
dict
);
platformService
.
clearDictCache
();
return
new
JsonResult
().
success
();
}
@PostMapping
(
MODEL
+
"/update.json"
)
@Function
(
"dict.update"
)
@ResponseBody
public
JsonResult
<
String
>
update
(
@Validated
(
ValidateConfig
.
UPDATE
.
class
)
CoreDict
dict
)
{
boolean
success
=
dictService
.
update
(
dict
);
if
(
success
)
{
platformService
.
clearDictCache
();
return
new
JsonResult
().
success
();
}
else
{
return
JsonResult
.
failMessage
(
"保存失败"
);
}
}
}
@GetMapping
(
MODEL
+
"/edit.do"
)
@Function
(
"dict.edit"
)
@GetMapping
(
MODEL
+
"/view.json"
)
public
ModelAndView
edit
(
Long
id
)
{
@Function
(
"dict.query"
)
ModelAndView
view
=
new
ModelAndView
(
"/admin/dict/edit.html"
);
@ResponseBody
CoreDict
dict
=
dictService
.
queryById
(
id
);
public
JsonResult
<
CoreDict
>
queryInfo
(
Long
id
)
{
view
.
addObject
(
"dict"
,
dict
);
CoreDict
dict
=
dictService
.
queryById
(
id
);
return
view
;
return
JsonResult
.
success
(
dict
);
}
}
@GetMapping
(
MODEL
+
"/add.do"
)
@PostMapping
(
MODEL
+
"/delete.json"
)
@Function
(
"dict.add"
)
@Function
(
"dict.delete"
)
public
ModelAndView
add
()
{
@ResponseBody
ModelAndView
view
=
new
ModelAndView
(
"/admin/dict/add.html"
);
public
JsonResult
delete
(
String
ids
)
{
return
view
;
List
<
Long
>
dels
=
ConvertUtil
.
str2longs
(
ids
);
dictService
.
batchDelCoreDict
(
dels
);
platformService
.
clearDictCache
();
return
new
JsonResult
().
success
();
}
@PostMapping
(
MODEL
+
"/excel/export.json"
)
@Function
(
"dict.export"
)
@ResponseBody
public
JsonResult
<
String
>
export
(
HttpServletResponse
response
,
CoreDictQuery
condtion
)
{
String
excelTemplate
=
"excelTemplates/admin/dict/dict_collection_template.xls"
;
PageQuery
<
CoreUser
>
page
=
condtion
.
getPageQuery
();
// 取出全部符合条件的
page
.
setPageSize
(
Integer
.
MAX_VALUE
);
page
.
setPageNumber
(
1
);
page
.
setTotalRow
(
Integer
.
MAX_VALUE
);
List
<
CoreDict
>
dicts
=
dictService
.
queryExcel
(
page
);
try
(
InputStream
is
=
Thread
.
currentThread
().
getContextClassLoader
().
getResourceAsStream
(
excelTemplate
))
{
if
(
is
==
null
)
{
throw
new
PlatformException
(
"模板资源不存在:"
+
excelTemplate
);
}
FileItem
item
=
fileService
.
createFileTemp
(
"dict_collection.xls"
);
OutputStream
os
=
item
.
openOutpuStream
();
Context
context
=
new
Context
();
context
.
putVar
(
"dicts"
,
dicts
);
JxlsHelper
.
getInstance
().
processTemplate
(
is
,
os
,
context
);
os
.
close
();
// 下载参考FileSystemContorller
return
JsonResult
.
success
(
item
.
getPath
());
}
catch
(
IOException
e
)
{
throw
new
PlatformException
(
e
.
getMessage
());
}
}
}
/* ajax json */
@PostMapping
(
MODEL
+
"/excel/import.do"
)
@PostMapping
(
MODEL
+
"/list.json"
)
@Function
(
"dict.import"
)
@Function
(
"dict.query"
)
@ResponseBody
@ResponseBody
public
JsonResult
importExcel
(
@RequestParam
(
"file"
)
MultipartFile
file
)
throws
Exception
{
public
JsonResult
<
PageQuery
>
list
(
CoreDictQuery
condtion
)
if
(
file
.
isEmpty
())
{
{
return
JsonResult
.
fail
();
PageQuery
page
=
condtion
.
getPageQuery
();
dictService
.
queryByCondition
(
page
);
return
JsonResult
.
success
(
page
);
}
}
InputStream
ins
=
file
.
getInputStream
();
@PostMapping
(
MODEL
+
"/add.json"
)
@Function
(
"dict.add"
)
InputStream
inputXML
=
@ResponseBody
Thread
.
currentThread
()
public
JsonResult
add
(
@Validated
(
ValidateConfig
.
ADD
.
class
)
CoreDict
dict
)
.
getContextClassLoader
()
{
.
getResourceAsStream
(
"excelTemplates/admin/dict/dict_mapping.xml"
);
dict
.
setCreateTime
(
new
Date
());
XLSReader
mainReader
=
ReaderBuilder
.
buildFromXML
(
inputXML
);
dictService
.
save
(
dict
);
InputStream
inputXLS
=
ins
;
platformService
.
clearDictCache
();
List
<
DictExcelImportData
>
dicts
=
new
ArrayList
<
DictExcelImportData
>();
return
new
JsonResult
().
success
();
Map
beans
=
new
HashMap
();
beans
.
put
(
"list"
,
dicts
);
ReaderConfig
.
getInstance
().
setSkipErrors
(
true
);
XLSReadStatus
readStatus
=
mainReader
.
read
(
inputXLS
,
beans
);
List
<
XLSReadMessage
>
errors
=
readStatus
.
getReadMessages
();
if
(!
errors
.
isEmpty
())
{
StringBuilder
sb
=
new
StringBuilder
();
for
(
XLSReadMessage
msg
:
errors
)
{
sb
.
append
(
parseXLSReadMessage
(
msg
));
sb
.
append
(
","
);
}
sb
.
setLength
(
sb
.
length
()
-
1
);
return
JsonResult
.
failMessage
(
"解析excel出错:"
+
sb
.
toString
());
}
}
// this.dictService.batchInsert(dicts);//layui对话框不能正确处理http 500错误,改成下面方式
@PostMapping
(
MODEL
+
"/update.json"
)
// return JsonResult.success();
@Function
(
"dict.update"
)
try
{
@ResponseBody
this
.
dictService
.
batchInsert
(
dicts
);
public
JsonResult
<
String
>
update
(
@Validated
(
ValidateConfig
.
UPDATE
.
class
)
CoreDict
dict
)
{
return
JsonResult
.
success
();
boolean
success
=
dictService
.
update
(
dict
);
}
catch
(
Exception
ex
)
{
if
(
success
)
{
return
JsonResult
.
failMessage
(
ex
.
getMessage
());
platformService
.
clearDictCache
();
return
new
JsonResult
().
success
();
}
else
{
return
JsonResult
.
failMessage
(
"保存失败"
);
}
}
}
}
/*xlsReader 设计有问题,还需要通过解析msg知道错误位置在哪里*/
@GetMapping
(
MODEL
+
"/view.json"
)
private
String
parseXLSReadMessage
(
XLSReadMessage
msg
)
{
@Function
(
"dict.query"
)
// String message = "Can't read cell " + getCellName(mapping, rowShift) + " on " +
@ResponseBody
// cursor.getSheetName() + " spreadsheet";
public
JsonResult
<
CoreDict
>
queryInfo
(
Long
id
)
{
String
str
=
msg
.
getMessage
();
CoreDict
dict
=
dictService
.
queryById
(
id
);
int
start
=
"Can't read cell "
.
length
();
return
JsonResult
.
success
(
dict
);
int
end
=
str
.
indexOf
(
"on"
);
}
return
str
.
substring
(
start
,
end
);
}
@PostMapping
(
MODEL
+
"/delete.json"
)
@Function
(
"dict.delete"
)
@ResponseBody
public
JsonResult
delete
(
String
ids
)
{
List
<
Long
>
dels
=
ConvertUtil
.
str2longs
(
ids
);
dictService
.
batchDelCoreDict
(
dels
);
platformService
.
clearDictCache
();
return
new
JsonResult
().
success
();
}
@PostMapping
(
MODEL
+
"/excel/export.json"
)
@Function
(
"dict.export"
)
@ResponseBody
public
JsonResult
<
String
>
export
(
HttpServletResponse
response
,
CoreDictQuery
condtion
)
{
String
excelTemplate
=
"excelTemplates/admin/dict/dict_collection_template.xls"
;
PageQuery
<
CoreUser
>
page
=
condtion
.
getPageQuery
();
//取出全部符合条件的
page
.
setPageSize
(
Integer
.
MAX_VALUE
);
page
.
setPageNumber
(
1
);
page
.
setTotalRow
(
Integer
.
MAX_VALUE
);
List
<
CoreDict
>
dicts
=
dictService
.
queryExcel
(
page
);
try
(
InputStream
is
=
Thread
.
currentThread
().
getContextClassLoader
().
getResourceAsStream
(
excelTemplate
))
{
if
(
is
==
null
)
{
throw
new
PlatformException
(
"模板资源不存在:"
+
excelTemplate
);
}
FileItem
item
=
fileService
.
createFileTemp
(
"dict_collection.xls"
);
OutputStream
os
=
item
.
openOutpuStream
();
Context
context
=
new
Context
();
context
.
putVar
(
"dicts"
,
dicts
);
JxlsHelper
.
getInstance
().
processTemplate
(
is
,
os
,
context
);
os
.
close
();
//下载参考FileSystemContorller
return
JsonResult
.
success
(
item
.
getPath
());
}
catch
(
IOException
e
)
{
throw
new
PlatformException
(
e
.
getMessage
());
}
}
@PostMapping
(
MODEL
+
"/excel/import.do"
)
@Function
(
"dict.import"
)
@ResponseBody
public
JsonResult
importExcel
(
@RequestParam
(
"file"
)
MultipartFile
file
)
throws
Exception
{
if
(
file
.
isEmpty
())
{
return
JsonResult
.
fail
();
}
InputStream
ins
=
file
.
getInputStream
();
InputStream
inputXML
=
Thread
.
currentThread
().
getContextClassLoader
().
getResourceAsStream
(
"excelTemplates/admin/dict/dict_mapping.xml"
);
XLSReader
mainReader
=
ReaderBuilder
.
buildFromXML
(
inputXML
);
InputStream
inputXLS
=
ins
;
List
<
DictExcelImportData
>
dicts
=
new
ArrayList
<
DictExcelImportData
>();
Map
beans
=
new
HashMap
();
beans
.
put
(
"list"
,
dicts
);
ReaderConfig
.
getInstance
().
setSkipErrors
(
true
);
XLSReadStatus
readStatus
=
mainReader
.
read
(
inputXLS
,
beans
);
List
<
XLSReadMessage
>
errors
=
readStatus
.
getReadMessages
();
if
(!
errors
.
isEmpty
())
{
StringBuilder
sb
=
new
StringBuilder
();
for
(
XLSReadMessage
msg:
errors
)
{
sb
.
append
(
parseXLSReadMessage
(
msg
));
sb
.
append
(
","
);
}
sb
.
setLength
(
sb
.
length
()-
1
);
return
JsonResult
.
failMessage
(
"解析excel出错:"
+
sb
.
toString
());
}
// this.dictService.batchInsert(dicts);//layui对话框不能正确处理http 500错误,改成下面方式
// return JsonResult.success();
try
{
this
.
dictService
.
batchInsert
(
dicts
);
return
JsonResult
.
success
();
}
catch
(
Exception
ex
)
{
return
JsonResult
.
failMessage
(
ex
.
getMessage
());
}
}
/*xlsReader 设计有问题,还需要通过解析msg知道错误位置在哪里*/
private
String
parseXLSReadMessage
(
XLSReadMessage
msg
)
{
// String message = "Can't read cell " + getCellName(mapping, rowShift) + " on " + cursor.getSheetName() + " spreadsheet";
String
str
=
msg
.
getMessage
();
int
start
=
"Can't read cell "
.
length
();
int
end
=
str
.
indexOf
(
"on"
);
return
str
.
substring
(
start
,
end
);
}
}
}
Prev
1
2
3
4
5
…
9
Next
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