From f136166d9b46a51c9524779e5b8811cf4fe93592 Mon Sep 17 00:00:00 2001 From: liaozan <378024053@qq.com> Date: Thu, 11 May 2023 02:15:33 +0800 Subject: [PATCH] Update mybatis getById method --- .../autoconfigure/mybatis/base/BaseServiceImpl.java | 4 ++-- .../mybatis/exception/NoSuchRecordException.java | 6 ++---- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/starters/mybatis-spring-boot-starter/src/main/java/com/schbrain/framework/autoconfigure/mybatis/base/BaseServiceImpl.java b/starters/mybatis-spring-boot-starter/src/main/java/com/schbrain/framework/autoconfigure/mybatis/base/BaseServiceImpl.java index 95e3d3a..a2c900e 100644 --- a/starters/mybatis-spring-boot-starter/src/main/java/com/schbrain/framework/autoconfigure/mybatis/base/BaseServiceImpl.java +++ b/starters/mybatis-spring-boot-starter/src/main/java/com/schbrain/framework/autoconfigure/mybatis/base/BaseServiceImpl.java @@ -37,7 +37,7 @@ public class BaseServiceImpl, T extends BaseEntity> exte public T getById(Long id, boolean throwIfNotFound) { Supplier notFoundSupplier = null; if (throwIfNotFound) { - notFoundSupplier = () -> new NoSuchRecordException(entityClass, id); + notFoundSupplier = () -> new NoSuchRecordException(entityClass); } return getById(id, notFoundSupplier); } @@ -68,7 +68,7 @@ public class BaseServiceImpl, T extends BaseEntity> exte public T getByBizId(String bizId, boolean throwIfNotFound) { Supplier notFoundSupplier = null; if (throwIfNotFound) { - notFoundSupplier = () -> new NoSuchRecordException(entityClass, bizId); + notFoundSupplier = () -> new NoSuchRecordException(entityClass); } return getByBizId(bizId, notFoundSupplier); } diff --git a/starters/mybatis-spring-boot-starter/src/main/java/com/schbrain/framework/autoconfigure/mybatis/exception/NoSuchRecordException.java b/starters/mybatis-spring-boot-starter/src/main/java/com/schbrain/framework/autoconfigure/mybatis/exception/NoSuchRecordException.java index 2831b3a..ae7f755 100644 --- a/starters/mybatis-spring-boot-starter/src/main/java/com/schbrain/framework/autoconfigure/mybatis/exception/NoSuchRecordException.java +++ b/starters/mybatis-spring-boot-starter/src/main/java/com/schbrain/framework/autoconfigure/mybatis/exception/NoSuchRecordException.java @@ -2,8 +2,6 @@ package com.schbrain.framework.autoconfigure.mybatis.exception; import com.schbrain.common.exception.BaseException; -import java.io.Serializable; - /** * @author liaozan * @since 2022/04/15 @@ -12,8 +10,8 @@ public class NoSuchRecordException extends BaseException { private static final long serialVersionUID = -2197824144318250175L; - public NoSuchRecordException(Class entityClass, Serializable id) { - super(String.format("No %s entity with id %s exists!", entityClass.getSimpleName(), id)); + public NoSuchRecordException(Class entityClass) { + super(String.format("No such %s entity exists!", entityClass.getSimpleName())); } } \ No newline at end of file -- GitLab