From 8c419abbacde06b4582d450f1fb55630a32e0fe1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A2=81=E7=90=A6=E6=B6=9B?= Date: Wed, 8 Mar 2023 10:28:49 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90fix=20sonar=E3=80=91SysBaseApiImpl?= =?UTF-8?q?=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../system/service/impl/SysBaseApiImpl.java | 50 ++++++++++--------- 1 file changed, 27 insertions(+), 23 deletions(-) diff --git a/jero-boot/jero-boot-module-system/src/main/java/com/jero/modules/system/service/impl/SysBaseApiImpl.java b/jero-boot/jero-boot-module-system/src/main/java/com/jero/modules/system/service/impl/SysBaseApiImpl.java index 88843c2a..6930c2c8 100644 --- a/jero-boot/jero-boot-module-system/src/main/java/com/jero/modules/system/service/impl/SysBaseApiImpl.java +++ b/jero-boot/jero-boot-module-system/src/main/java/com/jero/modules/system/service/impl/SysBaseApiImpl.java @@ -5,14 +5,9 @@ import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; -import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.google.common.base.Joiner; -import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang.StringUtils; -import org.apache.poi.ss.formula.functions.T; -import org.apache.shiro.SecurityUtils; import com.jero.common.api.dto.OnlineAuthDTO; import com.jero.common.api.dto.message.*; import com.jero.common.aspect.UrlMatchEnum; @@ -35,7 +30,10 @@ import com.jero.modules.system.entity.*; import com.jero.modules.system.mapper.*; import com.jero.modules.system.service.*; import com.jero.modules.system.util.SecurityUtil; -import org.checkerframework.checker.units.qual.K; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang.StringUtils; +import org.apache.shiro.SecurityUtils; +import org.jetbrains.annotations.NotNull; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.cache.annotation.Cacheable; @@ -128,7 +126,7 @@ public class SysBaseApiImpl implements ISysBaseAPI { @Override public List queryPermissionDataRule(String component, String requestPath, String username) { - List currentSyspermission = null; + List currentSyspermission; if(oConvertUtils.isNotEmpty(component)) { //1.通过注解属性pageComponent 获取菜单 LambdaQueryWrapper query = new LambdaQueryWrapper<>(); @@ -176,7 +174,7 @@ public class SysBaseApiImpl implements ISysBaseAPI { } return dataRules; } - return null; + return Collections.emptyList(); } /** @@ -477,7 +475,7 @@ public class SysBaseApiImpl implements ISysBaseAPI { if(announcement != null){ LoginUser sysUser = (LoginUser)SecurityUtils.getSubject().getPrincipal(); String userId = sysUser.getId(); - LambdaUpdateWrapper updateWrapper = new UpdateWrapper().lambda(); + LambdaUpdateWrapper updateWrapper = new LambdaUpdateWrapper<>(); updateWrapper.set(SysAnnouncementSend::getReadFlag, CommonConstant.HAS_READ_FLAG); updateWrapper.set(SysAnnouncementSend::getReadTime, new Date()); updateWrapper.last("where annt_id ='"+announcement.getId()+"' and user_id ='"+userId+"'"); @@ -743,19 +741,7 @@ public class SysBaseApiImpl implements ISysBaseAPI { List userDepartList = sysUserDepartService.list(new QueryWrapper().eq("user_id",userId)); if(userDepartList != null){ //查找所属公司 - String orgCodes = ""; - for(SysUserDepart userDepart : userDepartList){ - //查询所属公司编码 - SysDepart depart = sysDepartService.getById(userDepart.getDepId()); - int length = YouBianCodeUtil.ZHANWEI_LENGTH; - String compyOrgCode = ""; - if(depart != null && depart.getOrgCode() != null){ - compyOrgCode = depart.getOrgCode().substring(0,length); - if(orgCodes.indexOf(compyOrgCode) == -1){ - orgCodes = orgCodes + "," + compyOrgCode; - } - } - } + String orgCodes = getOrgCodes(userDepartList); if(oConvertUtils.isNotEmpty(orgCodes)){ orgCodes = orgCodes.substring(1); List listIds = departMapper.getSubDepIdsByOrgCodes(orgCodes.split(",")); @@ -770,6 +756,24 @@ public class SysBaseApiImpl implements ISysBaseAPI { return userIds; } + @NotNull + private String getOrgCodes(List userDepartList) { + String orgCodes = ""; + for(SysUserDepart userDepart : userDepartList){ + //查询所属公司编码 + SysDepart depart = sysDepartService.getById(userDepart.getDepId()); + int length = YouBianCodeUtil.ZHANWEI_LENGTH; + String compyOrgCode = ""; + if(depart != null && depart.getOrgCode() != null){ + compyOrgCode = depart.getOrgCode().substring(0,length); + if(!orgCodes.contains(compyOrgCode)){ + orgCodes = orgCodes + "," + compyOrgCode; + } + } + } + return orgCodes; + } + /** * 查询用户拥有的角色集合 * @param username @@ -1067,7 +1071,7 @@ public class SysBaseApiImpl implements ISysBaseAPI { } return list; } - return null; + return Collections.emptyList(); } /** * 查询分类字典翻译