Commit 39dacefc by 李小龙

fixbug:28990 平台端:组织管理,组织被禁用后,组织关联的账号和下级组织关联的账号,应该控制无法登录

parent 00c9b8d8
......@@ -29,6 +29,7 @@ public enum CodeMessageEnum {
SYSTEM_ERROR_NAME_DUPLICATE(500, "SYSTEM.ERROR.NAME.DUPLICATE"),
SYSTEM_ERROR_NAME_ENG_DUPLICATE(500, "SYSTEM.ERROR.NAME.ENG.DUPLICATE"),
SYSTEM_ERROR_CODE_DUPLICATE(500, "SYSTEM.ERROR.CODE.DUPLICATE"),
SYSTEM_ERROR_TENANT_CODE_DUPLICATE(500, "SYSTEM.ERROR.TENANT.CODE.DUPLICATE"),
SYSTEM_ERROR_DICT_VALUE_DUPLICATE(500, "SYSTEM.ERROR.DICT.VALUE.DUPLICATE"),
SYSTEM_ERROR_DICT_NOT_EXIST(500, "SYSTEM.ERROR.DICT.NOT.EXIST"),
......@@ -110,6 +111,8 @@ public enum CodeMessageEnum {
SYSTEM_ERROR_TENANT_NOT_EXIST(510, "SYSTEM.ERROR.TENANT.NOT.EXIST"),
SYSTEM_ERROR_ROLE_ADMIN_CANT_ADD(500, "SYSTEM.ERROR.ROLE.ADMIN.CANT.ADD"),
SYSTEM_ERROR_ROLE_ADMIN_CANT_EDIT(500, "SYSTEM.ERROR.ROLE.ADMIN.CANT.EDIT"),
SYSTEM_ERROR_TENANT_FORBIDDEN(500, "SYSTEM.ERROR.TENANT.FORBIDDEN"),
SYSTEM_ERROR_ORG_FORBIDDEN(500, "SYSTEM.ERROR.ORG.FORBIDDEN"),
PLATFORM_ERROR_ALARM_NOT_FOUND_SPACE(500,"PLATFORM.ERROR.ALARM.NOT.FOUND.SPACE"),
......
......@@ -54,4 +54,10 @@ public class PlatTenantDTOVO extends BaseIdDTO {
@ApiModelProperty(value = "菜单id集合")
private List<String> menuIdList;
@ApiModelProperty(value = "租户标识")
private String code;
@ApiModelProperty(value = "租户平台地址")
private String url;
}
......@@ -26,6 +26,9 @@ public class PlatUserQueryDTO extends BaseOrgDTO {
@ApiModelProperty(value = "状态 0禁用 1启用")
private String status;
@ApiModelProperty(value = "邮箱")
private String email;
@ApiModelProperty(value = "角色id roleId和notRoleId只能用一个")
private String roleId;
......
......@@ -19,6 +19,7 @@ SYSTEM.ERROR.NAME.DUPLICATE=该名称已存在
SYSTEM.ERROR.NAME.ENG.DUPLICATE=该英文名称已存在
SYSTEM.ERROR.CODE.DUPLICATE=该编码已存在
SYSTEM.ERROR.TENANT.CODE.DUPLICATE=该标识已存在
SYSTEM.ERROR.DICT.VALUE.DUPLICATE=该字典值已存在
SYSTEM.ERROR.DICT.NOT.EXIST=该字典值不存在
......@@ -108,3 +109,7 @@ SYSTEM.ERROR.ROLE.ADMIN.CANT.EDIT=管理员角色不能修改
PLATFORM.ERROR.ALARM.NOT.FOUND.SPACE=设备未绑定空间
PLATFORM.ERROR.ALARM.NOT.FOUND.ELDER=设备空间下无长者
SYSTEM.ERROR.TENANT.FORBIDDEN=该租户被禁用
SYSTEM.ERROR.ORG.FORBIDDEN=该组织被禁用
......@@ -15,4 +15,6 @@ public class PlatUserRoleDTO extends BaseTenantDTO implements Serializable {
@ApiModelProperty(value = "角色id")
private String roleId;
private String roleName;
}
......@@ -54,5 +54,15 @@ public class PlatTenant extends BaseEntity {
*/
private String iotOrgId;
/**
* 租户标识
*/
private String code;
/**
* 租户平台地址
*/
private String url;
}
\ No newline at end of file
......@@ -2,8 +2,11 @@ package com.makeit.mapper.platform.auth;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.makeit.dto.platform.auth.PlatUserRoleDTO;
import com.makeit.entity.platform.auth.PlatUserRole;
import java.util.List;
/**
* @author lixl
* @description 针对表【plat_user_role(租户端用户角色关联表)】的数据库操作Mapper
......@@ -13,4 +16,5 @@ import com.makeit.entity.platform.auth.PlatUserRole;
public interface PlatUserRoleMapper extends BaseMapper<PlatUserRole> {
List<PlatUserRoleDTO> getByUserIdList(List<String> userIdList);
}
......@@ -2,6 +2,7 @@ package com.makeit.service.platform.auth;
import com.baomidou.mybatisplus.extension.service.IService;
import com.makeit.dto.platform.auth.PlatUserRoleDTO;
import com.makeit.entity.platform.auth.PlatUserRole;
import java.util.List;
......@@ -19,4 +20,7 @@ public interface PlatUserRoleService extends IService<PlatUserRole> {
* @return
*/
List<PlatUserRole> getByUserId(String userId);
List<PlatUserRoleDTO> getByUserIdList(List<String> userIdList);
}
......@@ -125,4 +125,6 @@ public interface PlatUserService extends IService<PlatUser> {
void delBatch(List<String> idList);
ExcelImportVo importExcel(MultipartFile excelFile) throws Exception;
void checkTenantOrgStatus(PlatUser platUser);
}
......@@ -13,6 +13,7 @@ import com.makeit.entity.platform.auth.PlatOrg;
import com.makeit.entity.platform.auth.PlatRole;
import com.makeit.entity.platform.auth.PlatRoleOrg;
import com.makeit.entity.platform.auth.PlatUserRole;
import com.makeit.enums.CodeMessageEnum;
import com.makeit.enums.CommonEnum;
import com.makeit.enums.id.TreeConst;
import com.makeit.exception.BusinessException;
......@@ -287,10 +288,10 @@ public class PlatOrgServiceImpl extends ServiceImpl<PlatOrgMapper, PlatOrg>
private void check(PlatOrg dto) {
LambdaQueryWrapper<PlatOrg> platOrgLambdaQueryWrapper = new LambdaQueryWrapper<>();
platOrgLambdaQueryWrapper.eq(PlatOrg::getParentId, dto.getParentId())
.eq(StringUtils.isNotBlank(dto.getId()),PlatOrg::getName, dto.getName())
.eq(PlatOrg::getName, dto);
.ne(StringUtils.isNotBlank(dto.getId()),PlatOrg::getId, dto.getId())
.eq(PlatOrg::getName, dto.getName());
if(count(platOrgLambdaQueryWrapper)>0){
throw new BusinessException("名称重复");
throw new BusinessException(CodeMessageEnum.SYSTEM_ERROR_NAME_DUPLICATE);
}
}
......
......@@ -2,6 +2,7 @@ package com.makeit.service.platform.auth.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.makeit.dto.platform.auth.PlatUserRoleDTO;
import com.makeit.entity.platform.auth.PlatUserRole;
import com.makeit.mapper.platform.auth.PlatUserRoleMapper;
import com.makeit.service.platform.auth.PlatRoleOrgService;
......@@ -36,5 +37,9 @@ implements PlatUserRoleService{
return list(queryWrapper);
}
@Override
public List<PlatUserRoleDTO> getByUserIdList(List<String> userIdList) {
return baseMapper.getByUserIdList(userIdList);
}
}
......@@ -7,6 +7,7 @@ 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.fasterxml.jackson.core.type.TypeReference;
import com.makeit.common.dto.BaseIdDTO;
import com.makeit.common.dto.LoginDTO;
import com.makeit.common.dto.StatusDTO;
import com.makeit.common.entity.BaseBusEntity;
......@@ -16,6 +17,7 @@ import com.makeit.common.page.PageVO;
import com.makeit.common.vo.ExcelErrorVo;
import com.makeit.common.vo.ExcelImportVo;
import com.makeit.dto.platform.auth.PlatUserImportDTO;
import com.makeit.dto.platform.auth.PlatUserRoleDTO;
import com.makeit.entity.platform.auth.PlatOrg;
import com.makeit.entity.platform.auth.PlatRole;
import com.makeit.entity.platform.auth.PlatRoleMenu;
......@@ -370,6 +372,9 @@ public class PlatUserServiceImpl extends ServiceImpl<PlatUserMapper, PlatUser>
.or()
.eq(PlatUser::getMobile, loginDTO.getAccount())
);
checkTenantOrgStatus(platUser);
//这样在所有租户内工号不能重复
if (platUser == null) {
......@@ -399,6 +404,17 @@ public class PlatUserServiceImpl extends ServiceImpl<PlatUserMapper, PlatUser>
return userLoginVO;
}
public void checkTenantOrgStatus(PlatUser platUser) {
PlatTenant platTenant = platTenantService.getById(platUser.getTenantId());
if(platTenant == null || StringUtils.equals(platTenant.getStatus(),CommonEnum.NO.getValue())){
throw new BusinessException(CodeMessageEnum.SYSTEM_ERROR_TENANT_FORBIDDEN);
}
PlatOrg platOrg = platOrgService.getById(platUser.getOrgId());
if(platOrg == null || StringUtils.equals(platOrg.getStatus(),CommonEnum.NO.getValue())){
throw new BusinessException(CodeMessageEnum.SYSTEM_ERROR_ORG_FORBIDDEN);
}
}
/**
* 校验组织
*
......@@ -646,6 +662,7 @@ public class PlatUserServiceImpl extends ServiceImpl<PlatUserMapper, PlatUser>
.in(CollectionUtils.isNotEmpty(dto.getNameList()), PlatUser::getUsername, dto.getUsername())
.like(StringUtils.isNotBlank(dto.getMobile()), PlatUser::getMobile, dto.getMobile())
.eq(StringUtils.isNotBlank(dto.getStatus()), PlatUser::getStatus, dto.getStatus())
.like(StringUtils.isNotBlank(dto.getEmail()),PlatUser::getEmail,dto.getEmail())
.eq(PlatUser::getTenantId, TenantIdUtil.getTenantId());
roleIdFilter(lambdaQueryWrapper, dto);
......@@ -679,10 +696,30 @@ public class PlatUserServiceImpl extends ServiceImpl<PlatUserMapper, PlatUser>
List<PlatPersonDTOVO> tntUserDTOVOList = BeanDtoVoUtils.listVo(pageList.getRecords(), PlatPersonDTOVO.class);
fillDept(tntUserDTOVOList);
fillRole(tntUserDTOVOList);
return PageUtil.toPageVO(tntUserDTOVOList, pageList);
}
private void fillRole(List<PlatPersonDTOVO> tntUserDTOVOList) {
if(CollectionUtils.isEmpty(tntUserDTOVOList)){
return;
}
List<String> userIdList = tntUserDTOVOList.stream().map(BaseIdDTO::getId).collect(Collectors.toList());
List<PlatUserRoleDTO> userRoleDTOList = platUserRoleService.getByUserIdList(userIdList);
Map<String, List<PlatUserRoleDTO>> userRoleMap = userRoleDTOList.stream().collect(Collectors.groupingBy(PlatUserRoleDTO::getUserId));
for (PlatPersonDTOVO platPersonDTOVO : tntUserDTOVOList) {
List<PlatUserRoleDTO> platUserRoleDTOS = userRoleMap.get(platPersonDTOVO.getId());
if(CollectionUtils.isEmpty(platUserRoleDTOS)){
continue;
}
String roleNameJoin = platUserRoleDTOS.stream().map(PlatUserRoleDTO::getRoleName).collect(Collectors.joining(","));
platPersonDTOVO.setRoleNameJoin(roleNameJoin);
}
}
@Override
public List<PlatPersonDTOVO> list(PlatUserQueryDTO dto) {
List<PlatPersonDTOVO> tntUserList = BeanDtoVoUtils.listVo(list(listLambdaQueryWrapper(dto)), PlatPersonDTOVO.class);
......
......@@ -202,6 +202,7 @@ implements PlatTenantService {
public String add(PlatTenantDTOVO dto) {
checkName(dto);
checkDate(dto);
checkCode(dto);
PlatTenant tntTenant = BeanDtoVoUtils.convert(dto, PlatTenant.class);
//新租户同步到iot
......@@ -227,12 +228,14 @@ implements PlatTenantService {
return tntTenant.getId();
}
@Transactional
@Override
@TenantIdIgnore
public void edit(PlatTenantDTOVO dto) {
checkName(dto);
checkDate(dto);
checkCode(dto);
PlatTenant tntTenant = BeanDtoVoUtils.convert(dto, PlatTenant.class);
PlatTenant platTenant = getById(tntTenant.getId());
//更新同步到iot
......@@ -376,4 +379,17 @@ implements PlatTenantService {
}
}
private void checkCode(PlatTenantDTOVO dto) {
PlatTenant tntTenant = getOne(
new QueryWrapper<PlatTenant>().lambda()
.eq(PlatTenant::getCode, dto.getCode())
.ne(StringUtils.isNotBlank(dto.getId()),PlatTenant::getCode,dto.getCode())
);
if (tntTenant != null && !tntTenant.getId().equals(dto.getId())) {
throw new BusinessException(CodeMessageEnum.SYSTEM_ERROR_TENANT_CODE_DUPLICATE);
}
}
}
......@@ -163,8 +163,8 @@ implements SaasUserService{
new QueryWrapper<SaasUser>().lambda()
.eq(SaasUser::getAccount, dto.getAccount())
.or()
.eq(SaasUser::getUsername, dto.getUsername())
.or()
//.eq(SaasUser::getUsername, dto.getUsername())
//.or()
.eq(SaasUser::getMobile, dto.getMobile())
);
......
......@@ -74,6 +74,10 @@ public class IotSyncTask {
Set<String> iotDeviceIdSet = iotDeviceList.stream().map(DeviceInstanceEntity::getId).collect(Collectors.toSet());
LambdaQueryWrapper<PlatDevice> deviceLambdaQueryWrapper = new LambdaQueryWrapper<PlatDevice>().eq(BaseBusEntity::getTenantId, platTenant.getId())
.in(PlatDevice::getOriDeviceId, iotDeviceIdSet);
//删除设备
LambdaQueryWrapper<PlatDevice> removeQw = new LambdaQueryWrapper<PlatDevice>().notIn(PlatDevice::getOriDeviceId, iotDeviceIdSet)
.eq(BaseBusEntity::getTenantId, platTenant.getId());
platDeviceService.remove(removeQw);
List<PlatDevice> deviceList = platDeviceService.list(deviceLambdaQueryWrapper);
//更新平台设备
Collection<PlatDevice> platDevices = convertToPlatDevice(iotDeviceList, deviceList, platTenant.getId(), dicNameIdMap);
......
......@@ -89,4 +89,9 @@ public class PlatPersonDTOVO extends BaseIdDTO {
@ApiModelProperty(value = "更新人名称")
private String updateBy;
@ApiModelProperty(value = "角色名称,逗号拼接")
private String roleNameJoin;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment