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
d95d0696
Commit
d95d0696
authored
Sep 01, 2023
by
hongguangwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1.5.8-hgw-权限-角色-账号
parent
f5b2c1c5
Show whitespace changes
Inline
Side-by-side
Showing
19 changed files
with
433 additions
and
430 deletions
+433
-430
SysRoleInfoSaveVo.java
...u/cloud/plus/v1/yifu/permission/vo/SysRoleInfoSaveVo.java
+41
-0
SysUserInfoSaveVo.java
...u/cloud/plus/v1/yifu/permission/vo/SysUserInfoSaveVo.java
+25
-0
SysRoleInfoController.java
.../plus/v1/permission/controller/SysRoleInfoController.java
+36
-37
SysUserInfoController.java
.../plus/v1/permission/controller/SysUserInfoController.java
+8
-19
SysRoleInfoMapper.java
...fu/cloud/plus/v1/permission/mapper/SysRoleInfoMapper.java
+7
-0
SysRoleMenuResMapper.java
...cloud/plus/v1/permission/mapper/SysRoleMenuResMapper.java
+9
-0
SysUserRoleResMapper.java
...cloud/plus/v1/permission/mapper/SysUserRoleResMapper.java
+4
-0
SysRoleInfoService.java
.../cloud/plus/v1/permission/service/SysRoleInfoService.java
+27
-5
SysRoleMenuResService.java
...oud/plus/v1/permission/service/SysRoleMenuResService.java
+10
-0
SysUserInfoService.java
.../cloud/plus/v1/permission/service/SysUserInfoService.java
+19
-6
SysUserRoleResService.java
...oud/plus/v1/permission/service/SysUserRoleResService.java
+20
-16
SysRoleInfoServiceImpl.java
...us/v1/permission/service/impl/SysRoleInfoServiceImpl.java
+102
-177
SysRoleMenuResServiceImpl.java
...v1/permission/service/impl/SysRoleMenuResServiceImpl.java
+12
-0
SysUserInfoServiceImpl.java
...us/v1/permission/service/impl/SysUserInfoServiceImpl.java
+58
-165
SysUserRoleResServiceImpl.java
...v1/permission/service/impl/SysUserRoleResServiceImpl.java
+10
-0
SysRoleInfoMapper.xml
...ssion-biz/src/main/resources/mapper/SysRoleInfoMapper.xml
+24
-2
SysRoleMenuResMapper.xml
...on-biz/src/main/resources/mapper/SysRoleMenuResMapper.xml
+6
-0
SysUserInfoMapper.xml
...ssion-biz/src/main/resources/mapper/SysUserInfoMapper.xml
+4
-3
SysUserRoleResMapper.xml
...on-biz/src/main/resources/mapper/SysUserRoleResMapper.xml
+11
-0
No files found.
yifu-permission/yifu-permission-api/src/main/java/com/yifu/cloud/plus/v1/yifu/permission/vo/SysRoleInfoSaveVo.java
0 → 100644
View file @
d95d0696
package
com
.
yifu
.
cloud
.
plus
.
v1
.
yifu
.
permission
.
vo
;
/*
* Copyright (c) 2018-2025, lengleng All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the yifu4cloud.com developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: lengleng (wangiegie@gmail.com)
*/
import
cn.hutool.core.lang.tree.Tree
;
import
com.yifu.cloud.plus.v1.yifu.permission.entity.SysRoleInfo
;
import
com.yifu.cloud.plus.v1.yifu.permission.entity.SysRoleMenuRes
;
import
lombok.Data
;
import
java.io.Serializable
;
import
java.util.List
;
/**
* 角色新增vo
*
* @author hgw
* @date 2023-08-29 14:49:40
*/
@Data
public
class
SysRoleInfoSaveVo
implements
Serializable
{
private
SysRoleInfo
role
;
private
List
<
SysRoleMenuRes
>
resList
;
private
List
<
Tree
<
String
>>
tree
;
}
yifu-permission/yifu-permission-api/src/main/java/com/yifu/cloud/plus/v1/yifu/permission/vo/SysUserInfoSaveVo.java
0 → 100644
View file @
d95d0696
package
com
.
yifu
.
cloud
.
plus
.
v1
.
yifu
.
permission
.
vo
;
import
com.yifu.cloud.plus.v1.yifu.permission.entity.SysUserInfo
;
import
com.yifu.cloud.plus.v1.yifu.permission.entity.SysUserRoleRes
;
import
lombok.Data
;
import
java.io.Serializable
;
import
java.util.List
;
/**
* 账号新增vo
*
* @author hgw
* @date 2023-08-29 14:49:40
*/
@Data
public
class
SysUserInfoSaveVo
implements
Serializable
{
private
SysUserInfo
user
;
private
List
<
SysUserRoleRes
>
resList
;
private
String
dataAuth
;
}
yifu-permission/yifu-permission-biz/src/main/java/com/yifu/cloud/plus/v1/permission/controller/SysRoleInfoController.java
View file @
d95d0696
...
...
@@ -3,20 +3,19 @@ package com.yifu.cloud.plus.v1.permission.controller;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.yifu.cloud.plus.v1.permission.service.SysRoleInfoService
;
import
com.yifu.cloud.plus.v1.yifu.common.core.util.ErrorMessage
;
import
com.yifu.cloud.plus.v1.permission.service.SysUserRoleResService
;
import
com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants
;
import
com.yifu.cloud.plus.v1.yifu.common.core.util.R
;
import
com.yifu.cloud.plus.v1.yifu.common.log.annotation.SysLog
;
import
com.yifu.cloud.plus.v1.yifu.permission.entity.SysRoleInfo
;
import
com.yifu.cloud.plus.v1.yifu.permission.vo.SysRoleInfoSaveVo
;
import
com.yifu.cloud.plus.v1.yifu.permission.vo.SysRoleInfoSearchVo
;
import
io.swagger.v3.oas.annotations.Operation
;
import
io.swagger.v3.oas.annotations.tags.Tag
;
import
lombok.RequiredArgsConstructor
;
import
lombok.SneakyThrows
;
import
org.springframework.security.access.prepost.PreAuthorize
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.multipart.MultipartFile
;
import
javax.servlet.http.HttpServletResponse
;
import
java.util.List
;
...
...
@@ -33,6 +32,7 @@ import java.util.List;
public
class
SysRoleInfoController
{
private
final
SysRoleInfoService
sysRoleInfoService
;
private
final
SysUserRoleResService
sysUserRoleResService
;
/**
...
...
@@ -70,22 +70,22 @@ public class SysRoleInfoController {
@Operation
(
summary
=
"通过id查询"
,
description
=
"通过id查询:hasPermission('ekp_sysroleinfo_get')"
)
@GetMapping
(
"/{fdId}"
)
@PreAuthorize
(
"@pms.hasPermission('ekp_sysroleinfo_get')"
)
public
R
<
SysRoleInfo
>
getById
(
@PathVariable
(
"fdId"
)
String
fdId
)
{
return
R
.
ok
(
sysRoleInfoService
.
getById
(
fdId
)
);
public
R
<
SysRoleInfo
SaveVo
>
getById
(
@PathVariable
(
"fdId"
)
String
fdId
)
{
return
sysRoleInfoService
.
getInfoById
(
fdId
);
}
/**
* 新增新权限-角色表
*
* @param
sysRoleInf
o 新权限-角色表
* @param
v
o 新权限-角色表
* @return R
*/
@Operation
(
summary
=
"新增
新权限-角色表"
,
description
=
"新增
新权限-角色表:hasPermission('ekp_sysroleinfo_add')"
)
@SysLog
(
"新增新权限-角色表"
)
@Operation
(
summary
=
"新增
或编辑新权限-角色表"
,
description
=
"新增或保存
新权限-角色表:hasPermission('ekp_sysroleinfo_add')"
)
@SysLog
(
"新增
或编辑
新权限-角色表"
)
@PostMapping
@PreAuthorize
(
"@pms.hasPermission('ekp_sysroleinfo_add')"
)
public
R
<
Boolean
>
save
(
@RequestBody
SysRoleInfo
sysRoleInf
o
)
{
return
R
.
ok
(
sysRoleInfoService
.
save
(
sysRoleInfo
)
);
public
R
<
String
>
saveOrUpdateRoleInfo
(
@RequestBody
SysRoleInfoSaveVo
v
o
)
{
return
sysRoleInfoService
.
saveOrUpdateRoleInfo
(
vo
);
}
/**
...
...
@@ -94,7 +94,7 @@ public class SysRoleInfoController {
* @param sysRoleInfo 新权限-角色表
* @return R
*/
@Operation
(
summary
=
"修改新权限-角色表"
,
description
=
"修改新权限-角色表:hasPermission('ekp_sysroleinfo_edit')"
)
@Operation
(
summary
=
"修改新权限-角色表
(可以修改状态)
"
,
description
=
"修改新权限-角色表:hasPermission('ekp_sysroleinfo_edit')"
)
@SysLog
(
"修改新权限-角色表"
)
@PutMapping
@PreAuthorize
(
"@pms.hasPermission('ekp_sysroleinfo_edit')"
)
...
...
@@ -108,39 +108,38 @@ public class SysRoleInfoController {
* @param fdId id
* @return R
*/
@Operation
(
summary
=
"通过id删除新权限-角色表"
,
description
=
"通过id删除新权限-角色表:hasPermission('ekp_sysroleinfo_del')"
)
@Operation
(
summary
=
"通过id删除新权限-角色表
-假删除
"
,
description
=
"通过id删除新权限-角色表:hasPermission('ekp_sysroleinfo_del')"
)
@SysLog
(
"通过id删除新权限-角色表"
)
@DeleteMapping
(
"/{fdId}"
)
@PreAuthorize
(
"@pms.hasPermission('ekp_sysroleinfo_del')"
)
public
R
<
Boolean
>
removeById
(
@PathVariable
String
fdId
)
{
return
R
.
ok
(
sysRoleInfoService
.
removeById
(
fdId
));
// 删除关联表
sysUserRoleResService
.
deleteByRoleId
(
fdId
);
// 假删除角色表
SysRoleInfo
roleInfo
=
sysRoleInfoService
.
getById
(
fdId
);
roleInfo
.
setDeleteFlag
(
CommonConstants
.
ONE_INT
);
sysRoleInfoService
.
updateById
(
roleInfo
);
return
R
.
ok
();
}
/**
*
新权限-角色表 批量导入
*
通过id删除新权限-角色表
*
* @author hgw
* @date 2023-08-29 14:49:40
**/
@SneakyThrows
@Operation
(
description
=
"批量新增新权限-角色表 hasPermission('ekp_sysroleinfo-batch-import')"
)
@SysLog
(
"批量新增新权限-角色表"
)
@PostMapping
(
"/importListAdd"
)
@PreAuthorize
(
"@pms.hasPermission('ekp_sysroleinfo-batch-import')"
)
public
R
<
List
<
ErrorMessage
>>
importListAdd
(
@RequestBody
MultipartFile
file
)
{
return
sysRoleInfoService
.
importDiy
(
file
.
getInputStream
());
* @param fdId id
* @return R
*/
@Operation
(
summary
=
"冻结-角色表"
,
description
=
"冻结-角色表:hasPermission('ekp_sysroleinfo_freeze')"
)
@SysLog
(
"冻结-角色表"
)
@PostMapping
(
"/freezeById"
)
@PreAuthorize
(
"@pms.hasPermission('ekp_sysroleinfo_freeze')"
)
public
R
<
Boolean
>
freezeById
(
@RequestParam
String
fdId
)
{
// 删除关联表
sysUserRoleResService
.
deleteByRoleId
(
fdId
);
// 冻结角色表
SysRoleInfo
roleInfo
=
sysRoleInfoService
.
getById
(
fdId
);
roleInfo
.
setStatus
(
CommonConstants
.
ONE_INT
);
sysRoleInfoService
.
updateById
(
roleInfo
);
return
R
.
ok
();
}
/**
* 新权限-角色表 批量导出
*
* @author hgw
* @date 2023-08-29 14:49:40
**/
@Operation
(
description
=
"导出新权限-角色表 hasPermission('ekp_sysroleinfo-export')"
)
@PostMapping
(
"/export"
)
@PreAuthorize
(
"@pms.hasPermission('ekp_sysroleinfo-export')"
)
public
void
export
(
HttpServletResponse
response
,
@RequestBody
SysRoleInfoSearchVo
searchVo
)
{
sysRoleInfoService
.
listExport
(
response
,
searchVo
);
}
}
yifu-permission/yifu-permission-biz/src/main/java/com/yifu/cloud/plus/v1/permission/controller/SysUserInfoController.java
View file @
d95d0696
...
...
@@ -6,6 +6,7 @@ import com.yifu.cloud.plus.v1.permission.service.SysUserInfoService;
import
com.yifu.cloud.plus.v1.yifu.common.core.util.R
;
import
com.yifu.cloud.plus.v1.yifu.common.log.annotation.SysLog
;
import
com.yifu.cloud.plus.v1.yifu.permission.entity.SysUserInfo
;
import
com.yifu.cloud.plus.v1.yifu.permission.vo.SysUserInfoSaveVo
;
import
com.yifu.cloud.plus.v1.yifu.permission.vo.SysUserInfoSearchVo
;
import
io.swagger.v3.oas.annotations.Operation
;
import
io.swagger.v3.oas.annotations.tags.Tag
;
...
...
@@ -67,22 +68,22 @@ public class SysUserInfoController {
@Operation
(
summary
=
"通过id查询"
,
description
=
"通过id查询:hasPermission('ekp_sysuserinfo_get')"
)
@GetMapping
(
"/{fdId}"
)
@PreAuthorize
(
"@pms.hasPermission('ekp_sysuserinfo_get')"
)
public
R
<
SysUserInfo
>
getById
(
@PathVariable
(
"fdId"
)
String
fdId
)
{
return
R
.
ok
(
sysUserInfoService
.
getById
(
fdId
)
);
public
R
<
SysUserInfo
SaveVo
>
getById
(
@PathVariable
(
"fdId"
)
String
fdId
)
{
return
sysUserInfoService
.
getInfoById
(
fdId
);
}
/**
* 新增新权限-账号管理表
*
* @param
sysUserInf
o 新权限-账号管理表
* @param
v
o 新权限-账号管理表
* @return R
*/
@Operation
(
summary
=
"新增
新权限-账号管理表"
,
description
=
"新增
新权限-账号管理表:hasPermission('ekp_sysuserinfo_add')"
)
@SysLog
(
"新增新权限-账号管理表"
)
@Operation
(
summary
=
"新增
或编辑新权限-账号管理表"
,
description
=
"新增或编辑
新权限-账号管理表:hasPermission('ekp_sysuserinfo_add')"
)
@SysLog
(
"新增
或编辑
新权限-账号管理表"
)
@PostMapping
@PreAuthorize
(
"@pms.hasPermission('ekp_sysuserinfo_add')"
)
public
R
<
Boolean
>
save
(
@RequestBody
SysUserInfo
sysUserInf
o
)
{
return
R
.
ok
(
sysUserInfoService
.
save
(
sysUserInfo
)
);
public
R
<
String
>
saveOrUpdateUserInfo
(
@RequestBody
SysUserInfoSaveVo
v
o
)
{
return
sysUserInfoService
.
saveOrUpdateUserInfo
(
vo
);
}
/**
...
...
@@ -113,16 +114,4 @@ public class SysUserInfoController {
return
R
.
ok
(
sysUserInfoService
.
removeById
(
fdId
));
}
/**
* 新权限-账号管理表 批量导出
*
* @author hgw
* @date 2023-08-29 14:49:40
**/
@Operation
(
description
=
"导出新权限-账号管理表 hasPermission('ekp_sysuserinfo-export')"
)
@PostMapping
(
"/export"
)
@PreAuthorize
(
"@pms.hasPermission('ekp_sysuserinfo-export')"
)
public
void
export
(
HttpServletResponse
response
,
@RequestBody
SysUserInfoSearchVo
searchVo
)
{
sysUserInfoService
.
listExport
(
response
,
searchVo
);
}
}
yifu-permission/yifu-permission-biz/src/main/java/com/yifu/cloud/plus/v1/permission/mapper/SysRoleInfoMapper.java
View file @
d95d0696
...
...
@@ -23,6 +23,8 @@ import com.yifu.cloud.plus.v1.yifu.permission.vo.SysRoleInfoSearchVo;
import
org.apache.ibatis.annotations.Mapper
;
import
org.apache.ibatis.annotations.Param
;
import
java.util.List
;
/**
* 新权限-角色表
*
...
...
@@ -38,4 +40,9 @@ public interface SysRoleInfoMapper extends BaseMapper<SysRoleInfo> {
* @return
*/
IPage
<
SysRoleInfo
>
getSysRoleInfoPage
(
Page
<
SysRoleInfo
>
page
,
@Param
(
"sysRoleInfo"
)
SysRoleInfoSearchVo
sysRoleInfo
);
List
<
String
>
getAllRoleDataAuthByUserId
(
@Param
(
"userId"
)
String
userId
);
int
checkExistenceRole
(
@Param
(
"roleName"
)
String
roleName
,
@Param
(
"roleId"
)
String
roleId
);
}
yifu-permission/yifu-permission-biz/src/main/java/com/yifu/cloud/plus/v1/permission/mapper/SysRoleMenuResMapper.java
View file @
d95d0696
...
...
@@ -37,4 +37,13 @@ public interface SysRoleMenuResMapper extends BaseMapper<SysRoleMenuRes> {
* @return
*/
IPage
<
SysRoleMenuRes
>
getSysRoleMenuResPage
(
Page
<
SysRoleMenuRes
>
page
,
@Param
(
"sysRoleMenuRes"
)
SysRoleMenuRes
sysRoleMenuRes
);
/**
* @param roleId
* @Description: 根据角色删除关联表
* @Author: hgw
* @Date: 2023/8/30 15:19
* @return: boolean
**/
boolean
deleteByRoleId
(
@Param
(
"roleId"
)
String
roleId
);
}
yifu-permission/yifu-permission-biz/src/main/java/com/yifu/cloud/plus/v1/permission/mapper/SysUserRoleResMapper.java
View file @
d95d0696
...
...
@@ -37,4 +37,8 @@ public interface SysUserRoleResMapper extends BaseMapper<SysUserRoleRes> {
* @return
*/
IPage
<
SysUserRoleRes
>
getSysUserRoleResPage
(
Page
<
SysUserRoleRes
>
page
,
@Param
(
"sysUserRoleRes"
)
SysUserRoleRes
sysUserRoleRes
);
boolean
deleteByUserId
(
@Param
(
"userId"
)
String
userId
);
boolean
deleteByRoleId
(
@Param
(
"roleId"
)
String
roleId
);
}
yifu-permission/yifu-permission-biz/src/main/java/com/yifu/cloud/plus/v1/permission/service/SysRoleInfoService.java
View file @
d95d0696
...
...
@@ -18,13 +18,11 @@ package com.yifu.cloud.plus.v1.permission.service;/*
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
com.yifu.cloud.plus.v1.yifu.common.core.util.ErrorMessage
;
import
com.yifu.cloud.plus.v1.yifu.common.core.util.R
;
import
com.yifu.cloud.plus.v1.yifu.permission.entity.SysRoleInfo
;
import
com.yifu.cloud.plus.v1.yifu.permission.vo.SysRoleInfoSaveVo
;
import
com.yifu.cloud.plus.v1.yifu.permission.vo.SysRoleInfoSearchVo
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.InputStream
;
import
java.util.List
;
/**
...
...
@@ -42,9 +40,33 @@ public interface SysRoleInfoService extends IService<SysRoleInfo> {
*/
IPage
<
SysRoleInfo
>
getSysRoleInfoPage
(
Page
<
SysRoleInfo
>
page
,
SysRoleInfoSearchVo
sysRoleInfo
);
R
<
List
<
ErrorMessage
>>
importDiy
(
InputStream
inputStream
);
/**
* @param fdId
* @Description: 查看
* @Author: hgw
* @Date: 2023/8/30 15:10
* @return: com.yifu.cloud.plus.v1.yifu.common.core.util.R<com.yifu.cloud.plus.v1.yifu.permission.vo.SysRoleInfoSaveVo>
**/
R
<
SysRoleInfoSaveVo
>
getInfoById
(
String
fdId
);
void
listExport
(
HttpServletResponse
response
,
SysRoleInfoSearchVo
searchVo
);
/**
* @param vo
* @Description: 新增或编辑新权限-角色表
* @Author: hgw
* @Date: 2023/8/30 15:10
* @return: com.yifu.cloud.plus.v1.yifu.common.core.util.R<java.lang.Boolean>
**/
R
<
String
>
saveOrUpdateRoleInfo
(
SysRoleInfoSaveVo
vo
);
List
<
SysRoleInfo
>
noPageDiy
(
SysRoleInfoSearchVo
searchVo
);
/**
* @param userId
* @Description: 各种角色的权限融合
* @Author: hgw
* @Date: 2023/8/30 18:06
* @return: java.lang.String
**/
String
getAllRoleDataAuthByUserId
(
String
userId
);
}
yifu-permission/yifu-permission-biz/src/main/java/com/yifu/cloud/plus/v1/permission/service/SysRoleMenuResService.java
View file @
d95d0696
...
...
@@ -39,4 +39,14 @@ public interface SysRoleMenuResService extends IService<SysRoleMenuRes> {
IPage
<
SysRoleMenuRes
>
getSysRoleMenuResPage
(
Page
<
SysRoleMenuRes
>
page
,
SysRoleMenuResSearchVo
sysRoleMenuRes
);
List
<
SysRoleMenuRes
>
noPageDiy
(
SysRoleMenuResSearchVo
searchVo
);
/**
* @param roleId
* @Description: 根据角色删除关联表
* @Author: hgw
* @Date: 2023/8/30 15:19
* @return: boolean
**/
boolean
deleteByRoleId
(
String
roleId
);
}
yifu-permission/yifu-permission-biz/src/main/java/com/yifu/cloud/plus/v1/permission/service/SysUserInfoService.java
View file @
d95d0696
...
...
@@ -18,13 +18,12 @@ package com.yifu.cloud.plus.v1.permission.service;/*
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
com.yifu.cloud.plus.v1.yifu.common.core.util.ErrorMessage
;
import
com.yifu.cloud.plus.v1.yifu.common.core.util.R
;
import
com.yifu.cloud.plus.v1.yifu.permission.entity.SysUserInfo
;
import
com.yifu.cloud.plus.v1.yifu.permission.vo.SysRoleInfoSaveVo
;
import
com.yifu.cloud.plus.v1.yifu.permission.vo.SysUserInfoSaveVo
;
import
com.yifu.cloud.plus.v1.yifu.permission.vo.SysUserInfoSearchVo
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.InputStream
;
import
java.util.List
;
/**
...
...
@@ -42,9 +41,23 @@ public interface SysUserInfoService extends IService<SysUserInfo> {
*/
IPage
<
SysUserInfo
>
getSysUserInfoPage
(
Page
<
SysUserInfo
>
page
,
SysUserInfoSearchVo
sysUserInfo
);
R
<
List
<
ErrorMessage
>>
importDiy
(
InputStream
inputStream
);
List
<
SysUserInfo
>
noPageDiy
(
SysUserInfoSearchVo
searchVo
);
void
listExport
(
HttpServletResponse
response
,
SysUserInfoSearchVo
searchVo
);
/**
* @param fdId
* @Description: 查看
* @Author: hgw
* @Date: 2023/8/30 15:10
* @return: com.yifu.cloud.plus.v1.yifu.common.core.util.R<com.yifu.cloud.plus.v1.yifu.permission.vo.SysUserInfoSaveVo>
**/
R
<
SysUserInfoSaveVo
>
getInfoById
(
String
fdId
);
List
<
SysUserInfo
>
noPageDiy
(
SysUserInfoSearchVo
searchVo
);
/**
* @param vo
* @Description: 新增或编辑新权限-账号表
* @Author: hgw
* @Date: 2023/8/30 15:10
* @return: com.yifu.cloud.plus.v1.yifu.common.core.util.R<java.lang.Boolean>
**/
R
<
String
>
saveOrUpdateUserInfo
(
SysUserInfoSaveVo
vo
);
}
yifu-permission/yifu-permission-biz/src/main/java/com/yifu/cloud/plus/v1/permission/service/SysUserRoleResService.java
View file @
d95d0696
package
com
.
yifu
.
cloud
.
plus
.
v1
.
permission
.
service
;
/*
* Copyright (c) 2018-2025, lengleng All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the yifu4cloud.com developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: lengleng (wangiegie@gmail.com)
*/
package
com
.
yifu
.
cloud
.
plus
.
v1
.
permission
.
service
;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
...
...
@@ -39,4 +24,23 @@ public interface SysUserRoleResService extends IService<SysUserRoleRes> {
IPage
<
SysUserRoleRes
>
getSysUserRoleResPage
(
Page
<
SysUserRoleRes
>
page
,
SysUserRoleResSearchVo
sysUserRoleRes
);
List
<
SysUserRoleRes
>
noPageDiy
(
SysUserRoleResSearchVo
searchVo
);
/**
* @param userId
* @Description: 根据账号删除关联表
* @Author: hgw
* @Date: 2023/8/30 15:45
* @return: boolean
**/
boolean
deleteByUserId
(
String
userId
);
/**
* @param roleId
* @Description: 根据角色删除关联表
* @Author: hgw
* @Date: 2023/8/30 15:45
* @return: boolean
**/
boolean
deleteByRoleId
(
String
roleId
);
}
yifu-permission/yifu-permission-biz/src/main/java/com/yifu/cloud/plus/v1/permission/service/impl/SysRoleInfoServiceImpl.java
View file @
d95d0696
package
com
.
yifu
.
cloud
.
plus
.
v1
.
permission
.
service
.
impl
;
/*
* Copyright (c) 2018-2025, lengleng All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the yifu4cloud.com developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: lengleng (wangiegie@gmail.com)
*/
package
com
.
yifu
.
cloud
.
plus
.
v1
.
permission
.
service
.
impl
;
import
cn.hutool.core.bean.BeanUtil
;
import
com.alibaba.excel.EasyExcel
;
import
com.alibaba.excel.ExcelWriter
;
import
com.alibaba.excel.context.AnalysisContext
;
import
com.alibaba.excel.read.listener.ReadListener
;
import
com.alibaba.excel.read.metadata.holder.ReadRowHolder
;
import
com.alibaba.excel.util.ListUtils
;
import
com.alibaba.excel.write.metadata.WriteSheet
;
import
cn.hutool.core.lang.tree.Tree
;
import
cn.hutool.core.lang.tree.TreeNode
;
import
cn.hutool.core.lang.tree.TreeUtil
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
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.SysMenuMapper
;
import
com.yifu.cloud.plus.v1.permission.mapper.SysRoleInfoMapper
;
import
com.yifu.cloud.plus.v1.permission.service.SysRoleInfoService
;
import
com.yifu.cloud.plus.v1.permission.service.SysRoleMenuResService
;
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.util.Common
;
import
com.yifu.cloud.plus.v1.yifu.common.core.util.R
;
import
com.yifu.cloud.plus.v1.yifu.common.mybatis.base.BaseEntity
;
import
com.yifu.cloud.plus.v1.yifu.permission.entity.SysMenu
;
import
com.yifu.cloud.plus.v1.yifu.permission.entity.SysRoleInfo
;
import
com.yifu.cloud.plus.v1.yifu.permission.entity.SysRoleMenuRes
;
import
com.yifu.cloud.plus.v1.yifu.permission.vo.SysRoleInfoSaveVo
;
import
com.yifu.cloud.plus.v1.yifu.permission.vo.SysRoleInfoSearchVo
;
import
com.yifu.cloud.plus.v1.yifu.permission.vo.SysRoleInfoVo
;
import
com.yifu.cloud.plus.v1.yifu.permission.vo.SysRoleMenuResSearchVo
;
import
lombok.AllArgsConstructor
;
import
lombok.extern.log4j.Log4j2
;
import
org.springframework.stereotype.Service
;
import
javax.servlet.ServletOutputStream
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.net.URLEncoder
;
import
java.util.ArrayList
;
import
java.util.List
;
import
javax.validation.constraints.NotNull
;
import
java.util.*
;
import
java.util.function.Function
;
import
java.util.stream.Collectors
;
/**
* 新权限-角色表
...
...
@@ -55,7 +39,12 @@ import java.util.List;
*/
@Log4j2
@Service
@AllArgsConstructor
public
class
SysRoleInfoServiceImpl
extends
ServiceImpl
<
SysRoleInfoMapper
,
SysRoleInfo
>
implements
SysRoleInfoService
{
private
final
SysRoleMenuResService
sysRoleMenuResService
;
private
final
SysMenuMapper
sysMenuMapper
;
/**
* 新权限-角色表简单分页查询
*
...
...
@@ -67,70 +56,65 @@ public class SysRoleInfoServiceImpl extends ServiceImpl<SysRoleInfoMapper, SysRo
return
baseMapper
.
getSysRoleInfoPage
(
page
,
sysRoleInfo
);
}
/**
* 新权限-角色表批量导出
*
* @param searchVo 新权限-角色表
* @return
*/
@Override
public
void
listExport
(
HttpServletResponse
response
,
SysRoleInfoSearchVo
searchVo
)
{
String
fileName
=
"新权限-角色表批量导出"
+
DateUtil
.
getThisTime
()
+
".xlsx"
;
//获取要导出的列表
List
<
SysRoleInfo
>
list
=
new
ArrayList
<>();
long
count
=
noPageCountDiy
(
searchVo
);
ServletOutputStream
out
=
null
;
try
{
out
=
response
.
getOutputStream
();
response
.
setContentType
(
CommonConstants
.
MULTIPART_FORM_DATA
);
response
.
setCharacterEncoding
(
"utf-8"
);
response
.
setHeader
(
CommonConstants
.
CONTENT_DISPOSITION
,
CommonConstants
.
ATTACHMENT_FILENAME
+
URLEncoder
.
encode
(
fileName
,
CommonConstants
.
UTF8
));
// 这里 需要指定写用哪个class去写,然后写到第一个sheet,然后文件流会自动关闭
//EasyExcel.write(out, TEmpBadRecord.class).sheet("不良记录").doWrite(list);
ExcelWriter
excelWriter
=
EasyExcel
.
write
(
out
,
SysRoleInfo
.
class
).
build
();
int
index
=
0
;
if
(
count
>
CommonConstants
.
ZERO_INT
)
{
for
(
int
i
=
0
;
i
<=
count
;
)
{
// 获取实际记录
searchVo
.
setLimitStart
(
i
);
searchVo
.
setLimitEnd
(
CommonConstants
.
EXCEL_EXPORT_LIMIT
);
list
=
noPageDiy
(
searchVo
);
if
(
Common
.
isNotNull
(
list
))
{
ExcelUtil
<
SysRoleInfo
>
util
=
new
ExcelUtil
<>(
SysRoleInfo
.
class
);
for
(
SysRoleInfo
vo
:
list
)
{
util
.
convertEntity
(
vo
,
null
,
null
,
null
);
}
}
if
(
Common
.
isNotNull
(
list
))
{
WriteSheet
writeSheet
=
EasyExcel
.
writerSheet
(
"新权限-角色表"
+
index
).
build
();
excelWriter
.
write
(
list
,
writeSheet
);
index
++;
}
i
=
i
+
CommonConstants
.
EXCEL_EXPORT_LIMIT
;
if
(
Common
.
isNotNull
(
list
))
{
list
.
clear
();
}
@NotNull
private
Function
<
SysMenu
,
TreeNode
<
String
>>
getNodeFunction
()
{
return
menu
->
{
TreeNode
<
String
>
node
=
new
TreeNode
<>();
node
.
setId
(
menu
.
getId
());
node
.
setName
(
menu
.
getMenuName
());
node
.
setParentId
(
menu
.
getMenuParentId
());
// 扩展属性
Map
<
String
,
Object
>
extra
=
new
HashMap
<>();
extra
.
put
(
"label"
,
menu
.
getMenuName
());
node
.
setExtra
(
extra
);
return
node
;
};
}
}
else
{
WriteSheet
writeSheet
=
EasyExcel
.
writerSheet
(
"新权限-角色表"
+
index
).
build
();
excelWriter
.
write
(
list
,
writeSheet
);
}
if
(
Common
.
isNotNull
(
list
))
{
list
.
clear
();
@Override
public
R
<
SysRoleInfoSaveVo
>
getInfoById
(
String
fdId
)
{
SysRoleInfoSaveVo
vo
=
new
SysRoleInfoSaveVo
();
SysRoleInfo
role
=
this
.
getById
(
fdId
);
if
(
role
!=
null
&&
Common
.
isNotNull
(
role
.
getFdId
()))
{
SysRoleMenuResSearchVo
sysRoleMenuRes
=
new
SysRoleMenuResSearchVo
();
sysRoleMenuRes
.
setRoleId
(
role
.
getFdId
());
List
<
SysRoleMenuRes
>
resList
=
sysRoleMenuResService
.
noPageDiy
(
sysRoleMenuRes
);
List
<
TreeNode
<
String
>>
collect
=
sysMenuMapper
.
selectList
(
Wrappers
.<
SysMenu
>
lambdaQuery
()
.
orderByAsc
(
SysMenu:
:
getCreateTime
)).
stream
()
.
map
(
getNodeFunction
()).
collect
(
Collectors
.
toList
());
List
<
Tree
<
String
>>
tree
=
TreeUtil
.
build
(
collect
,
CommonConstants
.
ZERO_STRING
);
vo
.
setRole
(
role
);
vo
.
setResList
(
resList
);
vo
.
setTree
(
tree
);
}
return
R
.
ok
(
vo
);
}
out
.
flush
();
excelWriter
.
finish
();
}
catch
(
Exception
e
)
{
log
.
error
(
"执行异常"
,
e
);
}
finally
{
try
{
if
(
null
!=
out
)
{
out
.
close
();
/**
* @param vo
* @Description: 新增或编辑新权限-角色表
* @Author: hgw
* @Date: 2023/8/30 15:24
* @return: com.yifu.cloud.plus.v1.yifu.common.core.util.R<java.lang.String>
**/
@Override
public
R
<
String
>
saveOrUpdateRoleInfo
(
SysRoleInfoSaveVo
vo
)
{
SysRoleInfo
role
=
vo
.
getRole
();
List
<
SysRoleMenuRes
>
resList
=
vo
.
getResList
();
if
(
role
!=
null
&&
Common
.
isNotNull
(
role
.
getRoleName
())
&&
resList
!=
null
&&
!
resList
.
isEmpty
())
{
if
(
Common
.
isNotNull
(
role
.
getFdId
()))
{
sysRoleMenuResService
.
deleteByRoleId
(
role
.
getFdId
());
}
}
catch
(
IOException
e
)
{
log
.
error
(
"执行异常"
,
e
);
int
num
=
baseMapper
.
checkExistenceRole
(
role
.
getRoleName
(),
role
.
getFdId
());
if
(
num
>
0
)
{
return
R
.
failed
(
"名称已存在"
);
}
this
.
saveOrUpdate
(
role
);
sysRoleMenuResService
.
saveBatch
(
resList
);
return
R
.
ok
(
"保存成功"
);
}
return
R
.
failed
(
"请检查信息"
);
}
@Override
...
...
@@ -147,17 +131,37 @@ public class SysRoleInfoServiceImpl extends ServiceImpl<SysRoleInfoMapper, SysRo
return
baseMapper
.
selectList
(
wrapper
);
}
private
Long
noPageCountDiy
(
SysRoleInfoSearchVo
searchVo
)
{
LambdaQueryWrapper
<
SysRoleInfo
>
wrapper
=
buildQueryWrapper
(
searchVo
);
List
<
String
>
idList
=
Common
.
getList
(
searchVo
.
getIds
());
if
(
Common
.
isNotNull
(
idList
))
{
wrapper
.
in
(
SysRoleInfo:
:
getFdId
,
idList
);
@Override
public
String
getAllRoleDataAuthByUserId
(
String
userId
)
{
List
<
String
>
authList
=
baseMapper
.
getAllRoleDataAuthByUserId
(
userId
);
String
auths
=
""
;
if
(
authList
!=
null
&&
!
authList
.
isEmpty
())
{
String
[]
authArr
;
Set
<
String
>
authSet
=
new
HashSet
<>();
for
(
String
auth
:
authList
)
{
authArr
=
auth
.
split
(
","
);
for
(
String
subAuth
:
authArr
)
{
authSet
.
add
(
subAuth
);
}
}
boolean
flag
=
false
;
for
(
String
subAuth
:
authSet
)
{
if
(
flag
)
{
auths
=
auths
+
","
+
subAuth
;
}
else
{
auths
=
subAuth
;
flag
=
true
;
}
}
return
baseMapper
.
selectCount
(
wrapper
);
}
return
auths
;
}
private
LambdaQueryWrapper
buildQueryWrapper
(
SysRoleInfoSearchVo
entity
)
{
LambdaQueryWrapper
<
SysRoleInfo
>
wrapper
=
Wrappers
.
lambdaQuery
();
if
(
Common
.
isNotNull
(
entity
.
getRoleName
()))
{
wrapper
.
like
(
SysRoleInfo:
:
getRoleName
,
entity
.
getRoleName
());
}
if
(
Common
.
isNotNull
(
entity
.
getCreateTimeStart
()))
{
wrapper
.
ge
(
SysRoleInfo:
:
getCreateTime
,
entity
.
getCreateTimeStart
());
}
...
...
@@ -170,83 +174,4 @@ public class SysRoleInfoServiceImpl extends ServiceImpl<SysRoleInfoMapper, SysRo
return
wrapper
;
}
@Override
public
R
<
List
<
ErrorMessage
>>
importDiy
(
InputStream
inputStream
)
{
List
<
ErrorMessage
>
errorMessageList
=
new
ArrayList
<>();
ExcelUtil
<
SysRoleInfoVo
>
util1
=
new
ExcelUtil
<>(
SysRoleInfoVo
.
class
);
// 写法2:
// 匿名内部类 不用额外写一个DemoDataListener
// 这里 需要指定读用哪个class去读,然后读取第一个sheet 文件流会自动关闭
try
{
EasyExcel
.
read
(
inputStream
,
SysRoleInfoVo
.
class
,
new
ReadListener
<
SysRoleInfoVo
>()
{
/**
* 单次缓存的数据量
*/
public
static
final
int
BATCH_COUNT
=
CommonConstants
.
BATCH_COUNT
;
/**
*临时存储
*/
private
List
<
SysRoleInfoVo
>
cachedDataList
=
ListUtils
.
newArrayListWithExpectedSize
(
BATCH_COUNT
);
@Override
public
void
invoke
(
SysRoleInfoVo
data
,
AnalysisContext
context
)
{
ReadRowHolder
readRowHolder
=
context
.
readRowHolder
();
Integer
rowIndex
=
readRowHolder
.
getRowIndex
();
data
.
setRowIndex
(
rowIndex
+
1
);
ErrorMessage
errorMessage
=
util1
.
checkEntity
(
data
,
data
.
getRowIndex
());
if
(
Common
.
isNotNull
(
errorMessage
))
{
errorMessageList
.
add
(
errorMessage
);
}
else
{
cachedDataList
.
add
(
data
);
}
if
(
cachedDataList
.
size
()
>=
BATCH_COUNT
)
{
saveData
();
// 存储完成清理 list
cachedDataList
=
ListUtils
.
newArrayListWithExpectedSize
(
BATCH_COUNT
);
}
}
@Override
public
void
doAfterAllAnalysed
(
AnalysisContext
context
)
{
saveData
();
}
/**
* 加上存储数据库
*/
private
void
saveData
()
{
log
.
info
(
"{}条数据,开始存储数据库!"
,
cachedDataList
.
size
());
importSysRoleInfo
(
cachedDataList
,
errorMessageList
);
log
.
info
(
"存储数据库成功!"
);
}
}).
sheet
().
doRead
();
}
catch
(
Exception
e
)
{
log
.
error
(
CommonConstants
.
IMPORT_DATA_ANALYSIS_ERROR
,
e
);
return
R
.
failed
(
CommonConstants
.
IMPORT_DATA_ANALYSIS_ERROR
);
}
return
R
.
ok
(
errorMessageList
);
}
private
void
importSysRoleInfo
(
List
<
SysRoleInfoVo
>
excelVOList
,
List
<
ErrorMessage
>
errorMessageList
)
{
// 个性化校验逻辑
ErrorMessage
errorMsg
;
// 执行数据插入操作 组装
for
(
int
i
=
0
;
i
<
excelVOList
.
size
();
i
++)
{
SysRoleInfoVo
excel
=
excelVOList
.
get
(
i
);
// 数据合法情况 TODO
// 插入
insertExcel
(
excel
);
errorMessageList
.
add
(
new
ErrorMessage
(
excel
.
getRowIndex
(),
CommonConstants
.
SAVE_SUCCESS
));
}
}
/**
* 插入excel bad record
*/
private
void
insertExcel
(
SysRoleInfoVo
excel
)
{
SysRoleInfo
insert
=
new
SysRoleInfo
();
BeanUtil
.
copyProperties
(
excel
,
insert
);
this
.
save
(
insert
);
}
}
yifu-permission/yifu-permission-biz/src/main/java/com/yifu/cloud/plus/v1/permission/service/impl/SysRoleMenuResServiceImpl.java
View file @
d95d0696
...
...
@@ -66,6 +66,18 @@ public class SysRoleMenuResServiceImpl extends ServiceImpl<SysRoleMenuResMapper,
return
baseMapper
.
selectList
(
wrapper
);
}
/**
* @param roleId
* @Description: 根据角色删除关联表
* @Author: hgw
* @Date: 2023/8/30 15:19
* @return: boolean
**/
@Override
public
boolean
deleteByRoleId
(
String
roleId
)
{
return
baseMapper
.
deleteByRoleId
(
roleId
);
}
private
LambdaQueryWrapper
buildQueryWrapper
(
SysRoleMenuResSearchVo
entity
)
{
LambdaQueryWrapper
<
SysRoleMenuRes
>
wrapper
=
Wrappers
.
lambdaQuery
();
if
(
ArrayUtil
.
isNotEmpty
(
entity
.
getCreateTimes
()))
{
...
...
yifu-permission/yifu-permission-biz/src/main/java/com/yifu/cloud/plus/v1/permission/service/impl/SysUserInfoServiceImpl.java
View file @
d95d0696
...
...
@@ -15,39 +15,32 @@ package com.yifu.cloud.plus.v1.permission.service.impl;/*
* Author: lengleng (wangiegie@gmail.com)
*/
import
cn.hutool.core.bean.BeanUtil
;
import
cn.hutool.core.lang.tree.Tree
;
import
cn.hutool.core.lang.tree.TreeNode
;
import
cn.hutool.core.lang.tree.TreeUtil
;
import
cn.hutool.core.util.ArrayUtil
;
import
com.alibaba.excel.EasyExcel
;
import
com.alibaba.excel.EasyExcelFactory
;
import
com.alibaba.excel.ExcelWriter
;
import
com.alibaba.excel.context.AnalysisContext
;
import
com.alibaba.excel.read.listener.ReadListener
;
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.conditions.query.LambdaQueryWrapper
;
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.SysMenuMapper
;
import
com.yifu.cloud.plus.v1.permission.mapper.SysUserInfoMapper
;
import
com.yifu.cloud.plus.v1.permission.service.SysRoleInfoService
;
import
com.yifu.cloud.plus.v1.permission.service.SysUserInfoService
;
import
com.yifu.cloud.plus.v1.permission.service.SysUserRoleResService
;
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.util.Common
;
import
com.yifu.cloud.plus.v1.yifu.common.core.util.R
;
import
com.yifu.cloud.plus.v1.yifu.common.mybatis.base.BaseEntity
;
import
com.yifu.cloud.plus.v1.yifu.permission.entity.
SysUserInfo
;
import
com.yifu.cloud.plus.v1.yifu.permission.vo.
SysUserInfoSearchVo
;
import
com.yifu.cloud.plus.v1.yifu.permission.vo.SysUserInfoVo
;
import
com.yifu.cloud.plus.v1.yifu.permission.entity.
*
;
import
com.yifu.cloud.plus.v1.yifu.permission.vo.
*
;
import
lombok.AllArgsConstructor
;
import
lombok.extern.log4j.Log4j2
;
import
org.springframework.stereotype.Service
;
import
javax.servlet.ServletOutputStream
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.net.URLEncoder
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.stream.Collectors
;
/**
* 新权限-账号管理表
...
...
@@ -57,7 +50,12 @@ import java.util.List;
*/
@Log4j2
@Service
@AllArgsConstructor
public
class
SysUserInfoServiceImpl
extends
ServiceImpl
<
SysUserInfoMapper
,
SysUserInfo
>
implements
SysUserInfoService
{
private
final
SysUserRoleResService
sysUserRoleResService
;
private
final
SysRoleInfoService
sysRoleInfoService
;
/**
* 新权限-账号管理表简单分页查询
*
...
...
@@ -69,71 +67,6 @@ public class SysUserInfoServiceImpl extends ServiceImpl<SysUserInfoMapper, SysUs
return
baseMapper
.
getSysUserInfoPage
(
page
,
sysUserInfo
);
}
/**
* 新权限-账号管理表批量导出
*
* @param searchVo 新权限-账号管理表
* @return
*/
@Override
public
void
listExport
(
HttpServletResponse
response
,
SysUserInfoSearchVo
searchVo
)
{
String
fileName
=
"新权限-账号管理表批量导出"
+
DateUtil
.
getThisTime
()
+
".xlsx"
;
//获取要导出的列表
List
<
SysUserInfo
>
list
=
new
ArrayList
<>();
long
count
=
noPageCountDiy
(
searchVo
);
ServletOutputStream
out
=
null
;
try
{
out
=
response
.
getOutputStream
();
response
.
setContentType
(
CommonConstants
.
MULTIPART_FORM_DATA
);
response
.
setCharacterEncoding
(
"utf-8"
);
response
.
setHeader
(
CommonConstants
.
CONTENT_DISPOSITION
,
CommonConstants
.
ATTACHMENT_FILENAME
+
URLEncoder
.
encode
(
fileName
,
CommonConstants
.
UTF8
));
// 这里 需要指定写用哪个class去写,然后写到第一个sheet,然后文件流会自动关闭
ExcelWriter
excelWriter
=
EasyExcelFactory
.
write
(
out
,
SysUserInfo
.
class
).
build
();
int
index
=
0
;
if
(
count
>
CommonConstants
.
ZERO_INT
)
{
for
(
int
i
=
0
;
i
<=
count
;
)
{
// 获取实际记录
searchVo
.
setLimitStart
(
i
);
searchVo
.
setLimitEnd
(
CommonConstants
.
EXCEL_EXPORT_LIMIT
);
list
=
noPageDiy
(
searchVo
);
if
(
Common
.
isNotNull
(
list
))
{
ExcelUtil
<
SysUserInfo
>
util
=
new
ExcelUtil
<>(
SysUserInfo
.
class
);
for
(
SysUserInfo
vo
:
list
)
{
util
.
convertEntity
(
vo
,
null
,
null
,
null
);
}
}
if
(
Common
.
isNotNull
(
list
))
{
WriteSheet
writeSheet
=
EasyExcelFactory
.
writerSheet
(
"新权限-账号管理表"
+
index
).
build
();
excelWriter
.
write
(
list
,
writeSheet
);
index
++;
}
i
=
i
+
CommonConstants
.
EXCEL_EXPORT_LIMIT
;
if
(
Common
.
isNotNull
(
list
))
{
list
.
clear
();
}
}
}
else
{
WriteSheet
writeSheet
=
EasyExcelFactory
.
writerSheet
(
"新权限-账号管理表"
+
index
).
build
();
excelWriter
.
write
(
list
,
writeSheet
);
}
if
(
Common
.
isNotNull
(
list
))
{
list
.
clear
();
}
out
.
flush
();
excelWriter
.
finish
();
}
catch
(
Exception
e
)
{
log
.
error
(
"执行异常"
,
e
);
}
finally
{
try
{
if
(
null
!=
out
)
{
out
.
close
();
}
}
catch
(
IOException
e
)
{
log
.
error
(
"执行异常"
,
e
);
}
}
}
@Override
public
List
<
SysUserInfo
>
noPageDiy
(
SysUserInfoSearchVo
searchVo
)
{
LambdaQueryWrapper
<
SysUserInfo
>
wrapper
=
buildQueryWrapper
(
searchVo
);
...
...
@@ -148,15 +81,6 @@ public class SysUserInfoServiceImpl extends ServiceImpl<SysUserInfoMapper, SysUs
return
baseMapper
.
selectList
(
wrapper
);
}
private
Long
noPageCountDiy
(
SysUserInfoSearchVo
searchVo
)
{
LambdaQueryWrapper
<
SysUserInfo
>
wrapper
=
buildQueryWrapper
(
searchVo
);
List
<
String
>
idList
=
Common
.
getList
(
searchVo
.
getIds
());
if
(
Common
.
isNotNull
(
idList
))
{
wrapper
.
in
(
SysUserInfo:
:
getFdId
,
idList
);
}
return
baseMapper
.
selectCount
(
wrapper
);
}
private
LambdaQueryWrapper
buildQueryWrapper
(
SysUserInfoSearchVo
entity
)
{
LambdaQueryWrapper
<
SysUserInfo
>
wrapper
=
Wrappers
.
lambdaQuery
();
if
(
ArrayUtil
.
isNotEmpty
(
entity
.
getCreateTimes
()))
{
...
...
@@ -170,83 +94,52 @@ public class SysUserInfoServiceImpl extends ServiceImpl<SysUserInfoMapper, SysUs
return
wrapper
;
}
@Override
public
R
<
List
<
ErrorMessage
>>
importDiy
(
InputStream
inputStream
)
{
List
<
ErrorMessage
>
errorMessageList
=
new
ArrayList
<>();
ExcelUtil
<
SysUserInfoVo
>
util1
=
new
ExcelUtil
<>(
SysUserInfoVo
.
class
);
// 写法2:
// 匿名内部类 不用额外写一个DemoDataListener
// 这里 需要指定读用哪个class去读,然后读取第一个sheet 文件流会自动关闭
try
{
EasyExcel
.
read
(
inputStream
,
SysUserInfoVo
.
class
,
new
ReadListener
<
SysUserInfoVo
>()
{
/**
* 单次缓存的数据量
*/
public
static
final
int
BATCH_COUNT
=
CommonConstants
.
BATCH_COUNT
;
/**
*临时存储
*/
private
List
<
SysUserInfoVo
>
cachedDataList
=
ListUtils
.
newArrayListWithExpectedSize
(
BATCH_COUNT
);
@Override
public
void
invoke
(
SysUserInfoVo
data
,
AnalysisContext
context
)
{
ReadRowHolder
readRowHolder
=
context
.
readRowHolder
();
Integer
rowIndex
=
readRowHolder
.
getRowIndex
();
data
.
setRowIndex
(
rowIndex
+
1
);
ErrorMessage
errorMessage
=
util1
.
checkEntity
(
data
,
data
.
getRowIndex
());
if
(
Common
.
isNotNull
(
errorMessage
))
{
errorMessageList
.
add
(
errorMessage
);
}
else
{
cachedDataList
.
add
(
data
);
}
if
(
cachedDataList
.
size
()
>=
BATCH_COUNT
)
{
saveData
();
// 存储完成清理 list
cachedDataList
=
ListUtils
.
newArrayListWithExpectedSize
(
BATCH_COUNT
);
}
}
* @param fdId
* @Description: 查看详情
* @Author: hgw
* @Date: 2023/8/30 18:14
* @return: com.yifu.cloud.plus.v1.yifu.common.core.util.R<com.yifu.cloud.plus.v1.yifu.permission.vo.SysUserInfoSaveVo>
**/
@Override
public
void
doAfterAllAnalysed
(
AnalysisContext
context
)
{
saveData
();
public
R
<
SysUserInfoSaveVo
>
getInfoById
(
String
fdId
)
{
SysUserInfoSaveVo
vo
=
new
SysUserInfoSaveVo
();
SysUserInfo
user
=
this
.
getById
(
fdId
);
if
(
user
!=
null
&&
Common
.
isNotNull
(
user
.
getFdId
()))
{
SysUserRoleResSearchVo
sysRoleMenuRes
=
new
SysUserRoleResSearchVo
();
sysRoleMenuRes
.
setUserId
(
user
.
getFdId
());
List
<
SysUserRoleRes
>
resList
=
sysUserRoleResService
.
noPageDiy
(
sysRoleMenuRes
);
vo
.
setUser
(
user
);
if
(
resList
!=
null
&&
!
resList
.
isEmpty
())
{
// 各种角色的权限融合
String
dataAuth
=
sysRoleInfoService
.
getAllRoleDataAuthByUserId
(
user
.
getFdId
());
vo
.
setDataAuth
(
dataAuth
);
}
vo
.
setResList
(
resList
);
}
return
R
.
ok
(
vo
);
}
/**
* 加上存储数据库
*/
private
void
saveData
()
{
log
.
info
(
"{}条数据,开始存储数据库!"
,
cachedDataList
.
size
());
importSysUserInfo
(
cachedDataList
,
errorMessageList
);
log
.
info
(
"存储数据库成功!"
);
* @param vo
* @Description: 新增或编辑新权限-角色表
* @Author: hgw
* @Date: 2023/8/30 15:24
* @return: com.yifu.cloud.plus.v1.yifu.common.core.util.R<java.lang.String>
**/
@Override
public
R
<
String
>
saveOrUpdateUserInfo
(
SysUserInfoSaveVo
vo
)
{
SysUserInfo
user
=
vo
.
getUser
();
List
<
SysUserRoleRes
>
resList
=
vo
.
getResList
();
if
(
user
!=
null
&&
Common
.
isNotNull
(
user
.
getFdName
())
&&
resList
!=
null
&&
!
resList
.
isEmpty
())
{
if
(
Common
.
isNotNull
(
user
.
getFdId
()))
{
sysUserRoleResService
.
deleteByUserId
(
user
.
getFdId
());
}
}).
sheet
().
doRead
();
}
catch
(
Exception
e
)
{
log
.
error
(
CommonConstants
.
IMPORT_DATA_ANALYSIS_ERROR
,
e
);
return
R
.
failed
(
CommonConstants
.
IMPORT_DATA_ANALYSIS_ERROR
);
this
.
saveOrUpdate
(
user
);
sysUserRoleResService
.
saveBatch
(
resList
);
return
R
.
ok
(
"保存成功"
);
}
return
R
.
ok
(
errorMessageList
);
return
R
.
failed
(
"请检查信息"
);
}
private
void
importSysUserInfo
(
List
<
SysUserInfoVo
>
excelVOList
,
List
<
ErrorMessage
>
errorMessageList
)
{
// 个性化校验逻辑
ErrorMessage
errorMsg
;
// 执行数据插入操作 组装
for
(
int
i
=
0
;
i
<
excelVOList
.
size
();
i
++)
{
SysUserInfoVo
excel
=
excelVOList
.
get
(
i
);
// 数据合法情况 TODO
// 插入
insertExcel
(
excel
);
errorMessageList
.
add
(
new
ErrorMessage
(
excel
.
getRowIndex
(),
CommonConstants
.
SAVE_SUCCESS
));
}
}
/**
* 插入excel bad record
*/
private
void
insertExcel
(
SysUserInfoVo
excel
)
{
SysUserInfo
insert
=
new
SysUserInfo
();
BeanUtil
.
copyProperties
(
excel
,
insert
);
this
.
save
(
insert
);
}
}
yifu-permission/yifu-permission-biz/src/main/java/com/yifu/cloud/plus/v1/permission/service/impl/SysUserRoleResServiceImpl.java
View file @
d95d0696
...
...
@@ -66,6 +66,16 @@ public class SysUserRoleResServiceImpl extends ServiceImpl<SysUserRoleResMapper,
return
baseMapper
.
selectList
(
wrapper
);
}
@Override
public
boolean
deleteByUserId
(
String
userId
)
{
return
baseMapper
.
deleteByUserId
(
userId
);
}
@Override
public
boolean
deleteByRoleId
(
String
roleId
)
{
return
baseMapper
.
deleteByRoleId
(
roleId
);
}
private
LambdaQueryWrapper
buildQueryWrapper
(
SysUserRoleResSearchVo
entity
)
{
LambdaQueryWrapper
<
SysUserRoleRes
>
wrapper
=
Wrappers
.
lambdaQuery
();
if
(
ArrayUtil
.
isNotEmpty
(
entity
.
getCreateTimes
()))
{
...
...
yifu-permission/yifu-permission-biz/src/main/resources/mapper/SysRoleInfoMapper.xml
View file @
d95d0696
...
...
@@ -55,7 +55,7 @@
AND a.fd_id = #{sysRoleInfo.fdId}
</if>
<if
test=
"sysRoleInfo.roleName != null and sysRoleInfo.roleName.trim() != ''"
>
AND a.role_name
= #{sysRoleInfo.roleName}
AND a.role_name
like concat('%',#{sysRoleInfo.roleName},'%')
</if>
<if
test=
"sysRoleInfo.remark != null and sysRoleInfo.remark.trim() != ''"
>
AND a.remark = #{sysRoleInfo.remark}
...
...
@@ -98,8 +98,30 @@
<include
refid=
"Base_Column_List"
/>
FROM sys_role_info a
<where>
1=1
a.delete_flag = 0
<include
refid=
"sysRoleInfo_where"
/>
</where>
order by a.CREATE_TIME desc
</select>
<!-- 根据用户Id获取所有的角色的权限-->
<select
id=
"getAllRoleDataAuthByUserId"
resultType=
"java.lang.String"
>
SELECT
a.data_auth
FROM sys_role_info a
left join sys_user_role_res r on r.role_id = a.fd_id
where a.delete_flag = 0 and r.user_id = #{userId}
</select>
<!-- 查找名称是否存在-->
<select
id=
"checkExistenceRole"
resultType=
"java.lang.Integer"
>
SELECT
count(1)
FROM sys_role_info a
where a.delete_flag = 0 and a.role_name = #{roleName}
<if
test=
"roleId != null and roleId.trim() != ''"
>
AND a.fd_id != #{roleId}
</if>
</select>
</mapper>
yifu-permission/yifu-permission-biz/src/main/resources/mapper/SysRoleMenuResMapper.xml
View file @
d95d0696
...
...
@@ -56,4 +56,10 @@
<include
refid=
"sysRoleMenuRes_where"
/>
</where>
</select>
<!-- 根据角色删除关联表 -->
<delete
id=
"deleteByRoleId"
>
delete from sys_role_menu_res where role_id = #{roleId}
</delete>
</mapper>
yifu-permission/yifu-permission-biz/src/main/resources/mapper/SysUserInfoMapper.xml
View file @
d95d0696
...
...
@@ -61,7 +61,7 @@
AND a.fd_id = #{sysUserInfo.fdId}
</if>
<if
test=
"sysUserInfo.fdName != null and sysUserInfo.fdName.trim() != ''"
>
AND a.fd_name
= #{sysUserInfo.fdName}
AND a.fd_name
like concat('%',#{sysUserInfo.fdName},'%')
</if>
<if
test=
"sysUserInfo.fdLoginName != null and sysUserInfo.fdLoginName.trim() != ''"
>
AND a.fd_login_name = #{sysUserInfo.fdLoginName}
...
...
@@ -70,7 +70,7 @@
AND a.fd_ldap_dn = #{sysUserInfo.fdLdapDn}
</if>
<if
test=
"sysUserInfo.fdDeptName != null and sysUserInfo.fdDeptName.trim() != ''"
>
AND a.fd_dept_name
= #{sysUserInfo.fdDeptName}
AND a.fd_dept_name
like concat('%',#{sysUserInfo.fdDeptName},'%')
</if>
<if
test=
"sysUserInfo.fdMobileNo != null and sysUserInfo.fdMobileNo.trim() != ''"
>
AND a.fd_mobile_no = #{sysUserInfo.fdMobileNo}
...
...
@@ -82,7 +82,7 @@
AND a.status = #{sysUserInfo.status}
</if>
<if
test=
"sysUserInfo.roleNames != null and sysUserInfo.roleNames.trim() != ''"
>
AND a.role_names
= #{sysUserInfo.roleNames}
AND a.role_names
like concat('%',#{sysUserInfo.roleNames},'%')
</if>
<if
test=
"sysUserInfo.createBy != null and sysUserInfo.createBy.trim() != ''"
>
AND a.CREATE_BY = #{sysUserInfo.createBy}
...
...
@@ -110,5 +110,6 @@
1=1
<include
refid=
"sysUserInfo_where"
/>
</where>
order by a.CREATE_TIME desc
</select>
</mapper>
yifu-permission/yifu-permission-biz/src/main/resources/mapper/SysUserRoleResMapper.xml
View file @
d95d0696
...
...
@@ -56,4 +56,15 @@
<include
refid=
"sysUserRoleRes_where"
/>
</where>
</select>
<!-- 根据账号删除关联表 -->
<delete
id=
"deleteByUserId"
>
delete from sys_user_role_res where user_id = #{userId}
</delete>
<!-- 根据角色删除关联表 -->
<delete
id=
"deleteByRoleId"
>
delete from sys_user_role_res where role_id = #{roleId}
</delete>
</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