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
0c36017d
Commit
0c36017d
authored
Dec 03, 2019
by
yanzg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
接口文档的支持
parent
3ea8716c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
8 deletions
+27
-8
BaseDaoImpl.java
...b/src/main/java/com/yanzuoguang/dao/impl/BaseDaoImpl.java
+5
-1
BaseDaoSql.java
...db/src/main/java/com/yanzuoguang/dao/impl/BaseDaoSql.java
+17
-5
MessageDaoImpl.java
...main/java/com/yanzuoguang/mq/dao/impl/MessageDaoImpl.java
+5
-2
No files found.
yzg-util-db/src/main/java/com/yanzuoguang/dao/impl/BaseDaoImpl.java
View file @
0c36017d
...
@@ -22,13 +22,17 @@ import java.util.*;
...
@@ -22,13 +22,17 @@ import java.util.*;
*/
*/
public
abstract
class
BaseDaoImpl
extends
BaseDaoSql
implements
BaseDao
{
public
abstract
class
BaseDaoImpl
extends
BaseDaoSql
implements
BaseDao
{
@Override
protected
void
initExecute
(){
}
/**
/**
* 获取当前主键
* 获取当前主键
*
*
* @return
* @return
*/
*/
private
String
getIdentity
()
{
private
String
getIdentity
()
{
return
StringHelper
.
toString
(
this
.
db
.
queryCell
(
this
.
getClass
(),
"GET_KEY"
,
"SELECT @@IDENTITY"
));
return
StringHelper
.
toString
(
this
.
getDb
()
.
queryCell
(
this
.
getClass
(),
"GET_KEY"
,
"SELECT @@IDENTITY"
));
}
}
/**
/**
...
...
yzg-util-db/src/main/java/com/yanzuoguang/dao/impl/BaseDaoSql.java
View file @
0c36017d
...
@@ -35,7 +35,10 @@ public abstract class BaseDaoSql {
...
@@ -35,7 +35,10 @@ public abstract class BaseDaoSql {
* 数据库执行类
* 数据库执行类
*/
*/
@Resource
@Resource
protected
DbExecute
db
;
private
DbExecute
db
;
private
boolean
initSql
=
false
;
/**
/**
* 当前Dao的表结构SQL语句信息
* 当前Dao的表结构SQL语句信息
...
@@ -53,6 +56,10 @@ public abstract class BaseDaoSql {
...
@@ -53,6 +56,10 @@ public abstract class BaseDaoSql {
* @return
* @return
*/
*/
protected
DbExecute
getDb
()
{
protected
DbExecute
getDb
()
{
if
(
this
.
db
!=
null
&&
!
this
.
initSql
)
{
this
.
initExecute
();
this
.
initSql
=
true
;
}
return
db
;
return
db
;
}
}
...
@@ -78,6 +85,11 @@ public abstract class BaseDaoSql {
...
@@ -78,6 +85,11 @@ public abstract class BaseDaoSql {
}
}
}
}
/**
* 初始化执行
*/
protected
abstract
void
initExecute
();
/**
/**
* 注册SQL语句
* 注册SQL语句
*/
*/
...
@@ -159,7 +171,7 @@ public abstract class BaseDaoSql {
...
@@ -159,7 +171,7 @@ public abstract class BaseDaoSql {
protected
int
updateSql
(
SqlData
sqlData
,
Object
model
)
{
protected
int
updateSql
(
SqlData
sqlData
,
Object
model
)
{
List
<
Object
>
paras
=
new
ArrayList
<
Object
>();
List
<
Object
>
paras
=
new
ArrayList
<
Object
>();
String
sql
=
this
.
getQueryPara
(
paras
,
sqlData
,
model
);
String
sql
=
this
.
getQueryPara
(
paras
,
sqlData
,
model
);
int
ret
=
db
.
update
(
this
.
getClass
(),
sqlData
.
getName
(),
sql
,
paras
.
toArray
());
int
ret
=
this
.
getDb
()
.
update
(
this
.
getClass
(),
sqlData
.
getName
(),
sql
,
paras
.
toArray
());
this
.
onUpdateSql
(
model
);
this
.
onUpdateSql
(
model
);
return
ret
;
return
ret
;
}
}
...
@@ -231,7 +243,7 @@ public abstract class BaseDaoSql {
...
@@ -231,7 +243,7 @@ public abstract class BaseDaoSql {
List
<
Object
>
paras
=
new
ArrayList
<>();
List
<
Object
>
paras
=
new
ArrayList
<>();
String
sql
=
this
.
getQueryPara
(
paras
,
sqlData
,
model
);
String
sql
=
this
.
getQueryPara
(
paras
,
sqlData
,
model
);
// 查询数据
// 查询数据
db
.
query
(
this
.
getClass
(),
cls
,
handle
,
sqlData
.
getName
(),
sql
,
paras
.
toArray
());
this
.
getDb
()
.
query
(
this
.
getClass
(),
cls
,
handle
,
sqlData
.
getName
(),
sql
,
paras
.
toArray
());
}
}
/**
/**
...
@@ -740,7 +752,7 @@ public abstract class BaseDaoSql {
...
@@ -740,7 +752,7 @@ public abstract class BaseDaoSql {
}
}
// 查询数据
// 查询数据
Object
ret
=
db
.
queryCell
(
this
.
getClass
(),
sqlName
,
sql
,
paras
);
Object
ret
=
this
.
getDb
()
.
queryCell
(
this
.
getClass
(),
sqlName
,
sql
,
paras
);
// 写入缓存
// 写入缓存
this
.
cacheList
.
put
(
cacheKey
,
ret
);
this
.
cacheList
.
put
(
cacheKey
,
ret
);
...
@@ -770,7 +782,7 @@ public abstract class BaseDaoSql {
...
@@ -770,7 +782,7 @@ public abstract class BaseDaoSql {
}
}
// 查询数据
// 查询数据
List
<
T
>
ret
=
db
.
query
(
this
.
getClass
(),
cls
,
sqlName
,
sql
,
paras
);
List
<
T
>
ret
=
this
.
getDb
()
.
query
(
this
.
getClass
(),
cls
,
sqlName
,
sql
,
paras
);
// 写入缓存
// 写入缓存
this
.
cacheList
.
put
(
cacheKey
,
ret
);
this
.
cacheList
.
put
(
cacheKey
,
ret
);
...
...
yzg-util-mq/src/main/java/com/yanzuoguang/mq/dao/impl/MessageDaoImpl.java
View file @
0c36017d
...
@@ -47,10 +47,13 @@ public class MessageDaoImpl extends BaseDaoImpl implements MessageDao {
...
@@ -47,10 +47,13 @@ public class MessageDaoImpl extends BaseDaoImpl implements MessageDao {
"INNER JOIN ( SELECT * FROM Queue_Message WHERE (HandleTime IS NULL OR HandleTime < NOW()) "
+
"INNER JOIN ( SELECT * FROM Queue_Message WHERE (HandleTime IS NULL OR HandleTime < NOW()) "
+
"ORDER BY HandleTime ASC,MessageId ASC {LIMIT} ) AS b ON a.MessageId = b.MessageId "
+
"ORDER BY HandleTime ASC,MessageId ASC {LIMIT} ) AS b ON a.MessageId = b.MessageId "
+
"SET a.BatchId = ?,a.HandleTime=DATE_ADD(NOW(),INTERVAL 5 MINUTE) "
,
"batchId"
);
"SET a.BatchId = ?,a.HandleTime=DATE_ADD(NOW(),INTERVAL 5 MINUTE) "
,
"batchId"
);
}
List
<
MapRow
>
tables
=
this
.
db
.
query
(
MessageDaoImpl
.
class
,
"QUERY_TABLE_SQL"
,
QUERY_TABLE_SQL
);
@Override
protected
void
initExecute
()
{
List
<
MapRow
>
tables
=
this
.
getDb
().
query
(
MessageDaoImpl
.
class
,
"QUERY_TABLE_SQL"
,
QUERY_TABLE_SQL
);
if
(
tables
.
isEmpty
())
{
if
(
tables
.
isEmpty
())
{
this
.
db
.
update
(
MessageDaoImpl
.
class
,
"CREATE_TABLE_SQL"
,
CREATE_TABLE_SQL
);
this
.
getDb
()
.
update
(
MessageDaoImpl
.
class
,
"CREATE_TABLE_SQL"
,
CREATE_TABLE_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