Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
schbrain-parent
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Package Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
panwangnan
schbrain-parent
Commits
f136166d
Commit
f136166d
authored
May 11, 2023
by
liaozan
🏀
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update mybatis getById method
parent
7d8819cb
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
4 additions
and
6 deletions
+4
-6
starters/mybatis-spring-boot-starter/src/main/java/com/schbrain/framework/autoconfigure/mybatis/base/BaseServiceImpl.java
...framework/autoconfigure/mybatis/base/BaseServiceImpl.java
+2
-2
starters/mybatis-spring-boot-starter/src/main/java/com/schbrain/framework/autoconfigure/mybatis/exception/NoSuchRecordException.java
...utoconfigure/mybatis/exception/NoSuchRecordException.java
+2
-4
No files found.
starters/mybatis-spring-boot-starter/src/main/java/com/schbrain/framework/autoconfigure/mybatis/base/BaseServiceImpl.java
View file @
f136166d
...
@@ -37,7 +37,7 @@ public class BaseServiceImpl<M extends BaseMapper<T>, T extends BaseEntity> exte
...
@@ -37,7 +37,7 @@ public class BaseServiceImpl<M extends BaseMapper<T>, T extends BaseEntity> exte
public
T
getById
(
Long
id
,
boolean
throwIfNotFound
)
{
public
T
getById
(
Long
id
,
boolean
throwIfNotFound
)
{
Supplier
<?
extends
RuntimeException
>
notFoundSupplier
=
null
;
Supplier
<?
extends
RuntimeException
>
notFoundSupplier
=
null
;
if
(
throwIfNotFound
)
{
if
(
throwIfNotFound
)
{
notFoundSupplier
=
()
->
new
NoSuchRecordException
(
entityClass
,
id
);
notFoundSupplier
=
()
->
new
NoSuchRecordException
(
entityClass
);
}
}
return
getById
(
id
,
notFoundSupplier
);
return
getById
(
id
,
notFoundSupplier
);
}
}
...
@@ -68,7 +68,7 @@ public class BaseServiceImpl<M extends BaseMapper<T>, T extends BaseEntity> exte
...
@@ -68,7 +68,7 @@ public class BaseServiceImpl<M extends BaseMapper<T>, T extends BaseEntity> exte
public
T
getByBizId
(
String
bizId
,
boolean
throwIfNotFound
)
{
public
T
getByBizId
(
String
bizId
,
boolean
throwIfNotFound
)
{
Supplier
<?
extends
RuntimeException
>
notFoundSupplier
=
null
;
Supplier
<?
extends
RuntimeException
>
notFoundSupplier
=
null
;
if
(
throwIfNotFound
)
{
if
(
throwIfNotFound
)
{
notFoundSupplier
=
()
->
new
NoSuchRecordException
(
entityClass
,
bizId
);
notFoundSupplier
=
()
->
new
NoSuchRecordException
(
entityClass
);
}
}
return
getByBizId
(
bizId
,
notFoundSupplier
);
return
getByBizId
(
bizId
,
notFoundSupplier
);
}
}
...
...
starters/mybatis-spring-boot-starter/src/main/java/com/schbrain/framework/autoconfigure/mybatis/exception/NoSuchRecordException.java
View file @
f136166d
...
@@ -2,8 +2,6 @@ package com.schbrain.framework.autoconfigure.mybatis.exception;
...
@@ -2,8 +2,6 @@ package com.schbrain.framework.autoconfigure.mybatis.exception;
import
com.schbrain.common.exception.BaseException
;
import
com.schbrain.common.exception.BaseException
;
import
java.io.Serializable
;
/**
/**
* @author liaozan
* @author liaozan
* @since 2022/04/15
* @since 2022/04/15
...
@@ -12,8 +10,8 @@ public class NoSuchRecordException extends BaseException {
...
@@ -12,8 +10,8 @@ public class NoSuchRecordException extends BaseException {
private
static
final
long
serialVersionUID
=
-
2197824144318250175L
;
private
static
final
long
serialVersionUID
=
-
2197824144318250175L
;
public
NoSuchRecordException
(
Class
<?>
entityClass
,
Serializable
id
)
{
public
NoSuchRecordException
(
Class
<?>
entityClass
)
{
super
(
String
.
format
(
"No
%s entity with id %s exists!"
,
entityClass
.
getSimpleName
(),
id
));
super
(
String
.
format
(
"No
such %s entity exists!"
,
entityClass
.
getSimpleName
()
));
}
}
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment