Преглед на файлове

企业组织机构删除接口关联企业用户

liangpeile преди 1 година
родител
ревизия
2ee4d7d84b
променени са 1 файла, в които са добавени 15 реда и са изтрити 8 реда
  1. 15 8
      crmeb-service/src/main/java/com/zbkj/service/service/impl/OrganizationServiceImpl.java

+ 15 - 8
crmeb-service/src/main/java/com/zbkj/service/service/impl/OrganizationServiceImpl.java

@@ -254,15 +254,22 @@ public class OrganizationServiceImpl extends ServiceImpl<OrganizationDao, Organi
         LambdaQueryWrapper<OrganizationDepartment> departmentLambdaQueryWrapper = new LambdaQueryWrapper<>();
         departmentLambdaQueryWrapper.eq(OrganizationDepartment::getOrganizationId,id);
         List<OrganizationDepartment> departmentList = organizationDeparementDao.selectList(departmentLambdaQueryWrapper);
-        for (OrganizationDepartment organizationDepartment : departmentList) {
-            strings.add(organizationDepartment.getId());
-        }
-        LambdaQueryWrapper<UserBypassAccount> accountLambdaQueryWrapper = new LambdaQueryWrapper<>();
-        accountLambdaQueryWrapper.in(UserBypassAccount::getDepartmentId,strings);
-        List<UserBypassAccount> userBypassAccounts = userBypassAccountService.list(accountLambdaQueryWrapper);
-        if (null != userBypassAccounts && userBypassAccounts.size() > 0){
-            return CommonResult.failed("该企业已关联企业子账户,请解除关联后进行删除");
+        if (null!=departmentList&&departmentList.size()>0){
+            for (OrganizationDepartment organizationDepartment : departmentList) {
+                strings.add(organizationDepartment.getId());
+
+            }
+       }
+        if (null!=strings&&strings.size()>0){
+            LambdaQueryWrapper<UserBypassAccount> accountLambdaQueryWrapper = new LambdaQueryWrapper<>();
+            accountLambdaQueryWrapper.in(UserBypassAccount::getDepartmentId,strings);
+            List<UserBypassAccount> userBypassAccounts = userBypassAccountService.list(accountLambdaQueryWrapper);
+            if (null != userBypassAccounts && userBypassAccounts.size() > 0){
+                return CommonResult.failed("该企业已关联企业子账户,请解除关联后进行删除");
+            }
         }
+        organizationDao.deleteById(id);
+
         return  CommonResult.success("操作成功");
 
     }