1、新增组织管理员删除限制;2、组织管理分页全称查询失败恢复;3、组织手机号验证放宽到校验未删除的组织;

This commit is contained in:
gaoqr
2026-05-09 16:23:38 +08:00
parent 9b87a914d1
commit 658685d029
10 changed files with 46 additions and 13 deletions
@@ -8,6 +8,8 @@ import com.cf.imes.framework.common.exception.ErrorCode;
* system 系统,使用 1-002-000-000 段
*/
public class ErrorCodeConstants {
private ErrorCodeConstants() {
}
// ========== AUTH 模块 1-002-000-000 ==========
public static final ErrorCode AUTH_LOGIN_BAD_CREDENTIALS = new ErrorCode(1_002_000_000, "auth.login.bad_credentials");
@@ -55,6 +57,7 @@ public class ErrorCodeConstants {
public static final ErrorCode USERNAME_MULTIPLE_ERROR = new ErrorCode(1_002_003_011, "user.username.multiple_error");
public static final ErrorCode USER_OPERATE_SELF_STATUS_ERROR = new ErrorCode(1_002_003_012, "user.operate_self_status_error");
public static final ErrorCode USER_MOBILE_UPDATE_NOT_ALLOW_ERROR = new ErrorCode(1_002_003_013, "user.mobile_update_not_allow");
public static final ErrorCode ORGAN_ADMIN_USER_DELETE_NOT_ALLOW = new ErrorCode(1_002_003_014, "user.organ_admin_user.delete_not_allow");
// ========== 部门模块 1-002-004-000 ==========
public static final ErrorCode DEPT_NAME_DUPLICATE = new ErrorCode(1_002_004_000, "dept.name.duplicate");
@@ -24,6 +24,10 @@ public class OrganPageReqVO extends PageParam {
@Size(max = 30, message = "联系人长度不能超过30个字符")
private String contactName;
@Schema(description = "组织名", example = "晨丰")
@Size(max = 30, message = "组织名长度不能超过30个字符")
private String exactName;
@Schema(description = "联系手机", example = "15601691300")
@Mobile
@Size(max = 11, message = "联系手机长度不能超过11个字符")
@@ -42,6 +42,7 @@ public interface OrganMapper extends BaseMapperX<OrganizationDO> {
.likeIfPresent(OrganizationDO::getContactName, reqVO.getContactName())
.likeIfPresent(OrganizationDO::getContactMobile, reqVO.getContactMobile())
.eqIfPresent(OrganizationDO::getStatus, reqVO.getStatus())
.eqIfPresent(OrganizationDO::getName, reqVO.getExactName())
.eqIfPresent(OrganizationDO::getProvince, reqVO.getProvince())
.eqIfPresent(OrganizationDO::getCity, reqVO.getCity())
.eqIfPresent(OrganizationDO::getCounty, reqVO.getCounty())
@@ -180,4 +180,12 @@ public interface OrganService {
* @param contactName
*/
void syncUserToOrgAdmin(Long id, String contactMobile, String contactName);
/**
* 获取组织管理员用户id
*
* @param id 组织id
* @return
*/
Long getOrganAdmin(Long id);
}
@@ -305,9 +305,7 @@ public class OrganServiceImpl implements OrganService {
// 同步更新 token 管理的 token
List<TokenConfigDO> tokenConfigDOS = tokenConfigMapper.selectConfigByOrganId(organId);
if (CollUtil.isNotEmpty(tokenConfigDOS)) {
tokenConfigDOS.forEach(f -> {
f.setAppToken(generateBaseToken(organId, currentOrgAdminMobile, f.getAppType(), jwtProperties.getSecret()));
});
tokenConfigDOS.forEach(f -> f.setAppToken(generateBaseToken(organId, currentOrgAdminMobile, f.getAppType(), jwtProperties.getSecret())));
tokenConfigMapper.updateBatch(tokenConfigDOS);
}
mobileChange = currentOrgAdminMobile;
@@ -544,8 +542,6 @@ public class OrganServiceImpl implements OrganService {
OrganizationDO tenant = getOrgan(OrganContextHolder.getRequiredOrganId());
Set<Long> menuIds;
//menuIds = tenantPackageService.getTenantPackage(tenant.getPackageId()).getMenuIds();
if (isSystemTenant(tenant) || (SecurityFrameworkUtils.isCfOrg() && SecurityFrameworkUtils.isManageEndPoint())) { // 系统组织,菜单是全量的
menuIds = CollectionUtils.convertSet(menuService.getMenuList(), MenuDO::getId);
} else {
@@ -749,7 +745,7 @@ public class OrganServiceImpl implements OrganService {
List<String> machineIds = processSchemeConfigs.stream().map(ProcessSchemeConfig::getAnalyzer).distinct().toList();
List<MachineDO> machineDOS = machineMapper.selectBatchIds(machineIds);
List<MachineDO> machineDOS = machineMapper.selectByIds(machineIds);
if(CollUtil.isNotEmpty(machineDOS)){
machineDOS.forEach(f->{
f.setId(null);
@@ -762,7 +758,7 @@ public class OrganServiceImpl implements OrganService {
List<Long> labelIds = machineDOS.stream().map(MachineDO::getLabelId).distinct().toList();
List<LabelDO> labelDOS = labelMapper.selectBatchIds(labelIds);
List<LabelDO> labelDOS = labelMapper.selectByIds(labelIds);
if(CollUtil.isNotEmpty(labelDOS)){
labelDOS.forEach(f->{
f.setId(null);
@@ -851,4 +847,10 @@ public class OrganServiceImpl implements OrganService {
.eq(OrganizationDO::getId, id)
);
}
@Override
public Long getOrganAdmin(Long id) {
OrganizationDO organizationDO = validOrgan(id);
return organizationDO.getContactUserId();
}
}
@@ -389,7 +389,9 @@ public class AdminUserServiceImpl implements AdminUserService {
// 不允许自身操作
checkCurrentWhenOperate(id);
// 校验用户存在
validateUserExists(id);
AdminUserDO adminUserDO = validateUserExists(id);
// 不允许删除组织管理员
validateOrgAdmin(id, adminUserDO.getOrganId());
// 物理删除用户
int deleteNum = userMapper.physicalDeleteById(id);
if (deleteNum > 0) {
@@ -496,7 +498,7 @@ public class AdminUserServiceImpl implements AdminUserService {
if (CollUtil.isEmpty(ids)) {
return Collections.emptyList();
}
return userMapper.selectBatchIds(ids);
return userMapper.selectByIds(ids);
}
@Override
@@ -505,7 +507,7 @@ public class AdminUserServiceImpl implements AdminUserService {
return;
}
// 获得用户信息
List<AdminUserDO> users = userMapper.selectBatchIds(ids);
List<AdminUserDO> users = userMapper.selectByIds(ids);
Map<Long, AdminUserDO> userMap = CollectionUtils.convertMap(users, AdminUserDO::getId);
// 校验
ids.forEach(id -> {
@@ -598,6 +600,18 @@ public class AdminUserServiceImpl implements AdminUserService {
return user;
}
/**
* 校验不允许删除组织管理员
*
* @param id
*/
void validateOrgAdmin(Long id, Long userOrgId) {
Long organAdminId = organService.getOrganAdmin(userOrgId);
if (ObjectUtil.equals(id, organAdminId)) {
throw new ServiceException(ORGAN_ADMIN_USER_DELETE_NOT_ALLOW);
}
}
@VisibleForTesting
private AdminUserDO validateUserNameExists(String userName) {
AdminUserDO user = userMapper.selectByUsernameUnique(userName);
@@ -85,6 +85,7 @@
<if test="organId !=null ">
and id != #{organId}
</if>
and deleted = false
</select>
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long