style: 优化 == 及 != 表达式格式
1.将 null 或常量值调整到符号左侧 2.将无特殊意义的方法判空写法改为表达式判断写法
This commit is contained in:
parent
94f88bad22
commit
487fa82306
@ -151,7 +151,7 @@ public abstract class BaseServiceImpl<M extends BaseMapper<T>, 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<T> entityList = baseMapper.selectList(queryWrapper);
|
||||
return BeanUtil.copyToList(entityList, targetClass);
|
||||
@ -168,7 +168,7 @@ public abstract class BaseServiceImpl<M extends BaseMapper<T>, 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<M extends BaseMapper<T>, 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<M extends BaseMapper<T>, T extends BaseDO,
|
||||
this.fill(detailVO);
|
||||
|
||||
Long updateUser = detailVO.getUpdateUser();
|
||||
if (updateUser == null) {
|
||||
if (null == updateUser) {
|
||||
return;
|
||||
}
|
||||
CommonUserService userService = SpringUtil.getBean(CommonUserService.class);
|
||||
|
@ -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))));
|
||||
}
|
||||
|
@ -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<BaseEnum<Integer, Strin
|
||||
@Override
|
||||
public WriteCellData<String> convertToExcelData(BaseEnum<Integer, String> value,
|
||||
ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) {
|
||||
if (ObjectUtil.isNull(value)) {
|
||||
if (null == value) {
|
||||
return new WriteCellData<>(StringConsts.EMPTY);
|
||||
}
|
||||
return new WriteCellData<>(value.getDescription());
|
||||
|
@ -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<Long> {
|
||||
@Override
|
||||
public WriteCellData<Object> 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);
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -69,7 +69,7 @@ public class PageDataVO<V> implements Serializable {
|
||||
* @return 分页信息
|
||||
*/
|
||||
public static <T, V> PageDataVO<V> build(IPage<T> page, Class<V> targetClass) {
|
||||
if (page == null) {
|
||||
if (null == page) {
|
||||
return null;
|
||||
}
|
||||
PageDataVO<V> pageDataVO = new PageDataVO<>();
|
||||
@ -88,7 +88,7 @@ public class PageDataVO<V> implements Serializable {
|
||||
* @return 分页信息
|
||||
*/
|
||||
public static <V> PageDataVO<V> build(IPage<V> page) {
|
||||
if (page == null) {
|
||||
if (null == page) {
|
||||
return null;
|
||||
}
|
||||
PageDataVO<V> pageDataVO = new PageDataVO<>();
|
||||
|
@ -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> T exToDefault(ExSupplier<T> exSupplier, T defaultValue, Consumer<Exception> 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;
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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"));
|
||||
|
@ -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);
|
||||
|
@ -60,7 +60,7 @@ public class QueryHelper {
|
||||
public static <Q, R> QueryWrapper<R> build(Q query) {
|
||||
QueryWrapper<R> 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;
|
||||
}
|
||||
|
||||
|
@ -47,7 +47,7 @@ public class Validator {
|
||||
* 异常类型
|
||||
*/
|
||||
protected static void throwIfNull(Object obj, String message, Class<? extends RuntimeException> 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<? extends RuntimeException> 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<? extends RuntimeException> exceptionType) {
|
||||
if (conditionSupplier != null && conditionSupplier.getAsBoolean()) {
|
||||
if (null != conditionSupplier && conditionSupplier.getAsBoolean()) {
|
||||
log.error(message);
|
||||
throw ReflectUtil.newInstance(exceptionType, message);
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
@ -83,7 +83,7 @@ public class LogServiceImpl implements LogService {
|
||||
PageDataVO<OperationLogVO> 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)));
|
||||
|
@ -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;
|
||||
}
|
||||
// 判断是否为永不过期
|
||||
|
@ -103,7 +103,7 @@ public class UserVO extends BaseVO {
|
||||
}
|
||||
|
||||
public String getPhone() {
|
||||
if (phone == null) {
|
||||
if (null == phone) {
|
||||
return null;
|
||||
}
|
||||
return DesensitizedUtil.mobilePhone(phone);
|
||||
|
@ -153,7 +153,7 @@ public class DeptServiceImpl extends BaseServiceImpl<DeptMapper, DeptDO, DeptVO,
|
||||
*/
|
||||
private boolean checkNameExists(String name, Long parentId, Long id) {
|
||||
return baseMapper.lambdaQuery().eq(DeptDO::getName, name).eq(DeptDO::getParentId, parentId)
|
||||
.ne(id != null, DeptDO::getId, id).exists();
|
||||
.ne(null != id, DeptDO::getId, id).exists();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -100,6 +100,6 @@ public class MenuServiceImpl extends BaseServiceImpl<MenuMapper, MenuDO, MenuVO,
|
||||
*/
|
||||
private boolean checkNameExists(String name, Long parentId, Long id) {
|
||||
return baseMapper.lambdaQuery().eq(MenuDO::getTitle, name).eq(MenuDO::getParentId, parentId)
|
||||
.ne(id != null, MenuDO::getId, id).exists();
|
||||
.ne(null != id, MenuDO::getId, id).exists();
|
||||
}
|
||||
}
|
||||
|
@ -189,7 +189,7 @@ public class RoleServiceImpl extends BaseServiceImpl<RoleMapper, RoleDO, RoleVO,
|
||||
* @return 是否存在
|
||||
*/
|
||||
private boolean checkNameExists(String name, Long id) {
|
||||
return baseMapper.lambdaQuery().eq(RoleDO::getName, name).ne(id != null, RoleDO::getId, id).exists();
|
||||
return baseMapper.lambdaQuery().eq(RoleDO::getName, name).ne(null != id, RoleDO::getId, id).exists();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -202,6 +202,6 @@ public class RoleServiceImpl extends BaseServiceImpl<RoleMapper, RoleDO, RoleVO,
|
||||
* @return 是否存在
|
||||
*/
|
||||
private boolean checkCodeExists(String code, Long id) {
|
||||
return baseMapper.lambdaQuery().eq(RoleDO::getCode, code).ne(id != null, RoleDO::getId, id).exists();
|
||||
return baseMapper.lambdaQuery().eq(RoleDO::getCode, code).ne(null != id, RoleDO::getId, id).exists();
|
||||
}
|
||||
}
|
||||
|
@ -175,7 +175,7 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, UserDO, UserVO,
|
||||
String avatarPath = localStorageProperties.getPath().getAvatar();
|
||||
File newAvatarFile = FileUtils.upload(avatarFile, avatarPath, false);
|
||||
CheckUtils.throwIfNull(newAvatarFile, "上传头像失败");
|
||||
assert newAvatarFile != null;
|
||||
assert null != newAvatarFile;
|
||||
|
||||
// 更新用户头像
|
||||
String newAvatar = newAvatarFile.getName();
|
||||
@ -266,7 +266,7 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, UserDO, UserVO,
|
||||
* @return 是否存在
|
||||
*/
|
||||
private boolean checkNameExists(String name, Long id) {
|
||||
return baseMapper.lambdaQuery().eq(UserDO::getUsername, name).ne(id != null, UserDO::getId, id).exists();
|
||||
return baseMapper.lambdaQuery().eq(UserDO::getUsername, name).ne(null != id, UserDO::getId, id).exists();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -279,7 +279,7 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, UserDO, UserVO,
|
||||
* @return 是否存在
|
||||
*/
|
||||
private boolean checkEmailExists(String email, Long id) {
|
||||
return baseMapper.lambdaQuery().eq(UserDO::getEmail, email).ne(id != null, UserDO::getId, id).exists();
|
||||
return baseMapper.lambdaQuery().eq(UserDO::getEmail, email).ne(null != id, UserDO::getId, id).exists();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -292,6 +292,6 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, UserDO, UserVO,
|
||||
* @return 是否存在
|
||||
*/
|
||||
private boolean checkPhoneExists(String phone, Long id) {
|
||||
return baseMapper.lambdaQuery().eq(UserDO::getPhone, phone).ne(id != null, UserDO::getId, id).exists();
|
||||
return baseMapper.lambdaQuery().eq(UserDO::getPhone, phone).ne(null != id, UserDO::getId, id).exists();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user