mirror of
https://gitee.com/best_handsome/mybatis-plus-join
synced 2025-07-11 00:02:22 +08:00
style: 简化代码
This commit is contained in:
parent
c8a21424af
commit
7a1afacfcb
@ -1,6 +1,7 @@
|
||||
package com.github.yulichang.test.util;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.DbType;
|
||||
import com.github.yulichang.wrapper.interfaces.DoSomething;
|
||||
import org.springframework.jdbc.BadSqlGrammarException;
|
||||
|
||||
import java.util.Arrays;
|
||||
@ -10,7 +11,7 @@ public class Throw {
|
||||
|
||||
public static void tryDo(DoSomething doSomething) {
|
||||
try {
|
||||
doSomething.doSomething();
|
||||
doSomething.doIt();
|
||||
} catch (BadSqlGrammarException e) {
|
||||
if (DbTypeUtil.getDbType() != DbType.H2) {
|
||||
throw e;
|
||||
@ -20,7 +21,7 @@ public class Throw {
|
||||
|
||||
public static void tryDo(DoSomething doSomething, DbType... ignore) {
|
||||
try {
|
||||
doSomething.doSomething();
|
||||
doSomething.doIt();
|
||||
} catch (BadSqlGrammarException e) {
|
||||
if (DbTypeUtil.getDbType() != DbType.H2 && Arrays.stream(ignore).noneMatch(n -> n == DbTypeUtil.getDbType())) {
|
||||
throw e;
|
||||
@ -30,13 +31,8 @@ public class Throw {
|
||||
|
||||
public static void tryDoIgnore(DoSomething doSomething) {
|
||||
try {
|
||||
doSomething.doSomething();
|
||||
doSomething.doIt();
|
||||
} catch (BadSqlGrammarException ignore) {
|
||||
}
|
||||
}
|
||||
|
||||
@FunctionalInterface
|
||||
public interface DoSomething {
|
||||
void doSomething();
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user