Commit f136166d authored by liaozan's avatar liaozan 🏀

Update mybatis getById method

parent 7d8819cb
......@@ -37,7 +37,7 @@ public class BaseServiceImpl<M extends BaseMapper<T>, T extends BaseEntity> exte
public T getById(Long id, boolean throwIfNotFound) {
Supplier<? extends RuntimeException> notFoundSupplier = null;
if (throwIfNotFound) {
notFoundSupplier = () -> new NoSuchRecordException(entityClass, id);
notFoundSupplier = () -> new NoSuchRecordException(entityClass);
}
return getById(id, notFoundSupplier);
}
......@@ -68,7 +68,7 @@ public class BaseServiceImpl<M extends BaseMapper<T>, T extends BaseEntity> exte
public T getByBizId(String bizId, boolean throwIfNotFound) {
Supplier<? extends RuntimeException> notFoundSupplier = null;
if (throwIfNotFound) {
notFoundSupplier = () -> new NoSuchRecordException(entityClass, bizId);
notFoundSupplier = () -> new NoSuchRecordException(entityClass);
}
return getByBizId(bizId, notFoundSupplier);
}
......
......@@ -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
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment