0410-海宁预警转发+北仑客群优化+海宁aum报表导出下载
This commit is contained in:
@@ -48,4 +48,22 @@ public class CustGroupMemberQueryDTO {
|
||||
*/
|
||||
@ApiModelProperty(value = "客户经理姓名")
|
||||
private String nickName;
|
||||
|
||||
/**
|
||||
* 当前用户角色
|
||||
*/
|
||||
@ApiModelProperty(value = "当前用户角色", hidden = true)
|
||||
private String userRole;
|
||||
|
||||
/**
|
||||
* 当前用户名
|
||||
*/
|
||||
@ApiModelProperty(value = "当前用户名", hidden = true)
|
||||
private String currentUserName;
|
||||
|
||||
/**
|
||||
* 当前机构ID
|
||||
*/
|
||||
@ApiModelProperty(value = "当前机构ID", hidden = true)
|
||||
private Long currentDeptId;
|
||||
}
|
||||
|
||||
@@ -51,6 +51,12 @@ public class CustGroupQueryDTO implements Serializable {
|
||||
@ApiModelProperty(value = "视图类型", name = "viewType")
|
||||
private String viewType;
|
||||
|
||||
/**
|
||||
* 当前用户是否属于总行管理员口径
|
||||
*/
|
||||
@ApiModelProperty(value = "当前用户是否总行管理员", hidden = true)
|
||||
private Boolean headRole;
|
||||
|
||||
/**
|
||||
* 页码
|
||||
*/
|
||||
|
||||
@@ -34,7 +34,8 @@ public interface CustGroupMapper extends BaseMapper<CustGroup> {
|
||||
*/
|
||||
List<CustGroupVO> selectCustGroupList(@Param("dto") CustGroupQueryDTO dto,
|
||||
@Param("userName") String userName,
|
||||
@Param("deptId") String deptId);
|
||||
@Param("deptId") String deptId,
|
||||
@Param("headId") String headId);
|
||||
|
||||
/**
|
||||
* 根据ID查询客群详情
|
||||
@@ -44,7 +45,9 @@ public interface CustGroupMapper extends BaseMapper<CustGroup> {
|
||||
*/
|
||||
CustGroupVO selectCustGroupById(@Param("id") Long id,
|
||||
@Param("userName") String userName,
|
||||
@Param("deptId") String deptId);
|
||||
@Param("deptId") String deptId,
|
||||
@Param("headRole") Boolean headRole,
|
||||
@Param("headId") String headId);
|
||||
|
||||
/**
|
||||
* 校验当前用户是否有客群查看权限
|
||||
@@ -56,7 +59,18 @@ public interface CustGroupMapper extends BaseMapper<CustGroup> {
|
||||
*/
|
||||
Long countVisibleCustGroup(@Param("id") Long id,
|
||||
@Param("userName") String userName,
|
||||
@Param("deptId") String deptId);
|
||||
@Param("deptId") String deptId,
|
||||
@Param("headRole") Boolean headRole,
|
||||
@Param("headId") String headId);
|
||||
|
||||
/**
|
||||
* 校验客群是否属于总行管理员共享操作范围
|
||||
*
|
||||
* @param id 客群ID
|
||||
* @return 数量
|
||||
*/
|
||||
Long countHeadOperableCustGroup(@Param("id") Long id,
|
||||
@Param("headId") String headId);
|
||||
|
||||
/**
|
||||
* 查询所有已有的客群标签
|
||||
|
||||
@@ -41,6 +41,9 @@ public class CustGroupMemberServiceImpl implements ICustGroupMemberService {
|
||||
@Override
|
||||
public List<CustGroupMemberVO> listCustGroupMembers(Long groupId, CustGroupMemberQueryDTO dto) {
|
||||
custGroupService.checkCustGroupViewPermission(groupId);
|
||||
dto.setUserRole(SecurityUtils.userRole());
|
||||
dto.setCurrentUserName(SecurityUtils.getUsername());
|
||||
dto.setCurrentDeptId(SecurityUtils.getDeptId());
|
||||
// 在权限检查之后启动分页,避免权限检查SQL消耗分页设置
|
||||
int pageNum = dto.getPageNum() != null ? dto.getPageNum() : 1;
|
||||
int pageSize = dto.getPageSize() != null ? dto.getPageSize() : 10;
|
||||
@@ -109,7 +112,14 @@ public class CustGroupMemberServiceImpl implements ICustGroupMemberService {
|
||||
if (custGroup == null) {
|
||||
throw new ServiceException("客群不存在");
|
||||
}
|
||||
if (!SecurityUtils.getUsername().equals(custGroup.getUserName())) {
|
||||
if (!SecurityUtils.hasRole("headAdmin")
|
||||
&& !SecurityUtils.hasRole("headPublic")
|
||||
&& !SecurityUtils.hasRole("headPrivate")
|
||||
&& !SecurityUtils.hasRole("headOps")) {
|
||||
throw new ServiceException("无权限操作该客群");
|
||||
}
|
||||
Long count = custGroupMapper.countHeadOperableCustGroup(groupId, SecurityUtils.getHeadId());
|
||||
if (count == null || count <= 0) {
|
||||
throw new ServiceException("无权限操作该客群");
|
||||
}
|
||||
|
||||
|
||||
@@ -67,12 +67,24 @@ public class CustGroupServiceImpl implements ICustGroupService {
|
||||
|
||||
@Override
|
||||
public List<CustGroupVO> listCustGroup(CustGroupQueryDTO dto) {
|
||||
return custGroupMapper.selectCustGroupList(dto, SecurityUtils.getUsername(), String.valueOf(SecurityUtils.getDeptId()));
|
||||
dto.setHeadRole(isHeadCustGroupAdmin());
|
||||
return custGroupMapper.selectCustGroupList(
|
||||
dto,
|
||||
SecurityUtils.getUsername(),
|
||||
String.valueOf(SecurityUtils.getDeptId()),
|
||||
SecurityUtils.getHeadId()
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CustGroupVO getCustGroup(Long id) {
|
||||
CustGroupVO custGroup = custGroupMapper.selectCustGroupById(id, SecurityUtils.getUsername(), String.valueOf(SecurityUtils.getDeptId()));
|
||||
CustGroupVO custGroup = custGroupMapper.selectCustGroupById(
|
||||
id,
|
||||
SecurityUtils.getUsername(),
|
||||
String.valueOf(SecurityUtils.getDeptId()),
|
||||
isHeadCustGroupAdmin(),
|
||||
SecurityUtils.getHeadId()
|
||||
);
|
||||
if (custGroup == null) {
|
||||
throw new ServiceException("客群不存在");
|
||||
}
|
||||
@@ -82,6 +94,7 @@ public class CustGroupServiceImpl implements ICustGroupService {
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public String createCustGroupByTemplate(CustGroup custGroup, MultipartFile file) {
|
||||
assertHeadCustGroupAdmin();
|
||||
// 检查客群名称是否存在
|
||||
if (checkGroupNameExist(custGroup.getGroupName())) {
|
||||
throw new ServiceException("客群名称已存在");
|
||||
@@ -117,6 +130,7 @@ public class CustGroupServiceImpl implements ICustGroupService {
|
||||
if (existGroup == null) {
|
||||
throw new ServiceException("客群不存在");
|
||||
}
|
||||
assertOperatePermission(existGroup);
|
||||
// 检查客群是否正在创建或更新
|
||||
if ("0".equals(existGroup.getCreateStatus())) {
|
||||
throw new ServiceException("客群正在处理中,请稍后再试");
|
||||
@@ -167,6 +181,11 @@ public class CustGroupServiceImpl implements ICustGroupService {
|
||||
throw new ServiceException("请选择要删除的客群");
|
||||
}
|
||||
for (Long id : idList) {
|
||||
CustGroup custGroup = custGroupMapper.selectById(id);
|
||||
if (custGroup == null) {
|
||||
throw new ServiceException("客群不存在");
|
||||
}
|
||||
assertOperatePermission(custGroup);
|
||||
// 删除客群客户关联
|
||||
LambdaQueryWrapper<CustGroupMember> memberWrapper = new LambdaQueryWrapper<>();
|
||||
memberWrapper.eq(CustGroupMember::getGroupId, id);
|
||||
@@ -196,12 +215,39 @@ public class CustGroupServiceImpl implements ICustGroupService {
|
||||
|
||||
@Override
|
||||
public void checkCustGroupViewPermission(Long id) {
|
||||
Long count = custGroupMapper.countVisibleCustGroup(id, SecurityUtils.getUsername(), String.valueOf(SecurityUtils.getDeptId()));
|
||||
Long count = custGroupMapper.countVisibleCustGroup(
|
||||
id,
|
||||
SecurityUtils.getUsername(),
|
||||
String.valueOf(SecurityUtils.getDeptId()),
|
||||
isHeadCustGroupAdmin(),
|
||||
SecurityUtils.getHeadId()
|
||||
);
|
||||
if (count == null || count <= 0) {
|
||||
throw new ServiceException("客群不存在或无查看权限");
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isHeadCustGroupAdmin() {
|
||||
return SecurityUtils.hasRole("headAdmin")
|
||||
|| SecurityUtils.hasRole("headPublic")
|
||||
|| SecurityUtils.hasRole("headPrivate")
|
||||
|| SecurityUtils.hasRole("headOps");
|
||||
}
|
||||
|
||||
public void assertHeadCustGroupAdmin() {
|
||||
if (!isHeadCustGroupAdmin()) {
|
||||
throw new ServiceException("当前用户无权限操作该功能");
|
||||
}
|
||||
}
|
||||
|
||||
private void assertOperatePermission(CustGroup custGroup) {
|
||||
assertHeadCustGroupAdmin();
|
||||
Long count = custGroupMapper.countHeadOperableCustGroup(custGroup.getId(), SecurityUtils.getHeadId());
|
||||
if (count == null || count <= 0) {
|
||||
throw new ServiceException("无权限操作该客群");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateDynamicCustGroups() {
|
||||
log.info("开始更新动态客群...");
|
||||
|
||||
@@ -6,7 +6,22 @@
|
||||
|
||||
<sql id="custGroupVisibleBaseCondition">
|
||||
AND (
|
||||
cg.user_name = #{userName}
|
||||
<choose>
|
||||
<when test="headRole != null and headRole">
|
||||
EXISTS (
|
||||
SELECT 1
|
||||
FROM sys_user su
|
||||
LEFT JOIN sys_user_role sur ON su.user_id = sur.user_id
|
||||
LEFT JOIN sys_role sr ON sur.role_id = sr.role_id
|
||||
WHERE su.user_name = cg.user_name
|
||||
AND LEFT(CAST(cg.dept_id AS CHAR), 3) = #{headId}
|
||||
AND sr.role_key IN ('headAdmin', 'headPublic', 'headPrivate', 'headOps')
|
||||
)
|
||||
</when>
|
||||
<otherwise>
|
||||
1 = 2
|
||||
</otherwise>
|
||||
</choose>
|
||||
OR (
|
||||
cg.share_enabled = 1
|
||||
AND cg.group_status = '0'
|
||||
@@ -20,7 +35,22 @@
|
||||
<sql id="custGroupVisibleCondition">
|
||||
<choose>
|
||||
<when test="dto != null and dto.viewType == 'mine'">
|
||||
AND cg.user_name = #{userName}
|
||||
<choose>
|
||||
<when test="dto.headRole">
|
||||
AND EXISTS (
|
||||
SELECT 1
|
||||
FROM sys_user su
|
||||
LEFT JOIN sys_user_role sur ON su.user_id = sur.user_id
|
||||
LEFT JOIN sys_role sr ON sur.role_id = sr.role_id
|
||||
WHERE su.user_name = cg.user_name
|
||||
AND LEFT(CAST(cg.dept_id AS CHAR), 3) = #{headId}
|
||||
AND sr.role_key IN ('headAdmin', 'headPublic', 'headPrivate', 'headOps')
|
||||
)
|
||||
</when>
|
||||
<otherwise>
|
||||
AND 1 = 2
|
||||
</otherwise>
|
||||
</choose>
|
||||
</when>
|
||||
<when test="dto != null and dto.viewType == 'sharedToMe'">
|
||||
AND cg.share_enabled = 1
|
||||
@@ -116,6 +146,22 @@
|
||||
<include refid="custGroupVisibleBaseCondition"/>
|
||||
</select>
|
||||
|
||||
<select id="countHeadOperableCustGroup" resultType="java.lang.Long">
|
||||
SELECT COUNT(1)
|
||||
FROM ibs_cust_group cg
|
||||
WHERE cg.id = #{id}
|
||||
AND cg.del_flag = '0'
|
||||
AND EXISTS (
|
||||
SELECT 1
|
||||
FROM sys_user su
|
||||
LEFT JOIN sys_user_role sur ON su.user_id = sur.user_id
|
||||
LEFT JOIN sys_role sr ON sur.role_id = sr.role_id
|
||||
WHERE su.user_name = cg.user_name
|
||||
AND LEFT(CAST(cg.dept_id AS CHAR), 3) = #{headId}
|
||||
AND sr.role_key IN ('headAdmin', 'headPublic', 'headPrivate', 'headOps')
|
||||
)
|
||||
</select>
|
||||
|
||||
<select id="selectAllGroupTags" resultType="java.lang.String">
|
||||
SELECT DISTINCT group_tags
|
||||
FROM ibs_cust_group
|
||||
|
||||
@@ -24,6 +24,17 @@
|
||||
<where>
|
||||
cgm.group_id = #{groupId}
|
||||
AND cgm.del_flag = '0'
|
||||
<choose>
|
||||
<when test="dto != null and dto.userRole == 'branch'">
|
||||
AND cgm.branch_id = #{dto.currentDeptId}
|
||||
</when>
|
||||
<when test="dto != null and dto.userRole == 'outlet'">
|
||||
AND cgm.outlet_id = #{dto.currentDeptId}
|
||||
</when>
|
||||
<when test="dto != null and dto.userRole == 'manager'">
|
||||
AND cgm.user_name = #{dto.currentUserName}
|
||||
</when>
|
||||
</choose>
|
||||
<if test="dto != null and dto.custType != null and dto.custType != ''">
|
||||
AND cgm.cust_type = #{dto.custType}
|
||||
</if>
|
||||
|
||||
Reference in New Issue
Block a user