Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
Y
yifu-mvp
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
fangxinjiang
yifu-mvp
Commits
4c02d490
Commit
4c02d490
authored
Sep 07, 2023
by
huyuchen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
菜单权限修改
parent
567d6873
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
326 additions
and
23 deletions
+326
-23
SysUserPermissionController.java
...v1/permission/controller/SysUserPermissionController.java
+13
-12
SysUserPermissionMapper.java
...ud/plus/v1/permission/mapper/SysUserPermissionMapper.java
+62
-0
SysUserPermissionService.java
.../plus/v1/permission/service/SysUserPermissionService.java
+6
-0
SysMenuServiceImpl.java
...d/plus/v1/permission/service/impl/SysMenuServiceImpl.java
+2
-0
SysUserPermissionServiceImpl.java
...permission/service/impl/SysUserPermissionServiceImpl.java
+192
-11
SysUserPermissionMapper.xml
...biz/src/main/resources/mapper/SysUserPermissionMapper.xml
+51
-0
No files found.
yifu-permission/yifu-permission-biz/src/main/java/com/yifu/cloud/plus/v1/permission/controller/SysUserPermissionController.java
View file @
4c02d490
...
...
@@ -30,7 +30,7 @@ import java.util.List;
@RestController
@RequiredArgsConstructor
@RequestMapping
(
"/sysuserpermission"
)
@Tag
(
name
=
"
新权限-
用户权限表管理"
)
@Tag
(
name
=
"用户权限表管理"
)
public
class
SysUserPermissionController
{
private
final
SysUserPermissionService
sysUserPermissionService
;
...
...
@@ -66,12 +66,12 @@ public class SysUserPermissionController {
* @param sysUserPermission 新权限-用户权限表
* @return R
*/
@Operation
(
description
=
"新增
新权限-
用户权限表:hasPermission('permission_sysuserpermission_add')"
)
@SysLog
(
"新增
新权限-
用户权限表"
)
@Operation
(
description
=
"新增用户权限表:hasPermission('permission_sysuserpermission_add')"
)
@SysLog
(
"新增用户权限表"
)
@PostMapping
@PreAuthorize
(
"@pms.hasPermission('permission_sysuserpermission_add')"
)
public
R
<
Boolean
>
save
(
@RequestBody
SysUserPermission
sysUserPermission
)
{
return
R
.
ok
(
sysUserPermissionService
.
save
(
sysUserPermission
)
);
public
R
save
(
@RequestBody
SysUserPermission
sysUserPermission
)
{
return
sysUserPermissionService
.
savePermission
(
sysUserPermission
);
}
/**
...
...
@@ -80,8 +80,8 @@ public class SysUserPermissionController {
* @param sysUserPermission 新权限-用户权限表
* @return R
*/
@Operation
(
description
=
"修改
新权限-
用户权限表:hasPermission('permission_sysuserpermission_edit')"
)
@SysLog
(
"修改
新权限-
用户权限表"
)
@Operation
(
description
=
"修改用户权限表:hasPermission('permission_sysuserpermission_edit')"
)
@SysLog
(
"修改用户权限表"
)
@PutMapping
@PreAuthorize
(
"@pms.hasPermission('permission_sysuserpermission_edit')"
)
public
R
<
Boolean
>
updateById
(
@RequestBody
SysUserPermission
sysUserPermission
)
{
...
...
@@ -94,8 +94,8 @@ public class SysUserPermissionController {
* @param idList
* @return R
*/
@Operation
(
description
=
"通过id删除
新权限-
用户权限表:hasPermission('permission_sysuserpermission_del')"
)
@SysLog
(
"通过id删除
新权限-
用户权限表"
)
@Operation
(
description
=
"通过id删除用户权限表:hasPermission('permission_sysuserpermission_del')"
)
@SysLog
(
"通过id删除用户权限表"
)
@PostMapping
(
"/deleteByIds"
)
@PreAuthorize
(
"@pms.hasPermission('permission_sysuserpermission_del')"
)
public
R
<
Boolean
>
removeById
(
@RequestBody
List
<
String
>
idList
)
{
...
...
@@ -109,8 +109,8 @@ public class SysUserPermissionController {
* @date 2023-08-29 14:49:40
**/
@SneakyThrows
@Operation
(
description
=
"批量新增
新权限-
用户权限表 hasPermission('permission_sysuserpermission-batch-import')"
)
@SysLog
(
"批量新增
新权限-
用户权限表"
)
@Operation
(
description
=
"批量新增用户权限表 hasPermission('permission_sysuserpermission-batch-import')"
)
@SysLog
(
"批量新增用户权限表"
)
@PostMapping
(
"/importListAdd"
)
@PreAuthorize
(
"@pms.hasPermission('permission_sysuserpermission-batch-import')"
)
public
R
<
List
<
ErrorMessage
>>
importListAdd
(
@RequestBody
MultipartFile
file
)
{
...
...
@@ -123,8 +123,9 @@ public class SysUserPermissionController {
* @author hyc
* @date 2023-08-29 14:49:40
**/
@Operation
(
description
=
"导出
新权限-
用户权限表"
)
@Operation
(
description
=
"导出用户权限表"
)
@PostMapping
(
"/export"
)
@SysLog
(
"批量导出用户权限表"
)
public
void
export
(
HttpServletResponse
response
,
@RequestBody
SysUserPermissionSearchVo
searchVo
)
{
sysUserPermissionService
.
listExport
(
response
,
searchVo
);
}
...
...
yifu-permission/yifu-permission-biz/src/main/java/com/yifu/cloud/plus/v1/permission/mapper/SysUserPermissionMapper.java
View file @
4c02d490
...
...
@@ -101,6 +101,68 @@ public interface SysUserPermissionMapper extends BaseMapper<SysUserPermission> {
*/
IPage
<
SysUserDeptVo
>
selectDeptVO
(
Page
<
SysUserDeptVo
>
page
,
@Param
(
"name"
)
String
name
);
/**
* 根据类型查询字典值
*
* @param type 类型
* @return
*/
List
<
SysDictVo
>
selectDictByType
(
@Param
(
"type"
)
String
type
);
/**
* 根据类型和名称判断字典值是否存在
*
* @param type 类型
* @return
*/
Integer
selectDictByName
(
@Param
(
"name"
)
String
name
,
@Param
(
"type"
)
String
type
);
/**
* 根据名称或者编码查询数据
* 单位权限
* @param name 名称
* @return
*/
Integer
selectUnitCount
(
@Param
(
"name"
)
String
name
);
/**
* 根据名称或者编码查询数据
* 合同权限
* @param name 名称
* @return
*/
Integer
selectContractCount
(
@Param
(
"name"
)
String
name
);
/**
* 根据名称或者编码查询数据
* 项目权限
* @param name 名称
* @return
*/
Integer
selectSettleCount
(
@Param
(
"name"
)
String
name
);
/**
* 根据名称或者编码查询数据
* 商机权限
* @param name 名称
* @return
*/
Integer
selectBusinessCount
(
@Param
(
"name"
)
String
name
);
/**
* 根据名称或者编码查询数据
* 报价单权限
* @param name 名称
* @return
*/
Integer
selectQuotationCount
(
@Param
(
"name"
)
String
name
);
/**
* 根据名称或者编码查询数据
* 部门&&收入归属权限
* @param name 名称
* @return
*/
Integer
selectDeptCount
(
@Param
(
"name"
)
String
name
);
}
yifu-permission/yifu-permission-biz/src/main/java/com/yifu/cloud/plus/v1/permission/service/SysUserPermissionService.java
View file @
4c02d490
...
...
@@ -28,6 +28,12 @@ public interface SysUserPermissionService extends IService<SysUserPermission> {
*/
IPage
<
SysUserPermission
>
getSysUserPermissionPage
(
Page
<
SysUserPermission
>
page
,
SysUserPermissionSearchVo
sysUserPermission
);
/**
* 新增权限
* @param sysUserPermission 新权限-用户权限表
*/
R
savePermission
(
SysUserPermission
sysUserPermission
);
R
<
List
<
ErrorMessage
>>
importDiy
(
InputStream
inputStream
);
void
listExport
(
HttpServletResponse
response
,
SysUserPermissionSearchVo
searchVo
);
...
...
yifu-permission/yifu-permission-biz/src/main/java/com/yifu/cloud/plus/v1/permission/service/impl/SysMenuServiceImpl.java
View file @
4c02d490
...
...
@@ -11,6 +11,7 @@ import com.yifu.cloud.plus.v1.yifu.common.core.util.Common;
import
com.yifu.cloud.plus.v1.yifu.common.core.util.R
;
import
com.yifu.cloud.plus.v1.yifu.permission.entity.SysMenu
;
import
com.yifu.cloud.plus.v1.yifu.permission.vo.SysMenuSearchVo
;
import
lombok.RequiredArgsConstructor
;
import
lombok.extern.log4j.Log4j2
;
import
org.springframework.stereotype.Service
;
...
...
@@ -24,6 +25,7 @@ import java.util.List;
*/
@Log4j2
@Service
@RequiredArgsConstructor
public
class
SysMenuServiceImpl
extends
ServiceImpl
<
SysMenuMapper
,
SysMenu
>
implements
SysMenuService
{
/**
...
...
yifu-permission/yifu-permission-biz/src/main/java/com/yifu/cloud/plus/v1/permission/service/impl/SysUserPermissionServiceImpl.java
View file @
4c02d490
...
...
@@ -9,20 +9,25 @@ import com.alibaba.excel.read.metadata.holder.ReadRowHolder;
import
com.alibaba.excel.util.ListUtils
;
import
com.alibaba.excel.write.metadata.WriteSheet
;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
com.baomidou.mybatisplus.core.toolkit.Wrappers
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.yifu.cloud.plus.v1.permission.mapper.SysUserPermissionMapper
;
import
com.yifu.cloud.plus.v1.permission.service.SysUserInfoService
;
import
com.yifu.cloud.plus.v1.permission.service.SysUserPermissionService
;
import
com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants
;
import
com.yifu.cloud.plus.v1.yifu.common.core.util.*
;
import
com.yifu.cloud.plus.v1.yifu.common.core.vo.YifuUser
;
import
com.yifu.cloud.plus.v1.yifu.common.security.util.SecurityUtils
;
import
com.yifu.cloud.plus.v1.yifu.permission.entity.SysUserInfo
;
import
com.yifu.cloud.plus.v1.yifu.permission.entity.SysUserPermission
;
import
com.yifu.cloud.plus.v1.yifu.permission.vo.SysDictVo
;
import
com.yifu.cloud.plus.v1.yifu.permission.vo.SysUserDeptVo
;
import
com.yifu.cloud.plus.v1.yifu.permission.vo.SysUserPermissionSearchVo
;
import
com.yifu.cloud.plus.v1.yifu.permission.vo.SysUserPermissionVo
;
import
lombok.RequiredArgsConstructor
;
import
lombok.extern.log4j.Log4j2
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
javax.servlet.ServletOutputStream
;
...
...
@@ -30,12 +35,19 @@ import javax.servlet.http.HttpServletResponse;
import
java.io.InputStream
;
import
java.net.URLEncoder
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.stream.Collectors
;
@Log4j2
@Service
@RequiredArgsConstructor
public
class
SysUserPermissionServiceImpl
extends
ServiceImpl
<
SysUserPermissionMapper
,
SysUserPermission
>
implements
SysUserPermissionService
{
@Autowired
private
SysUserInfoService
userInfoService
;
/**
* 新权限-用户权限表简单分页查询
*
...
...
@@ -47,6 +59,42 @@ public class SysUserPermissionServiceImpl extends ServiceImpl<SysUserPermissionM
return
baseMapper
.
getSysUserPermissionPage
(
page
,
sysUserPermission
);
}
@Override
public
R
savePermission
(
SysUserPermission
sysUserPermission
)
{
YifuUser
user
=
SecurityUtils
.
getUser
();
//非管理员判断是否包含此权限维度
SysUserPermission
permission
;
if
(!
CommonConstants
.
ONE_STRING
.
equals
(
user
.
getId
()))
{
permission
=
this
.
getOne
(
Wrappers
.<
SysUserPermission
>
query
().
lambda
()
.
eq
(
SysUserPermission:
:
getPermissionStatus
,
CommonConstants
.
ZERO_STRING
)
.
eq
(
SysUserPermission:
:
getEmpLoginName
,
user
.
getUsername
())
.
eq
(
SysUserPermission:
:
getCode
,
sysUserPermission
.
getCode
()).
last
(
CommonConstants
.
LAST_ONE_SQL
));
if
(
Common
.
isEmpty
(
permission
))
{
return
R
.
failed
(
"只有自己有权限的维度才可新增"
);
}
}
if
(
CommonConstants
.
SIX_STRING
.
equals
(
sysUserPermission
.
getPermissionType
())
||
CommonConstants
.
SEVEN_STRING
.
equals
(
sysUserPermission
.
getPermissionType
()))
{
permission
=
this
.
getOne
(
Wrappers
.<
SysUserPermission
>
query
().
lambda
()
.
eq
(
SysUserPermission:
:
getEmpLoginName
,
sysUserPermission
.
getEmpLoginName
())
.
eq
(
SysUserPermission:
:
getPermissionType
,
sysUserPermission
.
getPermissionType
())
.
eq
(
SysUserPermission:
:
getName
,
sysUserPermission
.
getName
()).
last
(
CommonConstants
.
LAST_ONE_SQL
));
if
(
Common
.
isNotNull
(
permission
))
{
return
R
.
failed
(
"系统中已经存在对应的名称权限维度"
);
}
}
else
{
permission
=
this
.
getOne
(
Wrappers
.<
SysUserPermission
>
query
().
lambda
()
.
eq
(
SysUserPermission:
:
getEmpLoginName
,
sysUserPermission
.
getEmpLoginName
())
.
eq
(
SysUserPermission:
:
getPermissionType
,
sysUserPermission
.
getPermissionType
())
.
eq
(
SysUserPermission:
:
getCode
,
sysUserPermission
.
getCode
()).
last
(
CommonConstants
.
LAST_ONE_SQL
));
if
(
Common
.
isNotNull
(
permission
))
{
return
R
.
failed
(
"系统中已经存在对应的编码的权限维度"
);
}
}
this
.
save
(
sysUserPermission
);
return
R
.
ok
();
}
/**
* 新权限-用户权限表批量导出
*
...
...
@@ -55,7 +103,7 @@ public class SysUserPermissionServiceImpl extends ServiceImpl<SysUserPermissionM
*/
@Override
public
void
listExport
(
HttpServletResponse
response
,
SysUserPermissionSearchVo
searchVo
)
{
String
fileName
=
"
用户
权限表批量导出"
+
DateUtil
.
getThisTime
()
+
".xlsx"
;
String
fileName
=
"
数据
权限表批量导出"
+
DateUtil
.
getThisTime
()
+
".xlsx"
;
//获取要导出的列表
List
<
SysUserPermissionVo
>
list
=
new
ArrayList
<>();
long
count
=
baseMapper
.
userSelectCount
(
searchVo
);
...
...
@@ -73,7 +121,7 @@ public class SysUserPermissionServiceImpl extends ServiceImpl<SysUserPermissionM
searchVo
.
setLimitEnd
(
CommonConstants
.
EXCEL_EXPORT_LIMIT
);
list
=
baseMapper
.
userSelectList
(
searchVo
);
if
(
Common
.
isNotNull
(
list
))
{
WriteSheet
writeSheet
=
EasyExcel
.
writerSheet
(
"
用户
权限表"
+
index
).
build
();
WriteSheet
writeSheet
=
EasyExcel
.
writerSheet
(
"
数据
权限表"
+
index
).
build
();
excelWriter
.
write
(
list
,
writeSheet
);
index
++;
}
...
...
@@ -82,7 +130,7 @@ public class SysUserPermissionServiceImpl extends ServiceImpl<SysUserPermissionM
}
}
}
else
{
WriteSheet
writeSheet
=
EasyExcel
.
writerSheet
(
"
用户
权限表"
+
index
).
build
();
WriteSheet
writeSheet
=
EasyExcel
.
writerSheet
(
"
数据
权限表"
+
index
).
build
();
excelWriter
.
write
(
list
,
writeSheet
);
}
if
(
Common
.
isNotNull
(
list
))
{
...
...
@@ -140,6 +188,15 @@ public class SysUserPermissionServiceImpl extends ServiceImpl<SysUserPermissionM
public
R
<
List
<
ErrorMessage
>>
importDiy
(
InputStream
inputStream
)
{
List
<
ErrorMessage
>
errorMessageList
=
new
ArrayList
<>();
ExcelUtil
<
SysUserPermissionVo
>
util1
=
new
ExcelUtil
<>(
SysUserPermissionVo
.
class
);
//查询权限类型字典
List
<
SysDictVo
>
typeList
=
baseMapper
.
selectDictByType
(
"permission"
);
Map
<
String
,
String
>
typeMap
=
typeList
.
stream
().
collect
(
Collectors
.
toMap
(
SysDictVo:
:
getName
,
SysDictVo:
:
getId
));
//查询所有用户的信息
List
<
SysUserInfo
>
userInfoList
=
userInfoService
.
list
(
Wrappers
.<
SysUserInfo
>
query
().
lambda
()
.
eq
(
SysUserInfo:
:
getStatus
,
CommonConstants
.
ZERO_INT
));
//登录账号+维度+唯一标识唯一
Map
<
String
,
String
>
uniqueMap
=
new
HashMap
<>();
// 写法2:
// 匿名内部类 不用额外写一个DemoDataListener
// 这里 需要指定读用哪个class去读,然后读取第一个sheet 文件流会自动关闭
...
...
@@ -182,7 +239,7 @@ public class SysUserPermissionServiceImpl extends ServiceImpl<SysUserPermissionM
*/
private
void
saveData
()
{
log
.
info
(
"{}条数据,开始存储数据库!"
,
cachedDataList
.
size
());
importSysUserPermission
(
cachedDataList
,
errorMessageList
);
importSysUserPermission
(
cachedDataList
,
errorMessageList
,
typeMap
,
userInfoList
,
uniqueMap
);
log
.
info
(
"存储数据库成功!"
);
}
}).
sheet
().
doRead
();
...
...
@@ -193,14 +250,108 @@ public class SysUserPermissionServiceImpl extends ServiceImpl<SysUserPermissionM
return
R
.
ok
(
errorMessageList
);
}
private
void
importSysUserPermission
(
List
<
SysUserPermissionVo
>
excelVOList
,
List
<
ErrorMessage
>
errorMessageList
)
{
private
void
importSysUserPermission
(
List
<
SysUserPermissionVo
>
excelVOList
,
List
<
ErrorMessage
>
errorMessageList
,
Map
<
String
,
String
>
typeMap
,
List
<
SysUserInfo
>
userInfoList
,
Map
<
String
,
String
>
uniqueMap
)
{
// 执行数据插入操作 组装
for
(
int
i
=
0
;
i
<
excelVOList
.
size
();
i
++)
{
SysUserPermissionVo
excel
=
excelVOList
.
get
(
i
);
// 插入
insertExcel
(
excel
);
errorMessageList
.
add
(
new
ErrorMessage
(
excel
.
getRowIndex
(),
CommonConstants
.
SAVE_SUCCESS
));
YifuUser
user
=
SecurityUtils
.
getUser
();
SysUserPermission
permission
;
List
<
SysUserInfo
>
userInfo
;
try
{
// 执行数据插入操作 组装
for
(
int
i
=
0
;
i
<
excelVOList
.
size
();
i
++)
{
SysUserPermissionVo
excel
=
excelVOList
.
get
(
i
);
//登录名校验
userInfo
=
userInfoList
.
stream
().
filter
(
e
->
excel
.
getEmpLoginName
().
equals
(
e
.
getFdLoginName
())).
collect
(
Collectors
.
toList
());
if
(
userInfo
.
isEmpty
())
{
errorMessageList
.
add
(
new
ErrorMessage
(
excel
.
getRowIndex
(),
"登录名填写错误,请核实"
,
excel
));
continue
;
}
//判断表格权限类型是否正确
if
(
typeMap
.
isEmpty
())
{
errorMessageList
.
add
(
new
ErrorMessage
(
excel
.
getRowIndex
(),
"获取权限类型字典值异常"
,
excel
));
continue
;
}
//判断表格权限类型是否正确
if
(
null
==
typeMap
.
get
(
excel
.
getPermissionType
()))
{
errorMessageList
.
add
(
new
ErrorMessage
(
excel
.
getRowIndex
(),
"权限类型填写错误,请核实"
,
excel
));
continue
;
}
else
{
excel
.
setPermissionType
(
typeMap
.
get
(
excel
.
getPermissionType
()));
}
//登录账号+维度+唯一标识唯一
StringBuilder
flag
=
new
StringBuilder
();
flag
.
append
(
excel
.
getEmpLoginName
());
flag
.
append
(
"_"
);
flag
.
append
(
excel
.
getPermissionType
());
flag
.
append
(
"_"
);
flag
.
append
(
excel
.
getCode
());
if
(
null
!=
uniqueMap
.
get
(
flag
.
toString
()))
{
errorMessageList
.
add
(
new
ErrorMessage
(
excel
.
getRowIndex
(),
"导表中已经存在该登录名对应的权限维度的名称或者编码!"
,
excel
));
continue
;
}
else
{
uniqueMap
.
put
(
flag
.
toString
(),
CommonConstants
.
ONE_STRING
);
}
//BU和条线的时候用名称判断,其他用编码判断
//判断此登录名是否已经存在此权限维度
if
(
CommonConstants
.
SIX_STRING
.
equals
(
excel
.
getPermissionType
())
||
CommonConstants
.
SEVEN_STRING
.
equals
(
excel
.
getPermissionType
()))
{
//判断对应维度的名称是否存在
Integer
count
;
if
(
CommonConstants
.
SIX_STRING
.
equals
(
excel
.
getPermissionType
()))
{
count
=
baseMapper
.
selectDictByName
(
excel
.
getName
(),
"bu"
);
}
else
{
count
=
baseMapper
.
selectDictByName
(
excel
.
getName
(),
"line"
);
}
if
(
count
<
1
)
{
errorMessageList
.
add
(
new
ErrorMessage
(
excel
.
getRowIndex
(),
"不存在对应维度的名称信息"
,
excel
));
continue
;
}
permission
=
this
.
getOne
(
Wrappers
.<
SysUserPermission
>
query
().
lambda
()
.
eq
(
SysUserPermission:
:
getEmpLoginName
,
excel
.
getEmpLoginName
())
.
eq
(
SysUserPermission:
:
getPermissionType
,
excel
.
getPermissionType
())
.
eq
(
SysUserPermission:
:
getName
,
excel
.
getName
()).
last
(
CommonConstants
.
LAST_ONE_SQL
));
if
(
Common
.
isNotNull
(
permission
))
{
errorMessageList
.
add
(
new
ErrorMessage
(
excel
.
getRowIndex
(),
"系统中已经存在该用户对应的名称权限维度"
,
excel
));
continue
;
}
}
else
{
//判断对应维度的编码是否存在
Integer
count
=
this
.
checkExit
(
excel
.
getPermissionType
(),
excel
.
getCode
());
if
(
count
<
1
)
{
errorMessageList
.
add
(
new
ErrorMessage
(
excel
.
getRowIndex
(),
"不存在对应维度的编码信息"
,
excel
));
continue
;
}
permission
=
this
.
getOne
(
Wrappers
.<
SysUserPermission
>
query
().
lambda
()
.
eq
(
SysUserPermission:
:
getEmpLoginName
,
excel
.
getEmpLoginName
())
.
eq
(
SysUserPermission:
:
getPermissionType
,
excel
.
getPermissionType
())
.
eq
(
SysUserPermission:
:
getCode
,
excel
.
getCode
()).
last
(
CommonConstants
.
LAST_ONE_SQL
));
if
(
Common
.
isNotNull
(
permission
))
{
errorMessageList
.
add
(
new
ErrorMessage
(
excel
.
getRowIndex
(),
"系统中已经存在该用户对应的编码的权限维度"
,
excel
));
continue
;
}
}
//非管理员的用户只能导入合同和项目权限维度的数据且只有自己有权限的维度才可导入
//当登录人不是管理员时根据导表登录名查询权限数据
if
(!
CommonConstants
.
ONE_STRING
.
equals
(
user
.
getId
()))
{
permission
=
this
.
getOne
(
Wrappers
.<
SysUserPermission
>
query
().
lambda
()
.
eq
(
SysUserPermission:
:
getPermissionStatus
,
CommonConstants
.
ZERO_STRING
)
.
eq
(
SysUserPermission:
:
getEmpLoginName
,
user
.
getUsername
())
.
eq
(
SysUserPermission:
:
getPermissionType
,
excel
.
getPermissionType
())
.
eq
(
SysUserPermission:
:
getCode
,
excel
.
getCode
()).
last
(
CommonConstants
.
LAST_ONE_SQL
));
if
(
Common
.
isEmpty
(
permission
))
{
errorMessageList
.
add
(
new
ErrorMessage
(
excel
.
getRowIndex
(),
"只有自己有权限的维度才可导入"
,
excel
));
continue
;
}
}
// 插入数据
insertExcel
(
excel
);
}
}
catch
(
Exception
e
)
{
log
.
error
(
"用户权限表导入异常:"
+
e
);
}
}
...
...
@@ -210,6 +361,36 @@ public class SysUserPermissionServiceImpl extends ServiceImpl<SysUserPermissionM
private
void
insertExcel
(
SysUserPermissionVo
excel
)
{
SysUserPermission
insert
=
new
SysUserPermission
();
BeanUtil
.
copyProperties
(
excel
,
insert
);
//转化是否含下级
if
(
Common
.
isNotNull
(
insert
.
getIsContains
()))
{
if
(
CommonConstants
.
IS_TRUE
.
equals
(
insert
.
getIsContains
()))
{
insert
.
setIsContains
(
CommonConstants
.
ZERO_STRING
);
}
else
{
insert
.
setIsContains
(
CommonConstants
.
ONE_STRING
);
}
}
this
.
save
(
insert
);
}
private
Integer
checkExit
(
String
type
,
String
name
)
{
//客户权限
if
(
CommonConstants
.
ONE_STRING
.
equals
(
type
))
{
return
baseMapper
.
selectUnitCount
(
name
);
}
else
if
(
CommonConstants
.
TWO_STRING
.
equals
(
type
))
{
//商机权限
return
baseMapper
.
selectBusinessCount
(
name
);
}
else
if
(
CommonConstants
.
THREE_STRING
.
equals
(
type
))
{
//报价单权限
return
baseMapper
.
selectQuotationCount
(
name
);
}
else
if
(
CommonConstants
.
FOUR_STRING
.
equals
(
type
))
{
//合同权限
return
baseMapper
.
selectContractCount
(
name
);
}
else
if
(
CommonConstants
.
EIGHT_STRING
.
equals
(
type
)
||
CommonConstants
.
NINE_STRING
.
equals
(
type
))
{
//部门&&收入归属权限
return
baseMapper
.
selectDeptCount
(
name
);
}
else
{
//项目权限
return
baseMapper
.
selectSettleCount
(
name
);
}
}
}
yifu-permission/yifu-permission-biz/src/main/resources/mapper/SysUserPermissionMapper.xml
View file @
4c02d490
...
...
@@ -212,4 +212,55 @@
where a.dict_type = #{type}
</select>
<!--针对BU归属和条线类型时的存在判断-->
<select
id=
"selectDictByName"
resultType=
"java.lang.Integer"
>
SELECT
count(1)
from permission_type a
where a.dict_type = #{type} and a.name = #{name}
</select>
<!--判断对应维度的名称或者编码是否存在-->
<select
id=
"selectUnitCount"
resultType=
"java.lang.Integer"
>
SELECT
count(1)
from ekp_05b7485fd444f95a6177 a
where a.fd_3a9d1d4d438bfc = #{name}
</select>
<select
id=
"selectContractCount"
resultType=
"java.lang.Integer"
>
SELECT
count(1)
from ekp_0103c453b2848c3bb31c a
where a.fd_3ade33763baa0e = #{name}
</select>
<select
id=
"selectSettleCount"
resultType=
"java.lang.Integer"
>
SELECT
count(1)
from ekp_24a8e6a7fc143bb8c48a a
where a.fd_3a37fe508071fe = #{name}
</select>
<select
id=
"selectBusinessCount"
resultType=
"java.lang.Integer"
>
SELECT
count(1)
from ekp_2f8e08660c542d8a169f a
where a.fd_3b107f1084fd96 = #{name}
</select>
<select
id=
"selectQuotationCount"
resultType=
"java.lang.Integer"
>
SELECT
count(1)
from ekp_2f8e08660c542d8a169f a
where a.fd_3b04b9dc64a9f4 = #{name}
</select>
<select
id=
"selectDeptCount"
resultType=
"java.lang.Integer"
>
SELECT
count(1)
from sys_org_element a
where a.fd_is_available = '1' and fd_org_type = 2 and a.fd_no = #{name}
</select>
</mapper>
Write
Preview
Markdown
is supported
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