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
Metrics
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
framework
schbrain-parent
Commits
09c3c219
Commit
09c3c219
authored
Nov 12, 2023
by
liaozan
🏀
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Support remove by bizId
parent
d97dad96
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
16 deletions
+23
-16
starters/mybatis-spring-boot-starter/src/main/java/com/schbrain/framework/autoconfigure/mybatis/base/BaseService.java
...ain/framework/autoconfigure/mybatis/base/BaseService.java
+10
-16
starters/mybatis-spring-boot-starter/src/main/java/com/schbrain/framework/autoconfigure/mybatis/base/BaseServiceImpl.java
...framework/autoconfigure/mybatis/base/BaseServiceImpl.java
+13
-0
No files found.
starters/mybatis-spring-boot-starter/src/main/java/com/schbrain/framework/autoconfigure/mybatis/base/BaseService.java
View file @
09c3c219
...
...
@@ -10,15 +10,11 @@ public interface BaseService<T extends BaseEntity> extends IService<T> {
/**
* 根据 id 获取记录
*
* @param throwIfNotFound 未获取到记录时是否抛异常
*/
T
getById
(
Long
id
,
boolean
throwIfNotFound
);
/**
* 根据 id 获取记录
*
* @param notFoundSupplier 未获取到记录时的异常处理
*/
T
getById
(
Long
id
,
Supplier
<?
extends
RuntimeException
>
notFoundSupplier
);
...
...
@@ -29,15 +25,11 @@ public interface BaseService<T extends BaseEntity> extends IService<T> {
/**
* 根据 id 获取记录
*
* @param throwIfNotFound 未获取到记录时是否抛异常
*/
<
V
>
V
getById
(
Long
id
,
SFunction
<
T
,
V
>
column
,
boolean
throwIfNotFound
);
/**
* 根据 id 获取记录
*
* @param notFoundSupplier 未获取到记录时的异常处理
*/
<
V
>
V
getById
(
Long
id
,
SFunction
<
T
,
V
>
column
,
Supplier
<?
extends
RuntimeException
>
notFoundSupplier
);
...
...
@@ -58,15 +50,11 @@ public interface BaseService<T extends BaseEntity> extends IService<T> {
/**
* 根据业务主键获取记录
*
* @param throwsIfNotFound 未获取到记录时是否抛异常
*/
T
getByBizId
(
Object
bizId
,
boolean
throwsIfNotFound
);
/**
* 根据业务主键获取记录
*
* @param notFoundSupplier 未获取到记录时的异常处理
*/
T
getByBizId
(
Object
bizId
,
Supplier
<?
extends
RuntimeException
>
notFoundSupplier
);
...
...
@@ -77,15 +65,11 @@ public interface BaseService<T extends BaseEntity> extends IService<T> {
/**
* 根据业务主键获取记录
*
* @param throwsIfNotFound 未获取到记录时是否抛异常
*/
<
V
>
V
getByBizId
(
Object
bizId
,
SFunction
<
T
,
V
>
column
,
boolean
throwsIfNotFound
);
/**
* 根据业务主键获取记录
*
* @param notFoundSupplier 未获取到记录时的异常处理
*/
<
V
>
V
getByBizId
(
Object
bizId
,
SFunction
<
T
,
V
>
column
,
Supplier
<?
extends
RuntimeException
>
notFoundSupplier
);
...
...
@@ -129,4 +113,14 @@ public interface BaseService<T extends BaseEntity> extends IService<T> {
*/
boolean
updateBatchByIdsWithNull
(
Collection
<
T
>
entityList
,
int
batchSize
);
/**
* 根据业务主键删除
*/
<
K
>
boolean
removeByBizId
(
K
bizId
);
/**
* 根据业务主键删除
*/
<
K
>
boolean
removeBatchByBizIds
(
Collection
<
K
>
bizIds
);
}
starters/mybatis-spring-boot-starter/src/main/java/com/schbrain/framework/autoconfigure/mybatis/base/BaseServiceImpl.java
View file @
09c3c219
...
...
@@ -222,6 +222,19 @@ public class BaseServiceImpl<M extends BaseMapper<T>, T extends BaseEntity> exte
});
}
@Override
public
<
K
>
boolean
removeByBizId
(
K
bizId
)
{
return
update
().
eq
(
getBidColumnField
().
getColumnName
(),
bizId
).
remove
();
}
@Override
public
<
K
>
boolean
removeBatchByBizIds
(
Collection
<
K
>
bizIds
)
{
if
(
isEmpty
(
bizIds
))
{
return
false
;
}
return
update
().
in
(
getBidColumnField
().
getColumnName
(),
bizIds
).
remove
();
}
@Override
public
void
afterPropertiesSet
()
{
ReflectionUtils
.
doWithFields
(
entityClass
,
bizId
->
{
...
...
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