Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gjjs-bd-common
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
s_guodong
gjjs-bd-common
Commits
48a9eb4c
Commit
48a9eb4c
authored
Nov 21, 2023
by
s_guodong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化dbUpdate方法
parent
3d420a82
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
1 deletions
+35
-1
MyBatisDaoSession.java
...com/brilliance/mda/support/mybatis/MyBatisDaoSession.java
+35
-1
No files found.
gjjs-bd-mybatis-support/src/main/java/com/brilliance/mda/support/mybatis/MyBatisDaoSession.java
View file @
48a9eb4c
...
@@ -72,7 +72,7 @@ public class MyBatisDaoSession extends AbstractDaoSession implements IDaoSession
...
@@ -72,7 +72,7 @@ public class MyBatisDaoSession extends AbstractDaoSession implements IDaoSession
//定义mapper文件中的sql语句id
//定义mapper文件中的sql语句id
private
static
final
String
SQLID_INSERT
=
"insert"
;
private
static
final
String
SQLID_INSERT
=
"insert"
;
private
static
final
String
SQLID_UPDATE
=
"updateByPrimaryKey"
;
private
static
final
String
SQLID_UPDATE
=
"updateByPrimaryKey
Selective
"
;
private
static
final
String
SQLID_DELETE
=
"deleteByPrimaryKey"
;
private
static
final
String
SQLID_DELETE
=
"deleteByPrimaryKey"
;
private
static
final
String
SQLID_DELBYIDS
=
"deleteByIds"
;
private
static
final
String
SQLID_DELBYIDS
=
"deleteByIds"
;
private
static
final
String
SQLID_DYNCREAD
=
"dyncRead"
;
private
static
final
String
SQLID_DYNCREAD
=
"dyncRead"
;
...
@@ -125,6 +125,10 @@ public class MyBatisDaoSession extends AbstractDaoSession implements IDaoSession
...
@@ -125,6 +125,10 @@ public class MyBatisDaoSession extends AbstractDaoSession implements IDaoSession
@Override
@Override
public
<
T
extends
IModule
>
int
dbUpdate
(
T
module
)
{
public
<
T
extends
IModule
>
int
dbUpdate
(
T
module
)
{
boolean
b
=
checkAllPropertiesNull
(
module
);
if
(
b
)
{
return
0
;
}
if
(
isMultiDb
)
{
if
(
isMultiDb
)
{
String
moduleDB
=
MdaUtils
.
getModuleDB
(
module
);
String
moduleDB
=
MdaUtils
.
getModuleDB
(
module
);
DynamicDataSourceContextHolder
.
setDataSourceType
(
moduleDB
);
DynamicDataSourceContextHolder
.
setDataSourceType
(
moduleDB
);
...
@@ -644,4 +648,34 @@ public class MyBatisDaoSession extends AbstractDaoSession implements IDaoSession
...
@@ -644,4 +648,34 @@ public class MyBatisDaoSession extends AbstractDaoSession implements IDaoSession
private
void
setNoMoreRow
()
{
private
void
setNoMoreRow
()
{
MdaEnv
.
getContext
().
setErrorCode
(
Constants
.
NO_MORE_ROW
);
MdaEnv
.
getContext
().
setErrorCode
(
Constants
.
NO_MORE_ROW
);
}
}
/**
* 校验是否所有的属性都为null
*
* @return
*/
private
boolean
checkAllPropertiesNull
(
Object
obj
)
{
if
(
obj
==
null
)
{
return
true
;
}
Class
<?>
aClass
=
obj
.
getClass
();
Field
[]
declaredFields
=
aClass
.
getDeclaredFields
();
for
(
Field
field
:
declaredFields
)
{
String
name
=
field
.
getName
();
if
(
field
.
isAnnotationPresent
(
Ignore
.
class
)
||
"inr"
.
equals
(
name
))
{
continue
;
}
field
.
setAccessible
(
true
);
Object
o
=
null
;
try
{
o
=
field
.
get
(
obj
);
}
catch
(
IllegalAccessException
e
)
{
}
if
(
o
!=
null
)
{
return
false
;
}
}
return
true
;
}
}
}
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