diff --git a/continew-admin-common/src/main/java/top/charles7c/cnadmin/common/base/BaseServiceImpl.java b/continew-admin-common/src/main/java/top/charles7c/cnadmin/common/base/BaseServiceImpl.java index 8244af02..55047e72 100644 --- a/continew-admin-common/src/main/java/top/charles7c/cnadmin/common/base/BaseServiceImpl.java +++ b/continew-admin-common/src/main/java/top/charles7c/cnadmin/common/base/BaseServiceImpl.java @@ -151,7 +151,7 @@ public abstract class BaseServiceImpl, T extends BaseDO, // 设置排序 Sort sort = Opt.ofNullable(sortQuery).orElseGet(SortQuery::new).getSort(); for (Sort.Order order : sort) { - queryWrapper.orderBy(order != null, order.isAscending(), StrUtil.toUnderlineCase(order.getProperty())); + queryWrapper.orderBy(null != order, order.isAscending(), StrUtil.toUnderlineCase(order.getProperty())); } List entityList = baseMapper.selectList(queryWrapper); return BeanUtil.copyToList(entityList, targetClass); @@ -168,7 +168,7 @@ public abstract class BaseServiceImpl, T extends BaseDO, @Override @Transactional(rollbackFor = Exception.class) public Long add(C request) { - if (request == null) { + if (null == request) { return 0L; } T entity = BeanUtil.copyProperties(request, entityClass); @@ -220,7 +220,7 @@ public abstract class BaseServiceImpl, T extends BaseDO, if (baseObj instanceof BaseVO) { BaseVO baseVO = (BaseVO)baseObj; Long createUser = baseVO.getCreateUser(); - if (createUser == null) { + if (null == createUser) { return; } CommonUserService userService = SpringUtil.getBean(CommonUserService.class); @@ -240,7 +240,7 @@ public abstract class BaseServiceImpl, T extends BaseDO, this.fill(detailVO); Long updateUser = detailVO.getUpdateUser(); - if (updateUser == null) { + if (null == updateUser) { return; } CommonUserService userService = SpringUtil.getBean(CommonUserService.class); diff --git a/continew-admin-common/src/main/java/top/charles7c/cnadmin/common/config/SwaggerConfiguration.java b/continew-admin-common/src/main/java/top/charles7c/cnadmin/common/config/SwaggerConfiguration.java index 746c7210..f340ffb2 100644 --- a/continew-admin-common/src/main/java/top/charles7c/cnadmin/common/config/SwaggerConfiguration.java +++ b/continew-admin-common/src/main/java/top/charles7c/cnadmin/common/config/SwaggerConfiguration.java @@ -63,7 +63,7 @@ public class SwaggerConfiguration { @Bean public GlobalOpenApiCustomizer orderGlobalOpenApiCustomizer() { return openApi -> { - if (openApi.getTags() != null) { + if (null != openApi.getTags()) { openApi.getTags() .forEach(tag -> tag.setExtensions(MapUtil.of("x-order", RandomUtil.randomInt(0, 100)))); } diff --git a/continew-admin-common/src/main/java/top/charles7c/cnadmin/common/config/easyexcel/ExcelBaseEnumConverter.java b/continew-admin-common/src/main/java/top/charles7c/cnadmin/common/config/easyexcel/ExcelBaseEnumConverter.java index 103b2c8a..e000622b 100644 --- a/continew-admin-common/src/main/java/top/charles7c/cnadmin/common/config/easyexcel/ExcelBaseEnumConverter.java +++ b/continew-admin-common/src/main/java/top/charles7c/cnadmin/common/config/easyexcel/ExcelBaseEnumConverter.java @@ -25,7 +25,6 @@ import com.alibaba.excel.metadata.property.ExcelContentProperty; import cn.hutool.core.convert.Convert; import cn.hutool.core.util.ClassUtil; -import cn.hutool.core.util.ObjectUtil; import top.charles7c.cnadmin.common.base.BaseEnum; import top.charles7c.cnadmin.common.constant.StringConsts; @@ -63,7 +62,7 @@ public class ExcelBaseEnumConverter implements Converter convertToExcelData(BaseEnum value, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) { - if (ObjectUtil.isNull(value)) { + if (null == value) { return new WriteCellData<>(StringConsts.EMPTY); } return new WriteCellData<>(value.getDescription()); diff --git a/continew-admin-common/src/main/java/top/charles7c/cnadmin/common/config/easyexcel/ExcelBigNumberConverter.java b/continew-admin-common/src/main/java/top/charles7c/cnadmin/common/config/easyexcel/ExcelBigNumberConverter.java index 6d63c1b3..eb6b95b3 100644 --- a/continew-admin-common/src/main/java/top/charles7c/cnadmin/common/config/easyexcel/ExcelBigNumberConverter.java +++ b/continew-admin-common/src/main/java/top/charles7c/cnadmin/common/config/easyexcel/ExcelBigNumberConverter.java @@ -26,7 +26,6 @@ import com.alibaba.excel.metadata.data.WriteCellData; import com.alibaba.excel.metadata.property.ExcelContentProperty; import cn.hutool.core.convert.Convert; -import cn.hutool.core.util.ObjectUtil; /** * Easy Excel 大数值转换器(Excel 中对长度超过 15 位的数值输入是有限制的,从 16 位开始无论录入什么数字均会变为 0,因此输入时只能以文本的形式进行录入) @@ -66,7 +65,7 @@ public class ExcelBigNumberConverter implements Converter { @Override public WriteCellData convertToExcelData(Long value, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) { - if (ObjectUtil.isNotNull(value)) { + if (null != value) { String str = Long.toString(value); if (str.length() > MAX_LENGTH) { return new WriteCellData<>(str); diff --git a/continew-admin-common/src/main/java/top/charles7c/cnadmin/common/config/jackson/SimpleDeserializersWrapper.java b/continew-admin-common/src/main/java/top/charles7c/cnadmin/common/config/jackson/SimpleDeserializersWrapper.java index 0d9cce92..20d36174 100644 --- a/continew-admin-common/src/main/java/top/charles7c/cnadmin/common/config/jackson/SimpleDeserializersWrapper.java +++ b/continew-admin-common/src/main/java/top/charles7c/cnadmin/common/config/jackson/SimpleDeserializersWrapper.java @@ -52,14 +52,14 @@ public class SimpleDeserializersWrapper extends SimpleDeserializers { public JsonDeserializer findEnumDeserializer(Class type, DeserializationConfig config, BeanDescription beanDesc) throws JsonMappingException { JsonDeserializer deser = super.findEnumDeserializer(type, config, beanDesc); - if (deser != null) { + if (null != deser) { return deser; } // 重写增强:开始查找指定枚举类型的接口的反序列化器(例如:GenderEnum 枚举类型,则是找它的接口 BaseEnum 的反序列化器) for (Class typeInterface : type.getInterfaces()) { deser = this._classMappings.get(new ClassKey(typeInterface)); - if (deser != null) { + if (null != deser) { return deser; } } diff --git a/continew-admin-common/src/main/java/top/charles7c/cnadmin/common/config/mybatis/DataPermissionHandlerImpl.java b/continew-admin-common/src/main/java/top/charles7c/cnadmin/common/config/mybatis/DataPermissionHandlerImpl.java index 658a72f7..25a5808a 100644 --- a/continew-admin-common/src/main/java/top/charles7c/cnadmin/common/config/mybatis/DataPermissionHandlerImpl.java +++ b/continew-admin-common/src/main/java/top/charles7c/cnadmin/common/config/mybatis/DataPermissionHandlerImpl.java @@ -21,7 +21,6 @@ import java.util.Collections; import lombok.extern.slf4j.Slf4j; -import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; import com.baomidou.mybatisplus.core.toolkit.StringUtils; import com.baomidou.mybatisplus.extension.plugins.handler.DataPermissionHandler; @@ -80,13 +79,13 @@ public class DataPermissionHandlerImpl implements DataPermissionHandler { String methodName = mappedStatementId.substring(mappedStatementId.lastIndexOf(StringConsts.DOT) + 1); Method[] methods = clazz.getDeclaredMethods(); for (Method method : methods) { - DataPermission annotation = method.getAnnotation(DataPermission.class); - if (ObjectUtils.isNotEmpty(annotation) + DataPermission dataPermission = method.getAnnotation(DataPermission.class); + if (null != dataPermission && (method.getName().equals(methodName) || (method.getName() + "_COUNT").equals(methodName))) { // 获取当前登录用户 LoginUser loginUser = LoginHelper.getLoginUser(); - if (ObjectUtils.isNotEmpty(loginUser) && !loginUser.isAdmin()) { - return buildDataScopeFilter(loginUser, annotation.value(), where); + if (null != loginUser && !loginUser.isAdmin()) { + return buildDataScopeFilter(loginUser, dataPermission.value(), where); } } } @@ -134,20 +133,19 @@ public class DataPermissionHandlerImpl implements DataPermissionHandler { InExpression inExpression = new InExpression(); inExpression.setLeftExpression(buildColumn(tableAlias, DEPT_ID)); inExpression.setRightExpression(subSelect); - expression = - ObjectUtils.isNotEmpty(expression) ? new OrExpression(expression, inExpression) : inExpression; + expression = null != expression ? new OrExpression(expression, inExpression) : inExpression; } else if (DataScopeEnum.DEPT.equals(dataScope)) { // select t1.* from table as t1 where t1.`dept_id` = xxx; EqualsTo equalsTo = new EqualsTo(); equalsTo.setLeftExpression(buildColumn(tableAlias, DEPT_ID)); equalsTo.setRightExpression(new LongValue(user.getDeptId())); - expression = ObjectUtils.isNotEmpty(expression) ? new OrExpression(expression, equalsTo) : equalsTo; + expression = null != expression ? new OrExpression(expression, equalsTo) : equalsTo; } else if (DataScopeEnum.SELF.equals(dataScope)) { // select t1.* from table as t1 where t1.`create_user` = xxx; EqualsTo equalsTo = new EqualsTo(); equalsTo.setLeftExpression(buildColumn(tableAlias, CREATE_USER)); equalsTo.setRightExpression(new LongValue(user.getId())); - expression = ObjectUtils.isNotEmpty(expression) ? new OrExpression(expression, equalsTo) : equalsTo; + expression = null != expression ? new OrExpression(expression, equalsTo) : equalsTo; } else if (DataScopeEnum.CUSTOM.equals(dataScope)) { // select t1.* from table as t1 where t1.`dept_id` in (select `dept_id` from `sys_role_dept` where // `role_id` = xxx); @@ -165,11 +163,10 @@ public class DataPermissionHandlerImpl implements DataPermissionHandler { InExpression inExpression = new InExpression(); inExpression.setLeftExpression(buildColumn(tableAlias, DEPT_ID)); inExpression.setRightExpression(subSelect); - expression = - ObjectUtils.isNotEmpty(expression) ? new OrExpression(expression, inExpression) : inExpression; + expression = null != expression ? new OrExpression(expression, inExpression) : inExpression; } } - return ObjectUtils.isNotEmpty(where) ? new AndExpression(where, new Parenthesis(expression)) : expression; + return null != where ? new AndExpression(where, new Parenthesis(expression)) : expression; } /** diff --git a/continew-admin-common/src/main/java/top/charles7c/cnadmin/common/config/mybatis/MyBatisPlusMetaObjectHandler.java b/continew-admin-common/src/main/java/top/charles7c/cnadmin/common/config/mybatis/MyBatisPlusMetaObjectHandler.java index 410bb9b8..4c162758 100644 --- a/continew-admin-common/src/main/java/top/charles7c/cnadmin/common/config/mybatis/MyBatisPlusMetaObjectHandler.java +++ b/continew-admin-common/src/main/java/top/charles7c/cnadmin/common/config/mybatis/MyBatisPlusMetaObjectHandler.java @@ -54,7 +54,7 @@ public class MyBatisPlusMetaObjectHandler implements MetaObjectHandler { @Override public void insertFill(MetaObject metaObject) { try { - if (ObjectUtil.isNull(metaObject)) { + if (null == metaObject) { return; } @@ -88,7 +88,7 @@ public class MyBatisPlusMetaObjectHandler implements MetaObjectHandler { @Override public void updateFill(MetaObject metaObject) { try { - if (ObjectUtil.isNull(metaObject)) { + if (null == metaObject) { return; } @@ -124,7 +124,7 @@ public class MyBatisPlusMetaObjectHandler implements MetaObjectHandler { private void fillFieldValue(MetaObject metaObject, String fieldName, Object fillFieldValue, boolean isOverride) { if (metaObject.hasSetter(fieldName)) { Object fieldValue = metaObject.getValue(fieldName); - setFieldValByName(fieldName, fieldValue != null && !isOverride ? fieldValue : fillFieldValue, metaObject); + setFieldValByName(fieldName, null != fieldValue && !isOverride ? fieldValue : fillFieldValue, metaObject); } } } diff --git a/continew-admin-common/src/main/java/top/charles7c/cnadmin/common/handler/CrudRequestMappingHandlerMapping.java b/continew-admin-common/src/main/java/top/charles7c/cnadmin/common/handler/CrudRequestMappingHandlerMapping.java index 4755cf2c..cfb3f6d1 100644 --- a/continew-admin-common/src/main/java/top/charles7c/cnadmin/common/handler/CrudRequestMappingHandlerMapping.java +++ b/continew-admin-common/src/main/java/top/charles7c/cnadmin/common/handler/CrudRequestMappingHandlerMapping.java @@ -41,7 +41,7 @@ public class CrudRequestMappingHandlerMapping extends RequestMappingHandlerMappi @Override protected RequestMappingInfo getMappingForMethod(@NonNull Method method, @NonNull Class handlerType) { RequestMappingInfo requestMappingInfo = super.getMappingForMethod(method, handlerType); - if (requestMappingInfo == null) { + if (null == requestMappingInfo) { return null; } diff --git a/continew-admin-common/src/main/java/top/charles7c/cnadmin/common/model/vo/PageDataVO.java b/continew-admin-common/src/main/java/top/charles7c/cnadmin/common/model/vo/PageDataVO.java index f5b34161..7716e112 100644 --- a/continew-admin-common/src/main/java/top/charles7c/cnadmin/common/model/vo/PageDataVO.java +++ b/continew-admin-common/src/main/java/top/charles7c/cnadmin/common/model/vo/PageDataVO.java @@ -69,7 +69,7 @@ public class PageDataVO implements Serializable { * @return 分页信息 */ public static PageDataVO build(IPage page, Class targetClass) { - if (page == null) { + if (null == page) { return null; } PageDataVO pageDataVO = new PageDataVO<>(); @@ -88,7 +88,7 @@ public class PageDataVO implements Serializable { * @return 分页信息 */ public static PageDataVO build(IPage page) { - if (page == null) { + if (null == page) { return null; } PageDataVO pageDataVO = new PageDataVO<>(); diff --git a/continew-admin-common/src/main/java/top/charles7c/cnadmin/common/util/ExceptionUtils.java b/continew-admin-common/src/main/java/top/charles7c/cnadmin/common/util/ExceptionUtils.java index b272b7d6..84484560 100644 --- a/continew-admin-common/src/main/java/top/charles7c/cnadmin/common/util/ExceptionUtils.java +++ b/continew-admin-common/src/main/java/top/charles7c/cnadmin/common/util/ExceptionUtils.java @@ -46,7 +46,7 @@ public class ExceptionUtils { * 异常 */ public static void printException(Runnable runnable, Throwable throwable) { - if (throwable == null && runnable instanceof Future) { + if (null == throwable && runnable instanceof Future) { try { Future future = (Future)runnable; if (future.isDone()) { @@ -60,7 +60,7 @@ public class ExceptionUtils { Thread.currentThread().interrupt(); } } - if (throwable != null) { + if (null != throwable) { log.error(throwable.getMessage(), throwable); } } @@ -135,9 +135,9 @@ public class ExceptionUtils { public static T exToDefault(ExSupplier exSupplier, T defaultValue, Consumer exConsumer) { try { return exSupplier.get(); - } catch (Exception ex) { - if (exConsumer != null) { - exConsumer.accept(ex); + } catch (Exception e) { + if (null != exConsumer) { + exConsumer.accept(e); } return defaultValue; } diff --git a/continew-admin-common/src/main/java/top/charles7c/cnadmin/common/util/IpUtils.java b/continew-admin-common/src/main/java/top/charles7c/cnadmin/common/util/IpUtils.java index 8c43cac0..188c393a 100644 --- a/continew-admin-common/src/main/java/top/charles7c/cnadmin/common/util/IpUtils.java +++ b/continew-admin-common/src/main/java/top/charles7c/cnadmin/common/util/IpUtils.java @@ -91,7 +91,7 @@ public class IpUtils { } Ip2regionSearcher ip2regionSearcher = SpringUtil.getBean(Ip2regionSearcher.class); IpInfo ipInfo = ip2regionSearcher.memorySearch(ip); - if (ipInfo != null) { + if (null != ipInfo) { return ipInfo.getAddress(); } return null; diff --git a/continew-admin-common/src/main/java/top/charles7c/cnadmin/common/util/ServletUtils.java b/continew-admin-common/src/main/java/top/charles7c/cnadmin/common/util/ServletUtils.java index 6f1b8811..c184580c 100644 --- a/continew-admin-common/src/main/java/top/charles7c/cnadmin/common/util/ServletUtils.java +++ b/continew-admin-common/src/main/java/top/charles7c/cnadmin/common/util/ServletUtils.java @@ -65,7 +65,7 @@ public class ServletUtils { * @return 浏览器及其版本信息 */ public static String getBrowser(HttpServletRequest request) { - if (request == null) { + if (null == request) { return null; } UserAgent userAgent = UserAgentUtil.parse(request.getHeader("User-Agent")); diff --git a/continew-admin-common/src/main/java/top/charles7c/cnadmin/common/util/helper/LoginHelper.java b/continew-admin-common/src/main/java/top/charles7c/cnadmin/common/util/helper/LoginHelper.java index fd48d0f7..75dc13d5 100644 --- a/continew-admin-common/src/main/java/top/charles7c/cnadmin/common/util/helper/LoginHelper.java +++ b/continew-admin-common/src/main/java/top/charles7c/cnadmin/common/util/helper/LoginHelper.java @@ -54,7 +54,7 @@ public class LoginHelper { * 登录用户信息 */ public static void login(LoginUser loginUser) { - if (loginUser == null) { + if (null == loginUser) { return; } @@ -64,7 +64,7 @@ public class LoginHelper { loginUser.setLocation(IpUtils.getCityInfo(loginUser.getClientIp())); loginUser.setBrowser(ServletUtils.getBrowser(request)); LogContext logContext = LogContextHolder.get(); - loginUser.setLoginTime(logContext != null ? logContext.getCreateTime() : LocalDateTime.now()); + loginUser.setLoginTime(null != logContext ? logContext.getCreateTime() : LocalDateTime.now()); // 登录保存用户信息 StpUtil.login(loginUser.getId()); @@ -79,7 +79,7 @@ public class LoginHelper { */ public static LoginUser getLoginUser() { LoginUser loginUser = (LoginUser)SaHolder.getStorage().get(CacheConsts.LOGIN_USER_KEY); - if (loginUser != null) { + if (null != loginUser) { return loginUser; } loginUser = (LoginUser)StpUtil.getTokenSession().get(CacheConsts.LOGIN_USER_KEY); diff --git a/continew-admin-common/src/main/java/top/charles7c/cnadmin/common/util/helper/QueryHelper.java b/continew-admin-common/src/main/java/top/charles7c/cnadmin/common/util/helper/QueryHelper.java index 04720d86..82441487 100644 --- a/continew-admin-common/src/main/java/top/charles7c/cnadmin/common/util/helper/QueryHelper.java +++ b/continew-admin-common/src/main/java/top/charles7c/cnadmin/common/util/helper/QueryHelper.java @@ -60,7 +60,7 @@ public class QueryHelper { public static QueryWrapper build(Q query) { QueryWrapper queryWrapper = new QueryWrapper<>(); // 没有查询条件,直接返回 - if (query == null) { + if (null == query) { return queryWrapper; } @@ -90,7 +90,7 @@ public class QueryHelper { field.setAccessible(true); // 没有 @Query,直接返回 Query queryAnnotation = field.getAnnotation(Query.class); - if (queryAnnotation == null) { + if (null == queryAnnotation) { return; } diff --git a/continew-admin-common/src/main/java/top/charles7c/cnadmin/common/util/validate/Validator.java b/continew-admin-common/src/main/java/top/charles7c/cnadmin/common/util/validate/Validator.java index 9d0e1d0e..e2a3f955 100644 --- a/continew-admin-common/src/main/java/top/charles7c/cnadmin/common/util/validate/Validator.java +++ b/continew-admin-common/src/main/java/top/charles7c/cnadmin/common/util/validate/Validator.java @@ -47,7 +47,7 @@ public class Validator { * 异常类型 */ protected static void throwIfNull(Object obj, String message, Class exceptionType) { - throwIf(obj == null, message, exceptionType); + throwIf(null == obj, message, exceptionType); } /** @@ -61,7 +61,7 @@ public class Validator { * 异常类型 */ protected static void throwIfNotNull(Object obj, String message, Class exceptionType) { - throwIf(obj != null, message, exceptionType); + throwIf(null != obj, message, exceptionType); } /** @@ -219,7 +219,7 @@ public class Validator { */ protected static void throwIf(BooleanSupplier conditionSupplier, String message, Class exceptionType) { - if (conditionSupplier != null && conditionSupplier.getAsBoolean()) { + if (null != conditionSupplier && conditionSupplier.getAsBoolean()) { log.error(message); throw ReflectUtil.newInstance(exceptionType, message); } diff --git a/continew-admin-monitor/src/main/java/top/charles7c/cnadmin/monitor/interceptor/LogInterceptor.java b/continew-admin-monitor/src/main/java/top/charles7c/cnadmin/monitor/interceptor/LogInterceptor.java index 828a0fb5..c2e23d2f 100644 --- a/continew-admin-monitor/src/main/java/top/charles7c/cnadmin/monitor/interceptor/LogInterceptor.java +++ b/continew-admin-monitor/src/main/java/top/charles7c/cnadmin/monitor/interceptor/LogInterceptor.java @@ -91,7 +91,7 @@ public class LogInterceptor implements HandlerInterceptor { @NonNull Object handler, Exception e) { // 记录请求耗时及异常信息 LogDO logDO = this.logElapsedTimeAndException(); - if (logDO == null) { + if (null == logDO) { return; } @@ -127,7 +127,7 @@ public class LogInterceptor implements HandlerInterceptor { private LogDO logElapsedTimeAndException() { LogContext logContext = LogContextHolder.get(); try { - if (logContext != null) { + if (null != logContext) { LogDO logDO = new LogDO(); logDO.setCreateTime(logContext.getCreateTime()); logDO @@ -142,7 +142,7 @@ public class LogInterceptor implements HandlerInterceptor { } // 记录异常详情 Exception exception = logContext.getException(); - if (exception != null) { + if (null != exception) { logDO.setStatus(LogStatusEnum.FAILURE); logDO.setExceptionDetail(ExceptionUtil.stacktraceToString(exception, -1)); } @@ -169,16 +169,16 @@ public class LogInterceptor implements HandlerInterceptor { // 例如:@Tag(name = "部门管理") -> 部门管理 // (本框架代码规范)例如:@Tag(name = "部门管理 API") -> 部门管理 - if (classTag != null) { + if (null != classTag) { String name = classTag.name(); logDO .setModule(StrUtil.isNotBlank(name) ? name.replace("API", StringConsts.EMPTY).trim() : "请在该接口类上指定所属模块"); } // 例如:@Log(module = "部门管理") -> 部门管理 - if (classLog != null && StrUtil.isNotBlank(classLog.module())) { + if (null != classLog && StrUtil.isNotBlank(classLog.module())) { logDO.setModule(classLog.module()); } - if (methodLog != null && StrUtil.isNotBlank(methodLog.module())) { + if (null != methodLog && StrUtil.isNotBlank(methodLog.module())) { logDO.setModule(methodLog.module()); } } @@ -196,11 +196,11 @@ public class LogInterceptor implements HandlerInterceptor { Log methodLog = handlerMethod.getMethodAnnotation(Log.class); // 例如:@Operation(summary="新增部门") -> 新增部门 - if (methodOperation != null) { + if (null != methodOperation) { logDO.setDescription(StrUtil.blankToDefault(methodOperation.summary(), "请在该接口方法上指定日志描述")); } // 例如:@Log("新增部门") -> 新增部门 - if (methodLog != null && StrUtil.isNotBlank(methodLog.value())) { + if (null != methodLog && StrUtil.isNotBlank(methodLog.value())) { logDO.setDescription(methodLog.value()); } } @@ -227,7 +227,7 @@ public class LogInterceptor implements HandlerInterceptor { logDO.setLocation(IpUtils.getCityInfo(logDO.getClientIp())); logDO.setBrowser(ServletUtils.getBrowser(request)); logDO.setCreateUser(ObjectUtil.defaultIfNull(logDO.getCreateUser(), LoginHelper.getUserId())); - if (logDO.getCreateUser() == null && SysConsts.LOGIN_URI.equals(request.getRequestURI())) { + if (null == logDO.getCreateUser() && SysConsts.LOGIN_URI.equals(request.getRequestURI())) { LoginRequest loginRequest = JSONUtil.toBean(requestBody, LoginRequest.class); logDO.setCreateUser( ExceptionUtils.exToNull(() -> userService.getByUsername(loginRequest.getUsername()).getId())); @@ -291,7 +291,7 @@ public class LogInterceptor implements HandlerInterceptor { private String getRequestBody(HttpServletRequest request) { String requestBody = ""; ContentCachingRequestWrapper wrapper = WebUtils.getNativeRequest(request, ContentCachingRequestWrapper.class); - if (wrapper != null) { + if (null != wrapper) { requestBody = StrUtil.utf8Str(wrapper.getContentAsByteArray()); } return requestBody; @@ -308,7 +308,7 @@ public class LogInterceptor implements HandlerInterceptor { String responseBody = ""; ContentCachingResponseWrapper wrapper = WebUtils.getNativeResponse(response, ContentCachingResponseWrapper.class); - if (wrapper != null) { + if (null != wrapper) { responseBody = StrUtil.utf8Str(wrapper.getContentAsByteArray()); } return responseBody; @@ -340,22 +340,22 @@ public class LogInterceptor implements HandlerInterceptor { Log methodLog = handlerMethod.getMethodAnnotation(Log.class); // 3.1 如果接口方法上既没有 @Log 注解,也没有 @Operation 注解,则不记录系统日志 Operation methodOperation = handlerMethod.getMethodAnnotation(Operation.class); - if (methodLog == null && methodOperation == null) { + if (null == methodLog && null == methodOperation) { return false; } // 3.2 请求方式不要求记录且接口方法上没有 @Log 注解,则不记录系统日志 - if (methodLog == null && operationLogProperties.getExcludeMethods().contains(request.getMethod())) { + if (null == methodLog && operationLogProperties.getExcludeMethods().contains(request.getMethod())) { return false; } // 3.3 如果接口被隐藏,不记录系统日志 - if (methodOperation != null && methodOperation.hidden()) { + if (null != methodOperation && methodOperation.hidden()) { return false; } // 3.4 如果接口方法或类上有 @Log 注解,但是要求忽略该接口,则不记录系统日志 - if (methodLog != null && methodLog.ignore()) { + if (null != methodLog && methodLog.ignore()) { return false; } Log classLog = handlerMethod.getBeanType().getDeclaredAnnotation(Log.class); - return classLog == null || !classLog.ignore(); + return null == classLog || !classLog.ignore(); } } diff --git a/continew-admin-monitor/src/main/java/top/charles7c/cnadmin/monitor/service/impl/LogServiceImpl.java b/continew-admin-monitor/src/main/java/top/charles7c/cnadmin/monitor/service/impl/LogServiceImpl.java index 468d822a..2fec39de 100644 --- a/continew-admin-monitor/src/main/java/top/charles7c/cnadmin/monitor/service/impl/LogServiceImpl.java +++ b/continew-admin-monitor/src/main/java/top/charles7c/cnadmin/monitor/service/impl/LogServiceImpl.java @@ -83,7 +83,7 @@ public class LogServiceImpl implements LogService { PageDataVO pageDataVO = PageDataVO.build(page, OperationLogVO.class); // 填充数据(如果是查询个人操作日志,只查询一次用户信息即可) - if (query.getUid() != null) { + if (null != query.getUid()) { String nickname = ExceptionUtils.exToNull(() -> commonUserService.getNicknameById(query.getUid())); pageDataVO.getList().forEach(o -> o.setCreateUserString(nickname)); } else { @@ -150,7 +150,7 @@ public class LogServiceImpl implements LogService { */ private void fill(LogVO logVO) { Long createUser = logVO.getCreateUser(); - if (createUser == null) { + if (null == createUser) { return; } logVO.setCreateUserString(ExceptionUtils.exToNull(() -> commonUserService.getNicknameById(createUser))); diff --git a/continew-admin-system/src/main/java/top/charles7c/cnadmin/auth/config/satoken/SaTokenRedisDaoImpl.java b/continew-admin-system/src/main/java/top/charles7c/cnadmin/auth/config/satoken/SaTokenRedisDaoImpl.java index fff94441..4b103157 100644 --- a/continew-admin-system/src/main/java/top/charles7c/cnadmin/auth/config/satoken/SaTokenRedisDaoImpl.java +++ b/continew-admin-system/src/main/java/top/charles7c/cnadmin/auth/config/satoken/SaTokenRedisDaoImpl.java @@ -97,7 +97,7 @@ public class SaTokenRedisDaoImpl implements SaTokenDao { @Override public void setObject(String key, Object object, long timeout) { - if (timeout == 0 || timeout <= SaTokenDao.NOT_VALUE_EXPIRE) { + if (0 == timeout || timeout <= SaTokenDao.NOT_VALUE_EXPIRE) { return; } // 判断是否为永不过期 diff --git a/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/model/vo/UserVO.java b/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/model/vo/UserVO.java index 59cfa654..947f303e 100644 --- a/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/model/vo/UserVO.java +++ b/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/model/vo/UserVO.java @@ -103,7 +103,7 @@ public class UserVO extends BaseVO { } public String getPhone() { - if (phone == null) { + if (null == phone) { return null; } return DesensitizedUtil.mobilePhone(phone); diff --git a/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/service/impl/DeptServiceImpl.java b/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/service/impl/DeptServiceImpl.java index f2635abe..e29cc90b 100644 --- a/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/service/impl/DeptServiceImpl.java +++ b/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/service/impl/DeptServiceImpl.java @@ -153,7 +153,7 @@ public class DeptServiceImpl extends BaseServiceImpl