From c939fbe59b236497673d0f6313e85882b6568a63 Mon Sep 17 00:00:00 2001 From: xiaofajia <1665375861@qq.com> Date: Thu, 31 Oct 2024 10:53:00 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=91=98=E5=B7=A5=E8=A7=92?= =?UTF-8?q?=E8=89=B2=E6=9D=83=E9=99=90=E9=9D=9E=E7=A9=BA=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/CompanyStaffServiceImpl.java | 45 ++++++++++--------- 1 file changed, 25 insertions(+), 20 deletions(-) diff --git a/dl-module-company/src/main/java/cn/iocoder/yudao/module/staff/service/impl/CompanyStaffServiceImpl.java b/dl-module-company/src/main/java/cn/iocoder/yudao/module/staff/service/impl/CompanyStaffServiceImpl.java index dc1ddcb8..b5b1cd61 100644 --- a/dl-module-company/src/main/java/cn/iocoder/yudao/module/staff/service/impl/CompanyStaffServiceImpl.java +++ b/dl-module-company/src/main/java/cn/iocoder/yudao/module/staff/service/impl/CompanyStaffServiceImpl.java @@ -1,6 +1,7 @@ package cn.iocoder.yudao.module.staff.service.impl; import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.util.ObjectUtil; import cn.iocoder.yudao.common.BaseConstants; import cn.iocoder.yudao.common.CommonErrorCodeConstants; @@ -125,7 +126,7 @@ public class CompanyStaffServiceImpl extends ServiceImpl roleIds = staffRespVO.getRoleIds().stream().collect(Collectors.toSet()); - permissionApi.assignUserRoleByRoleIds(userId, roleIds); + // 非空判断 + if (CollectionUtil.isNotEmpty(roleIds)) { + permissionApi.assignUserRoleByRoleIds(userId, roleIds); + } /* 插入标签到业务标签表 */ if (ObjectUtil.isNotEmpty(staffRespVO.getLabelsArray())) { @@ -235,10 +239,10 @@ public class CompanyStaffServiceImpl extends ServiceImpl roleIdes = staffRespVO.getRoleIds().stream().collect(Collectors.toSet()); permissionApi.assignUserRoleByRoleIds(staffRespVO.getUserId(), roleIdes); - }else { + } else { permissionApi.assignUserRoleByRoleIds(staffRespVO.getUserId(), null); } @@ -279,16 +283,17 @@ public class CompanyStaffServiceImpl extends ServiceImpl queryWrapper =new LambdaQueryWrapper<>(); - queryWrapper.eq(CompanyStaff::getUserId,userId).last("limit 1"); + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(CompanyStaff::getUserId, userId).last("limit 1"); CompanyStaff staff = baseMapper.selectOne(queryWrapper); /* 验证是否已交接工作 */ Boolean flag = staffChangeService.checkChangeStatus(staff.getUserId()); @@ -416,9 +421,9 @@ public class CompanyStaffServiceImpl extends ServiceImpl getStaffList(String query) { - if (ObjectUtil.isNotEmpty(query)){ + if (ObjectUtil.isNotEmpty(query)) { return baseMapper.selectList(new LambdaQueryWrapper() - .like(CompanyStaff::getName,query) + .like(CompanyStaff::getName, query) .or() .like(CompanyStaff::getTel, query) ); @@ -532,9 +537,9 @@ public class CompanyStaffServiceImpl extends ServiceImpl queryWrapper = new LambdaQueryWrapper() - .eq(CompanyStaff::getUniqueCode,uniqueCode); + .eq(CompanyStaff::getUniqueCode, uniqueCode); List staffList = this.list(queryWrapper); - if(!staffList.isEmpty()){ + if (!staffList.isEmpty()) { //员工推广 CompanyStaff staff = staffList.get(0); //查该客户是否已被该租户的员工推广过 @@ -556,7 +561,7 @@ public class CompanyStaffServiceImpl extends ServiceImpl { thisCus[0] = customerMainService.getCustomerByUserId(user.getId()); }); - if(null==thisCus[0]){ + if (null == thisCus[0]) { // 插入推广记录 BasePromotion basePromotion = new BasePromotion(); basePromotion.setOldUserId(staff.getUserId()); @@ -568,9 +573,9 @@ public class CompanyStaffServiceImpl extends ServiceImpl queryWrapper = new LambdaQueryWrapper() .isNull(CompanyStaff::getUniqueCode); List list = this.list(queryWrapper); - if(!list.isEmpty()){ - for (CompanyStaff staff:list){ + if (!list.isEmpty()) { + for (CompanyStaff staff : list) { try { // 2 生成唯一推广码 String uniqueCode = uniqueCodeService.createUniqueCode(); @@ -597,7 +602,7 @@ public class CompanyStaffServiceImpl extends ServiceImpl