Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
Y
yzg-util
Project
Project
Details
Activity
Releases
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
YZG
yzg-util
Commits
e007f8e7
Commit
e007f8e7
authored
Jul 20, 2021
by
yanzg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改保存历史记录
parent
7371b706
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
3 deletions
+32
-3
BaseDaoImpl.java
...b/src/main/java/com/yanzuoguang/dao/impl/BaseDaoImpl.java
+22
-3
TableStruct.java
...b/src/main/java/com/yanzuoguang/dao/impl/TableStruct.java
+10
-0
No files found.
yzg-util-db/src/main/java/com/yanzuoguang/dao/impl/BaseDaoImpl.java
View file @
e007f8e7
...
...
@@ -9,7 +9,6 @@ import com.yanzuoguang.util.exception.CodeException;
import
com.yanzuoguang.util.helper.DateHelper
;
import
com.yanzuoguang.util.helper.StringHelper
;
import
com.yanzuoguang.util.vo.*
;
import
org.omg.CORBA.StringHolder
;
import
java.util.*
;
...
...
@@ -868,7 +867,16 @@ public abstract class BaseDaoImpl extends BaseDaoSql implements BaseDao {
}
catch
(
Exception
ex
)
{
throw
new
RuntimeException
(
"创建对象"
+
cls
.
getName
()
+
"出错"
,
ex
);
}
ObjectHelper
.
writeWithFrom
(
from
,
request
);
TableStruct
tableStruct
=
this
.
table
.
getTable
();
// 写入历史版本号
TableFieldVo
version
=
tableStruct
.
getVersion
();
if
(
version
!=
null
)
{
Object
hisVersion
=
ObjectHelper
.
get
(
from
,
version
.
inputName
);
ObjectHelper
.
writeWithFrom
(
from
,
request
);
ObjectHelper
.
set
(
from
,
version
.
inputName
,
hisVersion
);
}
else
{
ObjectHelper
.
writeWithFrom
(
from
,
request
);
}
return
this
.
create
(
from
);
}
else
{
ObjectHelper
.
writeWithFrom
(
from
,
request
);
...
...
@@ -884,7 +892,18 @@ public abstract class BaseDaoImpl extends BaseDaoSql implements BaseDao {
* @return 保存成功,返回保存的ID,保存失败,返回空值
*/
public
<
T
extends
Object
>
String
saveWith
(
Class
<
T
>
cls
,
String
sqlName
,
Object
request
)
{
T
from
=
this
.
queryFirst
(
cls
,
sqlName
,
request
);
if
(
request
instanceof
InitDao
)
{
((
InitDao
)
request
).
init
();
}
TableStruct
tableStruct
=
this
.
table
.
getTable
();
// 获取所有条件字段
MapRow
condition
=
new
MapRow
();
List
<
TableFieldVo
>
fields
=
tableStruct
.
getFields
(
DaoConst
.
FIELD_SAVE_WITH
);
for
(
TableFieldVo
field
:
fields
)
{
condition
.
put
(
field
.
inputName
,
ObjectHelper
.
get
(
request
,
field
.
inputName
));
}
// 查询历史数据
T
from
=
this
.
queryFirst
(
cls
,
sqlName
,
condition
);
return
saveFromCreate
(
cls
,
from
,
request
);
}
...
...
yzg-util-db/src/main/java/com/yanzuoguang/dao/impl/TableStruct.java
View file @
e007f8e7
...
...
@@ -373,6 +373,16 @@ public class TableStruct {
return
null
;
}
/**
* 获取某一列
*
* @param fieldType 字段类型
* @return 获取到的字段
*/
public
List
<
TableFieldVo
>
getFields
(
int
fieldType
)
{
return
getFieldActionList
(
fieldType
);
}
/**
* 通过表结构自动生成SQL语句
*
...
...
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